/* The wall and its cards, and the three clock faces. Shared by the app and the exported
   HTML page (which inlines this file and app.css), so nothing here may depend on the
   app's chrome. One section per part. */

/* ==== Wall ================================================================== */

/* js/wall.js works out the grid that gives every card the most room (layout.js) and sets
   the column count and row height here; the fallbacks are what shows before it has. */
.wall {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(var(--wall-cols, 1), minmax(0, 1fr));
    grid-auto-rows: var(--wall-row, minmax(18rem, 1fr));
    gap: 0.75rem;
    align-content: start;
    padding: 0.75rem;
    overflow: hidden auto;
    box-sizing: border-box;
}

.wall:not(.wall-scroll) {
    overflow: hidden;
}

/* ==== Card ================================================================== */

.card {
    container: card / size;
    position: relative;
    min-width: 0;
    min-height: 0;
    border: 1px solid var(--tm-border-soft);
    border-radius: 1.1rem;
    background: var(--tm-surface);
    box-shadow: var(--tm-shadow);
    overflow: hidden;
    transition: background-color 0.6s, border-color 0.2s, opacity 0.15s;
}

.card-local {
    border-color: var(--tm-accent-dim);
}

.card-holiday {
    border-color: var(--tm-accent);
    box-shadow: var(--tm-shadow), inset 0 0 0 1px var(--tm-accent-dim);
}

.card-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: clamp(0.4rem, 2.5cqmin, 1.1rem);
    height: 100%;
    box-sizing: border-box;
    padding: clamp(0.7rem, 3.6cqmin, 1.6rem);
    /* Everything in a card scales with the card, inside sensible bounds. */
    font-size: clamp(0.72rem, 1.6cqmin + 0.42rem, 1.3rem);
}

/* A wide card puts its details beside the face rather than under it. */
@container card (min-aspect-ratio: 13 / 10) and (min-width: 28rem) {
    .card-inner {
        display: grid;
        grid-template-columns: minmax(0, 1.15fr) minmax(13rem, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
        column-gap: clamp(0.8rem, 4cqmin, 2.5rem);
    }

    .card-head {
        grid-column: 2;
        grid-row: 1;
    }

    .card-face {
        grid-column: 1;
        grid-row: 1 / span 2;
    }

    .card-info {
        grid-column: 2;
        grid-row: 2;
        align-self: center;
    }
}

/* Short cards drop the second lines, then the facts, before the face gets squeezed. */
@container card (max-height: 25rem) {
    .fact-note {
        display: none !important;
    }
}

@container card (max-height: 19rem) {
    .card-facts {
        display: none;
    }

    /* ...and so does the panel, when the facts were all it had. */
    .card-info:not(:has(.card-date:not([hidden]), .chip:not([hidden]), .card-sun:not([hidden]))) {
        display: none;
    }
}

/* ---- Head ---- */

.card-head {
    display: flex;
    align-items: flex-start;
    gap: 0.5em;
    min-width: 0;
}

.card-titles {
    flex: 1;
    min-width: 0;
}

.card-name {
    margin: 0;
    font-size: clamp(1.05rem, 5.4cqmin, 2.6rem);
    font-weight: 650;
    letter-spacing: -0.02em;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-sub {
    display: flex;
    align-items: center;
    gap: 0.45em;
    margin: 0.2em 0 0;
    color: var(--tm-muted);
    font-size: 0.86em;
    white-space: nowrap;
    overflow: hidden;
}

.card-country {
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-cc {
    flex: none;
    padding: 0.2em 0.38em;
    border: 1px solid var(--tm-border);
    border-radius: 0.3em;
    color: var(--tm-text);
    font: 700 0.72em/1 ui-monospace, 'Cascadia Mono', Consolas, monospace;
    letter-spacing: 0.04em;
}

.card-tag {
    flex: none;
    color: var(--tm-accent);
    font-size: 0.8em;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.card-phase {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 0.35em;
    padding: 0.28em 0.65em;
    border-radius: 999px;
    background: var(--tm-surface-2);
    color: var(--tm-muted);
    font-size: 0.82em;
    font-weight: 600;
}

/* The temperature there, above whether it is day or night. */
.card-aside {
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.4em;
}

.card-temp {
    display: inline-flex;
    align-items: center;
    gap: 0.25em;
    font-size: clamp(1.05rem, 5.4cqmin, 2.6rem);
    font-weight: 650;
    letter-spacing: -0.02em;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.card-temp .icon svg {
    width: 1em;
    height: 1em;
    stroke-width: 1.8;
}

.icon {
    display: inline-flex;
}

.icon svg {
    width: 1.15em;
    height: 1.15em;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.card-menu-btn {
    display: inline-grid;
    flex: none;
    place-items: center;
    width: 2rem;
    height: 2rem;
    margin: -0.25rem -0.4rem 0 0;
    padding: 0;
    border: 0;
    border-radius: 0.55rem;
    background: transparent;
    color: var(--tm-muted);
    cursor: pointer;
}

.card-menu-btn svg {
    width: 1.2rem;
    height: 1.2rem;
    fill: currentColor;
    stroke: none;
}

.card-menu-btn:hover,
.card-menu-btn[aria-expanded="true"] {
    background: var(--tm-hover);
    color: var(--tm-text);
}

/* ---- Face ---- */

.card-face {
    container: face / size;
    position: relative;
    display: grid;
    flex: 1 1 auto;
    min-height: 4rem;
    place-items: center;
}

.face {
    display: block;
    width: 100%;
    height: 100%;
}

/* ---- Details ---- */

.card-info {
    display: grid;
    flex: none;
    gap: 0.6em;
    min-width: 0;
}

.card-when {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4em;
    margin: 0;
}

.card-when:not(:has(> :not([hidden]))) {
    display: none;
}

.card-date {
    margin-right: 0.15em;
    font-weight: 600;
}

.chip {
    padding: 0.12em 0.55em;
    border: 1px solid var(--tm-border-soft);
    border-radius: 999px;
    background: var(--tm-surface-2);
    color: var(--tm-muted);
    font-size: 0.86em;
    white-space: nowrap;
}

.chip-day {
    border-color: var(--tm-night-wash);
    color: var(--tm-night);
}

.chip-day.ahead {
    border-color: var(--tm-accent-wash);
    color: var(--tm-accent);
}

/* Sunrise, a bar for the whole day there with daylight lit, and sunset. */
.card-sun {
    display: grid;
    grid-template-columns: auto minmax(3rem, 1fr) auto;
    align-items: center;
    gap: 0.6em;
    font-variant-numeric: tabular-nums;
}

.sun-time {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    color: var(--tm-muted);
    font-size: 0.92em;
    white-space: nowrap;
}

.sun-time .icon {
    color: var(--tm-accent);
}

.sun-track {
    position: relative;
    height: 0.42em;
    border-radius: 999px;
    background: var(--tm-night-wash);
}

.sun-day {
    position: absolute;
    top: 0;
    bottom: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--tm-dusk), var(--tm-accent) 25%, var(--tm-accent-bright) 50%, var(--tm-accent) 75%, var(--tm-dusk));
}

.sun-now {
    position: absolute;
    top: 50%;
    width: 0.8em;
    height: 0.8em;
    border: 0.16em solid var(--tm-surface);
    border-radius: 50%;
    background: var(--tm-text);
    box-sizing: border-box;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 0 1px var(--tm-border);
}

.sun-note {
    grid-column: 1 / -1;
    color: var(--tm-muted);
    font-size: 0.9em;
}

.sun-time[hidden] + .sun-track {
    grid-column: 1 / -1;
}

.card-sun:has(.sun-rise[hidden]) {
    grid-template-columns: 1fr;
}

.card-facts {
    display: grid;
    gap: 0.45em;
    margin: 0;
    padding-top: 0.6em;
    border-top: 1px solid var(--tm-border-soft);
}

.card-facts:not(:has(> .fact:not([hidden]))) {
    display: none;
}

.fact {
    display: grid;
    grid-template-columns: 5.6em minmax(0, 1fr);
    gap: 0.6em;
    align-items: baseline;
}

.fact dt {
    color: var(--tm-faint);
    font-size: 0.74em;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.fact dd {
    min-width: 0;
    margin: 0;
}

.fact-main,
.fact-note {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fact-note {
    color: var(--tm-muted);
    font-size: 0.88em;
}

.fact-note:empty {
    display: none;
}

.card-holiday .fact-holiday .fact-main {
    color: var(--tm-accent);
    font-weight: 650;
}

[hidden] {
    display: none !important;
}

/* ==== Sky ================================================================== */

/* While a card says whether it is day or night it is painted as the sky there: dawn, a
   blue day with the sun crossing it, dusk, or a night of stars with the moon up. The
   weather, when it is on, clouds it over, fogs it or rains, snows and storms on it.
   wall.js sets data-phase and data-sky on the card, --sun-x and --sun-y for where the
   sun or moon is, and --cover for how cloudy it is (0 to 1); everything else is here.

   The header text sits on the sky, so each scene says what ink reads on it; the details
   sit on a frosted panel in the theme's own colours, so they read the same everywhere. */

.card-sky {
    position: absolute;
    inset: 0;
    display: none;
    overflow: hidden;
    background: var(--sky);
    pointer-events: none;
}

.card[data-phase] .card-sky {
    display: block;
}

.card[data-phase="day"] {
    --sky: var(--tm-sky-day);
    --sky-ink: var(--tm-sky-day-ink);
    --sky-muted: var(--tm-sky-day-muted);
    --sky-line: var(--tm-sky-day-line);
    --sky-pill: var(--tm-sky-day-pill);
    --sky-shadow: var(--tm-sky-day-shadow);
    --sky-grey: var(--tm-sky-day-grey);
    --cloud-hi: rgba(255, 255, 255, 0.97);
    --cloud-lo: rgba(196, 210, 228, 0.9);
    --sky-mist: rgba(255, 255, 255, 0.42);
    --sky-stars: 0;
}

.card[data-phase="dawn"] {
    --sky: linear-gradient(180deg, #222a62 0%, #634a8c 40%, #d27583 72%, #f6b27a 100%);
    --cloud-hi: rgba(255, 218, 222, 0.9);
    --cloud-lo: rgba(150, 112, 152, 0.82);
    --sky-grey: #554a66;
    --sky-stars: 0.4;
}

.card[data-phase="dusk"] {
    --sky: linear-gradient(180deg, #121640 0%, #532d6c 40%, #bb4d6a 72%, #ee874a 100%);
    --cloud-hi: rgba(255, 192, 168, 0.88);
    --cloud-lo: rgba(108, 70, 112, 0.82);
    --sky-grey: #45384f;
    --sky-stars: 0.55;
}

.card[data-phase="night"] {
    --sky: linear-gradient(180deg, #04060f 0%, #0a1130 55%, #18204c 100%);
    --cloud-hi: rgba(118, 128, 162, 0.55);
    --cloud-lo: rgba(42, 48, 72, 0.6);
    --sky-grey: #141824;
    --sky-stars: 1;
}

.card[data-phase="dawn"],
.card[data-phase="dusk"],
.card[data-phase="night"] {
    --sky-ink: #f1f3ff;
    --sky-muted: rgba(230, 234, 255, 0.78);
    --sky-line: rgba(255, 255, 255, 0.3);
    --sky-pill: rgba(255, 255, 255, 0.14);
    --sky-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
    --sky-mist: rgba(215, 220, 240, 0.2);
}

.card[data-phase] .card-head {
    --tm-text: var(--sky-ink);
    --tm-muted: var(--sky-muted);
    --tm-border: var(--sky-line);
    --tm-hover: var(--sky-pill);
    color: var(--sky-ink);
    text-shadow: var(--sky-shadow);
}

.card[data-phase] .card-tag {
    color: var(--sky-ink);
}

.card[data-phase] .card-phase {
    background: var(--sky-pill);
    color: var(--sky-ink);
    text-shadow: none;
}

.card[data-phase] .card-info {
    margin: 0 -0.15em -0.15em;
    padding: 0.75em 0.85em;
    border-radius: 0.8em;
    background: var(--tm-panel);
    -webkit-backdrop-filter: blur(10px) saturate(1.15);
    backdrop-filter: blur(10px) saturate(1.15);
}

/* With every detail switched off there is no panel at all. The date row and the facts
   hide themselves by CSS rather than [hidden], so this asks for anything shown in them. */
.card-info:not(:has(.card-date:not([hidden]), .chip:not([hidden]), .card-sun:not([hidden]), .fact:not([hidden]))) {
    display: none;
}

.card-sky > span {
    position: absolute;
    display: block;
    opacity: 0;
}

/* ---- Stars: two tiled fields, one of them twinkling, fading out towards the
   horizon and behind cloud. ---- */

.sky-stars {
    inset: 0;
    opacity: calc(var(--sky-stars, 0) * (1 - 0.9 * var(--cover, 0))) !important;
    -webkit-mask-image: linear-gradient(#000 0%, #000 45%, transparent 85%);
    mask-image: linear-gradient(#000 0%, #000 45%, transparent 85%);
}

.sky-stars::before,
.sky-stars::after {
    content: '';
    position: absolute;
    inset: 0;
}

.sky-stars::before {
    background-image:
        radial-gradient(1.2px 1.2px at 22px 30px, #fff 60%, transparent),
        radial-gradient(1px 1px at 84px 74px, rgba(255, 255, 255, 0.75) 60%, transparent),
        radial-gradient(1.6px 1.6px at 151px 22px, #fff 60%, transparent),
        radial-gradient(1px 1px at 118px 118px, rgba(255, 255, 255, 0.7) 60%, transparent),
        radial-gradient(1.3px 1.3px at 42px 146px, #fff 60%, transparent),
        radial-gradient(1px 1px at 178px 162px, rgba(255, 255, 255, 0.8) 60%, transparent);
    background-size: 190px 180px;
}

.sky-stars::after {
    background-image:
        radial-gradient(1.4px 1.4px at 60px 50px, #fff 60%, transparent),
        radial-gradient(1px 1px at 200px 96px, rgba(255, 255, 255, 0.85) 60%, transparent),
        radial-gradient(1.8px 1.8px at 132px 176px, rgba(255, 250, 230, 0.95) 60%, transparent),
        radial-gradient(1px 1px at 18px 200px, #fff 60%, transparent);
    background-size: 236px 214px;
    animation: tm-twinkle 3.8s ease-in-out infinite alternate;
}

@keyframes tm-twinkle {
    from { opacity: 1; }
    to { opacity: 0.25; }
}

/* ---- The sun and the moon ---- */

.sky-body {
    left: var(--sun-x, 86%);
    top: var(--sun-y, 32%);
    width: clamp(1.5rem, 10cqmin, 4.2rem);
    aspect-ratio: 1;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: calc(1 - 0.85 * var(--cover, 0)) !important;
    transition: left 1.5s ease, top 1.5s ease, opacity 2s;
}

.card[data-phase="day"] .sky-body {
    background: radial-gradient(circle at 50% 50%, #fffdf0 0 45%, #ffe680 75%, #ffd34d);
    box-shadow:
        0 0 0 0.35em rgba(255, 228, 120, 0.3),
        0 0 2.2em 1.1em rgba(255, 214, 90, 0.5);
}

.card[data-phase="dawn"] .sky-body,
.card[data-phase="dusk"] .sky-body {
    width: clamp(2.2rem, 15cqmin, 6rem);
    background: radial-gradient(circle at 50% 50%, #fff2cf 0 35%, #ffc27a 70%, #ff9a5a);
    box-shadow:
        0 0 0 0.5em rgba(255, 170, 110, 0.25),
        0 0 3.5em 2em rgba(255, 140, 90, 0.5);
}

/* The moon, with a few seas on it, and a cool glow. */
.card[data-phase="night"] .sky-body {
    width: clamp(1.2rem, 8cqmin, 3.2rem);
    background:
        radial-gradient(circle at 34% 38%, rgba(160, 155, 140, 0.45) 0 12%, transparent 13%),
        radial-gradient(circle at 62% 30%, rgba(160, 155, 140, 0.35) 0 8%, transparent 9%),
        radial-gradient(circle at 56% 66%, rgba(160, 155, 140, 0.4) 0 15%, transparent 16%),
        radial-gradient(circle at 40% 40%, #fffdf2, #e2dcc8 70%, #c9c2ab);
    box-shadow: 0 0 1.8em 0.4em rgba(210, 220, 255, calc(0.06 + 0.24 * var(--moon-lit, 1)));
}

/* Its unlit side, a shade of the night sky with a little earthshine through it. */
.sky-body svg {
    position: absolute;
    inset: -1px;
    width: calc(100% + 2px);
    height: calc(100% + 2px);
    overflow: visible;
}

.moon-dark {
    fill: #0b1230;
    opacity: 0.9;
}

.card[data-moon="down"] .sky-body {
    display: none;
}

/* ---- Cloud cover: the sky greys over as the cloud comes in, more so when it is
   wet. ---- */

.sky-cover {
    inset: 0;
    background: var(--sky-grey);
    opacity: calc(var(--cover, 0) * var(--cover-max, 0.25)) !important;
    transition: opacity 2s;
}

.card[data-sky="cloudy"] { --cover-max: 0.6; }
.card[data-sky="fog"] { --cover-max: 0.5; }
.card[data-sky="drizzle"],
.card[data-sky="rain"],
.card[data-sky="snow"] { --cover-max: 0.68; }
.card[data-sky="storm"] { --cover-max: 0.8; }

.card[data-sky="drizzle"],
.card[data-sky="rain"],
.card[data-sky="snow"],
.card[data-sky="storm"],
.card[data-sky="fog"] {
    --wet: 1;
}

.card[data-sky="cloudy"] .sky-body,
.card[data-sky="fog"] .sky-body,
.card[data-sky="drizzle"] .sky-body,
.card[data-sky="rain"] .sky-body,
.card[data-sky="snow"] .sky-body,
.card[data-sky="storm"] .sky-body {
    opacity: 0.12 !important;
}

/* ---- Clouds: soft cumulus, lit from above and shaded underneath, drifting across the
   sky below the header so they never sit behind the name. The shape is a blurred
   silhouette used as a mask; the colours are the scene's, greyer when it is wet. ---- */

.sky-cloud {
    top: calc(var(--sky-top, 22%) + var(--cloud-drop, 0%));
    width: 34%;
    aspect-ratio: 240 / 110;
    background: linear-gradient(180deg,
        color-mix(in srgb, var(--sky-grey) calc(var(--wet, 0) * 35%), var(--cloud-hi)) 25%,
        color-mix(in srgb, var(--sky-grey) calc(var(--wet, 0) * 55%), var(--cloud-lo)) 90%);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 110'%3E%3Cfilter id='b' x='-20%25' y='-20%25' width='140%25' height='140%25'%3E%3CfeGaussianBlur stdDeviation='3.2'/%3E%3C/filter%3E%3Cg filter='url(%23b)'%3E%3Ccircle cx='70' cy='66' r='28'/%3E%3Ccircle cx='114' cy='48' r='38'/%3E%3Ccircle cx='160' cy='58' r='30'/%3E%3Ccircle cx='194' cy='74' r='20'/%3E%3Ccircle cx='44' cy='80' r='19'/%3E%3Crect x='30' y='64' width='182' height='34' rx='17'/%3E%3C/g%3E%3C/svg%3E") center / 100% 100% no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 110'%3E%3Cfilter id='b' x='-20%25' y='-20%25' width='140%25' height='140%25'%3E%3CfeGaussianBlur stdDeviation='3.2'/%3E%3C/filter%3E%3Cg filter='url(%23b)'%3E%3Ccircle cx='70' cy='66' r='28'/%3E%3Ccircle cx='114' cy='48' r='38'/%3E%3Ccircle cx='160' cy='58' r='30'/%3E%3Ccircle cx='194' cy='74' r='20'/%3E%3Ccircle cx='44' cy='80' r='19'/%3E%3Crect x='30' y='64' width='182' height='34' rx='17'/%3E%3C/g%3E%3C/svg%3E") center / 100% 100% no-repeat;
    transition: opacity 2s;
    animation: tm-drift 70s ease-in-out infinite alternate;
}

.sky-cloud-1 { left: 2%; --cloud-drop: 1%; }
.sky-cloud-2 { left: 63%; width: 27%; --cloud-drop: 12%; animation-duration: 90s; animation-direction: alternate-reverse; }
.sky-cloud-3 { left: 38%; width: 22%; --cloud-drop: 0.5%; animation-duration: 110s; }

.card[data-sky="partly"] .sky-cloud-1,
.card[data-sky="partly"] .sky-cloud-2 {
    opacity: 0.92;
}

.card[data-sky="cloudy"] .sky-cloud,
.card[data-sky="drizzle"] .sky-cloud,
.card[data-sky="rain"] .sky-cloud,
.card[data-sky="snow"] .sky-cloud,
.card[data-sky="storm"] .sky-cloud {
    opacity: 1;
}

@keyframes tm-drift {
    from { transform: translateX(-12%); }
    to { transform: translateX(12%); }
}

/* ---- Fog: banks of mist drifting across, in two layers at their own speeds, lying
   thicker towards the ground, over a haze that washes the sky out. Each layer is an SVG
   tile of blurred banks that slides one tile sideways and starts again. ---- */

.sky-fog {
    inset: 0;
    background: linear-gradient(180deg, transparent 0%, var(--sky-mist) 55%, var(--sky-mist) 100%);
}

.sky-fog::before,
.sky-fog::after {
    content: '';
    position: absolute;
    left: 0;
    right: -640px;
    opacity: var(--fog-alpha, 0.9);
    will-change: transform;
}

.sky-fog::before {
    top: 12%;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='640' height='300' viewBox='0 0 640 300' preserveAspectRatio='none'%3E%3Cdefs%3E%3Cfilter id='b' filterUnits='userSpaceOnUse' x='-640' y='-300' width='1920' height='900'%3E%3CfeGaussianBlur stdDeviation='20'/%3E%3C/filter%3E%3C/defs%3E%3Cg fill='%23fff' filter='url(%23b)'%3E%3Cellipse cx='37' cy='291' rx='185' ry='42' opacity='0.52'/%3E%3Cellipse cx='677' cy='291' rx='185' ry='42' opacity='0.52'/%3E%3Cellipse cx='93' cy='128' rx='112' ry='40' opacity='0.64'/%3E%3Cellipse cx='733' cy='128' rx='112' ry='40' opacity='0.64'/%3E%3Cellipse cx='249' cy='262' rx='220' ry='32' opacity='0.75'/%3E%3Cellipse cx='889' cy='262' rx='220' ry='32' opacity='0.75'/%3E%3Cellipse cx='304' cy='223' rx='113' ry='30' opacity='0.62'/%3E%3Cellipse cx='433' cy='91' rx='117' ry='48' opacity='0.50'/%3E%3Cellipse cx='-131' cy='152' rx='150' ry='51' opacity='0.51'/%3E%3Cellipse cx='509' cy='152' rx='150' ry='51' opacity='0.51'/%3E%3Cellipse cx='-73' cy='239' rx='153' ry='42' opacity='0.75'/%3E%3Cellipse cx='567' cy='239' rx='153' ry='42' opacity='0.75'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 640px 100% repeat-x;
    animation: tm-fog 95s linear infinite;
}

.sky-fog::after {
    top: 40%;
    bottom: -6%;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='640' height='300' viewBox='0 0 640 300' preserveAspectRatio='none'%3E%3Cdefs%3E%3Cfilter id='b' filterUnits='userSpaceOnUse' x='-640' y='-300' width='1920' height='900'%3E%3CfeGaussianBlur stdDeviation='24'/%3E%3C/filter%3E%3C/defs%3E%3Cg fill='%23fff' filter='url(%23b)'%3E%3Cellipse cx='14' cy='168' rx='176' ry='38' opacity='0.77'/%3E%3Cellipse cx='654' cy='168' rx='176' ry='38' opacity='0.77'/%3E%3Cellipse cx='204' cy='264' rx='183' ry='53' opacity='0.60'/%3E%3Cellipse cx='844' cy='264' rx='183' ry='53' opacity='0.60'/%3E%3Cellipse cx='283' cy='272' rx='241' ry='49' opacity='0.55'/%3E%3Cellipse cx='923' cy='272' rx='241' ry='49' opacity='0.55'/%3E%3Cellipse cx='-241' cy='291' rx='176' ry='42' opacity='0.81'/%3E%3Cellipse cx='399' cy='291' rx='176' ry='42' opacity='0.81'/%3E%3Cellipse cx='-37' cy='296' rx='145' ry='49' opacity='0.85'/%3E%3Cellipse cx='603' cy='296' rx='145' ry='49' opacity='0.85'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 640px 100% repeat-x;
    animation: tm-fog 58s linear infinite;
}

@keyframes tm-fog {
    to { transform: translateX(-640px); }
}

.card[data-sky="fog"] .sky-fog {
    opacity: 1;
}

.card[data-phase="dawn"] .sky-fog,
.card[data-phase="dusk"] .sky-fog {
    --fog-alpha: 0.5;
}

.card[data-phase="night"] .sky-fog {
    --fog-alpha: 0.28;
}

/* ---- Rain and drizzle: streaks on a slant, in two layers - a far one, finer, fainter
   and slower, and a near one - each an SVG tile of streaks, fading towards the top as a
   falling drop blurs, that falls by exactly one tile and starts again, which the
   compositor can do without repainting. Drizzle is the far layer alone, slower; a storm
   is both, faster and more slanted. Snow shares the layers, below. ---- */

.sky-precip {
    inset: -35% -30% -5%;
    transform: rotate(var(--rain-slant, 9deg));
}

.sky-precip::before,
.sky-precip::after {
    content: '';
    position: absolute;
    inset: 0;
    will-change: transform;
}

.sky-precip::before {
    top: -200px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='200'%3E%3Cdefs%3E%3ClinearGradient id='g' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%23fff' stop-opacity='0'/%3E%3Cstop offset='1' stop-color='%23fff'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cg fill='url(%23g)'%3E%3Crect x='5.2' y='129.9' width='1' height='15.9' opacity='0.37'/%3E%3Crect x='11.3' y='52.2' width='1' height='12.6' opacity='0.58'/%3E%3Crect x='14.8' y='159.9' width='1' height='16.9' opacity='0.45'/%3E%3Crect x='23.2' y='171.8' width='1' height='16.2' opacity='0.47'/%3E%3Crect x='31.2' y='83.4' width='1' height='11.8' opacity='0.55'/%3E%3Crect x='37.1' y='94.9' width='1' height='12.4' opacity='0.45'/%3E%3Crect x='43.2' y='3.6' width='1' height='11.7' opacity='0.41'/%3E%3Crect x='53.1' y='31.2' width='1' height='12.8' opacity='0.40'/%3E%3Crect x='58.3' y='43.4' width='1' height='14.1' opacity='0.44'/%3E%3Crect x='66.0' y='86.6' width='1' height='11.2' opacity='0.54'/%3E%3Crect x='72.2' y='181.3' width='1' height='15.4' opacity='0.41'/%3E%3Crect x='78.1' y='10.9' width='1' height='9.5' opacity='0.46'/%3E%3Crect x='84.6' y='142.7' width='1' height='16.9' opacity='0.48'/%3E%3Crect x='94.3' y='20.6' width='1' height='9.8' opacity='0.50'/%3E%3Crect x='98.6' y='103.7' width='1' height='15.5' opacity='0.54'/%3E%3Crect x='104.7' y='63.1' width='1' height='10.9' opacity='0.43'/%3E%3Crect x='111.1' y='34.7' width='1' height='15.6' opacity='0.38'/%3E%3Crect x='119.7' y='119.3' width='1' height='13.9' opacity='0.37'/%3E%3Crect x='126.0' y='154.2' width='1' height='17.8' opacity='0.54'/%3E%3Crect x='131.3' y='68.9' width='1' height='13.3' opacity='0.37'/%3E%3Crect x='137.4' y='139.9' width='1' height='12.9' opacity='0.51'/%3E%3Crect x='146.3' y='113.9' width='1' height='13.0' opacity='0.43'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 150px 200px;
    opacity: var(--rain-far, 0.85);
    animation: tm-rain-far var(--rain-far-time, 0.6s) linear infinite;
}

.sky-precip::after {
    top: -300px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='190' height='300'%3E%3Cdefs%3E%3ClinearGradient id='g' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%23fff' stop-opacity='0'/%3E%3Cstop offset='1' stop-color='%23fff'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cg fill='url(%23g)'%3E%3Crect x='7.4' y='150.2' width='1.5' height='34.6' opacity='0.78'/%3E%3Crect x='23.7' y='10.5' width='1.5' height='25.8' opacity='0.81'/%3E%3Crect x='32.8' y='27.9' width='1.5' height='33.6' opacity='0.88'/%3E%3Crect x='47.0' y='216.3' width='1.5' height='27.3' opacity='0.65'/%3E%3Crect x='68.3' y='53.1' width='1.5' height='41.9' opacity='0.92'/%3E%3Crect x='79.7' y='63.4' width='1.5' height='37.9' opacity='0.88'/%3E%3Crect x='97.5' y='243.2' width='1.5' height='40.1' opacity='0.84'/%3E%3Crect x='112.4' y='237.7' width='1.5' height='30.5' opacity='0.87'/%3E%3Crect x='123.3' y='91.9' width='1.5' height='41.5' opacity='0.86'/%3E%3Crect x='142.9' y='112.7' width='1.5' height='30.7' opacity='0.76'/%3E%3Crect x='148.4' y='196.4' width='1.5' height='35.0' opacity='0.79'/%3E%3Crect x='169.8' y='163.3' width='1.5' height='35.2' opacity='0.73'/%3E%3Crect x='184.7' y='132.3' width='1.5' height='32.0' opacity='0.87'/%3E%3C/g%3E%3C/svg%3E") 40px 0 / 190px 300px;
    opacity: var(--rain-near, 0.8);
    animation: tm-rain-near var(--rain-near-time, 0.42s) linear infinite;
}

@keyframes tm-rain-far {
    to { transform: translateY(200px); }
}

@keyframes tm-rain-near {
    to { transform: translateY(300px); }
}

.card[data-sky="rain"] .sky-precip,
.card[data-sky="storm"] .sky-precip {
    opacity: 1;
}

/* Fainter at night, when only what light there is catches it. */
.card[data-phase="night"] .sky-precip {
    --rain-far: 0.55;
    --rain-near: 0.5;
}

.card[data-sky="drizzle"] .sky-precip {
    opacity: 1;
    --rain-far: 1;
    --rain-slant: 5deg;
    --rain-far-time: 1.15s;
}

.card[data-sky="drizzle"] .sky-precip::after {
    display: none;
}

.card[data-sky="storm"] .sky-precip {
    --rain-slant: 17deg;
    --rain-far: 1;
    --rain-near: 0.95;
    --rain-far-time: 0.45s;
    --rain-near-time: 0.3s;
}

/* Snow: flakes of every size, scattered at random, in two layers - small soft ones far
   off, falling slowly, and fewer big ones near, faster - each wavering as it falls, with
   a slow sway of the wind over both. */

.card[data-sky="snow"] .sky-precip {
    opacity: 1;
    transform: none;
    animation: tm-snow-sway 7s ease-in-out infinite alternate;
}

.card[data-sky="snow"] .sky-precip::before {
    top: -240px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cdefs%3E%3CradialGradient id='f'%3E%3Cstop offset='0' stop-color='%23fff'/%3E%3Cstop offset='.5' stop-color='%23fff' stop-opacity='.85'/%3E%3Cstop offset='1' stop-color='%23fff' stop-opacity='0'/%3E%3C/radialGradient%3E%3C/defs%3E%3Cg fill='url(%23f)'%3E%3Ccircle cx='230.2' cy='165.4' r='0.91' opacity='0.57'/%3E%3Ccircle cx='139.1' cy='58.8' r='2.16' opacity='0.42'/%3E%3Ccircle cx='103.8' cy='206.3' r='1.70' opacity='0.73'/%3E%3Ccircle cx='22.0' cy='62.0' r='1.70' opacity='0.60'/%3E%3Ccircle cx='170.9' cy='233.8' r='1.69' opacity='0.83'/%3E%3Ccircle cx='90.9' cy='126.3' r='1.06' opacity='0.49'/%3E%3Ccircle cx='202.1' cy='100.0' r='1.71' opacity='0.47'/%3E%3Ccircle cx='230.9' cy='2.9' r='2.00' opacity='0.48'/%3E%3Ccircle cx='36.7' cy='212.9' r='1.21' opacity='0.42'/%3E%3Ccircle cx='132.6' cy='158.7' r='2.19' opacity='0.80'/%3E%3Ccircle cx='67.1' cy='186.6' r='1.98' opacity='0.84'/%3E%3Ccircle cx='191.7' cy='45.0' r='1.16' opacity='0.55'/%3E%3Ccircle cx='-0.2' cy='95.4' r='0.97' opacity='0.74'/%3E%3Ccircle cx='239.8' cy='95.4' r='0.97' opacity='0.74'/%3E%3Ccircle cx='34.9' cy='111.0' r='1.02' opacity='0.62'/%3E%3Ccircle cx='92.9' cy='36.9' r='1.18' opacity='0.63'/%3E%3Ccircle cx='176.6' cy='145.2' r='1.60' opacity='0.67'/%3E%3Ccircle cx='30.7' cy='165.6' r='0.90' opacity='0.69'/%3E%3Ccircle cx='157.4' cy='101.4' r='0.90' opacity='0.57'/%3E%3Ccircle cx='230.2' cy='50.8' r='1.07' opacity='0.61'/%3E%3Ccircle cx='46.7' cy='38.7' r='1.94' opacity='0.75'/%3E%3Ccircle cx='73.6' cy='79.9' r='0.90' opacity='0.80'/%3E%3Ccircle cx='66.5' cy='12.9' r='1.46' opacity='0.74'/%3E%3Ccircle cx='181.1' cy='196.6' r='2.37' opacity='0.57'/%3E%3Ccircle cx='132.9' cy='14.1' r='1.84' opacity='0.67'/%3E%3Ccircle cx='187.5' cy='71.6' r='2.19' opacity='0.72'/%3E%3Ccircle cx='114.2' cy='90.7' r='1.69' opacity='0.67'/%3E%3Ccircle cx='146.2' cy='189.6' r='1.41' opacity='0.42'/%3E%3Ccircle cx='3.3' cy='197.8' r='2.36' opacity='0.58'/%3E%3Ccircle cx='60.8' cy='153.2' r='1.29' opacity='0.44'/%3E%3Ccircle cx='192.0' cy='171.4' r='0.93' opacity='0.41'/%3E%3Ccircle cx='221.4' cy='119.7' r='0.92' opacity='0.62'/%3E%3Ccircle cx='204.3' cy='-1.7' r='2.52' opacity='0.77'/%3E%3Ccircle cx='204.3' cy='238.3' r='2.52' opacity='0.77'/%3E%3Ccircle cx='101.2' cy='165.4' r='1.58' opacity='0.73'/%3E%3Ccircle cx='129.7' cy='227.0' r='0.90' opacity='0.79'/%3E%3Ccircle cx='214.4' cy='198.5' r='0.99' opacity='0.45'/%3E%3Ccircle cx='105.7' cy='0.5' r='0.98' opacity='0.52'/%3E%3Ccircle cx='105.7' cy='240.5' r='0.98' opacity='0.52'/%3E%3Ccircle cx='17.7' cy='25.7' r='2.07' opacity='0.50'/%3E%3Ccircle cx='138.4' cy='126.8' r='1.28' opacity='0.82'/%3E%3Ccircle cx='8.1' cy='224.5' r='0.90' opacity='0.54'/%3E%3Ccircle cx='202.3' cy='215.7' r='0.90' opacity='0.59'/%3E%3Ccircle cx='123.1' cy='39.9' r='1.43' opacity='0.66'/%3E%3Ccircle cx='85.2' cy='149.7' r='1.64' opacity='0.52'/%3E%3Ccircle cx='148.2' cy='210.2' r='1.79' opacity='0.69'/%3E%3Ccircle cx='109.6' cy='115.4' r='1.39' opacity='0.76'/%3E%3Ccircle cx='163.8' cy='71.6' r='0.97' opacity='0.62'/%3E%3Ccircle cx='207.1' cy='60.6' r='0.99' opacity='0.40'/%3E%3Ccircle cx='172.1' cy='21.6' r='2.13' opacity='0.71'/%3E%3Ccircle cx='65.8' cy='119.5' r='0.90' opacity='0.64'/%3E%3Ccircle cx='150.9' cy='35.5' r='1.33' opacity='0.77'/%3E%3Ccircle cx='201.2' cy='22.7' r='1.78' opacity='0.41'/%3E%3Ccircle cx='169.1' cy='40.2' r='1.51' opacity='0.79'/%3E%3Ccircle cx='42.2' cy='79.4' r='1.22' opacity='0.40'/%3E%3Ccircle cx='180.3' cy='99.2' r='0.90' opacity='0.58'/%3E%3Ccircle cx='111.9' cy='183.3' r='2.46' opacity='0.40'/%3E%3Ccircle cx='87.9' cy='63.2' r='0.90' opacity='0.80'/%3E%3Ccircle cx='15.7' cy='135.8' r='0.91' opacity='0.60'/%3E%3Ccircle cx='88.6' cy='10.7' r='1.19' opacity='0.72'/%3E%3Ccircle cx='136.1' cy='106.0' r='1.15' opacity='0.82'/%3E%3Ccircle cx='192.0' cy='126.3' r='0.90' opacity='0.45'/%3E%3Ccircle cx='201.5' cy='153.6' r='1.04' opacity='0.47'/%3E%3Ccircle cx='227.7' cy='76.3' r='1.63' opacity='0.75'/%3E%3Ccircle cx='28.3' cy='86.5' r='1.16' opacity='0.65'/%3E%3Ccircle cx='35.7' cy='149.2' r='2.30' opacity='0.78'/%3E%3Ccircle cx='76.7' cy='173.4' r='1.17' opacity='0.57'/%3E%3Ccircle cx='92.1' cy='101.4' r='1.11' opacity='0.83'/%3E%3Ccircle cx='51.6' cy='177.0' r='0.90' opacity='0.42'/%3E%3Ccircle cx='105.0' cy='135.9' r='2.26' opacity='0.63'/%3E%3Ccircle cx='236.9' cy='30.7' r='2.16' opacity='0.49'/%3E%3Ccircle cx='20.6' cy='0.6' r='1.14' opacity='0.40'/%3E%3Ccircle cx='20.6' cy='240.6' r='1.14' opacity='0.40'/%3E%3Ccircle cx='151.2' cy='233.2' r='2.05' opacity='0.63'/%3E%3Ccircle cx='143.3' cy='80.2' r='1.41' opacity='0.69'/%3E%3Ccircle cx='70.1' cy='36.0' r='0.98' opacity='0.72'/%3E%3Ccircle cx='36.3' cy='23.6' r='2.34' opacity='0.51'/%3E%3Ccircle cx='42.3' cy='1.9' r='1.22' opacity='0.84'/%3E%3Ccircle cx='5.9' cy='60.9' r='2.22' opacity='0.65'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 240px 240px;
    opacity: var(--snow-far, 0.9);
    animation: tm-snow-far 12s linear infinite;
}

.card[data-sky="snow"] .sky-precip::after {
    top: -360px;
    display: block;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='360'%3E%3Cdefs%3E%3CradialGradient id='f'%3E%3Cstop offset='0' stop-color='%23fff'/%3E%3Cstop offset='.5' stop-color='%23fff' stop-opacity='.85'/%3E%3Cstop offset='1' stop-color='%23fff' stop-opacity='0'/%3E%3C/radialGradient%3E%3C/defs%3E%3Cg fill='url(%23f)'%3E%3Ccircle cx='57.7' cy='140.5' r='2.45' opacity='0.85'/%3E%3Ccircle cx='185.5' cy='21.8' r='4.62' opacity='0.97'/%3E%3Ccircle cx='211.1' cy='168.6' r='2.58' opacity='0.97'/%3E%3Ccircle cx='112.5' cy='282.4' r='3.72' opacity='0.88'/%3E%3Ccircle cx='250.4' cy='292.6' r='3.36' opacity='0.95'/%3E%3Ccircle cx='93.1' cy='-1.3' r='2.56' opacity='0.87'/%3E%3Ccircle cx='93.1' cy='358.7' r='2.56' opacity='0.87'/%3E%3Ccircle cx='11.1' cy='61.6' r='2.42' opacity='0.87'/%3E%3Ccircle cx='280.2' cy='204.9' r='2.61' opacity='0.93'/%3E%3Ccircle cx='41.0' cy='253.9' r='2.55' opacity='0.91'/%3E%3Ccircle cx='140.5' cy='109.5' r='2.66' opacity='0.87'/%3E%3Ccircle cx='4.8' cy='330.6' r='4.07' opacity='0.87'/%3E%3Ccircle cx='269.6' cy='119.6' r='4.64' opacity='0.90'/%3E%3Ccircle cx='180.2' cy='236.8' r='3.35' opacity='0.83'/%3E%3Ccircle cx='74.2' cy='199.7' r='4.35' opacity='0.96'/%3E%3Ccircle cx='246.1' cy='55.8' r='3.40' opacity='0.95'/%3E%3Ccircle cx='239.6' cy='343.5' r='5.58' opacity='0.93'/%3E%3Ccircle cx='152.8' cy='58.6' r='2.43' opacity='0.87'/%3E%3Ccircle cx='55.3' cy='62.9' r='4.28' opacity='0.91'/%3E%3Ccircle cx='161.0' cy='159.7' r='2.41' opacity='0.86'/%3E%3Ccircle cx='118.2' cy='182.1' r='3.10' opacity='0.98'/%3E%3Ccircle cx='169.3' cy='310.0' r='4.40' opacity='0.99'/%3E%3Ccircle cx='62.9' cy='290.7' r='5.59' opacity='0.89'/%3E%3C/g%3E%3C/svg%3E") 70px 0 / 300px 360px;
    opacity: var(--snow-near, 1);
    animation: tm-snow-near 7s linear infinite;
}

.card[data-phase="night"][data-sky="snow"] .sky-precip {
    --snow-far: 0.65;
    --snow-near: 0.8;
}

@keyframes tm-snow-sway {
    from { transform: translateX(-14px); }
    to { transform: translateX(14px); }
}

@keyframes tm-snow-far {
    0% { transform: translate(0, 0); }
    25% { transform: translate(4px, 60px); }
    50% { transform: translate(0, 120px); }
    75% { transform: translate(-4px, 180px); }
    100% { transform: translate(0, 240px); }
}

@keyframes tm-snow-near {
    0% { transform: translate(0, 0); }
    20% { transform: translate(9px, 72px); }
    45% { transform: translate(-3px, 162px); }
    70% { transform: translate(-10px, 252px); }
    100% { transform: translate(0, 360px); }
}

/* ---- Lightning, now and then, in a storm. ---- */

.sky-flash {
    inset: 0;
    background: rgba(235, 240, 255, 0.75);
}

.card[data-sky="storm"] .sky-flash {
    animation: tm-flash 9s linear infinite;
}

@keyframes tm-flash {
    0%, 91%, 100% { opacity: 0; }
    91.6% { opacity: 0.85; }
    92.4% { opacity: 0; }
    93.4% { opacity: 0.55; }
    94.4% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .sky-stars::after,
    .sky-cloud,
    .sky-fog::before,
    .sky-fog::after,
    .sky-precip,
    .sky-precip::before,
    .sky-precip::after,
    .card[data-sky] .sky-precip,
    .card[data-sky="storm"] .sky-flash {
        animation: none;
    }

    .sky-body {
        transition: none;
    }
}

/* ==== Analogue faces ======================================================== */

/* Each dial sets its colours here, as the custom properties a clock's look overrides
   inline (js/faces.js applyLook): --face-bg the dial, --face-fg the markings,
   --face-hand the hour and minute hands, --face-second the second hand, and
   --face-alpha how opaque the background is. The rest are worked out from those, so a
   chosen colour carries through. */

.face-classic {
    --face-bg: var(--tm-dial);
    --face-fg: var(--tm-dial-ink);
    --face-hand: var(--face-fg);
    --face-second: var(--tm-accent);
    --face-rim: color-mix(in srgb, var(--face-bg) 84%, var(--face-fg));
    --face-muted: color-mix(in srgb, var(--face-fg) 45%, var(--face-bg));
}

.face-bg { fill: var(--face-bg); fill-opacity: var(--face-alpha, 1); }
.face-rim { fill: var(--face-rim); fill-opacity: var(--face-alpha, 1); }
.face-glow { opacity: var(--face-alpha, 1); }
.face-ink { fill: var(--face-fg); }
.face-hand-ink { fill: var(--face-hand); }
.face-second-ink { fill: var(--face-second); }

.tick {
    stroke: var(--face-muted);
    stroke-width: 1.3;
    stroke-linecap: round;
}

.tick-hour {
    stroke: var(--face-fg);
    stroke-width: 3.2;
}

.dial-numerals text {
    fill: var(--face-fg);
    font: 600 15px 'Inter', 'Segoe UI', system-ui, sans-serif;
    text-anchor: middle;
    dominant-baseline: central;
}

.dial-meridiem {
    fill: var(--face-muted);
    font: 700 9px 'Inter', 'Segoe UI', system-ui, sans-serif;
    letter-spacing: 0.15em;
    text-anchor: middle;
}

.hand line {
    stroke-linecap: round;
}

.hand-hour line {
    stroke: var(--face-hand);
    stroke-width: 6.5;
}

.hand-minute line {
    stroke: var(--face-hand);
    stroke-width: 4.2;
}

.hand-second line {
    stroke: var(--face-second);
    stroke-width: 1.7;
}

.hand-second circle {
    fill: var(--face-second);
}

.hand-pin {
    fill: var(--face-bg);
}

/* ---- BBC: deep blue with a glow, white dots and hands. ---- */

.dial-bbc {
    --face-bg: #0b1d5a;
    --face-fg: #ffffff;
    --face-second: #ffffff;
    --face-rim: color-mix(in srgb, var(--face-bg) 55%, #000);
}

.dial-bbc .hand-second line {
    stroke-width: 1.1;
}

/* ---- Station: white, black bars, the red second hand. ---- */

.dial-station {
    --face-bg: #ffffff;
    --face-fg: #141414;
    --face-second: #d4141c;
    --face-rim: color-mix(in srgb, var(--face-fg) 82%, var(--face-bg));
}

.dial-station .hand-second line {
    stroke-width: 2.2;
    stroke-linecap: butt;
}

/* Small dials keep the ticks and lose the numerals, which would be mud. */
@container face (max-height: 8rem) {
    .dial-numerals,
    .dial-meridiem {
        display: none;
    }
}

/* ==== Digital face ========================================================== */

/* --face-bg is the panel and --face-fg the lit segments; unlit ones are a ghost of them. */
.face-digital {
    --face-bg: var(--tm-lcd-bg);
    --face-fg: var(--tm-lcd-on);
}

.lcd-panel {
    fill: var(--face-bg);
    fill-opacity: var(--face-alpha, 1);
    stroke: color-mix(in srgb, var(--face-bg) 82%, var(--face-fg));
    stroke-opacity: var(--face-alpha, 1);
    stroke-width: 2;
}

.face-digital .seg {
    fill: color-mix(in srgb, var(--face-fg) 8%, transparent);
    transition: fill 0.12s;
}

.face-digital .seg.on {
    fill: var(--face-fg);
    filter: drop-shadow(0 0 3px color-mix(in srgb, var(--face-fg) 55%, transparent));
}

.lcd-days text {
    fill: color-mix(in srgb, var(--face-fg) 8%, transparent);
    font: 700 12px 'Inter', 'Segoe UI', system-ui, sans-serif;
    letter-spacing: 0.08em;
}

.lcd-days text.on {
    fill: var(--face-fg);
}

.lcd-meridiem {
    fill: var(--face-fg);
    font: 700 15px 'Inter', 'Segoe UI', system-ui, sans-serif;
    letter-spacing: 0.1em;
}

/* ---- VFD: blue-green phosphor behind smoked glass and a fine wire mesh. ---- */

.face-vfd {
    --face-bg: #06110f;
    --face-fg: #52f7cf;
}

.face-vfd .lcd-panel {
    stroke: color-mix(in srgb, var(--face-bg) 70%, #fff);
}

.face-vfd .seg {
    fill: color-mix(in srgb, var(--face-fg) 11%, transparent);
}

.face-vfd .seg.on {
    filter: drop-shadow(0 0 2px var(--face-fg)) drop-shadow(0 0 8px color-mix(in srgb, var(--face-fg) 60%, transparent));
}

.face-vfd .lcd-days text {
    fill: color-mix(in srgb, var(--face-fg) 11%, transparent);
}

.face-vfd .lcd-days text.on,
.face-vfd .lcd-meridiem {
    fill: var(--face-fg);
    filter: drop-shadow(0 0 3px var(--face-fg));
}

.vfd-mesh {
    opacity: 0.55;
    pointer-events: none;
}

.vfd-mesh-line {
    stroke: var(--face-bg);
    stroke-width: 0.45;
}

/* ---- Retro LED: a 70s calculator's thin red segments behind dark red glass. ---- */

.face-led {
    --face-bg: #140506;
    --face-fg: #ff2a1c;
}

.face-led .lcd-panel {
    stroke: color-mix(in srgb, var(--face-bg) 75%, var(--face-fg));
}

.face-led .seg {
    fill: color-mix(in srgb, var(--face-fg) 7%, transparent);
    stroke: transparent;
    stroke-width: 1.5;
    stroke-linejoin: round;
}

.face-led .seg.on {
    fill: color-mix(in srgb, var(--face-fg) 82%, #fff);
    stroke: color-mix(in srgb, var(--face-fg) 82%, #fff);
    filter: drop-shadow(0 0 2px var(--face-fg)) drop-shadow(0 0 6px color-mix(in srgb, var(--face-fg) 50%, transparent));
}

.face-led .lcd-days text {
    fill: color-mix(in srgb, var(--face-fg) 7%, transparent);
}

.face-led .lcd-days text.on {
    fill: var(--face-fg);
}

/* ---- LCD: a digital watch's dark segments on grey-green, each casting a faint shadow
   on the reflector behind it - and no glow. ---- */

.face-lcd {
    --face-bg: #c3cbb3;
    --face-fg: #1c2119;
}

.face-lcd .lcd-panel {
    stroke: color-mix(in srgb, var(--face-bg) 60%, #000);
}

.face-lcd .seg {
    fill: color-mix(in srgb, var(--face-fg) 6%, transparent);
}

.face-lcd .seg.on {
    fill: var(--face-fg);
    filter: drop-shadow(1.5px 2px 0 rgba(0, 0, 0, 0.13));
}

.face-lcd .lcd-days text {
    fill: color-mix(in srgb, var(--face-fg) 6%, transparent);
}

.face-lcd .lcd-days text.on {
    fill: var(--face-fg);
}

/* ==== Railway face (split-flap) ============================================= */

/* --face-bg is the flaps and --face-fg their digits; --flap and --flap-2 are the flap's
   two shades with the opacity applied. */
.face-railway {
    --face-bg: var(--tm-flap);
    --face-fg: var(--tm-flap-ink);
    --flap: color-mix(in srgb, var(--face-bg) calc(var(--face-alpha, 1) * 100%), transparent);
    --flap-2: color-mix(in srgb, color-mix(in srgb, var(--face-bg), #fff 6%) calc(var(--face-alpha, 1) * 100%), transparent);
    display: grid;
    place-items: center;
}

.flip-row {
    display: flex;
    align-items: stretch;
    gap: 0.07em;
    /* Two flaps, a gap and the seconds side are about 3.9em wide and 1.42em tall. */
    font-size: min(24cqw, 62cqh);
}

.flap {
    position: relative;
    width: 1.32em;
    height: 1.42em;
    border-radius: 0.1em;
    box-shadow: 0 0.04em 0.12em rgba(0, 0, 0, calc(0.45 * var(--face-alpha, 1)));
    color: var(--face-fg);
    font-family: 'Bahnschrift', 'DIN Alternate', 'Roboto Condensed', 'Arial Narrow', 'Segoe UI', sans-serif;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    perspective: 3.5em;
}

.flap-half {
    position: absolute;
    left: 0;
    right: 0;
    height: 50%;
    overflow: hidden;
    background: var(--flap);
    backface-visibility: hidden;
}

.flap-top {
    top: 0;
    border-radius: 0.1em 0.1em 0 0;
    background: linear-gradient(var(--flap-2), var(--flap));
    transform-origin: 50% 100%;
}

.flap-bottom {
    bottom: 0;
    border-radius: 0 0 0.1em 0.1em;
    background: linear-gradient(var(--flap), var(--flap-2));
    transform-origin: 50% 0;
}

.flap-text {
    position: absolute;
    left: 0;
    right: 0;
    display: grid;
    height: 200%;
    place-items: center;
    line-height: 1;
    letter-spacing: -0.01em;
}

.flap-top .flap-text { top: 0; }
.flap-bottom .flap-text { bottom: 0; }

.flap-fall,
.flap-land {
    display: none;
    z-index: 2;
}

.flipping .flap-fall {
    display: block;
    animation: tm-fall 0.28s ease-in forwards;
}

.flipping .flap-land {
    display: block;
    animation: tm-land 0.28s ease-out 0.28s both;
}

@keyframes tm-fall {
    from { transform: rotateX(0deg); filter: brightness(1); }
    to { transform: rotateX(-90deg); filter: brightness(0.6); }
}

@keyframes tm-land {
    from { transform: rotateX(90deg); filter: brightness(1.4); }
    to { transform: rotateX(0deg); filter: brightness(1); }
}

.flap-hinge {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(50% - 0.012em);
    z-index: 3;
    height: 0.024em;
    background: var(--tm-flap-hinge);
    opacity: 0.85;
}


.flip-sep {
    width: 0.12em;
}

.flip-side {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    margin-left: 0.07em;
}

.flip-meridiem {
    padding: 0.1em 0.12em;
    border-radius: 0.06em;
    background: var(--flap);
    color: var(--face-fg);
    font: 700 0.22em/1 'Bahnschrift', 'Segoe UI', sans-serif;
    letter-spacing: 0.08em;
    text-align: center;
}

.flip-secs {
    margin-top: auto;
}

.flap-small {
    font-size: 0.5em;
}

@media (prefers-reduced-motion: reduce) {
    .flipping .flap-fall,
    .flipping .flap-land {
        display: none;
        animation: none;
    }
}

/* ==== Railway face (UK platform display) ==================================== */

/* --face-bg is the panel and --face-fg the LEDs; the unlit ones are a ghost of them. */
.face-platform {
    --face-bg: #070707;
    --face-fg: #ffa31a;
}

.dm-panel {
    fill: var(--face-bg);
    fill-opacity: var(--face-alpha, 1);
    stroke: color-mix(in srgb, var(--face-bg) 78%, #fff);
    stroke-opacity: var(--face-alpha, 1);
    stroke-width: 3;
}

.dm-off {
    fill: color-mix(in srgb, var(--face-fg) 10%, #181818);
}

.dm-on {
    fill: color-mix(in srgb, var(--face-fg) 80%, #fff);
    filter: drop-shadow(0 0 2.5px var(--face-fg));
}

/* ==== Exported page ========================================================= */

.tm-standalone {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: var(--tm-bg);
    color: var(--tm-text);
}

.sa-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: none;
    padding: 0.55rem 0.9rem;
    background: var(--tm-chrome);
    border-bottom: 1px solid var(--tm-border);
}

.sa-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.sa-now {
    flex: 1;
    color: var(--tm-muted);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.sa-btn {
    padding: 0.3rem 0.8rem;
    border: 1px solid var(--tm-border);
    border-radius: 0.5rem;
    background: var(--tm-surface);
    color: var(--tm-text);
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
}

.sa-foot {
    flex: none;
    padding: 0.25rem 0.9rem;
    color: var(--tm-faint);
    font-size: 0.68rem;
    text-align: right;
}

.tm-export.kiosk .sa-bar,
.tm-export.kiosk .sa-foot {
    display: none;
}
