/* ==========================================================================
 * SHARED VISUAL LAYER -- the source of truth for BOTH apps.
 *
 * hollands.co.nz (apps/site) and the hub (apps/hub) are separate deployables
 * on separate hostnames, and they have to look like one product. Everything
 * that decides that -- the typefaces, the colour tokens and their light-mode
 * overrides, the page ground and its orbs, the bento cells, the settings
 * panel -- lives HERE and nowhere else. Both apps get a copy in their
 * `public/` at build time (scripts/sync-shared-styles.mjs); those copies are
 * generated and gitignored, so there is exactly one version in the tree.
 *
 * DO NOT EDIT THE COPIES. Edit this file.
 *
 * Extracted from apps/site/public/style.css by HOL-136. Each block below is
 * verbatim, comments and all, so the history reads as a move rather than a
 * rewrite. What is NOT here is anything only one app can use: the site's
 * router views, plays reader, games and leaderboards stay in its own
 * style.css, which loads AFTER this file and is free to override it.
 *
 * The load order is load-bearing. `shared.css` first, then the app's own
 * sheet. Several site rules -- the location cell, the card away from home,
 * the game catalogue theming -- build on `.bento-cell` and expect to win.
 * ========================================================================== */


/* ---- Self-hosted fonts ---- */
/*
 * Previously loaded from fonts.googleapis.com, which told Google every
 * visitor's IP and which page they were on, and put a render-blocking
 * third-party request in front of every page load (TODO.md #5).
 *
 * Both families are variable fonts, so ONE file covers every weight the site
 * uses -- Google's own CSS served the same file three times over for Fraunces
 * 400/600/700. Only the latin subset is vendored; the unicode-range below
 * keeps that honest, so anything outside it falls back to a system font
 * rather than rendering from a subset that does not contain it.
 *
 * Files are named with the upstream version (v38, v19). Updating a font means
 * a new filename, which is what lets them be cached immutably.
 *
 * Both are SIL Open Font License. See fonts/README.md.
 */
@font-face {
    font-family: 'Fraunces';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('fonts/fraunces-v38-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Source Sans 3';
    font-style: normal;
    font-weight: 200 900;
    font-display: swap;
    src: url('fonts/source-sans-3-v19-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/*
 * Latin Extended, same versions as the latin files above so the metrics
 * cannot drift between subsets. Added for the translations: te reo Māori's
 * macron vowels (ā ē ī ō ū) are U+0100-017F, outside the latin subset, and
 * were falling back to a system font mid-heading. The range also carries
 * everything the other languages on the shortlist need beyond Latin-1 --
 * Spanish, Italian, German, Dutch and Afrikaans fit in the latin subset
 * already, and a browser only fetches whichever subsets a page actually
 * uses, so English visitors never download these.
 */
@font-face {
    font-family: 'Fraunces';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('fonts/fraunces-v38-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'Source Sans 3';
    font-style: normal;
    font-weight: 200 900;
    font-display: swap;
    src: url('fonts/source-sans-3-v19-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}


/* ---- Custom Properties ---- */
:root {
    --color-charcoal: #1a1a2e;
    --color-accent-teal: #4ECDC4;
    --color-accent-teal-glow: rgba(var(--accent-teal-rgb), 0.4);
    --color-accent-amber: #FFB347;
    --color-accent-amber-glow: rgba(var(--accent-amber-rgb), 0.4);
    --color-accent-purple: #a78bfa;
    --color-accent-purple-glow: rgba(var(--accent-purple-rgb), 0.4);
    --color-accent-coral: #FF6B6B;
    --color-accent-coral-glow: rgba(var(--accent-coral-rgb), 0.4);
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Source Sans 3', -apple-system, sans-serif;
    --bento-bg: rgba(var(--tint), 0.05);
    --bento-bg-hover: rgba(var(--tint), 0.09);
    /* ---- Tint channels ----
     *
     * The RGB triplet on its own, so alpha can vary at each use while the
     * whole ladder flips with one variable. `rgba(var(--tint), 0.55)` is the
     * same pixel as `rgba(var(--tint), 0.55)` was.
     *
     * Channels rather than 22 named greys because the alphas ARE the design
     * here -- collapsing them into four semantic levels would change how the
     * site looks, which is a decision to make deliberately and not a side
     * effect of a refactor. Light mode redefines --tint and nothing else.
     */
    --tint: 255, 255, 255;
    --accent-purple-rgb: 167, 139, 250;
    --accent-coral-rgb: 255, 107, 107;
    --accent-amber-rgb: 255, 179, 71;
    --accent-green-rgb: 87, 199, 133;
    --accent-teal-rgb: 78, 205, 196;

    /* Game tiles, as their own tokens so the palette can change without the
     * accent colours moving with it. Default is the original green/amber. */
    --tile-correct-rgb: 87, 199, 133;
    --tile-present-rgb: 255, 179, 71;

    /* Shadows stay black in both themes -- a light scheme wants darker, softer
     * shadows, not inverted ones. Tokenised for consistency, not because it
     * flips. */
    --shadow-rgb: 0, 0, 0;

    /* Page background, three gradient stops. Not an inversion in light mode --
     * a light scheme needs its own choice, which is why these are named by
     * position rather than by colour. */
    --page-bg-1: #1a1a2e;
    --page-bg-2: #16213e;
    --page-bg-3: #0f3460;
    --text-strong: #ffffff;

    /* The play reader is a deliberately LIGHT surface even in dark mode: it is
     * a page of a script, and reading long prose reversed out of a dark
     * background is worse. It therefore does NOT flip with the theme, and is
     * tokenised separately so that stays true by construction. */
    --paper-bg: #f5f5f7;
    --paper-text: #1a1a2e;
    --paper-body: #444;
    --paper-muted: #555;
    --paper-faint: #888;
    --paper-rule: #ddd;

    --bento-border: rgba(var(--tint), 0.08);
    --bento-radius: 20px;
    --bento-gap: 1rem;
    --bento-padding: 2rem;
}

/* ---- Light theme ----
 *
 * Only the tokens change. Every rule in the rest of this file already reads
 * through them, which is what the tokenising pass was for.
 *
 * `data-theme` is set on <html> by js/theme.js BEFORE the first paint, and it
 * resolves "system" to an explicit light or dark itself. That is why there is
 * no `@media (prefers-color-scheme)` block here: it would have to repeat every
 * declaration below, and two copies of a palette drift.
 *
 * The tint is a dark navy rather than pure black, so the greys sit against the
 * background rather than punching holes in it -- the same reason the dark
 * theme tints with white rather than pure white text everywhere.
 */
:root[data-theme="light"] {
    --tint: 26, 32, 56;

    --page-bg-1: #f6f7fb;
    --page-bg-2: #eef1f8;
    --page-bg-3: #e4eaf6;
    --text-strong: #141a2e;

    --charcoal: #141a2e;
    --bento-bg: rgba(var(--tint), 0.04);
    --bento-bg-hover: rgba(var(--tint), 0.07);
    --bento-border: rgba(var(--tint), 0.12);

    /* Accents darkened for contrast. The dark theme's amber and teal are
     * chosen to glow against navy; at full brightness on a near-white
     * background they are close to illegible. */
    --color-accent-amber: #a86a00;
    --color-accent-teal: #0f766e;
    --color-accent-coral: #c2410c;
    --color-accent-purple: #6d28d9;
    --accent-amber-rgb: 168, 106, 0;
    --accent-teal-rgb: 15, 118, 110;
    --accent-coral-rgb: 194, 65, 12;
    --accent-purple-rgb: 109, 40, 217;
    --accent-green-rgb: 21, 128, 61;
    --tile-correct-rgb: 21, 128, 61;
    --tile-present-rgb: 168, 106, 0;

    /* The play reader keeps its own palette in both themes -- see above. */
}



/* ---- Reset & Base ---- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    overflow-x: hidden;
}

body {
    font-family: var(--font-body);
    background: linear-gradient(135deg, var(--page-bg-1) 0%, var(--page-bg-2) 50%, var(--page-bg-3) 100%);
    color: var(--text-strong);
    min-height: 100vh;
    padding: 1.5rem;
    line-height: 1.6;
    position: relative;
}

body.view-inner {
    padding-top: 2rem;
}


/* ---- Background Orbs (simplified) ---- */
.bg-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.25;
    pointer-events: none;
    z-index: 0;
}

.bg-orb-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(var(--accent-teal-rgb), 0.5) 0%, transparent 70%);
    top: -200px;
    left: -200px;
    animation: float1 30s ease-in-out infinite;
}

.bg-orb-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(var(--accent-purple-rgb), 0.4) 0%, transparent 70%);
    bottom: -150px;
    right: -150px;
    animation: float2 35s ease-in-out infinite;
}

@keyframes float1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(80px, 60px) scale(1.1); }
}

@keyframes float2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-60px, -50px) scale(1.1); }
}


/* ---- Toggle switch ----
 *
 * Still a real <input type="checkbox">, restyled with `appearance: none`
 * rather than replaced by a div. It keeps the keyboard behaviour, the
 * :checked state, the disabled state and what a screen reader announces --
 * all of which a hand-built switch has to reimplement and usually does not.
 *
 * The knob is ::after on the input itself, so no wrapper markup is needed and
 * the three places that build one of these do not have to agree on a
 * structure.
 */
.toggle {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    flex: 0 0 auto;
    width: 2.1rem;
    height: 1.15rem;
    margin: 0;
    border: 1px solid var(--bento-border);
    border-radius: 999px;
    background: rgba(var(--tint), 0.12);
    cursor: pointer;
    vertical-align: middle;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.toggle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 2px;
    width: 0.82rem;
    height: 0.82rem;
    transform: translateY(-50%);
    border-radius: 50%;
    background: rgba(var(--tint), 0.6);
    transition: transform 0.15s ease, background 0.15s ease;
}

.toggle:checked {
    background: rgba(var(--accent-teal-rgb), 0.45);
    border-color: rgba(var(--accent-teal-rgb), 0.75);
}

.toggle:checked::after {
    transform: translateY(-50%) translateX(0.92rem);
    background: var(--text-strong);
}

/* Focus has to stay visible: with the native box gone there is nothing else to
   show a keyboard user where they are. */
.toggle:focus-visible {
    outline: 2px solid rgba(var(--accent-teal-rgb), 0.9);
    outline-offset: 2px;
}

.toggle:disabled {
    cursor: default;
}


/* ---- Settings ---- */

.settings-panel {
    max-width: 34rem;
    padding: var(--bento-padding);
    background: var(--bento-bg);
    border: 1px solid var(--bento-border);
    border-radius: var(--bento-radius);
}

.settings-group {
    margin: 0 0 1.5rem;
    padding: 0;
    border: 0;
}

.settings-group:last-of-type { margin-bottom: 0; }

.settings-group legend,
.settings-group > label {
    display: block;
    padding: 0;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-strong);
}

.settings-group label input {
    margin-right: 0.5rem;
}

.settings-group fieldset label,
fieldset.settings-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 400;
    color: rgba(var(--tint), 0.75);
}

.settings-check {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 400;
    color: rgba(var(--tint), 0.75);
}

.settings-input {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--bento-border);
    border-radius: 8px;
    background: rgba(var(--tint), 0.05);
    color: var(--text-strong);
    font-family: var(--font-body);
    font-size: 0.95rem;
}

.settings-hint {
    margin: 0.4rem 0 0.75rem;
    font-size: 0.85rem;
    color: rgba(var(--tint), 0.5);
}

.settings-status {
    margin: 0;
    min-height: 1.2em;
    font-size: 0.85rem;
    color: rgba(var(--accent-teal-rgb), 0.95);
}


/* ---- Bento Grid ---- */
.bento-grid {
    display: grid;
    gap: var(--bento-gap);
    max-width: 960px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    grid-template-columns: 1fr;
}

/* ---- Bento Cell Base ---- */
.bento-cell {
    background: var(--bento-bg);
    border: 1px solid var(--bento-border);
    border-radius: var(--bento-radius);
    padding: var(--bento-padding);
    position: relative;
    overflow: hidden;
    animation: bentoIn 0.5s ease-out both;
}

a.bento-cell {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease, background 0.3s ease;
}

@media (hover: hover) {
    a.bento-cell:hover {
        transform: translateY(-3px);
        background: var(--bento-bg-hover);
    }
}

a.bento-cell:active {
    transform: scale(0.98);
}

@keyframes bentoIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* The hero leads the entrance; each app staggers its own cells after it,
   because the cell names past this point belong to one app or the other. */
.cell-hero     { animation-delay: 0s; }

/* ---- Hero Cell ---- */
.cell-hero {
    /* No grid-area here, deliberately: placement is the app's. The site puts
       this cell in its named `hero` area; the hub spans it across two columns.
       A named area in the shared sheet would be a line the hub never defines. */
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2.5rem var(--bento-padding);
}

.cell-hero h1 {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-strong);
}

.cell-hero .tagline {
    font-size: 1rem;
    color: rgba(var(--tint), 0.45);
    margin-top: 0.5rem;
}

.cell-hero::after {
    content: '';
    position: absolute;
    bottom: -60px;
    left: -60px;
    width: 220px;
    height: 220px;
    background: radial-gradient(circle, rgba(var(--accent-purple-rgb), 0.12) 0%, transparent 70%);
    pointer-events: none;
}

@media (min-width: 540px) {
    .cell-hero h1 {
        font-size: 3rem;
    }
    .cell-hero {
        padding: 3rem var(--bento-padding);
    }
}

@media (min-width: 900px) {
    .cell-hero h1 {
        font-size: 3.5rem;
    }
}

/* ---- Business Card Cells ---- */
.card-header {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    margin-bottom: 0.75rem;
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.card-icon svg {
    width: 24px;
    height: 24px;
}

@media (hover: hover) {
    a.bento-cell:hover .card-icon {
        transform: scale(1.1) rotate(3deg);
    }
}

.card-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-strong);
}

.card-description {
    color: rgba(var(--tint), 0.6);
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 1rem;
}

.card-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    transition: gap 0.3s ease;
}

.card-link svg {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
}

@media (hover: hover) {
    a.bento-cell:hover .card-link {
        gap: 0.75rem;
    }
    a.bento-cell:hover .card-link svg {
        transform: translateX(3px);
    }
}



/* ---- Compact Cells (Plays, Books) ---- */
.cell-compact {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.625rem;
}

.cell-compact .cell-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.25rem;
    transition: transform 0.3s ease;
}

.cell-compact .cell-icon svg {
    width: 20px;
    height: 20px;
}

@media (hover: hover) {
    a.cell-compact:hover .cell-icon {
        transform: scale(1.1) rotate(3deg);
    }
}

.cell-label {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-strong);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cell-label svg {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
}

@media (hover: hover) {
    a.cell-compact:hover .cell-label svg {
        transform: translateX(3px);
    }
}

.cell-sublabel {
    font-size: 0.85rem;
    color: rgba(var(--tint), 0.45);
    line-height: 1.5;
}





/* ---- Responsive ----
 *
 * The shared half. The site's own sheet carries a second copy of the same
 * media query for its plays cards and reader, which is deliberate: one
 * breakpoint, two files, each owning only what it can use.
 */
@media (max-width: 539px) {
    body {
        padding: 1rem;
    }

    .bento-grid {
        gap: 0.75rem;
    }

    .bento-cell {
        padding: 1.5rem;
    }

    .cell-hero {
        padding: 2rem 1.5rem;
    }

    .card-title {
        font-size: 1.25rem;
    }
}

@media (min-width: 540px) {
    body {
        padding: 2rem;
    }
}

/* ---- Reduced motion ----
 *
 * Follows the operating system rather than a setting in the app. Nobody should
 * have to find a menu to stop things moving, and the OS already knows.
 *
 * The two background orbs are the real offender: 30 and 35 second loops running
 * forever in peripheral vision, which is exactly the pattern that triggers
 * nausea for people with vestibular disorders. Everything else here is a hover
 * transition or a one-off entrance.
 *
 * Near-zero rather than `none`, deliberately: an animation with a duration
 * still FIRES its events, so anything that waits on animationend keeps working.
 * Setting `animation: none` silently breaks that class of code later.
 *
 * Snake is untouched. Its motion is on a canvas, not in CSS, and it is the game
 * rather than decoration — someone who chose to play a snake game wants the
 * snake to move.
 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
