/* =========================================================
   The Sick Kitten — mobile responsive fixes (global)
   Load after page CSS. Phone-first hardening for 320–430px
   and general overflow / safe-area / touch targets.
   ========================================================= */

/* =========================================================
   BREAKPOINTS (keep in sync with docs/BREAKPOINTS.md)
   Width:  360 | 400 | 520 | 560 | 640 | 720 | 820 | 960
   Other:  max-height 430 + landscape
           prefers-reduced-motion: reduce
   ========================================================= */



:root{
  --sk-gutter: clamp(12px, 3.5vw, 22px);
  --sk-touch: 44px;
}

/* Kill horizontal page scroll from sprockets, marquees, long CA strings */
html{
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body{
  overflow-x: clip;
  max-width: 100%;
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Media never forces wider than viewport */
img, video, canvas, svg{
  max-width: 100%;
  height: auto;
}
canvas{
  max-width: 100% !important;
}

/* Long mono strings (CA, wallets) wrap instead of blowing layout */
code, .mono, .ca, #caText, .v, .quote-price, .stat dd,
[class*="contract"], .ticket .v{
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ========== Nav ========== */
/* z-indexes match the ones the pages already set inline (nav 150, subnav 140).
   Lowering them here would have floated the sticky subnav over the nav. */
.sk-nav{
  position: sticky;
  top: 0;
  z-index: 150;
}
.sk-nav ul{
  max-width: 100%;
  padding-left: max(.35rem, env(safe-area-inset-left, 0));
  padding-right: max(.35rem, env(safe-area-inset-right, 0));
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.sk-nav a{
  min-height: var(--sk-touch);
  display: inline-flex;
  align-items: center;
  padding: .7rem .7rem;
}

.sk-sub, .ia-sub, .sk-game-nav{
  position: sticky;
  top: var(--sk-nav-h, 48px);
  z-index: 140;
}
.sk-sub .inner, .ia-sub .inner, .sk-game-nav .inner{
  max-width: 100%;
  padding-left: max(.4rem, env(safe-area-inset-left, 0));
  padding-right: max(.4rem, env(safe-area-inset-right, 0));
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.sk-sub a, .sk-sub span,
.ia-sub a, .ia-sub .lbl{
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}
/* Workshop and Library pin a subnav of their own; the wing strip stands down
   there rather than stacking two sticky bars on the same offset. */
.ia-sub.flat{ position: static; }

/* ========== Marquee (don't expand page) ========== */
.marquee-bar{
  max-width: 100%;
  overflow: hidden;
}
.marquee-track{
  max-width: none; /* allow internal scroll animation */
}

/* ========== Reel frame / sprockets ========== */
.reel-frame{
  max-width: 100%;
  box-sizing: border-box;
}
@media (max-width: 820px){
  .reel-frame{
    padding-left: var(--sk-gutter) !important;
    padding-right: var(--sk-gutter) !important;
  }
  .sprockets{ display: none !important; }
}

/* ========== Buttons / CTAs ========== */
.cta-row, .mast-cta, .tr-mood-actions, .floor-chooser{
  display: flex;
  flex-wrap: wrap;
  gap: .55rem .65rem;
  justify-content: center;
}
.btn, .btn.sm, .copy-btn, .controls > button,
.floor-chooser button, .floor-chooser a.floor-btn{
  min-height: var(--sk-touch);
  min-width: var(--sk-touch);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
@media (max-width: 520px){
  .btn, .btn.sm{
    flex: 1 1 auto;
    justify-content: center;
    text-align: center;
    padding-left: .85rem;
    padding-right: .85rem;
  }
  .cta-row{ width: 100%; }
}

/* ========== IA / Picture House / About ========== */
.ia-wrap{
  padding-left: var(--sk-gutter) !important;
  padding-right: var(--sk-gutter) !important;
  max-width: 960px;
  box-sizing: border-box;
}
.door-row{
  grid-template-columns: 1fr !important;
}
@media (min-width: 640px){
  .door-row{ grid-template-columns: 1fr 1fr !important; }
}
.ia-grid{ grid-template-columns: 1fr !important; }
@media (min-width: 640px){
  .ia-grid{ grid-template-columns: 1fr 1fr !important; }
}
@media (min-width: 960px){
  .ia-grid.cols-3{ grid-template-columns: 1fr 1fr 1fr !important; }
}
.ia-title, .title-card{
  overflow-wrap: anywhere;
  hyphens: auto;
}
.ia-lede, .band-blurb, .subtitle, .ia-prose{
  max-width: min(48ch, 100%);
}

/* ========== Ticker Room ========== */
.quote{
  box-sizing: border-box;
  max-width: 100%;
}
.quote-head{
  flex-direction: column;
  align-items: flex-start !important;
  gap: 1rem !important;
}
@media (min-width: 640px){
  .quote-head{
    flex-direction: row;
    align-items: flex-end !important;
  }
}
.quote-change{
  width: 100%;
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  gap: .75rem 1rem !important;
}
@media (min-width: 520px){
  .quote-change{ grid-template-columns: repeat(4, minmax(0,1fr)); }
}
.stat-strip{
  grid-template-columns: 1fr 1fr !important;
}
@media (min-width: 720px){
  .stat-strip{ grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important; }
}
.stat dd{
  font-size: clamp(.9rem, 3.5vw, 1rem);
}

/* Sticky lamp: below nav+subnav, don't cover content forever */
.lamp-row{
  position: sticky;
  top: calc(var(--sk-nav-h, 48px) + var(--sk-subnav-h, 0px));
  z-index: 40;
  background: rgba(20,17,15,.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: .45rem var(--sk-gutter);
  margin-left: calc(-1 * var(--sk-gutter));
  margin-right: calc(-1 * var(--sk-gutter));
  max-width: 100vw;
  box-sizing: border-box;
}
@media (max-width: 720px){
  :root{ --sk-nav-h: 46px; --sk-subnav-h: 40px; }
  /* On small screens sticky lamp competes with dual sticky nav — pin less aggressively */
  .lamp-row{
    position: relative;
    top: auto;
    margin-left: 0;
    margin-right: 0;
    max-width: 100%;
  }
}

/* Supply board */
.supply-grid{
  grid-template-columns: 1fr 1fr !important;
}
@media (min-width: 720px){
  .supply-grid{ grid-template-columns: repeat(4, 1fr) !important; }
}
.supply-card .num{
  font-size: clamp(1rem, 4.2vw, 1.45rem) !important;
}

/* Tables: scroll region, not page */
.scroller,
.lock-table-wrap,
.table-wrap,
.holders-table-wrap{
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border-radius: 0;
}
table{
  max-width: none;
}
@media (max-width: 640px){
  table{ font-size: 10.5px; }
  .lock-table{ min-width: 480px; }
  .bar-cell{ width: 72px !important; min-width: 72px !important; }
  .scroller table{ min-width: 520px; }
}

/* Tape canvas */
#tapeCanvas, .tape canvas, #tape canvas{
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  min-height: 160px;
}
@media (max-width: 640px){
  #tapeCanvas, .tape canvas{ min-height: 180px; max-height: 240px; }
}

/* Card grids on ticker */
.card-grid{
  grid-template-columns: 1fr !important;
  gap: .75rem !important;
}
@media (min-width: 560px){
  .card-grid{ grid-template-columns: 1fr 1fr !important; }
}
/* Above the reel frame's own width the house cards go back to filling the row
   as they did before this file existed — four readings across, not two. */
@media (min-width: 960px){
  .card-grid{
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)) !important;
    gap: 1.2rem !important;
  }
}

/* Ticket CA row: stack copy button */
.ticket .row{
  display: grid;
  grid-template-columns: 1fr;
  gap: .35rem .75rem;
  align-items: start;
}
@media (min-width: 560px){
  .ticket .row{
    grid-template-columns: 7.5rem 1fr auto;
    align-items: center;
  }
}
.ticket .copy-btn{
  width: 100%;
  justify-content: center;
}
@media (min-width: 560px){
  .ticket .copy-btn{ width: auto; }
}

/* Conc bars */
.conc{
  display: grid;
  gap: .85rem;
}
.conc .bar{ max-width: 100%; }

/* Steps list */
.steps{
  padding-left: 1.15rem;
  max-width: 100%;
}
.steps li{ margin-bottom: .65rem; }

/* House extras / range rows */
.range-row, #rangeRow, .watch-row{
  flex-wrap: wrap;
  gap: .65rem;
  max-width: 100%;
}

/* ========== Workshop / play frames (if present) ========== */
.play-frame, .play-root, .stage-wrap{
  max-width: 100%;
  box-sizing: border-box;
}
@media (max-width: 520px){
  .play-frame{
    padding-left: max(.5rem, env(safe-area-inset-left));
    padding-right: max(.5rem, env(safe-area-inset-right));
  }
}

/* ========== Meme reel ========== */
.floor-chooser{
  justify-content: flex-start;
}
.floor-chooser button,
.floor-chooser a.floor-btn{
  flex: 1 1 calc(50% - .5rem);
  justify-content: center;
}
@media (min-width: 560px){
  .floor-chooser button,
  .floor-chooser a.floor-btn{ flex: 0 1 auto; }
}
.floor-panel, .floor-banner{
  padding-left: var(--sk-gutter);
  padding-right: var(--sk-gutter);
  box-sizing: border-box;
}

/* ========== Footer ========== */
.ia-foot, footer, .foot, .sk-foot-nav{
  padding-left: var(--sk-gutter);
  padding-right: var(--sk-gutter);
  box-sizing: border-box;
  max-width: 100%;
}
.sk-foot-nav{
  justify-content: center;
  gap: .25rem .4rem;
  font-size: 9.5px;
  line-height: 1.85;
}

/* ========== Band sections common ========== */
.band{
  max-width: 100%;
  box-sizing: border-box;
  padding-left: 0;
  padding-right: 0;
}
.band-head{
  flex-wrap: wrap;
  gap: .5rem;
}
.masthead{
  padding-left: 0;
  padding-right: 0;
  padding-top: clamp(2rem, 6vw, 4rem);
  padding-bottom: clamp(1.25rem, 3vw, 2.4rem);
}

/* ========== Ultra-narrow (iPhone SE / 320) ========== */
@media (max-width: 360px){
  .title-card, .ia-title{
    font-size: clamp(1.85rem, 11vw, 2.4rem) !important;
  }
  .eyebrow{ letter-spacing: .18em; font-size: 10px; }
  .supply-card{ padding: .9rem .75rem; min-height: 100px; }
  .quote-change{ grid-template-columns: 1fr 1fr; }
}

/* ========== Landscape phone ========== */
@media (max-height: 430px) and (orientation: landscape){
  .masthead{ padding-top: 1.25rem; padding-bottom: 1rem; }
  .lamp-row{ position: relative; top: auto; }
  .sk-sub, .ia-sub, .sk-game-nav{ position: relative; top: auto; }
}

/* Reduced motion already handled per-component; ensure no horizontal anim jank */
@media (prefers-reduced-motion: reduce){
  .marquee-track{ animation: none !important; }
}
