/* WAD Commander handout: the placeholder website for wadcmd.com and a two-page
   A4 handout, laid out as the front and back of a 1990s PC game box.

   One unit drives the whole layout: 1rem is 1/100 of a box face's width.
   - Print: a face is an A4 page, 100rem × 141.43rem (1rem = 2.1mm).
   - Landscape screens: a 16:9 face, 100rem × 56.25rem, fitted to the viewport.
   - Tall portrait screens (tablets): the printed A4 face, fitted to the viewport.
   - Anything smaller (phones): the faces flow, as long as they need to be.
   The palette, the type (the app's CP437 font) and the title bar follow the
   app and the press page (apps/press). */

@font-face { font-family: "cp437"; src: url("../fonts/cp437.woff") format("woff"); font-display: swap; }

:root {
  color-scheme: dark;
  /* DOS/EGA palette, identical to the app */
  --dos-black: #000000;
  --dos-blue: #0000aa;
  --dos-cyan: #00aaaa;
  --dos-red: #aa0000;
  --dos-brown: #aa5500;
  --dos-light-gray: #aaaaaa;
  --dos-dark-gray: #555555;
  --dos-bright-green: #55ff55;
  --dos-bright-cyan: #55ffff;
  --dos-yellow: #ffff55;
  --dos-white: #ffffff;

  --text: var(--dos-light-gray);
  --bright: var(--dos-white);
  --dim: #7c7c7c;
  --amber: var(--dos-yellow);
  --font: "cp437", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --pad: clamp(10px, 2.4vmin, 28px);

  /* Phones and small windows: the faces flow */
  font-size: calc(min(100vw, 600px) / 37);
}

*, *::before, *::after { box-sizing: border-box; }
html { background: #0b0b0b; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100svh; overflow-x: hidden;
  font: 1.3rem/1.4 var(--font); color: var(--text);
  /* The desk under the box: a faint ░ dither */
  background: repeating-conic-gradient(#131313 0 25%, #0b0b0b 0 50%) 0 0 / 4px 4px;
}
img, svg, canvas { display: block; max-width: 100%; }
p, figure, h1, h2, h3, ul, dl, dd { margin: 0; }
ul { padding: 0; list-style: none; }
h1, h2, h3 { font-weight: normal; line-height: 1; color: var(--bright); }
strong, b { font-weight: normal; color: var(--bright); }
a { color: inherit; }
::selection { color: var(--dos-black); background: var(--amber); }
:focus-visible { outline: .2rem solid var(--amber); outline-offset: .2rem; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); border: 0; white-space: nowrap; }
@keyframes blink { 50% { opacity: 0; } }

/* Switching between this page and the 3D box (default 3D view) cross-fades where the
   browser can; handout.js fades out to black where it can't */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .5s; }
html.is-leaving body { opacity: 0; transition: opacity .35s; }

/* ── The box ───────────────────────────────────────────────────────────── */
.desk { display: grid; justify-items: center; gap: 2.4rem; padding: var(--pad); }
.face {
  --m: 3rem;
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; grid-template-columns: var(--m) minmax(0, 1fr) var(--m); align-content: start;
  width: 100%;
  background: var(--dos-black);
  border-radius: .35rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .09), 0 .8rem 2.4rem rgba(0, 0, 0, .85), 0 0 0 1px #000;
}
/* Light on the shrink wrap */
.face::after {
  content: ""; position: absolute; inset: 0; z-index: 20; pointer-events: none;
  background: linear-gradient(118deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, 0) 26%, rgba(255, 255, 255, 0) 64%, rgba(255, 255, 255, .045) 78%, rgba(255, 255, 255, 0) 90%);
}

/* ── Front ─────────────────────────────────────────────────────────────── */
.face--front {
  grid-template-areas: "band band band" ". logo ." ". tag ." ". art ." ". callouts ." "stripes stripes stripes" ". foot .";
  row-gap: 2rem; padding-bottom: 1.6rem;
}

/* The publisher's band: the app's title bar */
.topband {
  grid-area: band;
  display: flex; align-items: center; gap: 1.2rem;
  height: 4.4rem; padding: 0 var(--m);
  background: var(--dos-light-gray); color: #1a1a1a;
  box-shadow: inset 0 .15rem #e6e6e6, inset 0 -.25rem #7c7c7c;
  font-size: 1.4rem; line-height: 1; white-space: nowrap;
}
.publisher { display: flex; align-items: center; gap: .6em; }
.publisher small { font-size: 1em; color: #555; }
/* The publisher's logo sits in a black inset, like the platform on the right */
.publisher-logo, .platform {
  display: flex; align-items: center; height: 2.7rem; padding: 0 .7em;
  background: var(--dos-black);
  border: .12rem solid #6b6b6b; border-right-color: #e6e6e6; border-bottom-color: #e6e6e6;
}
.publisher-logo img { width: auto; height: 72%; }
.topband-rule { flex: 1; min-width: 1rem; height: 1.1rem; background: repeating-linear-gradient(to bottom, #8f8f8f 0 .16rem, transparent 0 .36rem); }
.platform { gap: .5em; color: var(--amber); text-transform: uppercase; }
.platform small { font-size: 1em; color: var(--text); }

/* The logo: a huge "WAD" over "COMMANDER", the version stuck on after it */
.logo { grid-area: logo; position: relative; display: grid; justify-items: center; row-gap: 1rem; }
.logo-wad { width: 73%; height: auto; }
.logo-commander { width: 100%; height: auto; }

/* A small sticky note on the box: a photographic image (postit.mjs) with its
   own shadow. It hangs off the end of "COMMANDER", so the name reads first and
   the version last. */
.postit {
  position: absolute; right: -4%; bottom: 0; z-index: 3;
  width: 23%;
  transform: translateY(80%) rotate(7deg);
}
.postit img { width: 100%; height: auto; }

/* On phones it keeps clear of the note hanging off the logo above it */
.tagline { grid-area: tag; padding-right: 24%; font-size: 2.3rem; line-height: 1.1; color: var(--amber); text-transform: uppercase; }
.tagline::after { content: "_"; animation: blink 1.1s step-end infinite; }

/* The key art: the floppy, spinning in 3D, in front of rays */
.floppy { grid-area: art; position: relative; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; min-height: 0; }
.rays {
  position: absolute; left: 50%; top: 50%; z-index: -1;
  width: 130rem; height: 130rem; max-width: none; translate: -50% -50%;
  pointer-events: none;
}
.floppy canvas, .floppy [data-floppy-fallback] { width: min(100%, 30rem); height: auto; aspect-ratio: 1; image-rendering: pixelated; }
.floppy canvas { cursor: grab; touch-action: none; }
.floppy canvas:active { cursor: grabbing; }
.floppy [data-floppy-fallback] { padding: 12%; }
.floppy-print { display: none; }

.burst {
  position: absolute; right: 0; bottom: 4%; z-index: 2;
  display: grid; place-items: center;
  width: 12rem; aspect-ratio: 1;
  transform: rotate(-12deg);
}
.burst svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.burst span { position: relative; font-size: 1.6rem; line-height: 1.05; text-align: center; text-transform: uppercase; color: var(--amber); }

.callouts {
  grid-area: callouts;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  border: .35rem double var(--dos-dark-gray); background: rgba(0, 0, 0, .8);
}
.callouts li {
  display: flex; flex-direction: column; justify-content: center;
  padding: .9rem 1.2rem; border-left: .15rem solid #2a2a2a; border-top: .15rem solid #2a2a2a;
  font-size: 1.15rem; line-height: 1.2; color: var(--dim); text-transform: uppercase;
}
.callouts li:nth-child(odd) { border-left: 0; }
.callouts li:nth-child(-n + 2) { border-top: 0; }
.callouts b { margin-bottom: .25rem; font-size: 3rem; line-height: 1; color: var(--amber); }

/* 1980s speed stripes, in the logo's fire colours */
.stripes {
  grid-area: stripes; height: 2.6rem;
  background: linear-gradient(to bottom, var(--dos-yellow) 0 22%, transparent 0 34%, var(--dos-brown) 0 56%, transparent 0 68%, var(--dos-red) 0 90%, transparent 0);
}

.front-foot {
  grid-area: foot;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 2rem;
  font-size: 1.25rem; line-height: 1.2; color: var(--dim); text-transform: uppercase;
}
.front-foot > span:first-child { color: var(--bright); text-transform: none; }
.front-actions { display: flex; flex-wrap: wrap; gap: 1rem 1.4rem; }
.turn, .to-3d, .v1, .links a {
  display: inline-flex; align-items: center; gap: .6em; padding: .5rem 1rem;
  text-decoration: none; text-transform: uppercase; white-space: nowrap;
  color: var(--dos-black); background: var(--amber); box-shadow: .35rem .35rem 0 #333;
}
.turn:hover, .links a:hover { background: #ffffaa; }
/* The 3D box (default 3D view), in the cyan of "COMMANDER" */
.to-3d { background: var(--dos-bright-cyan); }
.to-3d:hover { background: #aaffff; }
/* The way to the current version while v2 is not out: a quieter grey button */
.v1, .links a.v1 { background: var(--dos-light-gray); }
.v1:hover, .links a.v1:hover { background: var(--dos-white); }
/* Names keep their case in uppercase text: v1, @level0x40 */
.as-is { text-transform: none; }
.turn:active, .to-3d:active, .v1:active, .links a:active { transform: translate(.35rem, .35rem); box-shadow: none; }

/* ── Back ──────────────────────────────────────────────────────────────── */
.face--back {
  grid-template-areas: ". head ." ". shots ." ". features ." ". sysreq ." ". links ." ". foot .";
  row-gap: 2.6rem; padding: 3rem 0 2rem;
  background: radial-gradient(ellipse 70% 45% at 80% 12%, rgba(0, 0, 170, .3), rgba(0, 0, 170, 0) 70%), var(--dos-black);
}

.back-head { grid-area: head; display: grid; gap: 1.1rem; align-content: start; }
.logo-line { width: 100%; max-width: 60%; height: auto; }
/* On phones it wraps beside the sticker: PLAY IT. / CAPTURE IT. / SHARE IT. */
.headline { max-width: 62%; font-size: 3.2rem; line-height: 1.05; color: var(--amber); text-transform: uppercase; }
.intro { font-size: 1.3rem; line-height: 1.45; }

/* The release date, on a round sticker */
.sticker {
  position: absolute; top: 1.4rem; right: 1.6rem; z-index: 5;
  width: 12rem; aspect-ratio: 1;
  transform: rotate(11deg);
}
.sticker svg { width: 100%; height: 100%; }
.sticker text { font-family: var(--font); }

.shots { grid-area: shots; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2rem; }
.shots figure { display: grid; gap: .8rem; align-content: start; }
/* A 1990s window frame around each screenshot */
.shot {
  display: block; padding: .45rem;
  background: var(--dos-light-gray);
  box-shadow: inset .15rem .15rem #e6e6e6, inset -.15rem -.15rem #6b6b6b, .45rem .45rem 0 #1e1e1e;
}
.shot img { width: 100%; height: auto; aspect-ratio: 16 / 10; outline: .1rem solid #000; }
.shots figcaption { font-size: 1.2rem; line-height: 1.35; }
.shots figcaption b { color: var(--amber); text-transform: uppercase; }

.label {
  justify-self: start; margin-bottom: .9rem; padding: .25rem .8rem;
  font-size: 1.3rem; line-height: 1.1; color: var(--dos-black); background: var(--amber); text-transform: uppercase;
}
.features { grid-area: features; display: grid; align-content: start; }
.features li { position: relative; padding: .2rem 0 .2rem 1.6em; font-size: 1.25rem; line-height: 1.35; color: var(--bright); }
.features li::before { content: "►"; position: absolute; left: 0; color: var(--amber); }
.features li b { color: var(--dos-bright-cyan); }

/* System requirements: a Turbo Vision dialog */
.sysreq {
  grid-area: sysreq; position: relative; align-self: start;
  margin: .5rem; padding: 1.2rem 1.4rem 1rem;
  background: var(--dos-light-gray); color: var(--dos-black);
  border: .35rem double var(--dos-white); outline: .5rem solid var(--dos-light-gray);
}
.sysreq-title {
  position: absolute; top: 0; left: 50%; transform: translate(-50%, -55%);
  padding: 0 .8ch; font-size: 1.3rem; white-space: nowrap; text-transform: uppercase;
  color: var(--dos-black); background: var(--dos-light-gray);
}
.sysreq dl > div { display: grid; grid-template-columns: 11ch minmax(0, 1fr); gap: 1ch; padding: .22rem .3rem; border-bottom: .12rem solid #8a8a8a; font-size: 1.15rem; line-height: 1.3; }
.sysreq dl > div:last-child { border-bottom: 0; }
.sysreq dt { color: var(--dos-blue); }
.sysreq .sysreq-plus { margin-top: .3rem; color: var(--amber); background: var(--dos-blue); }
.sysreq .sysreq-plus dt { color: var(--dos-bright-cyan); }

/* A double-line window with the QR code; a phone cannot scan its own screen */
.scan {
  grid-area: scan; position: relative; align-self: start;
  display: none; justify-items: center; gap: .5rem;
  padding: 2rem 1rem .8rem;
  border: .35rem double var(--dos-light-gray); background: var(--dos-black);
}
.scan-title {
  position: absolute; top: 0; left: 50%; transform: translate(-50%, -58%);
  padding: 0 .8ch; font-size: 1.25rem; white-space: nowrap; text-transform: uppercase;
  color: var(--bright); background: var(--dos-black);
}
.scan .qr { width: 100%; height: auto; }
.scan p { font-size: 1.2rem; color: var(--amber); }

.links { grid-area: links; display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.4rem; font-size: 1.2rem; }
.countdown { flex-basis: 100%; color: var(--dos-bright-green); text-transform: uppercase; }
/* CP437 draws ■ 0.17em below the middle of the capitals: lift it level */
.countdown::before { content: "■"; position: relative; top: -.17em; margin-right: .5em; }

.back-foot {
  grid-area: foot;
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 1.2rem 1.6rem;
  padding-top: 1.2rem; border-top: .15rem solid #262626;
}
.dev img { width: 13rem; height: auto; }
.legal { font-size: .95rem; line-height: 1.4; color: var(--dim); }
.legal p + p { margin-top: .3rem; }
.barcode {
  grid-column: 1 / -1; justify-self: start;
  display: grid; justify-items: center; gap: .15rem; padding: .6rem .9rem .35rem;
  font-size: .95rem; line-height: 1; letter-spacing: .05em; color: var(--dos-black); background: var(--dos-white);
}
.barcode-bars { width: 15rem; height: 3.4rem; }

/* ── Tall portrait screens: the A4 faces (portrait.css), fitted to the viewport ── */
@media screen and (min-width: 700px) and (min-height: 1000px) and (max-aspect-ratio: 5/4) {
  :root { font-size: min((100vw - 2 * var(--pad)) / 100, (100svh - 2 * var(--pad)) / 141.43); }
  html { scroll-snap-type: y mandatory; }
  .face { margin: calc((100svh - 141.43rem) / 2) 0; scroll-snap-align: center; }
}

/* ── Paper ─────────────────────────────────────────────────────────────── */
@page { size: A4; margin: 0; }
@media print {
  *, *::before, *::after { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  :root { font-size: 2.1mm; }
  html, body { background: var(--dos-black); scroll-behavior: auto; }
  .desk > .face { height: 297mm; margin: 0; border-radius: 0; box-shadow: none; break-after: page; }
  .face:last-child { break-after: auto; }
  .face::after { display: none; }
  .tagline::after { animation: none; }
  /* Nothing that only works on a screen: the QR code is the way in */
  .front-actions, .links, .floppy canvas, .floppy [data-floppy-fallback] { display: none !important; }
  .floppy-print { display: block; width: auto; height: 86%; max-width: 100%; image-rendering: pixelated; }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  html { scroll-behavior: auto; }
  .tagline::after { animation: none; }
}
