/* ---------------------------------------------------------------
   Puffer Reef - 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 field, its screens and the controls live here. The
   field itself is drawn on a canvas by game.js, which reads
   --stage-mode to switch between daylight and deep water.
---------------------------------------------------------------- */

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

:root {
  --stage-mode: light;
  --stage-edge: #cfd6ea;
  --puffer: #ffc53d;
  --puffer-2: #1d9fd0;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --stage-mode: dark;
    --stage-edge: #2a3350;
  }
}

:root[data-theme="dark"] {
  --stage-mode: dark;
  --stage-edge: #2a3350;
}

/* --------------------------- 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--puffer {
  background: linear-gradient(135deg, var(--puffer-2), #4fd2e6);
}

.brand__mark--puffer svg { width: 21px; height: 21px; fill: var(--puffer); }

@media (max-width: 520px) {
  .stats { gap: 6px; }
  .stat { min-width: 48px; 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: 10px 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stage-wrap {
  display: flex;
  justify-content: center;
}

.stage {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--stage-edge);
  box-shadow: var(--shadow);
  background: #1d8fbe;
  /* Every tap is a stroke, so the field must never scroll or zoom the page. */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  /* Replaced by game.js with the size that fits the screen. */
  width: min(100%, 360px);
  cursor: pointer;
}

#game {
  display: block;
  width: 100%;
  aspect-ratio: 360 / 600;
}

/* --------------------------- screens on the field ---------------------- */

.cover {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 14px;
  overflow-y: auto;
  background: rgba(8, 11, 20, .5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade .2s ease;
  z-index: 3;
}

.cover[hidden] { display: none; }

.cover__card {
  width: 100%;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 20px 18px 16px;
  text-align: center;
  animation: rise .25s cubic-bezier(.2, .8, .3, 1);
}

.cover__card[hidden] { display: none; }
.cover__card--wide { max-width: 360px; padding: 16px 14px 14px; }

.cover__icon { font-size: 36px; line-height: 1; margin-bottom: 4px; }

.cover__title {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.03em;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.cover__title--sm {
  font-size: 20px;
  background: none;
  color: var(--text);
}

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

.cover__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cover__actions + .cover__actions { margin-top: 8px; }

.cover__actions--row { flex-direction: row; }
.cover__actions--row .btn--primary { flex: 1; }

.cover__home { flex: none; width: 48px; padding: 0; }
.cover__home img { width: 26px; height: 26px; display: block; }

.cover__note {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--text-dim);
}

/* ------------------------------- dialogs ------------------------------- */

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

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

.score-row__value {
  font-size: 19px;
  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);
}

/* ------------------------------- tool row ------------------------------ */

.tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-dim);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  min-width: 104px;
  white-space: nowrap;
}

.tool:active { transform: scale(.97); }
.tool[disabled] { opacity: .45; cursor: default; }
.tool .icon { width: 18px; height: 18px; }

.icon--play { display: none; }
.is-paused .icon--pause { display: none; }
.is-paused .icon--play { display: block; }

.icon__mute { display: none; }
.is-off .icon__waves { display: none; }
.is-off .icon__mute { display: block; }

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

kbd {
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  min-width: 22px;
  padding: 1px 5px;
  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;
}

@media (hover: hover) and (pointer: fine) {
  .keys-hint { display: flex; }
}

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

.about {
  border-top: 1px solid var(--border);
  padding-top: 18px;
  margin-top: 10px;
  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__small { font-size: 12px; opacity: .8; }

.noscript {
  text-align: center;
  padding: 12px 16px;
  margin: 0;
  color: var(--error);
}

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

.doc table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 14px;
}

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

.doc th { background: var(--surface-2); color: var(--text); font-weight: 600; }
.doc ol { padding-left: 20px; }

/* ------------------------------ menu logo ------------------------------ */

.cover__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 52px;
  margin: 0 auto 8px;
}

/* A little CSS puffer: body, eye, tail. */
.cover__puffer {
  position: relative;
  display: block;
  width: 44px;
  height: 38px;
  margin-right: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #fff09a, #ffcb3d 62%, #f2a21e);
  border: 2px solid #b4630c;
  box-shadow: 0 8px 14px -8px rgba(0, 0, 0, .45);
  animation: bob 1.4s ease-in-out infinite;
}

.cover__puffer::before {
  content: '';
  position: absolute;
  right: 6px;
  top: 7px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 62% 50%, #1b2033 0 28%, #fff 31%);
  border: 1px solid #7a4308;
}

.cover__puffer::after {
  content: '';
  position: absolute;
  left: -13px;
  top: 9px;
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-right: 14px solid #f39a1c;
}

.cover__pearl {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #f3ecff 55%, #c9b8e8);
  box-shadow: 0 0 10px rgba(201, 184, 232, .9);
  animation: bob 1.4s ease-in-out infinite;
}

.cover__pearl:nth-child(3) { animation-delay: .15s; }
.cover__pearl:nth-child(4) { animation-delay: .3s; }

@keyframes bob {
  0%, 100% { transform: translateY(3px); }
  50% { transform: translateY(-5px); }
}

/* ---------------------------- rules on the menu ------------------------ */

.rules {
  list-style: none;
  margin: 0 0 12px;
  padding: 10px 12px;
  display: grid;
  gap: 8px;
  text-align: left;
  font-size: 13px;
  line-height: 1.4;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.rules li { display: flex; gap: 10px; align-items: flex-start; }

.rules__icon {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 1px;
}

.rules__icon--heart {
  background: #ff4f73;
  clip-path: path('M8 15C3 11 0 8 0 4.6 0 2 2 0 4.4 0 6 0 7.3.9 8 2.2 8.7.9 10 0 11.6 0 14 0 16 2 16 4.6 16 8 13 11 8 15z');
}

.rules__icon--pearl {
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #f3ecff 55%, #b9a6de);
  box-shadow: 0 0 0 1px rgba(120, 100, 170, .35);
}

.score-row--menu { margin: 0 0 12px; }
.score-row--menu .score-row__item:first-child .score-row__value { color: var(--text); }

/* On a short screen the menu keeps the rules and the button, not the numbers. */
@media (max-height: 700px) {
  .score-row--menu { display: none; }
}

/* ------------------------ continue after the last heart ---------------- */

.continue {
  margin: 0 0 10px;
}

.continue[hidden] { display: none; }

.continue__btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.continue__btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}

.continue__btn svg path { fill: currentColor; stroke: none; }

.continue__note {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--text-dim);
}

.notice {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--error-soft);
  border: 1px solid var(--border);
  font-size: 13px;
  text-align: left;
  display: grid;
  gap: 8px;
}

.notice[hidden] { display: none; }
.notice p { margin: 0; color: var(--text); }

/* ---------------------------- "tap to swim" ---------------------------- */

.ready {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 22%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  z-index: 2;
}

.ready[hidden] { display: none; }

.ready__finger {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .85);
  box-shadow: 0 0 0 0 rgba(255, 255, 255, .7);
  animation: tap 1.1s ease-out infinite;
}

.ready__text {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  background: rgba(8, 20, 40, .45);
  padding: 6px 14px;
  border-radius: 999px;
  letter-spacing: .01em;
}

@keyframes tap {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 255, 255, .7); }
  30% { transform: scale(.82); }
  60% { transform: scale(1); box-shadow: 0 0 0 16px rgba(255, 255, 255, 0); }
  100% { box-shadow: 0 0 0 16px rgba(255, 255, 255, 0); }
}

@media (hover: hover) and (pointer: fine) {
  .ready__text::after { content: ' · Space or click'; font-weight: 600; opacity: .85; }
}

/* ------------------------ pictures for the site ------------------------ */

.is-shot body > *:not(main) { display: none !important; }
.is-shot .page { padding: 0; max-width: none; }
.is-shot .tools, .is-shot .about, .is-shot .cover, .is-shot .ready { display: none !important; }
.is-shot .stage { position: fixed; inset: 0; width: 100vw !important; height: 100vh !important; border: 0; border-radius: 0; }
