/* =========================================================
   infra.day — a Swiss celestial almanac of unloved infra
   Palette: honeyed-neutral. Type: Bebas Neue / Inter / Cormorant Garamond.
   ========================================================= */

/* ---------- Custom properties ---------- */
:root {
    /* honeyed-neutral palette */
    --beeswax:        #F5EBD8;   /* primary background */
    --honey-paper:    #E8DBC4;   /* hairline grid, secondary background */
    --faded-brass:    #A1846A;   /* accents, italic Cormorant captions */
    --tarnished-gilt: #7A6951;   /* secondary text, separators */
    --coffee-bean:    #2C231C;   /* primary text */
    --molasses:       #1F1813;   /* the giant Bebas glyphs */
    --honey-gold:     #D6A24E;   /* the only accent */

    /* type-scale */
    --type-hour:       clamp(12rem, 32vw, 32rem);
    --type-wordmark:   clamp(6rem, 16vw, 18rem);
    --type-body:       0.875rem;        /* 14px */
    --type-caption:    0.6875rem;       /* 11px */
    --type-table:      0.5625rem;       /* 9pt */
    --type-star-name:  0.6875rem;

    /* baseline grid */
    --baseline: 8px;
    --gutter:   clamp(20px, 4.4vw, 64px);

    /* mechanical Swiss easing */
    --tick: cubic-bezier(0.7, 0, 0.3, 1);
}

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

html, body {
    height: 100%;
    background: var(--beeswax);
    color: var(--coffee-bean);
    font-family: "Inter", system-ui, sans-serif;
    font-weight: 300;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "tnum" 1, "ss01" 1;
}

body {
    overflow-x: hidden;
    position: relative;
}

/* ---------- The honey-paper hairline grid (always faintly visible) ---------- */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(to right, var(--honey-paper) 1px, transparent 1px),
        linear-gradient(to bottom, var(--honey-paper) 1px, transparent 1px);
    background-size:
        calc(100vw / 8) 100%,
        100% var(--baseline);
    opacity: 0.55;
    mix-blend-mode: multiply;
}

/* a deeper vertical hairline at every column to feel like a Müller-Brockmann sheet */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(to right,
            transparent calc(100% / 8 * 1 - 1px), var(--honey-paper) calc(100% / 8 * 1 - 1px), var(--honey-paper) calc(100% / 8 * 1), transparent calc(100% / 8 * 1),
            transparent calc(100% / 8 * 4 - 1px), var(--honey-paper) calc(100% / 8 * 4 - 1px), var(--honey-paper) calc(100% / 8 * 4), transparent calc(100% / 8 * 4));
    opacity: 0.4;
}

main {
    position: relative;
    z-index: 1;
}

/* =========================================================
   The hour panel — 8col x 16row Swiss grid, 100vh
   ========================================================= */

.hour {
    position: relative;
    min-height: 100vh;
    height: 100vh;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(16, 1fr);
    column-gap: var(--gutter);
    padding: calc(var(--baseline) * 4) calc(var(--baseline) * 4);
    border-bottom: 1px solid var(--honey-paper);
    overflow: hidden;
}

/* Hour glyph — Bebas Neue, near-black, columns 1–3, sticky */
.hour-glyph {
    grid-column: 1 / 4;
    grid-row: 3 / 12;
    position: sticky;
    top: calc(var(--baseline) * 4);
    align-self: start;
    font-family: "Bebas Neue", "Oswald", "Helvetica Neue", sans-serif;
    font-weight: 400;
    font-size: var(--type-hour);
    line-height: 0.82;
    letter-spacing: -0.02em;
    color: var(--molasses);
    margin: 0;
    user-select: none;
    transition: color 600ms var(--tick);
}

/* Facts table — columns 4–5, top */
.facts {
    grid-column: 4 / 6;
    grid-row: 3 / 9;
    align-self: start;
    border-collapse: collapse;
    font-size: var(--type-table);
    line-height: calc(14 / 9);
    font-weight: 300;
    color: var(--coffee-bean);
    border-top: 1px solid var(--tarnished-gilt);
    border-bottom: 1px solid var(--tarnished-gilt);
    width: 100%;
    table-layout: fixed;
}

.facts caption {
    text-align: left;
    font-family: "Cormorant Garamond", "Lora", Georgia, serif;
    font-style: italic;
    font-weight: 400;
    font-size: var(--type-caption);
    color: var(--faded-brass);
    padding: calc(var(--baseline) * 1) 0 calc(var(--baseline) * 1.5) 0;
    caption-side: top;
    letter-spacing: 0.01em;
}

.facts tbody tr {
    border-top: 1px solid var(--honey-paper);
}

.facts tbody tr:first-child {
    border-top: none;
}

.facts td {
    padding: calc(var(--baseline) * 0.75) calc(var(--baseline) * 1) calc(var(--baseline) * 0.75) 0;
    vertical-align: top;
    font-feature-settings: "tnum" 1, "ss01" 1;
}

.facts td:first-child {
    font-weight: 500;
    color: var(--molasses);
    width: 38%;
    white-space: nowrap;
}

.facts td:last-child {
    color: var(--tarnished-gilt);
}

/* Constellation SVG — columns 5–9 */
.constellation {
    grid-column: 5 / 9;
    grid-row: 2 / 14;
    width: 100%;
    height: 100%;
    color: var(--coffee-bean);
    overflow: visible;
}

.constellation .edge {
    fill: none;
    stroke: var(--tarnished-gilt);
    stroke-width: 1;
    stroke-linecap: round;
    stroke-dasharray: var(--dash-len, 0);
    stroke-dashoffset: var(--dash-len, 0);
    transition: stroke-dashoffset 1200ms var(--tick), stroke 600ms var(--tick);
    opacity: 0.85;
}

.constellation .edge.dotted {
    stroke-dasharray: 2 4;
    stroke-dashoffset: 0;
}

.hour.in-view .constellation .edge {
    stroke-dashoffset: 0;
}

.constellation .flip-group {
    transition: transform 600ms var(--tick);
    transform-origin: var(--cx, 50%) var(--cy, 50%);
    transform-box: fill-box;
    transform-style: preserve-3d;
}

.constellation .node {
    cursor: pointer;
}

.constellation .node .icon {
    color: var(--coffee-bean);
    opacity: 0;
    transition: opacity 600ms var(--tick), color 600ms var(--tick);
}

.hour.in-view .constellation .node .icon {
    opacity: 1;
}

.constellation .node .star {
    fill: var(--coffee-bean);
    transition: fill 800ms var(--tick), transform 600ms var(--tick), r 600ms var(--tick);
}

.constellation .node.lit .star {
    fill: var(--honey-gold);
}

.constellation .node.lit .icon {
    color: var(--honey-gold);
}

/* Card-flip — back face */
.constellation .face-back {
    opacity: 0;
    pointer-events: none;
    transition: opacity 300ms var(--tick) 250ms;
}

.constellation .node.flipped .flip-group {
    transform: rotateY(180deg);
}

.constellation .node.flipped .face-front {
    opacity: 0;
    transition: opacity 200ms var(--tick);
}

.constellation .node.flipped .face-back {
    opacity: 1;
    pointer-events: auto;
}

.constellation .face-back rect.back-card {
    fill: var(--coffee-bean);
    stroke: var(--molasses);
    stroke-width: 1;
}

.constellation .face-back text.back-title {
    fill: var(--honey-gold);
    font-family: "Bebas Neue", sans-serif;
    font-size: 14px;
    letter-spacing: 0.04em;
}

.constellation .face-back text.back-body {
    fill: var(--beeswax);
    font-family: "Inter", sans-serif;
    font-size: 9px;
    font-weight: 300;
}

.constellation .face-back text.back-meta {
    fill: var(--faded-brass);
    font-family: "Cormorant Garamond", serif;
    font-style: italic;
    font-size: 9px;
}

/* Micro-copy & marginalia */
.micro-copy {
    grid-column: 4 / 6;
    grid-row: 10 / 14;
    align-self: start;
    font-size: var(--type-caption);
    line-height: calc(18 / 11);
    color: var(--coffee-bean);
    max-width: 38ch;
    border-top: 1px solid var(--honey-paper);
    padding-top: calc(var(--baseline) * 1.5);
    margin-top: calc(var(--baseline) * 1.5);
    font-weight: 300;
}

.marginalia {
    grid-column: 8 / 9;
    grid-row: 2 / 3;
    justify-self: end;
    align-self: start;
    font-family: "Cormorant Garamond", serif;
    font-style: italic;
    font-weight: 400;
    font-size: var(--type-caption);
    color: var(--faded-brass);
    letter-spacing: 0.02em;
}

/* Caption strip at baseline 16 */
.caption-strip {
    grid-column: 1 / 9;
    grid-row: 16 / 17;
    align-self: end;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    border-top: 1px solid var(--tarnished-gilt);
    padding-top: calc(var(--baseline) * 1);
    margin-top: auto;
    font-size: var(--type-table);
    color: var(--tarnished-gilt);
    font-feature-settings: "tnum" 1;
}

.caption-strip .time {
    font-family: "Bebas Neue", sans-serif;
    font-size: 12px;
    letter-spacing: 0.04em;
    color: var(--molasses);
}

.caption-strip .latin-name {
    font-family: "Cormorant Garamond", serif;
    font-style: italic;
    font-size: 11px;
    color: var(--faded-brass);
    flex: 1;
    text-align: center;
    letter-spacing: 0.02em;
}

.caption-strip .signature {
    font-family: "Inter", sans-serif;
    font-weight: 300;
    font-size: 9px;
    text-align: right;
    color: var(--tarnished-gilt);
    font-feature-settings: "tnum" 1;
    white-space: nowrap;
}

/* =========================================================
   Hour 00 — OVERTURE
   ========================================================= */
.hour.overture {
    grid-template-rows: repeat(16, 1fr);
}

.overture-stars {
    grid-column: 1 / 9;
    grid-row: 1 / 3;
    position: relative;
    border-bottom: 1px solid var(--honey-paper);
}

.overture-stars .o-star {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--coffee-bean);
    transform: translate(-50%, -50%);
    transition: background-color 800ms var(--tick), transform 2400ms var(--tick), opacity 600ms var(--tick);
}

.overture-stars .o-star.lit {
    background: var(--honey-gold);
}

.overture-trails {
    position: absolute;
    inset: 0;
    pointer-events: none;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.overture-trails .trail {
    fill: none;
    stroke: var(--honey-paper);
    stroke-width: 1;
    stroke-dasharray: var(--len, 0);
    stroke-dashoffset: var(--len, 0);
    transition: stroke-dashoffset 2400ms var(--tick);
}

.overture-trails .trail.drawn {
    stroke-dashoffset: 0;
}

.wordmark {
    grid-column: 1 / 9;
    grid-row: 4 / 11;
    align-self: center;
    font-family: "Bebas Neue", "Oswald", sans-serif;
    font-weight: 400;
    font-size: var(--type-wordmark);
    line-height: 0.82;
    letter-spacing: -0.02em;
    color: var(--molasses);
    margin: 0;
}

.wordmark .dot {
    color: var(--honey-gold);
}

.overture-sub {
    grid-column: 1 / 5;
    grid-row: 11 / 14;
    align-self: start;
    font-size: var(--type-caption);
    line-height: calc(18 / 11);
    color: var(--tarnished-gilt);
    max-width: 38ch;
    border-top: 1px solid var(--honey-paper);
    padding-top: calc(var(--baseline) * 1.5);
}

.overture-meta {
    grid-column: 6 / 9;
    grid-row: 11 / 14;
    align-self: start;
    display: flex;
    flex-direction: column;
    gap: calc(var(--baseline) * 0.5);
    border-top: 1px solid var(--honey-paper);
    padding-top: calc(var(--baseline) * 1.5);
    font-family: "Bebas Neue", sans-serif;
    font-size: 14px;
    letter-spacing: 0.06em;
    color: var(--molasses);
    text-align: right;
}

.overture-marginalia {
    grid-column: 8 / 9;
    grid-row: 2 / 3;
    justify-self: end;
    align-self: start;
    font-family: "Cormorant Garamond", serif;
    font-style: italic;
    font-size: var(--type-caption);
    color: var(--faded-brass);
}

/* =========================================================
   Hour 23 — CODA
   ========================================================= */
.hour.coda {
    background: var(--coffee-bean);
    color: var(--beeswax);
    border-bottom: none;
}

.hour.coda::before {
    /* invert the hairline grid for the dark coda */
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(to right, rgba(232, 219, 196, 0.04) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(232, 219, 196, 0.04) 1px, transparent 1px);
    background-size: calc(100% / 8) var(--baseline);
}

.coda-title {
    grid-column: 1 / 4;
    grid-row: 2 / 4;
    align-self: start;
    font-family: "Bebas Neue", sans-serif;
    font-size: clamp(6rem, 12vw, 14rem);
    line-height: 0.82;
    letter-spacing: -0.02em;
    color: var(--beeswax);
    margin: 0;
}

.coda-chart {
    grid-column: 1 / 9;
    grid-row: 4 / 15;
    width: 100%;
    height: 100%;
    color: var(--honey-paper);
    overflow: visible;
}

.coda-chart .c-edge {
    fill: none;
    stroke: var(--faded-brass);
    stroke-width: 0.6;
    stroke-dasharray: var(--c-len, 0);
    stroke-dashoffset: var(--c-len, 0);
    opacity: 0.7;
}

.coda-chart .c-node {
    fill: var(--honey-paper);
    transition: fill 800ms var(--tick);
}

.coda-chart .c-node.lit {
    fill: var(--honey-gold);
}

.coda-chart .c-label {
    fill: var(--faded-brass);
    font-family: "Cormorant Garamond", serif;
    font-style: italic;
    font-size: 9px;
    opacity: 0;
    transition: opacity 600ms var(--tick);
}

.hour.coda.revealed .coda-chart .c-label {
    opacity: 1;
}

.coda-caption {
    grid-column: 1 / 9;
    grid-row: 15 / 16;
    align-self: end;
    text-align: center;
    font-family: "Cormorant Garamond", serif;
    font-style: italic;
    font-size: 14px;
    color: var(--faded-brass);
}

.coda-marginalia {
    color: var(--honey-paper);
}

.hour.coda .caption-strip {
    border-top: 1px solid var(--tarnished-gilt);
    color: var(--honey-paper);
}

.hour.coda .caption-strip .time {
    color: var(--beeswax);
}

.hour.coda .caption-strip .latin-name {
    color: var(--faded-brass);
}

.hour.coda .caption-strip .signature {
    color: var(--honey-paper);
}

/* =========================================================
   Hover state on a constellation node — pre-flip nudge
   ========================================================= */
.constellation .node:hover .icon {
    color: var(--honey-gold);
}

.constellation .node:hover .star {
    fill: var(--honey-gold);
}

/* =========================================================
   Responsive — tighten the grid on smaller screens
   ========================================================= */
@media (max-width: 900px) {
    :root {
        --gutter: 16px;
    }

    .hour {
        height: auto;
        min-height: 100vh;
        padding: calc(var(--baseline) * 3) calc(var(--baseline) * 2);
    }

    .hour-glyph {
        position: static;
        grid-column: 1 / 9;
        grid-row: 1 / 4;
        font-size: clamp(8rem, 28vw, 16rem);
    }

    .facts {
        grid-column: 1 / 9;
        grid-row: 4 / 8;
    }

    .constellation {
        grid-column: 1 / 9;
        grid-row: 8 / 14;
        height: 50vh;
    }

    .micro-copy {
        grid-column: 1 / 9;
        grid-row: 14 / 16;
        max-width: none;
    }

    .marginalia {
        grid-column: 8 / 9;
        grid-row: 1 / 2;
    }

    .wordmark {
        font-size: clamp(4rem, 22vw, 12rem);
    }

    .overture-sub,
    .overture-meta {
        grid-column: 1 / 9;
    }

    .overture-meta {
        text-align: left;
    }
}

/* =========================================================
   Reduced motion
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }

    .constellation .edge {
        stroke-dashoffset: 0 !important;
    }

    .constellation .node .icon {
        opacity: 1 !important;
    }

    .overture-trails .trail {
        stroke-dashoffset: 0 !important;
    }
}
