/* ============================================================
   Responsive Styles — iPhone / iPad / Mobile
   EyewearCost Index — Design D (Data Authority)
   Load AFTER inline styles to override
   ============================================================ */

/* Hide nav-links on iPad and smaller, show when .open */
@media (max-width: 1024px) {
  .nav-links { display: none; }
  .nav-links.open { display: flex; }
}

/* ---------- Language Switcher ---------- */
.lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 0;
  margin-left: 12px;
}

/* ---------- iPad (768px - 1024px) ---------- */
@media (max-width: 1024px) {
  .container { padding: 0 20px; }
  .page-header h1 { font-size: 32px; }
  .page-header p { font-size: 14px; }
  .page-stats { gap: 28px; }
  .page-stat .num { font-size: 20px; }
  section { padding: 48px 0; }
  .section-head h2 { font-size: 24px; }
  .market-info-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .location-card-body { grid-template-columns: 1fr; gap: 20px; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 28px; }
  .topbar-inner { flex-wrap: wrap; gap: 4px; }
  .topbar span { font-size: 14px; }

  /* Nav — mobile menu for iPad too */
  .nav-inner { flex-wrap: wrap; position: relative; }
  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    flex-direction: column;
    gap: 0;
    padding: 8px 20px 16px;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    z-index: 99;
  }
  .nav-links li { width: 100%; }
  .nav-links a {
    display: block;
    padding: 12px 0;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
  }
  .nav-links li:last-child a { border-bottom: none; }
  .nav-cta { margin-left: auto; }
  .lang-switcher { margin-left: 12px; }

  .compare-table { font-size: 14px; }
  .compare-table th, .compare-table td { padding: 10px 10px; }
  .cta-section h2 { font-size: 26px; }
  .market-card-header { padding: 20px 22px; }
  .market-card-body { padding: 20px 22px; }
  .market-card-footer { padding: 14px 22px; }
}

/* ---------- iPhone & Small Mobile (<= 767px) ---------- */
@media (max-width: 767px) {
  .container { padding: 0 16px; }

  /* Topbar — hide secondary info on very small screens */
  .topbar { padding: 5px 0; }
  .topbar-inner { flex-direction: column; align-items: flex-start; gap: 2px; }
  .topbar span { font-size: 14px; line-height: 1.4; }
  .topbar span:nth-child(2) { display: none; }

  /* Nav — mobile menu */
  .nav-inner { flex-wrap: wrap; padding: 12px 0; position: relative; }
  .logo { font-size: 14px; gap: 8px; }
  .logo-mark { width: 30px; height: 30px; font-size: 14px; }
  .logo-sub { font-size: 10px; }

  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    flex-direction: column;
    gap: 0;
    padding: 8px 16px 16px;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    z-index: 99;
  }
  .nav-links.open { display: flex; }
  .nav-links li { width: 100%; }
  .nav-links a {
    display: block;
    padding: 12px 0;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
  }
  .nav-links li:last-child a { border-bottom: none; }

  .nav-cta {
    order: 3;
    padding: 7px 14px;
    font-size: 14px;
    margin-left: auto;
    margin-right: 8px;
  }

  .lang-switcher {
    order: 4;
    margin-left: 0;
    margin-top: 10px;
    width: auto;
    justify-content: center;
  }

  /* Page Header */
  .page-header { padding: 36px 0 32px; }
  .breadcrumb { font-size: 14px; margin-bottom: 12px; }
  .page-header h1 { font-size: 26px; line-height: 1.25; margin-bottom: 12px; }
  .page-header p { font-size: 14px; line-height: 1.6; }
  .page-stats {
    gap: 16px;
    margin-top: 20px;
    padding-top: 18px;
  }
  .page-stat .num { font-size: 18px; }
  .page-stat .label { font-size: 14px; }

  /* Sections */
  section { padding: 36px 0; }
  .section-tag { font-size: 14px; margin-bottom: 8px; }
  .section-head h2 { font-size: 20px; margin-bottom: 10px; }
  .section-head p { font-size: 14px; margin-bottom: 20px; }

  /* Market Cards */
  .market-card { margin-bottom: 20px; }
  .carousel-placeholder { height: 200px; }
  .carousel-icon { font-size: 36px; }
  .carousel-text { font-size: 14px; }
  .carousel-sub { font-size: 14px; }
  .carousel-arrow { width: 30px; height: 30px; font-size: 14px; }
  .carousel-arrow.left { left: 10px; }
  .carousel-arrow.right { right: 10px; }

  .market-card-header { padding: 16px 18px; flex-direction: column; gap: 10px; }
  .market-card-header h3 { font-size: 18px; }
  .market-card-header .cn-name { font-size: 14px; }
  .market-badges { justify-content: flex-start; }

  .market-card-body { padding: 16px 18px; }
  .market-info-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .market-info-item { padding: 10px; }
  .market-info-item .label { font-size: 14px; }
  .market-info-item .value { font-size: 14px; line-height: 1.4; }

  .market-desc p { font-size: 14px; line-height: 1.65; margin-bottom: 10px; }
  .market-features { gap: 6px; margin-top: 12px; }
  .feature-pill { font-size: 14px; padding: 3px 8px; }

  .market-card-footer {
    padding: 12px 18px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .market-price .amount { font-size: 14px; }
  .market-rating { font-size: 14px; }

  /* Location Cards (locations.html) */
  .location-card { margin-bottom: 20px; }
  .location-card-header {
    padding: 16px 18px;
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .location-card-header h3 { font-size: 17px; }
  .location-card-header .meta { font-size: 14px; line-height: 1.5; }
  .location-badges { justify-content: flex-start; }
  .location-card-body { padding: 16px 18px; gap: 16px; }
  .location-desc p { font-size: 14px; line-height: 1.65; }
  .location-stats { padding: 14px; }
  .stat-row { padding: 6px 0; }
  .stat-row .label { font-size: 14px; }
  .stat-row .value { font-size: 14px; }
  .location-card-footer {
    padding: 12px 18px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .btn-link { font-size: 14px; }

  /* Comparison Tables — horizontal scroll */
  .compare-table-wrap,
  div[style*="overflow: hidden"] table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .compare-table {
    font-size: 14px;
    min-width: 500px;
  }
  .compare-table th, .compare-table td {
    padding: 8px 8px;
    white-space: nowrap;
  }
  /* City page comparison tables */
  section table {
    font-size: 14px;
    min-width: 480px;
  }
  section table th, section table td {
    padding: 8px 8px;
  }
  /* Make table container scrollable */
  section > .container > div[style*="background: var(--white)"] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Tip Box */
  .tip-box { padding: 12px 14px; }
  .tip-box .label { font-size: 14px; margin-bottom: 4px; }
  .tip-box p { font-size: 14px; line-height: 1.6; }

  /* CTA Section */
  .cta-section { padding: 40px 0; margin-top: 36px; }
  .cta-section h2 { font-size: 22px; margin-bottom: 10px; }
  .cta-section p { font-size: 14px; margin-bottom: 20px; }
  .cta-buttons {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }
  .btn-primary, .btn-outline {
    justify-content: center;
    padding: 12px 20px;
    font-size: 14px;
  }

  /* Footer */
  footer { padding: 32px 0 20px; }
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .footer-brand p { font-size: 14px; }
  .footer-col h5 { font-size: 14px; margin-bottom: 12px; }
  .footer-col li { margin-bottom: 8px; }
  .footer-col a { font-size: 14px; }
  .footer-bottom {
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
    text-align: center;
  }

  /* Badges */
  .badge-cell { font-size: 14px; padding: 2px 8px; }

  /* General text sizing */
  body { font-size: 14px; }
  p { line-height: 1.65; }
}

/* ---------- Very Small Screens (<= 380px, iPhone SE etc.) ---------- */
@media (max-width: 380px) {
  .container { padding: 0 14px; }
  .page-header h1 { font-size: 23px; }
  .page-stats { gap: 12px; }
  .page-stat .num { font-size: 14px; }
  .market-info-grid { grid-template-columns: 1fr; }
  .nav-cta { padding: 6px 10px; font-size: 14px; }
  .logo { font-size: 14px; }
  .section-head h2 { font-size: 18px; }
}

/* ---------- iPad Landscape / Large Tablet (1025px - 1180px) ---------- */
@media (min-width: 1025px) and (max-width: 1180px) {
  .container { max-width: 960px; }
  .market-info-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Print ---------- */
@media print {
  .topbar, nav, .cta-section, .lang-switcher { display: none !important; }
  .page-header { background: white !important; color: black !important; padding: 20px 0 !important; }
  .page-header h1, .page-header p { color: black !important; }
  section { padding: 20px 0; }
  .market-card, .location-card { break-inside: avoid; box-shadow: none; }
}

/* ===== 全局最小字体规则（Pad / iPhone端） ===== */
/* Pad端（768px-1024px）：最小字体1em */
@media (max-width: 1024px) {
  html { font-size: 14px; }
  body, p, td, th, li, span, a, div, label, input, textarea, select, button {
    font-size: 1em;
  }
  h1, h2, h3, h4, h5, h6 {
    font-size: 1.5em;
  }
  .mono, .section-tag, .badge-cell, .city-index, .page-stat .num {
    font-size: 1em;
  }
}

/* iPhone端（<768px）：最小字体1em */
@media (max-width: 768px) {
  html { font-size: 14px; }
  body, p, td, th, li, span, a, div, label, input, textarea, select, button {
    font-size: 1em;
  }
  h1 { font-size: 1.8em; }
  h2 { font-size: 1.5em; }
  h3 { font-size: 1.3em; }
  h4, h5, h6 { font-size: 1.1em; }
  .mono, .section-tag, .badge-cell, .city-index, .page-stat .num {
    font-size: 1em;
  }
}

/* 超小屏（<480px）：保持最小1em */
@media (max-width: 480px) {
  html { font-size: 14px; }
  * {
    font-size: 1em;
  }
  h1 { font-size: 1.6em; }
  h2 { font-size: 1.4em; }
  h3 { font-size: 1.2em; }
}
