/* A cultural timeline. The waveform is illustrative; its height is not data. */
.engineering-history,
.history-source,
.history-peek {
    --history-mono: 'SF Mono', 'Fira Code', Menlo, monospace;
    --history-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}
.engineering-history {
    --history-width: calc(100vw - 64px);
    --history-cursor-yellow: #f7db16;
    --history-empty-line: #d2d2cf;
    position: relative;
    width: var(--history-width);
    margin-block: 48px 62px;
    margin-inline: calc((100% - var(--history-width)) / 2);
    isolation: isolate;
}

.history-heading-row { display: flex; align-items: center; justify-content: center; gap: 24px; padding: 0 14px 28px; text-align: center; }
.history-heading-row h2 { margin: 0; font: 14px/1.6 var(--history-mono); color: var(--ai-ink); text-decoration: none; font-weight: 400; }
.history-scroll-frame { position: relative; width: 100vw; margin-inline: calc((100% - 100vw) / 2); }
.history-scroll-frame::before, .history-scroll-frame::after { content: ''; position: absolute; z-index: 5; top: 8px; bottom: 20px; width: clamp(88px, 11vw, 144px); opacity: 0; pointer-events: none; transition: opacity 180ms ease; background: radial-gradient(ellipse 100% 55% at 0 50%, rgba(55,53,47,.1), rgba(55,53,47,.05) 35%, rgba(55,53,47,.015) 70%, transparent 100%); }
.history-scroll-frame::before { left: 0; }
.history-scroll-frame::after { right: 0; transform: scaleX(-1); }
.history-scroll-frame.can-scroll-left::before, .history-scroll-frame.can-scroll-right::after { opacity: 1; }
.history-scroll { display: flex; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; touch-action: pan-x pan-y; }
.history-scroll::-webkit-scrollbar { display: none; }
.history-track { flex-shrink: 0; height: 480px; position: relative; width: max(2400px, calc(100% + 560px)); }
.history-next { position: relative; flex: 0 0 64px; margin: 0 32px 0 8px; }
.history-next .model-landmark { left: 0; pointer-events: none; }
.history-wave { position: absolute; inset: 0; height: 470px; pointer-events: none; }
.history-playhead { position: absolute; top: 8px; bottom: 20px; width: 1px; background: var(--history-cursor-yellow); pointer-events: none; z-index: 4; opacity: 0; transition: opacity 120ms; }
.history-playhead.is-visible { opacity: 1; }
.history-scroll.is-dragging { user-select: none; }
/* Match the reference's solid 1px CSS bars, without SVG stroke scaling. */
.history-bar { position: absolute; display: block; width: 1px; background: var(--history-empty-line); }
.history-bar.has-source { background: #000; }
.history-bar.is-model { background: var(--ai-ink); }
.history-bar.is-primary, .history-bar.is-active { background: var(--ai-blue); }
.history-evidence { position: absolute; inset: 0; }
.history-evidence-hit { position: absolute; top: 144px; height: 172px; transform: translateX(-50%); margin: 0; padding: 0; border: 0; background: transparent; cursor: pointer; }
.history-evidence-hit:focus-visible { outline: 1px solid var(--ai-blue); outline-offset: 2px; }
.history-moments { list-style: none; margin: 0; padding: 0; }
.history-moment { position: absolute; top: 0; left: var(--moment-x); width: 0; height: 470px; margin: 0; padding: 0; }
.history-marker { position: absolute; top: 208px; left: -22px; width: 44px; height: 44px; border: 0; padding: 0; background: none; color: var(--ai-ink); pointer-events: none; -webkit-tap-highlight-color: transparent; }
.history-label { position: absolute; left: -33px; width: 132px; text-align: left; cursor: pointer; pointer-events: auto; }
.history-moment-bottom .history-label { top: 112px; }
.history-moment-top .history-label { bottom: 112px; }
.history-label::before { content: ''; position: absolute; left: 55px; width: .5px; background: var(--history-empty-line); pointer-events: none; }
.history-moment-bottom .history-label::before { height: 49px; top: -61px; }
.history-moment-top .history-label::before { height: 43px; bottom: -55px; }
.history-era { display: block; font: 400 17px/1.3 var(--history-sans); }
.history-era > span { display: block; font-size: 12px; line-height: 1.5; color: var(--ai-muted); }
.history-era > .history-era-name { display: inline; padding: 2px 5px; margin-left: -5px; background: var(--ai-highlight); color: var(--ai-ink); font: inherit; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.history-label time,
.history-pending { display: block; margin-top: 7px; font: 9px/1.4 var(--history-mono); color: var(--ai-muted); white-space: nowrap; }
.history-marker:is(:hover, :focus-visible, [aria-expanded='true']) .history-era { text-decoration: underline; text-decoration-color: var(--ai-ink); text-underline-offset: 4px; text-decoration-thickness: .5px; }
.history-marker:focus-visible { outline: 1px solid var(--ai-ink); outline-offset: 2px; border-radius: 50%; }
.history-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; border-top: 1px solid var(--ai-line); padding: 13px 14px 0; }
.history-instruction { display: flex; align-items: center; gap: 8px; margin: 0; font: 10px/1.5 var(--history-mono); color: var(--ai-muted); }
.history-pointer-icon { font: 17px/1 var(--history-mono); color: var(--ai-muted); }
.history-touch-hint { display: none; }
.history-navigation { display: flex; gap: 6px; align-items: center; }
.history-navigation button { border: 0; border-radius: 2px; width: 28px; height: 28px; background: transparent; color: var(--ai-muted); font: 14px/1 var(--history-mono); cursor: pointer; transition: color 160ms, background 160ms; }
.history-navigation button:hover { color: var(--ai-ink); background: var(--ai-highlight); }
.history-navigation button:disabled { opacity: .3; cursor: default; }
.engineering-page.history-in-view .toc { opacity: 0; pointer-events: none; visibility: hidden; }
.engineering-page .toc { transition: opacity 180ms ease; }

/* Source cards sit beside the pointer, so they remain easy to enter and read. */
.history-source { position: fixed; z-index: 70; width: 306px; max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 0; border: 1px solid var(--ai-line); border-radius: 5px; color: var(--ai-ink); background: var(--ai-paper); box-shadow: 0 4px 16px rgba(55,53,47,.06); }
.history-source[hidden] { display: none; }
.history-source.is-entering { animation: history-card-in 230ms cubic-bezier(.16,1,.3,1) both; }
.history-source-top { display: flex; align-items: center; justify-content: space-between; min-height: 32px; padding: 6px 8px 0 14px; color: var(--ai-muted); font: 9px/1.5 var(--history-mono); }
.history-source-top button { display: grid; place-items: center; width: 28px; height: 28px; flex-shrink: 0; padding: 0; background: none; border: 0; border-radius: 2px; font: 18px/1 var(--history-sans); color: var(--ai-muted); cursor: pointer; }
.history-source-top button:hover { background: var(--ai-highlight); color: var(--ai-ink); }
.history-source-content { padding: 9px 14px 14px; }
.history-source-byline { display: flex; align-items: center; justify-content: space-between; gap: 12px; font: 11px/1.5 var(--history-sans); color: var(--ai-ink); }
.history-source-byline time, .history-source-date { font: 9px/1.5 var(--history-mono); color: var(--ai-muted); white-space: nowrap; }
.history-source-quote { margin: 10px 0 14px; font: 14px/1.5 var(--history-sans); color: var(--ai-ink); }
.history-source-note { margin: 0 0 14px; font: 12px/1.65 var(--history-sans); color: var(--ai-muted); }
.history-preview { display: block; width: 100%; position: relative; overflow: hidden; padding: 0; border: 1px solid var(--ai-line); border-radius: 2px; background: var(--ai-paper); cursor: pointer; }
.history-preview[hidden] { display: none; }
.history-preview img { display: block; width: 100%; height: auto; }
.history-source-links { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.history-source-links a { color: var(--ai-muted); text-decoration: none; font: 9px/1.5 var(--history-mono); }
.history-source-links a:hover { color: var(--ai-ink); }
.history-source-open { padding: 0 0 4px; }
.history-source-open .history-source-note { margin-bottom: 4px; }
.history-source :focus-visible,
.history-navigation button:focus-visible { outline: 2px solid var(--ai-blue); outline-offset: 3px; }

/* Hover is a small, non-interactive peek. Only a click opens the source card. */
.history-peek { position: fixed; z-index: 69; width: 184px; max-width: calc(100vw - 24px); padding: 7px; border: 1px solid var(--ai-line); border-radius: 3px; background: var(--ai-paper); color: var(--ai-ink); box-shadow: 0 2px 10px rgba(55,53,47,.04); pointer-events: none; animation: history-peek-in 180ms ease-out both; transition: left 110ms ease-out; }
.history-peek[hidden] { display: none; }
.history-peek-image { height: 66px; overflow: hidden; margin-bottom: 6px; }
.history-peek-image img { width: 100%; height: auto; display: block; }
.history-peek-meta { display: flex; justify-content: space-between; gap: 6px; font: 8px/1.4 var(--history-mono); color: var(--ai-muted); }
.history-peek-meta > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-peek p { margin: 4px 0 0; font: 11px/1.4 var(--history-sans); color: var(--ai-ink); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
@keyframes history-peek-in { from { opacity: 0; transform: translateY(4px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

@keyframes history-card-in { from { opacity: 0; transform: translateY(7px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@media (max-width: 760px) {
    .engineering-history { --history-width: calc(100vw - 32px); margin-block: 36px 48px; }
    .history-heading-row { padding: 0 12px 22px; gap: 12px; }
    .history-heading-row h2 { font-size: 12px; }
    .history-footer { padding: 12px 0 0; }
    .history-navigation { gap: 7px; }
    .history-navigation button { width: 36px; height: 36px; }
    .history-desktop-hint { display: none; }
    .history-touch-hint { display: inline; }
    .history-instruction { font-size: 9px; gap: 5px; }
    .history-source { width: min(340px, calc(100vw - 32px)); max-height: min(520px, calc(100dvh - 32px)); }
    .history-source-top { min-height: 42px; }
    .history-source-top button { width: 36px; height: 36px; }
}
@media (hover: hover) and (pointer: fine) {
    .history-track, .history-track button, .history-track .history-label { cursor: none; }
}
@media (hover: none) {
    .history-desktop-hint { display: none; }
    .history-touch-hint { display: inline; }
}
@media (prefers-reduced-motion: reduce) {
    .history-scroll-frame::before, .history-scroll-frame::after { transition: none; }
    .engineering-history *, .history-source *, .history-peek * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
    .history-source, .history-peek { animation: none !important; transition: none !important; }
}
@media print {
    .history-scroll-frame { width: 100%; margin-inline: 0; }
    .history-scroll-frame::before, .history-scroll-frame::after { display: none; }
    .engineering-history { width: 100%; margin: 20px 0; }
    .history-track { min-width: 0; }
    .history-footer, .history-source, .history-peek { display: none !important; }
}
