/* ═══════════════════════════════════════════════════════════
   Site-wide mobile & tablet UX pass
   Load AFTER page CSS. Does not replace desktop styles.
   ═══════════════════════════════════════════════════════════ */

/* Touch-friendly baseline */
@media (hover: none) and (pointer: coarse) {
  .btn,
  .filter-btn,
  .nav-links a,
  .social-link,
  .card-tile,
  .deck-panel-head,
  .howto-panel-head {
    min-height: 44px;
  }

  .card-tile:hover,
  .feature-card:hover,
  .class-card:hover,
  .deck-panel:hover {
    transform: none;
  }

  .card-tile:active .card-face {
    border-color: rgba(240, 180, 50, 0.55);
  }
}

/* ── Tablets (portrait) ── */
@media (max-width: 900px) {
  .container {
    width: min(100% - 1.5rem, var(--max));
  }

  .page-main {
    padding-block: 1.35rem 1.25rem;
  }

  .section-head {
    margin-bottom: 1.15rem;
  }

  .section-head h2,
  .section-head .h2 {
    font-size: clamp(1.45rem, 4vw, 1.9rem);
  }
}

/* ── Phones ── */
@media (max-width: 720px) {
  :root {
    --nav-h: 64px;
    --logo-h: 48px;
    --gutter: 0.85rem;
  }

  html {
    -webkit-text-size-adjust: 100%;
  }

  body {
    font-size: 15px;
    line-height: 1.55;
    overflow-x: hidden;
  }

  .container {
    width: min(100% - 1.5rem, var(--max));
  }

  /* Sticky header: denser */
  .site-header {
    backdrop-filter: blur(12px) saturate(1.1);
  }

  .nav {
    min-height: var(--nav-h);
    padding-block: 0.35rem;
    gap: 0.5rem;
  }

  .nav-logo {
    height: var(--logo-h);
    max-width: min(160px, 48vw);
  }

  .nav-toggle {
    width: 44px;
    height: 44px;
    border-radius: 12px;
  }

  .nav-links {
    max-height: min(70dvh, 420px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: max(0.85rem, env(safe-area-inset-bottom));
  }

  .nav-links a {
    font-size: 0.92rem;
    min-height: 46px;
  }

  .nav-links a.nav-purchase,
  .nav-links a[href*="shop.doginaldogs.com"] {
    margin-top: 0;
    min-height: 46px;
  }

  .page-main {
    padding-block: 1.15rem 1.5rem;
  }

  .lead {
    font-size: var(--text-prose);
    line-height: var(--text-prose-lh);
    max-width: none;
  }

  .eyebrow {
    font-size: 0.68rem;
    letter-spacing: 0.14em;
  }

  /* Buttons stack cleanly when .hero-actions is used */
  .hero-actions {
    gap: 0.65rem;
  }

  .btn {
    width: 100%;
    justify-content: center;
    min-height: 48px;
    font-size: 0.95rem;
    padding: 0.85rem 1.15rem;
  }

  /* Hero preorder is a compact pill — override full-width .btn rule */
  .btn-preorder,
  .btn.btn-preorder,
  .hero-bleed-actions .btn {
    width: auto;
    max-width: max-content;
    min-height: 36px;
    padding: 0.45rem 1.15rem;
    font-size: 0.72rem;
  }

  .hero-actions .btn:not(.btn-preorder) {
    width: 100%;
  }

  /* Footer */
  .site-footer {
    margin-top: 2.75rem;
    padding: 1.5rem 0 max(1.75rem, env(safe-area-inset-bottom));
  }

  .footer-brand img {
    height: 40px;
  }

  .footer-copy {
    font-size: 0.75rem;
    line-height: 1.45;
    padding-inline: 0.5rem;
  }

  .social-link {
    min-height: 44px;
    width: 100%;
    max-width: 280px;
    justify-content: center;
  }

  /* Panels */
  .panel {
    padding: 1.1rem 1rem;
    border-radius: 14px;
  }
}

/* ── Small phones ── */
@media (max-width: 400px) {
  :root {
    --nav-h: 58px;
    --logo-h: 42px;
  }

  body {
    font-size: 14.5px;
  }

  .container {
    width: min(100% - 1.15rem, var(--max));
  }

  .nav-logo {
    max-width: min(140px, 52vw);
  }
}

/* ════════════ Homepage (prototype sections) ════════════ */
@media (max-width: 600px) {
  .home-showcase {
    padding-top: 1.1rem;
  }

  .hero-actions {
    margin-top: 0.85rem;
    flex-direction: column;
    align-items: stretch;
  }

  /* Spacing owned by home.css --section-pad-y — do not double with margin-top */
  .home-section {
    margin-top: 0;
  }

  .community-carousel {
    gap: 0.15rem;
  }

  .community-nav {
    width: 40px;
    height: 40px;
  }

  /* legacy class cards if present on other pages */
  .feature-grid,
  .class-grid {
    gap: 0.75rem;
  }

  .feature-card,
  .class-card {
    padding: 1.1rem 1.05rem;
  }

  .feature-card .icon {
    width: 36px;
    height: 36px;
    margin-bottom: 0.75rem;
  }

  .set-panel {
    gap: 1.1rem;
  }

  .set-panel .panel-copy h2 {
    font-size: clamp(1.55rem, 7vw, 2rem);
  }

  .faction-pills,
  .class-pills {
    gap: 0.4rem;
  }

  .faction-pill,
  .class-pill {
    padding: 0.42rem 0.7rem;
    font-size: 0.72rem;
  }

  .cta-band {
    margin-top: 2.25rem;
    padding: 1.5rem 1rem;
    border-radius: 16px;
  }

  .cta-band h2 {
    font-size: clamp(1.45rem, 6.5vw, 1.9rem);
  }

  .cta-band .hero-actions {
    flex-direction: column;
  }
}

/* ════════════ Card Gallery ════════════ */
@media (max-width: 720px) {
  .page-cards .page-main,
  .page-cards main.page-main {
    padding-block: 0.85rem 1.25rem;
  }

  .library-hero {
    margin-bottom: 0.85rem;
    text-align: center;
  }

  .library-hero h1 {
    font-size: clamp(1.55rem, 7vw, 2rem);
    margin: 0.25rem 0 0.3rem;
  }

  .library-hero .lead {
    font-size: var(--text-prose);
    line-height: var(--text-prose-lh);
    margin-inline: auto;
    max-width: 36ch;
  }

  /* Sticky toolbars: stack cleanly under nav */
  .library-toolbar {
    top: calc(var(--nav-h) + env(safe-area-inset-top, 0px));
    padding: 0.65rem 0.7rem;
    gap: 0.55rem;
    border-radius: 12px;
    margin-bottom: 0.55rem;
  }

  .library-toolbar.class-toolbar {
    position: sticky;
    top: calc(var(--nav-h) + env(safe-area-inset-top, 0px));
    z-index: 39;
    margin-bottom: 1rem;
    padding: 0.65rem 0.75rem;
    flex-direction: column;
    align-items: stretch;
  }

  .class-toolbar-left {
    width: 100%;
  }

  .library-meta {
    font-size: 0.78rem;
    width: 100%;
    line-height: 1.4;
    text-align: left;
    white-space: normal;
    margin-left: 0;
  }

  .library-controls {
    width: 100%;
    gap: 0.55rem;
  }

  .library-filters {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .library-filters .filter-btn {
    flex: 1 1 calc(33.33% - 0.35rem);
    min-height: 42px;
    font-size: 0.78rem;
    padding: 0.45rem 0.4rem;
  }

  .class-filters {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0.4rem;
    padding-bottom: 0.15rem;
    margin-inline: -0.15rem;
    padding-inline: 0.15rem;
    scrollbar-width: none;
  }

  .class-filters::-webkit-scrollbar {
    display: none;
  }

  .class-filters .filter-btn {
    flex: 0 0 auto;
    min-width: max-content;
    min-height: 40px;
    font-size: 0.75rem;
    padding: 0.45rem 0.75rem;
  }

  .sort-label {
    width: 100%;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .sort-label select {
    flex: 1;
    min-height: 44px;
    font-size: 0.88rem;
  }

  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem 0.55rem;
  }

  .card-meta {
    min-height: 2.6rem;
    gap: 0.2rem;
  }

  .card-name {
    font-size: 0.78rem;
  }

  .card-sub {
    font-size: 0.65rem;
  }
}

@media (max-width: 380px) {
  .card-grid {
    gap: 0.7rem 0.45rem;
  }

  .card-name {
    font-size: 0.72rem;
  }
}

/* Modal — phones (still centered / frameless like desktop) */
@media (max-width: 480px) {
  .modal-root {
    padding:
      max(0.5rem, env(safe-area-inset-top))
      0.5rem
      max(0.5rem, env(safe-area-inset-bottom))
      0.5rem;
    place-items: center;
  }

  .modal-stage {
    width: min(100%, 320px);
    max-height: min(92dvh, 92vh);
  }

  .modal-art {
    width: min(100%, 280px, calc(min(56dvh, 56vh) * 546 / 743));
  }

  .modal-close {
    top: max(0.5rem, env(safe-area-inset-top));
    right: max(0.5rem, env(safe-area-inset-right));
    width: 44px;
    height: 44px;
  }

  .modal-tier {
    font-size: 0.7rem;
    padding: 0.36rem 0.8rem;
  }
}

/* ════════════ Deck Lists ════════════ */
@media (max-width: 720px) {
  .decks-hero h1 {
    font-size: clamp(1.75rem, 8vw, 2.25rem);
  }

  .decks-hero .lead,
  .howto-hero .lead {
    font-size: var(--text-prose);
    line-height: var(--text-prose-lh);
  }

  .decks-hero .hero-actions {
    flex-direction: column;
    align-items: stretch;
    margin-top: 1.1rem !important;
  }

  .decks-grid {
    gap: 0.75rem;
  }

  .deck-panel-head {
    padding: 1rem 0.9rem;
    grid-template-columns: 1fr auto;
  }

  .deck-panel-head h3 {
    font-size: 1.15rem;
  }

  .deck-blurb {
    font-size: 0.9rem;
  }

  .deck-stat-chips {
    width: 100%;
    gap: 0.35rem 0.65rem;
  }

  .deck-expand-label {
    font-size: 0.65rem;
  }

  .deck-panel-body-inner {
    padding: 0 0.9rem 1.1rem;
  }

  .deck-overview,
  .deck-synergy,
  .deck-win-angle {
    font-size: 0.9rem;
  }

  .deck-stat-row {
    gap: 0.4rem 0.75rem;
    font-size: 0.78rem;
  }

  .deck-card-list {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .deck-card-item {
    padding: 0.4rem;
  }

  .deck-card-thumb {
    width: 48px;
  }

  .deck-card-name {
    font-size: 0.85rem;
  }

  .deck-panel-actions {
    flex-direction: column;
  }

  .deck-panel-actions .btn {
    width: 100%;
  }

  .howto-panel-head-copy h2 {
    font-size: 1.05rem;
  }

  .howto-panel-head-copy p {
    font-size: 0.85rem;
  }

  .howto-bullets li {
    font-size: 0.88rem;
  }

  .class-guide-card.class-all {
    grid-column: auto;
  }

  .class-guide-card {
    padding: 0.9rem 0.95rem;
  }

  .class-guide-card h4 {
    font-size: 0.95rem;
  }

  .class-guide-card p {
    font-size: 0.85rem;
  }
}

/* Landscape phones — marketing pages */
@media (max-width: 900px) and (max-height: 420px) and (orientation: landscape) {
  .nav-logo {
    height: 36px;
    max-width: 120px;
  }

  .hero {
    padding-top: 0.5rem;
  }

  /* Open box + CTA stack — don’t clip the date/preorder */
  .box-stage {
    max-height: none;
  }

  .box-stage picture,
  .box-art {
    max-height: 140px;
  }

  .library-toolbar.class-toolbar {
    top: calc(var(--nav-h) + env(safe-area-inset-top, 0px) + 2.75rem);
  }
}
