/* ============================================================
   musical.quest — styles.css
   muji-quiet · editorial-flow · navy-metallic · border-animate
   ============================================================ */

/* ---------- Color tokens ---------- */
:root {
    --paper: #F2EEE5;            /* unbleached paper */
    --paper-aged: #E8E2D4;       /* aged margin */
    --ink: #0F1A2E;              /* prussian ink */
    --ink-second: #1B2940;       /* navy-second */
    --pewter: #7E8A9C;           /* brushed pewter */
    --brass: #C9A96E;            /* brass leaf */
    --filament: #3FE0D8;         /* filament cyan */

    --max-width: 1320px;
    --grid-cols: 12;
    --gutter: 24px;
    --header-rule-top: 32px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: #F2EEE5;
    color: #0F1A2E;
    font-family: 'Commissioner', 'Inter', system-ui, -apple-system, sans-serif;
    font-weight: 400;
    font-size: 17px;
    line-height: 1.7;
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

/* ---------- Paper grain texture ---------- */
.paper-grain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    opacity: 0.04;
    background-image:
        radial-gradient(circle at 13% 27%, #1B2940 1px, transparent 1px),
        radial-gradient(circle at 67% 71%, #7E8A9C 1px, transparent 1px),
        radial-gradient(circle at 41% 89%, #1B2940 0.5px, transparent 0.5px),
        radial-gradient(circle at 83% 13%, #7E8A9C 0.5px, transparent 0.5px),
        radial-gradient(circle at 22% 56%, #1B2940 0.7px, transparent 0.7px);
    background-size: 47px 47px, 53px 53px, 31px 31px, 37px 37px, 41px 41px;
    mix-blend-mode: multiply;
}

/* ---------- Header ---------- */
.site-header {
    position: relative;
    width: 100%;
    z-index: 5;
    padding-top: 32px;
}

.header-rule {
    position: absolute;
    top: 32px;
    left: 0;
    right: 0;
    height: 1px;
    background-color: #0F1A2E;
}

.header-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: 14px 64px 0;
    display: flex;
    align-items: center;
    gap: 14px;
}

.wordmark {
    font-family: 'Commissioner', 'Inter', sans-serif;
    font-weight: 300;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: #0F1A2E;
}

/* ---------- Eighth-note ornament ---------- */
.eighth-note {
    display: inline-flex;
    align-items: flex-end;
    width: 6px;
    height: 18px;
    position: relative;
}

.note-disk {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 6px;
    height: 6px;
    background-color: #1B2940;
    border-radius: 50%;
}

.note-stem {
    position: absolute;
    bottom: 3px;
    left: 5px;
    width: 1px;
    height: 14px;
    background-color: #1B2940;
}

.note-disk--brass {
    background-color: #C9A96E;
}

.note-stem--brass {
    background-color: #C9A96E;
}

/* ---------- Chapter rail ---------- */
.chapter-rail {
    position: fixed;
    top: 50%;
    left: 24px;
    transform: translateY(-50%);
    z-index: 8;
    display: flex;
    flex-direction: column;
    gap: 18px;
    opacity: 0;
    transition: opacity 600ms ease;
}

.chapter-rail:hover {
    opacity: 1;
}

.rail-numeral {
    font-family: 'Commissioner', 'Inter', sans-serif;
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #7E8A9C;
    text-decoration: none;
    transition: color 200ms ease;
}

.rail-numeral:hover,
.rail-numeral.active {
    color: #0F1A2E;
}

/* ---------- Journal layout ---------- */
.journal {
    position: relative;
    z-index: 2;
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 64px;
}

/* ---------- Chapters ---------- */
.chapter {
    position: relative;
    min-height: 100vh;
    padding: 96px 0 120px;
    display: grid;
    grid-template-columns: 80px 1fr;
    column-gap: 24px;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 900ms ease, transform 900ms ease;
}

.chapter.in-view {
    opacity: 1;
    transform: translateY(0);
}

.chapter-hero {
    min-height: 100vh;
    padding-top: 0;
}

.chapter-numeral {
    font-family: 'Commissioner', 'Inter', sans-serif;
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #7E8A9C;
    font-variant: small-caps;
}

.chapter-numeral.sticky {
    position: sticky;
    top: 28vh;
    align-self: start;
    height: 0;
}

/* ---------- Chapter divider ---------- */
.chapter-divider {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 64px;
    margin-top: -40px;
}

.divider-rule {
    flex: 1;
    height: 1px;
    background-color: #0F1A2E;
}

.divider-note {
    flex: 0 0 auto;
}

/* ---------- Chapter body ---------- */
.chapter-body {
    grid-column: 2;
    max-width: 1100px;
    position: relative;
    padding-right: 0;
}

.chapter-body--shifted {
    margin-left: 12%;
    max-width: 880px;
}

.chapter-body--hero {
    grid-column: 2;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 96px;
    padding-top: 38vh;
}

/* ---------- Hero block ---------- */
.hero-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 36px;
    padding-top: 0;
}

.hero-numeral {
    font-family: 'Commissioner', 'Inter', sans-serif;
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #7E8A9C;
    font-variant: small-caps;
}

/* ---------- Branch SVG ---------- */
.branch {
    position: absolute;
    width: 280px;
    height: 120px;
    opacity: 0.65;
    pointer-events: none;
}

.branch--left {
    top: 24px;
    left: -240px;
}

.branch--right {
    top: 24px;
    right: -240px;
}

/* ---------- Numeral display in chapter body ---------- */
.numeral-display {
    font-family: 'Commissioner', 'Inter', sans-serif;
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #7E8A9C;
    font-variant: small-caps;
    margin-bottom: 24px;
}

/* ---------- Display heading ---------- */
.display-heading {
    font-family: 'Commissioner', 'Inter', sans-serif;
    font-weight: 200;
    font-size: 64px;
    line-height: 1.05;
    letter-spacing: -0.01em;
    color: #0F1A2E;
    margin-bottom: 20px;
}

.chapter-hero .display-heading {
    font-size: 72px;
}

/* ---------- Lyric line (italic accent) ---------- */
.lyric-line {
    font-family: 'Cormorant Infant', 'Lora', serif;
    font-style: italic;
    font-weight: 400;
    font-size: 24px;
    line-height: 1.45;
    color: #0F1A2E;
    margin-bottom: 56px;
}

.chapter-hero .lyric-line {
    font-size: 24px;
    margin-bottom: 0;
}

/* ---------- Annotated row ---------- */
.annotated-row {
    display: grid;
    grid-template-columns: 5fr 2fr;
    column-gap: 56px;
    margin-bottom: 96px;
    align-items: start;
}

.annotated-row--reverse {
    grid-template-columns: 2fr 5fr;
}

.body-well p {
    margin-bottom: 22px;
    color: #0F1A2E;
}

.body-well p:last-child {
    margin-bottom: 0;
}

/* ---------- Margin scribble ---------- */
.margin-scribble {
    font-family: 'Commissioner', 'Inter', sans-serif;
    font-style: italic;
    font-weight: 400;
    font-size: 13px;
    line-height: 1.6;
    letter-spacing: 0.02em;
    color: #1B2940;
    padding-top: 48px;
    padding-left: 4px;
    transform: translateY(8px);
}

.margin-scribble--left {
    padding-top: 32px;
    padding-right: 4px;
    padding-left: 0;
    text-align: left;
    transform: translateY(-4px);
}

.scribble-text::after {
    content: '';
    display: inline-block;
    width: 0;
}

/* ---------- Listening plate ---------- */
.listening-plate {
    position: relative;
    margin: 56px auto 64px;
    max-width: 560px;
    aspect-ratio: 4 / 3;
    border: 1px solid #0F1A2E;
    padding: 4px;
    background-color: #F2EEE5;
    cursor: crosshair;
    transition: opacity 1200ms ease;
    opacity: 0;
}

.listening-plate.in-view {
    opacity: 1;
}

.listening-plate--leaf {
    aspect-ratio: 1 / 1;
    max-width: 480px;
}

.plate-double-rule {
    position: relative;
    width: 100%;
    height: 100%;
    border: 0.5px solid #7E8A9C;
    background-color: #F2EEE5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 36px;
    text-align: center;
    overflow: hidden;
}

.plate-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    width: 100%;
}

.plate-content--image {
    gap: 10px;
}

.plate-caption {
    font-family: 'Commissioner', 'Inter', sans-serif;
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #7E8A9C;
}

.plate-lyric {
    font-family: 'Cormorant Infant', 'Lora', serif;
    font-style: italic;
    font-weight: 400;
    font-size: 30px;
    line-height: 1.35;
    color: #0F1A2E;
    max-width: 90%;
}

.plate-content--lyric .plate-lyric {
    font-size: 32px;
}

.plate-runtime {
    font-family: 'JetBrains Mono', 'Inter', monospace;
    font-weight: 400;
    font-size: 11px;
    letter-spacing: 0.04em;
    color: #1B2940;
    font-variant-numeric: tabular-nums;
}

/* ---------- Leaf etching ---------- */
.leaf-etching {
    width: 60%;
    height: auto;
    max-width: 220px;
    opacity: 0.95;
}

/* ---------- Plate disk (interactive) ---------- */
.plate-disk {
    position: absolute;
    bottom: 16px;
    right: 16px;
    width: 18px;
    height: 22px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 4;
    transition: transform 200ms ease;
}

.plate-disk:hover {
    transform: translateY(-1px);
}

.plate-disk .note-disk {
    background-color: #7E8A9C;
    width: 7px;
    height: 7px;
}

.plate-disk .note-stem {
    background-color: #7E8A9C;
    height: 16px;
    bottom: 3px;
    left: 6px;
}

/* ---------- Plate reveal ---------- */
.plate-reveal {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #E8E2D4;
    border-top: 0.5px solid #7E8A9C;
    padding: 18px 28px 22px;
    transform: translateY(100%);
    transition: transform 600ms cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 3;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.plate-reveal.open {
    transform: translateY(0);
}

.reveal-line {
    display: flex;
    align-items: baseline;
    gap: 14px;
    font-size: 13px;
    color: #0F1A2E;
    text-align: left;
}

.reveal-label {
    font-family: 'Commissioner', 'Inter', sans-serif;
    font-weight: 500;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #7E8A9C;
    flex: 0 0 70px;
}

.reveal-value {
    font-family: 'Commissioner', 'Inter', sans-serif;
    font-weight: 400;
    font-size: 13px;
    color: #0F1A2E;
    letter-spacing: 0.01em;
}

.reveal-value.mono {
    font-family: 'JetBrains Mono', 'Inter', monospace;
    font-variant-numeric: tabular-nums;
}

/* ---------- Audio bar ---------- */
.audio-bar {
    position: relative;
    margin-top: 8px;
    height: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.audio-track {
    flex: 1;
    height: 1px;
    background-color: #0F1A2E;
    position: relative;
}

.audio-playhead {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 0.5px;
    height: 9px;
    background-color: #7E8A9C;
    transition: left 200ms linear;
    pointer-events: none;
}

.audio-track::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.audio-toggle {
    background: transparent;
    border: none;
    font-family: 'Commissioner', 'Inter', sans-serif;
    font-weight: 500;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #0F1A2E;
    cursor: pointer;
    padding: 0;
    border-bottom: 1px solid #0F1A2E;
    line-height: 1.2;
    transition: border-bottom-width 200ms ease;
}

.audio-toggle:hover {
    border-bottom-width: 2px;
}

/* ---------- Border pulse SVG ---------- */
.border-pulse {
    position: absolute;
    inset: -2px;
    width: calc(100% + 4px);
    height: calc(100% + 4px);
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    transition: opacity 1200ms ease;
}

.listening-plate.in-view .border-pulse {
    opacity: 1;
}

.pulse-stroke,
.pulse-glow {
    animation: dashFlow 14s linear infinite;
    transform-origin: center;
}

.listening-plate.audio-playing .pulse-stroke,
.listening-plate.audio-playing .pulse-glow {
    animation-duration: 22s;
}

@keyframes dashFlow {
    from { stroke-dashoffset: 0; }
    to   { stroke-dashoffset: -1240; }
}

/* ---------- Bird stave ---------- */
.bird-stave {
    display: block;
    width: 80%;
    height: auto;
    max-width: 600px;
    margin: 56px auto 32px;
    opacity: 0.85;
}

/* ---------- Closing ornament ---------- */
.closing-ornament {
    margin: 96px auto 48px;
    display: flex;
    justify-content: center;
}

.phonograph-needle {
    width: 320px;
    height: auto;
    transform: rotate(-22deg);
    opacity: 0.85;
}

/* ---------- Footer ---------- */
.site-footer {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 48px 0 64px;
    margin-top: 96px;
    border-top: 1px solid #0F1A2E;
    background-color: #E8E2D4;
    margin-left: -64px;
    margin-right: -64px;
    padding-left: 64px;
    padding-right: 64px;
}

.footer-rule {
    flex: 0 0 60px;
    height: 1px;
    background-color: #0F1A2E;
}

.footer-note {
    margin-right: 8px;
}

.footer-date {
    font-family: 'JetBrains Mono', 'Inter', monospace;
    font-weight: 400;
    font-size: 11px;
    letter-spacing: 0.06em;
    color: #0F1A2E;
    font-variant-numeric: tabular-nums;
}

.footer-divider {
    color: #7E8A9C;
    font-size: 11px;
}

.footer-initials {
    font-family: 'Commissioner', 'Inter', sans-serif;
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #C9A96E;
    margin-left: auto;
}

/* ---------- Inline link styling (if any) ---------- */
a {
    color: #0F1A2E;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
    transition: text-decoration-thickness 200ms ease;
}

a:hover {
    text-decoration-thickness: 2px;
}

/* ---------- Responsive adjustments ---------- */
@media (max-width: 960px) {
    .journal {
        padding: 0 32px;
    }
    .header-inner {
        padding: 14px 32px 0;
    }
    .chapter {
        grid-template-columns: 40px 1fr;
        column-gap: 16px;
    }
    .chapter-body--shifted {
        margin-left: 0;
    }
    .display-heading {
        font-size: 44px;
    }
    .chapter-hero .display-heading {
        font-size: 48px;
    }
    .annotated-row,
    .annotated-row--reverse {
        grid-template-columns: 1fr;
        row-gap: 24px;
    }
    .margin-scribble,
    .margin-scribble--left {
        padding-top: 0;
    }
    .branch--left,
    .branch--right {
        display: none;
    }
    .listening-plate {
        max-width: 100%;
    }
    .site-footer {
        flex-wrap: wrap;
        gap: 12px;
        margin-left: -32px;
        margin-right: -32px;
        padding-left: 32px;
        padding-right: 32px;
    }
}

@media (max-width: 600px) {
    body {
        font-size: 16px;
    }
    .display-heading {
        font-size: 36px;
    }
    .chapter-hero .display-heading {
        font-size: 40px;
    }
    .lyric-line {
        font-size: 20px;
    }
    .plate-lyric,
    .plate-content--lyric .plate-lyric {
        font-size: 22px;
    }
    .chapter-body--hero {
        padding-top: 28vh;
    }
}
