/* ==========================================================================
   The log as a recording — transcriber/macos
   The page's centerpiece: every commit of the app drawn as one bar of a
   waveform, the subsystems it touched as diarization lanes, and the lessons
   as the moments the playhead stops on. It sits full-width on the sheet,
   between the hero and the article, in the light field like everything else:
   no background of its own, white panels with the lit edge for the
   instruments, and the one orange for the lessons.
   ========================================================================== */

.log-section {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: calc(100svh - 64px);
    padding: clamp(36px, 5vw, 72px) var(--gutter) clamp(40px, 5vw, 72px);
    border-top: 1px solid var(--hair);
}

.log {
    --log-ink-dim: rgba(11, 12, 14, 0.16);
    --log-panel: rgba(255, 255, 255, 0.72);
    position: relative;
    margin: 0;
    color: var(--ink);
    font-family: var(--text);
}

/* ----- head --------------------------------------------------------------- */
.log-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
}
.log .log-title {
    margin: 0;
    font-family: var(--display);
    font-size: clamp(40px, 7vw, 96px);
    font-weight: 800;
    font-stretch: 78%;
    line-height: 0.9;
    letter-spacing: -0.04em;
    color: var(--ink);
}
.log .log-title em { font-style: normal; color: var(--accent-on-light); }
.log .log-sub {
    max-width: 58ch;
    margin: 16px 0 0;
    font-size: 16px;
    line-height: 1.55;
    color: var(--ink-3);
}
.log-play {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 0 26px 0 18px;
    border: 0;
    border-radius: 999px;
    background: var(--accent-bright);
    color: #fff;
    font-family: var(--display);
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--lift-1);
    transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.log-play:hover { transform: translateY(-2px); box-shadow: var(--lift-2); }
.log-play:focus-visible,
.log-stage:focus-visible,
.log-nav button:focus-visible { outline: 2px solid var(--accent-on-light); outline-offset: 3px; }
.log-play svg { width: 18px; height: 18px; }
.log-play .ico-pause { display: none; }
.log.is-playing .log-play .ico-play { display: none; }
.log.is-playing .log-play .ico-pause { display: block; }

/* ----- counters ----------------------------------------------------------- */
.log-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 30px 0 0;
}
.log-stat {
    padding: 16px 20px 14px;
    background: var(--log-panel);
    border-radius: 16px;
    box-shadow: var(--lift-1);
}
.log-stat dt {
    font-family: var(--display);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-4);
}
.log-stat dd {
    margin: 6px 0 0;
    font-family: var(--display);
    font-size: clamp(26px, 3.6vw, 44px);
    font-weight: 800;
    font-stretch: 82%;
    letter-spacing: -0.03em;
    line-height: 1;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}
.log-stat dd small { font-size: 0.42em; font-weight: 600; color: var(--ink-4); letter-spacing: 0; }

/* ----- the stage: waveform + lanes + axis --------------------------------- */
.log-stage {
    position: relative;
    --lane-gutter: 150px;
    margin: 26px 0 0;
    cursor: ew-resize;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
    border-radius: 8px;
}
/* The drawing sits right of a label column, so lane names never sit on ticks. */
.log-track { position: relative; margin-left: var(--lane-gutter); padding-top: 34px; }
.log-svg { display: block; width: 100%; overflow: visible; border-radius: 0; }
.log-wave { height: clamp(84px, 11vh, 120px); }
.log-lanes-wrap { position: relative; margin-top: 14px; }
.log-lanes { height: 104px; }

.log-svg .bar { fill: var(--log-ink-dim); transition: fill .25s var(--ease); }
.log-svg .bar.on { fill: var(--ink); }
.log-svg .bar.lesson { fill: var(--accent-bright); opacity: 0.3; }
.log-svg .bar.lesson.on { opacity: 1; }
.log-svg .bar.now { fill: var(--accent-bright); opacity: 1; }
.log-svg .env { fill: rgba(11, 12, 14, 0.045); }
.log-svg .mid { stroke: rgba(11, 12, 14, 0.12); stroke-width: 1; vector-effect: non-scaling-stroke; }
.log-svg .gap { stroke: rgba(11, 12, 14, 0.16); stroke-width: 1; stroke-dasharray: 2 3; vector-effect: non-scaling-stroke; }
.log-svg .lane-bg { fill: rgba(11, 12, 14, 0.035); }
.log-svg .tick { fill: rgba(11, 12, 14, 0.16); transition: fill .25s var(--ease); }
.log-svg .tick.on { fill: var(--ink-3); }
.log-svg .tick.lesson.on { fill: var(--accent-bright); }
.log-svg .tick.now { fill: var(--ink); }

.log-lane-labels {
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(-1 * var(--lane-gutter));
    width: calc(var(--lane-gutter) - 14px);
    display: grid;
    grid-template-rows: repeat(8, 1fr);
    pointer-events: none;
}
.log-lane-labels span {
    display: flex;
    align-items: center;
    font-family: var(--display);
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
    line-height: 1;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-4);
    transition: color .25s var(--ease);
}
.log-lane-labels span.on { color: var(--accent-on-light); }

.log-axis {
    position: relative;
    height: 26px;
    margin-top: 6px;
    font-family: var(--display);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--ink-3);
    font-variant-numeric: tabular-nums;
}
.log-axis span { position: absolute; top: 6px; transform: translateX(-50%); white-space: nowrap; }
.log-axis span:first-child { transform: none; }
.log-axis span:last-child { transform: translateX(-100%); }

/* Lesson pins above the waveform */
.log-pins { position: absolute; left: 0; right: 0; top: 0; height: 26px; pointer-events: none; }
.log-pin {
    position: absolute;
    top: 8px;
    display: grid;
    place-items: center;
    width: 8px;
    height: 8px;
    margin-left: -4px;
    border-radius: 50%;
    background: rgba(255, 71, 38, 0.3);
    color: transparent;
    font-family: var(--display);
    font-size: 11px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    transition: background .25s var(--ease), color .25s var(--ease), width .3s var(--ease), height .3s var(--ease), margin .3s var(--ease), top .3s var(--ease);
}
.log-pin.on { background: var(--accent-bright); }
.log-pin.active {
    z-index: 1;
    top: 0;
    width: 24px;
    height: 24px;
    margin-left: -12px;
    background: var(--accent-bright);
    color: #fff;
    box-shadow: 0 0 0 3px #fff, 0 4px 10px -4px rgba(255, 71, 38, 0.8);
}
.log.touched .log-pin.active::after {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 1.5px solid var(--accent-bright);
    opacity: 0;
    animation: log-ring 1.1s var(--ease) 1;
}
@keyframes log-ring {
    from { opacity: 0.9; transform: scale(0.6); }
    to   { opacity: 0;   transform: scale(1.9); }
}

/* Playhead */
.log-head-line {
    position: absolute;
    top: 26px;
    bottom: 32px;
    width: 0;
    border-left: 2px solid var(--ink);
    pointer-events: none;
    transition: left .12s linear;
}
.log-head-line::before {
    content: "";
    position: absolute;
    top: -4px;
    left: -6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--ink);
}
.log.is-dragging .log-head-line,
.log.is-playing .log-head-line { transition: none; }

/* ----- live caption: the commit under the playhead ------------------------ */
.log-caption {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 16px;
    align-items: baseline;
    min-height: 3.6em;
    margin: 16px 0 0;
    padding: 14px 20px;
    background: var(--log-panel);
    border-radius: 14px;
    box-shadow: var(--lift-1);
}
.log-caption .when {
    font-family: var(--display);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--accent-on-light);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.log-caption .what { font-size: 16px; line-height: 1.45; color: var(--ink); }
.log-caption .who {
    grid-column: 1;
    font-family: var(--display);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-4);
}

/* ----- the lessons -------------------------------------------------------- */
.log-lessons-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 34px 0 14px;
}
.log .log-lessons-head h3 {
    margin: 0;
    font-family: var(--display);
    font-size: clamp(20px, 2.4vw, 28px);
    font-weight: 800;
    font-stretch: 85%;
    letter-spacing: -0.02em;
    color: var(--ink);
}
.log-nav { display: flex; align-items: center; gap: 8px; }
.log-count {
    min-width: 5.5em;
    margin-right: 4px;
    text-align: right;
    font-family: var(--display);
    font-size: 14px;
    font-weight: 700;
    color: var(--ink-3);
    font-variant-numeric: tabular-nums;
}
.log-nav button {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 50%;
    background: var(--log-panel);
    color: var(--ink);
    box-shadow: var(--lift-1);
    cursor: pointer;
    transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.log-nav button:hover { transform: translateY(-1px); box-shadow: var(--lift-2); }
.log-nav button:disabled { opacity: 0.35; cursor: default; transform: none; box-shadow: var(--lift-1); }
.log-nav svg { width: 18px; height: 18px; }

.log .log-lessons {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: min(420px, 84%);
    gap: 16px;
    margin: 0 calc(-1 * var(--gutter));
    padding: 6px var(--gutter) 18px;
    list-style: none;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 var(--gutter);
    scrollbar-width: none;
    overscroll-behavior-x: contain;
}
.log .log-lessons::-webkit-scrollbar { display: none; }
.log-lesson {
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 24px 26px 22px;
    background: var(--log-panel);
    border-radius: 20px;
    box-shadow: var(--lift-1);
    outline: 2px solid transparent;
    outline-offset: -2px;
    cursor: pointer;
    transition: outline-color .3s var(--ease), box-shadow .3s var(--ease), background .3s var(--ease);
}
.log-lesson.active { outline-color: var(--accent-bright); background: #fff; box-shadow: var(--lift-2); cursor: default; }
.log-lesson .l-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-family: var(--display);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-4);
    font-variant-numeric: tabular-nums;
}
.log-lesson .l-meta b { color: var(--accent-on-light); font-weight: 800; }
.log-lesson h4 {
    margin: 14px 0 0;
    font-family: var(--display);
    font-size: clamp(22px, 2.4vw, 27px);
    font-weight: 800;
    font-stretch: 85%;
    line-height: 1.04;
    letter-spacing: -0.02em;
    color: var(--ink);
}
.log .log-lesson p {
    margin: 12px 0 0;
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink-3);
}
.log-lesson .l-fig {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-top: auto;
    padding-top: 20px;
}
.log-lesson .l-fig b {
    font-family: var(--display);
    font-size: clamp(34px, 4vw, 48px);
    font-weight: 800;
    font-stretch: 78%;
    line-height: 1;
    letter-spacing: -0.035em;
    color: var(--accent-on-light);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.log-lesson .l-fig span {
    flex: 1 1 14ch;
    font-size: 13px;
    line-height: 1.4;
    color: var(--ink-3);
}
/* The closing card is the one night surface left: the pattern, not a lesson. */
.log-lesson.l-final,
.log-lesson.l-final.active { background: var(--ink); }
.log-lesson.l-final .l-meta,
.log-lesson.l-final .l-meta b,
.log-lesson.l-final .l-fig span { color: var(--on-night-2); }
.log-lesson.l-final h4 { color: var(--on-night); }
.log .log-lesson.l-final p { color: var(--on-night-2); }
.log-lesson.l-final .l-fig b { color: var(--accent-bright); }

.log figcaption {
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--ink-4);
}
.log figcaption a { color: var(--ink-2); text-decoration-color: var(--accent-on-light); }

@media (max-width: 820px) {
    .log-section { min-height: 0; }
    .log-head { flex-direction: column; align-items: flex-start; }
    .log-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .log-stage { --lane-gutter: 0px; }
    .log-lane-labels { left: 0; width: auto; }
    .log-lane-labels span { padding-left: 6px; opacity: 0; transition: opacity .25s var(--ease); text-shadow: 0 0 6px #fff, 0 0 2px #fff; }
    .log-wave { height: 84px; }
    .log-lane-labels span.on { opacity: 1; }
    .log-caption { grid-template-columns: 1fr; }
    .log-caption .who { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
    .log *, .log *::before, .log *::after { transition: none !important; animation: none !important; }
    .log-lessons { scroll-behavior: auto; }
}

@media print {
    .log-section { min-height: 0; }
    .log-play, .log-nav, .log-stage, .log-caption { display: none; }
    .log .log-lessons { display: block; overflow: visible; margin: 0; padding: 0; }
    .log-lesson { margin: 0 0 10px; background: #fff; box-shadow: none; outline: 0; border: 1px solid #bbb; break-inside: avoid; }
    .log-lesson *, .log .log-title em, .log-stat dd, .log-stat dt { color: #000 !important; }
    .log-lesson.l-final { background: #fff; }
    .log-stat { box-shadow: none; border: 1px solid #bbb; }
}
