/* ==========================================================================
   Part four, played back — transcriber/macos
   A .dg panel like the other diagrams. Each release since v3.15.0 is one bar
   (taller means more Swift lines changed), the test count is the line drawn
   over the bars, and the plans are the hollow bars after the last release.
   The chapters, tests and plans below are plain text and fully readable at
   rest: the playhead only moves emphasis, never hides anything for good.
   ========================================================================== */

.reel { --reel-dim: rgba(11, 12, 14, 0.14); }

.reel .dg-head { align-items: flex-end; }
.reel-play {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 44px;
    padding: 0 20px 0 14px;
    border: 0;
    border-radius: 999px;
    background: var(--accent-bright);
    color: var(--ink);
    font-family: var(--display);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--lift-1);
    transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.reel-play:hover { transform: translateY(-2px); box-shadow: var(--lift-2); }
.reel-play svg { width: 16px; height: 16px; }
.reel-play .ico-pause { display: none; }
.reel.is-playing .reel-play .ico-play { display: none; }
.reel.is-playing .reel-play .ico-pause { display: block; }
.reel-play:focus-visible,
.reel-stage:focus-visible,
.reel-chapter:focus-visible { outline: 2px solid var(--accent-on-light); outline-offset: 3px; }

/* ----- counters ----------------------------------------------------------- */
.reel-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 22px 0 0;
}
.reel-stat { padding: 12px 16px 11px; background: rgba(255, 255, 255, 0.8); border-radius: 14px; box-shadow: var(--lift-1); }
.reel-stat dt {
    font-family: var(--display);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-4);
}
.reel-stat dd {
    margin: 4px 0 0;
    font-family: var(--display);
    font-size: clamp(22px, 3vw, 34px);
    font-weight: 800;
    font-stretch: 82%;
    letter-spacing: -0.03em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}
.reel-stat dd small { font-size: 0.45em; font-weight: 600; letter-spacing: 0; color: var(--ink-4); }
.reel-stat.is-tests dd { color: var(--accent-on-light); }

/* ----- the stage: bars, test line, axis ------------------------------------ */
.reel-stage {
    position: relative;
    margin: 22px 0 0;
    padding-top: 26px;
    cursor: ew-resize;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
    border-radius: 8px;
}
.reel-stage[hidden] { display: none; }
.reel-bars {
    position: relative;
    display: grid;
    grid-template-columns: repeat(var(--n, 25), minmax(0, 1fr));
    align-items: end;
    gap: 4px;
    height: clamp(110px, 16vw, 168px);
    border-bottom: 1px solid var(--hair-strong);
}
.reel-bar {
    position: relative;
    height: calc(var(--h) * 100%);
    min-height: 6px;
    background: var(--reel-dim);
    border-radius: 4px 4px 0 0;
    transform-origin: bottom;
    transition: background .3s var(--ease), transform .5s var(--ease);
}
.reel-bar.is-on { background: var(--ink); }
.reel-bar.is-now { background: var(--accent-bright); box-shadow: 0 0 16px rgba(255, 71, 38, 0.45); }
.reel-bar.is-plan {
    height: 100%;
    background: transparent;
    border: 1.5px dashed var(--hair-strong);
    border-bottom: 0;
}
.reel.is-ended .reel-bar.is-plan { border-color: var(--accent-on-light); animation: reel-breathe 2.4s var(--ease-soft) infinite; }
@keyframes reel-breathe { 50% { background: rgba(255, 71, 38, 0.08); } }
.reel.is-armed .reel-bar:not(.is-plan) { transform: scaleY(0.04); }
.reel.is-armed .reel-bar.is-on { transform: none; }

/* The test count, drawn over the bars and revealed with the playhead. */
.reel-line { position: absolute; inset: 26px 0 auto; height: clamp(110px, 16vw, 168px); width: 100%; overflow: visible; pointer-events: none; }
.reel-line .tests { fill: none; stroke: var(--accent-bright); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 5px rgba(255, 71, 38, 0.35)); }
.reel-line .tests-base { fill: none; stroke: rgba(255, 71, 38, 0.18); stroke-width: 1.5; stroke-dasharray: 2 4; vector-effect: non-scaling-stroke; }
.reel-line-label {
    position: absolute;
    top: 0;
    transform: translate(-50%, -150%);
    padding: 1px 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--lift-1);
    font-family: var(--display);
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-on-light);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    transition: left .3s var(--ease);
}
.reel-line-label.is-below { transform: translate(-115%, 40%); }

.reel-axis {
    display: grid;
    grid-template-columns: repeat(var(--n, 25), minmax(0, 1fr));
    gap: 4px;
    margin-top: 8px;
    font-family: var(--display);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-4);
}
.reel-axis span { white-space: nowrap; }
.reel-axis .is-next { color: var(--accent-on-light); }

.reel-caption {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    align-items: baseline;
    min-height: 3em;
    margin: 14px 0 0;
    font-size: 15px;
    line-height: 1.45;
    color: var(--ink-2);
}
.reel-caption .when { font-family: var(--display); font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ----- chapters: the features ---------------------------------------------- */
.reel .reel-chapters,
.reel .reel-suites,
.reel .reel-plans { padding: 0; list-style: none; }
.reel .reel-chapters > li,
.reel .reel-suites > li,
.reel .reel-plans > li { list-style: none; margin: 0; }
.reel li::marker { content: none; }
.reel .reel-suites > li::before { content: none; }
.reel-chapters {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: 12px;
    margin: 22px 0 0;
    padding: 0;
    list-style: none;
}
.reel-chapter {
    position: relative;
    padding: 16px 18px 16px;
    background: rgba(255, 255, 255, 0.86);
    border-radius: 16px;
    box-shadow: var(--lift-1);
    cursor: pointer;
    transition: opacity .4s var(--ease), transform .4s var(--ease), box-shadow .4s var(--ease);
}
.reel .reel-chapters > .reel-chapter::before {
    content: "";
    counter-increment: none;
    position: absolute;
    left: 0;
    top: 16px;
    bottom: 16px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--accent-bright);
    transform: scaleY(0);
    transition: transform .4s var(--ease);
}
.reel-chapter .v { font-family: var(--display); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; color: var(--ink-4); font-variant-numeric: tabular-nums; }
.reel-chapter h4 {
    margin: 4px 0 8px;
    font-family: var(--display);
    font-size: 19px;
    font-weight: 800;
    font-stretch: 86%;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--ink);
}
.reel-chapter p { margin: 0; font-size: 14.5px; line-height: 1.5; color: var(--ink-2); }
.reel-chapter p + p { margin-top: 8px; }

.reel.is-running .reel-chapter { opacity: 0.42; }
.reel.is-running .reel-chapter.is-past { opacity: 0.8; }
.reel .reel-chapter.is-now { opacity: 1; transform: translateY(-3px); box-shadow: var(--lift-2); }
.reel .reel-chapters > .reel-chapter.is-now::before { transform: scaleY(1); }
.reel .reel-chapter.is-now .v { color: var(--accent-on-light); }

/* ----- tests and plans ----------------------------------------------------- */
.reel-lower { display: grid; align-items: start; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 12px; margin-top: 12px; }
.reel-panel { padding: 16px 18px 18px; background: rgba(255, 255, 255, 0.86); border-radius: 16px; box-shadow: var(--lift-1); }
.reel-panel h4 { margin: 0 0 6px; font-family: var(--display); font-size: 19px; font-weight: 800; font-stretch: 86%; letter-spacing: -0.02em; color: var(--ink); }
.reel-panel h4 em { font-style: normal; color: var(--accent-on-light); }
.reel-panel > p { margin: 0; font-size: 14.5px; line-height: 1.5; color: var(--ink-2); }

.reel-suites { margin: 14px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.reel .reel-suites > li { padding-left: 0; }
.reel-suites li { display: grid; grid-template-columns: minmax(0, 8em) minmax(60px, 1fr) 1.6em; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-3); }
.reel-suites .n { font-family: var(--display); font-weight: 700; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
.reel-suites .track { height: 8px; border-radius: 4px; background: rgba(11, 12, 14, 0.06); overflow: hidden; }
.reel-suites .fill {
    display: block;
    height: 100%;
    width: calc(var(--w) * 100%);
    border-radius: 4px;
    background: var(--ink);
    transform-origin: left;
    transition: transform .9s var(--ease);
    transition-delay: calc(var(--d, 0) * 70ms);
}
.reel-suites li:first-child .fill { background: var(--accent-bright); }
.reel.is-armed:not(.is-ended) .reel-suites .fill { transform: scaleX(0); }

.reel-panel.is-plans { background: rgba(255, 255, 255, 0.5); box-shadow: none; border: 1.5px dashed var(--hair-strong); }
.reel-plans { margin: 12px 0 0; padding: 0; list-style: none; counter-reset: none; display: grid; gap: 10px; }
.reel-plans li { position: relative; padding-left: 22px; font-size: 14.5px; line-height: 1.5; color: var(--ink-2); }
.reel .reel-plans > li::before {
    background: none;
    content: "";
    position: absolute;
    left: 2px;
    top: 0.42em;
    width: 10px;
    height: 10px;
    border: 1.5px dashed var(--accent-on-light);
    border-radius: 50%;
}
.reel-plans li b { font-family: var(--display); font-weight: 700; color: var(--ink); }

@media (max-width: 820px) {
    .reel .dg-head { flex-direction: column; align-items: flex-start; }
    .reel-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .reel-lower { grid-template-columns: 1fr; }
    .reel-bars, .reel-axis { gap: 2px; }
    .reel-axis { font-size: 10px; }
}
@media (max-width: 520px) {
    .reel-axis span:not(.is-key) { visibility: hidden; }
}
@media (prefers-reduced-motion: reduce) {
    .reel *, .reel *::before { transition: none !important; animation: none !important; }
}
@media print {
    .reel-play, .reel-stage { display: none; }
    .reel-chapter, .reel-panel { opacity: 1 !important; transform: none !important; box-shadow: none; border: 1px solid #bbb; }
}
