@font-face {
    font-family: "Space Mono";
    src: url("/fonts/space-mono-regular.ttf") format("truetype");
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

/* Taptivate. — canonical semantic tokens.
 *
 * This file is the single source of truth for colour. Everything else
 * (app.css, phase3.css, wizard.css, the template studio) aliases to these
 * --tt-* values, so one theme flip repaints every surface correctly.
 *
 * Rule of thumb:
 *   --tt-accent     is for BORDERS, DIVIDERS and ICONS.
 *   --tt-accent-ink is for text that must be read (it clears 4.5:1).
 *
 * Values are chosen to clear WCAG AA (4.5:1 body text, 3:1 large text and
 * UI borders) against --tt-bg and --tt-surface in both themes.
 */

:root {
    color-scheme: light;

    /* surfaces ------------------------------------------------------ */
    --tt-bg: #F8F6F1;
    --tt-surface: #FFFFFF;
    --tt-surface-raised: #FFFFFF;
    --tt-surface-sunken: #F1EEE7;
    /* translucent neutral that reads as a chip on either surface */
    --tt-neutral-soft: rgba(17, 17, 17, 0.06);

    /* lines --------------------------------------------------------- */
    --tt-border: rgba(0, 0, 0, 0.10);
    --tt-border-strong: rgba(0, 0, 0, 0.20);

    /* ink ----------------------------------------------------------- */
    --tt-text: #111111;
    --tt-text-muted: #53534E;
    --tt-text-faint: #53534E;

    /* brand --------------------------------------------------------- */
    --tt-accent: #C8A96A;
    --tt-accent-ink: #7E652F;
    --tt-accent-soft: rgba(200, 169, 106, 0.18);
    --tt-on-accent: #111111;

    /* status -------------------------------------------------------- */
    --tt-danger: #B3423A;
    --tt-danger-soft: rgba(179, 66, 58, 0.10);
    --tt-success: #2E7D4F;
    --tt-success-soft: rgba(46, 125, 79, 0.12);
    --tt-warning: #8A5A12;
    --tt-warning-soft: rgba(212, 165, 55, 0.16);

    /* focus --------------------------------------------------------- */
    --tt-focus-ring: #7E652F;

    /* elevation: light mode uses real shadows ------------------------ */
    --tt-shadow-1: 0 1px 2px rgba(10, 10, 10, 0.06), 0 2px 8px rgba(10, 10, 10, 0.04);
    --tt-shadow-2: 0 10px 34px rgba(10, 10, 10, 0.08);
    --tt-shadow-3: 0 24px 60px rgba(10, 10, 10, 0.16);

    /* inverse pair used by primary buttons and solid chips ------------ */
    --tt-inverse-bg: #111111;
    --tt-inverse-text: #F8F6F1;

    /* Shared scales. Legacy aliases below keep existing screens compatible. */
    --tt-space-1: 4px; --tt-space-2: 8px; --tt-space-3: 12px;
    --tt-space-4: 16px; --tt-space-5: 24px; --tt-space-6: 32px;
    --tt-space-7: 48px; --tt-space-8: 64px;
    --tt-radius-xs: 8px; --tt-radius-sm: 12px; --tt-radius-md: 16px;
    --tt-radius-lg: 24px; --tt-radius-pill: 999px;
    --tt-font-serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
    --tt-font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --tt-font-store-display: "Maghfirea", var(--tt-font-serif);
    --tt-font-store-label: "Space Mono", ui-monospace, monospace;
    --tt-font-store: var(--tt-font-store-label);
    --tt-font-store-accent: "DM Sans", var(--tt-font-sans);
    --tt-type-lede: clamp(1rem, .9rem + .38vw, 1.25rem);
    --tt-type-display: clamp(2rem, 1.55rem + 2vw, 3rem);
    --tt-type-title: clamp(1.375rem, 1.25rem + .5vw, 1.625rem);
    --tt-type-body: clamp(1rem, .965rem + .18vw, 1.125rem);
    --tt-type-caption: clamp(.8125rem, .78rem + .16vw, .9375rem);
    --tt-type-micro: clamp(.6875rem, .66rem + .12vw, .8125rem);
    --tt-leading-tight: 1.1; --tt-leading-body: 1.55;
    --tt-target: 44px; --tt-control: 48px;
    --tt-duration-press: 120ms; --tt-duration-state: 200ms;
    --tt-duration-enter: 320ms; --tt-duration-flip: 600ms;
    --tt-ease-out: cubic-bezier(.2, .7, .2, 1);
    --tt-ease-spring: cubic-bezier(.2, .9, .3, 1.04);
}

[data-theme="dark"] {
    color-scheme: dark;

    --tt-bg: #0B0B0B;
    --tt-surface: #141414;
    --tt-surface-raised: #1C1C1C;
    --tt-surface-sunken: #080808;
    --tt-neutral-soft: rgba(255, 255, 255, 0.10);

    --tt-border: rgba(255, 255, 255, 0.12);
    --tt-border-strong: rgba(255, 255, 255, 0.22);

    --tt-text: #F5F2EA;
    --tt-text-muted: #B0B0AA;
    --tt-text-faint: #B0B0AA;

    --tt-accent: #C8A96A;
    --tt-accent-ink: #C8A96A;
    --tt-accent-soft: rgba(200, 169, 106, 0.16);
    --tt-on-accent: #111111;

    --tt-danger: #E5857B;
    --tt-danger-soft: rgba(229, 133, 123, 0.14);
    --tt-success: #66C48C;
    --tt-success-soft: rgba(102, 196, 140, 0.14);
    --tt-warning: #E0B061;
    --tt-warning-soft: rgba(224, 176, 97, 0.14);

    --tt-focus-ring: #C8A96A;

    /* A drop shadow on a near-black page is invisible, so dark mode lifts
       with a hairline instead. Same token name, same meaning: "this sits
       above the page". */
    --tt-shadow-1: 0 0 0 1px rgba(255, 255, 255, 0.04);
    --tt-shadow-2: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 18px 40px rgba(0, 0, 0, 0.55);
    --tt-shadow-3: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 30px 70px rgba(0, 0, 0, 0.65);

    --tt-inverse-bg: #F5F2EA;
    --tt-inverse-text: #0B0B0B;
}

/* ---------------------------------------------------------------------
 * Aliases for the three legacy scales. Their values now come from the
 * tokens above, so nothing can drift again.
 * ------------------------------------------------------------------- */

:root {
    --s-1: var(--tt-space-1); --s-2: var(--tt-space-2); --s-3: var(--tt-space-3);
    --s-4: var(--tt-space-4); --s-5: var(--tt-space-5); --s-6: var(--tt-space-6); --s-7: var(--tt-space-7);
    --r-xs: var(--tt-radius-xs); --r-sm: var(--tt-radius-sm); --r-md: var(--tt-radius-md);
    --r-lg: var(--tt-radius-lg); --r-pill: var(--tt-radius-pill);
    --sh-1: var(--tt-shadow-1); --sh-2: var(--tt-shadow-2); --sh-3: var(--tt-shadow-3);
    --border-w: 1px;
    --fs-display: var(--tt-type-display); --fs-title: var(--tt-type-title); --fs-body: var(--tt-type-body);
    --fs-caption: var(--tt-type-caption); --fs-micro: var(--tt-type-micro);
    --lh-tight: var(--tt-leading-tight); --lh-body: var(--tt-leading-body);
    --d-1: var(--tt-duration-press); --d-2: var(--tt-duration-state);
    --d-3: var(--tt-duration-enter); --d-4: var(--tt-duration-flip);
    --e-out: var(--tt-ease-out); --e-spring: var(--tt-ease-spring);
    --z-nav: 40; --z-dialog: 110; --z-sheet: 150; --z-toast: 300; --z-intro: 999;
    /* app.css scale */
    --bg: var(--tt-bg);
    --text: var(--tt-text);
    --surface: var(--tt-surface);
    --muted: var(--tt-text-muted);
    --hairline: var(--tt-border);
    --btn-bg: var(--tt-inverse-bg);
    --btn-text: var(--tt-inverse-text);
    --shadow: var(--tt-shadow-2);
    --gold: var(--tt-accent);
    --gold-ink: var(--tt-accent-ink);

    /* phase3.css scale */
    --tp-paper: var(--tt-bg);
    --tp-surface: var(--tt-surface);
    --tp-text: var(--tt-text);
    --tp-muted: var(--tt-text-muted);
    --tp-hairline: var(--tt-border);
    --tp-gold: var(--tt-accent);
    --tp-gold-ink: var(--tt-accent-ink);
    --tp-danger: var(--tt-danger);
    --tp-shadow: var(--tt-shadow-2);

    /* wizard.css scale */
    --wz-ink: var(--tt-text);
    --wz-off: var(--tt-bg);
    --wz-surface: var(--tt-surface);
    --wz-muted: var(--tt-text-muted);
    --wz-line: var(--tt-border);
    --wz-gold: var(--tt-accent);
    --wz-gold-ink: var(--tt-accent-ink);
    --wz-danger: var(--tt-danger);
}

/* ---------------------------------------------------------------- motion
 * A 200 ms colour crossfade makes a theme flip feel deliberate instead of
 * jarring. Only colour-ish properties are listed so layout never animates. */
html.tp-theme-anim,
html.tp-theme-anim body,
html.tp-theme-anim * {
    transition:
        background-color 200ms ease,
        border-color 200ms ease,
        color 200ms ease,
        fill 200ms ease,
        stroke 200ms ease,
        box-shadow 200ms ease;
}

@media (prefers-reduced-motion: reduce) {
    html.tp-theme-anim,
    html.tp-theme-anim body,
    html.tp-theme-anim * {
        transition: none !important;
    }
}

/* Device-local interface presets. Profile styles have their own motion scale. */
[data-ui-motion="showy"] {
    --tt-duration-state: 260ms;
    --tt-duration-enter: 400ms;
}

[data-ui-motion="off"], [data-ui-motion="off"] *,
[data-ui-motion="off"] *::before, [data-ui-motion="off"] *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
}

/* Scrollbars follow the theme instead of staying grey-on-grey. */
html {
    scrollbar-color: var(--tt-border-strong) transparent;
}

/* Keep editing and dragging cursors native while branding the rest of the UI. */
@media (hover: hover) and (pointer: fine) and (forced-colors: none) {
    :root {
        --tt-pointer-image: url('/assets/taptivate-pointer.svg?v=star') 12 12;
        cursor: var(--tt-pointer-image), default;
    }

    dialog::backdrop { cursor: var(--tt-pointer-image), default; }

    :is(a[href], button, summary, [role="button"], [role="tab"], [role="link"], label[for], .table tbody tr):not(
        :where(:disabled, [aria-disabled="true"], [aria-busy="true"], [draggable="true"], .is-loading, [inert], [inert] *)
    ) {
        /* Some components ship their own pointer rule in lazily loaded styles. */
        cursor: var(--tt-pointer-image), pointer !important;
    }

    :where(input, textarea, select) { cursor: auto; }
    [contenteditable]:not([contenteditable="false"]) { cursor: text; }
}

.tp-site-theme {
    box-sizing: border-box;
    display: inline-grid;
    place-items: center;
    flex: none;
    inline-size: var(--tt-target);
    block-size: var(--tt-target);
    padding: 0;
    border: 1px solid var(--tt-border-strong);
    border-radius: var(--tt-radius-pill);
    background: var(--tt-surface);
    color: var(--tt-text);
    cursor: pointer;
}
.tp-site-theme[data-site-theme="light"] .tp-site-theme__moon,
.tp-site-theme[data-site-theme="dark"] .tp-site-theme__sun { display: none; }
.tp-site-theme:focus-visible { outline: 2px solid var(--tt-focus-ring); outline-offset: 2px; }
.tp-site-theme:active { background: var(--tt-accent-soft); }

@media (hover: hover) and (pointer: fine) {
    .tp-site-theme:hover { border-color: var(--tt-accent-ink); color: var(--tt-accent-ink); }
}
