/* ============================================================
   Zenrac — responsive layer
   Loaded LAST on every page (after shared.css and each page's
   inline <style>), so these rules win at equal specificity.

   The site is authored desktop-first with fixed multi-column
   grids; this file collapses them and swaps the hover-driven
   nav for a tap-driven drawer.

   Breakpoints
     <=1180px  narrow desktop / landscape tablet — wide grids halve
     <=900px   portrait tablet & phones — nav drawer, single column
     <=560px   phones — tighter gutters, smaller display type
   ============================================================ */

/* Decorative marks are positioned to bleed past the layout edge by
   design; stop that bleed from creating a horizontal scrollbar. */
html, body { overflow-x: hidden; max-width: 100%; }

/* ===== Mobile nav toggle — hidden until the drawer breakpoint ===== */
.nav-toggle {
  display: none;
  width: 44px; height: 44px;
  flex-shrink: 0;
  align-items: center; justify-content: center;
  /* must paint above the open drawer (z-index 29) so it stays tappable
     as the close button */
  position: relative;
  z-index: 31;
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  color: var(--paper);
  cursor: pointer;
  padding: 0;
}
.nav-toggle:hover { border-color: var(--primary); color: var(--primary); }
.nav-toggle .bars { position: relative; width: 18px; height: 12px; display: block; }
.nav-toggle .bars::before,
.nav-toggle .bars::after,
.nav-toggle .bars span {
  content: ""; position: absolute; left: 0;
  width: 100%; height: 1.5px; border-radius: 2px;
  background: currentColor;
  transition: transform .22s ease, opacity .18s ease, top .22s ease;
}
.nav-toggle .bars::before { top: 0; }
.nav-toggle .bars span { top: 5.25px; }
.nav-toggle .bars::after { top: 10.5px; }
/* becomes an X while the drawer is open */
.nav-toggle[aria-expanded="true"] .bars::before { top: 5.25px; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] .bars::after  { top: 5.25px; transform: rotate(-45deg); }
.nav-toggle[aria-expanded="true"] .bars span    { opacity: 0; }

/* Backdrop behind the open drawer */
.nav-backdrop {
  position: fixed; inset: 0; z-index: 28;
  background: rgba(5, 4, 3, .6);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
body.nav-open { overflow: hidden; }

/* ============================================================
   901–1180px — wide grids halve
   Bounded at the bottom: the `!important` span rules below are more
   specific than the single-column collapse in the <=900px block, so
   letting them reach phone widths would defeat it.
   ============================================================ */
@media (min-width: 901px) and (max-width: 1180px) {
  .container { padding: 0 28px; }

  /* 4-across → 2-across */
  .stats-row, .stats-grid,
  .leaders,
  .platforms,
  .outcomes-strip,
  .outc,
  .arch-grid,
  .compl-grid,
  .pms-grid { grid-template-columns: repeat(2, 1fr); }

  .eng-grid, .pillar-grid { grid-template-columns: repeat(2, 1fr); }
  .proc-grid { grid-template-columns: repeat(2, 1fr); }
  .map-grid  { grid-template-columns: repeat(4, 1fr); }

  /* 12-column feature grids: half-width cards go full width */
  .svc-grid .svc-card { grid-column: span 6; }
  .ai-feat .span4, .ai-feat .span8 { grid-column: span 6 !important; }
  .feat-grid .feat-card.span4 { grid-column: span 6 !important; }

  .step { grid-template-columns: 64px 1fr; }
  .step .meta { grid-column: 2; text-align: left; }
}

/* ============================================================
   <=900px — nav drawer, single-column layout
   ============================================================ */
@media (max-width: 900px) {
  .container { padding: 0 24px; }
  [id] { scroll-margin-top: 84px; }

  /* ---------- section rhythm ---------- */
  .sec { padding: 76px 0; }
  .sec-inner { grid-template-columns: 1fr; gap: 20px; margin-bottom: 40px; align-items: start; }
  .sec-inner p { max-width: none; }
  .cta { padding: 76px 0; }
  .cta-grid { grid-template-columns: 1fr; gap: 36px; }
  .cta .lede { max-width: none; }
  .ipage-hero { padding: 120px 0 64px; }
  .ipage-hero .lede { font-size: 17px; max-width: none; }
  .ipage-hero h1 { font-size: clamp(40px, 11vw, 64px); margin: 24px 0 26px; }

  /* ---------- topbar → drawer ---------- */
  .tb { height: 68px; gap: 12px; }
  .logo-img { height: 32px; }
  .nav-toggle { display: inline-flex; }

  .nav {
    position: fixed; top: 0; right: 0; bottom: 0;
    z-index: 29;
    width: min(86vw, 340px);
    display: block;
    gap: 0;
    padding: 84px 22px 32px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: rgba(13, 11, 9, .98);
    backdrop-filter: blur(16px);
    border-left: 1px solid var(--line-2);
    box-shadow: -30px 0 60px -20px rgba(0, 0, 0, .7);
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    visibility: hidden;
  }
  body.nav-open .nav { transform: translateX(0); visibility: visible; }

  .nav-item { position: static; border-bottom: 1px solid var(--line); }
  .nav-item:last-of-type { border-bottom: none; }
  .nav-item > a {
    display: flex; justify-content: space-between; align-items: center;
    padding: 15px 4px; font-size: 16px; color: var(--paper); border-radius: 0;
  }
  .nav-item > a .chev { display: none; }

  /* submenus sit inline and stay open — no hover state on touch */
  .nav-item .menu {
    position: static; min-width: 0; width: auto;
    padding: 0 0 12px 4px; margin: 0;
    background: none; backdrop-filter: none;
    border: none; border-radius: 0; box-shadow: none;
    opacity: 1; pointer-events: auto; transform: none;
    transition: none;
  }
  .menu-grid { grid-template-columns: 1fr; gap: 2px; }
  .menu-item { flex-direction: row; align-items: center; gap: 10px; padding: 10px 8px; }
  .menu-item .ic { margin-bottom: 0; width: 26px; height: 26px; flex-shrink: 0; }
  .menu-item .ds { display: none; }         /* descriptions are noise at this width */
  .menu-item .nm { font-size: 14px; font-weight: 500; color: var(--paper-2); }
  .menu-foot { display: none; }

  /* CTA lives inside the drawer, appended by nav.js */
  .nav .nav-drawer-cta { display: block; margin-top: 22px; }
  .nav .nav-drawer-cta .btn { width: 100%; justify-content: center; padding: 15px 20px; font-size: 15px; }

  /* ---------- homepage hero ---------- */
  .hero { min-height: 0; padding: 116px 0 64px; }
  .hero-corners { display: none; }          /* corner labels would collide with content */
  h1.h1 { font-size: clamp(40px, 12vw, 68px); margin: 24px 0 32px; }
  .hero-sub { grid-template-columns: 1fr; gap: 32px; padding-top: 28px; }
  .lede { font-size: 17px; max-width: none; }
  .hero-meta .row { grid-template-columns: auto 1fr; gap: 10px; }
  .hero-meta .row .tag { grid-column: 2; }

  /* ---------- collapse the content grids ----------
     Grids whose cells hold prose or a whole card go to one column.
     Grids of small tiles (stat cells, badge cells, the floor map) keep
     multiple columns below — one column would blow each tile up to
     full width and lose the shape that makes them readable. */
  .about-grid,
  .prod-grid,
  .partner-cards,
  .partners-row,
  .principles,
  .leaders,
  .outcomes-grid,
  .pms-row,
  .eng-grid, .pillar-grid, .proc-grid,
  .certs-row,
  .agent-section,
  .mig-grid,
  .case-grid,
  .conc-grid,
  .floor,
  .ct-grid,
  .stack-grid,
  .modules, .h-modules,
  .clouds,
  .feat-grid, .svc-grid, .ai-feat, .feat6 { grid-template-columns: 1fr; }

  /* 12-column children must stop spanning once the track count is 1 */
  .svc-grid > *, .ai-feat > *, .feat-grid > *, .feat6 > *,
  .clouds > *, .stack-grid > *, .modules > *, .h-modules > * { grid-column: auto !important; }

  /* ---------- tile grids: fewer columns, not none ---------- */
  /* big-number stat cells — two up keeps the figures large but paired */
  .stats-row, .stats-grid, .outcomes-strip, .outc { grid-template-columns: repeat(2, 1fr); }
  /* short name + caption badge cells */
  .compl-grid, .pms-grid { grid-template-columns: repeat(2, 1fr); }
  /* platform tiles and the 4-column architecture diagram read as 2x2 */
  .platforms, .arch-grid { grid-template-columns: repeat(2, 1fr); }
  /* the floor map is a plan of small numbered rooms — keep it a plan */
  .map-grid { grid-template-columns: repeat(4, 1fr); }

  /* row-style grids with fixed side columns */
  .step { grid-template-columns: 1fr; gap: 14px; padding: 26px 22px; }
  .step .stp { font-size: 34px; }
  .step .meta { grid-column: auto; text-align: left; }
  .step p { max-width: none; }
  .tl-row { grid-template-columns: 1fr !important; gap: 10px; padding: 22px 24px; }
  .tl-row .yr { font-size: 28px; }
  .eval-bar { grid-template-columns: 1fr; gap: 8px; }
  .alert-item, .item, .pms-row, .row { gap: 12px; }

  /* Rows built from several fixed cells read as cramped columns on a
     phone; stack them instead. Compact two-cell rows (icon + text) are
     left alone — they still work side by side. */
  .mig-list .item { grid-template-columns: 1fr; gap: 6px; padding: 16px 20px; }
  /* the arrow carries the migration direction — turn it to match the stack */
  .mig-list .item .arr { transform: rotate(90deg); width: 1em; }
  .mig-list .item .to { color: var(--primary); }
  .outcomes-list .item { grid-template-columns: 1fr; gap: 8px; padding: 20px 22px; }
  .compliance .row { gap: 18px; }

  /* ---------- cards ---------- */
  .svc-card { min-height: 0; padding: 28px; }
  .svc-card h3 { font-size: 30px; }
  .feat-card, .ai-feat .card { padding: 24px; }
  .prod { min-height: 0; padding: 32px 26px; }
  .prod h3 { font-size: 34px; max-width: none; }
  .prod p { max-width: none; font-size: 15px; }
  .prod-glyph { font-size: 150px; top: 16px; right: 10px; }
  .stat-cell { padding: 26px 22px; }
  .stat-cell .v { font-size: 46px; }

  /* ---------- forms ---------- */
  form.demo, form.ct-form { padding: 22px; }
  form.demo .grid2, .ct-form .grid2 { grid-template-columns: 1fr; gap: 0; }
  .interest-grid { grid-template-columns: 1fr 1fr; }
  /* 16px avoids iOS Safari zooming the page on focus */
  form.demo input, form.demo select, form.demo textarea,
  .ct-form input, .ct-form select, .ct-form textarea { font-size: 16px; }

  /* ---------- footer ---------- */
  .ft { grid-template-columns: 1fr 1fr; gap: 28px 20px; }
  .ft > div:first-child { grid-column: 1 / -1; }
  .ft p.tag { max-width: none; }
  .ft-meta { flex-direction: column; align-items: flex-start; gap: 14px; }
  .ft-bottom { flex-direction: column; gap: 10px; }

  /* ---------- decorative marks: shrink and pin inside ---------- */
  .about-mark, .ct-mark, .pharma-mark, .hosp-mark,
  .ai-mark, .sf-mark, .cr-mark, .ma-mark {
    font-size: 200px !important;
    right: -20px !important;
    left: auto !important;
    top: 40px !important;
  }

  /* ---------- video modal ---------- */
  .video-modal { padding: 16px; }
  .vmst-pulse { width: 300px; height: 300px; }
  .vmst-headline { font-size: clamp(20px, 6vw, 32px); }
  .vmst-cap { left: 14px; top: 14px; font-size: 10px; }
  .vm-bar { padding: 12px 14px; }

  /* touch targets */
  .ft a { padding: 9px 0; }
}

/* ============================================================
   <=560px — phones
   ============================================================ */
@media (max-width: 560px) {
  .container { padding: 0 18px; }

  .sec { padding: 60px 0; }
  .cta { padding: 60px 0; }
  .ipage-hero { padding: 104px 0 52px; }
  .hero { padding: 104px 0 52px; }

  /* the topbar CTA has no room next to the logo and toggle */
  .tb-cta { display: none; }

  h1.h1 { font-size: clamp(34px, 12.5vw, 46px); letter-spacing: -0.02em; }
  .ipage-hero h1 { font-size: clamp(34px, 12vw, 46px); letter-spacing: -0.02em; }
  .sec-inner h2 { font-size: clamp(30px, 9.5vw, 40px); }
  .cta h2 { font-size: clamp(32px, 10vw, 44px); }
  .about-grid h2 { font-size: clamp(30px, 9.5vw, 40px); }

  /* hairline text-stroke headings turn to mush at small sizes */
  h1 .stroke, h2 .stroke, .ipage-hero h1 .stroke {
    -webkit-text-stroke-width: 1px;
  }

  .eyebrow { font-size: 10px; letter-spacing: .1em; padding: 7px 12px 7px 10px; }
  .num { font-size: 10px; letter-spacing: .12em; }

  .interest-grid { grid-template-columns: 1fr; }
  .stat-cell .v { font-size: 40px; }
  .prod-glyph { font-size: 110px; }
  .prod h3 { font-size: 28px; }
  .svc-card h3 { font-size: 26px; }
  .feat-card h4, .ai-feat .card h4 { font-size: 21px; }

  .ft { grid-template-columns: 1fr; gap: 24px; }
  .ft > div:first-child { grid-column: auto; }

  .about-mark, .ct-mark, .pharma-mark, .hosp-mark,
  .ai-mark, .sf-mark, .cr-mark, .ma-mark { font-size: 150px !important; }

  /* full-width buttons read better than wrapped pills */
  .ipage-hero .ctas .btn, .hero-cta .btn { width: 100%; justify-content: center; }
  .ipage-hero .ctas, .hero-cta { gap: 10px; }
}

/* Respect a user's reduced-motion preference for the drawer */
@media (prefers-reduced-motion: reduce) {
  .nav, .nav-backdrop, .nav-toggle .bars::before,
  .nav-toggle .bars::after, .nav-toggle .bars span { transition: none; }
}
