/* Modern Stunts website: one screen laid out like the game's car menu, on
   carbon fibre between muted red and gold racing stripes. */

:root {
  /* The VGA colours the game's menus use. */
  --black: #000;
  --white: #fcfcfc;
  --grey: #a8a8a8;
  --grey-dark: #545454;
  --yellow: #fcfc54;
  --red: #a80000;
  --magenta: #a800a8;

  /* The game window in dark mode: graphite panels with the same bevels. */
  --panel: #2a2c33;
  --panel-light: #4a4e57;
  --panel-dark: #101114;
  --panel-text: #e4e6ea;

  --carbon: #17181c;
  --carbon-weave: #1f2026;
  --stripe-red: #7a1f1f;
  --stripe-gold: #b8963e;
  --font-title: "Saira", system-ui, sans-serif;
  --font-game: "IBM VGA", monospace;
  --buttons-width: 13rem;
  --box-height: 17rem;
  /* Every height but the picture's is fixed, so the picture's is known. */
  --page-padding: 1.5rem;
  --title-height: 4.5rem;
  --frame: 6px;
  --picture-height: calc(100vh - 2 * var(--page-padding) - var(--title-height)
    - 2 * var(--frame) - var(--box-height));
  /* A 16:9 picture that tall shows the whole video with no bars. */
  --window-width: max(40rem, min(100rem, calc(var(--picture-height) * 16 / 9 + 2 * var(--frame))));
}

@font-face {
  font-family: "Saira";
  src: url("fonts/saira.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 50% 125%;
}

@font-face {
  font-family: "IBM VGA";
  src: url("fonts/ibm-vga-8x16.woff") format("woff");
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* The page is exactly one screen tall, and the picture takes whatever height
   the rest leaves. */
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 40rem;
  margin: 0;
  padding: var(--page-padding);
  background: repeating-linear-gradient(45deg, var(--carbon) 0 4px, var(--carbon-weave) 4px 8px);
  color: var(--panel-text);
  font-family: var(--font-game);
  font-size: 1.5rem;
  line-height: 1.4;
}

/* The stripes run top to bottom just outside the game window's left and
   right edges, so they frame it. */
body::before {
  --edge: calc(var(--window-width) / 2 + 1.5rem);
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg,
    transparent 0 calc(50% - var(--edge) - 3rem),
    var(--stripe-red) calc(50% - var(--edge) - 3rem) calc(50% - var(--edge) - 0.4rem),
    var(--stripe-gold) calc(50% - var(--edge) - 0.4rem) calc(50% - var(--edge)),
    transparent calc(50% - var(--edge)) calc(50% + var(--edge)),
    var(--stripe-gold) calc(50% + var(--edge)) calc(50% + var(--edge) + 0.4rem),
    var(--stripe-red) calc(50% + var(--edge) + 0.4rem) calc(50% + var(--edge) + 3rem),
    transparent calc(50% + var(--edge) + 3rem));
}

img,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 4px solid var(--magenta);
  outline-offset: 0;
}

h2 {
  margin: 0 0 0.5rem;
  font-size: 1em;
  font-weight: normal;
}

p {
  margin: 0 0 0.75rem;
}

code {
  font-family: inherit;
}

/* Title, one line above the window */

.window {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  max-width: var(--window-width);
  margin: 0 auto;
}

/* At least as wide as the window, wider when the logo and tagline need it. */
.title {
  display: flex;
  align-self: center;
  align-items: center;
  width: max-content;
  min-width: 100%;
  gap: 0 1.5rem;
  height: var(--title-height);
  color: var(--white);
}

/* Thin, smooth HD letters over the game's fat pixels, both the same width. */
.logo {
  margin: 0;
  line-height: 1;
}

/* The logo links back to the start screen. */
.logo a {
  display: flex;
  align-items: baseline;
  gap: 0.4em;
  text-decoration: none;
}

.logo__modern {
  font-family: var(--font-title);
  font-size: 3rem;
  font-weight: 400;
  font-stretch: 125%;
  line-height: 0.8;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--white);
}

/* 64 px is four times the font's 16 px, so every pixel stays square. */
.logo__stunts {
  font-family: var(--font-game);
  font-size: 64px;
  font-weight: normal;
  text-transform: uppercase;
  color: var(--panel-text);
  text-shadow: 4px 4px 0 var(--stripe-red);
}

/* Flush right, so the title row spans the window below it. */
.title p {
  margin: 0 0 0 auto;
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 600;
}

/* The game window: a picture over a text box, the buttons beside the box */

/* One grid for the open screen and the buttons, so the buttons always sit
   in the text box's row. */
.game {
  box-sizing: border-box;
  display: grid;
  flex: 1;
  min-height: 0;
  grid-template-columns: 1fr var(--buttons-width);
  grid-template-rows: minmax(0, 1fr) var(--box-height);
  background: var(--panel);
  border: var(--frame) solid;
  border-color: var(--panel-light) var(--panel-dark) var(--panel-dark) var(--panel-light);
}

/* Opening a screen scrolls to the page top, so the title stays in view. */
.screen {
  display: none;
  scroll-margin-top: 100vh;
}

.screen:target,
.game:not(:has(> .screen:target)) > #home {
  display: grid;
  grid-row: 1 / 3;
  grid-column: 1 / -1;
  min-height: 0;
  grid-template-columns: subgrid;
  grid-template-rows: subgrid;
}

.screen__picture {
  grid-column: 1 / -1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--black);
}

/* The start screen's reel, with a play button in the game's bevel style. */
.player {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.player video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.player__play {
  position: absolute;
  padding: 0.75rem 2rem 0.75rem 1.5rem;
  background: var(--panel);
  color: var(--panel-text);
  font-family: var(--font-game);
  font-size: 2rem;
  border: 5px solid;
  border-color: var(--panel-light) var(--panel-dark) var(--panel-dark) var(--panel-light);
  cursor: pointer;
}

/* A triangle drawn with borders, pointing right. */
.player__play::before {
  content: "";
  display: inline-block;
  margin-right: 0.75rem;
  border-style: solid;
  border-width: 0.5em 0 0.5em 0.85em;
  border-color: transparent transparent transparent currentcolor;
  vertical-align: -0.05em;
}

.player__play:hover,
.player__play:focus-visible {
  outline: 4px solid var(--magenta);
  outline-offset: 0;
}

.player__play:active {
  border-color: var(--panel-dark) var(--panel-light) var(--panel-light) var(--panel-dark);
}

.player__play[hidden] {
  display: none;
}

/* The Plugins page sits on the Options menu's blue, as in the game. */
.screen__picture--options {
  padding: 1.5rem;
  background: #5555ff;
}

/* Text links in the game's yellow. */
.screen__box a:not(.game-button) {
  color: var(--yellow);
}

/* The car menu's sunken text box. */
.screen__box {
  overflow: auto;
  margin: 0.5rem 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--panel);
  border: 4px solid;
  border-color: var(--panel-dark) var(--panel-light) var(--panel-light) var(--panel-dark);
}

.screen__box p:last-child {
  margin-bottom: 0;
}

/* The four new features, each marked in a road sign's colour. */
.news {
  margin: 0;
  padding: 0;
  list-style: none;
}

.news li {
  padding-left: 1.75rem;
  background-repeat: no-repeat;
  background-position: 0 0.3em;
  background-size: 1rem 1rem;
}

.news--red    { background-image: linear-gradient(#c80000, #c80000); }
.news--green  { background-image: linear-gradient(#208c20, #208c20); }
.news--blue   { background-image: linear-gradient(#0030c0, #0030c0); }
.news--orange { background-image: linear-gradient(#f09800, #f09800); }

/* Buttons */

.buttons {
  grid-row: 2;
  grid-column: 2;
  display: grid;
  grid-auto-rows: 1fr;
  gap: 0.35rem;
  height: var(--box-height);
  padding: 0.5rem 0.75rem 0.5rem 0;
}

/* A tighter line height fits six buttons in the text box's height. */
.game-button {
  display: grid;
  font-family: var(--font-game);
  line-height: 1.2;
  place-content: center;
  padding: 0 0.75rem;
  background: var(--panel);
  color: var(--panel-text);
  text-align: center;
  text-decoration: none;
  border: 4px solid;
  border-color: var(--panel-light) var(--panel-dark) var(--panel-dark) var(--panel-light);
}

/* The game marks the button under the pointer with a magenta frame. */
.game-button:hover,
.game-button:focus-visible {
  outline: 4px solid var(--magenta);
  outline-offset: 0;
}

.game-button:active {
  border-color: var(--panel-dark) var(--panel-light) var(--panel-light) var(--panel-dark);
}

.game-button small {
  display: block;
}

/* Download: a table with each download's button, where its stunts and roms
   folders go, and where its Jukebox songs go. */
.systems {
  width: 100%;
  margin: 0 0 1rem;
  border-collapse: collapse;
}

.systems thead td {
  border-top: 0;
}

.systems th {
  padding: 0 0.75rem 0.5rem 0;
  font-weight: normal;
  text-align: left;
  vertical-align: bottom;
}

.systems td {
  padding: 0.5rem 0.75rem 0.5rem 0;
  border-top: 1px solid var(--panel-light);
  vertical-align: middle;
}

.systems td:first-child {
  width: 9rem;
}

#download h3 {
  margin: 0 0 0.5rem;
  font-size: 1em;
  font-weight: normal;
}

/* A heavier line in the bevel's colour between the table and the list. */
.divided {
  padding-top: 1rem;
  border-top: 3px solid var(--panel-light);
}

/* Each folder's name beside what goes in it. */
.contents {
  margin: 0;
}

.contents div {
  display: grid;
  grid-template-columns: 14ch 1fr;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.2rem 0;
}

.contents dd {
  margin: 0;
}

.rom-files {
  margin: 0.25rem 0 0;
  padding-left: 1.25rem;
}

/* Download's long paths and notes in modern type, the labels in the game's. */
#download .systems td + td,
#download .contents div {
  font-family: var(--font-title);
  font-size: 1.15rem;
}

#download .systems td + td code,
#download .contents dt,
#download .contents dd code {
  font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: 0.95em;
}

/* Download and Credits are text only: they grow past the window's height,
   and the page scrolls. */
body:has(#download:target, #compete:target, #credits:target) {
  height: auto;
}

/* No picture: the box starts at the top, and the buttons sit beside it. */
.game:has(#download:target, #compete:target, #credits:target) {
  grid-template-rows: auto;
}

.game:has(#download:target, #compete:target, #credits:target) .buttons {
  grid-row: 1;
}

#download:target,
#compete:target,
#credits:target {
  grid-row: 1;
}

/* Credits: each name in the game's lettering beside its text in modern type. */
.credits {
  margin: 0;
}

.credits div {
  display: grid;
  grid-template-columns: 9ch 1fr;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.15rem 0;
}

.credits dd {
  margin: 0;
  font-family: var(--font-title);
  font-size: 1.05rem;
  line-height: 1.35;
}

/* Short screens: the game's crisp 16 px text, a shorter box, a smaller logo. */
@media (max-height: 50rem) {
  #download .systems td + td,
  #download .contents div {
    font-size: 1rem;
  }

  :root {
    --buttons-width: 10rem;
    --box-height: 14rem;
    --title-height: 3.5rem;
  }

  body {
    font-size: 1rem;
  }

  /* Three times the font's size keeps the logo's pixels square. */
  .logo__stunts {
    font-size: 48px;
    text-shadow: 3px 3px 0 var(--stripe-red);
  }

  .logo__modern {
    font-size: 2.25rem;
  }

  .title p {
    font-size: 1rem;
  }
}

/* Phones: the page scrolls, and each screen stacks its picture, its text box,
   then the buttons in two columns. The game's 16 px text keeps lines long. */
@media (max-width: 45rem) {
  body {
    height: auto;
    padding: 0.75rem;
    font-size: 1rem;
  }

  .title {
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    width: auto;
    height: auto;
    margin-bottom: 0.75rem;
  }

  .logo__modern {
    font-size: 1.75rem;
  }

  /* Twice the font's 16 px keeps the logo's pixels square. */
  .logo__stunts {
    font-size: 32px;
    text-shadow: 2px 2px 0 var(--stripe-red);
  }

  .title p {
    margin: 0;
    font-size: 1rem;
  }

  .game,
  .game:has(#download:target, #compete:target, #credits:target) {
    display: flex;
    flex-direction: column;
  }

  .screen:target,
  .game:not(:has(> .screen:target)) > #home {
    display: block;
  }

  .screen__picture {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .buttons {
    height: auto;
    padding: 0 0.75rem 0.75rem;
    grid-template-columns: repeat(2, 1fr);
  }

  .game-button {
    padding-block: 0.35rem;
  }

  .player__play {
    font-size: 1.25rem;
    padding: 0.5rem 1.25rem 0.5rem 1rem;
  }

  /* Each download stacks: its button, then where its folders go, each line
     labelled, since a phone has no room for the table's columns. */
  .systems thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .systems tr {
    display: block;
    padding: 0.5rem 0;
    border-top: 1px solid var(--panel-light);
  }

  .systems td {
    display: block;
    padding: 0.15rem 0;
    border: 0;
    overflow-wrap: anywhere;
  }

  .systems td:first-child {
    width: 10rem;
    padding-bottom: 0.4rem;
  }

  .systems td:nth-child(2)::before,
  .systems td:nth-child(3)::before {
    display: block;
    font-family: var(--font-game);
  }

  .systems td:nth-child(2)::before {
    content: "stunts and roms folders go";
  }

  .systems td:nth-child(3)::before {
    content: "jukebox folder is at";
  }

  #download .systems td + td,
  #download .contents div,
  .credits dd {
    font-size: 1rem;
  }

  .contents div,
  .credits div {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0.35rem 0;
  }
}
