/* YouTube captions: third output chip + inline setup panel (Pro left column).
   Chip = state at a glance, same family as projection/broadcast chips:
   off (default) / armed (brand outline) / unverified (amber) / live (red ON AIR,
   as broadcast) / error (red outline). Theme tokens only (light + dark). */

.youtube-caption-chip { position: relative; }
.youtube-caption-chip-dot { display: none; width: 7px; height: 7px; border-radius: 50%; flex: none; }
.youtube-caption-chip[data-state="armed"] { border-color: var(--color-brand); color: var(--color-brand); }
.youtube-caption-chip[data-state="armed"] .youtube-caption-chip-dot { display: inline-block; background: var(--color-brand); }
.youtube-caption-chip[data-state="unverified"] { border-color: var(--color-warning); color: var(--color-text-primary); }
.youtube-caption-chip[data-state="unverified"] .youtube-caption-chip-dot {
    display: inline-block; background: var(--color-warning); animation: youtubeCaptionPulse 1.6s ease-in-out infinite;
}
.youtube-caption-chip[data-state="live"] { background: var(--color-error); border-color: var(--color-error); color: var(--color-text-on-brand); }
.youtube-caption-chip[data-state="live"] .youtube-caption-chip-dot { display: inline-block; background: var(--color-text-on-brand); }
.youtube-caption-chip[data-state="error"] { border-color: var(--color-error); color: var(--color-error); }
.youtube-caption-chip[data-state="error"] .youtube-caption-chip-dot { display: inline-block; background: var(--color-error); }
.youtube-caption-chip[aria-expanded="true"] { box-shadow: 0 0 0 2px rgba(var(--brand-rgb), .18); }

@keyframes youtubeCaptionPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(var(--warning-rgb), .6); }
    50%      { box-shadow: 0 0 0 4px rgba(var(--warning-rgb), 0); }
}

/* Inline panel under the output chips: it holds a text input, so it must not be a
   popover that closes on an outside click. */
.youtube-caption-panel {
    display: grid; gap: 8px; min-width: 0; margin-top: 10px; padding: 12px;
    border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-bg-secondary);
}
.youtube-caption-panel[hidden], .youtube-caption-panel [hidden] { display: none; }
.youtube-caption-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--color-text-primary); }
.youtube-caption-beta {
    margin-left: auto; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--color-border);
    font-size: 11px; font-weight: 400; color: var(--color-text-secondary);
}
.youtube-caption-panel .panel-label { margin: 4px 0 0; }
.youtube-caption-panel p { margin: 0; line-height: 1.5; }
.youtube-caption-panel .panel-hint { margin: 0; line-height: 1.5; }
/* The URL field wears the face of TransLive's dropdown (custom-select.css .cs-trigger),
   so the two fields of this form read as one family, at rest, hovered, focused and locked. */
.youtube-caption-panel input[type="text"] {
    width: 100%; box-sizing: border-box; min-width: 0; min-height: 36px; padding: 8px 12px;
    border: 1px solid rgba(var(--overlay-rgb), 0.1); border-radius: var(--radius-sm);
    background: rgba(var(--shadow-rgb), 0.12); color: var(--color-text-primary);
    font: inherit; font-size: 14px; line-height: 1.4;
    transition: border-color var(--transition-fast), background-color var(--transition-fast);
}
.youtube-caption-panel input[type="text"]:hover:not(:disabled) { border-color: rgba(var(--brand-rgb), 0.4); }
.youtube-caption-panel input[type="text"]:focus-visible {
    outline: none; border-color: var(--color-brand); box-shadow: 0 0 0 2px rgba(var(--brand-rgb), 0.2);
}
.youtube-caption-panel input[type="text"]::placeholder { color: var(--color-text-tertiary); }
/* The ingestion URL is a secret (screen shares, projection): masked by CSS, not by
   type=password, which makes password managers offer saved logins and offer to
   save the URL as a password. */
.youtube-caption-panel .youtube-caption-secret { -webkit-text-security: disc; text-security: disc; }
.youtube-caption-panel input[type="text"]:disabled { opacity: .45; cursor: not-allowed; }
/* The caption language is TransLive's dropdown (custom-select.js), sized like the page's other panel fields. */
.youtube-caption-panel .cs-select { width: 100%; }
.youtube-caption-panel .cs-trigger { min-height: 36px; padding: 8px 12px; font-size: 14px; }

/* Interpreted-event switch: TransLive's toggle, with the focus ring and locked look of the fields above. */
/* As tall as the toggle itself: the row sits right under the language it qualifies. */
.youtube-caption-toggle-row { gap: 12px; min-height: 20px; }
.youtube-caption-panel .youtube-caption-toggle-row .panel-label { margin: 0; line-height: 20px; cursor: pointer; }
.youtube-caption-panel .toggle-switch { flex: none; margin: 0; }
.youtube-caption-panel .toggle-switch input:focus-visible + .toggle-slider {
    outline: 2px solid var(--input-focus-border); outline-offset: 2px;
}
.youtube-caption-panel .toggle-switch input:disabled + .toggle-slider { opacity: .45; cursor: not-allowed; }

/* One primary action: start (brand), stop (quiet), confirm stop (red pulse, reverts in 3 s). */
.youtube-caption-primary.btn { width: 100%; margin: 4px 0 0; font-family: inherit; }
.youtube-caption-primary[data-role="stop"] {
    background: var(--color-bg-primary); color: var(--color-text-primary); border: 1px solid var(--color-border);
}
.youtube-caption-primary[data-role="stop"]:hover:not(:disabled) { border-color: var(--color-error); color: var(--color-error); }
.youtube-caption-primary[data-role="confirmStop"] {
    background: var(--color-error); border-color: var(--color-error); color: var(--color-text-on-brand);
    animation: outputConfirmPulse .9s ease-in-out infinite;
}
.youtube-caption-primary:disabled { opacity: .45; cursor: not-allowed; }

.youtube-caption-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--color-text-tertiary); }
.youtube-caption-dot[data-tone="working"] { background: var(--color-brand); }
.youtube-caption-dot[data-tone="ok"] { background: var(--color-success); }
.youtube-caption-dot[data-tone="warn"] { background: var(--color-warning); }
.youtube-caption-dot[data-tone="error"] { background: var(--color-error); }
.youtube-caption-state { display: grid; grid-template-columns: 8px minmax(0, 1fr); column-gap: 8px; align-items: start; }
.youtube-caption-state > .youtube-caption-dot { margin-top: calc(.75em - 4px); }
.youtube-caption-status { grid-column: 2; font-size: 13px; font-weight: 500; color: var(--color-text-primary); font-variant-numeric: tabular-nums; }
.youtube-caption-state[data-tone="idle"] .youtube-caption-status { font-weight: 400; color: var(--color-text-secondary); }
.youtube-caption-confirmed { grid-column: 2; font-size: 12px; color: var(--color-text-secondary); font-variant-numeric: tabular-nums; }

/* The one failure TransLive cannot detect: ask the organizer to look once. */
.youtube-caption-viewer {
    display: grid; gap: 6px; padding: 10px 12px; border-radius: var(--radius-xs);
    border: 1px solid rgba(var(--warning-rgb), .45); background: rgba(var(--warning-rgb), .1);
}
.youtube-caption-viewer-title { font-size: 13px; font-weight: 600; color: var(--color-text-primary); }
.youtube-caption-viewer-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.youtube-caption-viewer-actions .btn { margin: 0; font-family: inherit; }
.youtube-caption-verified { font-size: 12px; color: var(--color-success); }

.youtube-caption-note { font-size: 12px; color: var(--color-text-secondary); font-variant-numeric: tabular-nums; }
.youtube-caption-notice { padding: 8px 12px; border: 1px solid; border-radius: var(--radius-xs); font-size: 13px; color: var(--color-text-primary); }
.youtube-caption-degraded { background: rgba(var(--warning-rgb), .1); border-color: rgba(var(--warning-rgb), .35); }
.youtube-caption-error { background: rgba(var(--error-rgb), .08); border-color: rgba(var(--error-rgb), .3); }

/* Setup steps: same chevron language as the other sections, not a native triangle. */
.youtube-caption-guide-toggle {
    display: inline-flex; align-items: center; gap: 4px; justify-self: start; padding: 2px 0;
    border: 0; background: none; color: var(--color-text-secondary); font: inherit; font-size: 12px; cursor: pointer;
}
.youtube-caption-guide-toggle svg { width: 14px; height: 14px; transition: transform var(--transition-normal) ease; }
.youtube-caption-guide-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.youtube-caption-guide-toggle:hover { color: var(--color-text-primary); }
.youtube-caption-guide { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 12px; line-height: 1.5; color: var(--color-text-secondary); }

/* Fields draw their own focus (above); everything else gets the page's focus ring. */
.youtube-caption-panel :focus-visible:not(input):not(.cs-trigger), .youtube-caption-chip:focus-visible {
    outline: 2px solid var(--input-focus-border); outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .youtube-caption-chip[data-state="unverified"] .youtube-caption-chip-dot,
    .youtube-caption-primary[data-role="confirmStop"] { animation: none; }
    .youtube-caption-guide-toggle svg { transition: none; }
}
