/*
  24901.org Mobile Fixes
  Ready-to-use media queries for mobile responsiveness

  INTEGRATION: Add this link to index.html before </head>:
  <link rel="stylesheet" href="/mobile-fixes.css">

  TESTING DEVICES:
  - Pixel 8 Pro: 412 x 732 CSS pixels (hits 480px breakpoint)
  - iPhone 14: 390 x 844 CSS pixels (hits 480px breakpoint)
  - iPhone SE: 375 x 667 CSS pixels (hits 375px breakpoint)

  BREAKPOINTS: 768px (tablet), 480px (primary mobile), 375px (ultra-narrow)

  NOTE: Globe (Three.js) is NOT modified — it handles its own resize via
  container.clientWidth/Height. The globe fills the hero section on all devices.
*/

/* ═════════════════════════════════════════════════════════════════════════════
   TABLET & MOBILE (max-width: 768px) - Already partially handled
   Enhancing existing breakpoint
   ═════════════════════════════════════════════════════════════════════════════ */

/* Kill the blue tap flash on all touchable elements */
* {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

@media (max-width: 768px) {
  /* Remove scan lines on mobile (visual noise on small screens) */
  .scanlines {
    display: none;
  }

  /* Improve nav on tablets */
  nav {
    padding: 16px 24px;
  }

  .logo {
    font-size: 20px;
  }

  /* Hero buttons: stack vertically */
  .hero-buttons {
    flex-direction: column;
    gap: 12px;
    width: 100%;
  }

  .hero-buttons button {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Reduce excessive top/bottom padding */
  #listen {
    padding: 80px 24px;
  }

  #pink {
    padding: 80px 24px;
  }

  #progress {
    padding: 80px 24px 60px;
  }

  #map {
    padding: 60px 24px 80px;
  }

  #origin {
    padding: 60px 24px;
  }

  #vote {
    padding: 60px 24px;
  }

  #support {
    padding: 80px 24px;
  }

  footer {
    padding: 40px 24px 30px;
  }

  /* Better touch targets for buttons */
  .bp, .bc, .bg {
    padding: 11px 20px;
    font-size: 11px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Platform buttons wrap better */
  .platform-buttons {
    gap: 12px;
  }

  /* Bike specs: single column on tablets */
  .specs-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .spec-item {
    padding-bottom: 8px;
  }

  /* Cards grid: stay responsive */
  .cards-grid {
    gap: 16px;
  }

  /* Improve card game expand box */
  .card-game {
    padding: 12px;
    cursor: pointer;
  }

  .game-label {
    font-size: 11px;
  }

  /* Better form spacing */
  .form-input,
  .form-textarea {
    font-size: 14px;
    padding: 11px 12px;
    min-height: 40px;
  }

  .form-label {
    font-size: 11px;
  }

  /* Improve world map */
  #world-map-picker {
    height: 250px;
  }

  /* Region buttons: better wrapping */
  .region-buttons {
    gap: 8px;
  }

  .rb {
    padding: 8px 14px;
    font-size: 9px;
    min-height: 36px;
  }

  /* Vote buttons */
  .vb {
    padding: 10px 14px;
    font-size: 11px;
    min-height: 40px;
  }

  /* Episode items: better spacing */
  .episode-item {
    gap: 12px;
    padding: 14px 16px;
  }

  /* Tier buttons: stack if needed */
  div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  .tier-buttons {
    gap: 8px;
  }

  .tier-button {
    padding: 9px 14px;
    font-size: 10px;
    flex: 1;
  }

  .bitcoin-address {
    font-size: 11px;
    padding: 10px;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .bitcoin-address p {
    word-break: break-word;
  }
}

/* ═════════════════════════════════════════════════════════════════════════════
   MOBILE (max-width: 480px) - CRITICAL FIXES
   iPhone 14 and similar sized phones
   ═════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
  /* CRITICAL: Navigation - prevent crowding */
  nav {
    padding: 14px 16px;
  }

  .logo {
    font-size: 18px;
    letter-spacing: 3px;
  }

  /* Hero section adjustments */
  .hero-content {
    bottom: 60px;
    left: 16px;
    right: 16px;
  }

  .hero-subtitle {
    font-size: 10px;
    letter-spacing: 3px;
    margin-bottom: 10px;
  }

  .hero-title {
    font-size: clamp(22px, 6vw, 32px);
    line-height: 1.2;
    margin-bottom: 12px;
  }

  .hero-desc {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
    color: #5a6a7a;
  }

  /* CRITICAL: Hero buttons must be full width */
  .hero-buttons {
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }

  .hero-buttons button {
    width: 100%;
    min-height: 44px;
    padding: 12px 16px;
    font-size: 12px;
    letter-spacing: 2px;
  }

  /* CRITICAL: Section padding for narrow screens */
  section {
    padding: 60px 16px !important;
  }

  #listen {
    padding: 60px 16px;
  }

  #pink {
    padding: 60px 16px;
  }

  #progress {
    padding: 60px 16px 50px;
  }

  #map {
    padding: 60px 16px 80px;
  }

  #origin {
    padding: 50px 16px;
  }

  #vote {
    padding: 50px 16px;
  }

  #support {
    padding: 70px 16px;
  }

  footer {
    padding: 40px 16px 24px;
  }

  /* CRITICAL: Cards grid must be single column */
  .cards-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    max-width: none;
  }

  .card {
    padding: 20px 14px;
  }

  .card-header {
    gap: 8px;
  }

  .card-title {
    font-size: 11px;
  }

  .card-miles-value {
    font-size: 32px;
  }

  .card-miles-unit {
    font-size: 11px;
  }

  .card-desc {
    font-size: 13px;
    line-height: 1.5;
  }

  .card-game {
    padding: 10px 12px;
  }

  .game-label {
    font-size: 10px;
  }

  .game-counter {
    font-size: 13px;
  }

  .game-expand-hint {
    font-size: 8px;
  }

  /* Container widths for mobile */
  .container,
  .container-wide {
    max-width: 100%;
    padding: 0;
  }

  /* Typography adjustments */
  .section-header {
    margin-bottom: 40px;
  }

  .section-label {
    font-size: 10px;
    margin-bottom: 12px;
  }

  .section-title {
    font-size: 24px;
    margin-bottom: 12px;
  }

  .section-desc {
    font-size: 14px;
    line-height: 1.6;
    max-width: 100%;
  }

  /* Progress counter - tighter spacing */
  .progress-counter {
    gap: 8px;
    margin-bottom: 6px;
  }

  .counter-value {
    font-size: clamp(36px, 10vw, 56px);
  }

  .counter-total {
    font-size: clamp(36px, 10vw, 56px);
  }

  .counter-divider {
    font-size: 16px;
  }

  .progress-header {
    font-size: 10px;
    margin-bottom: 16px;
  }

  .progress-label {
    font-size: 11px;
    margin-bottom: 16px;
  }

  .progress-bar-container {
    max-width: 100%;
    margin: 0 0 36px 0;
  }

  .progress-percent {
    top: 12px;
    font-size: 11px;
  }

  /* Bike section */
  .bike-grid {
    gap: 24px;
  }

  .bike-image {
    margin-bottom: 0;
  }

  .bike-emoji {
    font-size: 40px;
    margin-bottom: 6px;
  }

  .bike-location {
    font-size: 9px;
  }

  .bike-text h2 {
    font-size: 24px;
    margin-bottom: 12px;
  }

  .bike-label {
    font-size: 10px;
    margin-bottom: 10px;
  }

  .bike-specs-label {
    font-size: 10px;
    margin-bottom: 12px;
  }

  .bike-text p {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 14px;
  }

  .bike-specs {
    padding: 12px 14px;
    margin-top: 16px;
  }

  .specs-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .spec-label {
    font-size: 9px;
  }

  .spec-value {
    font-size: 12px;
    margin-top: 2px;
  }

  /* Map section */
  .map-header {
    margin-bottom: 20px;
  }

  .map-label {
    font-size: 10px;
    margin-bottom: 8px;
  }

  .map-title {
    font-size: 22px;
    margin-bottom: 8px;
  }

  .map-desc {
    font-size: 13px;
    line-height: 1.6;
    max-width: 100%;
  }

  .region-buttons {
    gap: 6px;
    margin-bottom: 12px;
  }

  .rb {
    padding: 7px 12px;
    font-size: 8px;
    min-height: 34px;
  }

  .map-container {
    height: clamp(280px, 50vh, 500px);
    border-radius: 3px;
  }

  /* Origin section */
  .origin-container {
    max-width: 100%;
  }

  .origin-label {
    font-size: 10px;
    margin-bottom: 24px;
  }

  .origin-quote {
    font-size: 20px;
    line-height: 1.4;
    margin-bottom: 24px;
  }

  .origin-text {
    font-size: 13px;
    line-height: 1.7;
    margin-bottom: 16px;
  }

  /* Vote section */
  .vote-container {
    max-width: 100%;
  }

  .vote-label {
    font-size: 10px;
    margin-bottom: 12px;
  }

  .vote-title {
    font-size: 22px;
    margin-bottom: 10px;
  }

  .vote-desc {
    font-size: 13px;
    line-height: 1.7;
    margin-bottom: 28px;
  }

  .continents-grid {
    gap: 20px;
  }

  .continent-block {
    text-align: left;
  }

  .continent-name {
    font-size: 10px;
    margin-bottom: 8px;
  }

  .cities-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .vb {
    padding: 11px 12px;
    font-size: 12px;
    min-height: 42px;
    border-radius: 2px;
  }

  .submit-votes-btn {
    margin-top: 20px;
  }

  /* Support section */
  .support-container {
    max-width: 100%;
  }

  .support-label {
    font-size: 10px;
    margin-bottom: 12px;
  }

  .support-title {
    font-size: 24px;
    margin-bottom: 24px;
  }

  .tier {
    padding: 18px 12px;
    margin-bottom: 14px;
    border-radius: 2px;
  }

  .tier-label {
    font-size: 16px;
    margin-bottom: 8px;
  }

  .tier-text {
    font-size: 13px;
    line-height: 1.6;
  }

  .tier-buttons {
    gap: 8px;
    margin-top: 12px;
  }

  .tier-button {
    padding: 10px 12px;
    font-size: 11px;
    flex: 1;
  }

  /* Fund a Mile buttons: stack vertically */
  div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  .bitcoin-box {
    margin-top: 12px;
    padding: 12px;
  }

  .bitcoin-label {
    font-size: 10px;
    margin-bottom: 6px;
  }

  .bitcoin-text {
    font-size: 12px;
    line-height: 1.4;
  }

  .bitcoin-address {
    margin-top: 8px;
    padding: 10px;
    font-size: 11px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
  }

  .bitcoin-address p {
    word-break: break-word;
  }

  .support-footer {
    font-size: 9px;
    margin-top: 16px;
    line-height: 1.5;
  }

  /* Forms: Critical improvements */
  .form-group {
    gap: 12px;
    margin-top: 12px;
  }

  .form-label {
    font-size: 11px;
    margin-bottom: 4px;
  }

  .form-input,
  .form-textarea {
    font-size: 16px; /* iOS accessibility: prevents auto-zoom */
    padding: 12px 12px;
    min-height: 44px;
    border-radius: 2px;
  }

  .form-textarea {
    font-size: 15px;
    min-height: 80px;
  }

  .form-actions {
    gap: 8px;
    margin-top: 12px;
  }

  .form-actions button {
    padding: 12px 16px;
    font-size: 12px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* World form specific */
  #world-map-picker {
    height: 280px;
    border-radius: 3px;
    margin-bottom: 4px;
  }

  #world-lat,
  #world-lon {
    width: 100%;
    font-size: 12px;
    padding: 10px 10px;
  }

  /* Stack lat/lon vertically */
  div:has(> input[id="world-lat"]) {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  /* Episode list */
  .episode-list {
    margin-bottom: 24px;
  }

  .episode-item {
    gap: 12px;
    padding: 12px 12px;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .episode-num {
    font-size: 12px;
    width: 24px;
  }

  .episode-info {
    flex: 1;
    min-width: 150px;
  }

  .episode-title {
    font-size: 15px;
    margin-bottom: 2px;
  }

  .episode-location {
    font-size: 11px;
  }

  .episode-duration {
    font-size: 11px;
    order: 3;
    width: 100%;
    text-align: right;
    padding-top: 4px;
    border-top: 1px solid #0e0c16;
  }

  .play-btn {
    width: 32px;
    height: 32px;
    font-size: 9px;
  }

  .platform-buttons {
    gap: 8px;
    flex-wrap: wrap;
  }

  .platform-buttons button {
    min-height: 40px;
    padding: 10px 14px;
    font-size: 11px;
    flex: 1;
    min-width: 100px;
  }

  /* Buttons: Better mobile targets */
  .bp, .bc, .bg {
    padding: 12px 16px;
    font-size: 11px;
    letter-spacing: 2px;
    min-height: 44px;
    border-radius: 2px;
  }

  /* Footer */
  .footer-logo {
    font-size: 18px;
    letter-spacing: 3px;
  }

  .footer-desc {
    font-size: 12px;
    margin: 12px auto 14px;
    line-height: 1.6;
  }

  .footer-links {
    gap: 16px;
    margin-bottom: 20px;
  }

  .footer-link {
    font-size: 10px;
  }

  .footer-copyright {
    font-size: 9px;
  }

  /* Leaflet overrides for mobile */
  .leaflet-control-zoom {
    margin-top: 8px;
    margin-right: 8px;
  }

  .leaflet-control-zoom a {
    font-size: 18px;
    width: 36px;
    height: 36px;
    line-height: 36px;
  }

  .leaflet-control-attribution {
    font-size: 8px !important;
    max-width: 90%;
    padding: 2px 4px !important;
  }

  .hub-tt {
    font-size: 9px !important;
    padding: 2px 6px !important;
  }

  /* Dividers and decorative elements */
  .dp, .dc {
    width: 60px;
    margin-bottom: 32px;
  }
}

/* ═════════════════════════════════════════════════════════════════════════════
   ULTRA-NARROW (max-width: 375px) - iPhone SE adjustments
   ═════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 375px) {
  nav {
    padding: 12px 14px;
  }

  .logo {
    font-size: 16px;
    letter-spacing: 2px;
  }

  .hamburger span {
    width: 20px;
  }

  .hero-content {
    bottom: 50px;
    left: 14px;
    right: 14px;
  }

  .hero-title {
    font-size: clamp(18px, 5vw, 26px);
  }

  .hero-desc {
    font-size: 13px;
  }

  .hero-buttons button {
    padding: 11px 14px;
    font-size: 11px;
  }

  section {
    padding: 50px 14px !important;
  }

  #progress {
    padding: 50px 14px 40px;
  }

  .section-label {
    font-size: 9px;
  }

  .section-title {
    font-size: 20px;
  }

  .section-desc {
    font-size: 13px;
  }

  .card {
    padding: 16px 12px;
  }

  .card-miles-value {
    font-size: 28px;
  }

  .card-desc {
    font-size: 12px;
  }

  .counter-value {
    font-size: clamp(32px, 8vw, 44px);
  }

  .counter-total {
    font-size: clamp(32px, 8vw, 44px);
  }

  .map-title {
    font-size: 20px;
  }

  .vote-title {
    font-size: 20px;
  }

  .support-title {
    font-size: 20px;
  }

  .bike-text h2 {
    font-size: 20px;
  }

  .origin-quote {
    font-size: 18px;
  }

  .tier-label {
    font-size: 14px;
  }

  .rb {
    padding: 6px 10px;
    font-size: 8px;
    min-height: 32px;
  }

  .vb {
    padding: 10px 10px;
    font-size: 11px;
  }

  .form-input,
  .form-textarea {
    font-size: 15px;
    padding: 11px 10px;
    min-height: 42px;
  }

  #world-map-picker {
    height: 250px;
  }

  .dp, .dc {
    width: 50px;
    margin-bottom: 24px;
  }

  /* Prevent horizontal scroll at all costs */
  body {
    max-width: 100vw;
    overflow-x: hidden;
  }

  /* Tighter button spacing */
  .bp, .bc, .bg {
    padding: 10px 12px;
    font-size: 10px;
    letter-spacing: 1px;
  }
}

/* ═════════════════════════════════════════════════════════════════════════════
   LANDSCAPE MODE (height < 600px) - minimal improvements
   ═════════════════════════════════════════════════════════════════════════════ */

@media (max-height: 600px) and (orientation: landscape) {
  /* Reduce hero height in landscape */
  .hero {
    height: 70vh;
  }

  /* Compress sections */
  section {
    padding-top: 40px !important;
    padding-bottom: 40px !important;
  }

  /* Tighter spacing */
  .section-header {
    margin-bottom: 20px;
  }

  .hero-content {
    bottom: 40px;
  }

  .cards-grid {
    gap: 12px;
  }

  .continents-grid {
    gap: 12px;
  }
}

/* ═════════════════════════════════════════════════════════════════════════════
   ACCESSIBILITY: Focus states for keyboard navigation
   ═════════════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ═════════════════════════════════════════════════════════════════════════════
   SUB-GAME & ACHIEVEMENT MOBILE FIXES
   ═════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
  /* Sub-game rows: better touch targets on mobile */
  .eu-sub-row {
    padding: 8px 0 !important;
    min-height: 36px;
  }

  .eu-sub-header {
    min-height: 28px;
  }

  /* Sub-game item lists: slightly larger text for readability */
  .eu-sub-items div {
    padding: 3px 0 3px 10px !important;
    min-height: 24px;
  }

  /* Japan line rows: better touch targets */
  .jp-line-row {
    min-height: 36px;
  }

  .jp-line-header {
    padding: 6px 0 !important;
  }

  /* Achievement overlay: ensure it's full-screen on mobile */
  .achievement-overlay {
    padding: 20px !important;
  }

  .achievement-card {
    max-width: 90vw !important;
    padding: 24px 16px !important;
  }

  #achievement-name {
    font-size: 20px !important;
  }

  #achievement-type {
    font-size: 10px !important;
  }

  #achievement-icon {
    font-size: 36px !important;
  }

  /* Map toggle buttons: stack and size for touch */
  .leaflet-top.leaflet-right .leaflet-control {
    margin-right: 6px !important;
    margin-top: 6px !important;
  }

  /* Boundary labels on map */
  .boundary-label {
    font-size: 9px !important;
    padding: 2px 4px !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: more) {
  .bp, .bc, .bg {
    border-width: 2px;
  }

  .card {
    border-width: 2px;
  }
}
