/* ============================================
   AMERICAN INDEPENDENCE GOLD
   Premium Mobile & Tablet Experience
   Loaded AFTER styles.css and homepage.css
   ============================================
   !important is used ONLY to override inline styles
   — the textbook-correct use case. All rules are
   scoped inside media queries so desktop is untouched.
   ============================================ */


/* ==================================================
   PHASE 6: TABLET BREAKPOINT (769px – 1024px)
   Listed first so mobile rules (lower breakpoint)
   can override when needed via cascade order.
   ================================================== */

@media (max-width: 1024px) and (min-width: 769px) {

  /* --- 6A: Form-page heroes — keep side-by-side, shrink form --- */
  .hero--dark .container > div[style*="display: flex"][style*="gap: 48px"] {
    gap: 32px !important;
  }

  .hero--dark .container > div[style*="display: flex"][style*="gap: 48px"] > div[style*="flex: 0 0 4"] {
    flex: 0 0 340px !important;
  }

  /* --- 6B: Content splits — tighter gaps --- */
  .section--white .container > div[style*="display: flex"][style*="gap: 48px"],
  .section--light .container > div[style*="display: flex"][style*="gap: 48px"] {
    gap: 32px !important;
  }

  /* --- 6C: Timeline cards 2×2 --- */
  .section--dark .container > div[style*="display: flex"][style*="gap: 16px"][style*="max-width: 900px"] {
    flex-wrap: wrap !important;
    gap: 16px !important;
  }

  .section--dark .container > div[style*="display: flex"][style*="gap: 16px"][style*="max-width: 900px"] > div[style*="flex: 1"] {
    flex: 0 0 calc(50% - 8px) !important;
  }

  /* --- 6D: Homepage hero image shrinks --- */
  .hp-hero .hp-hero__content > .hp-hero__image {
    flex: 0 0 40% !important;
  }

  .hp-hero .hp-hero__content {
    gap: 32px !important;
  }

  /* --- 6E: Blog grid 2-up at tablet --- */
  .grid.grid--3:has(> a.card) {
    grid-template-columns: repeat(2, 1fr);
  }

  /* --- 6F: HP CTA banner at tablet --- */
  .hp-cta-banner .container {
    gap: 40px !important;
  }

  .hp-cta-banner .container > div[style*="flex: 0 0 40%"] {
    flex: 0 0 35% !important;
  }
}


/* ==================================================
   MOBILE BREAKPOINT (768px and below)
   ================================================== */

@media (max-width: 768px) {

  /* ================================================
     PHASE 1: MOBILE NAV + STICKY CTA
     ================================================ */

  /* --- 1A: Full-Screen Luxury Nav Overlay --- */
  .nav__links--open {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    height: 100dvh;
    background: linear-gradient(180deg, #050d1a 0%, var(--deep-navy) 100%);
    padding: 100px 32px 40px 32px;
    gap: 0;
    justify-content: flex-start;
    align-items: stretch;
    z-index: 999;
    overflow-y: auto;
    border-bottom: none;
  }

  .nav__links--open .nav__link {
    font-size: 20px;
    font-family: var(--font-serif);
    color: var(--warm-white);
    letter-spacing: 0.5px;
    padding: 20px 0;
    border-bottom: 1px solid rgba(184, 149, 107, 0.1);
    display: block;
    transition: color 0.2s ease, padding-left 0.2s ease;
  }

  .nav__links--open .nav__link:last-of-type {
    border-bottom: none;
  }

  .nav__links--open .nav__link:active {
    color: var(--muted-gold);
    padding-left: 8px;
  }

  .nav__links--open .nav__cta {
    margin-top: 24px;
    width: 100%;
    text-align: center;
    padding: 16px 24px;
    font-size: 14px;
    border-color: var(--muted-gold);
    display: block;
  }

  /* --- 1B: Nav Gold-Glow Bottom Border --- */
  .nav {
    border-bottom: 1px solid rgba(184, 149, 107, 0.25);
    box-shadow: 0 1px 8px rgba(184, 149, 107, 0.08);
  }

  /* --- 1C: Sticky CTA Entrance Glow --- */
  .sticky-cta {
    animation: stickyGlow 2s ease-in-out 1s 1;
  }

  .sticky-cta .btn--gold {
    padding: 14px 24px;
    font-size: 15px;
    min-height: 48px;
  }

  @keyframes stickyGlow {
    0%, 100% { box-shadow: 0 -1px 4px rgba(184, 149, 107, 0); }
    50% { box-shadow: 0 -2px 16px rgba(184, 149, 107, 0.25); }
  }

  /* --- 1D: Hamburger → X Transition --- */
  .nav__toggle {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    min-width: 48px;
  }

  .nav__toggle span {
    transition: transform 0.3s ease, opacity 0.3s ease;
  }

  .nav__toggle[aria-expanded="true"] span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
  }

  .nav__toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
  }

  .nav__toggle[aria-expanded="true"] span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
  }


  /* ================================================
     PHASE 2: HERO SECTIONS
     ================================================ */

  /* --- 2A: Homepage Hero --- */
  .hp-hero .hp-hero__content {
    display: block !important;
    gap: 0 !important;
  }

  .hp-hero .hp-hero__content > div:first-child {
    flex: none !important;
    width: 100% !important;
  }

  .hp-hero .hp-hero__content > .hp-hero__image {
    display: none !important;
  }

  .hp-hero h1 {
    font-size: clamp(36px, 10vw, 52px);
    letter-spacing: -0.5px;
  }

  /* Hero trust badges row */
  .hp-hero .hero__actions + div[style*="display: flex"] {
    flex-wrap: wrap !important;
    gap: 12px !important;
    font-size: 12px !important;
  }

  /* --- 2B: Form-Page Heroes (gold-ira, consultation, free-guide) --- */

  /* Stack vertically, form FIRST (column-reverse for conversion) */
  .hero--dark .container > div[style*="display: flex"][style*="gap: 48px"] {
    display: flex !important;
    flex-direction: column-reverse !important;
    gap: 32px !important;
  }

  /* Text column: full width */
  .hero--dark .container > div[style*="display: flex"][style*="gap: 48px"] > div[style*="flex: 1"] {
    flex: none !important;
    width: 100% !important;
  }

  /* Form card: full width, remove fixed sizing */
  .hero--dark .container > div[style*="display: flex"][style*="gap: 48px"] > div[style*="flex: 0 0 4"] {
    flex: none !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 12px !important;
    padding: 24px !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25) !important;
  }

  /* Hero padding tightening */
  .hero--dark[style*="padding: 120px"] {
    padding: 100px 0 40px 0 !important;
  }

  /* Trust badge images row in gold-ira hero */
  .hero--dark div[style*="gap: 24px"][style*="border-top"] {
    flex-wrap: wrap !important;
    gap: 16px !important;
    justify-content: center !important;
  }

  /* --- 2C: Homepage CTA Banner (guide image + text) --- */
  .hp-cta-banner .container {
    display: flex !important;
    flex-direction: column !important;
    gap: 24px !important;
    text-align: center !important;
  }

  .hp-cta-banner .container > div[style*="flex: 0 0 40%"] {
    flex: none !important;
    width: 60% !important;
    max-width: 240px;
    margin: 0 auto;
  }

  .hp-cta-banner .container > div[style*="flex: 1"] {
    flex: none !important;
  }

  .hp-cta-banner {
    padding: 40px 20px !important;
  }


  /* ================================================
     PHASE 3: CONTENT LAYOUTS
     ================================================ */

  /* --- 3A: Side-by-side Image + Text sections --- */

  /* Stack all inline-flex 48px-gap splits inside sections */
  .section--white .container > div[style*="display: flex"][style*="gap: 48px"],
  .section--light .container > div[style*="display: flex"][style*="gap: 48px"] {
    display: block !important;
    gap: 0 !important;
  }

  /* Each flex:1 child goes full width */
  .section--white .container > div[style*="display: flex"][style*="gap: 48px"] > div[style*="flex: 1"],
  .section--light .container > div[style*="display: flex"][style*="gap: 48px"] > div[style*="flex: 1"] {
    flex: none !important;
    width: 100% !important;
  }

  /* Images inside these splits: full-bleed edge-to-edge */
  .section--white .container > div[style*="display: flex"][style*="gap: 48px"] > div[style*="flex: 1"] > img,
  .section--light .container > div[style*="display: flex"][style*="gap: 48px"] > div[style*="flex: 1"] > img {
    width: calc(100% + 40px) !important;
    margin-left: -20px !important;
    margin-right: -20px !important;
    border-radius: 0 !important;
    max-width: none !important;
  }

  /* Second child gets gold accent top border */
  .section--white .container > div[style*="display: flex"][style*="gap: 48px"] > div[style*="flex: 1"] + div[style*="flex: 1"],
  .section--light .container > div[style*="display: flex"][style*="gap: 48px"] > div[style*="flex: 1"] + div[style*="flex: 1"] {
    border-top: 2px solid var(--muted-gold);
    padding-top: 24px;
    margin-top: 24px;
  }

  /* --- 3B: Homepage Veteran + Testimonial splits --- */
  .hp-veteran__image img {
    width: calc(100% + 40px) !important;
    margin-left: -20px !important;
    margin-right: -20px !important;
    border-radius: 0 !important;
    max-width: none !important;
  }

  .hp-veteran__content {
    border-top: 2px solid var(--muted-gold);
    padding-top: 20px;
  }

  .hp-testimonial__image img {
    width: calc(100% + 40px) !important;
    margin-left: -20px !important;
    margin-right: -20px !important;
    border-radius: 0 !important;
    max-width: none !important;
  }

  .hp-testimonial__quote {
    font-size: 20px;
    padding-left: 20px;
  }

  /* --- 3C: How-It-Works Process Steps → Vertical Gold-Line Timeline --- */

  /* The container holding all 4 steps */
  .section--white .container > div[style*="max-width: 800px"] {
    position: relative;
    padding-left: 16px !important;
  }

  /* Continuous gold vertical line */
  .section--white .container > div[style*="max-width: 800px"]::before {
    content: '';
    position: absolute;
    left: 39px;
    top: 28px;
    bottom: 56px;
    width: 2px;
    background: linear-gradient(180deg, var(--muted-gold) 0%, var(--warm-bronze) 100%);
  }

  /* Each step div */
  .section--white .container > div[style*="max-width: 800px"] > div[style*="display: flex"][style*="gap: 32px"] {
    gap: 16px !important;
    margin-bottom: 24px !important;
    position: relative;
    z-index: 1;
  }

  /* The numbered circle — shrink slightly, add white ring */
  .section--white .container > div[style*="max-width: 800px"] > div[style*="display: flex"] > div[style*="width: 56px"] {
    width: 48px !important;
    height: 48px !important;
    font-size: 18px !important;
    flex-shrink: 0 !important;
    box-shadow: 0 0 0 4px var(--warm-white);
  }

  /* --- 3D: How-It-Works Timeline Cards → Vertical Connected Nodes --- */
  .section--dark .container > div[style*="display: flex"][style*="gap: 16px"][style*="max-width: 900px"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
    position: relative;
    padding-left: 24px;
  }

  /* Connecting gold line */
  .section--dark .container > div[style*="display: flex"][style*="gap: 16px"][style*="max-width: 900px"]::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 24px;
    bottom: 24px;
    width: 2px;
    background: linear-gradient(180deg, var(--muted-gold) 0%, rgba(184, 149, 107, 0.3) 100%);
  }

  /* Each timeline card */
  .section--dark .container > div[style*="display: flex"][style*="gap: 16px"][style*="max-width: 900px"] > div[style*="flex: 1"] {
    flex: none !important;
    width: 100% !important;
    margin-bottom: 16px;
    padding: 20px 20px 20px 28px !important;
    border-radius: 8px !important;
    position: relative;
  }

  /* Gold dot node on the timeline line */
  .section--dark .container > div[style*="display: flex"][style*="gap: 16px"][style*="max-width: 900px"] > div[style*="flex: 1"]::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 28px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--muted-gold);
    box-shadow: 0 0 0 3px #0d1a2e;
  }

  /* --- 3E: Stats → 2×2 Grid with Gold Dividers --- */
  .stats-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0 !important;
    flex-direction: unset !important;
  }

  .stats-row .stat {
    padding: 24px 16px;
    border-bottom: 1px solid rgba(184, 149, 107, 0.15);
    border-right: 1px solid rgba(184, 149, 107, 0.15);
  }

  .stats-row .stat:nth-child(2n) {
    border-right: none;
  }

  .stats-row .stat:nth-last-child(-n+2) {
    border-bottom: none;
  }

  .stat__number {
    font-size: 36px;
  }

  /* --- 3E (cont): HP Stats → 2×2 with Gold Dividers --- */
  .hp-stats__row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    flex-direction: unset !important;
    gap: 0 !important;
  }

  .hp-stat__divider {
    display: none !important;
  }

  .hp-stat {
    flex: none !important;
    padding: 20px 16px !important;
    border-bottom: 1px solid rgba(184, 149, 107, 0.15);
    border-right: 1px solid rgba(184, 149, 107, 0.15);
  }

  .hp-stat:nth-child(even) {
    border-right: none;
  }

  /* Last two stats: no bottom border (accounts for hidden dividers) */
  .hp-stat:nth-last-of-type(-n+2) {
    border-bottom: none;
  }

  .hp-stat__number {
    font-size: clamp(32px, 8vw, 44px);
  }

  /* --- 3F: Reviews Rating Summary --- */
  .section--white .container > div[style*="display: flex"][style*="gap: 48px"][style*="justify-content: center"] {
    flex-direction: column !important;
    gap: 20px !important;
    text-align: center !important;
  }

  .section--white .container > div[style*="display: flex"][style*="gap: 48px"][style*="justify-content: center"] > div:last-child {
    text-align: center !important;
  }


  /* ================================================
     PHASE 4: CARDS, BLOG, FOOTER
     ================================================ */

  /* --- 4A: Blog Cards → Horizontal-Scrolling Filmstrip --- */
  .grid.grid--3:has(> a.card) {
    display: flex !important;
    grid-template-columns: unset !important;
    overflow-x: auto !important;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 16px !important;
    padding-bottom: 16px;
    margin-left: -20px;
    margin-right: -20px;
    padding-left: 20px;
    padding-right: 20px;
  }

  .grid.grid--3:has(> a.card) > a.card {
    flex: 0 0 280px !important;
    scroll-snap-align: start;
    min-width: 280px;
  }

  /* --- 4B: Homepage Trust Bar Gold Accents --- */
  .hp-trust-item {
    position: relative;
    padding: 16px 24px !important;
  }

  .hp-trust-item::after {
    content: '';
    position: absolute;
    left: 24px;
    bottom: 0;
    width: 40px;
    height: 2px;
    background: var(--muted-gold);
    opacity: 0.3;
  }

  .hp-trust-item:last-child::after {
    display: none;
  }

  /* --- 4C: CTA Banner Buttons — Full Width --- */
  .cta-banner .btn--lg,
  .hp-cta-banner .btn {
    width: 100%;
    justify-content: center;
    min-height: 48px;
  }

  /* --- 4D: Footer Enhancement --- */
  .footer__grid > div + div {
    border-top: 1px solid rgba(184, 149, 107, 0.1);
    padding-top: 24px;
  }

  .footer {
    padding-bottom: 80px;
  }

  .footer__bottom {
    padding-bottom: 12px;
  }


  /* ================================================
     PHASE 5: MICRO-DETAILS & POLISH
     ================================================ */

  /* --- 5A: Gold Section Dividers --- */
  main > .section--dark + section:not(.section--dark):not(.hp-trust-bar) {
    border-top: 2px solid var(--muted-gold);
  }

  main > section:not(.section--dark) + section:not(.section--dark) {
    border-top: 1px solid rgba(184, 149, 107, 0.12);
  }

  /* Don't double-border after the special HP sections */
  main > .hp-stats + section,
  main > .hp-cta-banner + section,
  main > .hp-trust-bar + section {
    border-top: none;
  }

  /* --- 5B: Touch-Friendly Tap Targets (48px min) --- */
  .btn {
    min-height: 48px;
    padding: 14px 24px;
  }

  .btn--sm {
    min-height: 44px;
    padding: 12px 20px;
  }

  .faq-question {
    min-height: 48px;
    padding: 16px 0;
  }

  .footer__link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  /* Form inputs: 16px prevents iOS auto-zoom on focus */
  .form-input,
  .form-select,
  .form-textarea {
    padding: 14px 16px;
    font-size: 16px;
  }

  /* --- 5C: Typography + Spacing --- */
  body {
    font-size: 16px;
  }

  :root {
    --section-padding: 48px 0;
  }

  .container {
    padding: 0 20px;
  }

  h2 {
    font-size: clamp(26px, 7vw, 36px);
  }

  .hp-section-header h2 {
    font-size: clamp(28px, 8vw, 40px);
  }

  .hp-section-header p {
    font-size: 15px;
  }

  /* Safety: prevent horizontal overflow from any element */
  html, body {
    overflow-x: hidden;
  }

  /* --- 5D: Suppress Hover Effects on Touch --- */
  .card:hover,
  .hp-card:hover {
    transform: none;
    box-shadow: none;
  }

  .hp-card:hover::before {
    opacity: 0;
  }

  /* --- Page hero padding on mobile --- */
  .page-hero {
    padding: 100px 0 40px 0;
  }

  .page-hero p {
    font-size: 16px;
  }
}
