/* The design system: tokens first, then the reset, then the primitives every
   screen is built out of.

   There used to be no system here. Twenty-five distinct font sizes, fifteen
   border radii and spacing on every integer from one to eighteen - which is
   what happens when each screen is styled on its own and none of them are
   styled against each other. The result read as fine print: eighty of the
   hundred and thirty size declarations were eleven pixels or smaller, and one
   was seven.

   So sizes come from a scale, space comes from a four-pixel grid, and there is
   one accent colour. A value that is not in this file is a value somebody has
   to justify. */

:root {
    /* ---------------------------------------------------------------- type */
    /* Seven steps. Anything between two of them is a decision to argue with,
       not a decision to make. --text-2xs is for tracked-out uppercase labels
       and nothing else; body copy starts at --text-sm. */
    /* Below the scale on purpose, and used in exactly one place: a photo
       credit laid over the picture it belongs to, where anything larger takes
       the picture. Not for interface text. */
    --text-credit: 9px;
    --text-2xs: 11px;
    --text-xs: 13px;
    --text-sm: 15px;
    --text-md: 17px;
    --text-lg: 22px;
    --text-xl: 28px;
    --text-2xl: 40px;

    --leading-flat: 1;
    --leading-tight: 1.18;
    --leading-snug: 1.38;
    --leading-normal: 1.55;

    /* Tighter as the type gets bigger, which is how optical sizing works when
       the typeface has none. */
    --tracking-hero: -0.035em;
    --tracking-tight: -0.02em;
    --tracking-normal: 0;
    --tracking-label: 0.07em;

    --weight-normal: 400;
    --weight-medium: 500;
    --weight-semi: 600;
    --weight-bold: 700;

    /* --------------------------------------------------------------- space */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --space-8: 64px;
    --space-9: 96px;

    /* -------------------------------------------------------------- radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 22px;
    --radius-full: 999px;

    /* --------------------------------------------------------------- colour */
    /* One accent. Everything else is ink on paper, and the semantic colours
       are reserved for saying something is wrong - never for decoration. */
    --ink: #16211e;
    --ink-2: #4a5a54;
    --ink-3: #78877f;
    --ink-inverse: #ffffff;

    --paper: #ffffff;
    --canvas: #f6f7f5;
    --canvas-2: #eef1ed;
    --canvas-3: #e4e9e4;

    --line: #e4e8e4;
    --line-strong: #d0d8d2;

    --fern: #1f5b47;
    --fern-hover: #17452f;
    --fern-tint: #eaf1ec;
    --fern-tint-2: #d8e6dc;

    /* State only. */
    --alert: #a1382a;
    --alert-tint: #fbeeeb;
    --caution: #8a5a13;
    --caution-tint: #fdf4e5;
    --calm: #2c6076;
    --calm-tint: #eaf2f5;

    /* ------------------------------------------------------------ elevation */
    --shadow-1: 0 1px 2px rgba(20, 40, 32, 0.05);
    --shadow-2: 0 1px 2px rgba(20, 40, 32, 0.04), 0 6px 16px rgba(20, 40, 32, 0.06);
    --shadow-3: 0 2px 6px rgba(20, 40, 32, 0.05), 0 18px 44px rgba(20, 40, 32, 0.12);
    --shadow-4: 0 4px 10px rgba(20, 40, 32, 0.06), 0 32px 72px rgba(20, 40, 32, 0.18);

    /* -------------------------------------------------------------- motion */
    --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --dur-1: 120ms;
    --dur-2: 200ms;
    --dur-3: 320ms;

    /* -------------------------------------------------------------- layout */
    --topbar-h: 60px;
    --rail-w: 268px;
    --assistant-w: 396px;
    --page-max: 1200px;

    /* --------------------------------------------------------------- scrim */
    --scrim: rgba(14, 30, 24, 0.4);

    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
    color: var(--ink);
    background: var(--canvas);
    font-synthesis: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Compatibility aliases. The old names are still spelled out across seven
   stylesheets and twenty scripts; pointing them at the new roles means the
   system lands everywhere at once instead of one file at a time. */
:root {
    --ink-soft: var(--ink-2);
    --muted: var(--ink-3);
    --white: var(--paper);
    --fern-deep: var(--fern-hover);
    --fern-soft: var(--fern-tint);
    --blue: var(--calm);
    --blue-soft: var(--calm-tint);
    --warning-ink: var(--alert);
    --shadow-sm: var(--shadow-2);
    --shadow-md: var(--shadow-3);
    --shadow-lg: var(--shadow-4);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-width: 320px;
    background: var(--canvas);
    color: var(--ink);
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

button, textarea, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
textarea { resize: vertical; }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* One focus ring, everywhere, and never removed - only redrawn. */
:where(button, textarea, select, input, a, [tabindex]):focus-visible {
    outline: 2px solid var(--fern);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

h1, h2, h3, h4 {
    margin-top: 0;
    color: var(--ink);
    text-wrap: pretty;
    letter-spacing: var(--tracking-tight);
    line-height: var(--leading-tight);
    font-weight: var(--weight-semi);
}
h1 { font-size: var(--text-xl); letter-spacing: var(--tracking-hero); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-md); }
h4 { font-size: var(--text-sm); }

p { text-wrap: pretty; }

.app-shell { min-height: 100vh; }

.legal-page {
    min-height: 100vh;
    padding: var(--space-6) clamp(var(--space-4), 4vw, var(--space-7)) var(--space-8);
    background: var(--paper);
}

.legal-header {
    max-width: 820px;
    margin: 0 auto var(--space-7);
}

.legal-document {
    max-width: 820px;
    margin: 0 auto;
    color: var(--ink);
}

.legal-document h1 {
    margin-bottom: var(--space-5);
}

.legal-document p {
    margin: 0 0 var(--space-4);
    color: var(--ink-2);
}

.legal-document strong {
    color: var(--ink);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ------------------------------------------------------------------- brand */

.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    border: 0;
    background: none;
    padding: 0;
    color: var(--ink);
    text-decoration: none;
    text-align: left;
}
.brand-mark,
.loading-mark,
.ai-orb {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-md);
    color: var(--ink-inverse);
    background: var(--fern);
    flex: none;
}
.brand-name {
    font-size: var(--text-sm);
    font-weight: var(--weight-semi);
    letter-spacing: var(--tracking-tight);
}

/* ----------------------------------------------------------------- buttons */
/* Four roles, three sizes. A button that is none of these is a button that has
   not decided what it is. */

.btn,
.primary-button,
.secondary-button,
.quiet-button,
.assistant-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 40px;
    padding: 0 var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--text-xs);
    font-weight: var(--weight-semi);
    letter-spacing: var(--tracking-normal);
    white-space: nowrap;
    transition: background var(--dur-1) var(--ease),
                border-color var(--dur-1) var(--ease),
                color var(--dur-1) var(--ease),
                box-shadow var(--dur-1) var(--ease);
}

.btn-lg { min-height: 48px; padding: 0 var(--space-5); font-size: var(--text-sm); }
.btn-sm { min-height: 32px; padding: 0 var(--space-3); font-size: var(--text-xs); }

.primary-button,
.assistant-button {
    border: 1px solid var(--fern);
    background: var(--fern);
    color: var(--ink-inverse);
}
.primary-button:hover:not(:disabled),
.assistant-button:hover:not(:disabled) {
    background: var(--fern-hover);
    border-color: var(--fern-hover);
}

.secondary-button {
    border: 1px solid var(--line-strong);
    background: var(--paper);
    color: var(--ink);
}
.secondary-button:hover:not(:disabled) {
    border-color: var(--ink-3);
    background: var(--canvas);
}

.quiet-button {
    border: 1px solid transparent;
    background: transparent;
    color: var(--ink-2);
}
.quiet-button:hover:not(:disabled) {
    background: var(--canvas-2);
    color: var(--ink);
}

.text-button,
.btn-link {
    border: 0;
    background: none;
    padding: var(--space-2) 0;
    color: var(--ink-2);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
}
.text-button:hover, .btn-link:hover { color: var(--ink); }

.icon-button {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid transparent;
    background: transparent;
    border-radius: var(--radius-md);
    flex: none;
    font-size: var(--text-md);
    line-height: var(--leading-flat);
    color: var(--ink-3);
    transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.icon-button:hover { background: var(--canvas-2); color: var(--ink); }

.primary-button:disabled,
.secondary-button:disabled,
.quiet-button:disabled,
.btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* ------------------------------------------------------------------ inputs */

.field {
    width: 100%;
    min-height: 44px;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: var(--paper);
    color: var(--ink);
    font-size: var(--text-sm);
}
.field:focus {
    border-color: var(--fern);
    outline: 0;
    box-shadow: 0 0 0 3px var(--fern-tint-2);
}
.field::placeholder { color: var(--ink-3); }

/* --------------------------------------------------------------- text bits */

.eyebrow,
.section-kicker {
    display: block;
    margin: 0;
    font-size: var(--text-2xs);
    font-weight: var(--weight-semi);
    letter-spacing: var(--tracking-label);
    line-height: var(--leading-snug);
    text-transform: uppercase;
    color: var(--ink-3);
}
.eyebrow { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--fern); }
.section-kicker { margin-bottom: var(--space-2); }

.meta { color: var(--ink-3); font-size: var(--text-xs); }

/* --------------------------------------------------------------- overlays */
/* Every modal in the app uses this pair, so they open the same way and close
   the same way. */

.overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: var(--space-5);
    background: var(--scrim);
    animation: overlay-in var(--dur-2) var(--ease) both;
}
.overlay-panel {
    width: min(560px, 100%);
    max-height: min(86vh, 760px);
    display: flex;
    flex-direction: column;
    padding: var(--space-5);
    border-radius: var(--radius-xl);
    background: var(--paper);
    box-shadow: var(--shadow-4);
    animation: panel-in var(--dur-3) var(--ease-out) both;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes panel-in {
    from { opacity: 0; transform: translateY(10px) scale(0.985); }
    to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------- scrollbars */
/* Thin and out of the way, so a scrolling rail beside a scrolling canvas does
   not read as two competing pieces of furniture. */

.scroll-quiet { scrollbar-width: thin; scrollbar-color: var(--canvas-3) transparent; }
.scroll-quiet::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll-quiet::-webkit-scrollbar-track { background: transparent; }
.scroll-quiet::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    border-radius: var(--radius-full);
    background: var(--canvas-3);
    background-clip: content-box;
}
.scroll-quiet:hover::-webkit-scrollbar-thumb { background: var(--line-strong); background-clip: content-box; }
