/* ================================================================
   SR Design System — Page Chrome
   design-system.css  ·  Loaded only by design-system.html
   ================================================================ */

/* ── PREVENT HORIZONTAL SCROLL (not inherited from styles.css) ── */
html {
  overflow-x: hidden;
}
body {
  overflow-x: clip; /* clip prevents horizontal scroll without creating a scroll container — overflow:hidden breaks position:sticky and blocks vertical scroll on iOS */
  max-width: 100vw;
}

/* ── TOPBAR (hidden on desktop) ──────────────────────────────── */
.ds-topbar {
  display: none; /* shown only in mobile media query */
}
.ds-topbar__logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ds-topbar__logo img { height: 28px; width: auto; }
.ds-topbar__name {
  font-size: 13px;
  font-weight: 700;
  color: #0D0D12;
  letter-spacing: -.01em;
}
.ds-topbar__v {
  font-size: 10px;
  background: rgba(89,86,233,.1);
  color: #5956E9;
  padding: 2px 7px;
  border-radius: 100px;
  font-weight: 600;
}
.ds-menu-toggle {
  width: 40px;
  height: 40px;
  background: none;
  border: 1.5px solid #E8ECF2;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #0D0D12;
  font-size: 15px;
  /* Large touch target */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.ds-menu-toggle:active {
  background: rgba(89,86,233,.08);
}

/* ── SIDEBAR OVERLAY ─────────────────────────────────────────── */
/* Always invisible + non-interactive; becomes visible when .open */
.ds-sidebar-overlay {
  display: none;          /* disabled on desktop */
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 998;
  opacity: 0;
  pointer-events: none;   /* can't steal clicks when closed */
  /* NO backdrop-filter — too slow on mobile */
  transition: opacity .25s ease;
}
.ds-sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* ── SIDEBAR SCROLL INNER (desktop: transparent pass-through) ── */
.ds-sidebar__scroll {
  display: block;
  width: 100%;
}

/* ── BRAND MARK in sidebar ───────────────────────────────────── */
.ds-sidebar__brand-img {
  display: block;
  height: 32px;
  width: auto;
  margin-bottom: 8px;
}

/* ── SOURCE BADGE CHIPS ──────────────────────────────────────── */
.ds-src {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 6px;
}
.ds-src--styles { background: rgba(124,58,237,.1); color: #7c3aed; }
.ds-src--style  { background: rgba(37,99,235,.1);  color: #2563eb; }
.ds-src--book   { background: rgba(180,83,9,.1);   color: #b45309; }
.ds-src--boot   { background: rgba(20,184,166,.1); color: #0d9488; }
.ds-src--mean   { background: rgba(234,88,12,.1);  color: #c2410c; }

/* ── LOGO USAGE GRID ─────────────────────────────────────────── */
.ds-logo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.ds-logo-card {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid #E8ECF2;
}
.ds-logo-card__bg {
  padding: 32px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
}
.ds-logo-card__bg--light { background: #fff; }
.ds-logo-card__bg--dark  { background: #0D0D12; }
.ds-logo-card__bg--grad  { background: linear-gradient(135deg,#181530,#0D0D12); }
.ds-logo-card__meta      { padding: 12px 16px; background: #fff; border-top: 1px solid #E8ECF2; }
.ds-logo-card__label     { font-size: 12px; font-weight: 700; color: #0D0D12; margin-bottom: 3px; }
.ds-logo-card__usage     { font-size: 11px; color: #9CA3AF; line-height: 1.5; }

/* ── CLEAR SPACE DEMO ────────────────────────────────────────── */
.ds-clearspace {
  display: inline-block;
  padding: 20px;
  border: 2px dashed rgba(89,86,233,.3);
  border-radius: 12px;
  background: rgba(89,86,233,.04);
  position: relative;
}
.ds-clearspace::before {
  content: '← clear space →';
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: rgba(89,86,233,.5);
  white-space: nowrap;
}

/* ── TABLET (1024px) ─────────────────────────────────────────── */
@media (max-width: 1024px) {
  .ds-main {
    padding: 40px 40px 80px !important;
  }
}

/* ── MOBILE (≤768px) ─────────────────────────────────────────── */
@media (max-width: 768px) {

  /* 1. Body: plain block — remove flex so fixed topbar + scroll work cleanly */
  body {
    display: block !important;
    overflow-x: hidden !important;        /* clip horizontal without blocking vertical */
    overflow-y: scroll !important;        /* force vertical scroll on (needed on iOS Safari) */
    -webkit-overflow-scrolling: touch !important;
  }

  /* 2. Topbar: FIXED bar at top — stays put while page scrolls */
  .ds-topbar {
    display: flex !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    height: 56px !important;
    z-index: 1002 !important;    /* above overlay (1000) and mobile nav (1001) */
    background: #fff !important;
    border-bottom: 1px solid #E8ECF2 !important;
    padding: 0 16px !important;
    align-items: center !important;
    justify-content: space-between !important;
    box-shadow: 0 1px 8px rgba(0,0,0,.06) !important;
  }

  /* 3. Main: push down below fixed topbar, full width */
  .ds-main {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    padding: 76px 18px 80px !important; /* 56px topbar + 20px gap */
    position: relative !important;
    z-index: 0 !important; /* creates a stacking context so no child can float above the overlay (z-index 998) or sidebar (z-index 999) */
  }

  /* 4. Sidebar: fixed slide-in panel — outer handles position+animation only */
  .ds-sidebar {
    display: flex !important;
    flex-direction: column !important;
    position: fixed !important;
    top: 56px !important;
    left: 0 !important;
    bottom: 0 !important;
    height: auto !important;
    width: 72vw !important;
    max-width: 290px !important;
    z-index: 999 !important;
    overflow: hidden !important;  /* outer must NOT scroll — transform + overflow on same element breaks iOS */
    will-change: transform;
    transform: translateX(-100%) !important;
    transition: transform .28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: none !important;
  }
  .ds-sidebar.open {
    transform: translateX(0) !important;
    box-shadow: 4px 0 32px rgba(0,0,0,.25) !important;
  }

  /* Inner wrapper: handles ALL scrolling — no transform here */
  .ds-sidebar__scroll {
    flex: 1 !important;
    overflow-y: scroll !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: contain !important;
    touch-action: pan-y !important;
    height: 100% !important;
  }

  /* 5. Overlay: enable on mobile */
  .ds-sidebar-overlay {
    display: block;
    z-index: 998;
  }

  /* 6. Nav groups: strict single column inside sidebar */
  .ds-nav-group {
    display: block !important;
    width: 100% !important;
    float: none !important;
    clear: both !important;
  }
  .ds-nav-group__label {
    display: block !important;
    width: 100% !important;
  }
  .ds-nav-link {
    display: flex !important;
    width: 100% !important;
    box-sizing: border-box !important;
    -webkit-tap-highlight-color: transparent;
  }

  /* 7. Typography */
  .ds-section-title { font-size: 18px !important; }
  h1[style*="font-size:40px"] { font-size: 26px !important; }

  /* 8. Inline grid adaptations */
  [style*="grid-template-columns: repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  [style*="grid-template-columns: auto 1fr"],
  [style*="grid-template-columns:auto 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

/* ── MOBILE NAV (completely separate from desktop .ds-sidebar) ── */
.ds-mobile-nav { display: none; }          /* hidden on desktop */

@media (max-width: 768px) {
  /* Suppress desktop sidebar entirely */
  .ds-sidebar { display: none !important; }

  /* Raise overlay above main content */
  .ds-sidebar-overlay { z-index: 1000 !important; }

  /* Slide-in panel */
  .ds-mobile-nav {
    display: block;
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: 75vw;
    max-width: 290px;
    background: #fff;
    border-right: 1px solid #E8ECF2;
    z-index: 1001;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    transform: translateX(-110%);
    transition: transform 0.27s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 16px 0 48px;
    will-change: transform;
  }
  .ds-mobile-nav.open {
    transform: translateX(0);
    box-shadow: 6px 0 28px rgba(0,0,0,.18);
  }

  /* Header inside panel */
  .ds-mn-header {
    padding: 4px 20px 16px;
    border-bottom: 1px solid #E8ECF2;
    margin-bottom: 8px;
  }
  .ds-mn-header img { height: 26px; width: auto; display: block; margin-bottom: 6px; }
  .ds-mn-header span { font-size: 10px; color: #9CA3AF; }

  /* Group label */
  .ds-mn-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #9CA3AF;
    padding: 10px 20px 4px;
  }

  /* Nav link */
  .ds-mn-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 20px;
    font-size: 13px;
    font-weight: 500;
    color: #6B7280;
    text-decoration: none;
    border-left: 2px solid transparent;
    -webkit-tap-highlight-color: transparent;
  }
  .ds-mn-link:active,
  .ds-mn-link.active {
    color: #5956E9;
    border-left-color: #5956E9;
    background: rgba(89,86,233,.05);
  }
  .ds-mn-link i { width: 15px; font-size: 12px; flex-shrink: 0; }
}

/* ── SMALL PHONES (≤480px) ───────────────────────────────────── */
@media (max-width: 480px) {
  .ds-main {
    padding: 72px 14px 60px !important;
  }
  .ds-section { margin-bottom: 52px !important; }
  .ds-sidebar {
    width: 78vw !important;
    max-width: 300px !important;
  }
}

/* ── PRINT ───────────────────────────────────────────────────── */
@media print {
  .ds-sidebar, .ds-topbar { display: none !important; }
  .ds-main { padding: 20px !important; max-width: 100% !important; }
}
