/* ── CSS custom properties ── */
:root {
  --c-bg: #ffffff;
  --c-surface: #f7f7f5;
  --c-border: #e5e5e3;
  --c-text: #1a1a18;
  --c-muted: #8a8a85;
  --c-correct: #1D9E75;
  --c-correct-bg: #E1F5EE;
  --c-wrong: #D85A30;
  --c-wrong-bg: #FAECE7;

  --radius-card: 10px;
  --gap-card: 8px;
  --max-w: 480px;
  --px: 24px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-bg: #111110;
    --c-surface: #1c1c1a;
    --c-border: #2e2e2b;
    --c-text: #f0f0ee;
  }
}

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

/* Ensure [hidden] always wins over display rules set by class selectors */
[hidden] { display: none !important; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 400;
  background: var(--c-bg);
  color: var(--c-text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#app {
  width: 100%;
  max-width: var(--max-w);
  padding: 0 var(--px);
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
  border-bottom: 0.5px solid var(--c-border);
  margin-bottom: 20px;
}

.wordmark {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.3px;
}

.header-meta {
  display: flex;
  gap: 12px;
}

.meta-text {
  font-size: 12px;
  color: var(--c-muted);
}

/* ── Status views (loading / error) ── */
.status-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px 0;
  text-align: center;
}

.status-text {
  font-size: 14px;
  color: var(--c-muted);
}

/* ── Label ── */
.label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--c-muted);
  margin-bottom: 8px;
}

/* ── Instructions ── */
.instructions {
  font-size: 13px;
  color: var(--c-muted);
  margin-bottom: 16px;
  text-align: center;
}

/* ── Pip row ── */
.pip-row {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-bottom: 16px;
}

.pip {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: var(--c-surface);
  border: 0.5px solid var(--c-border);
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.pip--correct {
  background: var(--c-correct);
  border-color: var(--c-correct);
}

.pip--wrong {
  background: var(--c-wrong);
  border-color: var(--c-wrong);
}

/* ── Card list ── */
.card-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--gap-card);
  margin-bottom: 20px;
}

.card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--c-surface);
  border: 0.5px solid var(--c-border);
  border-radius: var(--radius-card);
  cursor: grab;
  user-select: none;
  transition: background 0.2s, border-color 0.2s, opacity 0.15s;
}

.card:active { cursor: grabbing; }

.drag-handle {
  color: var(--c-muted);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  line-height: 0;
}

.card-label {
  flex: 1;
  font-size: 14px;
  line-height: 1.4;
}

/* Card states post-submission */
.card--correct {
  background: var(--c-correct-bg);
  border-color: var(--c-correct);
}

.card--wrong {
  background: var(--c-wrong-bg);
  border-color: var(--c-wrong);
}

/* Sortable.js drag states */
.card--ghost {
  opacity: 0.4;
  border-style: dashed;
}

.card--chosen {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* ── Buttons ── */
.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--c-text);
  color: var(--c-bg);
  border: none;
  border-radius: var(--radius-card);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-primary:hover { opacity: 0.85; }
.btn-primary:active { opacity: 0.7; }

.btn-secondary {
  flex: 1;
  padding: 10px 14px;
  background: var(--c-surface);
  color: var(--c-text);
  border: 0.5px solid var(--c-border);
  border-radius: var(--radius-card);
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover { background: var(--c-border); }

/* ── Result view ── */
.score-block {
  text-align: center;
  margin-bottom: 20px;
}

.score-value {
  font-size: 22px;
  font-weight: 500;
}

.share-block {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.countdown-block {
  text-align: center;
  margin-bottom: 24px;
}

.countdown {
  font-size: 18px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}

/* ── Reveal section ── */
.reveal-section {
  border: 0.5px solid var(--c-border);
  border-radius: var(--radius-card);
  overflow: hidden;
  margin-bottom: 24px;
}

.reveal-summary {
  font-size: 13px;
  color: var(--c-muted);
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.reveal-summary::before {
  content: '▶';
  font-size: 10px;
  transition: transform 0.2s;
}

details[open] .reveal-summary::before {
  transform: rotate(90deg);
}

.correct-order-list {
  padding: 0 14px 12px 36px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.correct-order-list li {
  font-size: 13px;
  line-height: 1.4;
  color: var(--c-muted);
}

.correct-order-list li span {
  color: var(--c-text);
}

/* ── Footer ── */
.footer {
  margin-top: auto;
  padding: 20px 0;
  border-top: 0.5px solid var(--c-border);
}

.attribution {
  font-size: 11px;
  color: var(--c-muted);
  text-align: center;
  margin-bottom: 12px;
}

.attribution a {
  color: var(--c-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Ad slots ── */
.ad-slot {
  width: 100%;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-muted);
  font-size: 11px;
  margin-bottom: 16px;
}

.ad-slot--footer {
  min-height: 60px;
  margin-bottom: 0;
}

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