/* Phone and tablet layout refinements, shared by the Temple pages. */
html { scroll-padding-top: 86px; }
body { min-width: 0; }
.site-nav-mobile-toggle { display: none; }

@media (max-width: 760px) {
  html { scroll-padding-top: 80px; }
  .site-nav { position: sticky; top: 0; isolation: isolate; }
  .site-nav-inner {
    position: relative;
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
    min-height: 72px;
    padding: 10px max(17px, env(safe-area-inset-right)) 10px max(17px, env(safe-area-inset-left));
    gap: 10px;
  }
  .site-nav-brand { flex: 1 1 auto; width: auto; min-width: 0; padding: 0; justify-content: space-between; gap: 12px; }
  .site-nav-logo { width: clamp(169px, 52vw, 218px); max-width: calc(100% - 60px); }
  .site-nav-mobile-toggle {
    display: inline-flex;
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    border: 1px solid #bda17e;
    border-radius: 8px;
    background: #f9f3e9;
    color: #4e3926;
    cursor: pointer;
    box-shadow: 0 4px 12px #49371e0c;
  }
  .site-nav-mobile-toggle span { display: block; width: 20px; height: 2px; border-radius: 3px; background: currentColor; transition: transform .2s, opacity .2s; }
  .site-nav.is-menu-open .site-nav-mobile-toggle span:first-child { transform: translateY(7px) rotate(45deg); }
  .site-nav.is-menu-open .site-nav-mobile-toggle span:nth-child(2) { opacity: 0; }
  .site-nav.is-menu-open .site-nav-mobile-toggle span:last-child { transform: translateY(-7px) rotate(-45deg); }
  .site-nav-mobile-toggle:focus-visible { outline: 3px solid #b68c55; outline-offset: 3px; }
  .site-nav.mobile-nav-ready .site-nav-links { display: none; }
  .site-nav.mobile-nav-ready.is-menu-open .site-nav-links {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    max-height: min(75svh, 560px);
    padding: 14px max(16px, env(safe-area-inset-right)) 17px max(16px, env(safe-area-inset-left));
    margin: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f6eee3;
    border-top: 1px solid #dbc6a9;
    border-bottom: 1px solid #bf9d74;
    box-shadow: 0 18px 36px #28170938;
  }
  .site-nav-link {
    justify-content: center;
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 10px 7px;
    font-size: 11px;
    letter-spacing: .075em;
    white-space: normal;
    text-align: center;
    border: 1px solid #dac4aa;
    border-radius: 6px;
    background: #fff9f1;
  }
  .site-nav-link[aria-current] { border-color: #af8655; }
  .site-nav-register { grid-column: 1 / -1; background: #e1c49d; border-color: #a58151; }
  .site-nav .theme-toggle {
    position: static;
    inset: auto;
    justify-self: center;
    width: 46px;
    height: 46px;
    min-width: 46px;
    min-height: 46px;
    margin: 0;
  }
  #main, #survey-main, #book, #leaderboard, #players, #instagram, #house-lineup, #join-a-house { scroll-margin-top: 88px; }

  html[data-theme="dark"] .site-nav-mobile-toggle { background: #302921; color: #f2dfc2; border-color: #896a48; }
  html[data-theme="dark"] .site-nav.is-menu-open .site-nav-links { background: #211c17; border-color: #6f553b; }
  html[data-theme="dark"] .site-nav-link { background: #2d251e; border-color: #594936; }
  html[data-theme="dark"] .site-nav-register { background: #4a3625; }
  html body.survey-page-body .site-nav-mobile-toggle { background: var(--survey-paper); border-color: var(--survey-ink); color: var(--survey-ink); }
  html body.survey-page-body .site-nav.is-menu-open .site-nav-links { background: var(--survey-paper); border-color: var(--survey-ink); }
  html body.survey-page-body .site-nav-link { background: var(--survey-paper); color: var(--survey-ink); border-color: color-mix(in srgb, var(--survey-ink) 38%, transparent); }

  .landing { min-height: calc(100svh - 72px); }
  .landing-stage { min-height: 0; overflow: hidden; padding: 38px 12px 54px; }
  .cinematic-hero-art { flex: 0 1 auto; width: min(690px, 116vw); max-width: none; max-height: min(67svh, 610px); height: auto; }
  .cinematic-enter { min-height: 52px; gap: 12px; padding: 12px 24px; font-size: 11px; letter-spacing: .11em; white-space: normal; text-align: center; }
  .landing-footer { min-height: 22px; }

  .future-survey, .book-section, .player-cards-section, .house-preview { padding-top: 70px; padding-bottom: 78px; }
  .future-survey, .book-section, .player-cards-section, .house-preview, .instagram-section { padding-left: 18px; padding-right: 18px; }
  .book-shell { gap: 27px; }
  .book-cover-frame { max-width: 320px; }
  .book-content h2 { font-size: clamp(32px, 9vw, 44px); }
  .book-description { font-size: 14px; }
  .book-buy { width: min(100%, 330px); justify-content: space-between; }
  .book-price { align-items: center; }

  .leaderboard-section { padding: 70px 14px 75px; }
  .leaderboard-heading-wrap h2 { font-size: clamp(30px, 8vw, 40px); }
  .leaderboard-card { padding: 9px; }
  .leaderboard-card-header { flex-wrap: wrap; gap: 6px; }
  .leaderboard-card-footer { line-height: 1.6; }
  .leaderboard-filter-fields { gap: 9px; }
  .leaderboard-register { width: 100%; }
  .leaderboard-gate { top: 245px; width: calc(100% - 18px); padding: 25px 16px; }
  .leaderboard-gate h3 { font-size: clamp(21px, 6vw, 27px); }
  .leaderboard-gate>p:not(.leaderboard-gate-kicker) { font-size: 12px; line-height: 1.6; }
  .leaderboard-artwork { width: min(310px, 75%); }
  .leaderboard-unlocked .leaderboard-scroll { overflow: visible; }

  .player-cards-grid { scroll-padding-left: 3px; }
  .player-card-tile { flex-basis: min(82vw, 348px); }
  .player-cards-arrow { min-width: 44px; min-height: 44px; }
  .player-cards-scroll-label { font-size: 9px; line-height: 1.6; }
  .player-card-caption { flex-wrap: wrap; }

  .house-preview-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 11px; }
  .house-preview-card { min-height: 219px; padding: 19px 9px; border-radius: 9px; }
  .house-preview-medallion { width: min(31vw, 113px); }
  .house-preview-visit { overflow-wrap: anywhere; }

  .email-popup { width: calc(100vw - 24px); max-height: calc(100dvh - 24px); border-radius: 14px; }
  .dialog-content { padding: 49px 22px 25px; }
  .dialog-content h2 { font-size: clamp(27px, 7vw, 35px); line-height: 1.22; }
  .dialog-content input { min-height: 52px; font-size: 16px; }
  .submit-email { min-height: 54px; font-size: 11px; line-height: 1.4; letter-spacing: .075em; gap: 12px; }
  .dialog-close { top: 8px; right: 8px; width: 46px; height: 46px; }

  /* House rosters should fit without sideways scrolling or clipped names. */
  .houses-intro { width: calc(100% - 34px); padding-top: 52px; padding-bottom: 67px; }
  .house-options { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
  .house-option { min-height: 0; padding: 16px 10px; border-radius: 8px; }
  .house-option-name { font-size: clamp(24px, 6.5vw, 37px); }
  .house-detail-shell { width: calc(100% - 30px); }
  .squad-switch { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px; }
  .squad-tab { min-width: 0; min-height: 46px; padding: 10px 8px; font-size: 10px; }
  .squad-match-facts { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .match-fact { min-width: 0; overflow-wrap: anywhere; }
  .named-formation-row { min-width: 0; }
  .named-player { min-width: 0; }

  /* Survey inputs must remain comfortably tappable without triggering iOS zoom. */
  .survey-page-content { width: calc(100% - 26px); padding-top: 48px; }
  .survey-page-intro h1 { font-size: clamp(31px, 8.2vw, 46px); overflow-wrap: break-word; }
  .survey-question { padding: 22px 16px 24px; }
  .survey-question legend { align-items: flex-start; overflow-wrap: anywhere; }
  .survey-email input[type="email"], .survey-select, .survey-short-answer, .survey-search, .survey-writing textarea { font-size: 16px; }
  .survey-choice { min-height: 48px; }
  .survey-factor-row { flex-wrap: wrap; gap: 5px 12px; }
  .survey-factor-row .survey-stars { justify-content: space-between; width: 100%; }
  .survey-factor-row .survey-stars label { flex: 1 1 0; min-height: 44px; }
  .survey-factor-row .survey-stars .star-glyph { font-size: clamp(24px, 7vw, 32px); }
  .survey-bubble-row { grid-template-columns: repeat(5,minmax(0,1fr)); }
  .survey-bubble span { width: 100%; max-width: 62px; aspect-ratio: 1; height: auto; }
  .survey-rank-list li { gap: 7px; }
  .survey-rank-list strong { min-width: 0; overflow-wrap: anywhere; font-size: 12px; }
  .rank-position { width: 29px; height: 29px; }
  .rank-arrows button { width: 44px; height: 44px; }
  .survey-character-picker summary { padding: 14px; }
  .character-pick { min-height: 44px; }
  .survey-submit { width: min(100%, 350px); min-width: 0; }
}

@media (max-width: 390px) {
  .site-nav-inner { min-height: 66px; }
  .site-nav-logo { width: clamp(155px, 51vw, 195px); }
  .site-nav.is-menu-open .site-nav-links { gap: 6px; padding: 11px 13px 13px; }
  .site-nav-link { font-size: 10px; letter-spacing: .02em; }
  .cinematic-hero-art { width: 124vw; }
  .cinematic-enter { padding-left: 19px; padding-right: 19px; }
  .leaderboard-card-header { font-size: 8px; }
  .leaderboard-gate { top: 260px; }
  .house-preview-card { min-height: 198px; padding: 15px 7px; }
  .house-preview-medallion { width: min(30vw, 99px); }
  .house-preview-card strong { font-size: 25px; }
  .house-preview-visit { font-size: 7px; }
  .squad-match-facts { grid-template-columns: 1fr; gap: 7px; }
  .match-fact { min-height: 0; padding: 11px 13px; }
  .named-formation { padding: 23px 6px; }
  .named-player { padding: 7px 2px; }
  .survey-star-caption { font-size: 8px; letter-spacing: .04em; }
  .survey-plain-options { grid-template-columns: 1fr; }
  .survey-question { padding-left: 13px; padding-right: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .site-nav-mobile-toggle span { transition: none; }
}
