/*
  thecogquest.com. One screen, like the game's title screen: a robot town going about its day fills
  the window, and the game's own menu panel sits over it. The look is the game's (the owner,
  2026-10-14: "earthy", "feel free to use the game style"), with its colours taken from the title
  screen's panel. The pack's own font and panel pictures are never served (Gowl's licence); the
  panel is drawn here in CSS, the lettering is Pixelify Sans, and the logo is a picture the game
  drew of its name. DESIGN_BRIEF.md has the reasons and the overrides of the Etti rules.
*/

@font-face { font-family: "Pixelify Sans"; src: url("fonts/pixelify-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Pixelify Sans"; src: url("fonts/pixelify-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }

/* Layout: the video covers the window; logo and menu stack on the left (on a phone, logo at the
   top and menu at the bottom), the hint plate along the bottom, the scene's name and the sound in corners. */
:root {
  /* The title screen's colours */
  --parchment: #e7d5b3;
  --parchment-shade: #d7b594;
  --tan: #c09473;
  --rust: #884b2b;
  --bark: #7a4841;
  --maroon: #602c2c;
  --plum: #341c27;
  --gold: #e8c170;
  --pointer: #c8432f;
  --grass: #5e963e;
  --night: #0b0d17;

  --font-pixel: "Pixelify Sans", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* One game pixel on the page, for borders and steps: it grows with the page, like the rest */
  --px: 0.3rem;
  color-scheme: light;
}

/* Everything is measured in rem, and the rem follows the window: whichever of its width and height
   is tighter, so the logo, menu and plates keep their place in the picture on any screen. 16px on
   a 1440 by 860 window, up to 30px on a large one. */
html { font-size: clamp(12px, min(1.11vw, 1.86vh), 30px); }

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--maroon);
  font-family: var(--font-pixel);
  overflow: hidden;
}
:focus-visible { outline: calc(var(--px) * 1) solid var(--gold); outline-offset: var(--px); }
::selection { background: var(--gold); color: var(--plum); }

/* ---------- The town ---------- */
.town {
  opacity: 0;
  transition: opacity 1.5s ease;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;          /* until the script sizes it in whole game pixels (index.html, fit) */
  image-rendering: pixelated;
  background: var(--night);
}
.town.is-showing { opacity: 1; }
.shade {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgb(11 13 23 / 0.42) 0%, rgb(11 13 23 / 0.12) 38%, transparent 55%),
    radial-gradient(ellipse at 60% 50%, transparent 55%, rgb(11 13 23 / 0.35) 100%);
}

/* ---------- The title stack ---------- */
.title {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 30rem) 1fr;
  align-items: center;
  padding-top: calc(env(safe-area-inset-top, 0px) + 2rem);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 5.5rem);
  padding-left: max(clamp(16px, 6vw, 6rem), env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  pointer-events: none;
}
.stack {
  display: grid;
  gap: clamp(1.25rem, 3vh, 2rem);
  justify-items: center;
  width: 100%;
  max-width: 30rem;
  min-width: 0;
  pointer-events: auto;
  /* backwards, not both: a rise held on after it ends would hide the scene from the soft patch
     below (Chrome, 2026-10-15) */
  animation: rise 0.7s ease-out backwards;
  position: relative;
  isolation: isolate;
}
/* The scene goes soft and a little darker just behind the logo and the menu, as a game's does
   behind its pause menu, so the menu reads as sitting on top of the game (the owner, 2026-10-15).
   Feathered at the edges; the rest of the scene stays sharp. */
.stack::before {
  content: "";
  position: absolute;
  inset: -3rem -4rem;
  z-index: -1;
  pointer-events: none;
  -webkit-backdrop-filter: blur(3px) brightness(0.82);
  backdrop-filter: blur(3px) brightness(0.82);
  -webkit-mask-image: radial-gradient(closest-side, #000 55%, transparent);
  mask-image: radial-gradient(closest-side, #000 55%, transparent);
}
.logo {
  width: min(100%, 26rem);
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(calc(var(--px) * 1) calc(var(--px) * 2) 0 rgb(11 13 23 / 0.5));
}
h1 { margin: 0; width: 100%; display: flex; justify-content: center; }

/* ---------- The game's menu panel, drawn in CSS ---------- */
.panel {
  position: relative;
  width: min(100%, 22rem);
  background: var(--parchment);
  border: calc(var(--px) * 1) solid var(--plum);
  border-radius: calc(var(--px) * 3);
  padding: calc(var(--px) * 5) calc(var(--px) * 4);
  box-shadow:
    inset 0 0 0 calc(var(--px) * 1) var(--tan),
    inset 0 0 0 calc(var(--px) * 2) var(--parchment),
    inset 0 calc(var(--px) * -3) 0 calc(var(--px) * 2) var(--parchment-shade),
    0 0 0 calc(var(--px) * 1) var(--rust),
    0 calc(var(--px) * 3) 0 calc(var(--px) * 1) var(--bark),
    0 calc(var(--px) * 4) 0 calc(var(--px) * 1) var(--plum),
    /* A hard pixel shadow cast onto the scene, so the panel stands off it */
    calc(var(--px) * 3) calc(var(--px) * 7) 0 calc(var(--px) * 1) rgb(11 13 23 / 0.5),
    0 calc(var(--px) * 10) calc(var(--px) * 6) rgb(11 13 23 / 0.35);
}
/* The little studs in the panel's corners */
.panel::before, .panel::after {
  content: "";
  position: absolute;
  top: calc(var(--px) * 3);
  width: calc(var(--px) * 2);
  height: calc(var(--px) * 2);
  background: var(--tan);
  box-shadow: 0 0 0 var(--px) var(--parchment-shade);
}
.panel::before { left: calc(var(--px) * 3); }
.panel::after { right: calc(var(--px) * 3); }

/* The rows touch, each padded by half the space between them, so the mouse moving down the menu
   is always over a row and the highlight goes straight from one to the next */
.choices { list-style: none; margin: calc(var(--px) * -0.75) 0; padding: 0; display: grid; }
.choices li { padding: calc(var(--px) * 0.75) 0; }
.choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: calc(var(--px) * 1.5) calc(var(--px) * 4) calc(var(--px) * 1.5) calc(var(--px) * 9);
  border-radius: 9999px;
  color: var(--maroon);
  font-size: 1.65rem;
  font-weight: 600;
  line-height: 1.15;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.choice small { font-size: 0.62em; font-weight: 400; color: var(--bark); }
/* The red pointer, on the row chosen: the first, or the one under the mouse or keyboard (never
   Steam, which is not there yet) */
.choice::before {
  content: "";
  position: absolute;
  left: calc(var(--px) * 3);
  top: 50%;
  width: 0;
  height: 0;
  border-top: calc(var(--px) * 2.5) solid transparent;
  border-bottom: calc(var(--px) * 2.5) solid transparent;
  border-left: calc(var(--px) * 3) solid var(--pointer);
  transform: translateY(-50%);
  opacity: 0;
}
.choices:not(:has(li:hover > .choice:not([aria-disabled="true"]), .choice:focus-visible)) li:first-child .choice,
li:hover > .choice:not([aria-disabled="true"]),
.choice:focus-visible {
  background: var(--parchment-shade);
}
.choices:not(:has(li:hover > .choice:not([aria-disabled="true"]), .choice:focus-visible)) li:first-child .choice::before,
li:hover > .choice:not([aria-disabled="true"])::before,
.choice:focus-visible::before {
  opacity: 1;
  animation: nudge 0.9s steps(2, jump-none) infinite;
}
.choice:focus-visible { outline: none; }
.choice[aria-disabled="true"] { color: var(--tan); cursor: default; }
.choice[aria-disabled="true"] small { color: var(--tan); }

/* ---------- The hint plate along the bottom, like the game's ---------- */
.hint {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 1.25rem);
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: calc(var(--px) * 1.5) calc(var(--px) * 2);
  max-width: calc(100% - 32px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
  margin: 0;
  padding: calc(var(--px) * 1.5) calc(var(--px) * 2.5);
  background: var(--parchment);
  border: var(--px) solid var(--plum);
  border-radius: calc(var(--px) * 2);
  box-shadow: inset 0 calc(var(--px) * -1) 0 var(--parchment-shade), 0 var(--px) 0 var(--px) var(--rust);
  font-size: 0.95rem;
  color: var(--maroon);
}
.key {
  padding: calc(var(--px) * 0.5) calc(var(--px) * 1.5);
  background: var(--rust);
  color: var(--parchment);
  border-radius: var(--px);
  box-shadow: 0 var(--px) 0 var(--plum);
  white-space: nowrap;
}

/* ---------- Corners: the scene's name and the sound ---------- */
.plate {
  position: fixed;
  display: inline-flex;
  align-items: center;
  gap: calc(var(--px) * 1.5);
  padding: calc(var(--px) * 1) calc(var(--px) * 2);
  background: var(--parchment);
  color: var(--maroon);
  border: var(--px) solid var(--plum);
  border-radius: calc(var(--px) * 2);
  box-shadow: inset 0 calc(var(--px) * -1) 0 var(--parchment-shade), 0 var(--px) 0 var(--px) var(--rust);
  font: 600 1.05rem/1.1 var(--font-pixel);
  font-variant-numeric: tabular-nums;
}
.scene-name {
  top: calc(env(safe-area-inset-top, 0px) + 1.25rem);
  right: max(1.25rem, calc(env(safe-area-inset-right, 0px) + 1rem));
  margin: 0;
}
.sound {
  bottom: calc(env(safe-area-inset-bottom, 0px) + 1.25rem);
  right: max(1.25rem, calc(env(safe-area-inset-right, 0px) + 1rem));
  cursor: pointer;
  padding: calc(var(--px) * 1.5);
}
.sound svg { width: calc(var(--px) * 5); height: calc(var(--px) * 5); }
.sound .on { display: none; }

/* A tip, bottom left, with the credit above it */
.tip {
  left: max(1.25rem, calc(env(safe-area-inset-left, 0px) + 1rem));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 1.25rem);
  text-decoration: none;
  cursor: pointer;
}
.tip:hover { background: var(--parchment-shade); }
.tip svg { width: calc(var(--px) * 4); height: calc(var(--px) * 4); }
.tip:active { transform: translateY(var(--px)); }
.sound[aria-pressed="true"] .on { display: block; }
.sound[aria-pressed="true"] .off { display: none; }
.sound:active { transform: translateY(var(--px)); }

.credit {
  position: fixed;
  left: max(1.25rem, calc(env(safe-area-inset-left, 0px) + 1rem));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 4.5rem);
  margin: 0;
  font-size: 0.8rem;
  color: var(--parchment);
  text-shadow: 0 1px 0 var(--plum), 0 0 6px rgb(11 13 23 / 0.8);
}
.credit a { color: inherit; }

/* ---------- Upright screens: phones and tablets held upright ---------- */
@media (max-width: 860px) and (orientation: portrait) {
  html { font-size: clamp(14px, min(3.9vw, 2.1vh), 24px); }
  .title {
    grid-template-columns: 1fr;
    align-items: stretch;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-top: calc(env(safe-area-inset-top, 0px) + 4.25rem);
    /* Room for the hint plate, which wraps to two lines on a phone */
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8.25rem);
  }
  .stack { align-content: space-between; height: 100%; justify-self: center; }
  /* The column fills the screen here, so the soft patch would blur the whole scene */
  .stack::before { display: none; }
  .logo { width: min(100%, 22rem); }
  .shade { background: linear-gradient(180deg, rgb(11 13 23 / 0.35) 0%, transparent 30%, transparent 55%, rgb(11 13 23 / 0.45) 100%); }
  .credit { display: none; }
  /* A tall screen shows about a quarter of a film's width: each scene says where to centre
     (`focus` in index.html), the town square on its talkers. */
  .hint { font-size: 0.85rem; }
  .sound { bottom: auto; top: calc(env(safe-area-inset-top, 0px) + 1.25rem); right: auto; left: max(1.25rem, calc(env(safe-area-inset-left, 0px) + 1rem)); }
  /* The bottom is the hint plate's, so the tip is just its cup, beside the sound at the top */
  .tip {
    bottom: auto;
    top: calc(env(safe-area-inset-top, 0px) + 1.25rem);
    left: calc(max(1.25rem, calc(env(safe-area-inset-left, 0px) + 1rem)) + 3.6rem);
    padding: calc(var(--px) * 1.5);
  }
  .tip svg { width: calc(var(--px) * 5); height: calc(var(--px) * 5); }
  .tip span { display: none; }
}

/* ---------- Short, wide screens: a phone on its side, a small laptop window ---------- */
@media (max-height: 560px) and (orientation: landscape) {
  html { font-size: clamp(9px, 2.7vh, 15px); }
  .title {
    padding-top: calc(env(safe-area-inset-top, 0px) + 0.75rem);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 0.75rem);
    padding-left: max(1.5rem, env(safe-area-inset-left, 0px));
  }
  .stack { gap: 1rem; }
  .logo { width: min(100%, 20rem); }
  .panel { width: min(100%, 19rem); }
  .hint, .credit { display: none; }
}

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes nudge { 0% { margin-left: 0; } 100% { margin-left: calc(var(--px) * -1); } }
@media (prefers-reduced-motion: reduce) {
  .stack { animation: none; }
  .town { transition: none; }
  .choice::before { animation: none !important; }
}
