/* "Suck It!" vacuum game styles (see game.js / DESIGN.md).
   Depends on the shared color tokens from ../css/colors.css. */

:root,
:root.light,
:root.dark {
  color-scheme: dark;
  /* The game is always dark, but this page has no dark-mode toggle, so a
     light-OS visitor would otherwise keep colors.css's light token values
     (black text) on the dark canvas. Pin the dark values so the HUD and
     header stay readable regardless of OS theme. */
  --bgcolor: #13181e;
  --fontcolor: #ffffff;
  --footer-text: #dddddd;
  --border: #cccccc;
  --buttonborder: #cccccc;
  --imgshadow: #dddddd;
}

* {
  box-sizing: border-box;
}

/* Keyboard a11y: visible focus ring for the game's controls */
:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Visually hidden, e.g. the off-screen page <h1> for the document outline */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html,
body {
  margin: 0; /* game page doesn't load main.css; kill default body margin (was causing overflow scrollbar) */
  background: #13181e;
}
/* column layout so an in-flow header (the mobile top bar) and the game share
   the viewport height cleanly; on desktop the header is absolute, so .game
   still gets the whole height. */
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* source-code link: top-right, out of the lower touch-steering zone */
.header {
  font-size: 16px;
  position: absolute;
  top: 10px;
  right: 10px;
  color: var(--footer-text);
  z-index: 10;
}

.navbar {
  /* opaque page-color fill so the tiled logo wallpaper (body::before) doesn't
     show through behind the links and clutter them */
  background-color: var(--bgcolor);
  border-left: 1px solid var(--footer-text);
  border-right: 1px solid var(--footer-text);
  border-bottom: 1px solid var(--footer-text);
  padding: 6px;
  margin-left: 10px;
  margin-right: 10px;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 0 4px 1px var(--footer-text);
}

/* <main> fills exactly the viewport -- dvh accounts for the mobile URL bar
   so nothing spills past the bottom into a scrollbar */
.game {
  flex: 1 1 auto;
  min-height: 0; /* fill the height the header leaves; shrink so the canvas fits */
  overflow: hidden;
}
#gamefield {
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 22px; /* clear the fixed source-code link row above the controls */
}

/* controls (mode + reset) + HUD sit directly above the field, NOT captured
   by touch steering */
/* controls row + status box stacked and unified to one width */
.control-panel {
  display: inline-flex; /* shrink-to-fit the wider of the two rows */
  flex-direction: column;
  align-items: stretch; /* both rows take the panel's (widest-child) width */
  gap: 8px;
}
.game-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center; /* keep buttons centered if the row is stretched to match */
}
button {
  font-size: 14px;
}

/* buttons + dropdown: same styling as the main site (main.css) */
button,
.game-controls select {
  font-family: inherit;
  box-shadow: 1px 1px 1px 0 var(--buttonborder);
  border: 1px solid var(--buttonborder);
  border-radius: 5px;
  background-color: #292929;
  color: #ffffff;
  cursor: pointer;
}
button:hover,
.game-controls select:hover {
  background-color: #494949;
}
button:active {
  box-shadow: 1px 1px 1px 0 #222222 inset;
  background-color: #393939;
}
/* uniform control sizing: buttons and dropdown same height */
.game-controls button,
.game-controls select {
  height: 30px;
  box-sizing: border-box;
  font-size: 14px;
  padding: 0 8px;
  margin: 0;
  vertical-align: middle;
}
.game-hud {
  font-family: monospace;
  font-size: 18px;
  color: var(--fontcolor);
  text-align: center;
  white-space: nowrap;
  text-shadow: 1px 1px 0 #000; /* 1px black shadow, no blur */
  border: 1px solid var(--footer-text); /* outline box around the status area */
  border-radius: 5px; /* match the controls */
  padding: 4px 10px;
  margin: 4px 0; /* 4px breathing room from the buttons above + game below */
}

/* touch-steering zone: the field (canvas) plus all space below it. Canvas
   sits flush at the top of this zone (right under the controls); the empty
   space beneath is swipeable too. Controls above are outside this element. */
.game-play {
  flex: 1 1 auto;
  min-height: 0; /* let it shrink so the canvas fits with no page scroll */
  align-self: stretch;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  touch-action: none;
}
#gamefield canvas {
  max-width: 100%;
  max-height: 100%; /* fit the zone vertically too (aspect preserved, no overflow) */
  background-color: #232323;
  border: 2px solid var(--border); /* fixed game outline */
  image-rendering: pixelated; /* keep the 64px pixel art crisp when scaled */
}

/* The game is a full-viewport (100dvh) app, so the header must stay out of
   flow (absolute) at every width — going `static` would push the game area
   down and clip it. So instead of reflowing, center it horizontally while
   keeping it absolute (left:50% + translateX). */
@media (max-width: 1100px) {
  /* a real centered top bar (in flow) rather than a floating tab — so it no
     longer sits over the game controls, and the navbar has the full width to
     stay on one line. body flex + .game flex:1 absorb the bar's height. */
  .header {
    position: static;
    display: flex;
    justify-content: center;
    top: auto;
    right: auto;
    transform: none;
  }
  .navbar {
    margin: 0;
  }
  #gamefield {
    padding-top: 16px;
  }
}

/* Mobile layout */
@media (max-width: 800px) {
  body {
    overflow-x: hidden; /* belt-and-suspenders against stray page widening */
  }
  /* smaller nav font on phones (horizontal centering handled above) */
  .header {
    font-size: 14px;
  }
}
