/* ---------------------------------------------------------------
   Minesweeper - game-specific styles.

   Loaded after /assets/base.css, which supplies the design tokens,
   the top bar, the buttons, the footer, the modals, the cookie
   banner and the legal-page layout shared by every Lynxy game.
   Only the board and the tokens it needs live here.
---------------------------------------------------------------- */

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

/* The tile surfaces and the eight number colours: nothing outside the
   Minesweeper board uses them, so they are not in base.css. */
:root {
  --tile: #e4e9f5;
  --tile-top: #f2f5fd;
  --tile-hover: #d9e0f2;
  --opened: #fbfcfe;
  --opened-line: #e7ebf4;
  --flag-soft: #fff1e0;
  --n1: #2d6ae3;
  --n2: #1a8f5e;
  --n3: #e0435b;
  --n4: #7b52d3;
  --n5: #d2740c;
  --n6: #0f9aa8;
  --n7: #3d4557;
  --n8: #8c94a8;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tile: #273044;
    --tile-top: #303b53;
    --tile-hover: #35415c;
    --opened: #141924;
    --opened-line: #1f2633;
    --flag-soft: #3a2a18;
    --n1: #7aa2ff;
    --n2: #43cf96;
    --n3: #ff7b90;
    --n4: #b394ff;
    --n5: #f0a54a;
    --n6: #46cfdd;
    --n7: #c3cbdd;
    --n8: #8791a8;
  }
}

:root[data-theme="dark"] {
  --tile: #273044;
  --tile-top: #303b53;
  --tile-hover: #35415c;
  --opened: #141924;
  --opened-line: #1f2633;
  --flag-soft: #3a2a18;
  --n1: #7aa2ff;
  --n2: #43cf96;
  --n3: #ff7b90;
  --n4: #b394ff;
  --n5: #f0a54a;
  --n6: #46cfdd;
  --n7: #c3cbdd;
  --n8: #8791a8;
}

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

/* The expert board is 30 tiles wide, so the whole page is wider than the
   560px the shared sheet gives a game. */
.topbar__inner { max-width: 980px; }

.stats {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px 10px;
  text-align: center;
  min-width: 58px;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.stat__value {
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat__label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-dim);
}

/* Three counters, the brand and the two buttons only fit a phone once the
   tiles give up their padding and the brand keeps just its mark. */
@media (max-width: 520px) {
  .stats { gap: 6px; }
  .stat { min-width: 44px; padding: 4px 6px; }
  .stat__value { font-size: 15px; }
  .stat__label { font-size: 9px; letter-spacing: .04em; }
  .brand__name { display: none; }
}

.topbar__hint {
  max-width: 980px;
  margin: 6px auto 0;
  padding: 0 16px;
  font-size: 12px;
  color: var(--text-dim);
}

/* -------------------------------- page --------------------------------- */

.page {
  flex: 1;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel {
  display: flex;
  gap: 10px;
  align-items: center;
}

.levels {
  flex: 1;
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
}

.level {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 7px 4px;
  border-radius: 9px;
  cursor: pointer;
  display: grid;
  gap: 1px;
  line-height: 1.15;
}

.level small {
  font-size: 10px;
  font-weight: 600;
  opacity: .75;
  font-variant-numeric: tabular-nums;
}

.level.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--text-dim);
}

.meta__item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 11px;
  font-variant-numeric: tabular-nums;
}

.meta__item--time { margin-left: auto; }
.meta__item.is-warn { color: var(--error); border-color: var(--error); }

/* -------------------------------- board -------------------------------- */

.board-wrap {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px;
}

/* The expert board is wider than a phone, so it scrolls inside its own box
   instead of stretching the whole page. */
.board-scroll {
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  justify-content: center;
}

.board {
  --cell: 32px;
  display: grid;
  grid-template-columns: repeat(var(--cols, 9), var(--cell));
  grid-auto-rows: var(--cell);
  gap: 2px;
  margin: 0 auto;
  touch-action: manipulation;
}

.cell {
  border: 0;
  margin: 0;
  padding: 0;
  border-radius: 6px;
  background: var(--tile);
  background-image: linear-gradient(180deg, var(--tile-top), var(--tile));
  color: var(--text);
  font: inherit;
  font-size: calc(var(--cell) * .58);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color .1s ease, transform .1s ease;
}

@media (hover: hover) {
  .cell:not(.is-open):hover { background: var(--tile-hover); background-image: none; }
}

.cell:active:not(.is-open) { transform: scale(.94); }

.cell.is-open {
  background: var(--opened);
  background-image: none;
  box-shadow: inset 0 0 0 1px var(--opened-line);
  cursor: default;
}

.cell.is-flag {
  background: var(--flag-soft);
  background-image: none;
  font-size: calc(var(--cell) * .52);
}

.cell.is-hint { animation: pop .45s ease; box-shadow: inset 0 0 0 2px var(--ok); }

.cell.is-mine {
  background: var(--surface-2);
  background-image: none;
  font-size: calc(var(--cell) * .52);
}

.cell.is-boom {
  background: var(--error);
  background-image: none;
}

.cell.is-wrong {
  background: var(--error-soft);
  background-image: none;
  color: var(--error);
}

.cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  z-index: 2;
}

.cell[data-n="1"] { color: var(--n1); }
.cell[data-n="2"] { color: var(--n2); }
.cell[data-n="3"] { color: var(--n3); }
.cell[data-n="4"] { color: var(--n4); }
.cell[data-n="5"] { color: var(--n5); }
.cell[data-n="6"] { color: var(--n6); }
.cell[data-n="7"] { color: var(--n7); }
.cell[data-n="8"] { color: var(--n8); }

@keyframes pop {
  0% { transform: scale(.7); }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.board-cover {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg); /* fallback for browsers without color-mix */
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(6px);
  border-radius: var(--radius);
  z-index: 3;
}

.board-cover[hidden] { display: none; }

.board-cover__card {
  text-align: center;
  display: grid;
  gap: 12px;
  font-weight: 600;
}

.board-cover__card p { margin: 0; }

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

.tools {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-dim);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 8px 2px 6px;
  display: grid;
  justify-items: center;
  gap: 3px;
  cursor: pointer;
}

.tool:active { transform: scale(.97); }
.tool[disabled] { opacity: .45; cursor: default; }

.tool[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.tool__state {
  font-style: normal;
  opacity: .7;
  font-size: 10px;
}

/* ---------------------------- win/lose dialog -------------------------- */

.score-row {
  display: flex;
  gap: 8px;
  margin: 18px 0;
}

.score-row__item {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 4px;
  display: grid;
  gap: 2px;
}

.score-row__value {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.score-row__item:first-child .score-row__value { color: var(--ok); }
.score-row__item--bad .score-row__value,
.score-row__item--bad:first-child .score-row__value { color: var(--error); }

.score-row__label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-dim);
}

/* ------------------------ about / SEO copy ----------------------------- */

.about {
  border-top: 1px solid var(--border);
  padding-top: 18px;
  color: var(--text-dim);
  font-size: 14px;
}

.about h1 {
  font-size: 18px;
  letter-spacing: -.02em;
  color: var(--text);
  margin: 0 0 6px;
}

.about h2 {
  font-size: 15px;
  color: var(--text);
  margin: 18px 0 4px;
}

.about p { margin: 0 0 8px; }

/* --------------------------- tables in prose --------------------------- */

/* The level table on this page and in the guide; the shared sheet has no
   table styles because no other page needs one. */
.about table,
.doc table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 14px;
  font-size: 13px;
}

.about th, .about td,
.doc th, .doc td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
}

.about th, .doc th { background: var(--surface-2); color: var(--text); font-weight: 600; }

.doc table { margin: 14px 0; font-size: 14px; }
.doc th, .doc td { padding: 7px 9px; }

/* The guide uses numbered lists; base.css only styles the bulleted ones. */
.doc ol { padding-left: 20px; }
