/* RevoPlan design system.
   Tokens are lifted from the marketing site (revoplan.ai) so app.revoplan.ai reads as the same product.
   See docs/brand/design-language.md. Use tokens, never raw hex, in components. */

/* ---------- fonts (self-hosted, same files as the marketing site) ---------- */
@font-face {
    font-family: "Inter";
    src: url("/fonts/inter.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

@font-face {
    font-family: "Space Grotesk";
    src: url("/fonts/space-grotesk.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

/* ---------- tokens ---------- */
:root {
    --background: 216 45.5% 97.8%;
    --foreground: 215 27.9% 16.9%;
    --card: 0 0% 100%;
    --primary: 215.6 59.8% 42%;
    --primary-foreground: 0 0% 100%;
    --muted: 216 45.5% 96%;
    --muted-foreground: 215 18% 42%;
    --accent: 215.8 64.7% 57.8%;
    --destructive: 0 84% 60%;
    --success: 152 52% 34%;
    --border: 216 30% 89%;
    --ring: 215.6 59.8% 42%;
    --revo-deep: 215 40% 10%;
    --revo-cyan: 214.1 86.2% 71.6%;
    --revo-surface: 216 32% 91%;

    --font-display: "Space Grotesk", system-ui, sans-serif;
    --font-sans: "Inter", system-ui, -apple-system, sans-serif;

    --radius: 0.75rem;
    --radius-sm: 0.5rem;
    --measure: 64ch;

    --step--1: 0.8125rem;
    --step-0: 0.9375rem;
    --step-1: 1.125rem;
    --step-2: 1.5rem;
    --step-3: clamp(1.75rem, 1.4rem + 1.6vw, 2.25rem);
    --step-4: clamp(2.25rem, 1.6rem + 3vw, 3.5rem);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--step-0);
    line-height: 1.6;
    color: hsl(var(--foreground));
    background: hsl(var(--background));
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 500;
    line-height: 1.12;
    letter-spacing: -0.02em;
    margin: 0 0 0.5em;
    text-wrap: balance;
}

h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-2); letter-spacing: -0.01em; }

p { margin: 0 0 1rem; max-width: var(--measure); }

a { color: hsl(var(--primary)); text-underline-offset: 0.2em; }
a:hover { color: hsl(var(--accent)); }

img { max-width: 100%; display: block; }

:where(a, button, input, select, textarea):focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

.lede { font-size: var(--step-1); color: hsl(var(--muted-foreground)); }
.muted { color: hsl(var(--muted-foreground)); }
.small { font-size: var(--step--1); }
.stack > * + * { margin-top: var(--gap, 1rem); }
.center-text { text-align: center; }

/* ---------- layout ---------- */
.shell { width: min(100% - 2.5rem, 68rem); margin-inline: auto; }
.shell--narrow { width: min(100% - 2.5rem, 42rem); }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: hsl(var(--background) / 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid hsl(var(--border));
}

.topbar__inner {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    min-height: 4rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.375rem;
    letter-spacing: -0.02em;
    color: hsl(var(--foreground));
    text-decoration: none;
}

.brand img { width: 2.5rem; height: 2.5rem; border-radius: 0.5rem; }

.brand--lg { font-size: 1.625rem; gap: 0.875rem; }
.brand--lg img { width: 3rem; height: 3rem; }
.topbar__spacer { margin-left: auto; }

.topbar__user {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--step--1);
    color: hsl(var(--muted-foreground));
}

.site-footer {
    border-top: 1px solid hsl(var(--border));
    margin-top: 5rem;
    padding: 2rem 0 3rem;
    font-size: var(--step--1);
    color: hsl(var(--muted-foreground));
}

.site-footer__inner { display: flex; flex-wrap: wrap; gap: 0.75rem 2rem; align-items: center; }
.site-footer nav { display: flex; gap: 1.5rem; margin-left: auto; }
.site-footer a { color: inherit; text-decoration: none; }
.site-footer a:hover { color: hsl(var(--primary)); }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6875rem 1.25rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.btn--primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn--primary:hover { background: hsl(var(--primary) / 0.9); color: hsl(var(--primary-foreground)); }

.btn--secondary {
    background: hsl(var(--card));
    border-color: hsl(var(--border));
    color: hsl(var(--foreground));
}
.btn--secondary:hover { border-color: hsl(var(--primary) / 0.45); color: hsl(var(--foreground)); }

.btn--ghost { background: transparent; color: hsl(var(--foreground)); padding-inline: 0.5rem; }
.btn--ghost:hover { color: hsl(var(--primary)); }

.btn--block { width: 100%; }
.btn--lg { padding: 0.875rem 1.5rem; font-size: var(--step-1); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; pointer-events: none; }

.btn__icon { width: 1.125rem; height: 1.125rem; flex: none; }

/* ---------- surfaces ---------- */
.panel {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 1.75rem;
}

.panel--flush { padding: 0; overflow: hidden; }

.divider { border: 0; border-top: 1px solid hsl(var(--border)); margin: 1.75rem 0; }

.rule-label {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: hsl(var(--muted-foreground));
    font-size: var(--step--1);
}
.rule-label::before, .rule-label::after {
    content: "";
    flex: 1;
    border-top: 1px solid hsl(var(--border));
}

/* ---------- forms ---------- */
.field { margin-bottom: 1.125rem; }

.field label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: var(--step--1);
    font-weight: 500;
}

.field input, .field select, .field textarea {
    width: 100%;
    padding: 0.6875rem 0.875rem;
    font: inherit;
    color: hsl(var(--foreground));
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-sm);
    transition: border-color 150ms ease;
}

.field input:hover { border-color: hsl(var(--primary) / 0.35); }
.field input::placeholder { color: hsl(var(--muted-foreground) / 0.7); }

.field__hint { margin: 0.375rem 0 0; font-size: var(--step--1); color: hsl(var(--muted-foreground)); }
.field__error { margin: 0.375rem 0 0; font-size: var(--step--1); color: hsl(var(--destructive)); }
.field--invalid input { border-color: hsl(var(--destructive)); }

.field-row { display: flex; gap: 0.75rem; }
.field-row .field { flex: 1; }

/* one box per digit, for the mobile code */
.code-input {
    display: flex;
    gap: 0.625rem;
}
.code-input input {
    width: 3rem;
    height: 3.5rem;
    padding: 0;
    text-align: center;
    font-family: var(--font-display);
    font-size: 1.5rem;
    letter-spacing: 0;
}

/* ---------- notices ---------- */
.notice {
    display: flex;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border: 1px solid hsl(var(--border));
    border-left-width: 3px;
    border-radius: var(--radius-sm);
    background: hsl(var(--card));
    font-size: var(--step--1);
}

.notice p { margin: 0; }
.notice--info { border-left-color: hsl(var(--accent)); }
.notice--working { border-left-color: hsl(var(--accent)); background: hsl(var(--muted)); }
.notice--error { border-left-color: hsl(var(--destructive)); }
.notice--success { border-left-color: hsl(var(--success)); }

/* ---------- auth split ---------- */
.auth {
    display: grid;
    grid-template-columns: 1fr;
    min-height: 100dvh;
}

.auth__form {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2.5rem clamp(1.25rem, 6vw, 4rem);
}

.auth__form-inner { width: min(100%, 24rem); margin-inline: auto; }
.auth__heading { margin-bottom: 1.75rem; }
.auth__heading h1 { font-size: var(--step-3); margin-bottom: 0.25rem; }
.auth__heading p { margin: 0; color: hsl(var(--muted-foreground)); }

.auth__aside {
    display: none;
    position: relative;
    padding: 1.25rem;
    background: hsl(var(--revo-deep));
}

.auth__aside-card {
    position: relative;
    height: 100%;
    border-radius: calc(var(--radius) * 1.5);
    overflow: hidden;
    background: hsl(var(--revo-deep));
}

.auth__aside img { width: 100%; height: 100%; object-fit: cover; opacity: 0.85; }

.auth__aside figcaption {
    position: absolute;
    inset: auto 0 0 0;
    padding: 2.5rem;
    background: linear-gradient(to top, hsl(var(--revo-deep)) 10%, hsl(var(--revo-deep) / 0.2) 65%, transparent);
    color: hsl(0 0% 100%);
    font-family: var(--font-display);
    font-size: var(--step-2);
    line-height: 1.25;
    letter-spacing: -0.015em;
    padding-right: 28%;
    text-wrap: balance;
}

.auth__footer { margin-top: 1.75rem; font-size: var(--step--1); color: hsl(var(--muted-foreground)); }

@media (min-width: 62rem) {
    /* Image left, form right. The form keeps DOM order so it comes first on mobile. */
    .auth { grid-template-columns: 1.05fr 1fr; }
    .auth__aside { display: block; grid-area: 1 / 1; }
    .auth__form { grid-area: 1 / 2; }
}

/* ---------- landing ---------- */
.hero { padding: clamp(3rem, 7vw, 6rem) 0 0; }

.hero__grid {
    display: grid;
    gap: 2rem;
    grid-template-columns: 1fr;
    align-items: end;
}

.hero h1 { margin-bottom: 0; max-width: 18ch; }
.hero p { font-size: var(--step-1); color: hsl(var(--muted-foreground)); max-width: 42ch; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }
.hero__note { margin: 0.875rem 0 0; font-size: var(--step--1); color: hsl(var(--muted-foreground)); }

@media (min-width: 62rem) {
    .hero__grid { grid-template-columns: 1.35fr 1fr; gap: 4rem; }
    .hero__side { padding-bottom: 0.5rem; }
}

.hero__figure {
    margin-top: clamp(2.5rem, 5vw, 4rem);
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    overflow: hidden;
    background: hsl(var(--revo-surface));
}

.steps { margin-top: clamp(3rem, 6vw, 5rem); }

.steps__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0;
    counter-reset: step;
}

.steps__list li {
    counter-increment: step;
    padding: 1.5rem 0;
    border-top: 1px solid hsl(var(--border));
    display: grid;
    gap: 0.25rem 1.5rem;
    grid-template-columns: 2.5rem 1fr;
    align-items: baseline;
}

.steps__list li::before {
    content: counter(step);
    font-family: var(--font-display);
    font-size: var(--step-1);
    color: hsl(var(--accent));
}

.steps__list h3 { margin: 0; font-size: var(--step-1); }
.steps__list p { margin: 0; grid-column: 2; color: hsl(var(--muted-foreground)); }

/* ---------- dashboard ---------- */
.dash { padding: clamp(2rem, 4vw, 3.5rem) 0; }

.dash__header {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 2rem;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.dash__header h1 { font-size: var(--step-3); margin: 0; }

.trial {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 1fr;
    align-items: center;
    padding: 1.75rem;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--card));
}

.trial__count { display: flex; align-items: baseline; gap: 0.625rem; }

.trial__days {
    font-family: var(--font-display);
    font-size: clamp(3.5rem, 9vw, 5rem);
    font-weight: 500;
    line-height: 0.9;
    letter-spacing: -0.04em;
    color: hsl(var(--primary));
}

.trial__unit { font-size: var(--step-1); color: hsl(var(--muted-foreground)); }
.trial__body p { margin: 0 0 0.75rem; }

.trial__meter {
    height: 4px;
    border-radius: 2px;
    background: hsl(var(--revo-surface));
    overflow: hidden;
    margin-top: 1rem;
}

.trial__meter span { display: block; height: 100%; background: hsl(var(--accent)); }

@media (min-width: 48rem) {
    .trial { grid-template-columns: auto 1fr auto; }
}

.tiles {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    margin-top: 1.5rem;
}

.tile {
    padding: 1.25rem 1.375rem;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--card));
}

.tile h3 { font-size: var(--step-0); font-family: var(--font-sans); font-weight: 600; margin-bottom: 0.25rem; }
.tile p { margin: 0; font-size: var(--step--1); color: hsl(var(--muted-foreground)); }

/* ---------- onboarding choice cards ---------- */
.choices { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }

.choice input { position: absolute; opacity: 0; pointer-events: none; }

.choice span {
    display: block;
    padding: 1rem 1.125rem;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-sm);
    background: hsl(var(--card));
    cursor: pointer;
    transition: border-color 150ms ease, background-color 150ms ease;
}

.choice span:hover { border-color: hsl(var(--primary) / 0.45); }

.choice input:checked + span {
    border-color: hsl(var(--primary));
    background: hsl(var(--muted));
}

.choice input:focus-visible + span { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }

/* ---------- progress through onboarding ---------- */
.progress { display: flex; gap: 0.375rem; margin-bottom: 2rem; }
.progress span { height: 3px; flex: 1; border-radius: 2px; background: hsl(var(--revo-surface)); }
.progress span[data-done] { background: hsl(var(--primary)); }

@media (prefers-reduced-motion: reduce) {
    * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---------- step flow ---------- */
.step[hidden] { display: none !important; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin-bottom: 1rem;
    font-size: var(--step--1);
    color: hsl(var(--muted-foreground));
    text-decoration: none;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}
.back-link:hover { color: hsl(var(--primary)); }

.identity-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
    padding: 0.375rem 0.75rem 0.375rem 0.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid hsl(var(--border));
    border-radius: 999px;
    background: hsl(var(--card));
    font-size: var(--step--1);
}
.identity-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity-chip button {
    border: 0;
    background: none;
    padding: 0;
    font: inherit;
    color: hsl(var(--primary));
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

/* ---------- inputs with affordances ---------- */
.input-wrap { position: relative; display: flex; align-items: stretch; }

.input-wrap input { flex: 1; }

.input-prefix {
    display: inline-flex;
    align-items: center;
    padding: 0 0.75rem;
    border: 1px solid hsl(var(--border));
    border-right: 0;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
    font-variant-numeric: tabular-nums;
}
.input-wrap:has(.input-prefix) input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.input-action {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: none;
    padding: 0.25rem 0.5rem;
    font: inherit;
    font-size: var(--step--1);
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    border-radius: var(--radius-sm);
}
.input-action:hover { color: hsl(var(--primary)); }

.field[data-state="valid"] input { border-color: hsl(var(--success) / 0.6); }
.field[data-state="invalid"] input { border-color: hsl(var(--destructive)); }

/* ---------- password strength ---------- */
.strength { margin-top: 0.625rem; }

.strength__bars { display: flex; gap: 0.25rem; }

.strength__bars i {
    height: 3px;
    flex: 1;
    border-radius: 2px;
    background: hsl(var(--revo-surface));
    transition: background-color 150ms ease;
}

.strength[data-score="1"] .strength__bars i:nth-child(-n+1) { background: hsl(var(--destructive)); }
.strength[data-score="2"] .strength__bars i:nth-child(-n+2) { background: hsl(38 92% 50%); }
.strength[data-score="3"] .strength__bars i:nth-child(-n+3) { background: hsl(var(--accent)); }
.strength[data-score="4"] .strength__bars i { background: hsl(var(--success)); }

.strength__label { margin: 0.375rem 0 0; font-size: var(--step--1); color: hsl(var(--muted-foreground)); }

.checklist { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; gap: 0.25rem; }

.checklist li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--step--1);
    color: hsl(var(--muted-foreground));
}

.checklist li::before {
    content: "";
    width: 0.875rem;
    height: 0.875rem;
    border-radius: 50%;
    border: 1.5px solid hsl(var(--border));
    flex: none;
}

.checklist li[data-met]::before {
    border-color: hsl(var(--success));
    background: hsl(var(--success)) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 6.3 4.8 8.6 9.5 3.9'/%3E%3C/svg%3E") center/0.75rem no-repeat;
}
.checklist li[data-met] { color: hsl(var(--foreground)); }

/* ---------- button loading ---------- */
.btn[data-loading] { position: relative; color: transparent !important; pointer-events: none; }

.btn[data-loading]::after {
    content: "";
    position: absolute;
    width: 1.125rem;
    height: 1.125rem;
    border: 2px solid hsl(0 0% 100% / 0.45);
    border-top-color: hsl(0 0% 100%);
    border-radius: 50%;
    animation: spin 700ms linear infinite;
}

.btn--secondary[data-loading]::after { border-color: hsl(var(--border)); border-top-color: hsl(var(--primary)); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- resend countdown ---------- */
.resend { color: hsl(var(--muted-foreground)); }
.resend[data-waiting] { pointer-events: none; opacity: 0.65; }

/* ---------- consent ---------- */
.consent {
    display: flex;
    gap: 0.625rem;
    align-items: flex-start;
    margin: 1.25rem 0 1rem;
    font-size: var(--step--1);
    color: hsl(var(--muted-foreground));
    cursor: pointer;
}

.consent input {
    flex: none;
    width: 1.125rem;
    height: 1.125rem;
    margin-top: 0.125rem;
    accent-color: hsl(var(--primary));
}

.consent a { color: hsl(var(--primary)); }

.cf-turnstile { margin-bottom: 1rem; }

/* ==========================================================================
   task-10: sign-in / sign-up fit and hierarchy
   Scoped to .auth (Views/Account/SignIn.cshtml, SignUp.cshtml, Views/Shared/_AuthLayout.cshtml)
   so the shared .field/.rule-label/.cf-turnstile rules above stay untouched for every other page
   that uses them (Settings, onboarding, ...). Only the vertical rhythm changes here - type sizes
   are barely touched, spacing does the work.
   ========================================================================== */

/* Own vertical rhythm instead of centering an unbounded stack: pulling padding down first is what
   actually stops the page scrolling at 1920x1080 / 1440x900, browser chrome included. */
.auth__form { padding-block: clamp(1rem, 4.5vh, 2.5rem); }

.auth .brand--lg { margin-bottom: clamp(1rem, 3vh, 1.75rem); }

.auth__heading { margin-bottom: 1.125rem; }
.auth__heading h1 { font-size: clamp(1.5rem, 1.2rem + 1.1vw, 1.875rem); }

.auth .rule-label { margin: 1.125rem 0; }

.auth .field { margin-bottom: 0.8125rem; }

.auth .cf-turnstile { margin-bottom: 0.75rem; }

.auth .consent { margin: 1rem 0 0.875rem; }

/* "Already have an account? / New to RevoPlan?" - was small grey subtext (easy to miss); now a
   bordered, full-contrast block so it reads as the second action on the screen, not a footnote. */
.auth__switch {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 0.875rem;
    margin-top: 1.25rem;
    padding: 0.8125rem 1.125rem;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-sm);
    background: hsl(var(--muted));
    font-size: var(--step--1);
    color: hsl(var(--foreground));
}

.auth__switch a {
    font-weight: 600;
    color: hsl(var(--primary));
    white-space: nowrap;
    text-decoration: none;
}

.auth__switch a:hover { color: hsl(var(--accent)); }

/* Short laptop lids and browser chrome eat real estate before the OS-reported viewport ever does -
   tighten one notch further under that height instead of letting the page scroll. */
@media (max-height: 800px) {
    .auth__form { padding-block: 0.875rem; }
    .auth .brand--lg { margin-bottom: 0.875rem; }
    .auth__heading { margin-bottom: 0.875rem; }
    .auth .rule-label { margin: 0.875rem 0; }
}

/* ---------- error pages ---------- */
.error-page { padding-block: clamp(2rem, 10vh, 6rem); }

.error-page__code {
    font-family: var(--font-display);
    font-size: clamp(3rem, 2rem + 4vw, 5rem);
    font-weight: 500;
    line-height: 1;
    letter-spacing: -0.04em;
    color: hsl(var(--revo-surface));
    margin: 0 0 0.5rem;
}

.error-page__actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2rem; }
.error-page__help { margin-top: 2rem; }
