/* SANDTRIX — styles.css
   Retro-arcade, dark only. Tokens, header, buttons, toasts and footer
   mirror ../sandfall/styles.css and ../serpent/styles.css; the
   hold | board | next layout and the touch pad are Sandtrix-specific. */

/* ---------- fonts (self-hosted, shared with the lab root) ---------- */

@font-face { font-family: "Press Start 2P"; font-style: normal; font-weight: 400; font-display: swap; src: url("/press-start-2p.woff2") format("woff2"); }
@font-face { font-family: "Press Start 2P Fallback"; src: local("Courier New"); size-adjust: 166.64%; ascent-override: 60%; descent-override: 0%; line-gap-override: 0%; }

/* ---------- tokens ---------- */

:root {
  --bg: #0a0a12;
  --surface: #12121d;
  --surface-2: #1a1a2a;
  --line: #28283c;
  --text: #e9e9f2;
  --dim: #9aa0b5;
  --cyan: #45f0ff;
  --magenta: #ff3d8b;
  --gold: #ffc857;
  --green: #41ff8b;
  --red: #ff5560;
  --board-bg: #0d0d16;

  --pixel: "Press Start 2P", "Press Start 2P Fallback", "Courier New", monospace;
  --body: -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;

  --radius: 8px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --glow-cyan: 0 0 14px rgba(69, 240, 255, 0.35);
  --space-gutter: clamp(16px, 4vw, 48px);
  --side-w: 76px;
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(255, 200, 87, 0.05), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(255, 200, 87, 0.3); }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px; top: -48px;
  z-index: 200;
  background: var(--cyan);
  color: #05050d;
  padding: 10px 16px;
  border-radius: 6px;
  font-family: var(--mono);
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.2s var(--ease-out);
}
.skip-link:focus-visible { transform: translateY(60px); }

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(69, 240, 255, 0.15);
}

a { color: var(--cyan); }

kbd {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text);
}

/* ---------- header ---------- */

.site-header {
  padding: 26px var(--space-gutter) 10px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.lab-link {
  align-self: flex-start;
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--dim);
  text-decoration: none;
  padding: 6px 2px;
  transition: color 0.15s, text-shadow 0.15s;
}
.lab-link:hover { color: var(--cyan); text-shadow: var(--glow-cyan); }

.level {
  margin: 0;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--gold);
}

.wordmark {
  margin: 6px 0 4px;
  font-family: var(--pixel);
  font-size: clamp(22px, 4.5vw, 34px);
  letter-spacing: 3px;
  color: var(--text);
  text-shadow: 0 0 16px rgba(255, 200, 87, 0.55), 3px 3px 0 var(--magenta);
}

.tagline {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--dim);
}

.cursor { color: var(--gold); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- layout ---------- */

main {
  flex: 1;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 16px var(--space-gutter) 72px;
}

.game-panel { display: flex; flex-direction: column; gap: 12px; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.chip-row, .action-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- buttons ---------- */

.btn, .chip {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.12s var(--ease-out), border-color 0.12s, box-shadow 0.12s, color 0.12s;
}

.btn {
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
}
.btn:hover, .chip:hover { border-color: var(--cyan); box-shadow: 0 0 12px rgba(69, 240, 255, 0.22); transform: translateY(-1px); }
.btn:active, .chip:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary { background: var(--gold); border-color: var(--gold); color: #1a1205; }
.btn-primary:hover { border-color: var(--gold); box-shadow: 0 0 18px rgba(255, 200, 87, 0.5); }
.btn-ghost { background: transparent; }
.btn-big { font-family: var(--pixel); font-size: 11px; padding: 14px 20px; }

.chip {
  padding: 8px 14px;
  background: var(--bg);
  color: var(--dim);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.chip.is-active, .btn.is-active {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(255, 200, 87, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 200, 87, 0.35);
}

/* ---------- play layout: hold | board | next ---------- */

.play-layout {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr) var(--side-w);
  gap: 8px;
  align-items: start;
}

.side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.preview-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* Narrow side columns: the pixel font would need 6–7px type to fit the
   longest Turkish labels (SIRADAKİ, TEMİZLEME), so they use the bold mono
   face at 9–10px until the columns widen at 720px. */
.preview-title {
  margin: 0;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--gold);
  text-shadow: 0 0 8px rgba(255, 200, 87, 0.4);
  overflow-wrap: anywhere;
}

.preview-box { display: flex; flex-direction: column; gap: 4px; }

.preview {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 5 / 3;
  background: var(--board-bg);
  border-radius: 4px;
  image-rendering: pixelated;
}

.hud { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.hud > div {
  min-width: 0;
  padding: 8px 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.hud dt {
  margin-bottom: 6px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--dim);
  overflow-wrap: anywhere;
}
.hud dd {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(0.78rem, 2.6vw, 1.15rem);
  font-weight: 700;
  color: var(--gold);
  overflow-wrap: anywhere;
}
.hud .is-hot dd { color: var(--magenta); text-shadow: 0 0 10px rgba(255, 61, 139, 0.6); }

.board-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  min-width: 0;
  padding: 6px;
  background: linear-gradient(180deg, var(--surface), rgba(18, 18, 29, 0.5));
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: inset 0 0 32px rgba(255, 200, 87, 0.05);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.board-wrap.is-danger {
  border-color: var(--red);
  box-shadow: inset 0 0 32px rgba(255, 85, 96, 0.08), 0 0 18px rgba(255, 85, 96, 0.25);
}
.board-wrap.is-shaking { animation: shake 0.28s steps(4) 1; }
@keyframes shake {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3px, 1px); }
  50% { transform: translate(3px, -1px); }
  75% { transform: translate(-2px, 0); }
  100% { transform: translate(0, 0); }
}

#board {
  display: block;
  width: 180px;
  height: 360px;
  background: var(--board-bg);
  border-radius: 2px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

/* ---------- overlay ---------- */

.overlay {
  position: absolute;
  inset: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 10px;
  text-align: center;
  border-radius: 4px;
  background: rgba(10, 10, 18, 0.84);
  backdrop-filter: blur(2px);
}

.overlay-title {
  margin: 0;
  font-family: var(--pixel);
  font-size: clamp(10px, 2.8vw, 22px);
  letter-spacing: 1px;
  color: var(--gold);
  text-shadow: 0 0 16px rgba(255, 200, 87, 0.55), 2px 2px 0 var(--magenta);
}
.overlay[data-phase="paused"] .overlay-title { color: var(--cyan); text-shadow: 0 0 16px rgba(69, 240, 255, 0.55), 2px 2px 0 var(--magenta); }
.overlay[data-phase="over"] .overlay-title { color: var(--red); text-shadow: 0 0 16px rgba(255, 85, 96, 0.55), 2px 2px 0 var(--magenta); }

.overlay-sub {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-wrap: balance;
  color: var(--dim);
}

.overlay-final {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
}
.final-badge { margin-top: 6px; font-family: var(--pixel); font-size: 10px; letter-spacing: 1px; color: var(--gold); }

.overlay .btn-big { font-size: 9px; padding: 12px; }

/* ---------- touch pad ---------- */

.pad { display: none; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

.pad-btn {
  min-height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--cyan);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.1s var(--ease-out), border-color 0.12s, background 0.12s;
}
.pad-btn:hover { border-color: var(--cyan); }
.pad-btn:active, .pad-btn.is-down { transform: scale(0.95); background: rgba(69, 240, 255, 0.12); }
.pad-hold { font-family: var(--pixel); font-size: 9px; color: var(--gold); }
.pad-hard { color: var(--magenta); }

@media (pointer: coarse), (max-width: 720px) {
  .pad { display: grid; }
}

.status {
  min-height: 24px;
  margin: 0;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 13px;
  text-align: center;
}

/* ---------- rules panel ---------- */

.panel {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.panel-title {
  margin: 0;
  font-family: var(--pixel);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--gold);
  text-shadow: 0 0 8px rgba(255, 200, 87, 0.4);
}

.rules-list {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--dim);
  font-size: 14px;
}

.keys {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 8px 18px;
}
.keys > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.keys dt { color: var(--text); }
.keys dd { margin: 0; color: var(--dim); font-size: 13px; }

.note { margin: 0; color: var(--dim); font-size: 13px; }

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--cyan);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.22s var(--ease-out) both;
}
.toast-error { border-left-color: var(--red); }
.toast-success { border-left-color: var(--green); }
.toast.out, .toast.toast--out { opacity: 0; transform: translateY(6px); transition: opacity 0.25s, transform 0.25s; }

@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 22px var(--space-gutter);
  text-align: center;
  color: var(--dim);
  font-size: 13px;
}
.site-footer p { margin: 4px 0; }
.site-footer a { color: var(--cyan); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; text-shadow: var(--glow-cyan); }

/* ---------- responsive ---------- */

@media (min-width: 720px) {
  :root { --side-w: 150px; }
  .play-layout { gap: 16px; }
  .preview-title, .hud dt { font-family: var(--pixel); font-weight: 400; }
  .preview-title { font-size: 9px; letter-spacing: 1px; }
  .hud > div { padding: 8px 6px; }
  .hud dt { font-size: 8px; letter-spacing: 1px; }
  .overlay .btn-big { font-size: 11px; padding: 14px 20px; }
}

@media (max-width: 480px) {
  .overlay-sub { font-size: 10px; letter-spacing: 1px; }
}

@media (max-width: 360px) {
  :root { --side-w: 64px; }
  .preview-card { padding: 6px; }
  .preview-title, .hud dt { font-size: 9px; letter-spacing: 0; }
  .wordmark { letter-spacing: 1px; }
}

/* ---------- reduced motion: kill looping and decorative motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .cursor { animation: none; }
  .board-wrap.is-shaking { animation: none; }
}
