/*
 * styles.css — Legendare Calibration App.
 * Matches the live legendareoutdoors.com design system (verified 2026-07-16).
 * Responsive: full-width mobile flow; two-column desktop with a sticky brand rail.
 * Brand tokens from Brand Manual v1.0 (docs 03-hld.md §8).
 */

/* ---- Fonts (bundled Commuters Sans; Veneer via Typekit in index.html) ---- */
@font-face {
  font-family: "Commuters Sans";
  src: url("./fonts/commuterssans-regular-webfont.woff2") format("woff2"),
       url("./fonts/commuterssans-regular-webfont.woff") format("woff");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Commuters Sans";
  src: url("./fonts/commuterssans-semibold-webfont.woff2") format("woff2"),
       url("./fonts/commuterssans-semibold-webfont.woff") format("woff");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Commuters Sans";
  src: url("./fonts/commuterssans-bold-webfont.woff2") format("woff2"),
       url("./fonts/commuterssans-bold-webfont.woff") format("woff");
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --lg-teal:    #0D5459;
  --lg-teal-d:  #0a4247;
  --lg-teal-l:  #14676d;
  --lg-brown:   #88785A;
  --lg-tan:     #D8CFBE;
  --lg-tan-50:  #EAE5DB;
  --lg-orange:  #D87328;
  --lg-orange-d:#bd6220;
  --lg-blue:    #7FBFC2;
  --lg-ink:     #2B2725;
  --lg-white:   #FFFFFF;

  --font-display: "veneer", "Commuters Sans", "Arial Black", system-ui, sans-serif;
  --font-body: "Commuters Sans", "Avenir Next", "Segoe UI", Helvetica, Arial, sans-serif;

  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(43,39,37,.08);
  --shadow: 0 4px 18px rgba(43,39,37,.10);
  --shadow-lg: 0 12px 34px rgba(13,84,89,.18);
  --shell: 1140px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
html { scroll-behavior: smooth; }

/* Pin the footer to the true bottom of the viewport (flex column, main
   content grows to fill) instead of leaving a stray blank strip of body
   background below a short page — used dvh (accounts for mobile Safari's
   collapsing toolbar) with a vh fallback for older browsers. */
body {
  font-family: var(--font-body);
  color: var(--lg-ink);
  background: var(--lg-tan-50);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---- Header ------------------------------------------------------------- */
.site-header {
  background: var(--lg-white);
  border-bottom: 1px solid var(--lg-tan);
  position: sticky; top: 0; z-index: 20;
}
.site-header .inner { max-width: var(--shell); margin: 0 auto; padding: .8rem 1.15rem; display: flex; align-items: center; }
.site-header .logo { height: 44px; width: auto; display: block; }

/* ---- Shell / responsive layout ----------------------------------------- */
.shell { max-width: var(--shell); margin: 0 auto; flex: 1 0 auto; width: 100%; }

/* ---- Brand rail (teal) -------------------------------------------------- */
.brand-rail {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 100% 0%, var(--lg-teal-l) 0%, rgba(20,103,109,0) 55%),
    var(--lg-teal);
  color: var(--lg-white);
  padding: 1.6rem 1.15rem 1.9rem;
}
.brand-rail .watermark {
  position: absolute; z-index: 0; right: -46px; bottom: -40px;
  width: 260px; height: 260px;
  background: url("./img/legendare-mark-white.svg") no-repeat center / contain;
  opacity: .07; pointer-events: none;
}
/* Explicit z-index (not relying on DOM order alone) — on some mobile Safari
   renders the watermark was inconsistently compositing above the hero text
   ("sometimes on top, sometimes behind" on a real test device) without this. */
.rail-content { position: relative; z-index: 1; }
.hero-title {
  font-family: var(--font-display);
  font-style: italic; font-weight: 400;
  color: var(--lg-tan);
  font-size: 2.15rem; line-height: 1.02;
  margin: 0 0 .4rem;
}
.hero-title .accent { color: var(--lg-white); }
.hero-sub { font-weight: 600; font-size: 1.12rem; margin: 0; color: var(--lg-white); }

/* Visible on step 1 only, then collapses away — Andrew wanted the intro
   decluttered once someone's past the first step (2026-07-28). max-height is
   just a generous cap (actual content is ~3 lines) so the collapse can be a
   pure CSS transition with no JS height measurement. */
.rail-disclaimer {
  margin: 1.1rem 0 0; font-size: .76rem; line-height: 1.5; color: rgba(255,255,255,.72); max-width: 46ch;
  max-height: 12rem; opacity: 1; overflow: hidden;
  transition: max-height .4s ease, opacity .3s ease, margin-top .4s ease;
}
.rail-disclaimer.collapsed { max-height: 0; opacity: 0; margin-top: 0; }
@media (prefers-reduced-motion: reduce) {
  .rail-disclaimer { transition-duration: .01s; }
}

/* ---- Work area ---------------------------------------------------------- */
.work-area { padding: 1.15rem 1.15rem 2.5rem; }

.card {
  background: var(--lg-white);
  border: 1px solid var(--lg-tan);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.25rem;
  margin: 0 0 1.1rem;
}

h2.section {
  font-family: var(--font-body); font-weight: 600; color: var(--lg-teal);
  font-size: 1.35rem; line-height: 1.15; margin: 0 0 .65rem;
}
.lead { color: var(--lg-teal); font-weight: 600; }

/* ---- Steps timeline ----------------------------------------------------- */
#steps { position: relative; }
.step { position: relative; display: flex; gap: .9rem; padding: .95rem 0; border-bottom: 1px solid var(--lg-tan-50); }
.step:last-child { border-bottom: 0; padding-bottom: .2rem; }
.step-num {
  flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%;
  background: var(--lg-teal); color: var(--lg-white); font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-size: .95rem;
  box-shadow: 0 0 0 4px rgba(13,84,89,.10); z-index: 1;
}
.step.done .step-num { background: var(--lg-brown); box-shadow: 0 0 0 4px rgba(136,120,90,.12); }
/* Optional steps are called out with a text badge (see .badge-optional
   below), not a differently-colored number — color alone wasn't a clear
   enough signal on real-device testing. */
/* connector line between numbers */
.step:not(:last-child)::before {
  content: ""; position: absolute; left: 16px; top: 2.4rem; bottom: -0.05rem;
  width: 2px; background: var(--lg-tan); z-index: 0;
}
.step-body { flex: 1 1 auto; min-width: 0; padding-top: .2rem; }
.step-title { font-weight: 600; margin: .1rem 0 .55rem; }
.step-title .const { color: var(--lg-orange-d); font-weight: 700; }

.help-toggle { background: none; border: 0; color: var(--lg-teal); font: inherit; font-size: .85rem; cursor: pointer; padding: 0; text-decoration: underline; }
.help-text { font-size: .88rem; background: var(--lg-tan-50); border-radius: 8px; padding: .55rem .65rem; margin-top: .45rem; }

/* ---- Form controls ------------------------------------------------------ */
label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: .3rem; color: #4a453f; }
select, input[type="number"], input[type="email"] {
  font: inherit; width: 100%; padding: .68rem .7rem;
  border: 2px solid var(--lg-tan); border-radius: 9px;
  background: var(--lg-white); color: var(--lg-ink); transition: border-color .15s, box-shadow .15s;
}
select:focus, input:focus { outline: none; border-color: var(--lg-teal); box-shadow: 0 0 0 3px rgba(13,84,89,.14); }
.weight-inputs { display: flex; gap: .65rem; }
.weight-inputs > div { flex: 1; }
.field { margin-bottom: .2rem; }

/* Tappable option buttons (replaces system dropdowns for model + spacing).
   One tap selects — big targets, no picker to open. Equal-width grid columns
   so every button is the same size (flex made them uneven). */
.option-group { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: .5rem; }
.option-btn {
  font: inherit; font-weight: 600;
  min-height: 48px; padding: .55rem .75rem;
  border: 2px solid var(--lg-tan); border-radius: 10px;
  background: var(--lg-white); color: var(--lg-ink);
  cursor: pointer; width: 100%; text-align: center;
  transition: border-color .12s, background .12s, color .12s, box-shadow .12s;
}
.option-btn:hover { border-color: var(--lg-teal); }
.option-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(13,84,89,.18); }
.option-btn.selected {
  background: var(--lg-teal); border-color: var(--lg-teal); color: var(--lg-white);
  box-shadow: 0 2px 8px rgba(13,84,89,.20);
}
.field + .field { margin-top: .65rem; }
.sub-label { font-weight: 400; text-align: center; margin: .25rem 0 0; color: #6b655d; font-size: .8rem; }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  font: inherit; font-weight: 700; border: 2px solid transparent; border-radius: 6px;
  padding: .62rem 1.15rem; cursor: pointer; background: var(--lg-teal); color: var(--lg-white);
  transition: background .15s, color .15s, border-color .15s, transform .05s;
  display: inline-block; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--lg-orange); border-color: var(--lg-orange); }
.btn-outline { background: var(--lg-white); color: var(--lg-orange-d); border-color: var(--lg-orange); }
/* Soft secondary — tan chip, teal text (used for Start over / Install) */
.btn-soft { background: var(--lg-tan-50); color: var(--lg-teal); border-color: var(--lg-tan); }
/* Ghost — text link; FIX: keep transparent on hover (was inheriting dark fill) */
.btn-ghost { background: transparent; color: var(--lg-teal); border-color: transparent; text-decoration: underline; padding-left: .2rem; padding-right: .2rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
/* Hover styles ONLY for real pointer devices — on touch, :hover otherwise
   sticks after a tap until the user taps elsewhere, making buttons (like
   "Download as image") look stuck/pressed with no feedback (Michael, 2026-07-28). */
@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: var(--lg-teal-d); }
  .btn-primary:hover { background: var(--lg-orange-d); border-color: var(--lg-orange-d); }
  .btn-outline:hover { background: var(--lg-tan-50); color: var(--lg-orange-d); }
  .btn-soft:hover { background: var(--lg-tan); color: var(--lg-teal-d); }
  .btn-ghost:hover { background: transparent; color: var(--lg-teal-d); }
}

.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: 0 0 1.1rem; }

/* ---- Result card -------------------------------------------------------- */
.result {
  position: relative; overflow: hidden;
  background: linear-gradient(160deg, var(--lg-teal) 0%, var(--lg-teal-d) 100%);
  color: var(--lg-white); border-color: var(--lg-teal); box-shadow: var(--shadow-lg);
}
.result .result-accent { position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--lg-orange); }
.result h2 { color: var(--lg-white); font-weight: 600; margin: 0 0 .5rem; }
.result .measured { font-size: .92rem; letter-spacing: .01em; opacity: .9; text-transform: uppercase; }
.result .setting-value {
  font-weight: 700; font-size: 4rem; line-height: 1; margin: .25rem 0 .1rem; color: var(--lg-white);
  font-variant-numeric: tabular-nums;
}
.result .recap { margin-top: .7rem; font-size: .96rem; line-height: 1.5; }
.result .recap strong { color: var(--lg-blue); }
.result .plant-note { margin: .8rem 0 0; }
.result .disclaimer { margin-top: 1rem; font-size: .76rem; opacity: .82; }
.result.warn { background: linear-gradient(160deg, var(--lg-orange) 0%, var(--lg-orange-d) 100%); border-color: var(--lg-orange-d); }
.result.warn .result-accent { background: var(--lg-ink); }
.result-summary { margin-top: 1rem; border-top: 1px solid rgba(255,255,255,.22); padding-top: .8rem; }
.result-summary .summary-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--lg-blue); font-weight: 700; margin-bottom: .45rem; }
.result-summary .summary-row { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; font-size: .92rem; border-bottom: 1px solid rgba(255,255,255,.12); }
.result-summary .summary-row:last-child { border-bottom: 0; }
.result-summary .summary-row span { opacity: .85; }

/* ---- Wizard (step-by-step / list / results) ---------------------------- */
.wiz-topbar { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin: 0 0 1rem; }
.wiz-tab { font: inherit; font-weight: 600; font-size: .9rem; background: var(--lg-white); color: var(--lg-teal);
  border: 1px solid var(--lg-tan); border-radius: 999px; padding: .5rem 1rem; cursor: pointer; }
.wiz-tab:hover { border-color: var(--lg-teal); }
.wiz-admin { font-size: .85rem; font-weight: 600; color: var(--lg-teal); text-decoration: none; padding: .5rem .6rem; border-radius: 8px; }
.wiz-admin:hover { background: var(--lg-tan-50); }

.wiz-progress { margin: 0 0 1rem; }
.wiz-progress .seg-row { display: flex; gap: 5px; }
.wiz-progress .seg { flex: 1; height: 7px; border-radius: 4px; background: var(--lg-tan); }
.wiz-progress .seg.on { background: var(--lg-teal); }
.wiz-progress .seg-label { margin-top: .5rem; font-size: .82rem; font-weight: 600; color: var(--lg-teal); }

.wiz-step-card { min-height: 8rem; }
.wiz-step-title { font-size: 1.3rem; font-weight: 600; line-height: 1.25; margin: 0 0 1rem; }
.wiz-step-title .const { color: var(--lg-orange-d); font-weight: 700; }

.wiz-nav { display: flex; gap: .7rem; margin: 1rem 0 0; }
.wiz-nav .btn { flex: 1; min-height: 52px; font-size: 1.05rem; }
.wiz-nav #backBtn { flex: 0 0 32%; }
.wiz-nav .btn:disabled { opacity: .45; }

/* List view: each step is a big tappable row */
.list-step.tappable { width: 100%; text-align: left; background: var(--lg-white); border: 0;
  border-bottom: 1px solid var(--lg-tan-50); cursor: pointer; font: inherit; }
.list-step.tappable:hover { background: var(--lg-tan-50); }
.list-step .step-value { font-size: .85rem; color: var(--lg-teal); font-weight: 600; margin-top: .3rem; }

/* ---- Messages ----------------------------------------------------------- */
.error { color: #b00020; font-size: .85rem; margin-top: .35rem; }
.result .error { color: #ffdbe0; }
.toast {
  position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%);
  background: var(--lg-ink); color: var(--lg-white); padding: .75rem 1.05rem; border-radius: 10px;
  box-shadow: var(--shadow-lg); max-width: 92%; font-size: .9rem; z-index: 60; text-align: center;
}
.hidden { display: none !important; }

/* ---- Install ------------------------------------------------------------ */
.install ol { padding-left: 1.2rem; margin: .4rem 0; }
.install li { margin: .45rem 0; }
.install .kbd { display: inline-block; background: var(--lg-tan); border-radius: 5px; padding: 0 .38rem; font-weight: 600; }
.ios-steps li { margin: .55rem 0; }
.copy-msg { font-size: .82rem; color: var(--lg-teal); font-weight: 600; }

/* ---- Auto-surfaced install banner (mobile only — see js/app.js) --------- */
.install-banner {
  position: fixed; left: .75rem; right: .75rem; bottom: .75rem; z-index: 55;
  background: var(--lg-white); color: var(--lg-ink);
  border: 1px solid var(--lg-tan); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1rem 2.4rem 1rem 1rem;
  animation: install-banner-in .25s ease-out;
}
@keyframes install-banner-in {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.install-banner-close {
  position: absolute; top: .5rem; right: .6rem;
  background: none; border: 0; font-size: 1.3rem; line-height: 1; color: #8a8478;
  cursor: pointer; padding: .25rem;
}
.install-banner-close:hover { color: var(--lg-ink); }
.install-banner .ib-title { font-weight: 700; color: var(--lg-teal); margin: 0 0 .3rem; font-size: 1rem; }
.install-banner .ib-body { font-size: .92rem; margin: 0 0 .7rem; }
.install-banner .btn { width: 100%; }

/* iOS variant: Safari's Share icon location varies by iOS version, device,
   and user settings (top toolbar vs. bottom tab bar) — deliberately NOT
   pointing at a specific side of the screen (a directional arrow here read
   as "look left" on a real test device where Share was actually on the
   right — see docs/05-test-plan.md I10). Bold, centered, unpositioned. */
.install-banner .ib-ios-pointer {
  text-align: center; margin-top: .6rem; font-size: .92rem;
  color: var(--lg-teal); font-weight: 600; line-height: 1.4;
}
@media (prefers-reduced-motion: reduce) {
  .install-banner { animation: none; }
}

/* ---- Footer ------------------------------------------------------------- */
.app-footer { background: var(--lg-white); border-top: 1px solid var(--lg-tan); }
.app-footer .inner { max-width: var(--shell); margin: 0 auto; padding: 1.15rem 1.15rem 1.6rem; font-size: .8rem; color: #6b655d; text-align: center; }
.app-footer a { color: var(--lg-teal); font-weight: 600; }

/* =========================================================================
   DESKTOP — two-column with sticky brand rail (hero only; the calibration
   result lives solely in the result card to its right — no duplication)
   ========================================================================= */
@media (min-width: 920px) {
  .shell {
    display: grid;
    grid-template-columns: 384px 1fr;
    gap: 1.75rem;
    padding: 1.9rem 1.5rem 3rem;
    align-items: start;
  }
  .brand-rail {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    position: sticky; top: calc(44px + 1.6rem + 1px);
    padding: 2rem 1.7rem;
  }
  .brand-rail .watermark { width: 320px; height: 320px; right: -60px; bottom: -50px; opacity: .08; }
  .hero-title { font-size: 2.8rem; }
  .hero-sub { font-size: 1.2rem; }
  .work-area { padding: 0; }

  .card { padding: 1.5rem 1.6rem; }
  h2.section { font-size: 1.5rem; }
  .result .setting-value { font-size: 4.4rem; }
}

@media (min-width: 1024px) {
  .shell { grid-template-columns: 420px 1fr; gap: 2.25rem; }
  .hero-title { font-size: 3.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn { transition: none; }
}
