/* Bushcamp Games shell styles for the game pages: phone-landscape layouts.
   Injected by integrations/games.mjs; rules are scoped with html[data-bcg-game] (set by bcg-shell.js),
   which also gives them enough specificity to beat each game's own styles. */

/* Links bcg-shell.js adds into the games' menus: look like the game's own buttons, not web links */
a[data-bcg-nav] {
  color: inherit;
  text-decoration: none;
}

/* No zooming in the games: no double-tap zoom, and text boxes at 16px so iPhone Safari doesn't
   zoom in when one is tapped (bcg-shell.js also pins the viewport scale). */
html[data-bcg-game],
html[data-bcg-game] body {
  touch-action: manipulation;
}
/* the main play surfaces take taps but never browser pan/zoom gestures (menus keep scrolling) */
html[data-bcg-game='park-the-bus'] #cv,
html[data-bcg-game='singletrack-trails'] #cv,
html[data-bcg-game='slipstream'] #world,
html[data-bcg-game='gnome-hollow'] #stageCv {
  touch-action: none;
}
@media (pointer: coarse) {
  html[data-bcg-game] input:not([type='checkbox']):not([type='radio']):not([type='range']),
  html[data-bcg-game] textarea,
  html[data-bcg-game] select {
    font-size: max(16px, 1em);
  }
}

/* Phones held sideways: wide but short. */
@media (orientation: landscape) and (max-height: 500px) {
  /* ---------- Park the Bus: pitch on the left at full height, scoreboard/tools/tray beside it ---------- */
  html[data-bcg-game='park-the-bus'] body {
    --pw: min(calc((100dvh - 50px) * 960 / 576), calc(100vw - 240px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
    display: grid;
    grid-template-columns: var(--pw) minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 6px 10px;
    height: 100dvh;
    overflow: hidden;
    box-sizing: border-box;
    padding: 6px calc(8px + env(safe-area-inset-right, 0px)) 6px calc(8px + env(safe-area-inset-left, 0px));
  }
  html[data-bcg-game='park-the-bus'] .app {
    display: contents;
  }
  html[data-bcg-game='park-the-bus'] .stage {
    grid-column: 1;
    grid-row: 1 / 4;
    align-self: center;
    width: var(--pw);
  }
  html[data-bcg-game='park-the-bus'] .hoarding {
    height: 22px;
  }
  html[data-bcg-game='park-the-bus'] .top {
    grid-column: 2;
    grid-row: 1;
    gap: 0;
  }
  html[data-bcg-game='park-the-bus'] .brand,
  html[data-bcg-game='park-the-bus'] .savenote,
  html[data-bcg-game='park-the-bus'] .help {
    display: none;
  }
  html[data-bcg-game='park-the-bus'] .board {
    width: 100%;
  }
  html[data-bcg-game='park-the-bus'] .cell {
    flex: 1;
    min-width: 0;
    padding: 3px 2px 2px;
  }
  html[data-bcg-game='park-the-bus'] .lbl {
    font-size: 8.5px;
    letter-spacing: 0.06em;
  }
  html[data-bcg-game='park-the-bus'] .val {
    font-size: 18px;
  }
  html[data-bcg-game='park-the-bus'] .controls {
    grid-column: 2;
    grid-row: 2;
    gap: 5px;
  }
  html[data-bcg-game='park-the-bus'] .controls .primary {
    flex: 1 1 100%;
    padding: 7px 6px;
    font-size: 13px;
  }
  html[data-bcg-game='park-the-bus'] .tools {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    margin: 0;
    gap: 4px;
  }
  html[data-bcg-game='park-the-bus'] .tool {
    flex-direction: column;
    gap: 1px;
    padding: 4px 1px;
    font-size: 9.5px;
    font-weight: 600;
  }
  html[data-bcg-game='park-the-bus'] .tool svg {
    width: 15px;
    height: 15px;
  }
  html[data-bcg-game='park-the-bus'] .tool .long {
    display: none;
  }
  html[data-bcg-game='park-the-bus'] .tool .short {
    display: inline;
  }
  html[data-bcg-game='park-the-bus'] .tray {
    grid-column: 2;
    grid-row: 3;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    align-content: start;
    gap: 5px;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: 4px;
  }
  html[data-bcg-game='park-the-bus'] .kit {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    padding: 4px 2px;
    gap: 0;
    font-size: 11px;
    line-height: 1.1;
    border-left-width: 1px;
    border-top: 3px solid var(--ring);
  }
  html[data-bcg-game='park-the-bus'] .kit canvas {
    grid-row: auto;
    width: 26px;
    height: 26px;
  }
  html[data-bcg-game='park-the-bus'] .kit .nm {
    justify-content: center;
    font-size: 10px;
    overflow-wrap: anywhere;
    text-wrap: balance;
  }
  html[data-bcg-game='park-the-bus'] .kit .meta {
    align-items: center;
  }
  html[data-bcg-game='park-the-bus'] .kit .meta,
  html[data-bcg-game='park-the-bus'] .kit .meta * {
    font-size: 12px;
  }
  html[data-bcg-game='park-the-bus'] .kit .rl,
  html[data-bcg-game='park-the-bus'] .kit .nm kbd {
    display: none;
  }

  /* ---------- Slipstream: compact the race HUD so it clears the steering buttons ---------- */
  html[data-bcg-game='slipstream'] .hud-tl {
    top: calc(8px + env(safe-area-inset-top, 0px));
    left: calc(8px + env(safe-area-inset-left, 0px));
    gap: 4px;
  }
  html[data-bcg-game='slipstream'] .hud-box {
    min-width: 0;
    padding: 3px 9px;
    gap: 0;
  }
  html[data-bcg-game='slipstream'] .hud-box .lab {
    font-size: 8.5px;
  }
  html[data-bcg-game='slipstream'] .hud-pos {
    font-size: 26px;
    line-height: 1;
  }
  html[data-bcg-game='slipstream'] .hud-val {
    font-size: 14px;
  }
  /* the full timing tower doesn't fit; position and lap stay visible */
  html[data-bcg-game='slipstream'] #tower {
    display: none;
  }
  html[data-bcg-game='slipstream'] #mini {
    right: calc(8px + env(safe-area-inset-right, 0px));
    top: calc(8px + env(safe-area-inset-top, 0px));
    width: 112px;
    height: 90px;
  }
  html[data-bcg-game='slipstream'] .hud-btn {
    right: calc(128px + env(safe-area-inset-right, 0px));
    top: calc(8px + env(safe-area-inset-top, 0px));
  }

  /* ---------- Gnome Hollow: gnome always on the left, Store/Hollow beside it, one-row header ---------- */
  html[data-bcg-game='gnome-hollow'] .app {
    padding-inline: env(safe-area-inset-left, 0px) env(safe-area-inset-right, 0px);
  }
  html[data-bcg-game='gnome-hollow'] .top {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    padding-block: 4px;
    row-gap: 0;
  }
  html[data-bcg-game='gnome-hollow'] .count {
    grid-column: auto;
    grid-row: auto;
  }
  html[data-bcg-game='gnome-hollow'] .count .n {
    font-size: 1.35rem;
  }
  html[data-bcg-game='gnome-hollow'] .cols {
    grid-template-columns: minmax(0, 42%) minmax(0, 1fr);
  }
  html[data-bcg-game='gnome-hollow'] #col-gnome {
    display: block;
    padding-bottom: 0;
  }
  html[data-bcg-game='gnome-hollow'] .col + .col {
    border-left: 1px solid var(--line);
  }
  html[data-bcg-game='gnome-hollow'] .col:not(#col-gnome) {
    padding-bottom: calc(52px + env(safe-area-inset-bottom, 0px));
  }
  /* before the script picks a panel (or if it can't), show the Store */
  html[data-bcg-game='gnome-hollow'] .cols:has(#col-gnome.on) #col-store {
    display: block;
  }
  html[data-bcg-game='gnome-hollow'] .mnav {
    left: 42%;
    grid-template-columns: repeat(2, 1fr);
  }
  html[data-bcg-game='gnome-hollow'] .mnav [data-col='col-gnome'] {
    display: none;
  }
  html[data-bcg-game='gnome-hollow'] .mnav button {
    padding-block: 9px;
  }
  html[data-bcg-game='gnome-hollow'] .toasts {
    left: 42%;
  }
}

/* ---------- Singletrack Trails on an upright phone: drawn sideways (bcg-shell.js forceLandscape) ---------- */
html.bcg-rotated,
html.bcg-rotated body {
  overflow: hidden !important;
}
html.bcg-rotated body {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  margin: 0 !important;
  width: var(--bcg-h) !important;
  height: var(--bcg-w) !important;
  transform-origin: 0 0;
  transform: translateX(var(--bcg-w)) rotate(90deg);
}
/* the game's own "turn your phone sideways" hint isn't needed any more */
html.bcg-rotated .rotate {
  display: none !important;
}
/* vw/vh still measure the upright screen, so restate the game's viewport-unit rules in the rotated
   frame: frame width = var(--bcg-h), frame height = var(--bcg-w) */
html.bcg-rotated #leanzone {
  width: calc(var(--bcg-h) * 0.44);
  height: calc(var(--bcg-w) * 0.62);
}
html.bcg-rotated h1 {
  font-size: clamp(40px, calc(var(--bcg-h) * 0.07), 68px);
}
html.bcg-rotated .homehead h1 {
  font-size: clamp(34px, calc(var(--bcg-h) * 0.06), 54px);
}
html.bcg-rotated .tlogo h1 {
  font-size: clamp(48px, calc(var(--bcg-h) * 0.09), 86px);
}
html.bcg-rotated .card {
  margin-top: calc(var(--bcg-w) * 0.06);
}
html.bcg-rotated .namecard {
  margin-top: calc(var(--bcg-w) * 0.12);
}
html.bcg-rotated .stand {
  max-height: calc(var(--bcg-w) * 0.46);
}
html.bcg-rotated .title {
  min-height: calc(var(--bcg-w) - 40px);
}

/* Menu ad unit added by bcg-shell.js (outside the games' re-rendered menus; never shown during play) */
.bcg-ad {
  box-sizing: border-box;
  width: min(728px, calc(100% - 32px));
  margin: 20px auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bcg-ad[hidden] {
  display: none;
}
/* see AdSlot.astro: no label until an ad fills, nothing at all if unfilled, and no white frame */
.bcg-ad:not(:has(ins[data-ad-status='filled'])) .bcg-ad-label {
  visibility: hidden;
}
.bcg-ad:has(ins[data-ad-status='unfilled']) {
  display: none;
}
.bcg-ad ins {
  color-scheme: light;
}
.bcg-ad-label {
  font: 600 10px/1 system-ui, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  opacity: 0.55;
}
.bcg-ad ins,
.bcg-ad-preview {
  min-height: 90px; /* reserved, so the menu doesn't jump when the ad loads */
}
.bcg-ad-preview {
  display: grid;
  place-items: center;
  border: 1px dashed currentColor;
  border-radius: 8px;
  opacity: 0.5;
  font: 12px system-ui, sans-serif;
}
/* Gnome Hollow: the unit sits inside the Options pane */
html[data-bcg-game='gnome-hollow'] .bcg-ad {
  width: 100%;
  margin: 16px 0 0;
}
/* Slipstream: #scr is a flex row, so wrap the unit onto its own full-width line below the panel */
html[data-bcg-game='slipstream'] #scr {
  flex-wrap: wrap;
  align-content: flex-start;
}
html[data-bcg-game='slipstream'] .bcg-ad {
  flex: 0 0 100%;
  width: 100%;
  margin: 20px 0;
  padding-inline: max(0px, calc((100% - 728px) / 2));
}

/* One-time iPhone hint: add the game to the Home Screen to play without Safari's bars */
.bcg-tip {
  position: fixed;
  left: 50%;
  top: calc(10px + env(safe-area-inset-top, 0px));
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 24px);
  padding: 8px 8px 8px 14px;
  border-radius: 12px;
  background: rgba(20, 18, 15, 0.92);
  color: #f2e9da;
  font: 500 13px/1.35 system-ui, sans-serif;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}
.bcg-tip svg {
  vertical-align: -2px;
}
.bcg-tip button {
  flex: none;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 13px;
}
