/*
 * 2videos components. Load after tokens.css and before the page stylesheet:
 *   tokens.css → components.css → page.css (page CSS only adds layout + one-offs)
 *
 * Everything here is built from tokens (colour, spacing, radii, control heights),
 * so a change in tokens.css restyles every page consistently. The brand page
 * (/brand/#components) shows each component in all its states.
 */

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
img, svg, video, canvas { max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.icon { flex: none; }
.with-icon { display: inline-flex; align-items: center; gap: 0.4em; }

/* ---------------------------------------------------------------- layout */
.container { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: var(--space-4); }
.stack { display: flex; flex-direction: column; gap: var(--stack-gap, var(--space-3)); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster-gap, var(--space-2)); }
.split { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.grid-auto { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(var(--grid-min, 240px), 1fr)); }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--color-line); border: 0; margin: var(--space-4) 0; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control-md); padding: 0 var(--space-4);
  border: 1px solid var(--color-line); border-radius: var(--radius-md);
  background: var(--color-surface-2); color: var(--color-text);
  font: inherit; font-size: var(--text-base); font-weight: var(--weight-semibold); line-height: 1.2;
  text-decoration: none; white-space: nowrap; cursor: pointer; user-select: none;
  transition: background var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease);
}
.btn:hover { border-color: var(--color-line-strong); background: #2a2a36; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled=true] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-on-accent); }
.btn.primary:hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--color-surface-2); }
.btn.good { background: rgba(74, 222, 128, 0.14); border-color: rgba(74, 222, 128, 0.45); color: var(--color-good); }
.btn.bad, .btn.danger { background: transparent; border-color: rgba(248, 113, 113, 0.5); color: var(--color-bad); }
.btn.bad:hover, .btn.danger:hover { background: rgba(248, 113, 113, 0.12); }
.btn.small { min-height: var(--control-sm); padding: 0 var(--space-3); font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn.big, .btn.lg { min-height: var(--control-lg); padding: 0 var(--space-5); font-size: var(--text-md); }
.btn.block { width: 100%; }
.btn.icon-only { padding: 0; width: var(--control-md); }
.btn.icon-only.small { width: var(--control-sm); }

/* ---------------------------------------------------------------- form fields */
:where(input:not([type=checkbox], [type=radio], [type=range], [type=file], [type=color]), select, textarea) {
  font: inherit; color: var(--color-text);
  background: var(--color-surface-sunken); border: 1px solid var(--color-line); border-radius: var(--radius-md);
  min-height: var(--control-md); padding: var(--space-2) var(--space-3);
  transition: border-color var(--duration-fast) var(--ease);
}
:where(textarea) { min-height: 80px; resize: vertical; }
:where(input, select, textarea):hover { border-color: var(--color-line-strong); }
:where(input, select, textarea):focus-visible { border-color: var(--color-accent); box-shadow: 0 0 0 3px rgba(255, 61, 127, 0.25); }
:where(input, select, textarea)[aria-invalid=true] { border-color: var(--color-bad); }
:where(input, select, textarea)::placeholder { color: #6e6e80; }
:where(input[type=checkbox], input[type=radio], input[type=range]) { accent-color: var(--color-accent); }
.field { display: grid; gap: var(--space-1); min-width: 0; align-content: start; }
.field > label, .field-label { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--color-text-2); }
.field-hint { font-size: var(--text-xs); color: var(--color-muted); }
.field-error { font-size: var(--text-xs); color: var(--color-bad); }
.check { display: flex; align-items: flex-start; gap: var(--space-2); font-size: var(--text-sm); cursor: pointer; }
.check input { margin-top: 3px; }

/* switch: <label class="switch-row"><span class="switch"><input type="checkbox"><span></span></span> Label</label> */
.switch-row { display: flex; align-items: center; gap: var(--space-3); cursor: pointer; }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: var(--radius-full); background: #3a3a48; transition: background var(--duration) var(--ease); cursor: pointer; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--duration) var(--ease); }
.switch input:checked + span { background: var(--color-good); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: var(--focus-ring); }
.switch input:disabled + span { opacity: 0.5; cursor: not-allowed; }

/* inline status line under a form: <p class="form-msg ok">Saved.</p> */
.form-msg { font-size: var(--text-sm); color: var(--color-muted); min-height: 1.3em; }
.form-msg.ok { color: var(--color-good); }
.form-msg.error { color: var(--color-bad); }

/* ---------------------------------------------------------------- surfaces */
.card, .panel { background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius-lg); padding: var(--space-4); min-width: 0; }
.card-head, .panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.card-head h2, .panel-head h2 { margin: 0; font-size: var(--text-lg); }
.card-sub { color: var(--color-muted); font-size: var(--text-sm); margin: 0; }
.section-label { margin: var(--space-5) 0 var(--space-2); font-family: var(--font-ui); font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--color-muted); text-transform: uppercase; letter-spacing: var(--tracking-caps); }

/* ---------------------------------------------------------------- pills, badges, tags */
.pill { display: inline-flex; align-items: center; gap: var(--space-1); padding: 2px var(--space-2); border: 1px solid transparent; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: var(--weight-semibold); line-height: 1.5; white-space: nowrap; }
.pill.good { color: var(--color-good); background: rgba(74, 222, 128, 0.1); border-color: rgba(74, 222, 128, 0.35); }
.pill.warn { color: var(--color-warn); background: rgba(251, 191, 36, 0.1); border-color: rgba(251, 191, 36, 0.35); }
.pill.bad { color: var(--color-bad); background: rgba(248, 113, 113, 0.1); border-color: rgba(248, 113, 113, 0.35); }
.pill.info { color: var(--color-info); background: rgba(96, 165, 250, 0.1); border-color: rgba(96, 165, 250, 0.35); }
.pill.neutral { color: var(--color-text-2); background: var(--color-surface-2); border-color: var(--color-line); }
.pill.live { color: #fff; background: var(--color-live); font-weight: var(--weight-bold); letter-spacing: 0.04em; }
.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 6px; border-radius: var(--radius-full); background: var(--color-line); color: var(--color-text-2); font-size: var(--text-2xs); font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; }
.badge:empty { display: none; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-live); animation: live-pulse 1.4s infinite; flex: none; }
@keyframes live-pulse { 50% { opacity: 0.3; } }

/* ---------------------------------------------------------------- tabs */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--color-line); }
.tabs [role=tab] { display: inline-flex; align-items: center; gap: var(--space-1); background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: var(--space-2) var(--space-3); font: inherit; font-weight: var(--weight-semibold); color: var(--color-muted); cursor: pointer; }
.tabs [role=tab]:hover { color: var(--color-text-2); }
.tabs [role=tab][aria-selected=true] { color: var(--color-text); border-bottom-color: var(--color-accent); }

/* ---------------------------------------------------------------- notices */
.notice { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border: 1px solid var(--color-line); border-radius: var(--radius-md); background: var(--color-surface-2); color: var(--color-text-2); font-size: var(--text-sm); }
.notice > .icon { margin-top: 2px; }
.notice.info { border-color: rgba(96, 165, 250, 0.35); background: rgba(96, 165, 250, 0.08); }
.notice.info > .icon { color: var(--color-info); }
.notice.warn { border-color: rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.08); }
.notice.warn > .icon { color: var(--color-warn); }
.notice.bad { border-color: rgba(248, 113, 113, 0.4); background: rgba(248, 113, 113, 0.08); }
.notice.bad > .icon { color: var(--color-bad); }
.notice.good { border-color: rgba(74, 222, 128, 0.35); background: rgba(74, 222, 128, 0.08); }
.notice.good > .icon { color: var(--color-good); }

/* ---------------------------------------------------------------- data */
.stat { display: grid; gap: 2px; }
.stat-label { font-size: var(--text-xs); color: var(--color-muted); text-transform: uppercase; letter-spacing: var(--tracking-caps); font-weight: var(--weight-semibold); }
.stat-value { font-family: var(--font-display); font-size: var(--text-xl); font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; letter-spacing: var(--tracking-tight); }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.data-table th { text-align: left; font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--color-muted); text-transform: uppercase; letter-spacing: var(--tracking-caps); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-line); }
.data-table td { padding: var(--space-3); border-bottom: 1px solid var(--color-line); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--brand-gradient); color: #fff; font-family: var(--font-display); font-weight: var(--weight-bold); flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------------------------------------------------------------- states */
.empty-state { display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-10) var(--space-4); text-align: center; color: var(--color-muted); border: 1px dashed var(--color-line); border-radius: var(--radius-lg); }
.empty-state .icon { color: var(--color-accent); }
.empty-state strong { color: var(--color-text); font-size: var(--text-md); }
.skeleton { background: linear-gradient(90deg, var(--color-surface-2) 25%, #2b2b37 50%, var(--color-surface-2) 75%); background-size: 200% 100%; border-radius: var(--radius-sm); animation: skeleton 1.4s ease-in-out infinite; }
@keyframes skeleton { from { background-position: 200% 0; } to { background-position: -200% 0; } }
