/*
 * Oral Archivist — public transcript player.
 *
 * All colors, spacing accents, and radii come from the custom properties
 * below, with neutral gray defaults that inherit the theme's fonts.
 * Themes override by redefining the variables, e.g.:
 *
 *   .oral-archivist-player {
 *       --oa-accent: #1d4e33;
 *       --oa-highlight-bg: #f6efdf;
 *       --oa-bar-bg: #1d4e33;
 *       --oa-bar-fg: #fff;
 *   }
 */

.oral-archivist-player {
    --oa-accent: #4a4a4a;                 /* active rail, timestamps, focus */
    --oa-muted: #757575;                  /* secondary text */
    --oa-border: #d9d9d9;                 /* rules and rails */
    --oa-surface: rgba(0, 0, 0, 0.03);    /* subtle panels */
    --oa-highlight-bg: rgba(0, 0, 0, 0.06); /* active paragraph/chapter */
    --oa-bar-bg: #2f2f2f;                 /* audio player bar background */
    --oa-bar-fg: #fff;                    /* audio player bar text */
    --oa-play-bg: #fff;                   /* play button circle */
    --oa-play-fg: #2f2f2f;                /* play button icon */
    --oa-wave-played: #fafafa;            /* waveform, played portion */
    --oa-wave-rest: rgba(255, 255, 255, 0.35); /* waveform, remaining */
    --oa-radius: 8px;

    margin: 1.75rem 0;
    max-width: 100%;
}

/*
 * Player layout styles (module setting "Player style", per-site
 * overridable): basic (native, no custom chrome), slate (waveform bar),
 * chapters (segmented timeline), compact (pill), card (cover-art).
 * All layouts read the custom properties above, so themes recolor any
 * of them by overriding variables.
 */

.oral-archivist-player .oa-heading {
    margin: 0 0 0.25rem;
}

/* Meta line ------------------------------------------------------------- */

.oral-archivist-player .oa-meta {
    margin: 0 0 0.75rem;
    color: var(--oa-muted);
    font-size: 0.88em;
}

/* Player bar ------------------------------------------------------------ */

.oral-archivist-player .oa-player-bar {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--oa-border);
    border-radius: var(--oa-radius);
}

.oral-archivist-player .oa-media {
    width: 100%;
    max-height: 60vh;
    display: block;
}

.oral-archivist-player .oa-now-playing {
    margin: 0.4rem 0 0;
    font-size: 0.85em;
    font-variant-numeric: tabular-nums;
    color: var(--oa-muted);
}

/* Custom audio bar (JS-enhanced): full-width dark bar with a big play
   toggle, seekable waveform canvas, and elapsed/chapter/total readout. */

.oral-archivist-player .oa-audio-bar.oa-enhanced {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    min-height: 84px;
    padding: 1rem 1.25rem;
    background: var(--oa-bar-bg);
    color: var(--oa-bar-fg);
    border: none;
    border-radius: calc(var(--oa-radius) + 4px);
}

.oral-archivist-player .oa-player-bar.oa-enhanced .oa-media {
    display: none; /* playback runs through the custom controls */
}

/* Basic layout: the browser's standard player, no chrome of ours. */
.oral-archivist-player .oa-basic-bar {
    padding: 0;
    border: none;
}

.oral-archivist-player .oa-play-toggle {
    flex: 0 0 auto;
    width: 54px;
    height: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--oa-play-bg);
    color: var(--oa-play-fg);
    cursor: pointer;
}

.oral-archivist-player .oa-play-toggle svg {
    width: 26px;
    height: 26px;
    display: block;
}

.oral-archivist-player .oa-play-toggle:hover,
.oral-archivist-player .oa-play-toggle:focus-visible {
    transform: scale(1.05);
}

.oral-archivist-player .oa-play-toggle:focus-visible {
    outline: 2px solid var(--oa-bar-fg);
    outline-offset: 3px;
}

/* Icon toggling — keep these more specific than the base
   `.oa-play-toggle svg` display rule, or both icons show at once. */
.oral-archivist-player .oa-play-toggle .oa-icon-pause,
.oral-archivist-player .oa-playing .oa-play-toggle .oa-icon-play {
    display: none;
}

.oral-archivist-player .oa-playing .oa-play-toggle .oa-icon-pause {
    display: block;
}

.oral-archivist-player .oa-wave-wrap {
    flex: 1;
    min-width: 0;
}

.oral-archivist-player .oa-wave {
    position: relative;
    height: 44px;
    border-radius: 4px;
}

.oral-archivist-player .oa-wave:focus-within {
    outline: 2px solid var(--oa-bar-fg);
    outline-offset: 3px;
}

.oral-archivist-player .oa-wave-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.oral-archivist-player .oa-seek {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.oral-archivist-player .oa-bar-meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin: 0.45rem 0 0;
    font-size: 0.85em;
    font-variant-numeric: tabular-nums;
}

.oral-archivist-player .oa-bar-meta .oa-now-playing {
    margin: 0;
    color: inherit;
    opacity: 0.9;
}

.oral-archivist-player .oa-bar-meta .oa-total {
    opacity: 0.65;
    white-space: nowrap;
}

.oral-archivist-player .oa-video-bar .oa-now-playing {
    color: var(--oa-muted);
}

/* Chapter timeline layout: dark bar shared with slate, but the progress
   surface is a row of proportional, titled chapter segments. */

.oral-archivist-player .oa-timeline-wrap {
    flex: 1;
    min-width: 0;
}

.oral-archivist-player .oa-timeline {
    position: relative;
    height: 30px;
}

.oral-archivist-player .oa-timeline:focus-within {
    outline: 2px solid var(--oa-bar-fg);
    outline-offset: 3px;
    border-radius: 4px;
}

.oral-archivist-player .oa-tl-base,
.oral-archivist-player .oa-tl-fill {
    position: absolute;
    inset: 0;
}

.oral-archivist-player .oa-tl-seg {
    position: absolute;
    top: 50%;
    height: 10px;
    transform: translateY(-50%);
    border-radius: 5px;
    background: var(--oa-wave-rest);
    transition: height 0.15s ease;
}

.oral-archivist-player .oa-timeline:hover .oa-tl-seg {
    height: 16px;
}

.oral-archivist-player .oa-tl-fill {
    width: 0;
    overflow: hidden;
}

.oral-archivist-player .oa-tl-fill-inner {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
}

.oral-archivist-player .oa-tl-fill .oa-tl-seg {
    background: var(--oa-wave-played);
}

/* Compact layout: slim pill, light chrome, thin progress line. */

.oral-archivist-player .oa-compact-bar.oa-enhanced {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.4rem 1.1rem 0.4rem 0.4rem;
    background: var(--oa-surface);
    border: 1px solid var(--oa-border);
    border-radius: 999px;
}

.oral-archivist-player .oa-compact-bar .oa-play-toggle {
    width: 38px;
    height: 38px;
    background: var(--oa-accent);
    color: #fff;
}

.oral-archivist-player .oa-compact-bar .oa-play-toggle svg {
    width: 18px;
    height: 18px;
}

.oral-archivist-player .oa-compact-bar .oa-play-toggle:focus-visible {
    outline-color: var(--oa-accent);
}

.oral-archivist-player .oa-line-wrap {
    flex: 1;
    min-width: 0;
}

.oral-archivist-player .oa-line {
    position: relative;
    height: 20px;
}

.oral-archivist-player .oa-line::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 4px;
    transform: translateY(-50%);
    background: var(--oa-border);
    border-radius: 2px;
}

.oral-archivist-player .oa-line-fill {
    position: absolute;
    left: 0;
    top: 50%;
    height: 4px;
    width: 0;
    transform: translateY(-50%);
    background: var(--oa-accent);
    border-radius: 2px;
}

.oral-archivist-player .oa-line:focus-within {
    outline: 2px solid var(--oa-accent);
    outline-offset: 3px;
    border-radius: 4px;
}

.oral-archivist-player .oa-compact-times {
    font-size: 0.82em;
    font-variant-numeric: tabular-nums;
    color: var(--oa-muted);
    white-space: nowrap;
}

.oral-archivist-player .oa-compact-sep {
    margin: 0 0.3em;
    opacity: 0.6;
}

.oral-archivist-player .oa-compact-readout {
    margin: 0.35rem 0 0 3.3rem;
    font-size: 0.8em;
}

/* Card layout: cover art (or a generated backdrop) with a large overlay
   play button, title, and a thin progress line. */

.oral-archivist-player .oa-card-bar.oa-enhanced {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1rem;
    background: var(--oa-surface);
    border: 1px solid var(--oa-border);
    border-radius: calc(var(--oa-radius) + 4px);
}

.oral-archivist-player .oa-card-cover {
    position: relative;
    flex: 0 0 132px;
    height: 132px;
    border-radius: var(--oa-radius);
    overflow: hidden;
}

.oral-archivist-player .oa-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.oral-archivist-player .oa-card-pattern {
    background:
        repeating-linear-gradient(115deg,
            rgba(255, 255, 255, 0.06) 0 6px, transparent 6px 14px),
        linear-gradient(135deg, var(--oa-bar-bg), #5a5a5a);
}

.oral-archivist-player .oa-play-overlay {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.92);
    color: #222;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.oral-archivist-player .oa-play-overlay:focus-visible {
    outline-color: #fff;
}

.oral-archivist-player .oa-card-body {
    flex: 1;
    min-width: 0;
}

.oral-archivist-player .oa-card-title {
    margin: 0 0 0.6rem;
    font-weight: 700;
}

.oral-archivist-player .oa-card-bar .oa-bar-meta {
    color: var(--oa-muted);
}

@media (max-width: 560px) {
    .oral-archivist-player .oa-card-cover {
        flex-basis: 92px;
        height: 92px;
    }
}

/* Two-column body ------------------------------------------------------- */

.oral-archivist-player .oa-columns {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    margin-top: 1.25rem;
}

.oral-archivist-player .oa-col-heading {
    margin: 0 0 0.75rem;
    font-size: 0.78em;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--oa-muted);
}

/* Sidebar: chapter rail + in-interview search --------------------------- */

.oral-archivist-player .oa-sidebar {
    flex: 0 0 240px;
    position: sticky;
    top: 1rem;
}

.oral-archivist-player .oa-chapters {
    margin-bottom: 1.5rem;
}

.oral-archivist-player .oa-chapters ol {
    margin: 0;
    padding: 0;
    list-style: none;
    border-left: 2px solid var(--oa-border);
}

.oral-archivist-player .oa-chapter-link {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 0.45rem 0.6rem 0.45rem 0.85rem;
    margin-left: -2px;
    border-left: 2px solid transparent;
    text-decoration: none;
    color: inherit;
}

.oral-archivist-player .oa-chapter-link:hover,
.oral-archivist-player .oa-chapter-link:focus-visible {
    background: var(--oa-surface);
}

.oral-archivist-player .oa-chapter-link.oa-active {
    border-left-color: var(--oa-accent);
    background: var(--oa-highlight-bg);
}

.oral-archivist-player .oa-chapter-link.oa-active .oa-chapter-name {
    font-weight: 700;
}

.oral-archivist-player .oa-chapter-time {
    color: var(--oa-muted);
    font-size: 0.85em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Transcript ------------------------------------------------------------ */

.oral-archivist-player .oa-transcript-col {
    flex: 1;
    min-width: 0;
}

/* The transcript is a bounded scroll pane (the follow-along highlight
   auto-scrolls inside it); the document layout resets this to flow with
   the page. Without overflow-y here, a max-height just lets the text
   paint over whatever follows. */
.oral-archivist-player .oa-transcript {
    max-height: 480px;
    overflow-y: auto;
    padding-right: 0.5rem;
    scroll-behavior: smooth;
}

.oral-archivist-player .oa-transcript:focus-visible {
    outline: 2px solid var(--oa-accent);
    outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
    .oral-archivist-player .oa-transcript {
        scroll-behavior: auto;
    }
}

.oral-archivist-player .oa-paragraph {
    margin: 0 0 1.1rem;
    padding: 0.6rem 0.85rem;
    border-radius: var(--oa-radius);
    cursor: pointer;
}

.oral-archivist-player .oa-paragraph:hover {
    background: var(--oa-surface);
}

.oral-archivist-player .oa-paragraph.oa-active {
    background: var(--oa-highlight-bg);
}

.oral-archivist-player .oa-p-meta {
    margin: 0 0 0.3rem;
    font-size: 0.78em;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--oa-muted);
}

.oral-archivist-player .oa-p-time {
    color: var(--oa-accent);
    font-variant-numeric: tabular-nums;
}

.oral-archivist-player .oa-text {
    margin: 0;
    line-height: 1.7;
}

/* Footnotes: numbered markers, hover popups, references list ------------ */

.oral-archivist-player .oa-fn {
    border-bottom: 1px dotted var(--oa-accent);
    cursor: help;
}

.oral-archivist-player .oa-fn:hover,
.oral-archivist-player .oa-fn:focus-visible {
    background: var(--oa-highlight-bg);
    outline: none;
}

.oral-archivist-player .oa-fn-num {
    font-size: 0.72em;
    line-height: 0;
    margin-left: 1px;
}

.oral-archivist-player .oa-fn-num a {
    color: var(--oa-accent);
    text-decoration: none;
    font-weight: 700;
}

.oral-archivist-player .oa-fn-pop {
    position: fixed;
    z-index: 1000;
    display: none;
    width: 280px;
    max-width: calc(100vw - 16px);
    padding: 0.7rem 0.85rem;
    background: #fff;
    border: 1px solid var(--oa-border);
    border-top: 3px solid var(--oa-accent);
    border-radius: var(--oa-radius);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.16);
    font-size: 0.88em;
    color: #222;
}

.oral-archivist-player .oa-fn-pop--visible {
    display: block;
}

.oral-archivist-player .oa-fn-pop-num {
    margin: 0 0 0.3rem;
    font-size: 0.78em;
    font-weight: 700;
    color: var(--oa-muted);
}

.oral-archivist-player .oa-fn-pop-num::before {
    content: 'Note ';
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.oral-archivist-player .oa-fn-pop-body {
    margin: 0 0 0.5rem;
    line-height: 1.5;
}

.oral-archivist-player .oa-fn-pop-item {
    display: flex;
    gap: 10px;
    align-items: center;
    text-decoration: none;
    color: inherit;
}

.oral-archivist-player .oa-fn-pop-item img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    flex: 0 0 auto;
}

.oral-archivist-player .oa-fn-pop-item span {
    text-decoration: underline;
    line-height: 1.35;
}

.oral-archivist-player .oa-fn-pop-url {
    display: inline-block;
    margin-top: 0.3rem;
    color: var(--oa-accent);
}

/* References list at the end of the transcript column. */
.oral-archivist-player .oa-references {
    margin-top: 1.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--oa-border);
}

.oral-archivist-player .oa-references ol {
    margin: 0;
    padding-left: 1.4rem;
}

.oral-archivist-player .oa-references li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.oral-archivist-player .oa-references li:target {
    background: var(--oa-highlight-bg);
    border-radius: 4px;
}

.oral-archivist-player .oa-ref-link {
    margin-left: 6px;
    color: var(--oa-accent);
}

/* Action buttons -------------------------------------------------------- */

.oral-archivist-player .oa-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 1.25rem;
}

.oral-archivist-player .oa-action {
    padding: 0.45rem 1.1rem;
    background: none;
    border: 1px solid var(--oa-border);
    border-radius: 999px;
    color: inherit;
    font: inherit;
    font-size: 0.9em;
    cursor: pointer;
}

.oral-archivist-player .oa-action:hover,
.oral-archivist-player .oa-action:focus-visible {
    border-color: var(--oa-accent);
    background: var(--oa-surface);
}

/* Responsive + motion --------------------------------------------------- */

@media (max-width: 800px) {
    .oral-archivist-player .oa-columns {
        flex-direction: column;
    }

    .oral-archivist-player .oa-sidebar {
        position: static;
        flex-basis: auto;
        width: 100%;
    }
}

/* Page layouts ---------------------------------------------------------- */

/* Sidecar: player + chapters + search stick on the left, the transcript
   reads alongside (Cap-style side-by-side). */
.oral-archivist-player--layout-sidecar .oa-columns--sidecar {
    align-items: flex-start;
}

.oral-archivist-player--layout-sidecar .oa-sidecar-left {
    flex: 0 0 42%;
    max-width: 480px;
}

.oral-archivist-player--layout-sidecar .oa-sidecar-left .oa-player-bar {
    margin-bottom: 1.25rem;
}

.oral-archivist-player--layout-sidecar .oa-transcript {
    max-height: 76vh;
    overflow-y: auto;
}

/* Document: reading view — slim sticky player, chapters inline as
   section headings, transcript flows with the page. */
/* The sticky strip is a docked toolbar card: player + search travel
   together, visually contained (opaque so the document can't scroll
   through it). Override --oa-doc-sticky-bg to retheme. */
.oral-archivist-player--layout-document .oa-doc-playerwrap {
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 10px 12px;
    background: var(--oa-doc-sticky-bg, #f6f6f4);
    border: 1px solid var(--oa-border);
    border-radius: calc(var(--oa-radius) + 4px);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 1.5rem;
}

.oral-archivist-player--layout-document .oa-doc-playerwrap .oa-player-bar {
    margin: 0;
}

.oral-archivist-player--layout-document .oa-doc-body {
    max-width: 760px;
    margin: 0 auto;
}

/* In the sticky strip the search collapses to one compact row: input,
   match counter, prev/next — no heading. */
/* Toolbar row under the player: chapter jump left, search right. */
.oral-archivist-player--layout-document .oa-doc-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 8px 2px 0;
}

.oral-archivist-player--layout-document .oa-doc-chapter-select {
    flex: 0 1 auto;
    max-width: 46%;
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--oa-border);
    border-radius: var(--oa-radius);
    background: #fff;
    font: inherit;
    font-size: 0.9em;
    color: inherit;
}

.oral-archivist-player--layout-document .oa-doc-chapter-select:focus-visible {
    outline: 2px solid var(--oa-accent);
    outline-offset: 1px;
}

.oral-archivist-player--layout-document .oa-search {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.oral-archivist-player--layout-document .oa-search-input {
    background: #fff;
}

.oral-archivist-player--layout-document .oa-search .oa-col-heading {
    display: none;
}

.oral-archivist-player--layout-document .oa-search-input {
    flex: 0 1 320px;
    padding: 0.35rem 0.7rem;
}

.oral-archivist-player--layout-document .oa-search-meta {
    margin-top: 0;
    min-height: 0;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.oral-archivist-player--layout-document .oa-transcript {
    max-height: none;
    overflow: visible;
    border: none;
    padding: 0;
}

.oral-archivist-player--layout-document .oa-doc-chapter {
    margin: 1.9rem 0 0.7rem;
    font-size: 1.2em;
}

.oral-archivist-player--layout-document .oa-doc-chapter .oa-chapter-link {
    font-weight: 700;
}

/* Search-to-moment ------------------------------------------------------ */

.oral-archivist-player .oa-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--oa-border);
    border-radius: var(--oa-radius);
    font: inherit;
    font-size: 0.9em;
}

.oral-archivist-player .oa-search-input:focus-visible {
    outline: 2px solid var(--oa-accent);
    outline-offset: 1px;
}

.oral-archivist-player .oa-search-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 0.4rem;
    min-height: 26px;
}

.oral-archivist-player .oa-search-status {
    font-size: 0.82em;
    color: var(--oa-muted);
    font-variant-numeric: tabular-nums;
}

.oral-archivist-player .oa-search-nav button {
    padding: 1px 9px;
    background: var(--oa-surface);
    border: 1px solid var(--oa-border);
    border-radius: 10px;
    cursor: pointer;
    font: inherit;
    font-size: 0.85em;
}

.oral-archivist-player .oa-search-nav button:hover,
.oral-archivist-player .oa-search-nav button:focus-visible {
    border-color: var(--oa-accent);
}

.oral-archivist-player mark.oa-hit {
    padding: 0 2px;
    background: var(--oa-highlight-bg);
    border-bottom: 2px solid var(--oa-accent);
    border-radius: 2px;
    color: inherit;
    cursor: pointer;
}

.oral-archivist-player mark.oa-hit--current {
    background: var(--oa-accent);
    color: #fff;
}

@media (prefers-reduced-motion: no-preference) {
    .oral-archivist-player .oa-paragraph,
    .oral-archivist-player .oa-chapter-link {
        transition: background-color 0.2s ease;
    }
}
