/* ═══════════════════════════════════════════════════════
   Dictate.it  –  Stylesheet
   Theme: Warm editorial / academic paper
   Fonts: Playfair Display (display) + Lora (body) + DM Mono
   ═══════════════════════════════════════════════════════ */

/* ─── Design tokens ─────────────────────────────────── */
:root {
  --cream:       #f7f3ec;
  --cream-dark:  #ede7da;
  --cream-border:#d8cfc0;
  --ink:         #1a1612;
  --ink-light:   #4a4038;
  --ink-faint:   #8a7f72;
  --amber:       #d4860a;
  --amber-light: #f0a320;
  --amber-glow:  rgba(212, 134, 10, 0.15);
  --amber-glow2: rgba(212, 134, 10, 0.25);
  --highlight:   #ffe066;
  --highlight-bg:#fff8d6;
  --green:       #3a7d44;
  --red:         #b5372a;
  --white:       #ffffff;
  --shadow-sm:   0 2px 8px rgba(26,22,18,0.08);
  --shadow-md:   0 6px 24px rgba(26,22,18,0.12);
  --shadow-lg:   0 16px 48px rgba(26,22,18,0.16);
  --radius:      14px;
  --radius-sm:   8px;
  --radius-xs:   4px;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'Lora', Georgia, serif;
  --font-mono:    'DM Mono', 'Courier New', monospace;
  --transition:   0.22s cubic-bezier(0.4,0,0.2,1);
}

/* ─── Reset & base ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.65;
  background-image:
    radial-gradient(ellipse at 10% 0%, rgba(212,134,10,0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 90% 100%, rgba(212,134,10,0.05) 0%, transparent 55%);
}

/* subtle paper texture via pseudo */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ─── Header ────────────────────────────────────────── */
.site-header {
  background: var(--ink);
  color: var(--cream);
  padding: 1.75rem 2rem 1.6rem;
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow-md);
}

.header-inner {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.logo-icon { font-size: 1.75rem; }

.logo-text {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--cream);
  line-height: 1;
}

.logo-dot { color: var(--amber-light); }

.tagline {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.9rem;
  color: rgba(247,243,236,0.6);
  border-left: 2px solid var(--amber);
  padding-left: 1rem;
}

/* ─── Layout ────────────────────────────────────────── */
.app-container {
  max-width: 820px;
  margin: 2.5rem auto 4rem;
  padding: 0 1.25rem;
  position: relative;
  z-index: 1;
}

/* ─── Cards ─────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1.5px solid var(--cream-border);
  border-radius: var(--radius);
  padding: 2rem 2.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.card-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 1.4rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--cream-border);
}

/* ─── Drop zone ─────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--cream-border);
  border-radius: var(--radius-sm);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
  overflow: hidden;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drop-zone:hover,
.drop-zone:focus {
  border-color: var(--amber);
  background: var(--amber-glow);
  outline: none;
}

.drop-zone.drag-over {
  border-color: var(--amber-light);
  background: var(--amber-glow2);
  transform: scale(1.01);
}

.drop-zone-inner { pointer-events: none; }

.dz-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.75rem;
  opacity: 0.6;
}

.dz-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.25rem;
}

.dz-subtitle {
  color: var(--ink-light);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.dz-link {
  color: var(--amber);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-style: dotted;
  cursor: pointer;
}

.dz-hint {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}

/* Preview inside drop zone */
.dz-preview {
  position: absolute;
  inset: 0;
  border-radius: calc(var(--radius-sm) - 2px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.dz-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--cream-dark);
  padding: 0.5rem;
}

.preview-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(26,22,18,0.85), transparent);
  padding: 0.75rem 1rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.preview-name {
  color: var(--cream);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
}

.btn-remove {
  background: rgba(181,55,42,0.85);
  color: var(--white);
  border: none;
  border-radius: var(--radius-xs);
  padding: 0.3rem 0.7rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-remove:hover { background: var(--red); }

/* ─── Buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.75rem 1.6rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.01em;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--ink);
  color: var(--cream);
  width: 100%;
  justify-content: center;
  margin-top: 1.25rem;
  padding: 0.9rem 1.6rem;
  font-size: 1rem;
  border: 2px solid transparent;
}

.btn-primary:hover:not(:disabled) {
  background: var(--amber);
  color: var(--white);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(212,134,10,0.3);
}

.btn-icon { font-size: 0.9rem; }

.btn-secondary {
  background: var(--cream);
  color: var(--ink-light);
  border: 1.5px solid var(--cream-border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--cream-dark);
  border-color: var(--ink-faint);
}

.btn-play {
  background: var(--amber);
  color: var(--white);
  padding: 0.8rem 2rem;
  font-size: 1rem;
  box-shadow: 0 3px 12px rgba(212,134,10,0.25);
}
.btn-play:hover:not(:disabled) {
  background: var(--amber-light);
  transform: translateY(-1px);
  box-shadow: 0 5px 18px rgba(212,134,10,0.35);
}
.btn-play.is-paused {
  background: var(--green);
  box-shadow: 0 3px 12px rgba(58,125,68,0.25);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-faint);
  border: 1.5px dashed var(--cream-border);
  font-size: 0.85rem;
  width: 100%;
  justify-content: center;
  margin-bottom: 1rem;
}
.btn-ghost:hover { color: var(--amber); border-color: var(--amber); }

/* ─── Inline error ──────────────────────────────────── */
.inline-error {
  background: #fdf0ee;
  border: 1.5px solid #e8b5b0;
  border-radius: var(--radius-xs);
  color: var(--red);
  padding: 0.65rem 1rem;
  font-size: 0.875rem;
  margin-top: 1rem;
}

/* ─── Processing card ───────────────────────────────── */
.processing-card {
  text-align: center;
  padding: 3rem 2rem;
}

.spinner-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 0 auto 1.5rem;
}

.spinner {
  width: 64px;
  height: 64px;
  border: 3px solid var(--cream-border);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.processing-orbs {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.processing-orbs span {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
  animation: orb-pulse 1.2s ease-in-out infinite;
}

.processing-orbs span:nth-child(2) { animation-delay: 0.2s; }
.processing-orbs span:nth-child(3) { animation-delay: 0.4s; }

@keyframes orb-pulse {
  0%, 100% { opacity: 0.2; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

.processing-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.4rem;
}

.processing-sub {
  color: var(--ink-faint);
  font-style: italic;
  font-size: 0.9rem;
}

/* ─── Controls grid ─────────────────────────────────── */
.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem 2rem;
}

.control-group { display: flex; flex-direction: column; gap: 0.5rem; }
.control-group--wide { grid-column: 1 / -1; }

.control-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.control-unit {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
}

/* Segmented control */
.segmented-control {
  display: flex;
  background: var(--cream);
  border: 1.5px solid var(--cream-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  width: fit-content;
}

.seg-btn {
  flex: 1;
  padding: 0.45rem 0.85rem;
  background: transparent;
  border: none;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--ink-light);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.seg-btn.active {
  background: var(--ink);
  color: var(--cream);
}

.seg-btn:not(.active):hover { background: var(--cream-dark); }

/* Number control */
.number-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.num-btn {
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--cream-border);
  border-radius: 50%;
  background: var(--white);
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.num-btn:hover { border-color: var(--amber); color: var(--amber); }

.num-val {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--ink);
  min-width: 2ch;
  text-align: center;
}

/* Voice select */
.voice-select {
  appearance: none;
  background: var(--cream) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238a7f72'/%3E%3C/svg%3E") no-repeat right 0.85rem center;
  border: 1.5px solid var(--cream-border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 2rem 0.5rem 0.85rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--ink);
  cursor: pointer;
  width: 100%;
  max-width: 320px;
}
.voice-select:focus { outline: 2px solid var(--amber); outline-offset: 2px; }

/* Toggle */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  user-select: none;
}

.toggle-wrap input { display: none; }

.toggle-track {
  width: 44px;
  height: 24px;
  background: var(--cream-dark);
  border: 1.5px solid var(--cream-border);
  border-radius: 99px;
  position: relative;
  transition: all var(--transition);
  flex-shrink: 0;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--white);
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: all var(--transition);
}

.toggle-wrap input:checked ~ .toggle-track { background: var(--amber); border-color: var(--amber); }
.toggle-wrap input:checked ~ .toggle-track .toggle-thumb { transform: translateX(20px); }

.toggle-label { font-size: 0.875rem; color: var(--ink-light); }

/* ─── Dictation card ─────────────────────────────────── */
.dictation-card { padding: 2rem 2.25rem 1.5rem; }

/* Progress bar */
.progress-bar-wrap {
  position: relative;
  height: 6px;
  background: var(--cream-dark);
  border-radius: 99px;
  margin-bottom: 0.6rem;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(to right, var(--amber), var(--amber-light));
  border-radius: 99px;
  width: 0%;
  transition: width 0.4s ease;
}

.progress-label {
  display: block;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ink-faint);
  margin-bottom: 1.25rem;
}

/* Text display area */
.text-display {
  font-family: var(--font-body);
  font-size: 1.15rem;
  line-height: 2.1;
  color: var(--ink);
  min-height: 120px;
  margin-bottom: 1.5rem;
  padding: 1.25rem 1.5rem;
  background: var(--cream);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--cream-border);
}

/* Word spans */
.word {
  display: inline;
  border-radius: 2px;
  padding: 0 1px;
  transition: background var(--transition), color var(--transition);
}

.word.in-group {
  background: var(--highlight-bg);
  color: var(--ink);
}

.word.speaking {
  background: var(--highlight);
  color: var(--ink);
  font-weight: 500;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.word.spoken {
  color: var(--ink-faint);
}

/* Group separator */
.group-sep {
  display: inline-block;
  width: 0.4em;
}

/* Playback controls */
.playback-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

/* Status bar */
.status-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  justify-content: center;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-faint);
  flex-shrink: 0;
  transition: background var(--transition);
}

.status-dot.speaking { background: var(--green); animation: pulse-green 1s ease-in-out infinite; }
.status-dot.paused   { background: var(--amber); }
.status-dot.stopped  { background: var(--red); }

@keyframes pulse-green {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Start-over row */
.start-over-row { margin-top: 0.5rem; }

/* ─── Exam overlay ───────────────────────────────────── */
.exam-overlay {
  position: fixed;
  inset: 0;
  background: var(--ink);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 2rem;
  animation: exam-in 0.35s ease forwards;
}

@keyframes exam-in {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

.exam-exit-btn {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(247,243,236,0.6);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.05em;
}
.exam-exit-btn:hover { color: var(--cream); border-color: rgba(255,255,255,0.35); }

.exam-status {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.exam-group-label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber);
}

.exam-progress {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: rgba(247,243,236,0.4);
}

.exam-spoken-word {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 600;
  color: var(--cream);
  text-align: center;
  letter-spacing: -0.02em;
  min-height: 1.2em;
  line-height: 1.2;
  max-width: 80vw;
  transition: all 0.15s ease;
}

.exam-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.exam-controls .btn-secondary {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.15);
  color: var(--cream);
  padding: 0.65rem 1.25rem;
}
.exam-controls .btn-secondary:hover:not(:disabled) {
  background: rgba(255,255,255,0.14);
}

/* ─── Toast notifications ────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 360px;
}

.toast {
  background: var(--ink);
  color: var(--cream);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1.2rem;
  font-size: 0.875rem;
  font-family: var(--font-body);
  box-shadow: var(--shadow-md);
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  animation: toast-in 0.28s ease forwards;
  border-left: 3px solid var(--amber);
}

.toast.toast-error { border-left-color: var(--red); }
.toast.toast-success { border-left-color: var(--green); }

.toast-icon { font-size: 1rem; flex-shrink: 0; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateX(30px); }
}

/* ─── Footer ─────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
  position: relative;
  z-index: 1;
}

/* ─── Utilities ─────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 600px) {
  .site-header { padding: 1.25rem 1rem; }
  .header-inner { flex-direction: column; gap: 0.6rem; }
  .tagline { border-left: none; padding-left: 0; border-top: 1px solid rgba(255,255,255,0.15); padding-top: 0.5rem; }
  .app-container { margin: 1.5rem auto 3rem; padding: 0 0.85rem; }
  .card { padding: 1.5rem 1.25rem; }
  .controls-grid { grid-template-columns: 1fr; }
  .control-group--wide { grid-column: auto; }
  .playback-controls { gap: 0.5rem; }
  .btn-play { padding: 0.75rem 1.5rem; }
  .text-display { font-size: 1rem; }
  #toast-container { left: 1rem; right: 1rem; max-width: unset; }
}
