/* vonmath — design system v0.
 * Mobile-first: base rules target phones (320px+).
 * @media (min-width: 640px)  -> large phones / portrait tablets
 * @media (min-width: 960px)  -> landscape tablets / small laptops
 * @media (min-width: 1200px) -> desktop
 * Touch targets ≥ 44x44 px (WCAG 2.5.5 / Apple HIG).
 */

:root {
    --vm-bg: #f7f9fc;
    --vm-surface: #ffffff;
    --vm-surface-2: #f1f4fa;
    --vm-text: #1a1f2c;
    --vm-muted: #5b6577;
    --vm-border: #e3e7ef;
    --vm-primary: #2962ff;
    --vm-primary-hover: #1e4fd1;
    --vm-danger: #d93636;
    --vm-success: #1f9c5b;

    /* Spacing scale (multiples of 4px). Use these, not magic numbers. */
    --vm-s-1: 4px;
    --vm-s-2: 8px;
    --vm-s-3: 12px;
    --vm-s-4: 16px;
    --vm-s-5: 24px;
    --vm-s-6: 32px;
    --vm-s-7: 48px;
    --vm-s-8: 64px;

    --vm-radius: 12px;
    --vm-radius-sm: 8px;
    --vm-shadow: 0 1px 2px rgba(20, 30, 50, 0.04), 0 8px 24px rgba(20, 30, 50, 0.06);

    /* Min size for any tappable control. */
    --vm-tap: 44px;
}

@media (prefers-color-scheme: dark) {
    /* Reserved for v1. For now we ship light-mode only so we don't ship a half-finished palette. */
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--vm-bg);
    color: var(--vm-text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body {
    /* iOS safe-area for notched devices. */
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

a { color: var(--vm-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { max-width: 100%; height: auto; display: block; }

/* ---------------- Shell + nav ---------------- */

.vm-shell {
    min-height: 100vh;
    min-height: 100dvh; /* avoids mobile-browser URL-bar resize jank */
    display: flex;
    flex-direction: column;
}

.vm-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--vm-s-3);
    padding: var(--vm-s-3) var(--vm-s-4);
    background: var(--vm-surface);
    border-bottom: 1px solid var(--vm-border);
    padding-top: max(var(--vm-s-3), env(safe-area-inset-top));
}
.vm-brand {
    font-weight: 700;
    font-size: 1.125rem; /* 18px */
    letter-spacing: -0.01em;
    color: var(--vm-text);
}
.vm-brand .vm-brand-dot { color: var(--vm-primary); }
.vm-nav-actions {
    display: flex;
    gap: var(--vm-s-2);
    align-items: center;
    min-width: 0;
}
.vm-nav-actions > span {
    /* email truncates on small screens instead of pushing the button off */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 18ch;
}

@media (min-width: 640px) {
    .vm-nav { padding: var(--vm-s-4) var(--vm-s-5); }
    .vm-brand { font-size: 1.25rem; }
    .vm-nav-actions > span { max-width: none; }
}

/* ---------------- Main + cards ---------------- */

.vm-main {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: var(--vm-s-5) var(--vm-s-4);
    padding-bottom: max(var(--vm-s-5), env(safe-area-inset-bottom));
}

@media (min-width: 640px) {
    .vm-main { padding: var(--vm-s-6) var(--vm-s-5); }
}

.vm-card {
    background: var(--vm-surface);
    border: 1px solid var(--vm-border);
    border-radius: var(--vm-radius);
    box-shadow: var(--vm-shadow);
    padding: var(--vm-s-5);
    width: 100%;
    max-width: 420px;
}
.vm-card h1 {
    font-size: clamp(1.375rem, 1.2rem + 1vw, 1.5rem);
    margin: 0 0 var(--vm-s-1);
    line-height: 1.2;
}
.vm-card .vm-sub {
    color: var(--vm-muted);
    margin: 0 0 var(--vm-s-5);
    font-size: 0.875rem;
}

@media (min-width: 640px) {
    .vm-card { padding: var(--vm-s-6); }
}

/* ---------------- Forms ---------------- */

.vm-field { margin-bottom: var(--vm-s-3); display: flex; flex-direction: column; gap: var(--vm-s-1); }
.vm-field label { font-size: 0.8125rem; color: var(--vm-muted); font-weight: 500; }
.vm-field input,
.vm-field select,
.vm-field textarea {
    padding: 12px 14px;
    min-height: var(--vm-tap);
    border: 1px solid var(--vm-border);
    border-radius: var(--vm-radius-sm);
    font-size: 16px; /* 16px+ prevents iOS Safari zoom-on-focus */
    background: var(--vm-surface);
    color: var(--vm-text);
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
    font-family: inherit;
}
.vm-field input:focus,
.vm-field select:focus,
.vm-field textarea:focus {
    outline: none;
    border-color: var(--vm-primary);
    box-shadow: 0 0 0 3px rgba(41, 98, 255, 0.18);
}

/* ---------------- Buttons ---------------- */

.vm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--vm-s-2);
    padding: 10px 16px;
    min-height: var(--vm-tap);
    border: 1px solid transparent;
    border-radius: var(--vm-radius-sm);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.05s;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
}
.vm-btn:active { transform: scale(0.98); }
.vm-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(41, 98, 255, 0.35);
}
.vm-btn-primary { background: var(--vm-primary); color: #fff; }
.vm-btn-primary:hover { background: var(--vm-primary-hover); text-decoration: none; }
.vm-btn-ghost { background: transparent; color: var(--vm-text); border-color: var(--vm-border); }
.vm-btn-ghost:hover { background: var(--vm-surface-2); text-decoration: none; }
.vm-btn-block { display: flex; width: 100%; }

/* ---------------- Misc primitives ---------------- */

.vm-divider {
    display: flex; align-items: center;
    gap: var(--vm-s-3);
    color: var(--vm-muted);
    font-size: 0.75rem;
    margin: var(--vm-s-5) 0;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.vm-divider::before, .vm-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--vm-border);
}

.vm-error {
    color: var(--vm-danger);
    font-size: 0.8125rem;
    min-height: 18px;
    margin: var(--vm-s-1) 0 0;
}
.vm-success { color: var(--vm-success); font-size: 0.8125rem; min-height: 18px; margin: var(--vm-s-1) 0 0; }

.vm-footnote {
    margin-top: var(--vm-s-5);
    text-align: center;
    color: var(--vm-muted);
    font-size: 0.8125rem;
}

/* ---------------- Hero (landing) ---------------- */

.vm-hero {
    max-width: 720px;
    text-align: center;
    padding: var(--vm-s-6) var(--vm-s-4);
}
.vm-hero h1 {
    /* Fluid: 30px on phone, up to 56px on desktop. */
    font-size: clamp(1.875rem, 1.25rem + 3.2vw, 3.5rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin: 0 0 var(--vm-s-4);
}
.vm-hero p {
    font-size: clamp(1rem, 0.92rem + 0.4vw, 1.125rem);
    color: var(--vm-muted);
    margin: 0 0 var(--vm-s-6);
}
.vm-hero-actions {
    display: flex;
    gap: var(--vm-s-3);
    justify-content: center;
    flex-wrap: wrap;
}
.vm-hero-actions .vm-btn { min-width: 160px; }

@media (min-width: 640px) {
    .vm-hero { padding: var(--vm-s-7) var(--vm-s-5); }
}

/* ---------------- Dashboard ---------------- */

.vm-dash {
    width: 100%;
    max-width: 880px;
}
.vm-dash-header { margin-bottom: var(--vm-s-5); }
.vm-dash-header h1 {
    font-size: clamp(1.5rem, 1.3rem + 1vw, 1.875rem);
    margin: 0 0 var(--vm-s-1);
    line-height: 1.2;
}
.vm-dash-header p { color: var(--vm-muted); margin: 0; font-size: 0.9375rem; }

.vm-profile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)); /* 2-up on phones */
    gap: var(--vm-s-3);
}
@media (min-width: 640px) {
    .vm-profile-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: var(--vm-s-4);
    }
}

.vm-profile-card {
    background: var(--vm-surface);
    border: 1px solid var(--vm-border);
    border-radius: var(--vm-radius);
    padding: var(--vm-s-4);
    text-align: center;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
    .vm-profile-card:hover { transform: translateY(-2px); box-shadow: var(--vm-shadow); }
}
.vm-profile-card:active { transform: scale(0.98); }
.vm-profile-avatar { font-size: 2.5rem; line-height: 1; margin-bottom: var(--vm-s-2); }
.vm-profile-name { font-weight: 600; font-size: 0.9375rem; }
.vm-profile-grade { color: var(--vm-muted); font-size: 0.8125rem; margin-top: var(--vm-s-1); }

@media (min-width: 640px) {
    .vm-profile-avatar { font-size: 3rem; }
    .vm-profile-name { font-size: 1rem; }
}

.vm-profile-card.vm-add {
    color: var(--vm-muted);
    border-style: dashed;
    background: transparent;
    box-shadow: none;
}
.vm-profile-card.vm-add:hover { color: var(--vm-primary); border-color: var(--vm-primary); }

/* ---------------- Dialog (modal) ---------------- */

dialog {
    border: 1px solid var(--vm-border);
    border-radius: var(--vm-radius);
    padding: 0;
    max-width: 420px;
    width: calc(100% - 32px);
    box-shadow: var(--vm-shadow);
    background: var(--vm-surface);
    color: inherit;
}
dialog::backdrop {
    background: rgba(20, 30, 50, 0.4);
    backdrop-filter: blur(2px);
}

