/* ────────────────────────────────────────────────────────────
   Debate Judge - Design System
   Scholarly Modern: academic gravitas + tech precision
   ──────────────────────────────────────────────────────────── */

:root {
  /* ── Surfaces (warm parchment palette) ── */
  --bg:          #FAFAF6;
  --bg-2:        #F4F2EC;
  --surface:     #FFFFFF;
  --surface-2:   #F4F2EC;
  --surface-3:   #ECEAE3;
  --surface-ink: #0F0F0F;

  /* ── Borders ── */
  --border:        rgba(15, 15, 15, 0.08);
  --border-strong: rgba(15, 15, 15, 0.16);
  --hairline:      rgba(15, 15, 15, 0.05);

  /* ── Text ── */
  --text:        #0F0F0F;
  --text-soft:   #2A2A2A;
  --muted:       #6B6B6B;
  --muted-2:     #94918B;

  /* ── Accents ── */
  --accent:        #C8302F;        /* deeper, more scholarly red */
  --accent-hover:  #A82424;
  --accent-soft:   rgba(200, 48, 47, 0.08);
  --accent-line:   rgba(200, 48, 47, 0.22);
  --accent-glow:   rgba(200, 48, 47, 0.18);
  --accent-ink:    #5B1717;        /* deep wine for serious headings */

  --ink:           #1A1A1A;        /* deep slate for authority */
  --scholar:       #5B3A29;        /* warm walnut */

  /* ── Sides ── */
  --prop:        #2B5BA8;          /* deeper, scholarly blue */
  --prop-soft:   rgba(43, 91, 168, 0.08);
  --prop-line:   rgba(43, 91, 168, 0.22);
  --opp:         #C66B1D;          /* warmer, scholarly orange */
  --opp-soft:    rgba(198, 107, 29, 0.08);
  --opp-line:    rgba(198, 107, 29, 0.22);

  /* ── Status ── */
  --success:     #1F8F3B;
  --success-soft: rgba(31, 143, 59, 0.10);
  --warning:     #C97A14;
  --danger:      #B83232;

  /* ── Typography ── */
  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* ── Radii ── */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 28px;
  --r-pill: 999px;

  /* ── Shadows (soft, layered, paper-like) ── */
  --shadow-xs: 0 1px 2px rgba(15, 15, 15, 0.04);
  --shadow-sm: 0 2px 6px rgba(15, 15, 15, 0.04), 0 1px 2px rgba(15, 15, 15, 0.05);
  --shadow-md: 0 8px 22px rgba(15, 15, 15, 0.06), 0 2px 6px rgba(15, 15, 15, 0.04);
  --shadow-lg: 0 18px 48px rgba(15, 15, 15, 0.08), 0 4px 12px rgba(15, 15, 15, 0.05);
  --shadow-xl: 0 32px 80px rgba(15, 15, 15, 0.10), 0 8px 20px rgba(15, 15, 15, 0.06);
  --shadow-accent: 0 12px 32px rgba(200, 48, 47, 0.18);

  /* ── Motion ── */
  --ease-out:    cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast:    140ms;
  --dur-base:    240ms;
  --dur-slow:    480ms;

  /* legacy compat (referenced by old templates) */
  --font: var(--font-body);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'ss01', 'cv11', 'kern';
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow-x: hidden;
}

/* Subtle paper grain texture overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.1 0 0 0 0 0.1 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

body > * { position: relative; z-index: 1; }

a { color: var(--accent); text-decoration: none; transition: color var(--dur-fast) var(--ease-out); }
a:hover { color: var(--accent-hover); }

::selection { background: var(--accent-soft); color: var(--accent-ink); }

/* ── Typography ─────────────────────────────────────────── */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.1;
  font-feature-settings: 'ss01', 'kern';
}
h1 { font-size: 2.5rem; font-weight: 500; }
h2 { font-size: 1.75rem; font-weight: 500; letter-spacing: -0.015em; }
h3 { font-size: 1.15rem; font-weight: 600; letter-spacing: -0.01em; font-family: var(--font-body); }
h4 { font-size: 1rem; font-weight: 600; font-family: var(--font-body); }

p  { line-height: 1.65; color: var(--muted); }

.eyebrow {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
}

.mono { font-family: var(--font-mono); font-feature-settings: 'zero', 'ss01'; }

/* ── Cards ──────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 36px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}

/* ── Inputs ─────────────────────────────────────────────── */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="file"],
select,
textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font-body);
  padding: 12px 16px;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
}
input:hover, select:hover, textarea:hover {
  border-color: var(--text-soft);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  background: #fff;
}
input::placeholder { color: var(--muted-2); }

label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 8px;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

.field { margin-bottom: 22px; }

/* ── Buttons ────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--r-sm);
  font-size: 0.95rem;
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
  text-decoration: none;
  user-select: none;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-accent);
  transform: translateY(-1px);
  color: #fff;
}

.btn-ink {
  background: var(--ink);
  color: #fff;
}
.btn-ink:hover { background: #000; color: #fff; transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--text-soft);
  color: var(--text);
}

.btn-soft {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-line);
}
.btn-soft:hover { background: var(--accent-line); color: var(--accent-ink); }

.btn-full { width: 100%; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-sm { padding: 8px 14px; font-size: 0.85rem; }

.btn-row {
  display: flex;
  gap: 12px;
  margin-top: 28px;
}

/* ── Welcome Screen (post-login splash) ── */

.welcome-screen {
  text-align: center;
  animation: fadeIn 0.6s var(--ease-out);
}
.welcome-screen h1 {
  font-family: var(--font-display);
  font-size: 3.2rem;
  margin-bottom: 14px;
  letter-spacing: -0.03em;
}
.welcome-screen .subtitle {
  font-size: 1.05rem;
  color: var(--muted);
}
.welcome-dot {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  margin: 32px auto 0;
  animation: pulse 1.5s infinite;
}

/* ── Wizard (Setup flow) ── */

.wizard-wrap { width: 100%; max-width: 560px; }

.step-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 32px;
  justify-content: center;
}
.step-dot {
  width: 28px; height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
  transition: background var(--dur-base) var(--ease-out), width var(--dur-base) var(--ease-out);
}
.step-dot.active { background: var(--accent); width: 40px; }
.step-dot.done { background: var(--text-soft); }

.step { display: none; animation: slideIn 0.3s var(--ease-out); }
.step.active { display: block; }

.step-header { margin-bottom: 28px; }
.step-header h2 {
  font-family: var(--font-display);
  margin-bottom: 8px;
}

/* ── Badge ── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.badge-prop { background: var(--prop-soft); color: var(--prop); border-color: var(--prop-line); }
.badge-opp  { background: var(--opp-soft);  color: var(--opp);  border-color: var(--opp-line); }

/* ── Debate Page ── */

.debate-wrap {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

.debate-header { text-align: center; width: 100%; }
.debate-topic {
  font-family: var(--font-body);
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 8px;
  font-weight: 600;
}
.debate-motion {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: var(--text);
}

.speaker-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 32px;
  text-align: center;
  width: 100%;
  box-shadow: var(--shadow-sm);
}
.speaker-card .speaker-name {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 500;
  margin: 14px 0 8px;
  letter-spacing: -0.02em;
}
.speaking-time {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ── Record Button ── */

.record-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.record-btn {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
  box-shadow: var(--shadow-accent);
}
.record-btn:hover { background: var(--accent-hover); transform: scale(1.04); }
.record-btn:active { transform: scale(0.96); }
.record-btn.recording { animation: recordPulse 1.2s infinite; }
.record-icon { width: 34px; height: 34px; fill: #fff; }

.record-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.timer {
  font-family: var(--font-mono);
  font-size: 2.4rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  color: var(--text);
}
.timer.active { color: var(--accent); }

/* ── Speaker Progress List ── */

.speaker-list {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.speaker-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--hairline);
  transition: background var(--dur-fast) var(--ease-out);
}
.speaker-row:last-child { border-bottom: none; }
.speaker-row.current { background: var(--accent-soft); }
.speaker-row.done { opacity: 0.5; }
.speaker-row .check { color: var(--success); font-size: 1.1rem; margin-left: auto; }
.speaker-row .current-indicator {
  margin-left: auto;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s infinite;
}

/* ── Status Banner ── */

.status-banner {
  padding: 12px 20px;
  border-radius: var(--r-sm);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
  width: 100%;
}
.status-processing {
  background: rgba(201, 122, 20, 0.08);
  color: var(--warning);
  border: 1px solid rgba(201, 122, 20, 0.25);
}
.status-done {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid rgba(31, 143, 59, 0.25);
}

/* ── Results Page ── */

.results-wrap {
  width: 100%;
  max-width: 820px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 56px 0;
}

.winner-banner {
  border-radius: var(--r-xl);
  padding: 44px 36px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.winner-banner.prop {
  background: linear-gradient(180deg, var(--prop-soft), transparent);
  border: 1px solid var(--prop-line);
}
.winner-banner.opp {
  background: linear-gradient(180deg, var(--opp-soft), transparent);
  border: 1px solid var(--opp-line);
}
.winner-label {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 12px;
  font-weight: 600;
}
.winner-name {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 500;
  margin-bottom: 8px;
  letter-spacing: -0.025em;
}
.winner-name.prop { color: var(--prop); }
.winner-name.opp  { color: var(--opp); }
.voting-issue {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--text-soft);
  font-style: italic;
  max-width: 600px;
  margin: 12px auto 0;
  line-height: 1.5;
}

.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px 32px;
  box-shadow: var(--shadow-xs);
}
.section-card h3 {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--hairline);
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.rfd-text {
  line-height: 1.75;
  color: var(--text-soft);
  white-space: pre-wrap;
  font-size: 0.98rem;
}

.feedback-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 580px) { .feedback-grid { grid-template-columns: 1fr; } }

.feedback-card {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 18px;
}
.feedback-card .speaker-label { font-weight: 600; margin-bottom: 4px; }
.feedback-card .score-row {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  font-size: 0.82rem;
  flex-wrap: wrap;
}
.score-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  padding: 4px 10px;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}
.feedback-card p { font-size: 0.9rem; margin-top: 8px; line-height: 1.6; }

.flow-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.flow-table th, .flow-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--hairline);
}
.flow-table th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.5px; }
.status-standing  { color: var(--success); font-weight: 500; }
.status-taken_out { color: var(--danger); font-weight: 500; }
.status-dropped   { color: var(--muted); font-weight: 500; }
.status-answered  { color: var(--warning); font-weight: 500; }

/* ── Evidence Page ── */

.evidence-wrap {
  width: 100%;
  max-width: 820px;
  padding: 56px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.evidence-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-xs);
}
.evidence-card .citation { font-weight: 600; font-size: 0.98rem; }
.evidence-card .claim    { color: var(--muted); font-size: 0.9rem; line-height: 1.6; }

.ev-status-row { display: flex; gap: 8px; flex-wrap: wrap; }
.ev-btn {
  padding: 6px 14px;
  border-radius: var(--r-xs);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--muted);
  transition: all var(--dur-fast) var(--ease-out);
  font-family: var(--font-body);
}
.ev-btn:hover { border-color: var(--text-soft); color: var(--text); }
.ev-btn.active-verified  { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.ev-btn.active-miscut    { background: rgba(201, 122, 20, 0.10); color: var(--warning); border-color: var(--warning); }
.ev-btn.active-fabricated{ background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.ev-btn.active-unclear   { background: rgba(120,120,120,0.12); color: var(--muted); border-color: var(--border-strong); }

/* ── History ── */

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.history-table th, .history-table td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--hairline);
}
.history-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.history-table tr:hover td { background: var(--surface-2); }

/* ── Animations ── */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
@keyframes recordPulse {
  0%   { box-shadow: 0 0 0 0 var(--accent-glow); }
  70%  { box-shadow: 0 0 0 22px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ── Utility ── */
.text-center { text-align: center; }
.text-muted  { color: var(--muted); }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.divider { border: none; border-top: 1px solid var(--hairline); margin: 28px 0; }
.page-title { text-align: center; margin-bottom: 36px; }
