/*
  Station70 responsive retrofit layer.
  Loaded by every page after colors_and_type.css.
  Breakpoints per design system: 640 / 1024.
  Desktop styles are inline; mobile overrides live here inside media
  queries (the one thing inline styles cannot express), using !important
  to win over the inline declarations.
*/

/* Bunker hero "graph": the hero's own 2 column grid (repeat(auto-fit,
   minmax(340px, 1fr))) drops the vault visual below the text column once
   there isn't room for two real 340px+ columns side by side (~840px and
   under). Below 1400px, force that same below-the-text stacking for the
   whole gap up to where the 2 column split can comfortably fit both a real
   text column and the vault visual at close to its natural width (see the
   container query below for why 1400) - this only controls WHEN the vault
   visual moves below the text, not its own internal layout. */
@media (max-width: 1400px) {
  .s70-bunker-hero-grid { grid-template-columns: 1fr !important; }
}

/* Bunker hero "graph", continued: the vault visual's own desktop layout
   (4-across wallet-chip row, branching svg connector, side by side "Zero
   knowledge architecture / vault / Operations" row) should survive moving
   below the text above - it only needs to change once it genuinely doesn't
   fit. Its fixed-width pieces need ~558px to lay out side by side (the
   sidewrap row alone renders at a constant 558px regardless of container
   width, since every one of its children is a fixed pixel width with no
   wrap - confirmed unchanging across many container widths); the
   wallet-chip row's own natural minimum is narrower (~460px) so the
   sidewrap row is always the binding constraint. `.s70-bunker-vault` is a
   container (container-type: inline-size) precisely so this can be judged
   against its own rendered width instead of viewport width - it works
   whether the vault visual is sitting beside the text (a narrow tablet-era
   grid column) or below it (up to its own 660px cap), with no separate
   breakpoint math needed for either case. 560px (a ~2px safety margin over
   the 558px minimum, not more) matters here: with more slack than that
   (580px was tried first), the vault visual's own natural `auto-fit` 2
   column width lands *between* the true 558px minimum and the padded
   threshold for a real range above 1400px (roughly 1400-1435px, where the
   hero naturally gives the visual 567-579px - comfortably enough) and
   incorrectly drops to the stacked layout there even though the desktop
   layout fits fine. */
@container (max-width: 560px) {
  .s70-bunker-walletgrid { grid-template-columns: 1fr !important; }
  .s70-bunker-connsvg { display: none !important; }
  .s70-bunker-connsvg-mobile { display: block !important; }
  .s70-bunker-sidewrap { flex-direction: column !important; }
  .s70-bunker-connline { width: 1px !important; height: 22px !important; }
}

/* Tablet and below: swap the desktop nav links for the hamburger (s70-mobile-nav.js) */
@media (max-width: 1023px) {
  .s70-desktop-nav { display: none !important; }

  /* s70-nav.js's background scrim behind the logo (same element desktop fades in
     on scroll) never appears here: its scroll-triggered opacity toggle listens
     on window.scrollY, but at these widths the phone-only overflow-x: hidden
     rule below turns <body> into its own scroll container, so window.scrollY
     stays 0 and the listener never fires. Rather than chase that, just make
     the scrim permanently visible below 1024px - it's already styled exactly
     like the desktop nav's background (rgba(11,11,11,0.72), blur(14px)), it's
     just never been shown. */
  .s70-nav-scrim { opacity: 1 !important; }

  /* Collapsed nav bar: shrink its vertical padding and the logomark (wordmark
     stays its own size) so the bar takes up less height once the desktop
     link row is gone. The hamburger button (s70-mobile-nav.js) is fixed
     positioned independent of this nav's flex row, so its `top` is re-centered
     to match the new, shorter bar. */
  s70-nav nav { padding-top: 14px !important; padding-bottom: 14px !important; }
  .s70-nav-logomark { width: 30px !important; height: 30px !important; }
  .s70-mnav-btn { top: 7px !important; }

  /* Bunker "Selected by" logo strip: 4 columns instead of the desktop
     default of 5. This is a fixed count, not auto-fit, deliberately - see
     the phone-tier comment below for why. */
  .s70-bunker-logos { grid-template-columns: repeat(4, 1fr) !important; }
}

/* Phones */
@media (max-width: 767px) {
  html, body { overflow-x: hidden; }

  /* Collapse equal multi column grids to a single column.
     Grids with fixed track sizes (icon + text rows) are untouched. */
  [style*="grid-template-columns: repeat(2"],
  [style*="grid-template-columns: repeat(3"],
  [style*="grid-template-columns: repeat(4"],
  [style*="grid-template-columns: repeat(5"],
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* FAQ sections (home/castle/gatekeeper): a fixed-min sidebar column
     (minmax(220px, 360px)) next to the questions column doesn't fit a phone
     width even with the 1fr column collapsed to its content, so this needs
     its own rule rather than the equal-column one above. home.html still
     carries this as a raw inline style, hence the attribute selector; castle
     and gatekeeper's own FAQ grids moved to classes (.s70-castle-faq-grid,
     .s70-gk-faq-grid) during their inline-style extractions, so they're
     listed here explicitly too - the attribute selector alone stopped
     matching those two pages once the inline style was replaced with a
     class, which briefly regressed gatekeeper.html's FAQ mobile collapse
     until caught here. */
  [style*="grid-template-columns: minmax(220px, 360px) 1fr"],
  .s70-castle-faq-grid,
  .s70-gk-faq-grid {
    grid-template-columns: 1fr !important;
  }

  /* Footer category columns (Company/Products/Architectures/Trust/Legal): flex-wrap
     packs them 2-per-row when they fit and drops to 1-per-row when they don't,
     and which happens depends on exact viewport width and each column's own
     content length - inconsistent, and not always the same pairing. Stack them
     as a single column instead so every category (Products, Trust, etc.) is
     full width and vertically stacked, same at every phone width. */
  [style*="display: flex; flex-wrap: wrap; gap: clamp(48px, 8vw, 112px);"] {
    flex-direction: column !important;
    gap: 40px !important;
  }

  /* Bunker "Selected by" logo strip: force exactly 2 columns on phones (see
     the tablet-tier 4 column override above - both are fixed counts, not
     `repeat(auto-fit, minmax(...))`, deliberately: with 20 logos, auto-fit
     naturally picks anywhere from 1 to 5 columns depending on viewport
     width, and 3 is the only one of those that doesn't divide 20 evenly -
     leaving a lone half-filled last row whose empty cell visibly shows this
     grid's own background (the hairline color used for the gaps between
     items - see below) as a highlighted blank rectangle, not a subtle line.
     2/4/5 (phone/tablet/desktop) all divide 20 evenly, so every tier's grid
     fills completely with no leftover cells. Also shrink the logos to fit
     the narrower phone column (at 320px wide, a column is ~136px including
     its own 16px×2 padding, so the image itself only has ~100px to work
     with once padding is tightened below). */
  .s70-bunker-logos {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .s70-bunker-logo-item {
    padding: 20px 10px !important;
  }
  .s70-bunker-logo-item img {
    height: 22px !important;
    max-width: 108px !important;
  }

  /* Whitepaper request form (s70-whitepaper-form.js, shared across bunker/
     castle/gatekeeper): the card's own flex-wrap never reliably breaks the
     text block and the form column onto separate rows - both are plain
     flex children with no explicit min-width of their own (the form column
     aside), so from ~640-767px wide they just both shrink to share one row
     instead of wrapping, squeezing the form column down far enough that
     its input+button overflow past the card's right edge (confirmed via
     screenshot at 700px: "Request access" clipped off-screen, form column
     never even reaching its own 300px floor). Forcing column direction
     below 767px removes the ambiguity - the form is always a full-width
     row below the heading text, at every phone/tablet width, not just the
     ones narrow enough to force a flex-wrap the browser would otherwise
     choose on its own. align-items reset to stretch alongside it: center
     (its row-layout cross-axis meaning) would otherwise become "shrink
     each stacked block to its own content width and center it" once the
     axis rotates to column. */
  .s70-wp-card {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  /* ...and the form column's own hard 300px minimum still doesn't shrink
     on phones even once column direction guarantees it a full-width row -
     a flex item's stretched cross-size is still clamped to its own
     min-width, and the card's own padding alone already leaves less than
     300px available at 320-375px wide. Only the column needs this; the
     email input's own 200px minimum stays untouched - that's what makes
     the input+button form row wrap the button below the input once they
     don't both fit, instead of just squeezing the input down to an
     unreadable sliver. */
  .s70-wp-formcol {
    min-width: 0 !important;
    /* Below ~300px viewport, `min-width: 0` alone isn't enough - confirmed
       via direct DOM testing that even with min-width:0 explicitly set,
       the column's *stretched* cross-size (align-items: stretch, from the
       card's own flex-direction: column above) still floors out around
       219px instead of tracking the card's actual shrinking content box,
       because the column re-derives its own width from its deepest
       children's natural (unwrapped) line lengths rather than the
       stretch-fit size in this nested-flex arrangement. An explicit
       `width: 100%` sidesteps that entirely - confirmed by direct testing
       that it's the one override that reliably pins the column to the
       card's real available width at every size, letting its own children
       (the email input, the "Work email required." helper text) wrap or
       shrink to fit rather than forcing the column wider than its parent. */
    width: 100% !important;
  }

  /* Bunker "Continuity" section (With Bunker / Without Bunker timeline
     cards): same fixed-min-track problem as the hero vault visual's own
     grid above, one level of scope smaller - a 300px floor that doesn't
     shrink and overflows a phone width even once auto-fit has already
     collapsed it to a single column. Scoped to this specific grid (not a
     sitewide `minmax(300px, 1fr)` selector) since that exact pattern is
     used in ~20 other files this session hasn't audited. */
  .s70-bunker-continuity-grid {
    grid-template-columns: 1fr !important;
  }

  /* Gatekeeper capability index (.s70-gk-capindex): same fixed 300px
     floor, same fix, same scoping reasoning as the bunker continuity grid
     immediately above - `repeat(auto-fit, minmax(300px, 1fr))` still
     overflows at 320-375px even once auto-fit is already down to a single
     column, and `minmax(300px, 1fr)` is too widely reused elsewhere in
     this codebase to touch sitewide. (This rule previously targeted
     .s70-gk-why-grid, which was replaced by the comparison ledger.) */
  .s70-gk-capindex {
    grid-template-columns: 1fr !important;
  }

  /* Gatekeeper hero gateway diagram: the hero's own 2 column grid uses the
     same fixed 340px column floor as bunker's hero grid, but unlike
     bunker's (forced to a single 1fr track by its own 1400px media query,
     removing the floor well before phone width) gatekeeper's stays on
     `repeat(auto-fit, minmax(340px, 1fr))` all the way down - already a
     single column below ~680px via auto-fit, but that one column still
     refuses to be narrower than 340px, so the whole hero overflows every
     phone width under ~390px. Drop the floor the same way bunker's does. */
  .s70-gk-hero-grid {
    grid-template-columns: 1fr !important;
  }

  /* Gatekeeper hero diagram's two side callouts ("Deny by default", "Scoped
     per human or agent identity") are absolutely positioned to either side
     of the 128px policy engine icon - fine on desktop, where the diagram
     has ~640px to spread into, but there's no room left over for two
     ~110-150px callouts breaking out sideways once the diagram is squeezed
     down to a phone's content width, so they ran off both edges of the
     screen. Drop them back into normal document flow (they already sit
     right after the "Policy engine" label in source order, inside a
     centered flex column) so they wrap and center under the icon instead. */
  .s70-gk-sidelabel {
    position: static !important;
    width: auto !important;
    max-width: 240px !important;
    text-align: center !important;
    margin: 2px auto 0 !important;
  }

  /* Gatekeeper hero diagram's "Humans / Agents / Any LLM" source row: the
     generic 3-column collapse rule above (targeting the literal
     `repeat(3, 1fr)` inline style) would otherwise stack these into a
     single column too - but unlike a normal 3-card feature grid, this one
     has a branching SVG connector directly beneath it whose curve assumes
     3 evenly spaced horizontal source points converging on the policy
     engine icon. Stacked vertically, the badges no longer line up with
     where the curve actually fans out from, so the diagram reads as
     visually broken even though nothing overflows. Confirmed via
     screenshot the 3 columns fit fine down to 320px wide (each badge is
     just a short nowrap pill) - this needs to stay a fixed 3-column row,
     not collapse, unlike an actual multi-card grid. */
  .s70-gk-sources {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  /* Castle hero identity diagram: the same template as gatekeeper's hero
     gateway diagram above (2 column grid with a fixed 340px floor, a 3
     badge source row above a curved SVG connector, two absolutely
     positioned side callouts either side of the central icon) - built as
     its own copy on this page rather than a shared component, so it has
     the identical 3 bugs and gets the identical fix, just under its own
     castle-prefixed classes since that matches how bunker/gatekeeper's
     analogous-but-not-identical hero grids were already scoped separately. */
  .s70-castle-hero-grid {
    grid-template-columns: 1fr !important;
  }

  .s70-castle-sidelabel {
    position: static !important;
    width: auto !important;
    max-width: 240px !important;
    text-align: center !important;
    margin: 2px auto 0 !important;
  }

  .s70-castle-sources {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  /* Castle's 3 source badges themselves (unlike gatekeeper's "Humans / Agents
     / Any LLM", which are all short enough to fit as single-line nowrap pills
     down to 320px - see the comment on .s70-gk-sources above): the middle
     "Entra / Azure AD" badge's own nowrap min-content (~160px) is wide enough
     that once the hero grid above collapses the text column and the diagram
     column onto the same shared single-column track (below ~680px), that one
     badge's width alone forces the shared column wider than the viewport all
     the way down to ~370px, dragging the whole hero (headline included) into
     horizontal overflow. Letting these badges wrap to 2-3 lines instead of
     forcing one line drops each badge's own min-content down to its longest
     single word ("AZURE" or "SHARING"-scale), which fits easily inside a
     grid-thirds column even at 320px - confirmed via direct DOM testing
     (toggling white-space on the badges) that this alone drops the row's
     rendered width from ~346px to the container's full available ~272px at
     320px wide, with no other change needed. */
  .s70-castle-source-badge {
    white-space: normal !important;
    text-align: center !important;
  }

  /* blog.html's post card grid (.s70-blog-grid): same fixed-min-track bug as
     bunker's Continuity grid and gatekeeper's Why Gatekeeper grid above -
     `repeat(auto-fill, minmax(320px, 1fr))` already collapses to a single
     column well before phone width (2 real 320px columns need ~712px), but
     that one remaining column still refuses to shrink below 320px, so it
     overflows the ~296-344px viewport range where the container's available
     width sits between 272px and 320px. Same fix, same scoping reasoning as
     the other two: collapsed to `1fr` below 767px (already effectively a
     single column for this grid across all of that range anyway), scoped to
     its own class rather than the shared `minmax(320px, 1fr)` literal since
     that pattern isn't audited sitewide this session.
  */
  .s70-blog-grid {
    grid-template-columns: 1fr !important;
  }

  /* team.html's team member card grid (.s70-team-grid): same fixed-min-track
     bug as the grids above - `repeat(auto-fit, minmax(300px, 1fr))` already
     down to a single column well before phone width, but that one column
     still refuses to shrink below 300px, overflowing by a few px right at
     the 320px floor itself (300px card + 24px padding each side = 348px,
     4px past a 320px viewport - confirmed via a bounding-box sweep, clean
     again by 340px). Same fix: collapsed to `1fr` below 767px, scoped to its
     own class rather than the shared `minmax(300px, 1fr)` literal.
  */
  .s70-team-grid {
    grid-template-columns: 1fr !important;
  }

  /* Job posting detail pages (careers-*.html, 11 pages): the "What you will
     do" / "What we look for" two column layout has the same fixed-min-track
     bug as the grids above - `repeat(auto-fit, minmax(340px, 1fr))` is
     already a single column well before phone width, but that column still
     refuses to shrink below 340px, overflowing at every phone width (272px
     available at 320px, up to ~660px available at 767px - both under the
     340px+ floor). Was scoped via an attribute selector matching the literal
     inline style string (identical across, and unique to, all 11 job
     posting pages) before careers.css existed; now targets the `.s70-role-grid`
     class those pages carry instead (see careers.css). */
  .s70-role-grid {
    grid-template-columns: 1fr !important;
  }

  /* contact.html's top level layout (.s70-contact-grid, the copy/contact
     info column next to the form column) has the same fixed-min-track bug
     as the grids above - `repeat(auto-fit, minmax(320px, 1fr))` already a
     single column well before phone width, but that column still refuses
     to shrink below 320px, overflowing by 24px right at the site's 320px
     floor itself (clean again by 360px, confirmed via a bounding-box
     sweep). Same fix: collapsed to `1fr` below 767px, scoped to its own
     class rather than the shared `minmax(320px, 1fr)` literal (also used,
     with a different fix, by blog.html's `.s70-blog-grid` above).
  */
  .s70-contact-grid {
    grid-template-columns: 1fr !important;
  }

  /* Long URLs in body copy (EULA subprocessor link, privacy-policy opt-out links) have no break points and ran off
     the screen at 320-375px. break-word only splits a word that cannot fit on a line by itself. */
  p, li, dd, td, th, figcaption, blockquote {
    overflow-wrap: break-word;
  }

  /* Wide tables scroll horizontally instead of overflowing the page */
  table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 16px minimum stops iOS zooming the page when a field gets focus */
  input, select, textarea { font-size: 16px !important; }

  /* Full height heroes track the visible viewport, not the URL bar.
     Must be "; height: 100vh", not just "height: 100vh" - the bare substring
     also matches inside "min-height: 100vh" (bunker/castle/gatekeeper's hero
     wrappers), which would hand those a hard `height` they don't have on
     desktop. Combined with their `overflow: hidden`, that silently clipped
     anything in the hero taller than one screen - e.g. bunker.html's vault
     graph once it's tall enough to need scrolling within the hero. */
  [style*="; height: 100vh"] { height: 100svh !important; }

  /* Utility: hide desktop-only decoration on phones */
  .s70-m-hide { display: none !important; }

  /* Utility: pin absolutely positioned hero copy to the phone's edges */
  .s70-m-inset {
    left: 24px !important;
    right: 24px !important;
    max-width: none !important;
  }
}

/* Small phones: keep display type inside the viewport */
@media (max-width: 640px) {
  h1 { font-size: clamp(30px, 9.5vw, 42px) !important; }
}

/* Gatekeeper "Integrations" logo row: 24 fixed 156px-wide boxes in a
   centered flex-wrap row. From ~380px viewport down to ~544px it already
   wraps to a clean 2-per-row naturally (2*156px + the 14px gap = 326px,
   comfortably under the available width there), so this is scoped to
   only kick in below 380px, where there's no longer room for 2 fixed
   156px boxes side by side and flex-wrap drops to 1 per row instead -
   not overflowing, just a much taller single column than intended.
   Switch to an explicit 2-column grid and shrink the boxes/logos to fit:
   24 divides evenly by 2, so there's no half-filled last row to worry
   about (unlike the bunker logo strip's column-count math). Both
   selectors are scoped to this exact literal style string rather than a
   class, since grep confirms neither pattern (the 156px/90px box, or
   this row's own flex-wrap style) appears anywhere else in the
   codebase. */
@media (max-width: 380px) {
  [style*="display: flex; flex-wrap: wrap; gap: 14px; justify-content: center;"] {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
  }
  [style*="width: 156px; height: 90px"] {
    width: auto !important;
    height: 72px !important;
    padding: 10px !important;
  }
  [style*="width: 156px; height: 90px"] img {
    max-height: 26px !important;
  }
}

/* Gatekeeper comparison ledger and review pack: stack below tablet width.
   The ledger's per-cell micro-labels are hidden on desktop (the header row
   carries the column names) and shown when rows stack. */
@media (max-width: 899px) {
  /* !important because responsive.css loads BEFORE gatekeeper.css in every
     page's helmet, so equal-specificity rules here lose to the base styles
     there - same reason as every other override in this file. */
  .s70-gk-compare-head { display: none !important; }
  .s70-gk-compare-row { grid-template-columns: 1fr !important; gap: 16px !important; }
  .s70-gk-compare-microlabel { display: block !important; }
  .s70-gk-review-row { grid-template-columns: 1fr auto !important; }
  .s70-gk-review-desc { grid-column: 1 / -1 !important; }
}

/* Gatekeeper hero return rail: phones don't have the horizontal room for
   the side rail and its vertical label; the caption below the diagram
   carries the same claim there. !important for the same load-order reason
   as the block above. */
@media (max-width: 767px) {
  .s70-gk-returnrail, .s70-gk-returnrail-label { display: none !important; }
  .s70-gk-gateway-inner { padding-right: 0 !important; }
}
