/* sift-mobile.css — shared mobile responsive fixes + hamburger
 * Loaded by ALL user-facing pages (both sift-brand.css pages and inline-styled
 * pages). Designed to NOT conflict with desktop layouts; only active below 768px.
 *
 * Strategy:
 *  - Hamburger button + drawer markup is injected by sift-nav.js.
 *  - Mobile rules use !important sparingly only where [data-lang-*] selector
 *    specificity must be overridden.
 *  - At ≤768px the existing .nav-link.hide-sm is force-hidden, hamburger appears,
 *    tapping it shows a drawer below the nav bar.
 */

/* ============ hamburger button (mobile only) ============ */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  background: transparent;
  border: 1px solid rgba(26, 26, 26, 0.16);
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
  margin-left: 6px;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.nav-toggle:hover { background: rgba(26, 26, 26, 0.04); }
.nav-toggle .bar {
  position: relative;
  display: block;
  width: 18px; height: 1.5px;
  background: #1A1A1A;
  border-radius: 1px;
  transition: background 120ms ease;
}
.nav-toggle .bar::before,
.nav-toggle .bar::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 1.5px;
  background: #1A1A1A;
  border-radius: 1px;
  transition: transform 200ms cubic-bezier(0.16,1,0.3,1), top 200ms;
}
.nav-toggle .bar::before { top: -6px; }
.nav-toggle .bar::after  { top:  6px; }
.nav-toggle[aria-expanded="true"] .bar { background: transparent; }
.nav-toggle[aria-expanded="true"] .bar::before { top: 0; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] .bar::after  { top: 0; transform: rotate(-45deg); }

/* ============ drawer panel ============ */
.nav-drawer {
  display: none;
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid rgba(26, 26, 26, 0.08);
  padding: 4px 22px 14px;
  box-shadow: 0 12px 32px rgba(20,20,20,0.10);
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  z-index: 99;
}
.nav-drawer.nav-open { display: flex; }
.nav-drawer .nav-link {
  display: block;
  padding: 14px 4px;
  font-size: 16px;
  color: #1A1A1A;
  border-bottom: 1px solid rgba(26, 26, 26, 0.08);
  min-height: 44px;
  line-height: 1.5;
  text-decoration: none;
}
.nav-drawer .nav-link:last-of-type { border-bottom: none; }
.nav-drawer .nav-link.current { color: #0A0A0A; font-weight: 600; }
/* Drawer lang switching */
.nav-drawer [data-lang-zh], .nav-drawer [data-lang-en] { display: none; }
html[lang="zh-CN"] .nav-drawer [data-lang-zh] { display: block; }
html[lang="en"]    .nav-drawer [data-lang-en] { display: block; }
/* Hide nav-cta if cloned into drawer — drawer is for nav-link only */
.nav-drawer .nav-cta, .nav-drawer .lang-toggle { display: none !important; }

/* ============ global overflow guards (always on) ============ */
/* Prevent horizontal scroll caused by stray content extending past viewport */
html, body { max-width: 100%; overflow-x: hidden; }

/* ============ mobile responsive ≤ 768px ============ */
@media (max-width: 768px) {
  /* Show hamburger */
  .nav-toggle { display: inline-flex; }

  /* ---- overflow root-cause fix: flex/grid children with intrinsic min-content ----
     Default flex/grid children have min-width:auto which equals intrinsic min content.
     Long URLs / pre / mono text break the layout. Force min-width:0 so they can shrink. */
  .dl-tile, .dl-tile > *,
  .platform-row, .platform-left, .platform-info,
  .step, .step-body, .step-num,
  .deploy-inner, .steps,
  .pillar, .feature-card, .contrib-card,
  .footer-col, .footer-inner > * { min-width: 0 !important; }

  /* Tile / step layout — break flex/grid containers to single column */
  .dl-grid, .install-steps { grid-template-columns: 1fr !important; }
  .step { grid-template-columns: 48px 1fr !important; }

  /* Section padding never exceeds viewport gutters */
  section.deploy, section.contribute, section.thanks, section.license,
  section.why, section.hero, section.dl-section {
    padding-left: 22px !important;
    padding-right: 22px !important;
  }

  /* Download .sha hex string breaks anywhere */
  .dl-tile .sha { word-break: break-all !important; overflow-wrap: anywhere !important; }
  /* platform-meta spans don't force nowrap on mobile */
  .dl-tile .platform-meta { flex-wrap: wrap !important; }
  .dl-tile .platform-meta span { white-space: normal !important; }

  /* Pre code blocks scroll horizontally inside without pushing parent wide */
  pre, .step-body pre {
    max-width: 100% !important;
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    white-space: pre;
    font-size: 11.5px !important;
    line-height: 1.55;
    box-sizing: border-box;
  }

  /* Make nav.top a positioning context for drawer */
  nav.top { position: sticky; top: 0; z-index: 100; }
  nav.top .nav-inner { position: relative; padding: 12px 18px !important; gap: 6px; flex-wrap: nowrap; }
  nav.top .nav-links { flex-wrap: nowrap; gap: 4px; }

  /* Force-hide nav-link.hide-sm beating [data-lang-*] specificity */
  nav.top .nav-links > a.nav-link.hide-sm {
    display: none !important;
  }

  /* Touch-friendly CTA and lang toggle */
  nav.top .nav-cta {
    padding: 10px 14px;
    font-size: 13.5px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
  }
  nav.top .lang-toggle { margin-left: 4px; }
  nav.top .lang-toggle button {
    padding: 8px 10px;
    min-height: 36px;
    min-width: 36px;
    font-size: 12px;
  }

  /* Hero typography scaling */
  h1.hero-title, .hero-title {
    font-size: clamp(34px, 9vw, 48px) !important;
    line-height: 1.05 !important;
    letter-spacing: -0.02em !important;
  }
  .hero-sub { font-size: 16px !important; line-height: 1.55 !important; }
  section.hero, .hero {
    padding-left: 22px !important;
    padding-right: 22px !important;
  }

  /* Section titles */
  .section-title, .contribute-title, .why-title {
    font-size: clamp(26px, 6.5vw, 40px) !important;
    line-height: 1.1 !important;
  }

  /* Body legibility */
  body { font-size: 16px; }
  .prose { font-size: 16px; }

  /* code inline word-break */
  pre code, code { word-break: break-word; }

  /* FAQ accordion responsive */
  details.faq-item .answer { padding-right: 0 !important; font-size: 15.5px !important; }

  /* Download tiles */
  .dl-tile { padding: 24px 20px !important; }
  .dl-tile h3 { font-size: 21px !important; }

  /* Tap-friendly footer links */
  footer.site .footer-col a,
  footer.site .footer-bottom a {
    display: inline-block;
    padding: 6px 0;
    min-height: 32px;
    line-height: 1.5;
    font-size: 14.5px;
  }
}

/* ============ ≤ 600px small phone tweaks ============ */
@media (max-width: 600px) {
  nav.top .nav-cta { padding: 9px 12px; font-size: 13px; }
  section.hero, .hero { padding-top: 40px !important; padding-bottom: 28px !important; }
  .hero-cta-row, .hero-actions { flex-direction: column; align-items: stretch; gap: 10px; }
  .hero-cta-row .btn-primary, .hero-cta-row .btn-ghost,
  .hero-actions a { width: 100%; justify-content: center; text-align: center; }
}

/* ============ pricing comparison table → cards on mobile ============ */
@media (max-width: 600px) {
  .cmp-wrap {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    overflow: visible !important;
  }
  table.cmp, table.cmp thead, table.cmp tbody, table.cmp tr, table.cmp th, table.cmp td {
    display: block;
    width: 100%;
  }
  table.cmp { min-width: 0 !important; font-size: 14.5px; border-collapse: collapse; }
  table.cmp thead tr {
    display: grid;
    grid-template-columns: 1fr 1.1fr 1fr;
    gap: 6px;
    padding: 8px;
    background: #FAFAF7;
    border-radius: 12px;
    margin-bottom: 12px;
    position: sticky;
    top: 56px;
    z-index: 2;
  }
  table.cmp thead th {
    padding: 10px 6px !important;
    font-size: 12.5px !important;
    border: none !important;
    text-align: center !important;
    position: static !important;
    border-radius: 8px;
    background: #fff !important;
    line-height: 1.25;
  }
  table.cmp thead th.featured {
    background: rgba(74, 107, 42, 0.10) !important;
    color: #0A0A0A;
  }
  table.cmp tbody tr {
    background: #fff;
    border: 1px solid rgba(26,26,26,0.08);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 12px;
  }
  table.cmp tbody td {
    padding: 8px 0 !important;
    border: none !important;
    border-bottom: 1px dashed rgba(26,26,26,0.08) !important;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    text-align: right;
    line-height: 1.45;
  }
  table.cmp tbody tr td:last-child { border-bottom: none !important; }
  table.cmp tbody td.label {
    white-space: normal !important;
    text-align: left;
    font-size: 11.5px !important;
    color: #1A1A1A;
    flex: 0 0 38%;
  }
  table.cmp tbody td.featured { background: transparent !important; }
  table.cmp tbody td .yes, table.cmp tbody td .no { font-size: 16px; }
}

/* ============ landscape phone tweaks ============ */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  section.hero, .hero { padding-top: 32px !important; padding-bottom: 24px !important; }
  h1.hero-title, .hero-title { font-size: clamp(28px, 5vw, 40px) !important; }
}
