/* styles.css -- design tokens and look follow StatLab
   (github.com/PeterSlijkhuis/StatLab, src/App.css): indigo-to-sky gradient,
   pill buttons, soft cards. Tune the look here, in the tokens. */
:root {
  color-scheme: light;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #56627a;
  --line: #e4e7ef;
  --line-strong: #cbd2df;

  --brand: #4f46e5;
  --brand-2: #2563eb;
  --brand-soft: #eef0ff;
  --brand-ink: #3730a3;
  --brand-line: #c7d2fe;
  --on-brand: #fff;
  --gradient: linear-gradient(135deg, #6366f1 0%, #2563eb 55%, #0ea5e9 100%);

  --success: #16a34a;
  --success-line: #86efac;
  --warn: #d97706;
  --warn-ink: #92400e;
  --warn-line: #fcd34d;
  --warn-tint: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --danger-ink: #991b1b;
  --danger-line: #fca5a5;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 14px rgba(15, 23, 42, 0.07), 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 18px 40px rgba(30, 41, 99, 0.16);
  --speaker-l: 45%;

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --fast: 150ms;
  --medium: 260ms;
}
/* Dark tokens apply via data-theme, set by the inline script in index.html
   from the Settings choice (or the OS preference when it's "system"). */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1120;
  --surface: #131a2a;
  --surface-2: #1c2436;
  --ink: #e7ebf3;
  --ink-2: #c5ccda;
  --muted: #98a3b8;
  --line: #273149;
  --line-strong: #36425e;

  --brand: #8b93f8;
  --brand-2: #6cb0fb;
  --brand-soft: #232a52;
  --brand-ink: #c7d2fe;
  --brand-line: #3e4787;
  --on-brand: #0b1120;

  --success-line: #1f6b3d;
  --warn-ink: #fcd34d;
  --warn-line: #7a5a12;
  --warn-tint: #241b08;
  --danger-soft: #3a1515;
  --danger-ink: #fca5a5;
  --danger-line: #7f2a2a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.55);
  --speaker-l: 68%;
}

* {
  box-sizing: border-box;
}
/* A class rule that sets its own `display` (.job-exports, .job-speakers,
   ...) otherwise beats the `hidden` attribute's UA-stylesheet `display:
   none` in the cascade -- same specificity, author styles win. This kept
   download buttons visible on jobs that weren't done yet. */
[hidden] {
  display: none !important;
}
body {
  max-width: 820px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}
::selection {
  background: var(--brand-line);
}

/* ---- Header ------------------------------------------------------------ */
.hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 1.75rem;
  padding: 2rem 2.25rem;
  border-radius: var(--radius-lg);
  color: #fff;
  background: var(--gradient);
  box-shadow: var(--shadow-lg);
}
.hero::after {
  content: "";
  position: absolute;
  inset: auto -10% -60% auto;
  width: 26rem;
  height: 26rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.22), transparent 65%);
  pointer-events: none;
  animation: drift 14s ease-in-out infinite alternate;
}
@keyframes drift {
  to {
    transform: translate(-3rem, -2rem) scale(1.1);
  }
}
.hero-eyebrow {
  display: inline-flex;
  margin: 0;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 0.8rem;
  font-weight: 650;
}
.hero h1 {
  margin: 0.4rem 0 0.4rem;
  font-size: clamp(2rem, 1.5rem + 2.5vw, 2.8rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.subtitle {
  margin: 0;
  max-width: 36rem;
  color: rgba(255, 255, 255, 0.88);
}
.privacy-badge {
  position: relative;
  z-index: 1;
  display: inline-block;
  margin: 1.1rem 0 0;
  padding: 0.55rem 0.9rem;
  max-width: 36rem;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 0.85rem;
  font-weight: 550;
}

/* ---- Banners ------------------------------------------------------------ */
.banner {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  margin: 1rem 0;
  border: 1px solid;
}
.banner-error {
  background: var(--danger-soft);
  color: var(--danger-ink);
  border-color: var(--danger-line);
}
.banner-info {
  background: var(--brand-soft);
  color: var(--brand-ink);
  border-color: var(--brand-line);
}
.banner progress {
  width: 100%;
  margin-top: 0.6rem;
}

/* Progress bars as StatLab's slim gradient meters. */
progress {
  appearance: none;
  height: 6px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
progress::-webkit-progress-bar {
  background: var(--surface-2);
  border-radius: 999px;
}
progress::-webkit-progress-value {
  background: var(--gradient);
  border-radius: 999px;
  transition: width 0.2s ease;
}
progress::-moz-progress-bar {
  background: var(--gradient);
  border-radius: 999px;
}

/* ---- Step panels ------------------------------------------------------- */
.panel,
#queue-section {
  position: relative;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.35rem;
  margin: 1.5rem 0;
}
/* A connecting line down the left edge, behind each step's number badge,
   so the three panels read as one sequence rather than three cards. */
.panel::before,
#queue-section::before {
  content: "";
  position: absolute;
  left: 2.4rem;
  top: -1.5rem;
  width: 2px;
  height: 1.5rem;
  background: var(--line);
}
.panel:first-of-type::before {
  content: none;
}
.step-heading {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  margin: 0 0 0.15rem;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: 1.2rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.step-heading:hover {
  color: var(--brand);
}
.step-heading .chevron {
  margin-left: auto;
  color: var(--muted);
  transition: transform var(--medium) var(--ease);
}
.step-heading[aria-expanded="false"] .chevron {
  transform: rotate(-90deg);
}
.step-heading[aria-expanded="false"] {
  margin-bottom: 0;
}
#waiting-game {
  margin-bottom: 0.75rem;
}
#flappy-canvas {
  display: block;
  margin-top: 0.5rem;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.step-num {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0;
}
#queue-section {
  margin: 1.5rem 0 0;
}
#queue-section .step-heading {
  margin-bottom: 0.75rem;
  padding-left: 1.35rem;
}
.panel > .hint,
.dropzone + .hint {
  margin-top: 0.6rem;
}

/* Animated collapse: a grid row transitions between 1fr and 0fr, clipped by
   the single child's overflow -- no JS height measuring needed. `inert` (set
   in app.js alongside data-collapsed) keeps collapsed content out of the tab
   order, since a squashed grid row doesn't do that on its own. */
.panel-body,
.job-result {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows var(--medium) var(--ease);
}
.panel-body[data-collapsed],
.job-result[data-collapsed] {
  grid-template-rows: 0fr;
}
.collapsible-inner {
  overflow: hidden;
  min-height: 0;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1rem;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color var(--fast), background-color var(--fast), transform var(--fast) var(--ease);
}
.dropzone:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.dropzone:focus-within {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}
.dropzone.dragover {
  border-color: var(--brand);
  background: var(--brand-soft);
  transform: scale(1.015);
}
.dropzone-icon {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.35);
  transition: transform var(--fast) var(--ease);
}
.dropzone.dragover .dropzone-icon {
  transform: translateY(-3px);
}
.dropzone-text {
  color: var(--muted);
}
.dropzone-text strong {
  color: var(--ink);
}
#file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.field-wide {
  grid-column: span 2;
}
.field > label {
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--ink-2);
}
.field input[type="number"],
.field input[type="text"],
.field select {
  font: inherit;
  min-height: 2.6rem;
  padding: 0.45rem 0.75rem;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  transition: border-color var(--fast);
}
/* Windows Chrome/Edge draw the open dropdown list with the select's text
   color but their own light background, so dark-mode options came out
   light-on-white. Style the options explicitly. */
select option {
  background: var(--surface);
  color: var(--ink);
}
.field input:hover,
.field select:hover {
  border-color: var(--brand-line);
}
.field input:focus-visible,
.field select:focus-visible {
  outline: 3px solid var(--brand-line);
  outline-offset: 0;
  border-color: var(--brand);
}
.field-checkbox {
  justify-content: center;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 550;
  cursor: pointer;
}
input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--brand);
}
.hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---- Buttons: StatLab's pills ------------------------------------------- */
/* ---- Settings ------------------------------------------------------------ */
.settings-open {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 1;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 650;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
}
.settings-open:hover,
.settings-open:focus-visible {
  background: rgba(255, 255, 255, 0.28);
}
.settings-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid #fff;
}
.model-guide {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--ink-2);
}
.model-guide summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--brand-ink);
}
.model-guide table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.6rem 0;
}
.model-guide th,
.model-guide td {
  text-align: left;
  vertical-align: top;
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid var(--line);
}
.model-guide tbody th {
  font-weight: 600;
  color: var(--muted);
}
.settings-dialog {
  width: min(30rem, calc(100vw - 2rem));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
}
.settings-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}
.settings-dialog h2 {
  margin: 0 0 1rem;
  font-size: 1.2rem;
}
.settings-dialog form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.settings-actions {
  display: flex;
  justify-content: flex-end;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font: inherit;
  font-weight: 650;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.3);
  cursor: pointer;
  transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease), background var(--fast), border-color var(--fast);
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.4);
}
.btn:active {
  transform: translateY(0) scale(0.98);
}
.btn-sm {
  padding: 0.3rem 0.8rem;
  font-size: 0.85rem;
  box-shadow: 0 3px 10px rgba(79, 70, 229, 0.25);
}
.btn-ghost {
  background: var(--surface);
  color: var(--brand-ink);
  border-color: var(--line-strong);
  box-shadow: none;
}
.btn-ghost:hover {
  background: var(--brand-soft);
  border-color: var(--brand);
  box-shadow: none;
}

/* ---- Job list ------------------------------------------------------------- */
#job-list {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.job {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.15rem;
  transition: border-color var(--medium), box-shadow var(--medium), opacity 0.3s ease, transform 0.3s var(--ease);
}
.job:hover {
  box-shadow: var(--shadow);
}
/* A newly added job eases in instead of just appearing. */
@starting-style {
  .job {
    opacity: 0;
    transform: translateY(6px);
  }
}
.job[data-status="processing"],
.job[data-status="queued"] {
  border-left-color: var(--brand);
}
.job[data-status="done"] {
  border-color: var(--success-line);
  border-left-color: var(--success);
}
.job[data-status="error"] {
  border-color: var(--danger-line);
  border-left-color: var(--danger);
}
.job-name {
  font-weight: 700;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.job-status {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.15rem;
}
.job-progress {
  width: 100%;
  margin-top: 0.6rem;
}
.job-error {
  color: var(--danger-ink);
}
.job-retry {
  margin-top: 0.5rem;
}
.job-view-toggle {
  margin-top: 0.6rem;
}
.job-exports {
  margin: 0.7rem 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}
.job-exports-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin-right: 0.25rem;
}
.job-result {
  margin-top: 0.4rem;
}
.job-transcript {
  position: relative; /* offsetTop of lines is measured from here, for follow-along scrolling */
  max-height: 400px;
  overflow-y: auto;
  background: var(--surface-2);
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  scrollbar-width: thin;
}
.turn {
  margin: 0.45rem 0;
  color: var(--ink-2);
}
.turn-speaker {
  font-weight: 700;
  color: hsl(var(--hue), 60%, var(--speaker-l));
}
.turn-time {
  color: var(--muted);
  font: inherit;
  font-size: 0.82em;
  font-variant-numeric: tabular-nums;
  margin: 0 0.4rem;
  padding: 0 0.2rem;
  background: none;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}
.turn-time:hover,
.turn-time:focus-visible {
  color: var(--brand-ink);
  background: var(--brand-soft);
}
.turn.playing,
.edit-row.playing {
  background: var(--brand-soft);
  border-radius: 4px;
  outline: 2px solid var(--brand-line);
  outline-offset: 0.2rem;
}
.job-audio {
  display: block;
  width: 100%;
  margin: 0.6rem 0 0.2rem;
}
.job-find {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin: 0.5rem 0;
  font-size: 0.9rem;
}
.job-find input {
  width: 9rem;
  font: inherit;
  padding: 0.25rem 0.6rem;
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
}
.find-count,
.find-tip {
  color: var(--muted);
}
.find-tip {
  font-size: 0.82em;
  flex-basis: 100%;
}
.edit-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0.35rem 0;
  padding-left: 0.6rem;
  border-left: 3px solid hsl(var(--hue), 60%, var(--speaker-l));
}
.edit-row-speaker {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 650;
  color: hsl(var(--hue), 60%, var(--speaker-l));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0.2rem 0.35rem;
  flex: 0 0 auto;
  max-width: 8rem;
}
.edit-row-time {
  flex: 0 0 auto;
  margin-top: 0.3rem;
}
.edit-row-text {
  flex: 1 1 auto;
  font: inherit;
  resize: none;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  padding: 0.3rem 0.5rem;
}
.edit-row-text:focus-visible {
  outline: 3px solid var(--brand-line);
  outline-offset: 0;
  border-color: var(--brand);
}
.edit-row-tools {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 0 0 auto;
}
.edit-row-tools .btn {
  white-space: nowrap;
}
.job-warning {
  background: var(--warn-tint);
  color: var(--warn-ink);
  border: 1px solid var(--warn-line);
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  margin-top: 0.6rem;
}
.job-warning p {
  margin: 0 0 0.5rem;
}
.job-warning button {
  margin-right: 0.5rem;
}
.job-speakers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  margin: 0.6rem 0;
  font-size: 0.9rem;
}
.job-speakers label {
  color: hsl(var(--hue), 60%, var(--speaker-l));
  font-weight: 650;
}
.job-speakers input {
  width: 9rem;
  margin-left: 0.3rem;
  font: inherit;
  padding: 0.25rem 0.6rem;
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
}
.speaker-remove {
  margin-left: 0.3rem;
  padding: 0 0.5rem;
  font-weight: 700;
}
.speaker-remove:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
@media (max-width: 480px) {
  body {
    padding: 1rem 0.85rem 3rem;
  }
  .hero {
    padding: 3.5rem 1.25rem 1.5rem; /* room for the Settings button above the eyebrow */
  }
  .field-wide {
    grid-column: span 1;
  }
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
