/* ============================================================
   Whiteout Exercise — participant-facing styles
   Mobile-first, no framework. White / arctic palette.
   ============================================================ */

:root {
  --color-bg:        #ffffff;
  --color-surface:   #f8f8f7;
  --color-border:    #e5e5e3;
  --color-border-h:  #c8c8c5;
  --color-text:      #111111;
  --color-muted:     #6b6b6b;
  --color-primary:   #111111;
  --color-primary-h: #333333;
  --color-error:     #c0392b;
  --color-error-bg:  #fef2f2;
  --color-success:   #16a34a;
  --color-success-bg:#f0fdf4;
  --color-warn:      #b45309;
  --color-warn-bg:   #fffbeb;
  --color-info-bg:   #f0f4ff;
  --color-info:      #3b5bdb;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;

  --shadow-sm:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-card: 0 4px 16px rgba(0,0,0,.07), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg:   0 12px 40px rgba(0,0,0,.10);

  --font:       system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-story: Georgia, "Times New Roman", serif;

  --max-w: 620px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100dvh;
}

/* Snow canvas sits at z-index:0; push all real content above it */
main, footer {
  position: relative;
  z-index: 1;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .4rem;
  padding: .65rem 1.5rem;
  border: none; border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .95rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: background .12s, transform .08s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }

.btn-primary  { background: var(--color-primary); color: #fff; }
.btn-primary:hover  { background: var(--color-primary-h); }

.btn-secondary {
  background: transparent; color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
}
.btn-secondary:hover { background: rgba(0,0,0,.04); }

.btn-ghost {
  background: transparent; color: var(--color-muted);
  border: 1.5px solid var(--color-border);
}
.btn-ghost:hover { border-color: var(--color-border-h); color: var(--color-text); }

.btn-large { padding: .85rem 2rem; font-size: 1.05rem; }
.btn-full  { width: 100%; }
.btn:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }

/* ── Alerts ── */
.alert {
  padding: .8rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  font-size: .9rem;
  border-left: 3px solid;
}
.alert-error   { background: var(--color-error-bg);   color: var(--color-error);   border-color: var(--color-error); }
.alert-success { background: var(--color-success-bg); color: var(--color-success); border-color: var(--color-success); }
.alert-warn    { background: var(--color-warn-bg);    color: var(--color-warn);    border-color: var(--color-warn); }
.alert-info    { background: var(--color-info-bg);    color: var(--color-info);    border-color: var(--color-info); }

/* ── Form fields ── */
.field { margin-bottom: 1.25rem; }
.field label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .9rem; }

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: .6rem .85rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: .95rem;
  background: #fff;
  color: var(--color-text);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(17,17,17,.08);
}
.hint { color: var(--color-muted); font-size: .85rem; margin-top: .25rem; }

/* ============================================================
   Welcome page
   ============================================================ */
.page-welcome .container {
  display: flex; align-items: center; justify-content: center;
  min-height: 100dvh;
}

.welcome-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 2.75rem 2.25rem;
  text-align: center;
  max-width: 460px;
  width: 100%;
}

.welcome-logo {
  display: block;
  margin: 0 auto 1.5rem;
  width: 200px;
  height: auto;
}
.study-subtitle {
  color: var(--color-muted);
  font-size: .95rem;
  margin-bottom: 1.75rem;
}
.consent-text {
  text-align: left;
  font-size: .875rem;
  color: var(--color-muted);
  margin-bottom: 2rem;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 0;
}
.consent-text p + p { margin-top: .55rem; }
.welcome-footer {
  margin-top: 1.25rem;
  font-size: .82rem;
  color: var(--color-muted);
}
.welcome-footer a {
  color: var(--color-muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.welcome-footer a:hover { color: var(--color-text); border-color: currentColor; }

/* ============================================================
   Form card (join page etc.)
   ============================================================ */
.form-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 2rem 1.75rem;
  max-width: 400px;
  margin: 3rem auto;
}
.form-card h1 { font-size: 1.4rem; margin-bottom: .35rem; letter-spacing: -.01em; }
.form-card .sub { color: var(--color-muted); font-size: .9rem; margin-bottom: 1.5rem; }

/* Code input */
.code-input {
  text-transform: uppercase;
  letter-spacing: .2em;
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
}

/* ============================================================
   Waiting page
   ============================================================ */
.page-waiting .container {
  display: flex; align-items: center; justify-content: center;
  min-height: 100dvh;
}

.wait-card {
  text-align: center;
  max-width: 420px;
}

.wait-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: 1.75rem;
  margin-bottom: 1.5rem;
}

.wait-card h1 { font-size: 1.3rem; margin-bottom: .5rem; }
.wait-card p  { color: var(--color-muted); font-size: .95rem; }

.pulse-dots {
  display: inline-flex; gap: .35rem;
  margin-top: 1.5rem;
}
.pulse-dots span {
  display: block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--color-border-h);
  animation: pulse 1.4s ease-in-out infinite;
}
.pulse-dots span:nth-child(2) { animation-delay: .2s; }
.pulse-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes pulse {
  0%, 80%, 100% { transform: scale(.8); opacity: .5; }
  40% { transform: scale(1); opacity: 1; }
}

/* ============================================================
   Rank page — drag-and-drop
   ============================================================ */
.page-rank .container { max-width: 680px; }

.scenario-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
.scenario-card summary {
  font-weight: 600;
  font-size: .92rem;
  cursor: pointer;
  color: var(--color-text);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.scenario-card summary::after {
  content: '▾';
  font-size: .75rem;
  color: var(--color-muted);
  transition: transform .2s;
}
.scenario-card[open] summary::after { transform: rotate(-180deg); }
.scenario-card summary::-webkit-details-marker { display: none; }

.scenario-body {
  margin-top: 1rem;
  font-family: var(--font-story);
  font-size: .9rem;
  line-height: 1.75;
  color: var(--color-text);
}
.scenario-body p + p { margin-top: .75rem; }
.scenario-kicker {
  font-family: var(--font);
  font-size: .82rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--color-muted);
  font-style: normal;
  margin-bottom: .6rem;
  display: block;
}
.scenario-conditions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .5rem;
  margin: 1rem 0;
  font-family: var(--font);
  font-size: .82rem;
}
.scenario-condition {
  display: flex; align-items: center; gap: .4rem;
  padding: .45rem .65rem;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
}
.scenario-condition .ci { font-size: .95rem; }

.rank-instruction {
  font-size: .9rem;
  color: var(--color-muted);
  margin-bottom: 1rem;
}
.rank-instruction strong { color: var(--color-text); }

.rank-list {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  margin-bottom: 1.25rem;
}

.rank-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem .85rem .7rem .65rem;
  background: #fff;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  cursor: grab;
  user-select: none;
  transition: box-shadow .12s, border-color .12s, transform .1s;
  touch-action: none;
}
.rank-item:hover { border-color: var(--color-border-h); box-shadow: var(--shadow-sm); }
.rank-item.sortable-chosen {
  box-shadow: var(--shadow-lg);
  border-color: var(--color-border-h);
  background: var(--color-surface);
  cursor: grabbing;
}
.rank-item.sortable-ghost { opacity: .35; }

.rank-num {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.rank-letter {
  flex-shrink: 0;
  width: 20px;
  font-size: .72rem;
  font-weight: 700;
  color: var(--color-muted);
  text-align: center;
}
.rank-label {
  flex: 1;
  font-size: .875rem;
  line-height: 1.4;
  color: var(--color-text);
}
.item-qty {
  font-size: .78rem;
  color: var(--color-muted);
  font-weight: 400;
}
.drag-handle {
  flex-shrink: 0;
  color: var(--color-border-h);
  font-size: 1rem;
  line-height: 1;
}

.rank-submit { text-align: center; padding-bottom: 1.5rem; }

/* ============================================================
   Group rank page
   ============================================================ */
.page-group .container { max-width: 680px; }

.group-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .35rem;
  flex-wrap: wrap;
}
.group-header h1 { font-size: 1.3rem; letter-spacing: -.01em; }
.sync-status {
  font-size: .8rem;
  color: var(--color-muted);
}
.sync-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--color-border-h);
  margin-right: .3rem;
  vertical-align: middle;
}
.sync-dot.live { background: var(--color-success); }

/* ============================================================
   Reveal page
   ============================================================ */
.page-reveal .container { max-width: 720px; }

.score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .75rem;
  margin-bottom: 1.5rem;
}
.score-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.score-card__label {
  font-size: .75rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-bottom: .35rem;
}
.score-card__value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--color-text);
  margin-bottom: .25rem;
}
.score-card__band {
  font-size: .8rem;
  font-weight: 600;
}
.band-excellent { color: #16a34a; }
.band-good      { color: #2563eb; }
.band-average   { color: #b45309; }
.band-poor      { color: #c0392b; }

.reveal-section {
  margin-bottom: 2rem;
}
.reveal-section h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: .75rem;
  padding-bottom: .5rem;
  border-bottom: 1.5px solid var(--color-border);
  letter-spacing: -.01em;
}

.item-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.item-table th {
  text-align: left;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-muted);
  padding: .4rem .6rem;
  border-bottom: 1.5px solid var(--color-border);
}
.item-table td {
  padding: .55rem .6rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.item-table tr:last-child td { border-bottom: none; }
.item-table .td-rank { text-align: center; font-weight: 700; }
.item-table .td-diff { text-align: center; font-weight: 700; font-size: .8rem; }
.diff-ok   { color: #16a34a; }
.diff-mid  { color: #b45309; }
.diff-bad  { color: #c0392b; }
.trap-badge {
  display: inline-block;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #c0392b;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 3px;
  padding: .05rem .35rem;
  margin-left: .4rem;
  vertical-align: middle;
}

.benchmark-list {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.benchmark-item {
  display: flex;
  gap: .75rem;
  padding: .85rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.benchmark-item.is-trap {
  background: #fef9f9;
  border-color: #fca5a5;
}
.bm-rank {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: .78rem;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.benchmark-item.is-trap .bm-rank { background: #c0392b; }
.bm-body { flex: 1; min-width: 0; }
.bm-label {
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: .3rem;
  display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
}
.bm-letter {
  font-size: .72rem; font-weight: 700;
  color: var(--color-muted);
}
.bm-rationale {
  font-size: .82rem;
  color: var(--color-muted);
  line-height: 1.55;
}

.improvement-banner {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: .5rem;
}
.improvement-banner--win {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid #bbf7d0;
}
.improvement-banner--lose {
  background: var(--color-surface);
  color: var(--color-muted);
  border: 1px solid var(--color-border);
}

/* ============================================================
   Second stage
   ============================================================ */
.second-stage-card {
  background: var(--color-info-bg);
  border: 1px solid #c7d7ff;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
.second-stage-card h2 {
  font-size: 1rem;
  margin-bottom: .3rem;
}
.second-stage-card .scenario-snippet {
  font-family: var(--font-story);
  font-size: .875rem;
  color: var(--color-muted);
  margin-bottom: 1rem;
  font-style: italic;
  line-height: 1.6;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  margin-bottom: .85rem;
}
.choice-option {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  padding: .75rem 1rem;
  background: #fff;
  border: 1.5px solid #c7d7ff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .12s;
  -webkit-tap-highlight-color: transparent;
}
.choice-option input { display: none; }
.choice-option.is-selected,
.choice-option:has(input:checked) {
  border-color: var(--color-info);
  background: #eef2ff;
}
.choice-option__title { font-size: .875rem; font-weight: 600; }
.choice-option__desc  { font-size: .78rem; color: var(--color-muted); }

.ss-reveal {
  background: var(--color-success-bg);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  font-size: .875rem;
}
.ss-reveal strong { color: var(--color-success); }
.ss-answer-wrong {
  background: var(--color-warn-bg);
  border-color: #fde68a;
}
.ss-answer-wrong strong { color: var(--color-warn); }

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  margin-top: 3rem;
  padding: 1.25rem 1rem 1.75rem;
  border-top: 1px solid var(--color-border);
  text-align: center;
  font-size: .78rem;
  color: var(--color-muted);
}
.site-footer nav {
  display: flex; flex-wrap: wrap;
  align-items: center; justify-content: center;
  gap: .35rem .5rem;
  margin-bottom: .4rem;
}
.site-footer a { color: var(--color-muted); text-decoration: none; }
.site-footer a:hover { color: var(--color-text); text-decoration: underline; }
.site-footer__meta { font-size: .72rem; opacity: .8; }

/* Welcome page: nudge footer links to be subtler in the centered layout */
.page-welcome .site-footer { margin-top: 1.5rem; border-top: none; }

/* ============================================================
   Legal page
   ============================================================ */
.page-legal .container { max-width: 860px; }
.legal-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.legal-section h1 { font-size: 1.5rem; margin-bottom: .3rem; font-family: var(--font-story); }
.legal-section h2 { font-size: 1.1rem; margin: 1.25rem 0 .5rem; }
.legal-section p, .legal-section li { font-size: .9rem; color: #444; line-height: 1.7; }
.legal-section p + p { margin-top: .6rem; }
.legal-section ul { margin: .5rem 0 .5rem 1.25rem; }
.legal-section li + li { margin-top: .3rem; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 480px) {
  .choice-grid { grid-template-columns: 1fr; }
  .score-grid  { grid-template-columns: 1fr 1fr; }
  .item-table .td-rat { display: none; }
  .welcome-card { padding: 2rem 1.25rem; }
}
