/* ═══════════════════════════════════════════════════
   Shared mobile layout — loaded after the theme file.
   Uses theme CSS variables; type scale stays in the theme.
   ═══════════════════════════════════════════════════ */

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  max-width: 100%;
}

body {
  min-height: 100dvh;
  max-width: 100%;
}

.nav-toggle { display: none; }

img { max-width: 100%; }

/* iOS: prevent auto-zoom on focus (font-size must be ≥16px) */
@media (max-width: 768px) {
  input,
  .site-search-input {
    font-size: 16px;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 3px;
  }

  input[type="search"]::-webkit-search-decoration { display: none; }
}

/* ── Header / nav ── */
@media (max-width: 768px) {
  html, body {
    width: 100%;
    max-width: 100%;
  }

  .affiliate-disclosure {
    padding: 0.45rem max(0.9rem, env(safe-area-inset-right)) 0.45rem max(0.9rem, env(safe-area-inset-left));
    padding-top: max(0.45rem, env(safe-area-inset-top));
    font-size: 0.65rem;
    letter-spacing: 0.02em;
    line-height: 1.4;
    white-space: normal;
  }

  header {
    position: sticky;
    top: 0;
    z-index: 400;
    background: var(--bg-surface);
    padding: 0.75rem max(1rem, env(safe-area-inset-right)) 0.85rem max(1rem, env(safe-area-inset-left));
    max-width: 100%;
  }

  .header-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand toggle"
      "search search"
      "nav nav";
    align-items: center;
    gap: 0.7rem 0.6rem;
    min-width: 0;
    max-width: 100%;
  }

  header a.wordmark {
    grid-area: brand;
    min-width: 0;
    max-width: 100%;
  }

  header h1 {
    line-height: 1.4;
    white-space: normal;
    overflow-wrap: break-word;
  }

  .nav-toggle {
    grid-area: toggle;
    display: inline-flex;
    position: relative;
    width: auto;
    min-width: 44px;
    height: 44px;
    padding: 0 0.75rem;
    margin: 0;
    align-self: center;
    justify-self: end;
    justify-content: center;
    align-items: center;
    font-family: 'Oswald', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    background: rgba(0, 201, 177, 0.1);
    border: 1px solid var(--teal-dim);
    color: var(--teal-bright);
    cursor: pointer;
    overflow: visible;
    box-shadow: none;
    flex-shrink: 0;
    white-space: nowrap;
    touch-action: manipulation;
  }

  .nav-toggle::before { display: none; }

  .site-search {
    grid-area: search;
    max-width: none;
    min-width: 0;
    width: 100%;
  }

  .site-search-input {
    padding: 0.7rem 0.9rem;
  }

  .site-search-dropdown {
    max-height: min(380px, 55dvh);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.65);
  }

  .ss-result { padding: 0.75rem 0.9rem; }

  header nav {
    grid-area: nav;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: 100%;
    border-top: 1px solid var(--border-teal);
    padding-top: 0.35rem;
  }

  header.nav-open nav { display: flex; }

  .nav-link {
    width: 100%;
    padding: 0.9rem 0.35rem;
    min-height: 44px;
    display: flex;
    align-items: center;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    border-bottom: 1px solid var(--border);
    white-space: normal;
    touch-action: manipulation;
  }

  .nav-link:last-child { border-bottom: none; }

  main {
    padding: 1.25rem max(1rem, env(safe-area-inset-right)) 3rem max(1rem, env(safe-area-inset-left));
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
  }

  footer {
    padding: 1.1rem max(1rem, env(safe-area-inset-right)) max(1.25rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    gap: 0.25rem 0.5rem;
  }

  footer a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0.4rem 0.65rem;
  }
}

/* ── Search panel / chips ── */
@media (max-width: 768px) {
  .checklists,
  .set-chips {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.45rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-bottom: 1.25rem;
    padding-bottom: 0.35rem;
    min-width: 0;
    max-width: 100%;
  }

  .checklists::-webkit-scrollbar,
  .set-chips::-webkit-scrollbar { display: none; }

  .set-chip {
    flex-shrink: 0;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.8rem;
    touch-action: manipulation;
  }

  .search-panel {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
    margin-bottom: 1.15rem;
  }

  .search-group {
    min-width: 0;
    width: 100%;
    flex: none;
  }

  .search-panel > button {
    width: 100%;
    align-self: stretch;
    min-height: 44px;
    touch-action: manipulation;
  }

  .autocomplete-option {
    padding: 0.7rem 0.9rem;
    min-height: 44px;
  }

  .pagination {
    flex-wrap: wrap;
    gap: 0.6rem;
    justify-content: space-between;
  }

  .pagination button,
  .pagination-link {
    min-height: 44px;
    padding: 0.55rem 1rem;
    display: inline-flex;
    align-items: center;
    touch-action: manipulation;
  }
}

/* ── Data tables → stacked cards ── */
@media (max-width: 768px) {
  table {
    display: block;
    width: 100%;
    max-width: 100%;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  tbody { display: block; width: 100%; }

  tbody tr {
    display: block;
    width: 100%;
    max-width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-teal);
    margin-bottom: 0.7rem;
    padding: 0.8rem 0.95rem 0.7rem;
    box-sizing: border-box;
  }

  tbody tr:hover { background: var(--bg-card); }

  td {
    display: grid;
    grid-template-columns: 6.2rem minmax(0, 1fr);
    column-gap: 0.75rem;
    align-items: baseline;
    padding: 0.28rem 0;
    vertical-align: baseline;
    color: var(--text);
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  td::before {
    content: attr(data-label);
    font-family: 'Oswald', sans-serif;
    font-size: 0.62rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
  }

  td:not([data-label])::before,
  td[data-label=""]::before { content: none; }

  td:not([data-label]),
  td[data-label=""] {
    grid-template-columns: minmax(0, 1fr);
  }

  td.blank { display: none; }

  td .tag { margin-top: 0; }

  .ebay-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0.2rem 0;
  }
}

/* ── eBay listings ── */
@media (max-width: 768px) {
  .bin-header,
  .bin-valuation,
  .bin-affiliate,
  .bin-no-results {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .bin-header {
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
  }

  .bin-meta { margin-left: 0; }

  .bin-valuation { gap: 1rem 1.25rem; }

  .bin-section { max-width: 100%; }

  .bin-listing {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto;
    grid-template-areas:
      "img title price"
      "img title shop";
    align-items: center;
    column-gap: 0.75rem;
    row-gap: 0.35rem;
    padding: 0.7rem 1rem;
    max-width: 100%;
    min-width: 0;
  }

  .bin-listing:not(:has(.bin-listing-img)) {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "title price"
      "title shop";
  }

  .bin-listing-img {
    grid-area: img;
    width: 56px;
    min-width: 56px;
    height: 56px;
  }

  .bin-listing-title {
    grid-area: title;
    min-width: 0;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.82rem;
    line-height: 1.35;
  }

  .bin-listing-condition,
  .bin-listing-shipping { display: none; }

  .bin-listing-title {
    flex: none;
  }

  .bin-listing-price {
    grid-area: price;
    justify-self: end;
    align-self: start;
    flex: none;
    font-size: 1rem;
    white-space: nowrap;
  }

  .bin-shop-btn {
    grid-area: shop;
    justify-self: end;
    align-self: end;
    flex: none;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.75rem;
    touch-action: manipulation;
  }

  a.bin-listing-link {
    grid-template-areas:
      "img title price"
      "img title price";
  }
}

/* ── Homepage hero / timeline ── */
@media (max-width: 768px) {
  .hero-section { gap: 1.5rem; }

  .hero { min-height: 0; min-width: 0; max-width: 100%; }

  .hero-slide { min-height: 0; max-width: 100%; }

  .hero-title {
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
  }

  .hero-body,
  .set-summary,
  .subject-summary,
  .page-body,
  .charts-summary {
    overflow-wrap: break-word;
    max-width: 100%;
  }

  .slide-content { padding: 0.5rem 0 0; min-width: 0; }

  .slide-content--over-bg {
    position: relative;
    min-height: 260px;
    padding: 1.35rem 1rem 1.1rem;
  }

  .slide-overlay {
    background: linear-gradient(
      to top,
      rgba(0, 0, 0, 0.92) 0%,
      rgba(0, 0, 0, 0.7) 55%,
      rgba(0, 0, 0, 0.42) 100%
    ) !important;
  }

  .hero-body {
    font-size: 0.95rem;
    margin-bottom: 1.25rem;
    line-height: 1.6;
  }

  .hero-stats {
    gap: 1.1rem 1.5rem;
    margin-bottom: 1.25rem;
  }

  .slide-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    margin-top: 1rem;
  }

  .slide-footer--end { align-self: stretch; }

  .cta-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.7rem 1.15rem;
    white-space: normal;
    text-align: center;
    touch-action: manipulation;
  }

  .hero-dots { margin-top: 1.15rem; }

  .hero-dot {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    box-shadow: none;
    position: relative;
    padding: 0;
    overflow: visible;
  }

  .hero-dot::before { display: none; }

  .hero-dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    border: 2px solid var(--teal-dim);
    border-radius: inherit;
    transform: translate(-50%, -50%);
    background: transparent;
  }

  .hero-dot--active::after {
    background: var(--teal-bright);
    border-color: var(--teal-bright);
  }

  .timeline-section {
    margin-top: 2.25rem;
    gap: 2rem;
  }

  .timeline-heading {
    font-size: 2rem;
    letter-spacing: 0.08em;
    margin-bottom: 1.25rem;
  }

  .tl-row {
    flex-wrap: wrap;
    gap: 0.2rem 0.6rem;
    padding-top: 0.55rem;
    padding-bottom: 0.35rem;
  }

  .tl-connector { display: none; }

  .tl-set-link {
    white-space: normal;
    flex-shrink: 1;
    min-width: 0;
    line-height: 1.3;
  }

  .tl-card-count { white-space: nowrap; }

  .tl-entry { min-height: 0; }
}

@media (max-width: 480px) {
  .slide-footer { flex-direction: column; align-items: stretch; }
  .cta-btn { width: 100%; }
}

/* ── Inspirations ── */
@media (max-width: 768px) {
  .insp-grid {
    grid-template-columns: 1fr 1fr;
  }

  .insp-card {
    padding: 0.8rem 0.75rem;
    min-height: 44px;
    align-items: center;
  }
}

@media (max-width: 360px) {
  .insp-grid { grid-template-columns: 1fr; }
}

/* ── Page-specific blocks defined in templates ── */
@media (max-width: 768px) {
  main .subject-hero {
    flex-direction: column-reverse;
    gap: 1.25rem;
  }

  main .subject-image {
    display: none;
  }

  main .set-tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  main .set-tabs::-webkit-scrollbar { display: none; }

  main .set-tabs .set-tab {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    text-align: center;
    padding: 0.85rem 0.25rem;
    min-height: 44px;
    font-size: 0.65rem;
    letter-spacing: 0.04em;
    touch-action: manipulation;
  }

  main .widgets-grid {
    grid-template-columns: 1fr;
  }

  main .ranking-row {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  main .widget-header {
    flex-wrap: wrap;
    gap: 0.25rem 0.65rem;
  }

  main .page-hero,
  main .set-hero,
  main .card-hero,
  main .character-hero,
  main .charts-header,
  main .legal-header,
  main .post-hero,
  main .blog-index-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
  }

  main .back-link { margin-bottom: 1.25rem; }

  main .blog-post-body { max-width: 100%; }

  main .blog-post-body img {
    height: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-slide { animation: none; }
  .set-chip::after { display: none; }
}
