/*
  Notaste Games: game pages.
  Loads after /styles.css and reuses its tokens, header, footer, buttons, stamps and dots.
  Each page sets --accent on <body> (the game's colour). It is used sparingly:
  the bar over the title, the status dot, the cabinet's credit light, the boot
  log's results, the how-to-play numbers and the light button's shadow.
  The loud thing on the page is the cabinet: a bezel, a glass screen, scanlines.
*/

.game {
  --bezel: #121212;
  --screen-bg: #070707;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

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

.game-page {
  display: grid;
  grid-template-areas:
    "head"
    "screen"
    "info";
  gap: 1.75rem;
  padding-block: 1.25rem 3.5rem;
}

.game-head { grid-area: head; min-width: 0; }
.cabinet   { grid-area: screen; min-width: 0; }
.game-info { grid-area: info; min-width: 0; }

@media (min-width: 60rem) {
  .game-page {
    grid-template-columns: minmax(0, 1fr) 22rem;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "screen head"
      "screen info";
    column-gap: 3rem;
    row-gap: 2.5rem;
    align-items: start;
    padding-block: 2.25rem 5rem;
  }
}

@media (min-width: 75rem) {
  .game-page { grid-template-columns: minmax(0, 1fr) 21.5rem; column-gap: 3.25rem; }
}

/* ---------- Title block ---------- */

.game-head h1 {
  margin: 0;
  padding-top: 0.75rem;
  border-top: 6px solid var(--accent, var(--paper));
  font-size: clamp(3.4rem, 18vw, 5.5rem);
  line-height: 0.86;
}

@media (min-width: 40rem) {
  .game-head h1 { font-size: clamp(4.5rem, 10vw, 6.5rem); }
}

@media (min-width: 60rem) {
  .game-head h1 { font-size: clamp(4.75rem, 6.2vw, 6.25rem); border-top-width: 8px; padding-top: 1rem; }
}

.game-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.4rem;
  margin-top: 1.1rem;
}

.game-head .stamp-label {
  font-size: clamp(1.2rem, 1.2vw + 0.95rem, 1.55rem);
  transform: rotate(var(--tilt, -4deg));
}

.game-state {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  color: var(--smoke);
  font-size: var(--step--1);
  font-weight: 600;
}

.game-pitch {
  margin: 1.1rem 0 0;
  max-width: 30rem;
  font-size: var(--step-1);
  line-height: 1.42;
  color: #dcdcdc;
}

@media (max-width: 39.99rem) {
  .game-pitch { font-size: var(--step-0); line-height: 1.5; margin-top: 0.9rem; }
}

/* ---------- The cabinet ---------- */

/* the bezel: moulded black plastic with a lip of light along its top edge */
.cabinet {
  position: relative;
  padding: 10px 10px 0;
  border-radius: 16px;
  background:
    linear-gradient(180deg, #1d1d1d 0, var(--bezel) 30%, #0b0b0b 100%);
  border: 1px solid #2b2b2b;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.8),
    0 2px 0 #000,
    0 34px 70px -24px rgba(0, 0, 0, 0.9);
}

@media (min-width: 40rem) {
  .cabinet { padding: 18px 18px 0; border-radius: 22px; }
}

/* the glass */
.screen {
  position: relative;
  isolation: isolate;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--screen-bg);
  color: var(--paper);
  border-radius: 10px;
  /* a recessed lip between bezel and glass */
  box-shadow:
    0 0 0 1px #000,
    0 0 0 3px #1f1f1f,
    0 0 0 4px #000;
}

@media (min-width: 40rem) {
  .screen { aspect-ratio: 4 / 3; border-radius: 14px; }
}

/* Cover art behind everything, like an attract screen */
.screen-art {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.62;
  filter: saturate(0.9);
  transition: opacity 300ms ease, filter 300ms ease;
}

/* once the game is "running", the art drops back */
.screen:has(#game-root[data-state="boot"]) .screen-art,
.screen:has(#game-root[data-state="done"]) .screen-art { opacity: 0.3; filter: saturate(0.6) blur(1px); }

/* Glare across the glass, scanlines, and a darkened curved edge */
.screen::before,
.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
}

.screen::before {
  z-index: 4;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.09) 0%, rgba(255, 255, 255, 0.025) 28%, rgba(255, 255, 255, 0) 42%);
}

.screen::after {
  z-index: 3;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 0 90px rgba(0, 0, 0, 0.85),
    inset 0 0 22px rgba(0, 0, 0, 0.7);
}

/* the strip under the screen, like the panel on a cabinet */
.cabinet-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin: 0;
  padding: 0.7rem 0.25rem 0.8rem;
  color: #8c8c8c;
  font-family: var(--display);
  font-size: 1rem;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* a credit light in the game's colour */
.cabinet-strip span:last-child {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: #bdbdbd;
}
.cabinet-strip span:last-child::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--accent, var(--smoke));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #888) 22%, transparent), 0 0 10px var(--accent, transparent);
}

@media (min-width: 40rem) {
  .cabinet-strip { padding: 0.85rem 0.15rem 1rem; font-size: 1.1rem; }
}

/* ---------- Game root and placeholder states ---------- */

#game-root {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.ph {
  position: absolute;
  inset: 0;
  display: none;
  padding: 1.25rem;
}

#game-root:not([data-state]) .ph-idle,
#game-root[data-state="idle"] .ph-idle,
#game-root[data-state="boot"] .ph-boot,
#game-root[data-state="done"] .ph-done { display: grid; }

/* Idle: title and the start button, on a pool of shade so they read over the art */
.ph-idle {
  align-content: center;
  justify-items: center;
  gap: 1.1rem;
  text-align: center;
  background: radial-gradient(ellipse 62% 48% at 50% 52%, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0.35) 70%, rgba(0, 0, 0, 0.15));
}

.ph-title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.6rem, 6vw + 1rem, 5.25rem);
  line-height: 0.88;
  text-transform: uppercase;
  text-shadow: 0 3px 0 #000, 0 0 24px rgba(0, 0, 0, 0.8);
}

.ph-start.btn {
  border: 0;
  cursor: pointer;
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.85rem 1.7rem 0.75rem;
  box-shadow: 0 5px 0 var(--red-press), 0 12px 26px rgba(0, 0, 0, 0.6);
}
.ph-start.btn:active { box-shadow: 0 1px 0 var(--red-press), 0 6px 14px rgba(0, 0, 0, 0.6); }

@media (min-width: 40rem) {
  .ph-start.btn { font-size: 2rem; padding: 0.9rem 2rem 0.8rem; }
}

.ph-note {
  margin: 0;
  font-size: var(--step--1);
  font-weight: 600;
  color: #e4e4e4;
  text-shadow: 0 1px 2px #000, 0 0 10px #000;
}

/* Boot: a short log of things the game is pretending to do */
.ph-boot,
.ph-done { background: rgba(5, 5, 5, 0.8); }

.ph-boot { align-content: end; padding: 1.25rem 1.4rem; }
.ph-boot:focus { outline: none; }

.boot-log {
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--mono);
  font-size: clamp(0.82rem, 0.6vw + 0.66rem, 1rem);
  line-height: 1.75;
  color: #cfcfcf;
}

.boot-log li { overflow-wrap: anywhere; }
.boot-res { color: var(--accent, var(--paper)); font-weight: 700; }

.boot-log li:last-child::after {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 1em;
  margin-left: 0.35em;
  vertical-align: -0.15em;
  background: #cfcfcf;
}

/* Done: the stamp, the bad news, the way out */
.ph-done {
  align-content: center;
  justify-items: center;
  gap: 0.85rem;
  text-align: center;
}

.ph-done .stamp-label {
  font-size: clamp(1.7rem, 3vw + 1.1rem, 2.7rem);
  transform: rotate(var(--tilt, -4deg));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.55);
}

.ph-heading {
  margin: 0.5rem 0 0;
  font-family: var(--display);
  font-size: clamp(1.7rem, 2vw + 1.2rem, 2.6rem);
  line-height: 0.95;
  text-transform: uppercase;
  max-width: 16ch;
}

.ph-heading:focus { outline: none; }

.ph-line {
  margin: 0;
  max-width: 26rem;
  color: #d4d4d4;
  font-size: var(--step--1);
  line-height: 1.5;
}

@media (min-width: 40rem) {
  .ph-line { font-size: var(--step-0); }
}

.ph-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-top: 0.35rem;
}

.ph-actions .btn { padding: 0.75rem 1.15rem 0.7rem; }
.ph-actions .text-link { color: var(--paper); }

.ph-restart {
  margin-top: 0.15rem;
  padding: 0.4rem 0.85rem;
  background: transparent;
  color: var(--smoke);
  border: 1px solid #4a4a4a;
  border-radius: 3px;
  font: inherit;
  font-size: var(--step--1);
  font-weight: 700;
  cursor: pointer;
}

.ph-restart:hover { border-color: var(--paper); color: var(--paper); }

.screen :focus-visible { outline-color: var(--paper); }

/* Motion, only after the player presses something */
@media (prefers-reduced-motion: no-preference) {
  .boot-log li { animation: line-in 120ms ease-out both; }
  #game-root[data-state="done"] .ph-done .stamp-label {
    animation: stamp-in 520ms cubic-bezier(0.2, 0.7, 0.3, 1) both;
  }
  #game-root[data-state="boot"] .ph-boot { animation: power-on 260ms ease-out both; }
  .ph-start:active, .ph-restart:active { transform: translateY(3px); }
}

@keyframes line-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes power-on {
  0%   { opacity: 0; transform: scaleY(0.02); filter: brightness(3); }
  60%  { opacity: 1; transform: scaleY(1.02); filter: brightness(1.4); }
  100% { opacity: 1; transform: none; filter: none; }
}

@keyframes stamp-in {
  0%   { opacity: 0; transform: rotate(calc(var(--tilt, -4deg) - 4deg)) scale(1.8); }
  55%  { opacity: 1; transform: rotate(var(--tilt, -4deg)) scale(0.95); }
  75%  { transform: rotate(var(--tilt, -4deg)) scale(1.02); }
  100% { opacity: 1; transform: rotate(var(--tilt, -4deg)) scale(1); }
}

/* Phones: the screen is square, so tighten the end state to fit */
@media (max-width: 39.99rem) {
  .ph { padding: 1rem; }
  .ph-boot { padding: 1rem 1.1rem; }
  .ph-done { gap: 0.6rem; }
  .ph-done .stamp-label { font-size: 1.6rem; }
  .ph-heading { margin-top: 0.3rem; font-size: 1.65rem; }
  .ph-actions { gap: 0.6rem 1rem; margin-top: 0.2rem; }
  .ph-actions .btn { padding: 0.65rem 0.95rem 0.6rem; font-size: 0.95rem; }
}

/* ---------- How to play and share ---------- */

.game-info h2 {
  margin: 0;
  font-size: 2.2rem;
}

.how {
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
  counter-reset: how;
  border-top: 2px solid var(--paper);
}

.how li {
  display: grid;
  grid-template-columns: 1.6rem 1fr;
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--ash);
  line-height: 1.45;
}

.how li::before {
  counter-increment: how;
  content: counter(how);
  font-family: var(--display);
  font-size: 1.45rem;
  line-height: 1;
  color: var(--accent, var(--smoke));
}

.share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-top: 1.75rem;
}

/* the light button, with the game's colour under it */
.btn-line {
  display: inline-block;
  padding: 0.8rem 1.4rem 0.75rem;
  background: var(--paper);
  color: var(--ink);
  border: 0;
  border-radius: 3px;
  box-shadow: 0 4px 0 var(--accent, var(--smoke));
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: transform 80ms ease, box-shadow 80ms ease;
}

.btn-line:hover { background: #f1f1f1; }
.btn-line:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent, var(--smoke)); }

.share-status {
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--smoke);
  overflow-wrap: anywhere;
}

/* ---------- More games ---------- */

.more { padding-block: 2.5rem 5rem; }

@media (min-width: 60rem) {
  .more { padding-block: 1.5rem 6rem; }
}

.more .section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  margin-bottom: 2.25rem;
}

.more h2 { margin: 0; font-size: var(--step-2); }

.more-list {
  display: grid;
  gap: 3rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 44rem) {
  .more-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2.5rem; }
}

.more-card {
  display: block;
  text-decoration: none;
}

.more-cover {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #111;
  border-radius: 6px;
  outline: 1px solid var(--ash);
}

/* Shown until the cover art exists */
.more-cover-name {
  padding: 0.5rem;
  color: var(--paper);
  font-family: var(--display);
  font-size: clamp(1.4rem, 2vw + 0.8rem, 2.2rem);
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
}

.more-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 400ms ease;
}

.more-cover .stamp-label {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  font-size: clamp(1.25rem, 4vw, 1.8rem);
  transform: translate(-50%, -50%) rotate(-6deg);
}

.more-body { display: block; }

/* the title on a black tag that bites into the bottom of the art */
.more-title {
  position: relative;
  display: inline-block;
  margin: -1.5rem 0 0 0.75rem;
  padding: 0.5rem 0.75rem 0.3rem;
  background: var(--ink);
  border-top: 5px solid var(--accent, var(--paper));
  font-family: var(--display);
  font-size: clamp(2.3rem, 9vw, 3rem);
  line-height: 0.92;
  text-transform: uppercase;
}

.more-pitch {
  display: block;
  margin-top: 0.55rem;
  max-width: 30rem;
  font-size: var(--step-1);
  line-height: 1.4;
}

.more-status {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.7rem;
  color: var(--smoke);
  font-size: var(--step--1);
  font-weight: 600;
}

.more-card:hover .more-title,
.more-card:focus-visible .more-title { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 0.12em; }

@media (hover: hover) {
  .more-card:hover .more-cover img { transform: scale(1.035); }
  .more-card:hover .more-title { border-top-width: 8px; }
}

@media (max-width: 26rem) {
  .more-pitch { font-size: var(--step-0); }
}
