/* how-it-works.css — Full rebuild. Chapter-based layout matching index.html.
   Three.js drift cascade hero + deep methodology sections.
   ─────────────────────────────────────────────────────────── */

/* ── Hero ── */
#hiw-hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
#drift-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}
.hiw-hero-content {
    position: relative;
    z-index: 1;
    max-width: 720px;
    padding: 2rem 1.5rem;
    text-align: center;
}
.hiw-hero-content h1 {
    font-family: var(--font-display);
    font-size: clamp(2.4rem, 6vw, 4rem);
    font-weight: 900;
    letter-spacing: -0.03em;
    line-height: 1.05;
    margin: 0 0 1rem;
    animation: hiwFadeUp 0.5s ease both;
}
.hiw-hero-sub {
    font-size: clamp(0.95rem, 2vw, 1.15rem);
    color: var(--text-dim);
    line-height: 1.7;
    max-width: 560px;
    margin: 0 auto 1.5rem;
    animation: hiwFadeUp 0.5s ease 0.1s both;
}
.hiw-pe-hud {
    display: inline-flex;
    align-items: center;
    gap: 1rem;
    padding: 0.65rem 1.4rem;
    border: 1px solid var(--border);
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    font-family: var(--font-mono);
    animation: hiwFadeUp 0.6s ease 0.2s both;
}
.hiw-pe-hud .pe-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-faint);
}
.hiw-pe-hud .pe-val {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--accent);
    letter-spacing: -0.03em;
    min-width: 3.5rem;
    text-align: right;
}
.hiw-pe-hud .pe-phase {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    min-width: 6rem;
    text-align: left;
}
.hiw-scroll-hint {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    color: var(--text-faint);
    animation: hiwPulse 2s ease infinite;
    z-index: 1;
}

@keyframes hiwFadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes hiwPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* ── Pe Formula Interactive ── */
.pe-formula-box {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 2rem;
    margin: 2rem 0;
    font-family: var(--font-mono);
    text-align: center;
}
.pe-formula-box .formula {
    font-size: clamp(1rem, 3vw, 1.4rem);
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1rem;
    letter-spacing: 0.02em;
}
.pe-formula-box .formula-desc {
    font-size: 0.78rem;
    color: var(--text-dim);
    line-height: 1.8;
}

/* ── Math apparatus grid ── */
.math-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
    gap: 3px;
    margin: 1.5rem 0;
}
.math-cell {
    aspect-ratio: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 0.55rem;
    font-weight: 700;
    color: var(--text-faint);
    transition: all 0.2s;
    cursor: default;
}
.math-cell:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(200,151,106,0.08);
}
.math-cell[data-era="thermo"]  { border-left: 2px solid #4488aa; }
.math-cell[data-era="spectral"] { border-left: 2px solid #9966dd; }
.math-cell[data-era="quantum"]  { border-left: 2px solid #44aa66; }
.math-cell[data-era="frontier"] { border-left: 2px solid #cc6633; }

/* ── Kramers domains ── */
.kramers-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin: 2rem 0;
}
@media (max-width: 700px) { .kramers-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 420px) { .kramers-grid { grid-template-columns: 1fr; } }

.kramers-domain {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 1.2rem;
    transition: border-color 0.2s;
}
.kramers-domain:hover { border-color: var(--accent); }
.kramers-domain .kd-icon {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
}
.kramers-domain h4 {
    font-size: 0.82rem;
    font-weight: 700;
    margin: 0 0 0.3rem;
    color: var(--text);
}
.kramers-domain p {
    font-size: 0.72rem;
    color: var(--text-dim);
    line-height: 1.6;
    margin: 0;
}
.kramers-domain .kd-barrier {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--accent);
    margin-top: 0.5rem;
    display: block;
}

/* ── Kill conditions strip ── */
.kc-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 1.5rem 0;
}
.kc-dot {
    width: 18px;
    height: 18px;
    border: 1px solid rgba(68,136,68,0.4);
    background: rgba(68,136,68,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.45rem;
    color: #448844;
    cursor: default;
    transition: all 0.15s;
}
.kc-dot:hover {
    border-color: #448844;
    background: rgba(68,136,68,0.3);
    transform: scale(1.2);
}

/* ── Convergence bars ── */
.conv-bar-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1.5rem 0;
}
.conv-bar {
    display: grid;
    grid-template-columns: 2rem 1fr 4rem;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.78rem;
}
.conv-bar .cb-n {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-faint);
    text-align: right;
}
.conv-bar .cb-track {
    height: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}
.conv-bar .cb-fill {
    position: absolute;
    inset: 0;
    background: var(--accent);
    transform-origin: left;
    transition: transform 0.8s ease;
}
.conv-bar .cb-val {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.72rem;
    color: var(--text-dim);
    text-align: right;
}

/* ── Frontier cards (recent discoveries) ── */
.frontier-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem;
    margin: 2rem 0;
}
@media (max-width: 700px) { .frontier-grid { grid-template-columns: 1fr; } }

.frontier-card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 1.5rem;
    transition: border-color 0.2s;
}
.frontier-card:hover { border-color: var(--accent); }
.frontier-card .fc-tag {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.6rem;
    display: block;
}
.frontier-card h4 {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    line-height: 1.3;
}
.frontier-card .fc-stat {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--text);
    display: block;
    margin-bottom: 0.4rem;
}
.frontier-card p {
    font-size: 0.78rem;
    color: var(--text-dim);
    line-height: 1.6;
    margin: 0;
}

/* ── Timeline ── */
.hiw-timeline {
    position: relative;
    padding-left: 2rem;
    margin: 2rem 0;
}
.hiw-timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border);
}
.tl-node {
    position: relative;
    padding: 0 0 2rem;
}
.tl-node::before {
    content: '';
    position: absolute;
    left: -1.65rem;
    top: 0.4rem;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
}
.tl-node .tl-date {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-faint);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.tl-node h4 {
    font-size: 0.9rem;
    font-weight: 700;
    margin: 0.2rem 0 0.3rem;
}
.tl-node p {
    font-size: 0.78rem;
    color: var(--text-dim);
    line-height: 1.6;
    margin: 0;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .hiw-hero-content { padding: 1.5rem 1rem; }
    .hiw-pe-hud { flex-direction: column; gap: 0.3rem; padding: 0.5rem 1rem; }
    .hiw-pe-hud .pe-val { font-size: 1.4rem; text-align: center; }
    .hiw-pe-hud .pe-phase { text-align: center; min-width: auto; }
    .pe-formula-box { padding: 1.25rem; }
    .kramers-grid { gap: 0.75rem; }
    /* Inline stat grids → 2 columns on mobile */
    .stat-grid-4 { grid-template-columns: repeat(2, 1fr) !important; }
    .stat-grid-3 { grid-template-columns: 1fr !important; }
}

@media (max-width: 420px) {
    .stat-grid-4 { grid-template-columns: 1fr !important; gap: 0.75rem !important; }
}
