/* ============================================================
   nuz.pet — MODULE SHELL (2026-10-09)
   ------------------------------------------------------------
   The standard environment for every module except Zoomies.
   Load after css/nuz-dark.css. Markup (see pages/modules/_template.html):

     <div class="mod" id="mod" data-species="">
       <header class="mod-top">   back pill · pet chip · progress
       <section class="mod-stage"> optional: the pet + its colour field (left pane in landscape)
       <main class="mod-room">    the module's screens
       <footer class="mod-bar">   optional sticky primary button
     </div>

   Same bones as the hub (css/pet-flow.css): one column on a phone,
   two panes in landscape / on a desktop. Primitives below are all
   prefixed .mod-*; a module's own CSS adds, never overrides tokens.
   ============================================================ */

/* ---------- frame ---------- */
body.nz-mod { overflow: hidden; }
.mod {
  position: relative; z-index: 1;
  height: 100svh; height: 100dvh;
  max-width: 430px; margin: 0 auto;
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
}
.mod.is-nostage { grid-template-rows: auto minmax(0, 1fr) auto; } /* js/module-shell.js adds it when .mod-stage is empty/hidden */
.mod[data-species="dog"] { --field: var(--dog); --tint: var(--dog-tint); }
.mod[data-species="cat"] { --field: var(--cat); --tint: var(--cat-tint); }
.mod:not([data-species="dog"]):not([data-species="cat"]) { --field: var(--brand); --tint: var(--surface); }

/* ---------- top: back · pet · progress ---------- */
.mod-top {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-t)) 14px 6px; z-index: 5;
}
.mod-back {
  display: inline-flex; align-items: center; gap: 2px; min-height: 40px; padding: 0 14px 0 8px; border-radius: var(--radius-pill);
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); color: var(--ink);
  font-weight: 700; font-size: 14px; text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.mod-back svg { width: 20px; height: 20px; }
.mod-back:active { transform: scale(.97); }
.mod-pet {
  justify-self: end; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px 0 6px; border-radius: var(--radius-pill);
  background: color-mix(in oklab, var(--field) 18%, var(--surface)); box-shadow: inset 0 0 0 1px var(--border);
  color: var(--ink); font-weight: 700; font-size: 14px;
}
.mod-pet img { width: 28px; height: 28px; object-fit: contain; }
.mod-pet[hidden] { display: none; }
.mod-progress {
  grid-column: 1 / -1; height: 3px; border-radius: 99px; background: var(--border); overflow: hidden; margin-top: 4px;
}
.mod-progress i {
  display: block; height: 100%; width: var(--p, 0%); border-radius: 99px;
  background: var(--action-grad);
  transition: width .4s var(--ease);
}
.mod-progress[hidden] { display: none; }

/* ---------- stage: the pet on its colour field ---------- */
.mod-stage {
  position: relative; min-height: 0; height: var(--stage, 26svh); overflow: hidden;
  display: grid; place-items: center;
}
.mod-stage:empty, .mod-stage[hidden] { display: none; }
.mod-stage::before {
  content: ""; position: absolute; inset: -10% -20%; pointer-events: none;
  background: radial-gradient(ellipse at 50% 55%, color-mix(in oklab, var(--field) 50%, transparent), transparent 70%);
  -webkit-mask-image: linear-gradient(#000 55%, transparent 92%); mask-image: linear-gradient(#000 55%, transparent 92%);
}
.mod[data-species="cat"] .mod-stage::before { background: radial-gradient(ellipse at 50% 55%, color-mix(in oklab, var(--cat) 40%, var(--cat-tint)) 0%, transparent 70%); } /* orange cat on raw orange vanishes; use the tint */
.mod-stage img { position: relative; width: min(44vw, 170px); height: auto; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 12px 20px rgba(0,0,0,.55)); }
.mod-stage .mod-caption {
  position: absolute; left: 14px; top: 8px; margin: 0; max-width: 60%;
  font-family: var(--font-hand); font-size: 24px; font-weight: 700; color: var(--brand); line-height: 1;
}

/* ---------- room: the module's screens ---------- */
.mod-room {
  position: relative; z-index: 3; min-height: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 8px 16px calc(12px + var(--safe-b)); display: flex; flex-direction: column; gap: 10px;
}
.mod-screen { display: contents; }
.mod-screen[hidden] { display: none; }

/* text */
.mod-eyebrow { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); }
.mod-title { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(22px, 6vw, 28px); line-height: 1.05; text-transform: uppercase; letter-spacing: .01em; }
.mod-title.is-hero {   /* 32px+ only: the icon gradient on a Bowlby headline */
  font-size: clamp(32px, 9vw, 40px); text-transform: none; width: fit-content; max-width: 100%;
  background: linear-gradient(90deg, var(--g-start), var(--g-mid), var(--g-end)); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
}
.mod-sub { margin: 0; font-size: 15px; line-height: 1.4; color: var(--muted); font-weight: 500; }
.mod-sec { margin: 8px 0 0; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.mod-body { margin: 0; font-size: 15px; line-height: 1.55; }
.mod-body b { color: var(--ink); }
.mod-link { color: var(--brand); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* surfaces */
.mod-card {
  background: var(--surface); border-radius: var(--radius-xl); box-shadow: inset 0 0 0 1px var(--border);
  padding: 14px 16px; display: grid; gap: 8px;
}
.mod-card.is-tint { background: color-mix(in oklab, var(--field) 14%, var(--surface)); }
.mod-stat { margin: 0; width: fit-content; max-width: 100%; font-family: var(--font-display); font-size: 40px; line-height: 1; background: linear-gradient(90deg, var(--g-start), var(--g-mid), var(--g-end)); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; }

/* chips (facts, filters, small picks) */
.mod-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.mod-chip {
  appearance: none; border: 0; cursor: pointer; display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: var(--radius-pill);
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); color: var(--ink); font-weight: 700; font-size: 14px;
  transition: background .15s, box-shadow .15s, color .15s;
}
.mod-chip.is-on { background: var(--action-grad); color: var(--on-action); box-shadow: var(--action-glow); }
.mod-chip.is-quiet { pointer-events: none; color: var(--muted); min-height: 32px; font-size: 13px; background: transparent; }

/* choices: one answer per row; a .is-grid list becomes tiles */
.mod-choices { display: grid; gap: 8px; }
.mod-choices.is-grid { grid-template-columns: 1fr 1fr; }
.mod-choice {
  appearance: none; border: 0; cursor: pointer; text-align: left; color: var(--ink);
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px;
  min-height: 56px; padding: 12px 14px; border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--border);
  font-weight: 600; font-size: 15px; line-height: 1.3;
  transition: background .15s, box-shadow .15s, transform .12s;
}
.mod-choice.is-icon { grid-template-columns: auto 1fr auto; } /* leading <img> or .mod-ic */
.mod-choice img, .mod-choice .mod-ic { width: 36px; height: 36px; object-fit: contain; }
.mod-choice small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.mod-choice::after { content: "→"; grid-column: -1; justify-self: end; color: var(--brand); font-weight: 700; opacity: .8; }
.mod-choice:hover { background: color-mix(in oklab, var(--field) 10%, var(--surface)); }
.mod-choice.is-on { background: color-mix(in oklab, var(--brand) 22%, var(--surface)); box-shadow: inset 0 0 0 1.5px var(--brand); }
.mod-choice.is-on::after { content: "✓"; color: var(--brand); opacity: 1; }
.mod-choices.is-grid .mod-choice { grid-template-columns: 1fr; justify-items: center; text-align: center; min-height: 108px; }
.mod-choices.is-grid .mod-choice::after { content: none; }
.mod-choice:active { transform: scale(.985); }

/* inputs */
.mod-input {
  width: 100%; border: 0; min-height: 48px; padding: 12px 14px; border-radius: var(--radius-md);
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); color: var(--ink); font-size: 16px; font-weight: 600; outline: none;
}
.mod-input:focus { box-shadow: inset 0 0 0 2px var(--brand); }
.mod-input::placeholder { color: color-mix(in oklab, var(--muted) 70%, transparent); font-weight: 400; }
.mod-range { width: 100%; accent-color: var(--action-solid); }

/* buttons */
.mod-btn {
  width: 100%; min-height: 52px; border: 0; border-radius: var(--radius-pill); cursor: pointer;
  background: var(--action-grad); color: var(--on-action); font-weight: 700; font-size: 16px;
  box-shadow: var(--action-glow);
  transition: opacity .2s, transform .12s, background .2s;
}
.mod-btn:disabled { cursor: default; background: var(--surface); color: var(--muted); box-shadow: inset 0 0 0 2px color-mix(in oklab, var(--action-solid) 50%, transparent); }
.mod-btn:not(:disabled):active { transform: scale(.98); }
.mod-btn.is-soft { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--border); }
.mod-btn.is-outline { background: transparent; color: var(--brand); box-shadow: inset 0 0 0 1.5px var(--brand); }
.mod-row { display: grid; gap: 8px; grid-auto-flow: column; grid-auto-columns: 1fr; }
.mod-bar { padding: 8px 16px calc(12px + var(--safe-b)); background: linear-gradient(180deg, transparent, var(--ground) 35%); z-index: 6; display: grid; gap: 8px; }
.mod-bar[hidden] { display: none; }
.mod-cue { margin: 0; text-align: center; font-size: 14px; font-weight: 700; color: var(--brand); }

/* finish: result + the way out (one hub door, optional again) */
.mod-finish { display: grid; gap: 10px; }
.mod-doors { display: grid; gap: 8px; margin-top: 6px; }
.mod-door {
  appearance: none; border: 0; cursor: pointer; text-align: left; font: inherit;
  display: grid; gap: 2px; min-height: 60px; padding: 12px 16px; border-radius: var(--radius-lg); text-decoration: none;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); color: var(--ink);
}
.mod-door b { font-family: var(--font-display); font-weight: 400; font-size: 14px; text-transform: uppercase; }
.mod-door small { font-size: 12px; color: var(--muted); font-weight: 500; }
.mod-door.is-hub { background: color-mix(in oklab, var(--brand) 18%, var(--surface)); }

/* focus rings — one rule */
.mod :where(a, button, input, [tabindex]):focus-visible { outline: 2px dashed var(--brand); outline-offset: 2px; }

/* enter motion for a new screen */
@keyframes mod-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.mod-room > * { animation: mod-in .28s var(--ease) both; }

/* ---------- landscape / desktop: two panes, same as the hub ---------- */
@media (orientation: landscape) and (min-width: 720px) {
  .mod { max-width: 1120px; grid-template-columns: minmax(320px, 42%) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
  .mod-top { grid-column: 1 / -1; grid-row: 1; padding-left: 20px; padding-right: 20px; }
  .mod-stage { grid-column: 1; grid-row: 2 / 4; height: auto; }
  .mod-stage::before { inset: 0; background: radial-gradient(closest-side at 50% 55%, color-mix(in oklab, var(--field) 42%, transparent), transparent 100%); -webkit-mask-image: none; mask-image: none; }
  .mod[data-species="cat"] .mod-stage::before { background: radial-gradient(closest-side at 50% 55%, color-mix(in oklab, var(--cat) 34%, var(--cat-tint)), transparent 100%); }
  /* scroll hint: content fades under the top and bottom edges */
  .mod-room { -webkit-mask-image: linear-gradient(transparent 0, #000 14px, #000 calc(100% - 20px), transparent); mask-image: linear-gradient(transparent 0, #000 14px, #000 calc(100% - 20px), transparent); }
  .mod-stage img { width: min(30vw, 280px); }
  .mod-stage .mod-caption { left: 20px; top: 12px; font-size: 34px; }
  .mod-room { grid-column: 2; grid-row: 2; padding: 16px 28px 16px 24px; }
  .mod-bar { grid-column: 2; grid-row: 3; padding: 8px 28px calc(12px + var(--safe-b)) 24px; }
  .mod-bar > * { max-width: 420px; }
  /* no stage? the room takes both columns */
  .mod.is-nostage { grid-template-columns: 1fr; }
  .mod.is-nostage .mod-room, .mod.is-nostage .mod-bar { grid-column: 1; max-width: 720px; width: 100%; justify-self: center; }
  .mod-finish, .mod-doors { max-width: 420px; }
  .mod-title { font-size: clamp(24px, 2.4vw, 30px); }
  .mod-choices.is-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* short landscape phones (≈390px tall): tighter, cues off */
@media (orientation: landscape) and (max-height: 480px) {
  .mod-cue { display: none; }
  .mod-bar { padding-top: 4px; }
  .mod-choices.is-grid .mod-choice { min-height: 84px; }
}
