/* Design tokens — the single source of colour, type and shape. See DESIGN.md. */

:root {
  --surface: #faf9f7;
  --surface-raised: #ffffff;
  --surface-sunken: #f1efeb;
  --border: #e3dfd8;
  --border-strong: #cbc4b8;
  --text: #1c1a17;
  --text-muted: #6b655c;
  --text-faint: #9a938a;
  --accent: #b45309;
  --accent-soft: #fdf1e3;
  --accent-contrast: #ffffff;
  --ok: #15803d;
  --ok-soft: #eaf6ee;
  --warn: #b45309;
  --danger: #b91c1c;
  --danger-soft: #fdeceb;

  --speaker-1: #b45309;
  --speaker-2: #1d4ed8;
  --speaker-3: #15803d;
  --speaker-4: #7c3aed;
  --speaker-5: #be123c;
  --speaker-6: #0e7490;
  --speaker-7: #a16207;
  --speaker-8: #4d7c0f;

  --shadow-card: 0 1px 2px rgb(28 26 23 / 0.05), 0 4px 16px rgb(28 26 23 / 0.05);
  --radius-control: 6px;
  --radius-card: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --surface: #12110f;
    --surface-raised: #1c1a17;
    --surface-sunken: #0b0a09;
    --border: #2e2a25;
    --border-strong: #433d35;
    --text: #f2efe9;
    --text-muted: #9c948a;
    --text-faint: #6b645b;
    --accent: #f59e0b;
    --accent-soft: #2a1f10;
    --accent-contrast: #1c1a17;
    --ok: #4ade80;
    --ok-soft: #10251a;
    --warn: #fbbf24;
    --danger: #f87171;
    --danger-soft: #2a1414;

    --speaker-1: #f59e0b;
    --speaker-2: #60a5fa;
    --speaker-3: #4ade80;
    --speaker-4: #c084fc;
    --speaker-5: #fb7185;
    --speaker-6: #22d3ee;
    --speaker-7: #fcd34d;
    --speaker-8: #a3e635;

    --shadow-card: 0 1px 2px rgb(0 0 0 / 0.4), 0 4px 16px rgb(0 0 0 / 0.3);
  }
}

* { box-sizing: border-box; }

/* Minimal reset. Tailwind's preflight is disabled so the tokens above stay authoritative. */
h1, h2, h3, p, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
audio { display: block; width: 100%; }
/* Replace the native disclosure triangle with a chevron that rotates on open. */
summary::-webkit-details-marker { display: none; }
summary::marker { content: ''; }
summary { position: relative; list-style: none; }
summary::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 50%;
  width: 5px;
  height: 5px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: translateY(-70%) rotate(-45deg);
  transition: transform 150ms ease-out;
}
details[open] > summary::before { transform: translateY(-50%) rotate(45deg); }

body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, 'Segoe UI', sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* Devanagari needs the extra leading — matras collide at 1.5. */
.transcript-type {
  font-family: 'Noto Sans', Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.75;
}

.tabular { font-variant-numeric: tabular-nums; }

.card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.field {
  width: 100%;
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  padding: 7px 10px;
  font: inherit;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
}

.field:focus-visible,
.focusable:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

select.field {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) center, calc(100% - 10px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  color: var(--text);
  border-radius: var(--radius-control);
  padding: 7px 12px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease-out, border-color 150ms ease-out, opacity 150ms ease-out;
}

.btn:hover:not(:disabled) { background: var(--surface-sunken); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 86%, black); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Progress: width-only animation, so it stays cheap on long-running jobs. */
.track {
  height: 4px;
  border-radius: 999px;
  background: var(--surface-sunken);
  overflow: hidden;
}
.track > i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 300ms ease-out;
}

/* Indeterminate: speaker detection has no progress callback, so we show motion, not a number. */
.track.indeterminate > i {
  width: 35% !important;
  animation: slide 1.4s ease-in-out infinite;
}
@keyframes slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(320%); }
}

.segment {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 12px;
  padding: 7px 10px;
  border-radius: var(--radius-control);
  cursor: pointer;
  scroll-margin: 96px;
  transition: background 150ms ease-out;
}
.segment:hover { background: var(--surface-sunken); }
.segment[data-active='true'] { background: var(--accent-soft); }

/* Chapter headers stay put while their own section scrolls, so the timecode you are
   reading under is always visible in a long transcript. */
.chapter > summary {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-sunken);
  transition: background 150ms ease-out;
}
.chapter > summary:hover { background: var(--border); }
.chapter[open] > summary { border-bottom: 1px solid var(--border); }

/* Below the two-column breakpoint the transcript is not height-bounded, so let the page own the
   scrolling. An `overflow: auto` pane would otherwise become the sticky scrollport without ever
   scrolling, which stops the headers pinning at all. Offset them by the app bar instead. */
@media (max-width: 1023px) {
  #segments,
  #summary-panel { overflow: visible; }
  .chapter > summary { top: 56px; }
}

.segment mark {
  background: color-mix(in srgb, var(--accent) 30%, transparent);
  color: inherit;
  border-radius: 2px;
}

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-card);
  transition: border-color 150ms ease-out, background 150ms ease-out;
}
.dropzone[data-over='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.scroll-area { overflow-y: auto; overscroll-behavior: contain; }
.scroll-area::-webkit-scrollbar { width: 10px; }
.scroll-area::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 3px solid var(--surface);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
