/* AcctPanda shared responsive layer — phone (~375/390/430) + tablet (~768)
   Load after tokens.css + components.css. Desktop (≥921) unchanged unless noted. */

/* Root containment: stop any child from widening the page (iOS shrink-to-fit → side gap) */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden; /* fallback */
  overflow-x: clip;
  max-width: 100%;
  width: 100%;
}
body {
  overflow-x: hidden; /* fallback */
  overflow-x: clip;
  max-width: 100%;
  width: 100%;
  position: relative;
}
img, video, svg, canvas, iframe { max-width: 100%; height: auto; }

.ap-wrap {
  max-width: 100%;
  box-sizing: border-box;
}

/* Full-bleed chrome — never leave a side gap even if a child overflows */
.ap-header,
#ap-unified-header,
.ap-footer {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  left: 0;
  right: 0;
}

/* ---- Nav drawer overlay ---- */
.ap-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  top: 64px;
  background: rgba(15, 26, 28, 0.45);
  z-index: 49;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
}
body.ap-nav-open { overflow: hidden; }
body.ap-nav-open .ap-nav-overlay { display: block; }

.ap-nav-extras { display: none; }

/* ---- Tablet / phone header ---- */
@media (max-width: 920px) {
  :root { --ap-gutter: 16px; }

  .ap-header-inner {
    height: 56px;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  body.ap-nav-open .ap-nav-overlay { top: 56px; }

  .ap-nav {
    display: none;
  }
  .ap-nav.is-open {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: absolute;
    left: 0;
    right: 0;
    top: 56px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    background: #0f1a1c;
    padding: 10px 14px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 51;
    max-height: calc(100vh - 56px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .ap-nav.is-open > a {
    padding: 12px 12px;
    font-size: 15px;
    width: 100%;
  }
  .ap-menu-btn { display: inline-flex; flex: 0 0 auto; }

  /* Keep lang/currency compact; move member+login into drawer */
  .ap-header-tools {
    gap: 6px;
    flex: 0 1 auto;
    min-width: 0;
    margin-left: auto;
  }
  .ap-header-tools .ap-member,
  .ap-header-tools > .ap-btn.ap-btn-primary {
    display: none !important;
  }
  /* iOS Safari ignores max-width on <select> unless width+min-width are set */
  .ap-header-tools .ap-select {
    width: 68px;
    max-width: 68px;
    min-width: 0 !important;
    flex: 0 1 auto;
    height: 34px;
    font-size: 12px;
    padding-left: 8px;
    padding-right: 22px;
    box-sizing: border-box;
  }

  .ap-nav.is-open .ap-nav-extras {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-top: 6px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
  .ap-nav-extras .ap-member { width: 100%; }
  .ap-nav-extras .ap-member-btn {
    width: 100%;
    justify-content: space-between;
    height: 40px;
  }
  .ap-nav-extras .ap-member-drop {
    position: static;
    margin-top: 6px;
    box-shadow: none;
    min-width: 0;
    width: 100%;
  }
  .ap-nav-extras .ap-btn {
    width: 100%;
    height: 40px;
  }

  .ap-brand {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
  }
  .ap-brand-name {
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .ap-brand-tag { display: none; }
  .ap-brand-mark { width: 32px; height: 32px; flex-shrink: 0; }
  .ap-header-inner { flex-wrap: nowrap; }
  .ap-menu-btn { order: 5; margin-left: 2px; }
  .ap-header-tools { order: 4; }

  .ap-sec { padding: 36px 0 8px; }
  .ap-cs {
    width: 48px;
    height: 48px;
    right: max(14px, env(safe-area-inset-right, 0px));
    bottom: max(14px, env(safe-area-inset-bottom, 0px));
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  :root { --ap-gutter: 14px; }
  .ap-header-tools .ap-select {
    width: 56px;
    max-width: 56px;
    font-size: 11px;
    padding-left: 6px;
    padding-right: 18px;
  }
  .ap-btn { padding: 0 14px; font-size: 14px; }
}

/* ---- Footer compact (phone / small tablet) ---- */
@media (max-width: 768px) {
  .ap-footer {
    padding-top: 28px;
    margin-top: 32px;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }
  .ap-footer-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px 16px;
    padding-bottom: 18px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  .ap-footer-brand-col {
    grid-column: 1 / -1;
    min-width: 0;
  }
  .ap-footer-col { min-width: 0; max-width: 100%; }
  .ap-footer-brand {
    margin-bottom: 8px;
  }
  .ap-footer p {
    font-size: 12px;
    line-height: 1.5;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .ap-footer-social {
    margin-top: 10px;
    gap: 8px;
  }
  .ap-footer-social a {
    width: 30px;
    height: 30px;
  }
  .ap-footer h4 {
    margin: 0 0 8px;
    font-size: 13px;
  }
  .ap-footer ul {
    gap: 4px;
  }
  .ap-footer li,
  .ap-footer li a {
    font-size: 12px;
    line-height: 1.4;
    overflow-wrap: anywhere;
  }
  .ap-footer-switches {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    max-width: none;
    width: 100%;
  }
  .ap-footer-switches .ap-select {
    flex: 1 1 0;
    min-width: 0 !important;
    width: auto;
    max-width: 100%;
    height: 34px;
    font-size: 12px;
    padding-left: 8px;
    padding-right: 22px;
    box-sizing: border-box;
  }
  .ap-footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 0 16px;
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .ap-footer {
    padding-top: 24px;
    margin-top: 28px;
  }
  .ap-footer-grid {
    gap: 12px 12px;
    padding-bottom: 14px;
  }
  .ap-footer-brand-text strong {
    font-size: 16px;
  }
}

/* ---- Generic forms / tables on storefront ---- */
@media (max-width: 768px) {
  .ap-table-wrap,
  .ap-smm-table-wrap,
  .ap-member-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    width: 100%;
  }
}

/* Touch-friendly taps */
@media (pointer: coarse) {
  .ap-nav a,
  .ap-member-drop a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  .ap-footer a {
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    padding: 2px 0;
  }
}

/* Contain wide tables so the page itself does not grow */
.ap-smm-table-wrap,
.ap-table-wrap,
.ap-member-table-wrap {
  max-width: 100%;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
