/* YOU STILL DOWN BRO? — few colors, pixel shapes, no scroll. */

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

:root {
  --sky: #3c44c8;
  --ink: #141038;
  --sign: #b83c00;
  --sign-dark: #7a2400;
  --sign-light: #e45c10;
  --cream: #f8e0a0;
  --white: #f8f8f8;
  --lamp: #f8d878;
  --ad: rgba(20, 16, 56, 0.35);
  --px: 4px;
  --font: "Press Start 2P", "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--sky);
  color: var(--white);
  font-family: var(--font);
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: unset;
  -webkit-text-size-adjust: 100%;
}

#scene {
  position: fixed;
  left: 0;
  top: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  z-index: 0;
}

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

/* ---- layout: promo rail | stage | ad rail ----
   Tiers (keep in sync with scene.js BANNER_MAX and test/verify_ui.py):
   >=1080px  three columns: Site Upgrader card (320-360px) | sign | 160x600 ad rail.
   920-1079  two columns: card | sign. The reserved ad inventory drops to the
             320x50 bottom banner so the empty placeholder never squeezes the card.
   <920      one column: card hidden, compact strip inside the sign, bottom banner. ---- */

.layout {
  position: relative;
  z-index: 1;
  height: 100%;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(320px, 1.5fr) minmax(560px, 720px) minmax(160px, 1fr);
  grid-template-rows: 100%;
  gap: 0 8px;
  padding: 0 8px;
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  min-height: 0;
  padding: max(8px, env(safe-area-inset-top)) 0 max(8px, env(safe-area-inset-bottom));
}

/* ---- rails: promo (left, editorial) and ad slot (right, reserved) ---- */

.ad, .rail {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  /* Tracks the sign's top edge: HUD (~24px) + the sign's clamp() margin. */
  padding-top: calc(24px + clamp(10px, 4vh, 40px));
}
.ad-box {
  width: 160px;
  height: 600px;
  max-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed rgba(248, 248, 248, 0.25);
  background: var(--ad);
  color: rgba(248, 248, 248, 0.4);
  font-size: 10px;
  letter-spacing: 2px;
}

/* ---- Site Upgrader promo: rail card (ported from Play It Backwards, same copy/price/CTA).
   Not an .ad-box on purpose: ad-blocker lists hide generic ad class names.
   320px wide at the narrowest rail, up to 360px where the rail allows; the phone
   mockup takes whatever height is left under the copy (see --phone-w). ---- */

.promo {
  --p-ink: #e9e4da;
  --p-ink-dim: #8e887c;
  --p-red: #8a2b2b;
  --p-red-2: #a53434;
  --p-mono: "Courier Prime", "Courier New", Courier, "Nimbus Mono PS", monospace;
  --p-sans: -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue", Arial, sans-serif;
  /* Phone width from the viewport height: the copy block above it is ~330px tall,
     the rail padding ~60px; 9:17 frame => width = height * 0.53. */
  --phone-w: clamp(112px, calc((100dvh - 440px) * 0.53), 200px);
  width: min(100%, 360px);
  max-height: calc(100% - 8px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 18px 18px 14px;
  border: 1px solid #2a2320;
  border-radius: 4px;
  background: linear-gradient(180deg, #0c0909, #000);
  color: var(--p-ink);
  font-family: var(--p-sans);
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0;
  text-align: left;
  -webkit-font-smoothing: auto;
}
.promo[hidden] { display: none; }
.promo-text { flex: 0 0 auto; }
.promo-label { display: block; font-family: var(--p-mono); font-size: 9px; letter-spacing: .18em; color: var(--p-red-2); text-transform: uppercase; margin-bottom: 10px; }
.promo-head { font-family: var(--p-mono); font-weight: 400; font-size: 16px; line-height: 1.3; margin: 0 0 10px; letter-spacing: .02em; color: var(--p-ink); }
.promo-copy { margin: 0 0 8px; color: var(--p-ink-dim); }
.promo-copy:last-of-type { margin-bottom: 10px; }
.promo-copy strong { color: var(--p-ink); }
.promo-price { font-family: var(--p-mono); font-size: 11px; line-height: 1.5; letter-spacing: .02em; color: var(--p-ink-dim); margin: 0 0 12px; }
.promo-price strong { color: var(--p-ink); font-size: 24px; font-weight: 400; margin-right: 6px; }
.promo-cta {
  display: block;
  width: 100%;
  padding: 12px 10px;
  border: 1px solid var(--p-red-2);
  border-radius: 3px;
  background: var(--p-red);
  color: var(--p-ink);
  font-family: var(--p-sans);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .06em;
  text-align: center;
  text-decoration: none;
}
.promo-cta:hover, .promo-cta:focus-visible { background: var(--p-red-2); outline: 0; }
.promo-phone { flex: 0 1 auto; min-height: 0; margin: 14px auto 0; width: var(--phone-w); max-width: 100%; }
.promo-phone-frame {
  position: relative; aspect-ratio: 9 / 17; overflow: hidden;
  border-radius: 18px; border: 1px solid #3a3732; background: #0a0a0a; padding: 4px;
  box-shadow: 0 12px 26px -16px rgba(165, 52, 52, .55);
}
.promo-phone-frame img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; border-radius: 14px; image-rendering: auto; }
.promo-phone-frame::after { content: ""; position: absolute; left: 50%; top: 9px; width: 34px; height: 4px; margin-left: -17px; border-radius: 2px; background: rgba(0, 0, 0, .6); }
.promo-phone figcaption { margin-top: 7px; text-align: center; font-family: var(--p-mono); font-size: 8px; letter-spacing: .1em; color: var(--p-ink-dim); text-transform: uppercase; }

/* ---- AdSense inventory: reserved box until a real unit is configured ---- */

.ad-box.is-live { border-style: solid; border-color: transparent; background: transparent; }
.adspace-unit { width: 100%; height: 100%; }
.adspace-unit[hidden] { display: none; }

/* ---- Site Upgrader promo: compact strip (narrow screens only) ---- */

.promo-strip {
  display: none;
  margin: 10px -4px 0;
  padding: 7px 8px;
  background: var(--ink);
  border: 2px solid var(--cream);
  color: var(--white);
  font-size: 8px;
  line-height: 1.5;
  text-decoration: none;
  text-shadow: none;
}
.promo-strip[hidden] { display: none; }
.promo-strip-label { display: block; color: var(--lamp); letter-spacing: 1px; text-transform: uppercase; }
.promo-strip-offer { display: block; }
.promo-strip-offer strong { color: var(--lamp); font-weight: 400; }
.promo-strip-cta { color: var(--cream); white-space: nowrap; }
.promo-strip:hover .promo-strip-cta, .promo-strip:focus-visible .promo-strip-cta { color: var(--lamp); }
.promo-strip:focus-visible { outline: 2px solid var(--lamp); outline-offset: 2px; }

/* ---- HUD ---- */

.hud {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 2px 4px;
  font-size: 12px;
  line-height: 1;
  text-shadow: 2px 2px 0 var(--ink);
  white-space: nowrap;
}
.hud-label { color: var(--cream); }
.hud-right time { font-variant-numeric: tabular-nums; }

/* ---- the sign ---- */

.sign {
  width: min(100%, 560px);
  margin: clamp(10px, 4vh, 40px) auto 0;
  padding: 14px 16px 16px;
  background: var(--sign);
  border: var(--px) solid var(--ink);
  box-shadow:
    inset 0 0 0 var(--px) var(--sign-light),
    inset 0 0 0 calc(var(--px) * 2) var(--sign-dark),
    var(--px) var(--px) 0 var(--ink);
}

.title {
  margin: 0 0 12px;
  line-height: 1;
  color: var(--cream);
  text-shadow: 3px 3px 0 var(--ink);
}
.title span { display: block; }
.t-small {
  font-size: clamp(10px, 2.2vw, 16px);
  margin: 0 0 8px 2px;
  letter-spacing: 1px;
}
.t-big {
  font-size: clamp(22px, 6.4vw, 44px);
  color: var(--white);
  white-space: nowrap;
  letter-spacing: 0;
}
.t-big .t-down,
.t-big .t-bros { display: inline; letter-spacing: 0; }

/* ---- input + menu ---- */

.check { display: block; }

.field {
  display: flex;
  align-items: center;
  background: var(--ink);
  border: var(--px) solid var(--white);
  padding: 0 6px;
}
.field-prefix {
  color: var(--cream);
  font-size: 14px;
  padding-right: 6px;
}
#url {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--white);
  font: inherit;
  font-size: 14px;
  padding: 11px 0;
  caret-color: var(--cream);
}
#url::placeholder { color: rgba(248, 248, 248, 0.35); }
.field:focus-within { border-color: var(--cream); }

.menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}
.menu-item {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 6px 4px;
  color: var(--white);
  font: inherit;
  font-size: 12px;
  line-height: 1;
  text-align: left;
  text-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.menu-item .cursor { visibility: hidden; color: var(--cream); font-size: 10px; width: 12px; }
.menu-item:hover .cursor,
.menu-item:focus-visible .cursor,
.menu-item.is-active .cursor { visibility: visible; }
.menu-item:focus-visible { outline: 0; }
.menu-item:disabled { cursor: progress; opacity: 0.8; }

/* ---- result ---- */

.result {
  margin: 14px 0 0;
  min-height: 1em;
  font-size: 13px;
  line-height: 1.5;
  color: var(--cream);
  text-shadow: 2px 2px 0 var(--ink);
}
.result:empty { margin-top: 0; min-height: 0; }
body[data-status="up"] .result { color: var(--lamp); }
body[data-status="down"] .result { color: var(--white); }
body[data-status="busy"] .result::after {
  content: "";
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  margin-left: 6px;
  background: var(--cream);
  animation: blink 0.6s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.detail {
  margin: 6px 0 0;
  font-size: 9px;
  line-height: 1.6;
  color: var(--cream);
  opacity: 0.9;
  text-shadow: 1px 1px 0 var(--ink);
  overflow-wrap: anywhere;
}
.detail:empty { margin: 0; }

/* ---- footer ---- */

.foot {
  margin-top: auto;
  font-size: 8px;
  line-height: 1.4;
  text-align: center;
  color: var(--cream);
  text-shadow: 1px 1px 0 var(--ink);
  opacity: 0.9;
  padding: 4px 8px;
}
.foot-sep { padding: 0 6px; }

/* Wide monitors: equal rails so the sign sits centred (card is already at its 360px max). */
@media (min-width: 1600px) {
  .layout { grid-template-columns: minmax(320px, 1fr) minmax(560px, 720px) minmax(160px, 1fr); }
}

/* ---- 920-1079px: keep the full card beside the sign; the reserved ad inventory
   becomes the 320x50 bottom banner (the 160px rail would otherwise force the card
   back to a sliver). 920px is the narrowest width that fits 320px card + 560px sign
   (+ gaps/padding). Keep in sync with scene.js BANNER_MAX and test/verify_ui.py. ---- */

@media (max-width: 1079px) {
  .layout {
    grid-template-columns: 320px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .ad-b { grid-column: 1 / -1; align-items: center; padding: 4px 0 max(4px, env(safe-area-inset-bottom)); }
  .ad-b .ad-box { width: 320px; max-width: 100%; height: 50px; }
  .foot { display: none; }
  /* The bottom banner (58px) shortens the rail; keep the phone inside the card. */
  .promo { --phone-w: clamp(100px, calc((100dvh - 498px) * 0.6), 200px); }
}
@media (max-width: 1079px) and (max-height: 660px) {
  /* Two-column tier on a short window: no room under the copy for a legible phone. */
  .promo-phone { display: none; }
}
@media (min-width: 1080px) and (max-height: 599px) {
  .promo-phone { display: none; }
}

/* ---- narrow screens (<920px): rails collapse, strip inside the sign, one banner at the bottom. ---- */

@media (max-width: 919px) {
  .layout {
    grid-template-columns: 100%;
    gap: 0;
    padding: 0 12px;
  }
  .rail-promo { display: none; }
  .promo-strip:not([hidden]) { display: block; }
}

@media (max-width: 600px) {
  .sign { padding: 12px 12px 12px; margin-top: clamp(6px, 3vh, 24px); }
  .t-small { font-size: 10px; margin-bottom: 7px; }
  .t-big { font-size: clamp(22px, 8.6vw, 34px); }
  .hud { font-size: 10px; }
  #url { font-size: 12px; padding: 10px 0; }
  .menu-item { font-size: 9px; }
  .result { font-size: 11px; }
}

@media (max-height: 560px) {
  /* Short landscape screens: keep the no-scroll title screen, drop the strip. */
  .promo-strip { display: none !important; }
  .sign { margin-top: 6px; padding-top: 10px; padding-bottom: 10px; }
  .title { margin-bottom: 8px; }
  .menu { margin-top: 8px; gap: 2px; }
  .result { margin-top: 8px; }
  .detail { margin-top: 4px; font-size: 8px; line-height: 1.4; }
}

@media (prefers-reduced-motion: reduce) {
  body[data-status="busy"] .result::after { animation: none; }
}
