/* OpenCaptions UI components. Colours, type and motion come from tokens.css (light + dark). */
@import url('/tokens.css');

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
body { font-size: 16px; line-height: 1.5; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 800; letter-spacing: -.02em; line-height: 1.12; }
h1 { letter-spacing: -.03em; }
a { color: inherit; text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
code { font-family: var(--mono); font-size: .9em; background: var(--bg3); padding: .1em .35em; border-radius: 6px; }
pre code { background: none; color: inherit; padding: 0; border-radius: 0; font-size: inherit; }
::selection { background: var(--hl); color: var(--hl-ink); }
button, select, input, textarea { font: inherit; color: inherit; }
button {
  background: var(--bg2); border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px 14px; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
button:hover { background: color-mix(in srgb, var(--bg3) 55%, var(--bg2)); border-color: color-mix(in srgb, var(--fg) 28%, var(--line-strong)); }
button:active { transform: translateY(1px); box-shadow: none; }
button.primary { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-fg); font-weight: 700; }
button.primary:hover { background: color-mix(in srgb, var(--primary-bg) 88%, var(--fg)); border-color: color-mix(in srgb, var(--primary-bg) 88%, var(--fg)); }
button.danger { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); color: var(--bad); }
button:disabled { opacity: .5; cursor: default; transform: none; }
select, input, textarea {
  background: var(--bg2); border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px 10px; min-width: 0;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
select {
  -webkit-appearance: none; appearance: none; cursor: pointer; padding-right: 34px; text-overflow: ellipsis;
  background-image: var(--chevron); background-repeat: no-repeat; background-position: right 12px center; background-size: 11px 8px;
}
select::-ms-expand { display: none; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--fg2) 75%, transparent); }
input[type='checkbox'], input[type='radio'], input[type='range'] { accent-color: var(--fg); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--fg2); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: var(--pill);
  border: 1px solid var(--line-strong); background: var(--bg2); cursor: pointer; font-size: 14px; white-space: nowrap; box-shadow: none;
}
.pill[aria-pressed='true'] { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-fg); font-weight: 700; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 9px; border-radius: var(--pill); background: var(--bg3); border: 1px solid transparent; line-height: 1.5; }
.chip.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 11%, var(--bg2)); border-color: color-mix(in srgb, var(--ok) 28%, transparent); }
.chip.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 11%, var(--bg2)); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.chip.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--bg2)); border-color: color-mix(in srgb, var(--bad) 28%, transparent); font-weight: 700; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fg2); display: inline-block; flex: none; }
.dot.live { background: var(--bad); box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 60%, transparent); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 55%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: var(--shadow-sm); }
a.card { transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease); }
a.card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.meter { height: 8px; background: var(--bg3); border-radius: 4px; overflow: hidden; position: relative; }
.meter > i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--ok), var(--ok) 70%, var(--warn) 85%, var(--bad)); width: 0; transition: width .12s linear; border-radius: 4px; }
.meter > b { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--fg); opacity: .7; transition: left .3s; }

/* ---- logo + wordmark ---- */
.brand { font-family: var(--font-display); font-weight: 800; letter-spacing: -.025em; display: inline-flex; align-items: center; gap: .4em; white-space: nowrap; }
a.brand { color: inherit; text-decoration: none; }
.brand::before { print-color-adjust: exact; -webkit-print-color-adjust: exact; content: ''; display: inline-block; flex: none; width: 1.55em; height: 1.17em; background: var(--logo) center / contain no-repeat; }
.brand .sub { font-family: var(--font); font-weight: 400; letter-spacing: 0; color: var(--fg2); }
/* Inline logo (<svg class="oc-logo" viewBox="0 0 878 664"><use class="o" …/><use class="ln" …/></svg>), coloured per theme. */
.oc-logo { display: block; overflow: visible; }
.oc-logo .o { fill: var(--logo-o); }
.oc-logo .ln { fill: var(--logo-line); }
/* Signature motion: the caption line "types" out of the O. */
.oc-logo.typing .ln { transform-box: fill-box; transform-origin: 0 50%; animation: oc-type 2.6s steps(6, end) infinite; }
@keyframes oc-type { 0% { transform: scaleX(0); } 45%, 80% { transform: scaleX(1); } 100% { transform: scaleX(0); } }
.oc-logo.typed .ln { transform-box: fill-box; transform-origin: 0 50%; animation: oc-type-once .9s steps(6, end) .2s both; }
@keyframes oc-type-once { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---- signature motion: highlighter sweep on the live word ----
   The lime (::before) and an ink copy of the word (::after) are revealed together, left to right, so the word is
   always ink on lime or plain text on the page — never light text on lime. Final state is the resting style. */
.live-word { position: relative; z-index: 0; white-space: nowrap; }
.live-word::before, .live-word::after { position: absolute; top: 0; bottom: 0; left: -.1em; right: -.1em; padding: 0 .1em; border-radius: .18em; clip-path: inset(0 0 0 0 round .18em); animation: oc-sweep var(--sweep) var(--ease) both; }
.live-word::before { content: ''; z-index: -1; background: var(--hl); top: .04em; bottom: .02em; }
.live-word::after { content: attr(data-w); content: attr(data-w) / ''; color: var(--hl-ink); line-height: normal; white-space: nowrap; }
@keyframes oc-sweep { from { clip-path: inset(0 100% 0 0 round .18em); } }
.translation { color: var(--translation); }

.hidden { display: none !important; }
dialog { background: var(--bg2); color: var(--fg); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; max-width: min(640px, 92vw); width: 100%; box-shadow: var(--shadow-lg); }
dialog::backdrop { background: var(--scrim); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
dialog h3 { font-size: 20px; }
label.field { display: grid; gap: 5px; font-size: 13px; color: var(--fg2); }
label.field > * { color: var(--fg); }
.prefs { gap: 6px; flex-wrap: nowrap; }
.prefs select { padding: 5px 28px 5px 10px; font-size: 13px; background-position: right 10px center; border-radius: 9px; }
.prefs button { padding: 5px 10px; border-radius: 9px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 18px; border-radius: 12px; z-index: 50; box-shadow: var(--shadow-lg); font-weight: 700; animation: oc-rise .24s var(--ease); }
@keyframes oc-rise { from { opacity: 0; transform: translate(-50%, 8px); } }
.empty-state { display: grid; justify-items: center; gap: 14px; text-align: center; color: var(--fg2); }
.empty-state .oc-logo { width: 64px; }

/* ---------- audience: sheets, assistant, reading ---------- */
dialog.sheet { margin: auto auto 0; width: 100%; max-width: 720px; max-height: 88dvh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 10px 20px calc(20px + env(safe-area-inset-bottom)); overflow: auto; border-bottom: 0; }
dialog.sheet::before { content: ''; display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: 0 auto 12px; }
dialog.sheet[open] { animation: oc-sheet .28s var(--ease); }
@keyframes oc-sheet { from { transform: translateY(24px); opacity: .4; } }
dialog.sheet .sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
dialog.sheet .sheet-head h2 { font-size: 21px; margin: 0; flex: 1; }
dialog.sheet .sheet-head button { border-radius: var(--pill); width: 36px; height: 36px; padding: 0; box-shadow: none; border: 0; background: var(--bg3); }
.seg { display: inline-flex; background: var(--bg3); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; font-size: 14px; box-shadow: none; }
.seg button[aria-pressed='true'] { background: var(--bg2); box-shadow: var(--shadow-sm); font-weight: 700; }
.as-sum { margin: 14px 0 6px; min-height: 60px; }
.as-sum h3 { font-size: 19px; margin: 0 0 8px; line-height: 1.3; }
.as-sum ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 16px; line-height: 1.5; }
.as-terms { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.as-note { font-size: 12px; color: var(--fg2); margin-top: 10px; }
.as-ask { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.as-ask label { font-weight: 700; display: block; margin-bottom: 8px; }
.as-ask .row { flex-wrap: nowrap; }
.as-ask input { flex: 1; font-size: 16px; min-width: 0; width: 100%; }
.as-ans { margin-top: 12px; font-size: 16px; line-height: 1.55; }
.as-ans blockquote { margin: 8px 0 0; padding: 8px 12px; border-left: 3px solid var(--fg); background: var(--bg3); border-radius: 0 10px 10px 0; font-size: 15px; }
.as-ans blockquote b { font-family: var(--mono); font-size: 12px; color: var(--fg2); margin-right: 6px; }
.skeleton { background: linear-gradient(90deg, var(--bg3), var(--bg2), var(--bg3)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; height: 14px; margin: 8px 0; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.set-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
mark { background: var(--hl); color: var(--hl-ink); border-radius: 3px; padding: 0 2px; }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
svg.i { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
button:has(> svg.i), .btn-i { display: inline-flex; align-items: center; gap: 7px; }

/* search fields with a magnifier (the icon is a CSS mask, so it follows the text colour) */
.has-icon { position: relative; display: block; }
.has-icon::before { content: ''; position: absolute; left: 15px; top: 50%; width: 18px; height: 18px; translate: 0 -50%; pointer-events: none; z-index: 1; background: var(--fg2);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='M16 16l4.5 4.5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='M16 16l4.5 4.5'/%3E%3C/svg%3E") center / contain no-repeat; }
.has-icon > input { padding-left: 42px; width: 100%; box-sizing: border-box; }

/* ---- connect panels (public/connect.js): API key and public address, in the wizard and Settings ---- */
.connect { display: grid; gap: 12px; font-size: 15px; }
.connect p { margin: 0; }
.connect .cx-status { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; }
.connect .cx-status svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.connect .cx-status.ok svg { color: var(--ok); }
.connect .cx-status.warn svg { color: var(--warn); }
.connect .cx-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.connect .cx-row input { flex: 1 1 220px; min-width: 0; font-size: 15px; }
.connect .cx-row button svg { width: 17px; height: 17px; margin-right: 6px; vertical-align: -3px; }
.connect .cx-steps { margin: 0; padding-left: 20px; display: grid; gap: 10px; }
.connect .cx-steps .cx-row { margin-top: 8px; }
.connect .cx-fine { font-size: 13px; color: var(--fg2); }
.connect .cx-msg { font-size: 14px; padding: 10px 12px; border-radius: 12px; background: var(--bg3); }
.connect .cx-msg.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--bg2)); }
.connect .cx-msg.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--bg2)); }
.connect .cx-msg.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 9%, var(--bg2)); }
.connect .cx-link { background: none; border: 0; box-shadow: none; padding: 4px 2px; color: var(--fg2); text-decoration: underline; text-underline-offset: 3px; }
.connect .cx-link:hover { background: none; color: var(--fg); }
.connect .cx-url { font-size: 17px; font-weight: 700; overflow-wrap: anywhere; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); }
.connect .cx-url a { color: inherit; }
.connect .cx-own summary { cursor: pointer; font-size: 14px; color: var(--fg2); }
.connect .cx-own[open] summary { margin-bottom: 10px; }
.connect .cx-grid { display: grid; gap: 10px; }

/* Settings → Access (public/access.js) */
.access h4 { margin: 10px 0 0; font-size: 15px; }
.access h4:first-child { margin-top: 0; }
.access .ax-list { display: grid; gap: 8px; }
.access .ax-row { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); }
.access .ax-row svg { width: 18px; height: 18px; }
.access .ax-row span { display: grid; min-width: 0; }
.access .ax-row b { overflow-wrap: anywhere; }
.access .ax-row small { color: var(--fg2); font-size: 13px; }
.access .ax-secret { font-size: 15px; padding: 6px 10px; overflow-wrap: anywhere; user-select: all; }
.access .ax-tfa { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 16px; align-items: start; }
.access .ax-qr { background: #fff; border-radius: 12px; padding: 8px; }
.access .ax-qr svg { display: block; width: 100%; height: auto; }
@media (max-width: 600px) { .access .ax-tfa { grid-template-columns: minmax(0, 1fr); } .access .ax-qr { max-width: 200px; } }
dialog.signin button.sso { width: 100%; justify-content: center; }

/* Small utilities, in place of style="" attributes (the Content-Security-Policy allows no inline styles). They win
   over component rules, as the attributes they replace did. */
.u-m0 { margin: 0 !important; }
.u-mt0 { margin-top: 0 !important; }
.u-mt6 { margin-top: 6px !important; }
.u-mt8 { margin-top: 8px !important; }
.u-mt10 { margin-top: 10px !important; }
.u-mt12 { margin-top: 12px !important; }
.u-mt14 { margin-top: 14px !important; }
.u-m6t { margin: 6px 0 0 !important; }
.u-m14t { margin: 14px 0 0 !important; }
.u-mb14 { margin: 0 0 14px !important; }
.u-h17 { margin: 0 0 4px !important; font-size: 17px !important; }
.u-fs12 { font-size: 12px !important; }
.u-fs13 { font-size: 13px !important; }
.u-fs14 { font-size: 14px !important; }
.u-fs16 { font-size: 16px !important; }
.u-fs17 { font-size: 17px !important; }
.u-fs20 { font-size: 20px !important; }
.u-stack8 { display: grid !important; gap: 8px !important; }
.u-stack12 { display: grid !important; gap: 12px !important; }
.u-stack14 { display: grid !important; gap: 14px !important; }
.u-gap14 { gap: 14px !important; }
.u-start { align-content: start !important; }
.u-stretch { align-items: stretch !important; }
.u-between { justify-content: space-between !important; }
.u-grow { flex: 1 !important; }
.u-grow2 { flex: 2 !important; }
.u-flex260 { flex: 1 1 260px !important; }
.u-flex320 { flex: 1 1 320px !important; min-width: 0 !important; }
.u-minw0 { min-width: 0 !important; }
.u-minw200 { min-width: 200px !important; }
.u-minw220 { min-width: 220px !important; }
.u-w70 { width: 70% !important; }
.u-w85 { width: 85% !important; }
.u-w120 { width: 120px !important; }
.u-h10 { height: 10px !important; }
.u-left0 { left: 0; }
.u-num { min-width: 3ch !important; text-align: center !important; }
.u-center { text-align: center !important; }
.u-left { text-align: left !important; }
.u-right { text-align: right !important; }
.u-fg2 { color: var(--fg2) !important; }
.u-bad { color: var(--bad) !important; }
.u-noscript { color: #fff; padding: 20px; }
.u-btn-sm { padding: 3px 12px !important; font-size: 13px !important; box-shadow: none !important; }
.u-danger-outline { border-color: color-mix(in srgb, var(--bad) 50%, var(--line)) !important; color: var(--bad) !important; }
.u-fixed-bottom { position: fixed !important; bottom: 20px; left: 50%; transform: translateX(-50%); }
.u-help-list { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 6px; }
.u-code-input { font-size: 24px !important; letter-spacing: .2em; }
.u-bg-setup { background-image: url(/art/setup.webp) !important; }

/* Settings → Alerts (public/alerts-ui.js) */
.alerts .al-ch { border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); }
.alerts .al-ch summary { display: grid; gap: 2px; padding: 10px 12px; cursor: pointer; list-style: none; }
.alerts .al-ch summary::-webkit-details-marker { display: none; }
.alerts .al-ch summary label { display: flex; gap: 8px; align-items: center; }
.alerts .al-ch summary small { color: var(--fg2); font-size: 13px; padding-left: 26px; }
.alerts .al-body { display: grid; gap: 10px; padding: 0 12px 12px; }
.alerts .cx-row button svg { width: 16px; height: 16px; margin: 0; }

/* Speaker labels (set on the dashboard): a small name where the speaker changes */
p[data-spk]::before { content: attr(data-spk); display: block; margin-bottom: .15em; font-family: var(--font); font-size: max(12px, .5em); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--fg2); }
.para .spk { display: block; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--fg2); margin-bottom: 2px; }

/* Text for screen readers only (a page's heading where the design shows none) */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
