/* Cobbe's Secret Mission — design-system components.
 *
 * Class-based counterparts to the components in the Cobbe's Secret Mission
 * Design System bundle (Button, Card, Chip, StatusBadge, Avatar, Stamp,
 * TopBar, SummaryStat, CobbeMessage, FormField, ChoiceCard, ProgressStars).
 *
 * The design prototypes are React with inline styles; these are the same
 * components expressed the way this app is actually written — plain CSS driven
 * entirely by the tokens in tokens.css. Markup lives in the Jinja macros at
 * app/templates/components/ds.html; use those rather than hand-writing the
 * classes, so a change lands in one place.
 *
 * Rules for anything added here:
 *   - values come from tokens.css, never literals
 *   - 48px minimum tap target, 56px for primary actions
 *   - every entrance animation stops under prefers-reduced-motion
 *   - class names are prefixed ds- so they never collide with the older
 *     hand-written classes in agent-theme.css
 */

/* ═══ Button ═════════════════════════════════════════════════════ */

.ds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  font-size: var(--font-size-base);
  padding: 14px 28px;
  border: 2px solid;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  text-decoration: none;
  cursor: pointer;
  min-height: var(--tap-min);
  transition: all var(--transition-fast);
}

.ds-btn--sm { padding: 8px 16px; font-size: var(--font-size-sm); }
.ds-btn--lg { padding: 18px 36px; font-size: var(--font-size-lg); min-height: var(--tap-large); }
.ds-btn--block { width: 100%; }

.ds-btn[disabled],
.ds-btn--disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

.ds-btn--primary {
  background: var(--action-primary);
  color: var(--action-primary-ink);
  border-color: var(--action-primary);
}
.ds-btn--primary:hover:not([disabled]) {
  background: transparent;
  color: var(--neon-blue);
  box-shadow: var(--shadow-hover-blue);
}

.ds-btn--secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-color);
}
.ds-btn--secondary:hover:not([disabled]) {
  border-color: var(--neon-blue);
  color: var(--neon-blue);
}

.ds-btn--danger {
  background: transparent;
  color: var(--neon-red);
  border-color: var(--neon-red);
}
.ds-btn--danger:hover:not([disabled]) { background: var(--neon-red); color: var(--on-danger); }

/* The two "fancy" variants drop the border for a gradient fill. */
.ds-btn--solve,
.ds-btn--generate {
  border: none;
  border-radius: var(--radius);
  font-weight: var(--weight-heavy);
  letter-spacing: var(--tracking-title);
}
.ds-btn--solve { background: var(--grad-solve); color: var(--on-danger); }
.ds-btn--solve:hover:not([disabled]) { transform: scale(1.08); box-shadow: var(--shadow-solve); }
.ds-btn--generate { background: var(--grad-generate); color: var(--bg-primary); }
.ds-btn--generate:hover:not([disabled]) {
  transform: translateY(var(--lift-card));
  box-shadow: var(--shadow-hover-green);
}

/* ═══ Card ═══════════════════════════════════════════════════════ */

.ds-card {
  background: var(--surface-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
}
.ds-card--glow {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-glow), var(--shadow-card);
}
.ds-card--tight { padding: var(--space-5); }

.ds-card__title {
  font-family: var(--font-display);
  font-size: var(--font-size-xl);
  font-weight: var(--weight-bold);
  color: var(--text-accent);
  margin-bottom: var(--space-4);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
}

/* ═══ TopBar ═════════════════════════════════════════════════════ */

.ds-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: 12px 20px;
  background: var(--surface-raised);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  margin-bottom: var(--spacing);
  box-shadow: var(--shadow-glow);
}
.ds-topbar__title {
  font-family: var(--font-display);
  color: var(--neon-blue);
  font-weight: var(--weight-bold);
  font-size: var(--font-size-lg);
  text-transform: uppercase;
  letter-spacing: var(--tracking-title);
}
.ds-topbar__right { display: flex; align-items: center; gap: var(--space-4); flex-shrink: 0; }
.ds-topbar__status { color: var(--text-secondary); font-size: var(--font-size-sm); white-space: nowrap; }
/* A team's name can be long ("Agenter Elsa, Max och Ottilia-Charlotte"): on a
   phone the title gets its own row and status + back sit underneath. */
@media (max-width: 520px) {
  .ds-topbar { flex-wrap: wrap; row-gap: var(--space-2); padding: 10px 14px; }
  .ds-topbar__title { flex: 1 1 100%; min-width: 0; font-size: var(--font-size-base); overflow-wrap: anywhere; }
  .ds-topbar__right { flex: 1 1 100%; justify-content: flex-end; }
  .ds-topbar__status { margin-right: auto; }
  /* Without a status line the back button fits beside the title. */
  .ds-topbar:not(:has(.ds-topbar__status)) .ds-topbar__title { flex: 1 1 0; }
  .ds-topbar:not(:has(.ds-topbar__status)) .ds-topbar__right { flex: 0 0 auto; }
}

/* ═══ Chip ═══════════════════════════════════════════════════════ */

.ds-chip {
  display: inline-block;
  white-space: nowrap;
  padding: 4px 10px;
  border: 1px solid;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-sm);
  margin: 2px;
  transition: all var(--transition-fast);
}
.ds-chip--blue   { background: var(--wash-blue-10);   border-color: rgba(0,212,255,.3);  color: var(--neon-blue); }
.ds-chip--green  { background: var(--wash-green-05);  border-color: rgba(0,255,136,.3);  color: var(--neon-green); }
.ds-chip--orange { background: var(--wash-orange-08); border-color: rgba(255,107,53,.3); color: var(--neon-orange); }

a.ds-chip, button.ds-chip, .ds-chip--clickable { cursor: pointer; }
a.ds-chip:hover, button.ds-chip:hover, .ds-chip--clickable:hover { filter: brightness(1.4); }

/* ═══ StatusBadge ════════════════════════════════════════════════ */

.ds-badge {
  display: inline-block;
  font-family: var(--font-display);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: var(--font-size-sm);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
}
.ds-badge--active   { background: var(--neon-green); color: #000; }
.ds-badge--solved   { background: var(--neon-blue);  color: #000; }
.ds-badge--draft    { background: transparent; color: var(--neon-orange); border: 1px solid var(--neon-orange); }
.ds-badge--archived { background: transparent; color: var(--text-muted);  border: 1px solid var(--border-color); }

/* ═══ Avatar ═════════════════════════════════════════════════════ */

.ds-avatar {
  --ds-avatar-size: 56px;
  --ds-avatar-ring: var(--neon-blue);
  --ds-avatar-ring-width: 2px;
  width: var(--ds-avatar-size);
  height: var(--ds-avatar-size);
  border-radius: var(--radius-round);
  background: var(--bg-secondary);
  border: var(--ds-avatar-ring-width) solid var(--ds-avatar-ring);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  font-size: calc(var(--ds-avatar-size) * .48);
}
.ds-avatar--glow { box-shadow: 0 0 20px rgba(0,212,255,.3); }
.ds-avatar img { width: 100%; height: 100%; display: block; }

/* ═══ Stamp ══════════════════════════════════════════════════════ */

.ds-stamp {
  display: inline-block;
  font-family: var(--font-display);
  padding: 8px 20px;
  border: 3px solid;
  font-weight: var(--weight-heavy);
  font-size: var(--font-size-lg);
  text-transform: uppercase;
  letter-spacing: var(--tracking-title);
  transform: rotate(-5deg);
  opacity: .85;
}
.ds-stamp--red   { border-color: var(--neon-red);   color: var(--neon-red); }
.ds-stamp--green { border-color: var(--neon-green); color: var(--neon-green); }
.ds-stamp--blue  { border-color: var(--neon-blue);  color: var(--neon-blue); }

/* ═══ SummaryStat ════════════════════════════════════════════════ */

.ds-stat {
  --ds-stat-accent: var(--neon-blue);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}
.ds-stat__icon  { font-size: 28px; }
.ds-stat__value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: var(--weight-bold);
  color: var(--ds-stat-accent);
}
.ds-stat__label {
  font-size: 12px;
  text-transform: uppercase;
  font-weight: var(--weight-bold);
  color: var(--text-muted);
  letter-spacing: var(--tracking-label);
}

/* ═══ CobbeMessage ═══════════════════════════════════════════════ */

.ds-cobbe {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--grad-cobbe);
  border: 1px solid rgba(0,212,255,.2);
  border-radius: var(--radius);
  margin: var(--space-4) 0;
}
.ds-cobbe__avatar {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  background: var(--bg-secondary);
  border-radius: var(--radius-round);
  border: 2px solid var(--neon-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}
.ds-cobbe__body {
  color: var(--text-primary);
  font-style: italic;
  line-height: var(--leading-relaxed);
}
.ds-cobbe__sender {
  color: var(--neon-blue);
  font-weight: var(--weight-bold);
  font-style: normal;
  display: block;
  margin-bottom: 4px;
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
}

.ds-cobbe__body { flex: 1; min-width: 0; }

/* ═══ SpeakButton (read-aloud, P2) ═══════════════════════════════
   Added by static/js/speak.js to anything marked data-speak, at the end of
   its data-speak-host. A real target (48px), round, quiet until it plays. */

.speak-btn {
  flex-shrink: 0;
  align-self: flex-start;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-round);
  border: 2px solid var(--neon-blue);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.speak-btn:focus-visible { outline: 3px solid var(--neon-blue); outline-offset: 2px; }
.speak-btn--playing { background: var(--neon-blue); color: var(--ink-on-neon); }
.speak-btn--nudge { animation: pulse-glow 1.6s ease-in-out infinite; }
.ds-cobbe--paper .speak-btn { border-color: var(--ink-strong); background: transparent; color: var(--ink-strong); }
@media print { .speak-btn { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .speak-btn--nudge { animation: none; } }

/* On the paper surfaces (print sheet, notebook) Cobbe speaks in ink. */
.ds-cobbe--paper {
  background: rgba(255,255,255,.7);
  border-color: #ccc;
}
.ds-cobbe--paper .ds-cobbe__body,
.ds-cobbe--paper .ds-cobbe__sender { color: var(--ink-strong); }

/* ═══ FormField ══════════════════════════════════════════════════ */

.ds-field { margin-bottom: var(--space-5); }
.ds-field__label {
  display: block;
  font-family: var(--font-display);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  margin-bottom: var(--space-2);
}
.ds-field__hint { color: var(--text-muted); font-size: var(--font-size-sm); margin-bottom: 6px; }
.ds-field__help { color: var(--text-muted); font-size: var(--font-size-sm); }

.ds-field__input {
  width: 100%;
  padding: 14px 16px;
  /* max(16px, …) keeps iOS from zooming the viewport on focus */
  font-size: max(16px, var(--font-size-base));
  font-family: inherit;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 2px solid var(--border-control);   /* ≥3:1 boundary on every dark ground */
  border-radius: var(--radius-sm);
  min-height: var(--tap-min);
  outline: none;
  transition: border-color var(--transition-fast);
}
.ds-field__input:focus { border-color: var(--neon-blue); box-shadow: var(--shadow-focus); }
textarea.ds-field__input { resize: vertical; }

/* Evidence codes and other machine input. */
.ds-field__input--mono {
  font-family: var(--font-mono);
  font-size: max(16px, var(--font-size-xl));
  text-transform: uppercase;
  letter-spacing: var(--tracking-code);
}
.ds-field__input--center { text-align: center; }

/* ═══ ChoiceCard ═════════════════════════════════════════════════ */

.ds-choice {
  flex: 1;
  padding: var(--space-4);
  text-align: center;
  cursor: pointer;
  background: var(--bg-primary);
  border: 2px solid var(--border-control);
  border-radius: var(--radius);
  min-height: var(--tap-min);
  transition: all var(--transition-fast);
  display: block;
}
.ds-choice:hover { border-color: var(--neon-blue); }

/* A row of choice cards that always fits its container: minmax(0, 1fr) lets a
 * column shrink below its label's width (plain 1fr can't, which is how the
 * role chips overflowed the person form), and labels wrap instead. */
.ds-choice-grid {
  display: grid;
  grid-template-columns: repeat(var(--ds-choice-cols, 4), minmax(0, 1fr));
  gap: var(--space-2);
}
.ds-choice-grid .ds-choice { padding: var(--space-3) var(--space-2); min-width: 0; }
.ds-choice-grid .ds-choice__label { overflow-wrap: anywhere; }
@media (max-width: 420px) { .ds-choice-grid { --ds-choice-cols: 2; } }
/* The server-rendered --selected class is only the fallback for browsers
   without :has(); where :has() works, the checked input alone decides, so a
   new pick never leaves the old card looking selected too. */
@supports not selector(:has(*)) {
  .ds-choice--selected { background: var(--wash-green-05); border-color: var(--neon-green); }
  .ds-choice--selected:hover { border-color: var(--neon-green); }
}
.ds-choice__icon  { font-size: 2em; margin-bottom: 6px; }
.ds-choice__label { font-weight: var(--weight-bold); color: var(--text-primary); }
.ds-choice__desc  { font-size: var(--font-size-sm); color: var(--text-muted); margin-top: 4px; }

/* Live selection without script. The server-rendered --selected class is the
   fallback for browsers without :has(). */
.ds-choice:has(input:checked) { background: var(--wash-green-05); border-color: var(--neon-green); }

/* Keyboard focus must be visible even though the control is a label. */
.ds-choice:focus-within { border-color: var(--neon-blue); box-shadow: var(--shadow-focus); }
.ds-choice input { position: absolute; opacity: 0; pointer-events: none; }

/* ═══ ProgressStars ══════════════════════════════════════════════ */

.ds-stars {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
  padding: var(--space-4);
  background: var(--wash-gold-08);
  border-radius: var(--radius);
}
.ds-stars__star {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  opacity: .3;
  transition: all var(--transition-normal);
}
.ds-stars__star--on {
  opacity: 1;
  transform: scale(1.1);
  filter: drop-shadow(0 0 8px rgba(255,204,0,.6));
}

/* ═══ Reduced motion ═════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  .ds-btn,
  .ds-chip,
  .ds-choice,
  .ds-stars__star,
  .ds-field__input { transition: none; }
  .ds-btn--solve:hover:not([disabled]),
  .ds-btn--generate:hover:not([disabled]) { transform: none; }
}

/* ═══ Layout primitives ══════════════════════════════════════════
 * Not components so much as the page furniture the mission-setup screens
 * share: a centred column, a section eyebrow with a count, a tile grid, a
 * chip row, a help line. Kept here rather than in per-page <style> blocks so
 * the five new screens stay style-free.
 */

.ds-page {
  --ds-page-width: 520px;
  max-width: var(--ds-page-width);
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) var(--space-10);
}
.ds-page--wide { --ds-page-width: var(--width-station); }

/* Section eyebrow: label left, count right, sitting on the same baseline. */
.ds-section {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin: 26px 0 var(--space-3);
}
.ds-section__label {
  font-family: var(--font-display);
  font-size: var(--font-size-sm);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--text-muted);
}
.ds-section__count {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
}

.ds-help {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: var(--space-3);
}

/* ═══ Tile grid ══════════════════════════════════════════════════ */

.ds-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: var(--space-3);
}

.ds-tile {
  --ds-tile-ring: var(--border-color);
  display: block;
  text-align: center;
  text-decoration: none;
  color: inherit;
  padding: 12px 6px;
  background: var(--surface-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  transition: all var(--transition-fast);
}
.ds-tile:hover {
  border-color: var(--neon-blue);
  transform: translateY(var(--lift-card));
  box-shadow: var(--shadow-glow);
}
.ds-tile__name {
  font-size: 13px;
  font-weight: var(--weight-bold);
  margin-top: 6px;
  color: var(--text-primary);
}
.ds-tile__meta { font-size: 11px; color: var(--text-muted); line-height: 1.2; }
.ds-tile .ds-avatar { margin: 0 auto; }

/* The trailing "add" cell — dashed, so it never reads as a filled tile. */
.ds-tile--add {
  border-style: dashed;
  min-height: 118px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
}
.ds-tile--add:hover { border-color: var(--neon-blue); color: var(--neon-blue); transform: none; box-shadow: none; }
.ds-tile__plus { font-size: 30px; line-height: 1; }

/* ═══ Chip row + inline add ══════════════════════════════════════ */

.ds-chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* An add-chip is a dashed sibling of .ds-chip that opens an inline input. */
.ds-chip-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-xs);
  background: transparent;
  font-size: var(--font-size-sm);
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.ds-chip-add:hover { border-color: var(--neon-blue); color: var(--neon-blue); }

.ds-chip-add__input {
  width: 9em;
  padding: 4px 8px;
  font-size: max(16px, var(--font-size-sm));
  font-family: inherit;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--neon-blue);
  border-radius: var(--radius-xs);
  outline: none;
}

/* Reveal-on-tap for the add-chip, done with a checkbox rather than script so
   it keeps working on a cold offline load. The checkbox carries no name, so it
   never reaches the server. */
.ds-chip-add-form { display: inline-flex; align-items: center; }
.ds-chip-add__check { position: absolute; opacity: 0; pointer-events: none; }
.ds-chip-add__field { display: none; align-items: center; gap: 6px; }
.ds-chip-add__check:checked ~ .ds-chip-add { display: none; }
.ds-chip-add__check:checked ~ .ds-chip-add__field { display: inline-flex; }
.ds-chip-add__check:focus-visible ~ .ds-chip-add { border-color: var(--neon-blue); color: var(--neon-blue); }

/* Remove control riding on a chip. */
.ds-chip__remove {
  margin-left: 6px;
  border: none;
  background: none;
  color: inherit;
  opacity: .55;
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.ds-chip__remove:hover { opacity: 1; color: var(--neon-red); }

/* ═══ Toggle ═════════════════════════════════════════════════════ */

.ds-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--surface-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
}
.ds-toggle__label { font-weight: var(--weight-bold); color: var(--text-primary); }
.ds-toggle__help { font-size: var(--font-size-sm); color: var(--text-muted); margin-top: 4px; }

.ds-switch { position: relative; flex-shrink: 0; width: 64px; height: 36px; }
.ds-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.ds-switch__track {
  display: block;
  width: 64px;
  height: 36px;
  padding: 3px;
  border: 2px solid var(--border-control);
  border-radius: var(--radius-pill);
  background: var(--bg-primary);
  transition: all var(--transition-fast);
}
.ds-switch__knob {
  display: block;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-round);
  background: var(--text-muted);
  transition: all var(--transition-fast);
}
.ds-switch input:checked + .ds-switch__track {
  border-color: var(--neon-blue);
  background: var(--wash-blue-15);
}
.ds-switch input:checked + .ds-switch__track .ds-switch__knob {
  transform: translateX(28px);
  background: var(--neon-blue);
  box-shadow: 0 0 12px rgba(0,212,255,.6);
}
.ds-switch input:focus-visible + .ds-switch__track { box-shadow: var(--shadow-focus); }

/* ═══ Avatar picker ══════════════════════════════════════════════ */

.ds-picker {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--surface-raised);
  padding: var(--space-3);
  max-height: 280px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: var(--space-2);
}
.ds-picker__cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.ds-picker__cell:hover { background: rgba(0,212,255,.08); }
.ds-picker__cell input { position: absolute; opacity: 0; pointer-events: none; }
.ds-picker__cell input:checked + .ds-avatar {
  --ds-avatar-ring: var(--neon-blue);
  box-shadow: 0 0 20px rgba(0,212,255,.3);
}
.ds-picker__cell input:focus-visible + .ds-avatar { box-shadow: var(--shadow-focus); }

/* ═══ Reduced motion (layout primitives) ═════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  .ds-tile, .ds-chip-add, .ds-switch__track, .ds-switch__knob, .ds-picker__cell { transition: none; }
  .ds-tile:hover { transform: none; }
}

/* ═══ SuspectPolaroid ════════════════════════════════════════════
 * A photograph pinned to the board. This is one of the few places the app
 * shows the paper world on top of the dark shell, so the ink colours come
 * from the paper tokens, not the agent ones.
 */

.ds-polaroid {
  --ds-polaroid-tilt: -2deg;
  position: relative;
  width: min(240px, 100%);
  background: var(--polaroid);
  padding: 12px;
  border: 2px solid var(--polaroid-edge);
  box-shadow: var(--shadow-polaroid);
  text-align: center;
  transform: rotate(var(--ds-polaroid-tilt));
  transition: all var(--transition-normal);
}
.ds-polaroid:hover {
  transform: rotate(0deg) scale(1.05);
  box-shadow: var(--shadow-polaroid-hover);
}

.ds-polaroid__pin {
  position: absolute;
  top: -6px;
  right: 16px;
  width: 12px;
  height: 12px;
  border-radius: var(--radius-round);
  background: var(--grad-pin-red);
  box-shadow: 0 1px 3px rgba(0,0,0,.3), inset -1px -1px 1px rgba(0,0,0,.2);
  z-index: 5;
}

.ds-polaroid__photo {
  width: 100%;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f0f0f0 0%, #e8e8e8 100%);
  margin-bottom: var(--space-2);
  border-radius: var(--radius-xs);
  overflow: hidden;
  font-size: 48px;
  color: #ccc;
}
.ds-polaroid__photo img { width: 100%; height: 100%; object-fit: cover; }

.ds-polaroid__name {
  font-weight: var(--weight-bold);
  color: var(--ink-strong);
  font-size: 13px;
  margin-bottom: 2px;
  word-break: break-word;
}
.ds-polaroid__alias {
  color: var(--paper-alias);   /* neon-orange is 2.84:1 on the white polaroid */
  font-size: 11px;
  font-style: italic;
  margin-bottom: 6px;
}

.ds-polaroid__bar {
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: var(--space-2);
}
.ds-polaroid__fill { height: 100%; border-radius: 3px; transition: width var(--duration-fade) ease; }
.ds-polaroid__fill--green  { background: var(--neon-green); }
.ds-polaroid__fill--orange { background: var(--neon-orange); }
.ds-polaroid__fill--red    { background: var(--neon-red); }

.ds-polaroid__badges {
  display: flex;
  gap: 3px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 6px;
}
.ds-polaroid__badge {
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 3px;
  font-weight: var(--weight-semibold);
}
.ds-polaroid__badge--clue         { background: var(--wash-blue-10);   color: var(--bubble-q-label); }
.ds-polaroid__badge--interrogated { background: var(--wash-orange-08); color: var(--paper-alias); }

/* ═══ SuspicionMeter ═════════════════════════════════════════════ */

.ds-meter { display: flex; gap: 6px; justify-content: center; align-items: center; }
.ds-meter__label {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  font-weight: var(--weight-semibold);
  margin-right: var(--space-2);
}
.ds-meter__pip {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  opacity: .3;
  transition: all var(--transition-normal);
}
.ds-meter__pip--on {
  opacity: 1;
  transform: scale(1.2);
  filter: drop-shadow(0 0 6px rgba(180,77,255,.5));
}

/* ═══ BadgeCard ══════════════════════════════════════════════════ */

.ds-badgecard {
  position: relative;
  background: var(--surface-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  transition: all var(--transition-normal);
}
.ds-badgecard:hover {
  border-color: var(--neon-gold);
  box-shadow: var(--shadow-badge);
  transform: translateY(-4px) scale(1.02);
}
.ds-badgecard--locked { border-style: dashed; opacity: .3; }
.ds-badgecard--locked:hover { border-color: var(--border-color); box-shadow: none; transform: none; }
.ds-badgecard__lock { position: absolute; top: 8px; right: 8px; font-size: 14px; opacity: .6; }
.ds-badgecard__icon {
  font-size: 48px;
  display: block;
  margin-bottom: var(--space-3);
  filter: drop-shadow(0 0 8px rgba(255,215,0,.5));
}
.ds-badgecard--locked .ds-badgecard__icon { filter: grayscale(1) opacity(.4); }
.ds-badgecard__name {
  font-family: var(--font-display);
  font-size: var(--font-size-sm);
  font-weight: var(--weight-heavy);
  color: var(--neon-gold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  margin-bottom: 6px;
}
.ds-badgecard--locked .ds-badgecard__name { color: var(--text-muted); }
.ds-badgecard__desc { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

@media (prefers-reduced-motion: reduce) {
  .ds-polaroid, .ds-meter__pip, .ds-badgecard, .ds-polaroid__fill { transition: none; }
  .ds-polaroid:hover, .ds-badgecard:hover { transform: rotate(var(--ds-polaroid-tilt)); }
  .ds-badgecard:hover { transform: none; }
}

/* ═══ QR code ════════════════════════════════════════════════════
 * Rendered server-side as inline SVG (services/qr.py). Readers need a light
 * quiet zone behind the pattern, so the frame supplies one — the code itself
 * is drawn in near-black rather than pure black to match the shell's ink.
 */

.join-qr {
  display: inline-block;
  width: 180px;
  height: 180px;
  padding: 12px;
  background: #fff;
  border-radius: var(--radius-sm);
}
.join-qr svg { display: block; }

/* ═══ StationHeader ══════════════════════════════════════════════ */

.ds-station { text-align: center; margin-bottom: var(--space-8); }
.ds-station__title {
  --ds-station-accent: var(--neon-blue);
  font-family: var(--font-display);
  font-size: var(--font-size-xl);
  font-weight: var(--weight-heavy);
  color: var(--ds-station-accent);
  text-transform: uppercase;
  letter-spacing: 3px;
}
.ds-station__subtitle {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  letter-spacing: var(--tracking-title);
  margin-top: 4px;
}

/* ═══ Console nav ════════════════════════════════════════════════
 * The game leader's own navigation. It lives outside base.html's content
 * block because every admin template overrides that block, which is how the
 * links to settings, profiles and Vårt hushåll ended up existing only on the
 * landing page. Never shown on the child's screens.
 */

.console-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--spacing);
  padding: var(--space-2);
  background: var(--surface-raised);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}
.console-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  min-height: var(--tap-min);
  border-radius: var(--radius-xs);
  font-family: var(--font-display);
  font-size: var(--font-size-sm);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition-fast);
}
.console-nav a:hover { color: var(--neon-blue); background: var(--wash-blue-05); }
.console-nav a.is-current { color: var(--neon-blue); background: var(--wash-blue-10); }
.console-nav__out { margin-left: auto; color: var(--text-muted) !important; }
.console-nav__out:hover { color: var(--neon-red) !important; background: var(--wash-red-10) !important; }

@media (prefers-reduced-motion: reduce) { .console-nav a { transition: none; } }

/* Phone: one swipeable row instead of three wrapped ones, so the leader sees
 * the case status on the first screen (F11). base.html scrolls the current
 * page's link into view. */
@media (max-width: 600px) {
  .console-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 2px;
    padding: 4px;
    margin-bottom: var(--space-3);
  }
  .console-nav::-webkit-scrollbar { display: none; }
  .console-nav a { flex: 0 0 auto; padding: 8px 10px; letter-spacing: 0; white-space: nowrap; }
  .console-nav__out { margin-left: 0; }
}

/* ═══ Live link (P1) ══════════════════════════════════════════════
 * The game master's live card, and what the tablet shows when the game
 * master sends a hint or pauses the game.
 */

.live-hint { flex: 1; min-width: 200px; }
.live-hint > summary { list-style: none; cursor: pointer; display: inline-flex; }
.live-hint > summary::-webkit-details-marker { display: none; }
.live-hint__body { display: grid; gap: 6px; margin-top: 8px; }
.live-hint__canned {
  width: 100%; text-align: left; padding: 10px 12px; min-height: var(--tap-min);
  background: var(--bg-primary); color: var(--text-primary);
  border: 1px solid var(--border-color); border-radius: var(--radius-xs);
  font: inherit; cursor: pointer;
}
.live-hint__canned:hover { border-color: var(--neon-blue); }
.live-hint__own { display: flex; gap: 6px; }
.live-hint__own .form-input { flex: 1; min-width: 0; }

.live-feed {
  list-style: none; margin: 12px 0 0; padding: 0;
  max-height: 220px; overflow-y: auto;
  font-size: var(--font-size-sm);
}
.live-feed li { padding: 6px 0; border-top: 1px solid var(--border-color); }
.live-feed__at { color: var(--text-muted); font-family: var(--font-mono, monospace); margin-right: 4px; }
.live-feed__empty { color: var(--text-muted); }
.live-feed__new { animation: live-flash 1.6s ease-out; }
@keyframes live-flash { from { background: var(--wash-blue-10); } to { background: transparent; } }

/* Tablet: paused. Covers everything; only the game master can lift it. */
.live-pause {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 32px; text-align: center;
  background: rgba(5, 8, 16, 0.96);
}
.live-pause__radar { font-size: 72px; animation: live-pulse 2s ease-in-out infinite; }
.live-pause__title {
  font-family: var(--font-display); font-size: var(--font-size-xl, 2rem);
  font-weight: var(--weight-bold); color: var(--neon-blue);
  text-transform: uppercase; letter-spacing: var(--tracking-label);
}
.live-pause__body { font-size: var(--font-size-lg); color: var(--text-secondary); max-width: 28ch; }
@keyframes live-pulse { 50% { transform: scale(1.12); opacity: 0.7; } }

/* Tablet: a hint from the game master, as a Cobbe message. */
.live-hint-pop {
  position: fixed; inset: 0; z-index: 9100;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(5, 8, 16, 0.75);
}
.live-hint-pop__card {
  max-width: 520px; width: 100%; padding: 28px;
  background: var(--bg-card); border: 2px solid var(--neon-green);
  border-radius: var(--radius); box-shadow: 0 0 40px rgba(45, 255, 130, 0.25);
  display: grid; gap: 18px; text-align: center;
}
.live-hint-pop__sender {
  font-family: var(--font-display); font-weight: var(--weight-bold);
  color: var(--neon-green); text-transform: uppercase; letter-spacing: var(--tracking-label);
}
.live-hint-pop__text { font-size: var(--font-size-xl, 1.6rem); line-height: 1.4; }

.live-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 8900; padding: 12px 20px; border-radius: var(--radius);
  background: var(--bg-card); border: 1px solid var(--neon-blue);
  box-shadow: 0 0 24px rgba(0, 212, 255, 0.3);
  font-weight: var(--weight-bold); transition: opacity 0.6s;
}
.live-toast--out { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .live-pause__radar, .live-feed__new { animation: none; }
}

/* ═══ Surface roots (Phase C) ═════════════════════════════════════
 * One class on <body> picks the world; base.html sets it from the
 * {% block surface %}. Agent = child tablet, console = Spelledarläge on the
 * parent phone, paper = notebook/board/certificate on screen, print = A4.
 */
.csm-agent, .csm-console {
  font-family: var(--font-ui);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
}
/* .csm-agent ambience: body.csm-agent::before in base.css (fixed, so it does not scroll). */
.csm-console { font-size: 16px; }
.csm-paper { font-family: var(--font-ui); background: var(--paper); color: var(--ink); line-height: var(--leading-body); }
.csm-print { font-family: var(--font-ui); background: var(--print-page); color: var(--print-ink); }
.csm-agent *, .csm-console *, .csm-paper *, .csm-print * { box-sizing: border-box; }

/* Ghost button: the quiet third action (promoted from the hub briefing link). */
.ds-btn--ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.ds-btn--ghost:hover:not([disabled]) { background: var(--wash-blue-10); color: var(--neon-blue); }

/* ═══ Station tile (hub nav card) ════════════════════════════════ */
.ds-station-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; background: var(--bg-card); border: 2px solid var(--border-color); border-radius: var(--radius); text-decoration: none; color: inherit; transition: all var(--transition-fast); min-height: 200px; position: relative; overflow: hidden; }
.ds-station-tile::before { content: ''; position: absolute; inset: 0; background: var(--grad-gloss); opacity: 0; transition: opacity var(--transition-fast); pointer-events: none; }
.ds-station-tile:hover { border-color: var(--border-glow); box-shadow: var(--shadow-glow); transform: translateY(var(--lift-card-strong)) scale(var(--scale-hover)); }
.ds-station-tile:hover::before { opacity: 1; }
.ds-station-tile__icon { width: 100px; height: 100px; display: flex; align-items: center; justify-content: center; transition: all var(--transition-fast); }
.ds-station-tile:hover .ds-station-tile__icon { transform: scale(1.15) rotate(-5deg); }
.ds-station-tile__icon svg { width: 100%; height: 100%; fill: none; stroke: var(--ds-station-accent, var(--neon-blue)); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.ds-station-tile__label { overflow-wrap: anywhere; hyphens: auto; font-size: var(--font-size-base); font-weight: var(--weight-bold); text-align: center; color: var(--text-primary); }
.ds-station-tile__subtitle { font-size: var(--font-size-sm); color: var(--text-muted); text-align: center; font-weight: var(--weight-medium); }
.ds-station-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 560px) { .ds-station-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }
@media (hover: none) { .ds-station-tile:hover { transform: none; box-shadow: none; } }

/* ═══════════════════════════════════════════════════════════════════
 * Station tile and grid modifiers (Phase C hub)
 * ═══════════════════════════════════════════════════════════════════ */

/* The station tile wears its colour as a map: an accent edge on top, the
   accent on hover, and the icon drawn in it (components.css). */
.ds-station-tile { border-top: 4px solid var(--ds-station-accent, var(--border-color)); }
.ds-station-tile__icon { color: var(--ds-station-accent, var(--neon-blue)); }
.ds-station-tile:hover { border-color: var(--ds-station-accent, var(--border-glow)); }
.ds-station-tile:focus-visible {
  outline: none;
  border-color: var(--ds-station-accent, var(--neon-blue));
  box-shadow: var(--shadow-focus);
}

/* The one recommended station on the screen: lit in its own colour, with a
   slow breath so a child's eye finds it first. */
.ds-station-tile--primary {
  border-color: var(--ds-station-accent);
  box-shadow: 0 0 24px color-mix(in srgb, var(--ds-station-accent) 35%, transparent);
  animation: station-breathe 2.4s ease-in-out infinite;
}
.ds-station-tile--primary .ds-station-tile__label { color: var(--ds-station-accent); }

@keyframes station-breathe {
  0%, 100% { box-shadow: 0 0 14px color-mix(in srgb, var(--ds-station-accent) 25%, transparent); }
  50%      { box-shadow: 0 0 30px color-mix(in srgb, var(--ds-station-accent) 50%, transparent); }
}

/* Five stations as 3 + 2, the bottom pair centred (2 + 2 + 1 on a phone,
   the last one centred). Six (four) tracks, every tile spans two. */
/* Four stations (a kit run has no Hackerterminal): two by two. */
.ds-station-grid--four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ds-station-grid--five { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.ds-station-grid--five > * { grid-column: span 2; }
.ds-station-grid--five > :nth-child(4) { grid-column: 2 / span 2; }
@media (max-width: 560px) {
  .ds-station-grid--five { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ds-station-grid--five > :nth-child(4) { grid-column: auto / span 2; }
  .ds-station-grid--five > :nth-child(5) { grid-column: 2 / span 2; }
}

@media (prefers-reduced-motion: reduce) {
  .ds-station-tile--primary { animation: none; }
}
