/* ==========================================================================
   0ptim1zed — "Main Menu" theme (homepage and 404)
   A retro game title screen: pixel type, CRT scanlines, a menu and a preview
   panel. The SHAR: DE page has its own theme and doesn't load this file.
   ========================================================================== */

@font-face {
  font-family: "Press Start 2P";
  src: url("/assets/fonts/press-start-2p.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "VT323";
  src: url("/assets/fonts/vt323.woff2") format("woff2");
  font-display: swap;
}

:root {
  --bg: #0d0b1a;
  --ink: #f4ecd8;
  --dim: #8f88a8;
  --faint: #4d4766;
  --yel: #ffd84a;
  --pink: #ff6fa8;
  --plum: #b23a7a;
  --navy: #2b2458;
  --pixel: "Press Start 2P", ui-monospace, monospace;
  --term: "VT323", ui-monospace, monospace;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% -10%, #2b2458 0%, transparent 60%),
    radial-gradient(ellipse at 50% 120%, #3a1740 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  font: 26px/1.25 var(--term);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 3px solid var(--yel);
  outline-offset: 4px;
}

::selection {
  background: var(--pink);
  color: var(--bg);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

/* CRT scanlines + vignette */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

body::before {
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.22) 0 2px, transparent 2px 4px);
}

body::after {
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.55) 100%);
}

/* Pixel starfield */
.stars {
  position: fixed;
  inset: 0;
  opacity: 0.7;
  pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 78% 12%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 64% 34%, #cfc7ff 50%, transparent 51%),
    radial-gradient(2px 2px at 22% 62%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 88% 70%, #cfc7ff 50%, transparent 51%),
    radial-gradient(2px 2px at 40% 84%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 6% 40%, #cfc7ff 50%, transparent 51%),
    radial-gradient(2px 2px at 54% 8%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 94% 44%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 32% 30%, #cfc7ff 50%, transparent 51%);
  animation: twinkle 4s steps(2) infinite;
}

@keyframes twinkle {
  50% { opacity: 0.45; }
}

/* ---------- Layout ---------- */

.screen {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  /* title centred in the space above the menu, footer pinned to the bottom */
  grid-template-rows: 1fr auto 1fr;
  align-items: center;
  gap: 40px 48px;
  max-width: 1180px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 32px 28px 26px;
}

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

.title {
  grid-column: 1 / -1;
  text-align: center;
}

.title h1 {
  margin: 0;
  color: var(--yel);
  font: 400 clamp(30px, 7.4vw, 92px)/1.1 var(--pixel);
  letter-spacing: 0.02em;
  text-shadow: 4px 4px 0 var(--plum), 8px 8px 0 var(--navy);
}

.title h1 .one {
  color: var(--pink);
  text-shadow: 4px 4px 0 #6b1d48, 8px 8px 0 var(--navy);
}

.title p {
  margin: 18px 0 0;
  color: var(--dim);
  font-size: 28px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- Menu ---------- */

/* Menu starts level with the panel's heading, so SHAR: DE is a fixed anchor */
.screen > nav {
  align-self: start;
  padding-top: 34px;
}

/* Nudge the title so it's centred between the top of the page and SHAR: DE */
.title {
  align-self: center;
  margin-top: 40px;
}

.menu {
  margin: 0;
  padding: 0;
  list-style: none;
  font: 400 clamp(14px, 1.8vw, 21px)/1 var(--pixel);
}

.menu li + li {
  margin-top: 24px;
}

.menu .item {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.menu .item::before {
  content: "▶";
  color: transparent;
  font-size: 0.8em;
}

.menu .item.is-selected,
.menu .item:hover {
  color: var(--yel);
}

.menu .item.is-selected::before {
  color: var(--yel);
  animation: blink 1s steps(1) infinite;
}

.menu .item:focus-visible {
  outline: none;
}

.menu .locked {
  color: var(--faint);
  cursor: default;
}

.menu .locked.is-selected,
.menu .locked:hover {
  color: #6d6690;
}

.menu .locked small {
  margin-left: 4px;
  font: 400 20px/1 var(--term);
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ---------- Preview panel ---------- */

.panels {
  display: grid;
}

.panel {
  grid-area: 1 / 1;
  padding: 18px;
  border: 4px solid var(--ink);
  background: rgba(13, 11, 26, 0.78);
  box-shadow: 8px 8px 0 var(--navy);
}

/* Without JS every panel shows, stacked */
.no-js .panels {
  gap: 24px;
}

.no-js .panel {
  grid-area: auto;
}

.no-js .panel[hidden] {
  display: block;
  visibility: visible;
}

/* Inactive panels keep their space (stacked in one cell), so the box is always
   the size of the tallest panel and nothing on the screen moves when switching */
.panel[hidden] {
  display: block;
  visibility: hidden;
}

.panel.is-entering {
  animation: pop 0.18s steps(3);
}

@keyframes pop {
  from { transform: scale(0.96); opacity: 0.4; }
}

.panel header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  color: var(--dim);
  font: 400 12px/1.4 var(--pixel);
}

.panel h2 {
  margin: 0 0 8px;
  color: var(--yel);
  font: 400 15px/1.5 var(--pixel);
}

.panel p {
  margin: 0 0 10px;
}

.panel .row {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 18px;
  align-items: center;
}

.panel .row img {
  width: 112px;
  height: 112px;
  border: 3px solid var(--ink);
}

.panel dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 16px;
  margin: 14px 0 0;
  color: var(--dim);
}

.panel dd {
  margin: 0;
  color: var(--ink);
}

.panel .go {
  display: inline-block;
  margin-top: 16px;
  padding: 10px 14px;
  background: var(--yel);
  color: var(--bg);
  font: 400 12px/1 var(--pixel);
  box-shadow: 4px 4px 0 var(--plum);
}

.panel .go:hover {
  background: var(--pink);
}

.panel .go:active {
  transform: translate(4px, 4px);
  box-shadow: none;
}

.panel .links {
  display: grid;
  gap: 10px;
  margin-top: 6px;
}

.panel .links a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 2px solid var(--faint);
}

.panel .links a:hover {
  border-color: var(--yel);
  color: var(--yel);
}

.panel .links span:last-child {
  color: var(--dim);
}

.lock-art {
  display: grid;
  place-items: center;
  height: 112px;
  border: 3px dashed var(--faint);
  color: var(--faint);
  font: 400 40px/1 var(--pixel);
}

/* ---------- Footer hint ---------- */

.hint {
  grid-column: 1 / -1;
  align-self: end;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  color: var(--dim);
  font-size: 22px;
}

.hint .press {
  color: var(--ink);
  animation: blink 1.2s steps(1) infinite;
}

.hint kbd {
  padding: 0 6px;
  border: 2px solid var(--faint);
  font: inherit;
}

.hint .touch {
  display: none;
}

@media (hover: none) {
  .hint .keys { display: none; }
  .hint .touch { display: inline; }
}

/* ---------- 404 ---------- */

.over {
  grid-column: 1 / -1;
  grid-row: 2;
  display: grid;
  justify-items: center;
  gap: 22px;
  text-align: center;
}

.over h1 {
  margin: 0;
  color: var(--pink);
  font: 400 clamp(34px, 8vw, 96px)/1.1 var(--pixel);
  text-shadow: 4px 4px 0 #6b1d48, 8px 8px 0 var(--navy);
}

.over .code {
  color: var(--dim);
  font: 400 clamp(12px, 1.6vw, 16px)/1.6 var(--pixel);
}

.over .choices {
  display: flex;
  gap: 40px;
  font: 400 clamp(14px, 1.8vw, 20px)/1 var(--pixel);
}

.over .choices a::before {
  content: "▶ ";
  color: transparent;
}

.over .choices a:hover,
.over .choices a:focus-visible {
  color: var(--yel);
  outline: none;
}

.over .choices a:hover::before,
.over .choices a:focus-visible::before,
.over .choices a.first::before {
  color: var(--yel);
}

.over .choices a.first {
  color: var(--yel);
}

/* ---------- Sub-pages (Downloads) ---------- */

.page {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 28px;
  max-width: 820px;
  margin: 0 auto;
  padding: 32px 28px 26px;
}

.back {
  justify-self: start;
  color: var(--dim);
  font: 400 12px/1 var(--pixel);
}

.back:hover {
  color: var(--yel);
}

.page-title {
  text-align: center;
}

.page-title h1 {
  margin: 0;
  color: var(--yel);
  font: 400 clamp(26px, 6vw, 60px)/1.1 var(--pixel);
  text-shadow: 4px 4px 0 var(--plum), 8px 8px 0 var(--navy);
}

.page-title p {
  margin: 14px 0 0;
  color: var(--dim);
  font-size: 26px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Panels here flow in order instead of stacking in one cell like the menu's */
.page .panel {
  grid-area: auto;
}

.dl-card--locked {
  opacity: 0.6;
}

.files {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.files li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 16px;
  padding: 10px 12px;
  border: 2px solid var(--faint);
}

.files .file-meta {
  color: var(--dim);
}

.files .go {
  margin: 0;
}

.panel .go.is-off {
  background: var(--faint);
  color: var(--dim);
  box-shadow: 4px 4px 0 var(--navy);
  cursor: not-allowed;
}

.panel .note {
  margin: 16px 0 0;
  color: var(--dim);
}

.panel .note a {
  color: var(--yel);
}

.panel .note a:hover {
  color: var(--pink);
}

.page-foot {
  margin-top: 8px;
  color: var(--dim);
  font-size: 22px;
  text-align: center;
}

.page-foot p {
  margin: 0 0 6px;
}

@media (max-width: 560px) {
  .files li {
    grid-template-columns: 1fr auto;
  }

  .files .go {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 860px) {
  .screen {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    align-content: start;
    padding-top: 40px;
  }

  .hint {
    justify-content: center;
    text-align: center;
  }
}

/* When the footer wraps, centre it instead of splitting it left/right */
@media (max-width: 1180px) {
  .hint { justify-content: center; column-gap: 32px; text-align: center; }
}

/* Short laptop screens: tighten so everything fits without scrolling */
@media (max-height: 860px) and (min-width: 861px) {
  .screen { gap: 14px 48px; padding: 16px 28px 16px; }
  .screen > nav { padding-top: 26px; }
  .title { margin-top: 24px; }
  .title h1 { font-size: clamp(28px, 6vw, 68px); }
  .title p { margin-top: 10px; font-size: 24px; }
  .menu li + li { margin-top: 16px; }
  .panel { padding: 14px 16px; }
  .panel .row img, .lock-art { width: 96px; height: 96px; }
  .panel .row { grid-template-columns: 96px 1fr; }
}

@media (max-width: 420px) {
  .panel .row {
    grid-template-columns: 84px 1fr;
  }

  .panel .row img,
  .lock-art {
    width: 84px;
    height: 84px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before {
    animation: none !important;
  }
}
