/* Design tokens — the one --pt-* source for portal and Refresh. Fonts load from each app's fonts.css. */

/* ===== Tokens ===== */
:root {
    /* Brand font stacks; Refresh uses DM Sans for text and display figures. */
    --pt-font-display: "Moret", Georgia, serif;
    --pt-font-body: "DM Sans", ui-sans-serif, system-ui, sans-serif;
    --pt-font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
    --pt-white: #ffffff;
    --pt-cosmic-fog: #f7f3f2;
    --pt-lunar-dust: #e2dedd;
    --pt-crater-shadow: #4b4c51;
    --pt-steel-gray: #727779;
    --pt-polished-steel: #b5bbbf;
    --pt-graphite-core: #222326;
    --pt-deep-void: #121314;
    --pt-rocket-flame: #ed6033;
    --pt-galactic-seafoam: #5dc6ad;
    --pt-solar-gold: #ffae00;
    --pt-atmosphere-blue: #5da3c6;
    --pt-voyager-purple: #895dc6;
    --pt-red-alert: #e13d33;
    --pt-ink-on-flame-20: #b24321;
    --pt-ink-on-seafoam-20: #1f6e5d;
    --pt-ink-on-gold-20: #b06e00;
    --pt-ink-on-blue-20: #2f6680;
    --pt-ink-on-purple-20: #5b3b92;
    --pt-ink-on-red-20: #a2231c;
    --pt-rocket-flame-hover: #d95428;
    --pt-red-alert-hover: #c9352b;
    --pt-rocket-flame-20: rgba(237,96,51,0.2);
    --pt-galactic-seafoam-20: rgba(93,198,173,0.2);
    --pt-solar-gold-20: rgba(255,174,0,0.2);
    --pt-atmosphere-blue-20: rgba(93,163,198,0.2);
    --pt-voyager-purple-20: rgba(137,93,198,0.2);
    --pt-red-alert-20: rgba(225,61,51,0.2);

    --pt-bg: var(--pt-cosmic-fog);
    --pt-surface: var(--pt-white);
    --pt-border: var(--pt-lunar-dust);
    --pt-fg: var(--pt-graphite-core);
    --pt-fg-muted: var(--pt-steel-gray);
    --surface-muted: #f0eceb;
    --sidebar-w: 248px;
    /* Height of the bottom bars (sidebar footer + edit-page save bar) — shared so
       the two stay aligned along the bottom edge. */
    --bottom-bar-h: 65px;
    /* The data table's head and pager are one band height, so the table is bracketed
       by matching rails. Tall enough for a 32px pager button, which is what stops the
       pager collapsing to a thin strip when a result set fits on one page. */
    --table-band-h: 48px;

    --pt-radius-xs: 4px;
    --pt-radius-sm: 8px;
    --pt-radius-md: 16px;
    --pt-radius-lg: 24px;
    /* Portal modal sheet; Refresh stops at lg. */
    --pt-radius-xl: 32px;
    --pt-radius-pill: 1000px;

    /* Spacing — 8pt grid, name = multiplier of 4. Micro-alignment below 4px stays
       raw (1–3px is optical nudging, not layout).
       12 is the one half-step, and it is deliberate: the brand scale (4/8/16/24/32/
       48/64/96) is written for marketing surfaces, and dense CRUD rows need a step
       between 8 and 16 — it carries nav rows, tab padding and chip internals.
       20 and 40 were also off the brand scale but earned nothing, so they are gone.
       The 20px sidebar icon rail survives as calc(space-2 + space-3) at its one
       call site, where it is a rail measurement rather than a rhythm step. */
    --pt-space-1: 4px;
    --pt-space-2: 8px;
    --pt-space-3: 12px;
    --pt-space-4: 16px;
    --pt-space-6: 24px;
    --pt-space-8: 32px;
    --pt-space-12: 48px;
    --pt-space-16: 64px;
    --pt-space-24: 96px;

    /* Type presets — brand scale, base 14. Size and leading are paired: set
       `font-size: var(--pt-text-sm); line-height: var(--pt-leading-sm);`
       together. Leadings are 4px multiples so text sits on the grid. */
    --pt-text-2xs: 11px;     --pt-leading-2xs: 16px;  /* eyebrows, micro-labels */
    --pt-text-xs: 12px;      --pt-leading-xs: 16px;   /* meta, table sublines */
    --pt-text-sm: 14px;      --pt-leading-sm: 20px;   /* body / UI default */
    --pt-text-md: 16px;      --pt-leading-md: 24px;   /* emphasized body, inputs */
    --pt-text-lg: 20px;      --pt-leading-lg: 28px;   /* section titles */
    --pt-text-xl: 24px;      --pt-leading-xl: 32px;   /* page titles */
    --pt-text-2xl: 32px;     --pt-leading-2xl: 40px;  /* hero titles */
    --pt-text-display: 44px; --pt-leading-display: 48px;
    /* Portal icon sizes (hero and dropzone glyphs); no paired leading. */
    --pt-text-3xl: 40px;
    --pt-text-4xl: 56px;
    /* Mono renders optically larger than DM Sans, so code gets its own step off the ladder. */
    --pt-text-code: 13px;    --pt-leading-code: 20px; /* diffs, code */
    /* Multi-paragraph reading text; 14px UI text takes --pt-leading-sm instead. */
    --pt-leading-prose: 1.6;
    /* Ratio leadings for portal display and body copy. */
    --pt-leading-tight: 1.05;
    --pt-leading-snug: 1.2;
    --pt-leading-body: 1.5;

    /* Type roles — the weight and tracking half of the ramp: a size preset plus a weight. */
    /* Titles: page 2xl/strong/tight, section lg/strong, card md/strong. */
    /* Text: value sm/value, body sm/regular, meta xs/regular/muted, label 2xs/strong/caps/muted. */
    /* Figures use the display size; code uses mono at its own 13/20 step. */
    --pt-weight-regular: 400;
    --pt-weight-value: 500;
    --pt-weight-strong: 600;
    /* Not a role of its own — the emphasis a handful of totals and success labels take. */
    --pt-weight-bold: 700;
    /* Caps tracking is what every uppercase micro-label wears; tight reins in the two largest sizes. */
    --pt-track-caps: 0.1em;
    --pt-track-tight: -0.01em;

    /* Exits and small popovers sit between instant and base; without --pt-dur-fast
       every exit in the app hand-typed its own 150/180/200ms. */
    --pt-dur-instant: 80ms;
    --pt-dur-fast: 160ms;
    --pt-dur-base: 240ms;
    /* Portal draw and pop animations (check mark, badge). */
    --pt-dur-slow: 400ms;
    --pt-ease-paper: cubic-bezier(0.2, 0.7, 0.2, 1);
    /* Portal eases: typewriter and push drive the fee strike-through, settle drives draws and pops. */
    --pt-ease-typewriter: cubic-bezier(0.6, 0.0, 0.4, 1);
    --pt-ease-push: cubic-bezier(0.8, 0.0, 0.2, 1);
    --pt-ease-settle: cubic-bezier(0.4, 0.0, 0.2, 1);
    /* iOS-like curve for edge-anchored panels (the columns drawer). */
    --pt-ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

    --pt-focus-ring: 0 0 0 2px var(--pt-bg), 0 0 0 4px var(--pt-graphite-core);
    /* Brand-colored ring for the portal switch control. */
    --pt-focus-ring-accent: 0 0 0 2px var(--pt-bg), 0 0 0 4px var(--pt-rocket-flame);
    --pt-scrim: rgba(18, 19, 20, 0.55);
    /* Hover for controls sitting on an unknown surface (a tinted toast, a colored
       card). --surface-muted is opaque and would punch a grey hole in the tint. */
    --pt-hover-veil: rgba(0, 0, 0, 0.06);

    /* The brand is flat: depth comes from color, never shadow, and there is no
       elevation scale to reach for. Floating surfaces separate themselves with a
       border, a scrim, or a change of surface color. The two shadow tokens that
       used to live here were removed — the modal and palette that used them both
       sit on --pt-scrim, which already outweighs any shadow. */

    /* Illustrative icons in empty states — deliberately off the 16/20/24 UI ladder,
       because these are pictures rather than controls. One size, named once. */
    --pt-icon-empty: 40px;
    /* Solid high-contrast tile (company logo, processing chip) — inverts in dark. */
    --pt-contrast-bg: var(--pt-graphite-core);
    --pt-contrast-fg: var(--pt-white);
}
:root[data-theme="dark"] {
    --pt-bg: var(--pt-deep-void);
    --pt-surface: var(--pt-graphite-core);
    --pt-border: var(--pt-crater-shadow);
    --pt-fg: var(--pt-white);
    --pt-fg-muted: var(--pt-polished-steel);
    --surface-muted: #1a1b1e;
    --pt-focus-ring: 0 0 0 2px var(--pt-bg), 0 0 0 4px var(--pt-white);
    --pt-scrim: rgba(0, 0, 0, 0.65);
    --pt-hover-veil: rgba(255, 255, 255, 0.09);
    /* On dark surfaces the "ink-on-*-20" tones (tuned for light tints) are too dark
       to read. Remap them to the full-strength brand color so every component that
       paints text/icons with these tokens — including inline-styled avatars, tags,
       and FK chips — stays legible without a per-component dark override.
       This remap makes the inks the house rule for hue-carrying text/icons on ANY
       surface, tint or plain: base hues sit near 2:1 on light and may never color
       text there. A deliberate extension of the brand's tint-only ink rule. */
    --pt-ink-on-flame-20: var(--pt-rocket-flame);
    --pt-ink-on-seafoam-20: var(--pt-galactic-seafoam);
    --pt-ink-on-gold-20: var(--pt-solar-gold);
    --pt-ink-on-blue-20: var(--pt-atmosphere-blue);
    --pt-ink-on-purple-20: var(--pt-voyager-purple);
    --pt-ink-on-red-20: var(--pt-red-alert);
    --pt-contrast-bg: var(--pt-white);
    --pt-contrast-fg: var(--pt-graphite-core);
    color-scheme: dark;
}
/* OS-dark default with JS off, and the whole story in "system" mode — refresh.js
   only sets data-theme for an explicit light/dark choice. Must stay identical to
   the :root[data-theme="dark"] block above. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --pt-bg: var(--pt-deep-void);
        --pt-surface: var(--pt-graphite-core);
        --pt-border: var(--pt-crater-shadow);
        --pt-fg: var(--pt-white);
        --pt-fg-muted: var(--pt-polished-steel);
        --surface-muted: #1a1b1e;
        --pt-focus-ring: 0 0 0 2px var(--pt-bg), 0 0 0 4px var(--pt-white);
        --pt-scrim: rgba(0, 0, 0, 0.65);
        --pt-hover-veil: rgba(255, 255, 255, 0.09);
        --pt-ink-on-flame-20: var(--pt-rocket-flame);
        --pt-ink-on-seafoam-20: var(--pt-galactic-seafoam);
        --pt-ink-on-gold-20: var(--pt-solar-gold);
        --pt-ink-on-blue-20: var(--pt-atmosphere-blue);
        --pt-ink-on-purple-20: var(--pt-voyager-purple);
        --pt-ink-on-red-20: var(--pt-red-alert);
        --pt-contrast-bg: var(--pt-white);
        --pt-contrast-fg: var(--pt-graphite-core);
        color-scheme: dark;
    }
}
