/* ===================== Global & Video ===================== */
html, body { height: 100%; margin: 0; }
.page { position: relative; min-height: 100vh; }


.page {
  position: relative;
  min-height: 100vh;
  image-rendering: crisp-edges;  

  /* Tiled background */
  background:
    #000
    url('/assets/tile.png') 0 0 / var(--tile-size) var(--tile-size) repeat;

  /* Optional: keep the old poster if you want a fallback while tile loads
     background: #000 url('/assets/bg-poster.jpg') center/cover no-repeat,
                 url('/assets/tile.png') 0 0 / var(--tile-size) var(--tile-size) repeat; */
}

/* ===================== Portrait Stage (9:16) ===================== */
.stage-wrap {
  position: fixed;      /* pinned above video */
  inset: 0;             /* full viewport */
  display: grid;
  place-items: center;  /* center the stage box */
  z-index: 1;
}

.stage {
  position: relative;
  aspect-ratio: 9 / 16;
  width: min(100vw, calc(100vh * 9 / 16));
  /* height is implied by aspect-ratio */
  /* optional debug: outline: 1px dashed rgba(255,255,255,0.18); */
}

/* ===================== Tunable Controls ===================== */
:root{
  /* Tire fills the stage width at your preferred proportion */
  --tile-size: 256px; 

  --tire-width: 96%;

  /* Tire vertical slot (roughly top third) */
  --tire-top: 15%;

  /* Fine nudges (NOTE: your height adjustment is kept here) */
  --tire-nudge-x: -3px;
  --tire-nudge-y: 100px;  /* ← your tire height adjustment */

  /* Chain length relative to stage height */
  --chain-height: 34%;

  /* Button orbit radius for positioning math */
  --orbit-r: 40%;     /* smaller radius = closer to tire center */

  --hole-diam: 60%;

  --tsl-light: #1e579c;  /* inner fill */
  --tsl-mid:   #1e579c;  /* inner ring */
  --tsl-dark:  #0098db;  /* outer edge */

    /* Texvtbox sizing: fixed-ish across screens with safe bounds */
  --text-min-w: 320px;     /* never smaller than this */
  --text-pref-w: 62vmin;   /* preferred width tied to stage short side */
  --text-max-w: 900px;     /* never larger than this */

  --text-pad-y: clamp(10px, 1.2vmin, 16px);
  --text-pad-x: clamp(12px, 1.6vmin, 20px);

  /* Keep your existing gaps */
  --text-bottom-gap: 5%;
  --text-side-pad: 3.5vmin;
  --text-top-gap: 2vmin;

  --text-fs-min: 12px;   /* smallest allowed */
  --text-fs-ideal: 4vmin; /* fluid size tied to stage (short side) */
  --text-fs-max: 20px;   /* largest allowed */
}

/* ===================== Chain (top-center inside stage) ===================== */
.chain-img {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, 0);
  height: var(--chain-height);
  width: auto;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  z-index: 2;
}

/* ===================== Tire & Wrapper ===================== */
.tire-wrapper {
  position: absolute;
  top: var(--tire-top);
  left: 50%;
  transform: translate(-50%, 0) translate(var(--tire-nudge-x), var(--tire-nudge-y));
  width: var(--tire-width);
  aspect-ratio: 1 / 1;
  /* was: pointer-events: none; */
  pointer-events: auto;           /* ✅ allow button clicks inside */
  user-select: none;
  z-index: 3;
}

.tire-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;           /* ✅ tire itself stays click-through */
  user-select: none;
}

/* The square box aligned to the tire’s inner circle */
.tire-video-box {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--hole-diam);
  height: var(--hole-diam);
  transform: translate(-50%, -50%);
  z-index: 2;
  pointer-events: auto;   /* CHANGED from none → allows tap-to-advance */
}

/* Inner video visibility helpers */
.tire-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 0%;
  transform-origin: 50% 0%;
  display: block;
  pointer-events: auto;   /* can click the image */
  border-radius: 50%;
  opacity: 1;
  transition: opacity 120ms ease;
}
.tire-video.hidden { opacity: 0; }

/* Make sure stacking keeps the chain & tire above the inner video */
.chain-img { z-index: 2; }   /* chain in front of tire (adjust if you prefer) */
.tire-img  { z-index: 3; }   /* tire above the inner video */


.stage-text {
  /* same position as before */
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: var(--text-bottom-gap);
  margin-top: var(--text-top-gap);
  z-index: 6;
  opacity: 1;
  transition: opacity 140ms ease;

  /* ✅ size stays consistent across screens */
  width: min(
    clamp(var(--text-min-w), var(--text-pref-w), var(--text-max-w)),
    calc(100% - 2 * var(--text-side-pad))  /* still respect portrait margins */
  );

  /* TSL tire-edge look (unchanged, but scaled with vmin so relief stays even) */
  --edge: 8px;
  --inner: 12px;
  background: var(--tsl-light);
  border: var(--edge) solid var(--tsl-dark);
  box-shadow: inset 0 0 0 var(--inner) var(--tsl-mid);
  border-radius: 20px;

  /* typography & padding */
  color: white;
  padding: var(--text-pad-y) var(--text-pad-x);
  /* fluid, bounded type size */
  font-size: clamp(var(--text-fs-min), var(--text-fs-ideal), var(--text-fs-max));
  line-height: 1.5;

  /* make long URLs/words wrap nicely */
  overflow-wrap: anywhere;
  word-break: break-word;
  font-weight: 500;
  text-align: center; /* optional */
}

.stage-text a {
  color: #0ce6f2;             /* your link color */
  text-decoration: underline; /* optional */
}
.stage-text a:hover {
  color: #68c2d3;             /* hover color */
}

/* global hide helper */ .hidden { 
  opacity: 0; 
  pointer-events: none; 
  visibility: hidden; 
}

/* ===================== Lift tire + chain on smaller screens ===================== */
/* Mild lift on short viewports */
@media (max-height: 900px) {
  :root{
    --tire-top: 10%;     /* was 15% */
    --tire-nudge-y: 80px;/* was 100px */
    --chain-height: 30%; /* was 34%  → shorter chain = appears higher */
    --text-fs-ideal: 1.8vmin;
    --text-fs-min: 12px;
  }
}

/* More lift on very short viewports */
@media (max-height: 780px) {
  :root{
    --tire-top: 8%;
    --tire-nudge-y: 56px;
    --chain-height: 26%;
    --text-fs-ideal: 1.8vmin;
    --text-fs-min: 12px;
  }
}

/* Aggressive lift for the smallest heights */
@media (max-height: 680px) {
  :root{
    --tire-top: 8%;
    --tire-nudge-y: 40px;
    --chain-height: 22%;
    --text-fs-ideal: 1.8vmin;
    --text-fs-min: 12px;
  }
}

/* Narrow phones (portrait) – nudge a bit as well */
@media (max-width: 400px) {
  :root{
    --tire-top: 8%;
    --text-fs-ideal: 1.8vmin;
    --text-fs-min: 12px;
  }
}

/* ===================== iPad portrait tuning ===================== */
/* Older iPad / 9.7–10.2" (1024–1080px tall) */
@media (orientation: portrait) and (min-height: 1000px) and (max-height: 1080px) {
  :root{
    --tire-top: 12%;
    --tire-nudge-y: 84px;
    --chain-height: 30%;
    --text-fs-ideal: 2.2vmin;  /* a touch larger for readability */
    --text-fs-min: 13px;
  }
}

/* iPad mini 6 (~1133px tall) */
@media (orientation: portrait) and (min-height: 1081px) and (max-height: 1160px) {
  :root{
    --tire-top: 12%;
    --tire-nudge-y: 88px;
    --chain-height: 30%;
    --text-fs-ideal: 2.1vmin;
    --text-fs-min: 13px;
  }
}

/* iPad Air / Pro 10.5–11" (1180–1194px tall) */
@media (orientation: portrait) and (min-height: 1161px) and (max-height: 1210px) {
  :root{
    --tire-top: 13%;
    --tire-nudge-y: 92px;
    --chain-height: 31%;
    --text-fs-ideal: 2.0vmin;
    --text-fs-min: 13px;
  }
}

/* iPad Pro 12.9" (1366px tall) — close to desktop; mostly keep defaults */
@media (orientation: portrait) and (min-height: 1211px) and (max-height: 1400px) {
  :root{
    --tire-top: 15%;     /* same as your base */
    --tire-nudge-y: 100px;
    --chain-height: 34%;
    --text-fs-ideal: 1.9vmin;
    --text-fs-min: 14px;
  }
}

/* Fallback if aspect-ratio isn’t supported */
@supports not (aspect-ratio: 1 / 1) {
  .tire-wrapper {
    height: auto;
  }
  .stage {
    width: 100vw;
    height: 100vh; /* or compute 9:16 with padding-top trick */
  }
}

@media (prefers-reduced-motion: reduce) {        /* hide video */
  /* optionally show a static poster background */
  .page { background: #000 url('/assets/bg-poster.jpg') center/cover no-repeat; }
}

video::-webkit-media-controls-enclosure { display: none !important; }

.tire-video {
  will-change: transform, opacity;
}