/**
 * sudocube-play.css — the playable cube at /sudocube/puzzle.
 *
 * Deliberately shares the explorer's dark "backlit light-table" language (same
 * custom properties, same paper grid, same axis colours) so the two pages read as
 * one product. What is new here is cell STATE: given vs entered vs hinted vs
 * conflicting, plus the cursor and its peers.
 *
 * Standalone stylesheet, not Tailwind — the app.css bundle is purged, and none of
 * these classes exist anywhere else to keep them alive.
 */

:root {
  --bg: #0b1316; --panel: #111e23; --panel2: #172830; --line: #24373f;
  --ink: #e9eff1; --muted: #7e949c; --faint: #56676e;
  --paper: #f3eee1; --paper-line: #d7ccb6; --paper-box: #0c1316; --digit: #1d262b;
  --x: #ef7d57; --y: #54c08a; --z: #4fa3e3;
  --accent: var(--z);
  --entered: #1668a8;
  --bad: #c0392b;
  --r: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  background: radial-gradient(1200px 600px at 80% -10%, #14262e 0%, transparent 60%), var(--bg);
  color: var(--ink);
  font-family: "Space Grotesk", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding: clamp(12px, 3vw, 34px);
}

.wrap { max-width: 1080px; margin: 0 auto; }

header {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 22px;
  border-bottom: 1px solid var(--line); padding-bottom: 16px;
}
.title { display: flex; flex-direction: column; gap: 3px; }
.eyebrow {
  font-family: "IBM Plex Mono", monospace; font-size: 11px; letter-spacing: .32em;
  text-transform: uppercase; color: var(--faint);
}
h1 { font-size: clamp(21px, 3.4vw, 32px); font-weight: 600; margin: 0; letter-spacing: -.01em; }
h1 b { font-weight: 700; }
.lede { color: var(--muted); font-size: 13.5px; max-width: 46ch; line-height: 1.5; margin: 0; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }

/* ------------------------------------------------------------- progress -- */

.progress { margin-left: auto; min-width: 200px; }
.progress-track {
  height: 6px; border-radius: 999px; background: var(--panel2);
  border: 1px solid var(--line); overflow: hidden;
}
.progress-track i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.progress-meta {
  display: flex; justify-content: space-between; gap: 12px; margin-top: 6px;
  font-family: "IBM Plex Mono", monospace; font-size: 11.5px; color: var(--muted);
}

/* ---------------------------------------------------------------- stage -- */

.stage { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 24px; align-items: start; margin-top: 18px; }
@media (max-width: 860px) { .stage { grid-template-columns: 1fr; } }
.gridcol { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.gridwrap {
  position: relative; padding: 8px; border-radius: var(--r);
  background: rgba(12, 19, 22, .42); border: 1px solid var(--line);
}
.gridwrap::before {
  content: ""; position: absolute; inset: -18%; z-index: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 46%, var(--accent) 0%, transparent 60%);
  filter: blur(42px); opacity: .5; transition: background .35s, opacity .35s;
}
.gridstack {
  position: relative; z-index: 1; aspect-ratio: 1; border-radius: 6px; overflow: hidden;
  box-shadow: 0 0 52px -12px var(--accent), 0 18px 40px -22px #000; transition: box-shadow .35s;
}

.grid {
  position: relative; z-index: 1; display: grid; height: 100%;
  grid-template-columns: repeat(9, 1fr); grid-template-rows: repeat(9, 1fr);
  background: rgba(243, 238, 225, .93);
  backdrop-filter: blur(4px) saturate(1.15); -webkit-backdrop-filter: blur(4px) saturate(1.15);
}
.grid:focus { outline: none; }
.grid:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ----------------------------------------------------------------- cells -- */

.cell {
  display: flex; align-items: center; justify-content: center;
  font-family: "IBM Plex Mono", monospace;
  font-size: clamp(15px, 3.6vw, 25px); color: var(--digit);
  border-right: 1px solid var(--paper-line); border-bottom: 1px solid var(--paper-line);
  position: relative; cursor: pointer; user-select: none;
  transition: background .12s;
}
.cell.br { border-bottom: 2px solid var(--paper-box); }
.cell.bc { border-right: 2px solid var(--paper-box); }
.cell.edge-b { border-bottom: 0; }
.cell.edge-c { border-right: 0; }

/* State. A given is the puzzle; an entry is yours; a hint is yours but revealed. */
.cell.given   { font-weight: 700; color: var(--digit); }
.cell.entered { font-weight: 500; color: var(--entered); }
.cell.hinted  { font-weight: 500; color: var(--entered); font-style: italic; }
.cell.hinted::after {
  content: ""; position: absolute; right: 3px; top: 3px;
  width: 4px; height: 4px; border-radius: 50%; background: var(--entered); opacity: .55;
}

/* Peers first, then cursor, then conflict — most urgent wins. */
.cell.peer   { background: rgba(79, 163, 227, .13); }
.cell.same   { background: #fbe7b0; }
.cell.cursor { background: #cfe6f7; box-shadow: inset 0 0 0 2px var(--accent); z-index: 2; }
.cell.conflict { color: var(--bad); background: rgba(192, 57, 43, .16); }
.cell.conflict.cursor { background: rgba(192, 57, 43, .28); }
.cell:hover:not(.cursor) { background: #ece4d2; }

@keyframes sc-nope {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}
.cell.nope { animation: sc-nope .22s ease; }

/* pencil marks */
.marks {
  position: absolute; inset: 1px; display: grid;
  grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  font-size: 9px; line-height: 1; color: #7d786c; font-style: normal;
}
.marks i { display: flex; align-items: center; justify-content: center; font-style: normal; }

/* slice-complete flash — on-brand, in place of puzzle-fx.js's Kokoro hearts */
@keyframes sc-done {
  0% { box-shadow: 0 0 52px -12px var(--accent), 0 18px 40px -22px #000; }
  35% { box-shadow: 0 0 0 3px var(--y), 0 0 90px -4px var(--y); }
  100% { box-shadow: 0 0 52px -12px var(--accent), 0 18px 40px -22px #000; }
}
.gridstack.slice-done { animation: sc-done 1.1s ease; }
body.cube-complete .gridwrap::before { opacity: .95; }

/* ------------------------------------------------------------------ side -- */

.side { display: flex; flex-direction: column; gap: 16px; }
.cube-card { padding: 15px; }
.card-h {
  font-family: "IBM Plex Mono", monospace; font-size: 10.5px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--faint); margin: 0 0 10px;
}
.cube-card svg { display: block; width: 100%; max-width: 230px; height: auto; margin: 0 auto; }
.readout {
  font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--muted);
  margin-top: 10px; line-height: 1.7;
}
.readout b { color: var(--ink); font-weight: 500; }
.axline { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

/* -------------------------------------------------------------- controls -- */

.controls { margin: 18px 0 0; padding: 13px 15px; display: flex; flex-direction: column; gap: 12px; }
.crow { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.grp { display: flex; align-items: center; gap: 9px; min-width: 0; }
.lbl {
  font-family: "IBM Plex Mono", monospace; font-size: 10px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--faint);
}
.seg { display: flex; background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; flex-wrap: wrap; }
.seg button, .seg a {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font-family: "IBM Plex Mono", monospace; font-size: 12.5px; font-weight: 500;
  padding: 6px 12px; border-radius: 999px; cursor: pointer; transition: .18s; line-height: 1;
  text-decoration: none;
}
.seg button:hover, .seg a:hover { color: var(--ink); }
.seg button[aria-pressed="true"], .seg a[aria-current="page"] { background: var(--panel); color: var(--ink); }
.seg.axis button[aria-pressed="true"][data-a="x"] { color: var(--x); box-shadow: inset 0 0 0 1px var(--x); }
.seg.axis button[aria-pressed="true"][data-a="y"] { color: var(--y); box-shadow: inset 0 0 0 1px var(--y); }
.seg.axis button[aria-pressed="true"][data-a="z"] { color: var(--z); box-shadow: inset 0 0 0 1px var(--z); }

.sliderow { display: flex; align-items: center; gap: 11px; flex: 1 1 240px; }
.nav {
  width: 36px; height: 36px; flex: 0 0 auto; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--ink); font-size: 17px; cursor: pointer; line-height: 1; transition: .15s;
}
.nav:hover { border-color: var(--accent); color: var(--accent); }
input[type=range] { flex: 1 1 auto; min-width: 90px; accent-color: var(--accent); height: 26px; cursor: pointer; }
.idxout { font-family: "IBM Plex Mono", monospace; font-size: 14px; min-width: 58px; text-align: right; flex: 0 0 auto; }
.idxout small { color: var(--faint); }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--panel2); color: var(--ink);
  font-family: "IBM Plex Mono", monospace; font-size: 12.5px; padding: 8px 14px;
  border-radius: 9px; cursor: pointer; transition: .15s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.quiet { color: var(--muted); }

/* Top bar — the books and the tip jar sit above the puzzle, not buried in the
   footer rule. The Amazon link is affiliate, so `.affiliate-note` must always
   render with it. */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px 18px; margin-bottom: 6px;
}
.topbar-links { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.topbar-links a {
  font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--muted); text-decoration: none;
}
.topbar-links a:hover { color: var(--accent); }
.topbar-cta { display: flex; flex-wrap: wrap; gap: 8px; }
.topbar-cta .btn { text-decoration: none; }
.btn-cta { background: var(--accent); border-color: var(--accent); color: #0b1316; font-weight: 600; }
.btn-cta:hover:not(:disabled) { filter: brightness(1.12); color: #0b1316; }
.affiliate-note {
  margin: 0 0 14px; text-align: right;
  font-family: "IBM Plex Mono", monospace; font-size: 10.5px; color: var(--faint);
}

@media (max-width: 640px) {
  .topbar { gap: 8px; }
  .topbar-cta { width: 100%; }
  .topbar-cta .btn { flex: 1 1 auto; text-align: center; }
  .affiliate-note { text-align: left; }
}

.status {
  min-height: 1.4em; font-family: "IBM Plex Mono", monospace; font-size: 12.5px;
  color: var(--y); margin-top: 4px;
}

/* ----------------------------------------------------- collapsible tools -- */

details.panel { margin-top: 16px; overflow: hidden; }
details.panel summary {
  list-style: none; cursor: pointer; padding: 13px 15px; display: flex; align-items: center; gap: 10px;
  font-family: "IBM Plex Mono", monospace; font-size: 10.5px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--muted);
}
details.panel summary::-webkit-details-marker { display: none; }
details.panel summary:hover { color: var(--ink); }
.chev { margin-left: auto; transition: transform .2s; color: var(--faint); }
details[open] .chev { transform: rotate(180deg); }
.det-body { padding: 0 15px 15px; }

.keys { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; }
.k {
  aspect-ratio: 1; border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-family: "IBM Plex Mono", monospace; font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--line); background: var(--panel2); color: var(--ink); transition: .12s;
}
.k:hover { transform: translateY(-2px); border-color: var(--accent); }

/* film strip — thumbnails carry solve state, not a colour preview of the answer */
.film { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; }
.thumb {
  aspect-ratio: 1; border-radius: 5px; border: 1px solid var(--line); padding: 0; cursor: pointer;
  background: var(--panel2); position: relative; transition: .15s;
  display: flex; align-items: center; justify-content: center;
  font-family: "IBM Plex Mono", monospace; color: var(--muted);
}
.thumb b { font-size: 12px; font-weight: 600; }
.thumb em { position: absolute; right: 3px; bottom: 1px; font-style: normal; font-size: 10px; color: var(--y); }
.thumb.is-part { border-color: var(--accent); color: var(--ink); }
.thumb.is-solved { border-color: var(--y); color: var(--y); background: rgba(84, 192, 138, .12); }
.thumb:hover { border-color: var(--accent); }
.thumb[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--accent); color: var(--ink); }

.keytable { font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--muted); line-height: 2; }
.keytable kbd {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 4px;
  padding: 1px 6px; color: var(--ink); font-size: 11px; margin-right: 3px;
}

footer, nav.foot {
  margin-top: 22px; border-top: 1px solid var(--line); padding-top: 14px;
  font-family: "IBM Plex Mono", monospace; font-size: 11.5px; color: var(--faint);
  display: flex; flex-wrap: wrap; gap: 6px 18px;
}
footer a, nav.foot a { color: var(--muted); text-decoration: none; }
footer a:hover, nav.foot a:hover { color: var(--accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------- reused kakuro control pad -- */
/*
 * controlpad.blade.php + controls.js come over verbatim, but their Kokoro styling
 * does not: the pads are fixed to the viewport corners in kakuro red (#dc2626),
 * which on this dark cobalt page reads as an error state and — at desktop widths —
 * floats straight over the grid and the cube picker.
 *
 * So: show it only where it earns its place (touch / narrow), and recolour it to
 * this page's palette. Overrides live here rather than in controlpad.css so every
 * other player keeps the styling it has today.
 */
.ctrl-corner { display: none; }

@media (max-width: 860px), (pointer: coarse) {
  .ctrl-corner {
    display: block;
    background: rgba(11, 19, 22, .82);
    border: 1px solid var(--line);
    border-radius: 12px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }
  .digit-btn {
    background: var(--panel2);
    color: var(--ink);
    border: 1px solid var(--line);
  }
  .digit-btn:hover { background: var(--panel); }
  .digit-btn:active { background: var(--accent); color: #0b1316; }
  .arrow-btn { background: rgba(255, 255, 255, .10); color: var(--ink); }
  .clear-btn { background: rgba(255, 255, 255, .06); color: var(--muted); }
  .clear-btn:hover { background: rgba(255, 255, 255, .14); color: var(--ink); }
}

@media (max-width: 520px) {
  .lede { display: none; }
  body { padding: 10px; }
  .controls { margin: 14px 0 0; padding: 11px 12px; }
  .seg button { padding: 6px 10px; }
  .progress { margin-left: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
