/* Mobile parity — layout + unified header offset */

:root {
  --site-chrome-h: 132px;
  --layout-below-header-gap: 8px;
}

@media (max-width: 768px) {
  :root {
    --site-chrome-h: 158px;
  }
}

body.site-theme .layout {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  max-width: 1320px;
  margin-left: auto;
  margin-right: auto;
}

body.site-theme:has(.header.header--unified) .layout {
  padding-top: calc(var(--site-chrome-h) + var(--layout-below-header-gap));
  margin-top: 0;
}

body.site-theme:has(.directory-quick-ref) .layout.layout--below-quick-ref {
  padding-top: var(--layout-below-header-gap);
  margin-top: 0;
}

body.site-theme .directory-quick-ref {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  max-width: none;
  margin: 0;
  margin-top: var(--site-chrome-h);
  padding: 6px 10px 8px;
  border: none;
  border-bottom: none;
  background: linear-gradient(180deg, rgba(8, 12, 22, 0.96), rgba(6, 9, 18, 0.98));
  box-sizing: border-box;
}

body.site-theme .directory-quick-ref .sidebar__card {
  min-width: 0;
  margin-bottom: 0;
  padding: 5px 7px 6px;
  border: none;
  border-radius: 6px;
  background: rgba(8, 12, 22, 0.65);
}

body.site-theme .directory-quick-ref .sidebar__label {
  font-size: 9px;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

body.site-theme .directory-quick-ref .stats-list li {
  padding: 1px 0;
  font-size: 10px;
  line-height: 1.25;
}

body.site-theme .directory-quick-ref .sidebar__nav--pages {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 4px;
}

body.site-theme .directory-quick-ref .sidebar__nav--pages a {
  padding: 2px 4px;
  font-size: 9px;
  line-height: 1.25;
  min-height: 0;
}

body.site-theme .directory-quick-ref .stats-list:not(.stats-list--compact) {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px 6px;
}

body.site-theme .directory-quick-ref .sidebar__hint {
  font-size: 9px;
  line-height: 1.3;
  margin-top: 4px;
}

body.site-theme .sidebar.sidebar--secondary {
  width: var(--sidebar-w);
}

body.site-theme .main.main--inner > .breadcrumb {
  margin-bottom: 6px;
}

body.site-theme .main.main--inner > .hero.panel:first-of-type,
body.site-theme .main.main--inner > .section.panel:first-of-type {
  margin-top: 4px;
}

body.site-theme .sidebar {
  position: relative !important;
  top: auto !important;
  max-height: none !important;
  overflow: visible !important;
  align-self: flex-start;
  flex-shrink: 0;
}

body.site-theme .main {
  flex: 1;
  min-width: 0;
  position: relative;
}

html:has(body.site-theme) {
  scroll-padding-top: calc(var(--site-chrome-h) + 12px);
}

@media (max-width: 960px) {
  body.site-theme .directory-quick-ref {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.site-theme .layout {
    flex-direction: column;
  }

  body.site-theme .sidebar {
    display: block;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 14px 16px;
  }

  body.site-theme .main {
    padding-top: 0;
    width: 100%;
  }

  body.site-theme .stats-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 12px;
  }

  body.site-theme .sidebar__nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  body.site-theme .sidebar__nav li {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }

  body.site-theme .sidebar__nav a {
    display: block;
    padding: 10px 12px;
    min-height: 44px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid var(--border);
  }

  body.site-theme .sidebar__nav--pages a.is-active,
  body.site-theme .sidebar__nav--pages a[aria-current="page"] {
    border-color: rgba(100, 160, 230, 0.45);
    background: linear-gradient(105deg, rgba(20, 36, 62, 0.95), rgba(10, 18, 32, 0.88));
  }

  body.site-theme .sidebar__nav--pages a {
    min-height: 44px;
  }
}

@media (max-width: 768px) {
  body.site-theme:has(.header--unified) .nav {
    top: var(--site-chrome-h);
  }

  body.site-theme .header__status {
    display: inline-flex;
    font-size: 9px;
    padding: 3px 8px;
    margin-left: auto;
    order: 2;
  }

  body.site-theme .burger {
    order: 3;
  }

  body.site-theme .topbar__clock {
    display: inline-flex !important;
    flex-shrink: 0;
    font-size: 10px;
  }

  body.site-theme .topbar__right {
    display: inline;
    flex-shrink: 0;
    font-size: 9px;
    max-width: 42%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.site-theme .panel__badge {
    display: inline-flex;
  }

  body.site-theme .brand__sub {
    display: block;
  }

  body.site-theme .cards-grid--3 {
    grid-template-columns: 1fr;
  }

  body.site-theme .age-gate-overlay {
    padding-top: calc(var(--site-chrome-h, 158px) + 20px);
    padding-left: 10px;
    padding-right: 10px;
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
  }

  body.site-theme .age-gate-overlay__panel {
    width: 100%;
  }

  body.site-theme .age-gate-overlay__actions {
    flex-direction: column;
  }

  body.site-theme .age-gate-overlay__actions .btn {
    width: 100%;
    min-height: 44px;
  }

  body.site-theme .hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }

  body.site-theme .hero__actions .btn {
    flex: 1 1 calc(50% - 5px);
    min-width: 140px;
    min-height: 44px;
  }

  body.site-theme .age-gate-teaser__actions {
    flex-direction: column;
  }

  body.site-theme .age-gate-teaser__actions .btn {
    width: 100%;
    min-height: 44px;
  }
}

@media (max-width: 768px) {
  body.site-theme .page-toc__chip {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 10px 14px;
  }

  body.site-theme .mirror-verifier__row {
    flex-direction: column;
  }

  body.site-theme .mirror-verifier__row .btn {
    width: 100%;
    min-height: 44px;
  }

  body.site-theme .links-mirror-teaser .age-gate-teaser__actions {
    flex-direction: column;
  }

  body.site-theme .links-mirror-teaser .age-gate-teaser__actions .btn {
    width: 100%;
    min-height: 44px;
  }

  body.site-theme .links-mirror-teaser .age-gate-teaser__bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  body.site-theme .mirror-table__row .btn-copy {
    width: 100%;
    min-height: 44px;
    justify-content: center;
    margin-top: 8px;
  }

  body.site-theme .mirror-table__url {
    word-break: break-all;
    font-size: 11px;
    line-height: 1.45;
  }

  body.site-theme .spec-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.site-theme .spec-table {
    min-width: 480px;
  }

  body.site-theme .home-journey__step {
    grid-template-columns: 1fr;
  }

  body.site-theme .home-journey__num {
    justify-self: start;
  }

  body.site-theme .age-gate-overlay__check {
    align-items: flex-start;
    gap: 12px;
    padding: 12px 10px;
    min-height: 44px;
  }

  body.site-theme .age-gate-overlay__check input {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    flex-shrink: 0;
  }

  /* Pages sidebar nav — touch targets without horizontal slide */
  body.site-theme .sidebar__nav--pages a {
    min-height: 44px;
    display: flex;
    align-items: center;
    transform: none !important;
  }

  body.site-theme .sidebar__nav--pages a:hover,
  body.site-theme .sidebar__nav--pages a:focus-visible,
  body.site-theme .sidebar__nav--pages a.is-active,
  body.site-theme .sidebar__nav--pages a[aria-current="page"] {
    transform: none !important;
  }
}

@media (max-width: 520px) {
  body.site-theme .directory-quick-ref {
    grid-template-columns: minmax(0, 1fr);
  }

  body.site-theme .sidebar__nav li {
    flex: 1 1 100%;
  }

  body.site-theme .hero__actions .btn {
    flex: 1 1 100%;
  }

  body.site-theme .topbar__rates {
    flex: 1 1 100%;
    justify-content: stretch;
  }

  body.site-theme .rate-pill {
    max-width: none;
  }

  /* style.css hides .topbar__item at 520 — keep NY clock for parity */
  body.site-theme .topbar__item.topbar__clock {
    display: inline-flex !important;
    flex-shrink: 0;
    font-size: 9px;
  }

  body.site-theme .topbar__right {
    display: inline !important;
    flex-shrink: 1;
    max-width: 42%;
  }

  body.site-theme .panel__badge {
    display: inline-flex !important;
  }

  body.site-theme .cards-grid--2,
  body.site-theme .cards-grid--3 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 390px) {
  body.site-theme .topbar__row--live {
    flex-wrap: wrap;
    gap: 6px;
  }

  body.site-theme .topbar__right {
    flex: 1 1 100%;
    max-width: none;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 320px) {
  body.site-theme .layout {
    padding-left: 0;
    padding-right: 0;
  }

  body.site-theme .main,
  body.site-theme .sidebar {
    padding-left: 10px;
    padding-right: 10px;
  }

  body.site-theme .page-toc__chip {
    font-size: 10px;
    padding: 8px 12px;
  }

  body.site-theme .hero h1 {
    font-size: 1.25rem;
  }
}
