/* ==========================================================================
   concurrent.day — stylesheet
   Palette (from DESIGN.md):
     Deep Slate     #1c2130   background
     Charcoal Mist  #252b3b   surface
     Graphite Edge  #3a4259   border
     Silver Breath  #c8ced9   primary text
     Pewter Whisper #8b9bb4   secondary text / HUD
     Amber Thread   #d4a574   active accent
     Slate Blue     #6b89b8   interactive
     Warm Glow      #e8c9a0   highlight / cursor
   Typography:
      Libre Baskerville — display
      Source Sans 3    — body
      IBM Plex Mono    — HUD labels
      IBM Plex Mono at `0.75rem`; HUD elements creates a productive tension between
      humanist tradition and technical precision. IBM Plex Mono's slightly humanist
      construction prevents it from feeling robotic. IBM Plex Mono" (Google Fonts
      Interaction Interaction: Interaction:: Interaction* Interaction:* Interaction:** Intersection Observer for all scroll-triggered behavior.
      Intersection Observer on section elements. The number transition uses a brief
      vertical-slide animation: the old number slides up and fades out while the new
      number slides up from below and fades in. Intersection Observer threshold is
      set to 0.15 — cards begin revealing when 15% of their height enters the
      viewport. Cards in different columns trigger independently. Source Sans 3"
      (Google Fonts
   ========================================================================== */

:root {
    --c-bg:          #1c2130;
    --c-surface:     #252b3b;
    --c-border:      #3a4259;
    --c-text:        #c8ced9;
    --c-muted:       #8b9bb4;
    --c-amber:       #d4a574;
    --c-slate:       #6b89b8;
    --c-glow:        #e8c9a0;

    --font-display:  "Libre Baskerville", Georgia, serif;
    --font-body:     "Source Sans 3", "Inter", system-ui, sans-serif;
    --font-mono:     "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;

    --pad-x:         clamp(2rem, 5vw, 6rem);
    --gap-card:      1.6rem;
    --gap-col:       2.4rem;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    background: var(--c-bg);
    color: var(--c-text);
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    font-weight: 400;
    line-height: 1.72;
    letter-spacing: 0.005em;
    overflow-x: hidden;
    position: relative;
}

/* ---------- dot-grid background ---------- */
.dot-grid {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image: radial-gradient(circle, #252b3b 1px, transparent 1.2px);
    background-size: 32px 32px;
    background-position: 0 0;
    opacity: 0.9;
}

/* a second very faint grid gives the sensation of infinite depth */
.dot-grid::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 40%, transparent 0%, rgba(28,33,48,0.35) 80%);
    pointer-events: none;
}

/* ---------- HUD counter (fixed top-right) ---------- */
.hud-counter {
    position: fixed;
    top: clamp(1.25rem, 2.5vw, 2rem);
    right: clamp(1.25rem, 2.5vw, 2rem);
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.55rem 0.9rem;
    border: 1px solid var(--c-border);
    background: rgba(37, 43, 59, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--c-muted);
}

.hud-counter .counter-label {
    color: var(--c-muted);
}

.counter-track {
    position: relative;
    display: inline-flex;
    align-items: baseline;
    gap: 0.25rem;
    color: var(--c-text);
}

.counter-current {
    position: relative;
    display: inline-block;
    min-width: 1ch;
    color: var(--c-amber);
    transition: color 0.3s ease;
}

/* number slide animation */
.counter-current.is-leaving {
    animation: counter-out 0.28s ease forwards;
}
.counter-current.is-entering {
    animation: counter-in 0.28s ease forwards;
}

@keyframes counter-out {
    to { transform: translateY(-60%); opacity: 0; }
}
@keyframes counter-in {
    from { transform: translateY(80%); opacity: 0; }
    to   { transform: translateY(0);   opacity: 1; }
}

.counter-sep {
    color: var(--c-border);
}

.counter-total {
    color: var(--c-muted);
}

/* ---------- hero / entry ---------- */
.hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--pad-x);
    z-index: 2;
}

.hero-stage {
    position: relative;
    width: 100%;
    max-width: 1200px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.2rem;
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.4rem, 6vw, 4.6rem);
    letter-spacing: -0.01em;
    line-height: 1.15;
    color: var(--c-text);
    opacity: 0;
    transform: translateY(8px);
    animation: hero-fade-in 0.9s ease 0.6s forwards;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.hero-domain {
    display: inline-block;
}

.hero-cursor {
    display: inline-block;
    width: 2px;
    height: 0.9em;
    background: var(--c-glow);
    margin-left: 0.1em;
    animation: blink 1s step-end infinite;
    transform: translateY(0.06em);
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    50.01%, 100% { opacity: 0; }
}

@keyframes hero-fade-in {
    to { opacity: 1; transform: translateY(0); }
}

/* the horizontal line that extends across the viewport after title settles */
.hero-line {
    width: 100%;
    height: 2px;
    display: block;
    overflow: visible;
    opacity: 0;
    animation: hero-line-appear 0.4s ease 2.2s forwards;
}

.hero-line line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: hero-line-draw 1.2s ease 2.4s forwards;
}

@keyframes hero-line-appear {
    to { opacity: 1; }
}

@keyframes hero-line-draw {
    to { stroke-dashoffset: 0; }
}

.hero-subnote {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    opacity: 0;
    animation: hero-fade-in 0.8s ease 3.6s forwards;
    color: var(--c-muted);
}

.hero-subnote .mono-label {
    color: var(--c-muted);
}

/* ---------- mono labels ---------- */
.mono-label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--c-muted);
    display: inline-block;
}

/* ---------- status dot (pulse) ---------- */
.status-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--c-border);
    flex-shrink: 0;
    position: relative;
    transition: background 0.4s ease;
}

.status-dot.is-active,
.hero-subnote .status-dot,
.section-header.is-current .status-dot {
    background: var(--c-amber);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(212, 165, 116, 0.45); }
    70%  { box-shadow: 0 0 0 8px rgba(212, 165, 116, 0); }
    100% { box-shadow: 0 0 0 0 rgba(212, 165, 116, 0); }
}

/* ---------- main content shell ---------- */
.masonry-shell {
    position: relative;
    z-index: 2;
    padding: 2rem var(--pad-x) 4rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* timeline vertical line connecting sections */
.masonry-shell::before {
    content: "";
    position: absolute;
    left: calc(var(--pad-x) - 24px);
    top: 0;
    bottom: 0;
    width: 1px;
    background: linear-gradient(to bottom,
        transparent 0,
        var(--c-border) 40px,
        var(--c-border) calc(100% - 40px),
        transparent 100%);
    opacity: 0.55;
    pointer-events: none;
}

@media (max-width: 768px) {
    .masonry-shell::before {
        left: calc(var(--pad-x) - 16px);
    }
}

/* ---------- section header ---------- */
.thread-section {
    position: relative;
    padding: 3rem 0 2.2rem;
}

.section-header {
    position: relative;
    max-width: 720px;
    margin-bottom: 2.6rem;
    display: grid;
    grid-template-columns: auto auto 1fr;
    grid-template-rows: auto auto auto;
    column-gap: 0.9rem;
    row-gap: 0.7rem;
    align-items: center;
}

.section-header .timeline-node {
    position: absolute;
    left: calc(-1 * (var(--pad-x) - 24px) - 5px);
    top: 0.5rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--c-bg);
    border: 1.5px solid var(--c-muted);
    box-shadow: 0 0 0 4px var(--c-bg);
    transition: border-color 0.4s ease, background 0.4s ease;
}

.section-header.is-current .timeline-node {
    border-color: var(--c-amber);
    background: var(--c-bg);
    box-shadow: 0 0 0 4px var(--c-bg), 0 0 0 6px rgba(212, 165, 116, 0.2);
}

.section-header .status-dot {
    grid-column: 1;
    grid-row: 1;
    margin-right: 0.2rem;
}

.section-header .mono-label {
    grid-column: 2 / span 2;
    grid-row: 1;
}

.section-title {
    grid-column: 1 / span 3;
    grid-row: 2;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2rem, 4.5vw, 3.8rem);
    letter-spacing: -0.01em;
    line-height: 1.15;
    color: var(--c-text);
    margin-top: 0.3rem;
}

.section-lede {
    grid-column: 1 / span 3;
    grid-row: 3;
    max-width: 52ch;
    color: var(--c-muted);
    font-size: clamp(0.98rem, 1.7vw, 1.1rem);
    line-height: 1.7;
}

/* ---------- masonry grid (CSS columns) ---------- */
.masonry-grid {
    column-count: 3;
    column-gap: var(--gap-col);
}

@media (max-width: 1199px) {
    .masonry-grid {
        column-count: 2;
        column-gap: 2rem;
    }
}

@media (max-width: 768px) {
    .masonry-grid {
        column-count: 1;
        column-gap: 0;
    }
}

/* ---------- card ---------- */
.card {
    position: relative;
    display: inline-block;
    width: 100%;
    break-inside: avoid;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
    margin: 0 0 var(--gap-card);
    padding: 1.7rem 1.6rem 1.8rem;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    color: var(--c-text);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.6s ease-out,
                transform 0.6s ease-out,
                border-color 0.3s ease;
}

.card.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.card:hover {
    border-color: var(--c-slate);
}

/* height variants (masonry visual rhythm) */
.card-tall   { min-height: 420px; }
.card-medium { min-height: 300px; }
.card-short  { min-height: 180px; }

/* mobile alternating width / alignment so threads stay independent */
@media (max-width: 768px) {
    .card-tall,
    .card-medium,
    .card-short,
    .card {
        min-height: auto;
    }
    .masonry-grid > .card:nth-child(odd) {
        width: 100%;
        margin-left: 0;
    }
    .masonry-grid > .card:nth-child(even) {
        width: 85%;
        margin-left: 15%;
    }
}

/* ---------- card HUD corner brackets ---------- */
.card-hud {
    position: absolute;
    inset: -4px;
    pointer-events: none;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1;
    color: var(--c-border);
    opacity: 0.15;
    transition: opacity 0.3s ease, color 0.3s ease, inset 0.3s ease;
}

.card.is-visible .card-hud {
    opacity: 0.6;
}

.card:hover .card-hud {
    color: var(--c-slate);
    inset: -2px;
    opacity: 0.85;
}

.bracket {
    position: absolute;
    display: block;
}
.bracket-tl { top: 0;    left: 0;   }
.bracket-tr { top: 0;    right: 0;  }
.bracket-bl { bottom: 0; left: 0;   }
.bracket-br { bottom: 0; right: 0;  }

/* ---------- card contents ---------- */
.card-label {
    display: block;
    margin-bottom: 0.9rem;
    color: var(--c-muted);
}

.card-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.2rem, 1.9vw, 1.5rem);
    letter-spacing: -0.01em;
    line-height: 1.2;
    color: var(--c-text);
    margin-bottom: 0.9rem;
}

.card-body {
    color: var(--c-text);
    line-height: 1.72;
    margin-bottom: 0.5rem;
}

.card-body + .card-illo,
.card-illo + .card-body {
    margin-top: 1rem;
}

.card-body em {
    color: var(--c-glow);
    font-style: italic;
}

.card-footnote {
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px dashed var(--c-border);
    color: var(--c-muted);
    font-size: 0.9rem;
    line-height: 1.6;
    display: flex;
    gap: 0.6rem;
    align-items: baseline;
}

.card-footnote .mono-label {
    color: var(--c-slate);
}

/* inline SVG illustration */
.card-illo {
    display: block;
    width: 100%;
    height: auto;
    margin: 0.4rem 0 0.2rem;
    overflow: visible;
}

/* drawable paths begin offset; script sets dasharray exactly */
.draw-path {
    stroke-dasharray: var(--path-length, 1000);
    stroke-dashoffset: var(--path-length, 1000);
    transition: stroke-dashoffset 1.5s ease-out;
}

.card.is-visible .draw-path,
.thread-divider.is-visible .draw-path {
    stroke-dashoffset: 0;
}

/* ---------- glossary term list ---------- */
.term-list {
    list-style: none;
    margin: 0.3rem 0 0;
    padding: 0;
    display: grid;
    gap: 0.6rem;
}

.term-list li {
    display: grid;
    grid-template-columns: minmax(64px, auto) 1fr;
    gap: 1rem;
    align-items: baseline;
    padding: 0.45rem 0;
    border-bottom: 1px dashed var(--c-border);
}

.term-list li:last-child {
    border-bottom: 0;
}

.term {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--c-amber);
}

.term-def {
    color: var(--c-muted);
    line-height: 1.5;
    font-size: 0.95rem;
}

/* ---------- thread divider (between sections) ---------- */
.thread-divider {
    position: relative;
    width: 100%;
    height: clamp(70px, 10vw, 140px);
    margin: 2.6rem 0 2.2rem;
    overflow: visible;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.9s ease, transform 0.9s ease;
}

.thread-divider.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.thread-divider svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
}

.thread-divider .draw-path {
    transition: stroke-dashoffset 1.8s ease-out;
}

/* stagger using per-path delays */
.thread-divider .thread-main   { transition-duration: 0.8s; }
.thread-divider .thread-branch { transition-delay: 0.5s; transition-duration: 1.3s; }

.thread-node {
    transition: opacity 0.4s ease 1.2s;
    opacity: 0;
}

.thread-divider.is-visible .thread-node {
    opacity: 1;
}

/* ---------- closing ---------- */
.thread-section-closing {
    padding-bottom: 4rem;
}

.closing-card {
    position: relative;
    max-width: 760px;
    margin: 1.5rem auto 0;
    padding: 2.6rem 2.4rem 2.4rem;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.7s ease, transform 0.7s ease, border-color 0.3s ease;
}

.closing-card.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.closing-card > .mono-label {
    display: block;
    margin-bottom: 1.1rem;
    color: var(--c-amber);
}

.closing-body {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(1.15rem, 2.2vw, 1.5rem);
    line-height: 1.55;
    color: var(--c-text);
    letter-spacing: -0.005em;
}

.closing-sig {
    margin-top: 1.8rem;
    padding-top: 1.2rem;
    border-top: 1px dashed var(--c-border);
    display: flex;
    align-items: baseline;
    gap: 0.9rem;
}

.sig-name {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--c-glow);
    letter-spacing: -0.01em;
}

/* ---------- footer ---------- */
.site-footer {
    padding: 2.5rem var(--pad-x) 3rem;
    text-align: center;
    color: var(--c-muted);
    border-top: 1px solid var(--c-border);
    margin-top: 2rem;
    position: relative;
    z-index: 2;
}

.site-footer .mono-label {
    color: var(--c-border);
}

/* ---------- small screens ---------- */
@media (max-width: 540px) {
    .hud-counter {
        top: 0.9rem;
        right: 0.9rem;
        padding: 0.4rem 0.65rem;
        gap: 0.5rem;
        font-size: 0.68rem;
    }
    .section-header {
        margin-bottom: 1.8rem;
    }
    .card {
        padding: 1.4rem 1.3rem 1.5rem;
    }
    .closing-card {
        padding: 1.8rem 1.4rem 1.6rem;
    }
}

/* ---------- selection ---------- */
::selection {
    background: rgba(212, 165, 116, 0.35);
    color: var(--c-glow);
}
