/* ============================================================
   JAVIR — UNIVERSAL RESPONSIVE LAYER
   Precise, adaptable rendering across every device class:
   small phones → phablets → tablets (portrait/landscape)
   → laptops → desktops → ultrawide. Plus notch safe-areas.
   Loaded LAST so it arbitrates final layout.
   ------------------------------------------------------------
   Device map (CSS px):
     ≤ 380   small phones (iPhone SE, mini, older Android)
     381–600 phones (most iPhone/Android portrait)
     601–820 large phones / tablet portrait small
     821–1024 tablet portrait + landscape (iPad)
     1025–1440 laptops
     1441–1800 desktops
     ≥ 1801  ultrawide
============================================================ */

/* ============================================================
   0. GLOBAL SAFETY — no horizontal scroll, fluid media
============================================================ */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { max-width: 100%; overflow-x: clip; }

img, svg, video, canvas, iframe {
  max-width: 100%;
  height: auto;
}
/* The integration connector svg is sized via viewBox/inset — keep it free */
.int-connectors { height: 100% !important; }
/* Decorative SVGs inside character icons keep their box */
.int-side-icon svg, .int-card-logo svg { height: auto; }

/* Prevent long unbroken strings (URLs, handles) from forcing scroll */
.contact-value, .address-bar, .footer-card .small-note { overflow-wrap: anywhere; }

/* ============================================================
   1. SAFE-AREA (notch / rounded corners / home indicator)
============================================================ */
header.navbar-wrap {
  padding-left: max(18px, env(safe-area-inset-left));
  padding-right: max(18px, env(safe-area-inset-right));
  padding-top: env(safe-area-inset-top);
}
.bg-fixed { /* keep ambient bg edge-to-edge under notch */ }

/* Fixed/sticky UI respects the home-indicator + notch.
   Back-to-top stays clear of the LiveChat bubble (bottom-right). */
#backToTop {
  right: max(16px, env(safe-area-inset-right)) !important;
  bottom: calc(84px + env(safe-area-inset-bottom)) !important;
}
@media (min-width: 901px) {
  #backToTop { bottom: calc(24px + env(safe-area-inset-bottom)) !important; }
}
.video-modal-inner {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Container gutters scale with safe-area on the sides */
.container {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ============================================================
   2. ULTRAWIDE  ≥ 1801px — cap & breathe
============================================================ */
@media (min-width: 1801px) {
  :root { --max: 1440px; }
  body { font-size: 17px; }
  .section { padding: 150px 0; }
}

/* ============================================================
   3. DESKTOP  1441–1800 — comfortable default
============================================================ */
@media (min-width: 1441px) and (max-width: 1800px) {
  :root { --max: 1320px; }
}

/* ============================================================
   4. LAPTOP  1025–1440 — slightly tighter
============================================================ */
@media (min-width: 1025px) and (max-width: 1440px) {
  :root { --max: 1180px; }
  .section { padding: 104px 0; }
}

/* ============================================================
   5. TABLET LANDSCAPE + iPad  821–1024
   Two-column rhythm; hero & feature splits keep side-by-side
   but tighten. Nav still full (collapses < 900, see §7).
============================================================ */
@media (min-width: 821px) and (max-width: 1024px) {
  :root { --max: 940px; }
  .section { padding: 88px 0; }

  /* Keep the hero split but rebalance */
  .hero-content { grid-template-columns: 1.05fr .95fr; gap: 40px; }
  .hero-title { font-size: clamp(2.6rem, 6vw, 4.2rem); }
  .chat-burst { height: 500px; }

  /* Meet Javira: keep split, tighten gap */
  .javira-layout { grid-template-columns: 1fr 1fr; gap: 36px; }
  .javira-traits { grid-template-columns: 1fr 1fr; }

  /* Training brand split stays 2-up */
  .feature-layout { grid-template-columns: 1.05fr .95fr; gap: 22px; }

  /* Grids: 3-up → keep but tighten gaps */
  .value-grid, .usecase-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .workflow-visual { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .int-cards-4 { grid-template-columns: repeat(4, 1fr); }
  .int-cards-3 { grid-template-columns: repeat(3, 1fr); }
  .int-row-mid { grid-template-columns: 1fr auto 1fr; }

  /* Pro/cons stays 2-up */
  .procons-grid { grid-template-columns: 1fr 1fr; }

  .stats-strip { grid-template-columns: repeat(4, 1fr); }
}

/* ============================================================
   6. TABLET PORTRAIT  701–820
   Most multi-col → 2-up; hero & big splits stack centered.
============================================================ */
@media (min-width: 701px) and (max-width: 820px) {
  :root { --max: 720px; }
  .section { padding: 80px 0; }

  /* Stack the big hero / feature splits, center the intro */
  .hero-content { grid-template-columns: 1fr; gap: 36px; }
  .hero-text { text-align: center; max-width: 640px; margin: 0 auto; }
  .hero-text .eyebrow, .hero-lead { margin-left: auto; margin-right: auto; }
  .hero-actions, .hero-pills { justify-content: center; }
  .hero-text > .reveal[style*="margin-top: 18px"] { justify-content: center !important; }
  .chat-burst { height: 460px; margin: 0 auto; max-width: 520px; }

  .javira-layout { grid-template-columns: 1fr; gap: 32px; }
  .javira-intro { text-align: center; max-width: 640px; margin: 0 auto; }
  .javira-intro .eyebrow { margin-left: auto; margin-right: auto; }
  .javira-traits { grid-template-columns: 1fr 1fr; text-align: left; }
  .javira-cta-row { justify-content: center; }
  #javira .hero-visual { max-width: 480px; margin: 8px auto 0; }

  .feature-layout { grid-template-columns: 1fr; gap: 22px; }

  /* Grids → 2-up */
  .value-grid, .usecase-grid { grid-template-columns: 1fr 1fr; gap: 16px; }
  .workflow-visual { grid-template-columns: 1fr 1fr; gap: 14px; }
  .workflow-step { min-height: 0; }
  .procons-grid { grid-template-columns: 1fr 1fr; gap: 18px; }
  .int-cards-4 { grid-template-columns: repeat(2, 1fr); }
  .int-cards-3 { grid-template-columns: repeat(3, 1fr); }
  .int-row-mid { grid-template-columns: 1fr; gap: 18px; }
  .int-connectors { display: none; }
  .contact-grid { grid-template-columns: 1fr 1fr; }

  .stats-strip { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .stats-item { border-right: 1px solid rgba(117,239,255,.1); }

  /* Center section intros that are direct children */
  #training-brand > .container > .eyebrow,
  #training-brand > .container > .section-title,
  #training-brand > .container > .section-subtitle,
  #use-cases > .container > .eyebrow,
  #use-cases > .container > .section-title,
  #use-cases > .container > .section-subtitle { text-align: center; }
  #training-brand > .container > .eyebrow,
  #use-cases > .container > .eyebrow { margin-left: auto; margin-right: auto; }
}

/* ============================================================
   7. UNIFIED NAV COLLAPSE  ≤ 900px
   (was 860 in styles.css). Covers tablet portrait too so the
   nav never wraps awkwardly between 820–900.
============================================================ */
@media (max-width: 900px) {
  .navbar { align-items: center; }
  .mobile-menu { display: inline-flex; align-items: center; justify-content: center; }
  .nav-links {
    width: 100%;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding-top: 10px;
  }
  .nav-links.open { display: flex; }
  /* Keep the navbar CTA visible on tablet (hidden only on phones via mobile.css) */
}
@media (min-width: 601px) and (max-width: 900px) {
  .nav-links.open {
    background: rgba(7,17,31,.5);
    border: 1px solid rgba(117,239,255,.1);
    border-radius: 14px;
    padding: 12px 14px;
    margin-top: 8px;
  }
  .nav-links.open a { padding: 11px 6px; border-bottom: 1px solid rgba(117,239,255,.06); }
  .nav-links.open a:last-child { border-bottom: none; }
  .nav-links.open a::after { display: none; }
}

/* ============================================================
   8. PHABLET  481–600 — refine over mobile.css
============================================================ */
@media (min-width: 481px) and (max-width: 600px) {
  /* Allow 2-up for very compact cards where it still reads well */
  #masalah .value-grid { grid-template-columns: 1fr; }
  .int-cards-4 { grid-template-columns: 1fr 1fr !important; }
  /* Quick comparison can stay 2-up comfortably */
  #hasil .reveal[style*="repeat(4"] { grid-template-columns: 1fr 1fr !important; }
}

/* ============================================================
   9. SMALL PHONES  ≤ 380px — prevent crowding
============================================================ */
@media (max-width: 380px) {
  .container { width: min(calc(100% - 24px), var(--max)); }
  .hero-title { font-size: clamp(1.9rem, 12.5vw, 2.5rem); }
  .section-title { font-size: clamp(1.55rem, 8vw, 2.1rem); }
  .navbar { padding: 9px 10px; }
  .logo-mark { width: 40px; height: 32px; }
  .logo strong { font-size: .8rem; }
  .stats-strip { grid-template-columns: 1fr 1fr; }
  .int-cards-4, .int-cards-3 { grid-template-columns: 1fr !important; }
  #hasil .reveal[style*="repeat(4"] { grid-template-columns: 1fr !important; }
  .eyebrow { font-size: .62rem; letter-spacing: .1em; padding: 7px 11px; }
  .hero-pill { font-size: .74rem; }
  .cb-bubble { font-size: .8rem; padding: 10px 13px; }
  .btn { font-size: .94rem; padding: 14px 16px; }
}

/* ============================================================
   10. SHORT VIEWPORTS (landscape phones) — compress hero
============================================================ */
@media (max-height: 480px) and (orientation: landscape) and (max-width: 940px) {
  .hero { padding: 40px 0 28px; }
  .chat-burst { height: 280px; }
  .navbar { padding-top: 6px; padding-bottom: 6px; }
  .section { padding: 48px 0; }
}

/* ============================================================
   11. HIGH-DPI rendering polish (retina) — crisp hairlines
============================================================ */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .stats-item { border-width: .5px; }
}

/* ============================================================
   12. POINTER-COARSE — guarantee 44px min tap targets
============================================================ */
@media (pointer: coarse) {
  .nav-links a, .faq-question, .btn, .mobile-menu,
  .video-modal-close, #backToTop, .bp-tab {
    min-height: 44px;
  }
  .faq-question { display: flex; align-items: center; }
}

/* ============================================================
   13. PHONE OVERFLOW FIX  ≤ 600px  (hero + chat burst + stats)
   Root cause: single-column grid track used `1fr` (implicit
   min-width:auto), so the non-wrapping eyebrow pill / uppercase
   hero-sub expanded the track past the viewport and the page's
   overflow-x:hidden then CLIPPED the headline, lead, buttons &
   chat bubbles on the right. minmax(0,1fr) + min-width:0 lets
   the column shrink; hard-wrap guards stop any clipping.
============================================================ */
@media (max-width: 600px) {
  /* Let the single hero column actually shrink to the viewport */
  .hero-content { grid-template-columns: minmax(0, 1fr) !important; }
  .hero-text,
  .hero-visual { min-width: 0 !important; max-width: 100% !important; }

  /* Eyebrow pill: allow it to wrap & center, never set the column width */
  .hero .eyebrow {
    white-space: normal;
    max-width: 100%;
    text-align: center;
    line-height: 1.5;
    letter-spacing: .1em !important;
  }

  /* Headline / sub / lead: wrap hard, never clip on the right */
  .hero-title { overflow-wrap: anywhere; word-break: break-word; }
  .hero-title .line { max-width: 100%; }
  .hero-sub {
    white-space: normal;
    overflow-wrap: anywhere;
    max-width: 100%;
    letter-spacing: .14em !important;
  }
  .hero-lead { max-width: 100% !important; }

  /* Status row (USDT / cancel / support): wrap & center cleanly */
  .hero-text > .reveal[style*="margin-top: 18px"] {
    flex-wrap: wrap !important;
    justify-content: center !important;
    row-gap: 8px !important;
  }

  /* ---- Chat burst: fully contained, centered, symmetric ---- */
  .chat-burst {
    width: 100% !important;
    max-width: 340px !important;
    margin: 0 auto !important;
    overflow: visible;
  }
  .cb-stream { padding: 14px 14px !important; gap: 11px; }
  .cb-bubble { max-width: 86% !important; }
  /* keep floating chips inside the frame */
  .cb-chip { max-width: 62%; }
  .cb-chip-1 { left: 2% !important; top: 1% !important; }
  .cb-chip-2 { right: 2% !important; top: 16% !important; }
  .cb-avatar { left: 2% !important; bottom: 2% !important; }

  /* ---- Stats strip: balanced 2×2, no dangling divider ---- */
  .stats-strip { grid-template-columns: 1fr 1fr !important; gap: 10px 8px !important; }
  .stats-item { border-right: none !important; }
}

/* Extra-narrow phones: tighten chat frame & eyebrow further */
@media (max-width: 380px) {
  .chat-burst { max-width: 300px !important; }
  .hero .eyebrow { font-size: .6rem !important; letter-spacing: .08em !important; }
  .cb-bubble { max-width: 90% !important; }
}
