/*
 * CalHours, coming soon: the departure board reduced to its status line. Tokens, faces and the
 * flap are the site's own (DESIGN.md on main); there is no action here, so no amber.
 */
@font-face {
    font-family: 'Barlow Condensed';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/fonts/barlow-condensed-latin-600-normal.woff2') format('woff2');
}

@font-face {
    font-family: 'Barlow Condensed';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/fonts/barlow-condensed-latin-700-normal.woff2') format('woff2');
}

@font-face {
    font-family: 'Public Sans Variable';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/fonts/public-sans-latin-wght-normal.woff2') format('woff2-variations');
}

:root {
    --font-sans: 'Public Sans Variable', ui-sans-serif, system-ui, sans-serif;
    --font-signage: 'Barlow Condensed', 'Arial Narrow', ui-sans-serif, sans-serif;

    --color-stone: #e9ebe6;
    --color-ink: #1c1f23;
    --color-ink-muted: #4a4f57;
    --color-board: #202328;
    --color-flap-top: #363a41;
    --color-flap-bottom: #2d3137;
    --color-flap-split: #14161a;
    --color-flap-ink: #f1ede3;
    --color-signal: #f3b32b;
    --color-signal-ink: #1d1a12;

    color-scheme: light;
}

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

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

body {
    margin: 0;
    background: var(--color-stone);
    color: var(--color-ink);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
}

::selection {
    background: var(--color-signal);
    color: var(--color-signal-ink);
}

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

/*
 * One column on the wall, a little above center, as a sign hangs at eye level. The gutters take
 * the free space, so the column grows from 960px to 1280px on large screens instead of shrinking.
 */
.stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: center;
    container-type: inline-size;
    min-height: 100vh;
    min-height: 100svh;
    padding-block: clamp(24px, 8vh, 96px) clamp(32px, 14vh, 160px);
    padding-left: max(16px, 4vw, env(safe-area-inset-left, 0px), (100% - clamp(960px, 50vw, 1280px)) / 2);
    padding-right: max(16px, 4vw, env(safe-area-inset-right, 0px), (100% - clamp(960px, 50vw, 1280px)) / 2);
}

/* A landscape phone: the sign fits without a scroll. */
@media (max-height: 480px) {
    .stage {
        padding-block: 20px 24px;
    }
}

/* The flap carrying the C, then the name: the site header's wordmark at headline scale. */
.wordmark {
    display: inline-flex;
    align-items: center;
    gap: 0.32em;
    justify-self: start;
    margin: 0 0 clamp(20px, 3.4cqi, 40px);
    font-family: var(--font-signage);
    font-weight: 700;
    /* Capped by width for any face, so the name never runs off a phone with large text. */
    font-size: min(clamp(2rem, 5.8cqi, 4.25rem), calc((100vw - 32px) / 7.8));
    line-height: 1;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.mark {
    display: grid;
    place-items: center;
    width: 1.05em;
    height: 1.4em;
    border-radius: 3px;
    font-size: 0.9em;
    letter-spacing: 0;
}

/*
 * A flap: two leaves and a hairline seam drawn above the glyph, so the gap cuts through every
 * letter as on a real board. Barlow's caps sit low in their em box; the padding lifts them so the
 * seam halves each one.
 */
.mark,
.flap {
    position: relative;
    padding-bottom: 0.07em;
    background: linear-gradient(var(--color-flap-top) 0 50%, var(--color-flap-bottom) 50% 100%);
    color: var(--color-flap-ink);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06);
}

.mark::after,
.flap::after {
    content: '';
    position: absolute;
    inset-inline: 0;
    top: calc(50% - 0.5px);
    height: 1px;
    background: var(--color-flap-split);
}

/* The flaps are the board's picture of "Coming soon"; copying takes the words, not the cells. */
.mark,
.flaps {
    -webkit-user-select: none;
    user-select: none;
}

/* The board housing: the one object that casts a shadow onto the stone. */
.board {
    container-type: inline-size;
    margin: 0;
    padding: clamp(12px, 2.4vw, 28px);
    background: var(--color-board);
    border-radius: 6px;
    box-shadow:
        0 1px 0 rgb(255 255 255 / 0.55),
        0 16px 26px -18px rgb(20 22 26 / 0.6);
}

/*
 * Thirteen cells in a row: COMING, a blank, SOON and two blanks. They fill the board's width:
 * 13 cells of 0.8em and 12 gaps of 0.09em make 11.48em.
 */
.flaps {
    display: flex;
    gap: 0.09em;
    font-family: var(--font-signage);
    font-weight: 600;
    /* Before container units, one row that still fills most of the board. */
    font-size: min(6.6vw, 4.9rem);
    font-size: calc(100cqi / 11.48);
    line-height: 1;
}

.word {
    display: flex;
    gap: 0.09em;
}

.flap {
    display: grid;
    place-items: center;
    flex: none;
    width: 0.8em;
    height: 1.24em;
    border-radius: 2px;
    overflow: hidden;
}

/* A narrow board stacks the words, six cells to a row (6 × 0.8em + 5 × 0.09em), so each flap stays large. */
@container (max-width: 520px) {
    .flaps {
        flex-direction: column;
        font-size: calc(100cqi / 5.25);
    }

    .flap.gap {
        display: none;
    }
}

/* A new glyph arrives as the top leaf falls: its upper half first, tipped back, then whole. */
.glyph {
    display: block;
    animation: leaf-fall 80ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* The blank the board wakes on is already hanging; only a change falls. */
.glyph.at-rest {
    animation: none;
}

@keyframes leaf-fall {
    from {
        clip-path: inset(0 0 calc(50% - 0.035em) 0);
        transform: perspective(10em) rotateX(70deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .glyph {
        animation: none;
    }
}

/* The one line: what CalHours is and does, under the board's left edge. */
.line {
    max-width: 46ch;
    margin: clamp(26px, 3.8cqi, 48px) 0 0;
    color: var(--color-ink-muted);
    font-size: clamp(1.05rem, 2.15cqi, 1.45rem);
    line-height: 1.55;
    text-wrap: balance;
    /* A product name is held together, but never past the edge of a narrow screen with large text. */
    overflow-wrap: break-word;
}

/* A product name stays whole wherever the measure has room for it, at any text size. */
@container (min-width: 17em) {
    .line .keep {
        white-space: nowrap;
    }
}

/* More contrast: each cell keeps an edge, so the blank cells still read as cells. */
@media (prefers-contrast: more) {
    .mark,
    .flap {
        box-shadow: inset 0 0 0 1px rgb(241 237 227 / 0.35);
    }
}

/* High Contrast drops the leaves' fills; keep the housing and each cell as outlines, seam and all. */
@media (forced-colors: active) {
    .board,
    .mark,
    .flap {
        border: 1px solid CanvasText;
    }

    .mark::after,
    .flap::after {
        forced-color-adjust: none;
        background: CanvasText;
    }
}

/* Printed or saved as PDF: the board prints as itself, at the top of the page. */
@media print {
    .board,
    .mark,
    .flap {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .board {
        box-shadow: none;
    }

    .stage {
        min-height: 0;
    }
}
