/* ---------------------------------------------------------------
   Block Drop - 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 well, the side panel, the controls and the tokens they
   need live here.
---------------------------------------------------------------- */

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

/* The well and the pieces are drawn on canvases; app.js reads these
   tokens and redraws whenever the theme changes. */
:root {
  --well: #f3f6fd;
  --well-dot: #d6ddec;
  --piece-i: #1fb5cc;
  --piece-j: #4f6cf7;
  --piece-l: #f08c00;
  --piece-o: #f5b700;
  --piece-s: #2fa84f;
  --piece-t: #9061f9;
  --piece-z: #ef3e5c;
  --piece-dead: #b9c1d4;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --well: #11161f;
    --well-dot: #232b3a;
    --piece-i: #3bc9db;
    --piece-j: #6f8bff;
    --piece-l: #ffa94d;
    --piece-o: #ffd43b;
    --piece-s: #51cf66;
    --piece-t: #b197fc;
    --piece-z: #ff6b81;
    --piece-dead: #3a4356;
  }
}

:root[data-theme="dark"] {
  --well: #11161f;
  --well-dot: #232b3a;
  --piece-i: #3bc9db;
  --piece-j: #6f8bff;
  --piece-l: #ffa94d;
  --piece-o: #ffd43b;
  --piece-s: #51cf66;
  --piece-t: #b197fc;
  --piece-z: #ff6b81;
  --piece-dead: #3a4356;
}

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

.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);
}

.brand__mark--blocks {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.brand__mark--blocks svg { width: 18px; height: 18px; display: block; }

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

@media (max-width: 520px) {
  /* Every pixel of height goes to the well and the pad; the same
     information is in the description under the game. */
  .topbar__hint { display: none; }
  .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; }
}

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

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

.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;
}

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

/* ------------------------------ play area ------------------------------ */

/* The well on the left, the side panel (score, next, hold, pause) on the
   right - both within reach of a thumb on a phone. */
.play {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 10px;
}

.well-wrap {
  position: relative;
  flex: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 8px;
  /* Drags and flicks steer the piece, so the well must not scroll the page. */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.well {
  display: block;
  border-radius: 10px;
  /* Size is set by app.js to fit the screen; this is the pre-script size. */
  width: 200px;
  height: 400px;
}

.well-wrap.is-shake { animation: shake .45s cubic-bezier(.36, .07, .19, .97); }
.well-wrap.is-thud { animation: thud .16s ease-out; }

@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}

@keyframes thud {
  40% { transform: translateY(3px); }
}

.side {
  flex: none;
  width: 92px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 7px 6px 8px;
  display: grid;
  justify-items: center;
  gap: 4px;
  text-align: center;
}

.box__label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
}

.box__value {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.box__value.is-bump { animation: bump .3s ease; }

@keyframes bump {
  40% { transform: scale(1.18); color: var(--accent); }
}

.box canvas { display: block; }

/* The hold box is a button too: tapping it swaps the piece. */
button.box {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button.box:active { transform: scale(.97); }
button.box[aria-disabled="true"] { opacity: .6; }

.box--pair {
  grid-template-columns: 1fr 1fr;
  padding: 7px 4px 8px;
}

.box--pair > div { display: grid; gap: 2px; }
.box--pair .box__value { font-size: 16px; }

.side__pause {
  margin-top: auto;
  min-height: 44px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.side__pause:active { transform: scale(.96); }
.side__pause[disabled] { opacity: .45; cursor: default; }
.side__pause .icon { width: 22px; height: 22px; }

/* Pause/play glyphs swap with the state of the game. */
.icon--play { display: none; }
.is-paused .icon--pause { display: none; }
.is-paused .icon--play { display: block; }

.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) 74%, transparent);
  backdrop-filter: blur(5px);
  border-radius: var(--radius-lg);
  z-index: 3;
  animation: fade .2s ease;
}

.cover[hidden] { display: none; }

.cover__card {
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 12px;
}

.cover__icon {
  font-size: 40px;
  line-height: 1;
  animation: float 2.4s ease-in-out infinite;
}

@keyframes float {
  50% { transform: translateY(-6px); }
}

.cover__title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.02em;
}

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

.cover .btn { min-width: 130px; }

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

/* Left thumb moves (◀ ▼ ▶), right thumb rotates - the big button spans
   both rows; hold, hard drop and the other rotation sit on top. */
.pad {
  --key: 56px;
  display: grid;
  grid-template-columns: repeat(3, 1fr) 1.25fr;
  grid-template-rows: repeat(2, var(--key));
  gap: 6px;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  touch-action: none;
}

.pad__key {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1px;
  cursor: pointer;
  padding: 0;
  font: inherit;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .03em;
  transition: transform .08s ease, background-color .08s ease, border-color .08s ease;
  -webkit-user-select: none;
  user-select: none;
}

.pad__key .icon { width: 24px; height: 24px; stroke-width: 2.2; }
.pad__key small { font-size: 10px; color: var(--text-dim); font-weight: 600; }

.pad__key.is-down,
.pad__key:active {
  transform: scale(.94);
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.pad__key--rotate {
  grid-column: 4;
  grid-row: 1 / span 2;
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-text);
  border-radius: 22px;
}

.pad__key--rotate .icon { width: 34px; height: 34px; }

.pad__key--rotate.is-down,
.pad__key--rotate:active {
  background: var(--accent-2);
  color: var(--accent-text);
  border-color: transparent;
}

.pad__key--soft { color: var(--text); }

.keys-hint {
  display: none;
  gap: 6px 14px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 0;
  font-size: 13px;
  color: var(--text-dim);
}

.keys-hint span { white-space: nowrap; }

kbd {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  min-width: 24px;
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  background: var(--surface);
  color: var(--text);
  display: inline-block;
  text-align: center;
}

/* A mouse and a keyboard: the keys beat any on-screen pad, so the pad
   gives way to a key legend and the side panel grows a little. */
@media (hover: hover) and (pointer: fine) {
  .pad { display: none; }
  .keys-hint { display: flex; }
  .side { width: 116px; }
}

/* Short phones (or a browser with its toolbars showing): a lower pad
   leaves the well room to breathe. */
@media (max-height: 740px) {
  .pad { --key: 50px; gap: 5px; }
}

/* ---------------------------- game-over 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__label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-dim);
}

/* The lynx next to "Play again": a way back to every game on the site
   without having to close the dialog first. */
.modal__actions .modal__home {
  flex: none;
  width: 46px;
  padding: 0;
}

.modal__home img { width: 26px; height: 26px; display: block; }
.modal__home:active { transform: scale(.96); }

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

.about {
  border-top: 1px solid var(--border);
  padding-top: 18px;
  margin-top: 6px;
  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; }
.about ul { padding-left: 20px; margin: 0 0 8px; }
.about li { margin: 3px 0; }

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

.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; }
.doc ol { padding-left: 20px; }
