/* Solver factory: shared base styles. Game colours come from site.json (inline :root in <head>). */

:root {
  --font-display: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Nunito", "Quicksand", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --board-ink: #2b2145;
  --radius-lg: 22px;
  --radius-md: 14px;
  --gutter: 16px;
  --shadow-press: 0 3px 0 var(--ink);
  color-scheme: light dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { max-width: 100%; }
a { color: inherit; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

h1, h2, h3 { font-family: var(--font-display); line-height: 1.1; margin: 0 0 .5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(2.1rem, 8.5vw, 3.6rem); font-weight: 800; letter-spacing: -0.025em; }
h2 { font-size: clamp(1.45rem, 4.5vw, 1.95rem); font-weight: 800; }
h3 { font-size: 1.2rem; font-weight: 700; }
p { margin: 0 0 1em; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }

/* ---------- header / footer ---------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 72rem; margin: 0 auto; padding: 14px var(--gutter);
}
.wordmark { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font: 800 1.15rem/1 var(--font-display); }
.wordmark-mark { width: 34px; height: 34px; color: var(--ink); }
/* Brand marks are drawn in --ink, which turns light in dark mode. The piece's eyes read
   --piece-eye (a light default), so flip it to the page colour or the face disappears.
   Pieces on the board keep the fixed --board-ink and don't need this. */
@media (prefers-color-scheme: dark) {
  .wordmark-mark, .not-found svg { --piece-eye: var(--paper); }
}
.site-nav { display: flex; gap: 4px; }
.site-nav a { text-decoration: none; padding: 8px 12px; border-radius: 999px; font: 600 .95rem/1 var(--font-display); }
.site-nav a:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.site-nav a:first-child { display: none; }
@media (min-width: 640px) { .site-nav a:first-child { display: inline-block; } }

main { max-width: 72rem; margin: 0 auto; padding: 0 var(--gutter) 56px; }

.site-footer {
  max-width: 72rem; margin: 0 auto; padding: 28px var(--gutter) 40px;
  border-top: 2px dashed var(--line); color: var(--muted); font-size: .9rem;
}
.site-footer p { margin: 0 0 .5em; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 18px; }

/* ---------- buttons ---------- */
.btn {
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px; border-radius: 999px;
  font: 700 1rem/1 var(--font-display); cursor: pointer; text-decoration: none;
  border: 2px solid var(--ink); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-press);
  transition: transform .08s ease, box-shadow .08s ease, background-color .15s ease;
  touch-action: manipulation;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: var(--shadow-press); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-quiet { border-color: var(--line); box-shadow: none; background: transparent; }
.btn-quiet:active { box-shadow: none; }
.btn-small { min-height: 38px; padding: 0 14px; font-size: .92rem; }
.linklike { background: none; border: 0; padding: 4px 0; font: inherit; color: inherit; text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; cursor: pointer; }

/* ---------- home: hero + stage ---------- */
.hero { display: grid; gap: 28px; padding-top: 8px; }
.hero-copy { max-width: 34rem; }
.hero-copy .lede { font-size: 1.15rem; color: var(--muted); max-width: 32rem; }
@media (min-width: 920px) {
  .hero { grid-template-columns: minmax(0, 1fr) minmax(0, 31rem); align-items: start; gap: 56px; padding-top: 40px; }
  .hero-copy { position: sticky; top: 24px; }
}

.drop {
  position: relative; display: grid; justify-items: start; gap: 10px;
  margin: 22px 0 10px; padding: 22px 20px;
  border: 2.5px dashed color-mix(in srgb, var(--ink) 30%, transparent);
  border-radius: var(--radius-lg); background: var(--surface);
  transition: border-color .15s ease, background-color .15s ease;
}
.drop.is-over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.drop-hint { color: var(--muted); font-size: .95rem; margin: 0; }
.drop input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.draw-instead { margin-top: 2px; }
.privacy-note { font-size: .88rem; color: var(--muted); margin-top: 14px; }

.stage { min-width: 0; }
.stage-label { font: 700 .95rem/1.3 var(--font-display); color: var(--muted); margin: 0 0 10px; }

.status {
  display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: var(--radius-lg);
  background: var(--surface); border: 2px solid var(--line);
}
.status img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 2px solid var(--line); }
.status p { margin: 0; font-weight: 600; }
.status .error-text { font-weight: 400; color: var(--muted); }
.spinner { width: 28px; height: 28px; flex: none; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-box { display: grid; gap: 12px; padding: 18px; border-radius: var(--radius-lg); background: var(--surface); border: 2px solid var(--accent); }
.error-box p { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.notice { padding: 10px 14px; border-radius: var(--radius-md); background: color-mix(in srgb, var(--focus) 28%, var(--surface)); font-size: .95rem; margin: 0 0 12px; }
.notice-redirect p { margin: 0 0 8px; }
.notice-redirect p:last-child { margin: 0; }

/* ---------- feedback ---------- */
.feedback { margin-top: 18px; padding-top: 16px; border-top: 2px dashed var(--line); }
.feedback-ask { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.feedback-ask p { flex: 1 1 100%; margin: 0; font: 700 1rem/1.3 var(--font-display); }
@media (min-width: 520px) { .feedback-ask p { flex: 0 1 auto; margin-right: auto; } }
.thumb { min-width: 64px; }
.thumb[aria-pressed="true"] { background: var(--accent); }
.feedback-form { display: grid; gap: 12px; margin-top: 14px; padding: 16px; border-radius: var(--radius-md); background: var(--surface); border: 2px solid var(--line); }
.feedback-form fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 6px; }
.feedback-form legend { font: 700 1rem/1.3 var(--font-display); margin-bottom: 6px; padding: 0; }
.feedback-form label.choice { display: flex; gap: 10px; align-items: center; min-height: 36px; cursor: pointer; }
.feedback-form input[type=radio] { width: 20px; height: 20px; accent-color: var(--accent); }
.feedback-form textarea {
  width: 100%; min-height: 84px; padding: 10px 12px; border-radius: 12px; resize: vertical;
  border: 2px solid var(--line); background: var(--paper); color: var(--ink); font: inherit;
}
.feedback-form textarea:focus { border-color: var(--ink); outline: none; }
.feedback-thanks { margin: 10px 0 0; font-weight: 600; }

/* ---------- below the fold ---------- */
.explainer { margin-top: 64px; display: grid; gap: 28px; }
@media (min-width: 820px) { .explainer { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 36px; } }
.explainer h2 { grid-column: 1 / -1; margin: 0; }
.explainer h3 { margin-bottom: .35em; }
.explainer p { color: var(--muted); margin: 0; }

/* ---------- prose pages ---------- */
.prose { max-width: 42rem; padding-top: 16px; }
.prose h1 { font-size: clamp(2rem, 7vw, 3rem); }
.prose h2 { margin-top: 1.8em; }
.prose p, .prose li { line-height: 1.65; }
.prose .lede { font-size: 1.15rem; color: var(--muted); }
.prose ul, .prose ol { padding-left: 1.3em; }
.rules-box { padding: 16px 18px; border-radius: var(--radius-md); background: var(--surface); border: 2px solid var(--line); }
.rules-box ul { margin: 0; }
.prose .rules-box h2 { margin-top: 0; }
.cta-row { margin: 28px 0; }

.diagram { margin: 18px 0 22px; display: grid; justify-items: start; gap: 8px; }
.diagram svg { width: min(100%, 236px); height: auto; border-radius: 10px; }
.diagram figcaption { font-size: .92rem; color: var(--muted); max-width: 30rem; }
.diagram-pair { display: flex; flex-wrap: wrap; gap: 0 24px; }
.dg-grid { stroke: rgba(43, 33, 69, .2); stroke-width: 1; fill: none; }
.dg-wall { stroke: var(--board-ink); stroke-width: 2.6; fill: none; stroke-linecap: square; stroke-linejoin: round; }
.dg-x { stroke: var(--board-ink); stroke-width: 2.4; stroke-linecap: round; opacity: .75; }
.dg-focus { fill: none; stroke: #e0a100; stroke-width: 3; }
.dg-cat { color: var(--board-ink); }

.faq { display: grid; gap: 10px; }
.faq-item { border: 2px solid var(--line); border-radius: var(--radius-md); background: var(--surface); padding: 0 16px; }
.faq-item summary { cursor: pointer; padding: 14px 0; font: 700 1.02rem/1.35 var(--font-display); list-style-position: outside; }
.faq-item p { margin: 0 0 14px; color: var(--muted); }

.not-found { text-align: center; padding: 64px 0; }
.not-found svg { width: 96px; height: 96px; color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
