/* ── Krytz · Mobile compatibility ─────────────────────────────────────── *
 *
 * Loaded LAST so these rules win the cascade against feature stylesheets.
 * Targets ≤880px (phone), with extra tightening at ≤560px (small phone).
 */

/* ══════════════════════════════════════════════════════════════════
   MOBILE NAV · hamburger + drawer
   ══════════════════════════════════════════════════════════════════ */
.nav-hamburger {
  display: none;
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  position: relative;
}
.nav-hamburger:active { background: var(--bg-3); }
.nav-hamburger span {
  position: absolute;
  left: 10px; right: 10px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 240ms cubic-bezier(0.2, 0.7, 0.3, 1), opacity 200ms;
}
.nav-hamburger span:nth-child(1) { top: 13px; }
.nav-hamburger span:nth-child(2) { top: 19px; }
.nav-hamburger span:nth-child(3) { top: 25px; }
.nav-hamburger.is-open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-hamburger.is-open span:nth-child(2) { opacity: 0; }
.nav-hamburger.is-open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.mobile-drawer {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 49;
  display: flex; flex-direction: column;
  padding: 88px 28px 32px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease-out;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.mobile-drawer.is-open {
  opacity: 1;
  pointer-events: auto;
}
.mobile-drawer a {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  transition: transform 360ms cubic-bezier(0.2,0.7,0.3,1), opacity 300ms;
  transform: translateY(16px);
  opacity: 0;
}
.mobile-drawer a::after {
  content: '→';
  font-family: var(--mono);
  font-size: 20px;
  color: var(--ink-3);
  font-weight: 400;
}
.mobile-drawer.is-open a {
  transform: translateY(0);
  opacity: 1;
}
.mobile-drawer.is-open a:nth-child(1) { transition-delay: 80ms; }
.mobile-drawer.is-open a:nth-child(2) { transition-delay: 120ms; }
.mobile-drawer.is-open a:nth-child(3) { transition-delay: 160ms; }
.mobile-drawer.is-open a:nth-child(4) { transition-delay: 200ms; }
.mobile-drawer.is-open a:nth-child(5) { transition-delay: 240ms; }
.mobile-drawer.is-open a:nth-child(6) { transition-delay: 280ms; }
.mobile-drawer.is-open a:nth-child(7) { transition-delay: 320ms; }
.mobile-drawer.is-open a:nth-child(8) { transition-delay: 360ms; }

/* ── Drawer accordion (nav submenus) ──────────────────────────────── */
.mobile-drawer .nav-item {
  position: relative;
  transform: translateY(16px);
  opacity: 0;
  transition: transform 360ms cubic-bezier(0.2,0.7,0.3,1), opacity 300ms;
}
.mobile-drawer.is-open .nav-item {
  transform: translateY(0);
  opacity: 1;
}
.mobile-drawer.is-open .nav-item:nth-child(1) { transition-delay: 80ms; }
.mobile-drawer.is-open .nav-item:nth-child(2) { transition-delay: 140ms; }
.mobile-drawer.is-open .nav-item:nth-child(3) { transition-delay: 200ms; }
.mobile-drawer.is-open .nav-item:nth-child(4) { transition-delay: 260ms; }

.mobile-drawer .nav-link {
  width: 100%;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  background: transparent;
  border: 0;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer;
  font-family: inherit;
}
.mobile-drawer .nav-link .nav-caret {
  transition: transform 240ms cubic-bezier(0.2, 0.7, 0.3, 1);
  width: 14px; height: 9px;
  opacity: 0.55;
}
.mobile-drawer .nav-item.is-open .nav-link .nav-caret {
  transform: rotate(180deg);
  opacity: 1;
}
.mobile-drawer .nav-link-solo {
  /* keep the simple-link items (Pricing) consistent with old style */
  font-size: 26px;
}

.mobile-drawer .nav-sub {
  position: static;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  min-width: 0;
  opacity: 1;
  transform: none;
  pointer-events: auto;
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 320ms cubic-bezier(0.2, 0.7, 0.3, 1);
  overflow: hidden;
}
.mobile-drawer .nav-item.is-open .nav-sub {
  grid-template-rows: 1fr;
}
.mobile-drawer .nav-sub > div,
.mobile-drawer .nav-sub-inner {
  min-height: 0;
}
.mobile-drawer .nav-sub a {
  font-size: 16px !important;
  font-weight: 400 !important;
  padding: 12px 4px 12px 14px !important;
  border-bottom: 1px dashed var(--line) !important;
  border-left: 2px solid var(--g-soft);
  margin-left: 4px;
  transform: none !important;
  opacity: 1 !important;
  display: flex !important;
  align-items: flex-start;
  gap: 10px;
  letter-spacing: -0.005em;
  transition: none;
}
.mobile-drawer .nav-sub a::after {
  display: none;
}
.mobile-drawer .nav-sub a:last-child {
  border-bottom: 0 !important;
}
.mobile-drawer .nav-sub .ns-glyph {
  display: grid; place-items: center;
  width: 22px; height: 22px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--g);
  font-family: var(--mono);
  margin-top: 2px;
}
.mobile-drawer .nav-sub .ns-text {
  display: flex; flex-direction: column; gap: 1px;
  min-width: 0;
}
.mobile-drawer .nav-sub .ns-text strong {
  font-weight: 500;
  font-size: 16px;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.mobile-drawer .nav-sub .ns-text em {
  font-style: normal;
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.4;
}
.mobile-drawer .drawer-actions {
  margin-top: auto;
  padding-top: 24px;
  display: flex; flex-direction: column; gap: 10px;
}
.mobile-drawer .drawer-actions .btn { width: 100%; padding: 14px 18px; font-size: 15px; }

@media (max-width: 880px) {
  .nav-hamburger { display: flex; }
  .nav-links { display: none !important; }
  .nav-cta .btn-ghost { display: none; }
  .nav-cta .btn:not(.btn-primary) { display: none; }
  body.has-drawer-open { overflow: hidden; }
}

/* ══════════════════════════════════════════════════════════════════
   GLOBAL · spacing, typography, hit targets
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 880px) {
  .wrap { padding: 0 20px; }
  section { padding: 56px 0; }

  .h-display { font-size: clamp(34px, 9vw, 44px) !important; line-height: 1.05 !important; }
  .h-section { font-size: clamp(26px, 7vw, 34px) !important; line-height: 1.1 !important; }
  .lede { font-size: 16px !important; line-height: 1.55; }

  .btn { padding: 12px 16px; min-height: 44px; }
  .btn-sm { padding: 10px 14px; min-height: 40px; }
  .btn-lg { padding: 14px 18px; font-size: 15px; }

  /* Settings panel position — anchor to right edge, slightly inset */
  .sf-panel {
    width: calc(100vw - 32px);
    max-width: 320px;
    right: -8px;
  }
}

@media (max-width: 560px) {
  .wrap { padding: 0 16px; }
  section { padding: 48px 0; }
}

/* ══════════════════════════════════════════════════════════════════
   PAGE HEAD · architecture workflow strip
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 880px) {
  .page-head { padding: 48px 0 32px; }
  .page-head .h-display { margin-top: 12px; }
  .page-head .lede { margin-top: 16px; }

  .arch {
    margin-top: 32px !important;
    padding: 18px !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }
  .arch-node { padding: 12px !important; }
  .arch-node h5 { font-size: 13px !important; }
  .arch-node p { font-size: 11px !important; }
  .arch-arrow { display: none !important; }
}

@media (max-width: 480px) {
  .arch { grid-template-columns: 1fr !important; }
}

/* ══════════════════════════════════════════════════════════════════
   TICKERS STRIP
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 560px) {
  .nt-strip { padding: 40px 0; }
  .nt-grid { grid-template-columns: 1fr 1fr !important; gap: 20px; }
  .nt-num { font-size: 42px !important; }
}

/* ══════════════════════════════════════════════════════════════════
   PARALLAX HERO · drop back layers, scale down, freeze motion
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 880px) {
  .px-section { padding: 56px 0 40px; }
  .px-stage { height: 460px; }
  .px-center h2 { font-size: clamp(28px, 8vw, 40px) !important; padding: 0 12px; }
  .px-center .px-sub { font-size: 14px; padding: 0 12px; }

  /* Smaller layers */
  .px-layer { padding: 8px 12px; font-size: 10.5px; border-radius: 8px; }
  .px-layer .lbl { font-size: 9px; }
  .px-layer.lg { padding: 12px 14px; font-size: 12px; }
  .px-layer.lg.score { min-width: 140px; }
  .px-layer.pill { padding: 6px 10px; font-size: 11px; }
  .px-layer.glyph { width: 44px; height: 44px; font-size: 20px; }
}

@media (max-width: 560px) {
  /* Hide deeper/decorative layers on small phones to reduce clutter */
  .px-stage { height: 420px; }
  .px-layer[data-depth="0.18"],
  .px-layer[data-depth="0.20"],
  .px-layer[data-depth="0.22"] {
    display: none;
  }
}

/* Touch devices — disable cursor parallax, layers stay static */
@media (hover: none) {
  .px-stage [data-depth] { transition: none !important; }
}

/* ══════════════════════════════════════════════════════════════════
   SCROLL-TRIGGERED SCENE
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 980px) {
  .ss-outer { height: 420vh; }
  .ss-sticky {
    grid-template-columns: 1fr !important;
    gap: 18px !important;
    padding: 80px 20px 20px !important;
    min-height: 100vh !important;
    align-items: start;
    overflow-y: auto;
  }
  .ss-meta { top: 24px; left: 20px; right: 20px; font-size: 10px; }
  .ss-progress { margin: 0 14px; }
  .ss-text { height: auto; min-height: 180px; }
  .ss-text .ss-step h3 { font-size: clamp(22px, 6vw, 30px) !important; }
  .ss-text .ss-step p { font-size: 14px; }
  .ss-canvas { height: 360px; }
  .ss-card { width: min(360px, 86%); padding: 18px; }
  .ss-card .ss-body { font-size: 13.5px; }
  .ss-queue { top: 60px; left: 16px; right: 16px; }
  .ss-queue .ss-q-row { padding: 10px 12px; }
  .ss-queue .ss-q-title { font-size: 12.5px; }
  .ss-score { padding: 10px 14px; width: min(360px, 86%); }
  .ss-score .ss-score-num { font-size: 18px; }
  .ss-chip { font-size: 9.5px; padding: 4px 8px; }
}

/* ══════════════════════════════════════════════════════════════════
   FORCE-DIRECTED GRAPH
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 880px) {
  .fg-canvas { height: 380px; }
  .fg-toolbar { padding: 12px 14px; flex-wrap: wrap; gap: 10px; }
  .fg-toolbar-left { gap: 12px; font-size: 10px; flex-wrap: wrap; }
  .fg-btn { padding: 5px 8px; font-size: 10px; }
  .fg-detail { left: 10px; bottom: 10px; padding: 10px 14px; max-width: calc(100% - 20px); font-size: 10.5px; }
}

/* ══════════════════════════════════════════════════════════════════
   PRIORITY RECOMPUTE
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 880px) {
  .pr-list { height: auto; min-height: 460px; }
  .pr-row { height: auto; min-height: 56px; padding: 10px 12px; grid-template-columns: 24px 1fr auto; gap: 10px; }
  .pr-row .pr-title { font-size: 13px; }
  .pr-row .pr-meta { flex-wrap: wrap; gap: 8px; }
  .pr-row .pr-meta .m { font-size: 9.5px; }
  .pr-row .pr-score .num { font-size: 14px; }
}

/* ══════════════════════════════════════════════════════════════════
   AI EXTRACTION
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 880px) {
  .cx-pane { min-height: 360px; }
  .cx-input { font-size: 14px; min-height: 160px; }
  .cx-input-area { padding: 16px; }
  .cx-presets { padding: 10px 16px 16px; }
  .cx-preset { font-size: 12px; padding: 7px 10px; }
}

/* ══════════════════════════════════════════════════════════════════
   PRICING CALC
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 880px) {
  .pc-wrap { padding: 24px; }
  .pc-left h3 { font-size: clamp(24px, 7vw, 32px) !important; }
  .pc-total { font-size: clamp(48px, 13vw, 64px) !important; }
  .pc-right { text-align: left; }
  .pc-savings { display: flex; }
}

/* ══════════════════════════════════════════════════════════════════
   SYSTEMS SHOWCASE
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 980px) {
  .ep-wrap { padding: 24px 20px; }
  .ep-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important; gap: 8px; }
  .ep-card { padding: 12px; }
  .ep-name { font-size: 12px; }
  .ep-meta { font-size: 9.5px; }
  .ep-detail {
    position: static !important;
    top: auto !important;
    margin-top: 8px;
  }
}

@media (max-width: 480px) {
  .ep-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ══════════════════════════════════════════════════════════════════
   TIMELINE SCRUBBER
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 880px) {
  .tl-wrap { padding: 20px 16px; }
  .tl-head { flex-direction: column; align-items: start; gap: 14px; }
  .tl-stats { text-align: left; align-self: stretch; justify-content: space-between; gap: 8px; }
  .tl-time { font-size: 36px; }
  .tl-event { grid-template-columns: 44px 64px 1fr; gap: 8px; font-size: 12px; }
  .tl-event .type { font-size: 8.5px; padding: 2px 5px; }
  .tl-events { height: 260px; }
  .tl-controls { flex-wrap: wrap; }
  /* Bigger drag handle for fingers */
  .tl-handle { width: 28px; height: 28px; top: 16px; }
}

/* ══════════════════════════════════════════════════════════════════
   DATA-FLOW DAG · already scales via viewBox, just tighten padding
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 880px) {
  .dfdag-header { flex-direction: column; align-items: start; gap: 10px; padding: 14px 16px; }
  .dfdag-stats { gap: 12px; }
  .dfdag-stat .v { font-size: 18px; }
}

/* ══════════════════════════════════════════════════════════════════
   MARQUEE
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 880px) {
  .mq-section { padding: 40px 0; }
  .mq-track { gap: 40px; animation-duration: 28s; }
  .mq-track.reverse { animation-duration: 34s; }
  .mq-logo { font-size: 18px; }
  .mq-logo .glyph { width: 24px; height: 24px; font-size: 12px; }
}

/* ══════════════════════════════════════════════════════════════════
   STABILITY STRIP / DARK CONSTRAINTS BANNER
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 880px) {
  .cons { padding: 40px 24px; border-radius: var(--r-3); }
  .cons h2 { font-size: clamp(24px, 7vw, 32px) !important; }
  .cons-grid { grid-template-columns: 1fr !important; }
  .cons-row { padding: 12px 16px; font-size: 12px; }
}

/* ══════════════════════════════════════════════════════════════════
   END CTA
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 880px) {
  .end-cta { padding: 64px 0 80px; }
  .end-cta h2 { font-size: clamp(28px, 8vw, 38px) !important; }
  .end-cta-actions { flex-direction: column; gap: 10px; }
  .end-cta-actions .btn { width: 100%; }
}

/* ══════════════════════════════════════════════════════════════════
   FOOTER
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 880px) {
  .foot { grid-template-columns: 1fr 1fr; gap: 28px; }
  .foot-brand { grid-column: 1 / -1; max-width: 100%; }
  .foot-meta { flex-direction: column; gap: 8px; align-items: start; }
}

@media (max-width: 480px) {
  .foot { grid-template-columns: 1fr; gap: 24px; }
}

/* ══════════════════════════════════════════════════════════════════
   DEMO SECTION HEADINGS
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 880px) {
  .demo-section { padding: 56px 0; }
  .demo-head { grid-template-columns: 1fr !important; gap: 14px; margin-bottom: 28px; }
  .demo-head .lede { margin-top: 12px; }
  .demo-instructions { font-size: 10px; }
}

/* ══════════════════════════════════════════════════════════════════
   SSN PRODUCT TOUR — tighten on small phones
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 560px) {
  .ssn-frame { height: 440px !important; }
  .ssn-block h3 { font-size: clamp(20px, 6vw, 26px) !important; }
  .ssn-block p { font-size: 14px !important; }
}

/* ══════════════════════════════════════════════════════════════════
   404 / 500 pages
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 880px) {
  .err-wrap { grid-template-columns: 1fr !important; gap: 36px !important; padding: 48px 20px !important; }
  .err-title { font-size: clamp(32px, 9vw, 48px) !important; }
  .err-lede { font-size: 15px; }
}

/* ══════════════════════════════════════════════════════════════════
   TOAST — keep within viewport on small screens
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 560px) {
  .sf-toast {
    left: 16px; right: 16px;
    transform: translate(0, 32px);
    width: auto;
  }
  .sf-toast.is-visible { transform: translate(0, 0); }
}

/* ══════════════════════════════════════════════════════════════════
   ACCESSIBILITY · respect reduced motion
   ══════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .mq-track { animation: none !important; }
}
