/* ==========================================================================
   VISHWAKARMA AI 2.0 — Responsive Layer
   --------------------------------------------------------------------------
   Loaded via <link> placed AFTER each page's inline <style>, so equal-
   specificity rules here win without needing !important.

   Breakpoints:  <=480 phone   <=760 large phone   <=900 tablet   >900 desktop
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Overflow containment
   The page already sets body{overflow-x:hidden}, which HIDES sideways
   overflow rather than fixing it — content gets silently clipped. These
   rules remove the actual causes so nothing needs clipping.
   -------------------------------------------------------------------------- */
html { -webkit-text-size-adjust: 100%; }
html, body { max-width: 100%; }

img, video, canvas, svg, iframe, embed, object {
  max-width: 100%;
}
img, video { height: auto; }

/* Grid and flex children default to min-width:auto, which refuses to shrink
   below their content's intrinsic width — the single most common source of
   horizontal overflow. */
.grid-4 > *, .proof-grid > *, .pricing-grid > *, .specs-grid > *,
.meaning-grid > *, .portal-body > *, .spectrum-row > *,
.countdown > *, .hero-actions > *, .tribute-terms > * { min-width: 0; }

/* Long unbroken strings (emails, URLs, mono readouts) must not push width. */
p, li, td, h1, h2, h3, dd, dt,
.spectrum-code, .cosmos-addr, .mind-card p, .hero-sub { overflow-wrap: break-word; }

/* 100vw includes the scrollbar gutter, so it overflows on desktop. */
#cosmos { width: 100%; }

/* --------------------------------------------------------------------------
   2. Viewport height on mobile browsers
   100vh is measured against the *largest* viewport, so the URL bar covers
   the bottom of anything sized with it. dvh tracks the visible area.
   -------------------------------------------------------------------------- */
@supports (height: 100dvh) {
  #cosmos { height: 100dvh; }
  #hero { min-height: 100dvh; }
}

/* --------------------------------------------------------------------------
   3. Safe-area insets (notched / rounded phones)
   -------------------------------------------------------------------------- */
@supports (padding: max(0px)) {
  nav    { padding-left: max(42px, env(safe-area-inset-left));
           padding-right: max(42px, env(safe-area-inset-right)); }
  footer { padding-bottom: max(46px, env(safe-area-inset-bottom)); }
}

/* --------------------------------------------------------------------------
   4. Grid layouts — min(px, 100%) keeps the track from exceeding the viewport
   -------------------------------------------------------------------------- */
.grid-4     { grid-template-columns: repeat(auto-fit, minmax(min(270px, 100%), 1fr)); }
.proof-grid { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }

/* Countdown is a flex row of 4 fixed-min cells (~446px) — wider than a phone.
   Let it wrap to 2x2 instead of being clipped. */
.countdown { flex-wrap: wrap; width: auto; }
.cd-cell   { flex: 1 1 auto; }

/* --------------------------------------------------------------------------
   5. Fluid type — small fixed-px text raised to a legible mobile floor
   -------------------------------------------------------------------------- */
.hero-sub      { font-size: clamp(16px, 0.9rem + 0.4vw, 18px); }
.section-sub   { font-size: clamp(15.5px, 0.9rem + 0.3vw, 16.5px); }
.mind-card p   { font-size: clamp(15px, 0.85rem + 0.2vw, 15.5px); }
.mind-card h3  { font-size: clamp(17px, 1rem + 0.3vw, 19px); }
.spectrum-what { font-size: clamp(15px, 0.85rem + 0.2vw, 15.5px); }
.spectrum-who  { font-size: clamp(16px, 0.95rem + 0.2vw, 17px); }
.proof-item p  { font-size: clamp(15px, 0.85rem + 0.2vw, 15.5px); }
.proof-item h3 { font-size: clamp(16.5px, 1rem + 0.3vw, 18px); }
.meaning-copy p { font-size: clamp(15.5px, 0.9rem + 0.3vw, 16.5px); }

/* Decorative mono labels — small by design, but 9-10.5px is unreadable. */
.nav-link      { font-size: clamp(11px, 0.68rem + 0.1vw, 12px); }
.eyebrow       { font-size: clamp(10.5px, 0.65rem + 0.1vw, 11px); }
.field label   { font-size: clamp(11.5px, 0.7rem + 0.1vw, 12px); }
.portal-note   { font-size: clamp(11.5px, 0.7rem + 0.1vw, 12px); }
.cd-lbl        { font-size: clamp(10px, 0.6rem + 0.1vw, 10.5px); letter-spacing: 0.25em; }
.cd-num        { font-size: clamp(26px, 1.4rem + 1.6vw, 40px); }
footer         { font-size: clamp(11px, 0.68rem + 0.1vw, 11.5px); }
.cosmos-addr   { font-size: clamp(11px, 0.68rem + 0.1vw, 11.5px); }
.tribute-dedication { font-size: clamp(11.5px, 0.7rem + 0.2vw, 13px); letter-spacing: 0.25em; }

/* Fixed HUD readout: nowrap text pinned bottom-centre would run off-screen. */
.hud-readout {
  max-width: 92vw;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(9px, 0.55rem + 0.1vw, 10px);
}

/* --------------------------------------------------------------------------
   6. Touch targets — 44px minimum (WCAG 2.5.5 / Apple HIG)
   -------------------------------------------------------------------------- */
.btn, .btn-gold, .btn-ghost, .btn-uplink, .nav-uplink {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* --------------------------------------------------------------------------
   7. Forms
   iOS Safari zooms the page when a focused input's font-size is under 16px.
   -------------------------------------------------------------------------- */
.field input, .field select, .field textarea,
input[type="text"], input[type="email"], input[type="password"],
input[type="tel"], input[type="number"], input[type="search"],
select, textarea {
  font-size: 16px;
  max-width: 100%;
}

/* appearance:none strips the native dropdown arrow, leaving selects looking
   like inert boxes. Restore an inline SVG chevron (no network request). */
.field select, select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%2300f0ff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 44px;
  min-height: 44px;
}

.field input, .field textarea { min-height: 44px; }

/* --------------------------------------------------------------------------
   8. Mobile navigation — hamburger drawer
   Markup is injected by assets/nav.js; these styles are inert until then.
   -------------------------------------------------------------------------- */
.nav-burger { display: none; }

.nav-scrim {
  position: fixed;
  inset: 0;
  z-index: 18;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0.28s;
}
.nav-scrim.open { opacity: 1; visibility: visible; }

@media (max-width: 900px) {
  /* Brand mark: 15px Arial Black at 0.32em tracking is ~300px wide; shrink
     it so the mark and the burger both fit on a 320px screen. */
  .nav-mark {
    font-size: clamp(11px, 2.6vw, 14px);
    letter-spacing: 0.16em;
    display: flex;
    align-items: center;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
  }
  .nav-mark img { height: 22px; }

  .nav-burger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 0 10px;
    margin-left: 12px;
    flex: 0 0 auto;
    background: transparent;
    border: 1px solid rgba(0, 240, 255, 0.28);
    cursor: pointer;
    position: relative;
    z-index: 22;
  }
  .nav-burger span {
    display: block;
    height: 1.5px;
    width: 100%;
    background: var(--cyan, #00f0ff);
    transition: transform 0.28s ease, opacity 0.2s ease;
  }
  .nav-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
  .nav-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .nav-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

  /* The drawer itself */
  nav .nav-right {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 21;
    width: min(84vw, 320px);
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 2px;
    padding: 88px 22px calc(28px + env(safe-area-inset-bottom, 0px));
    padding-right: max(22px, env(safe-area-inset-right, 0px));
    background: rgba(3, 3, 8, 0.97);
    backdrop-filter: blur(14px);
    border-left: 1px solid rgba(0, 240, 255, 0.22);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  nav .nav-right.open { transform: none; }

  nav .nav-right .nav-link {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 12px 10px;
    font-size: 13px;
    letter-spacing: 0.2em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }
  /* The active underline is positioned for a horizontal bar; drop it here. */
  nav .nav-right .nav-link.active::after { display: none; }
  nav .nav-right .nav-link.active {
    color: var(--gold-hot, #ffd558);
    border-left: 2px solid var(--gold-hot, #ffd558);
    padding-left: 14px;
  }

  nav .nav-right .nav-uplink {
    margin-top: 18px;
    width: 100%;
    text-align: center;
  }

  /* Lock background scroll while the drawer is open. */
  body.nav-open { overflow: hidden; }
}

/* --------------------------------------------------------------------------
   9. Spacing and layout per breakpoint
   -------------------------------------------------------------------------- */
/* The footer policy links are inline <a>s with only horizontal margins, so on
   a phone they wrap into a dense ~19px-tall block. Give them real hit areas. */
.policy-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 4px;
}
.policy-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  margin: 0 !important;   /* beats the inline style="margin:0 1rem" */
}

@media (max-width: 900px) {
  /* nav's gradient background fades to transparent, so page content scrolling
     underneath collides with the brand mark. Make it opaque where the drawer
     button lives. */
  nav { background: linear-gradient(180deg, rgba(0,0,0,0.97) 0%, rgba(0,0,0,0.92) 62%, rgba(0,0,0,0.72) 100%); }

  nav { padding-top: 14px; padding-bottom: 14px; }
  @supports (padding: max(0px)) {
    nav { padding-left: max(20px, env(safe-area-inset-left));
          padding-right: max(20px, env(safe-area-inset-right)); }
  }
  section { padding: 96px 6vw; }
  .meaning-grid { gap: 40px; }
  .portal-body { padding: 32px 22px; }
  .portal-head { padding: 16px 22px; font-size: 10px; letter-spacing: 0.2em; }
}

@media (max-width: 760px) {
  section { padding: 80px 5.5vw; }
  .mind-card { padding: 32px 24px; }
  .proof-item { padding: 18px; }
  .spectrum-code { white-space: normal; }
  .spectrum-row { padding: 22px 6px; }
  .hero-actions { gap: 14px; }
  .btn { padding: 16px 26px; letter-spacing: 0.2em; }
  #intake { padding-bottom: 110px; }
  footer { padding: 34px 6vw; gap: 14px; }
}

@media (max-width: 480px) {
  section { padding: 64px 5vw; }
  .mind-card { padding: 26px 20px; }
  .grid-4 { margin-top: 40px; }
  .proof-grid { gap: 18px; margin-top: 36px; }
  .btn { width: 100%; padding: 16px 20px; }
  .hero-actions { flex-direction: column; align-items: stretch; }
  .countdown { margin-top: 44px; }
  .cd-cell { min-width: 0; flex: 1 1 40%; padding: 16px 10px; }
  .tribute-terms { gap: 8px; }
  .tribute-terms span { padding: 8px 12px; letter-spacing: 0.18em; }
  .portal-body { padding: 24px 16px; }
  .btn-uplink { width: 100%; }
  .portal-foot { gap: 14px; }
  .hud-corner { width: 26px; height: 26px; }
}

/* --------------------------------------------------------------------------
   10. Cross-page helpers
   pricing.html / faq.html / policy pages use their own simpler shells.
   -------------------------------------------------------------------------- */
.nav a, .container .nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 6px;
}

@media (max-width: 600px) {
  .container { padding: 1.1rem; }
  .header h1 { font-size: clamp(1.7rem, 7vw, 2.2rem); }
  .pricing-card { padding: 1.4rem; }
  .pricing-card .price { font-size: clamp(2rem, 9vw, 2.5rem); }
  .specs { padding: 1.1rem; }
}

/* Policy / FAQ shells: body{padding:2rem} is tight on a phone. */
@media (max-width: 600px) {
  body.doc-shell { padding: 1.15rem; }
}

/* --------------------------------------------------------------------------
   11. Accessibility
   -------------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--cyan, #00f0ff);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  nav .nav-right,
  .nav-scrim,
  .nav-burger span { transition: none; }
  html { scroll-behavior: auto; }
}
