/*
 * GovtSave mobile responsiveness layer.
 * Loaded after page-specific styles so the shared rules can correct narrow layouts
 * without changing desktop layouts or replacing country-specific design systems.
 */

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

html, body {
  max-width: 100%;
}

body {
  overflow-wrap: break-word;
}

img, svg, video, canvas, iframe {
  max-width: 100%;
}

p, li, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
}

pre, pre code, .code-block {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  max-width: 100%;
}

[class*="table-wrap"],
[class*="table-wrapper"],
[class*="table-scroll"],
.comparison-wrap,
.comparison-table-wrap,
.market-table-wrap,
.history-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}



button, input[type="button"], input[type="submit"], input[type="reset"] {
  touch-action: manipulation;
}

@media (max-width: 1024px) {
  .guide-grid, .footer-grid, .calculator-grid, .rate-grid,
  .result-grid, .planner-grid, .comparison-grid {
    min-width: 0;
  }

  .container {
    width: min(100% - 28px, 1160px);
  }
}

@media (max-width: 760px) {
  *, *::before, *::after {
    box-sizing: border-box;
  }

  html {
    scroll-padding-top: 78px;
  }

  body {
    min-width: 320px;
    overflow-x: clip;
    font-size: 15px;
    line-height: 1.6;
  }

  main, header, footer, section, article, aside, nav, form, fieldset {
    min-width: 0;
  }

  button, input, select, textarea {
    max-width: 100%;
    min-width: 0;
  }

  input, select, textarea {
    font-size: 16px;
  }

  a {
    overflow-wrap: anywhere;
  }

  .container {
    width: min(100% - 28px, 1160px);
  }

  .nav {
    height: auto;
    min-height: 64px;
    flex-wrap: wrap;
    gap: 9px;
    padding-block: 10px;
  }

  .nav .brand {
    min-width: 0;
    margin-right: auto;
    gap: 8px;
    font-size: 1.16rem;
  }

  .nav .brand-mark {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
  }

  .site-search {
    order: 10;
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    margin: 0;
  }

  .site-search input {
    width: 100%;
    min-width: 0;
  }

  .mobile-links {
    width: 100%;
  }

  .mobile-links a {
    min-height: 42px;
    display: flex;
    align-items: center;
  }

  .hero {
    padding-block: 42px;
  }

  .hero-grid, .calculator-grid, .guide-grid, .footer-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-grid {
    gap: 24px;
  }

  .hero h1, .page-hero h1 {
    font-size: clamp(1.9rem, 7.7vw, 3rem);
    line-height: 1.12;
    overflow-wrap: anywhere;
  }

  .hero p, .page-hero p {
    font-size: 1rem;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .hero-actions .btn, .btn {
    max-width: 100%;
  }

  .section {
    padding-block: 44px;
  }

  .section-heading {
    margin-bottom: 26px;
  }

  .section-heading h2 {
    font-size: clamp(1.55rem, 6.2vw, 2.2rem);
  }

  .calculator-card {
    padding: 18px;
  }

  .calc-head {
    flex-wrap: wrap;
  }

  .calculator-grid > .calculator-card:last-child:nth-child(odd) {
    grid-column: auto;
    justify-self: stretch;
    width: 100%;
  }

  .rate-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .guide-card {
    min-width: 0;
  }

  .comparison-wrap, .comparison-table-wrap {
    max-width: 100%;
    overflow-x: auto;
  }

  .comparison-table {
    min-width: 580px;
  }

  .chart-wrap, .chart-wrapper, .chart-wrapper canvas {
    max-width: 100%;
  }

  .global-market-rail-list {
    display: flex;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding-bottom: 8px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .global-market-rail-list > * {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }

  .mobile-quick-nav {
    left: 8px;
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 2px;
    padding: 6px;
  }

  .mobile-quick-nav a {
    min-width: 0;
    min-height: 48px;
    padding: 5px 1px;
    font-size: 9px;
    line-height: 1.15;
    overflow-wrap: normal;
    text-align: center;
  }

  .mobile-quick-nav a i {
    font-size: 15px;
  }

  body {
    padding-bottom: 0;
  }

  body:has(.mobile-quick-nav) {
    padding-bottom: max(82px, calc(78px + env(safe-area-inset-bottom)));
  }

  /* The international dashboards have their own visual styles; these shared
     constraints keep their headers, section menus and card grids from overflowing. */
  body[class*="market-page"] :is(.mp-shell, .nz-shell, .ie-shell, .sg-shell, .ca-shell, .au-shell, .de-shell, .ph-wrap),
  body[class*="market-page"] :is(.mp-header-inner, .nz-header-inner, .ie-header-inner, .sg-header-inner, .ca-header-inner, .au-header-inner, .de-header-inner, .ph-header-inner) {
    width: calc(100% - 28px);
    max-width: 100%;
    min-width: 0;
  }

  body[class*="market-page"] :is(.mp-section-nav, .nz-section-nav, .ie-section-nav, .sg-section-nav, .ca-section-nav, .au-section-nav, .de-section-nav, .ph-section-nav) {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  body[class*="market-page"] :is(.mp-section-nav-inner, .nz-section-nav-inner, .ie-section-nav-inner, .sg-section-nav-inner, .ca-section-nav-inner, .au-section-nav-inner, .de-section-nav-inner, .ph-section-nav-inner) {
    min-width: 0;
    max-width: 100%;
    gap: 8px;
  }

  body[class*="market-page"] :is(.mp-section-nav-inner, .nz-section-nav-inner, .ie-section-nav-inner, .sg-section-nav-inner, .ca-section-nav-inner, .au-section-nav-inner, .de-section-nav-inner, .ph-section-nav-inner) a {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  body[class*="market-page"] :is(.mp-hero-grid, .nz-hero-grid, .ie-hero-grid, .sg-hero-grid, .ca-hero-grid, .au-hero-grid, .de-hero-grid, .ph-hero-grid) {
    grid-template-columns: minmax(0, 1fr);
  }

  body[class*="market-page"] :is(.mp-hero-actions, .nz-hero-actions, .ie-hero-actions, .sg-hero-actions, .ca-hero-actions, .au-hero-actions, .de-hero-actions, .ph-hero-actions) {
    flex-wrap: wrap;
  }

  body[class*="market-page"] :is(.mp-hero-actions, .nz-hero-actions, .ie-hero-actions, .sg-hero-actions, .ca-hero-actions, .au-hero-actions, .de-hero-actions, .ph-hero-actions) > * {
    min-width: 0;
    max-width: 100%;
  }

  body[class*="market-page"] :is(.mp-card, .uk-card, .ca-card, .de-card, .au-card, .nz-card, .ie-card, .sg-card, .ph-card) {
    min-width: 0;
    max-width: 100%;
  }

  body[class*="market-page"] canvas {
    max-width: 100%;
  }

  /* Account forms and admin-style cards must shrink to the viewport. */
  body > .card {
    width: calc(100% - 28px) !important;
    max-width: 480px;
    margin: 14px auto !important;
    padding: 22px 18px !important;
  }

  .auth-shell, .auth-card {
    width: min(100% - 24px, 480px);
    max-width: 100%;
  }

  .auth-card {
    padding: 24px 18px;
  }

  .auth-card input, .auth-card select, .auth-card textarea,
  .auth-card button, .auth-card .btn {
    width: 100%;
  }

  /* Dashboard tables remain readable through intentional inner scrolling. */
  .table-responsive, .responsive-table, .dashboard-table-wrap,
  .saved-calculations-table-wrap, .results-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 560px) {
  .container {
    width: calc(100% - 22px);
  }

  .section {
    padding-block: 36px;
  }

  .section-heading {
    text-align: left;
    margin-bottom: 22px;
  }

  .hero {
    padding-block: 34px;
  }

  .hero-panel, .calculator-card {
    padding: 16px;
    border-radius: 16px;
  }

  .rate-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .rate-card {
    padding: 17px;
  }

  .field-help {
    flex-wrap: wrap;
  }

  .result-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .chart-wrap {
    padding: 10px;
  }

  .mobile-quick-nav {
    left: 6px;
    right: 6px;
    padding: 5px 4px;
    gap: 1px;
  }

  .mobile-quick-nav a {
    font-size: 8.5px;
  }

  body[class*="market-page"] :is(.mp-shell, .nz-shell, .ie-shell, .sg-shell, .ca-shell, .au-shell, .de-shell, .ph-wrap),
  body[class*="market-page"] :is(.mp-header-inner, .nz-header-inner, .ie-header-inner, .sg-header-inner, .ca-header-inner, .au-header-inner, .de-header-inner, .ph-header-inner) {
    width: calc(100% - 22px);
  }

  body[class*="market-page"] :is(.mp-card, .uk-card, .ca-card, .de-card, .au-card, .nz-card, .ie-card, .sg-card, .ph-card) {
    padding-inline: 15px;
  }

  body > .card {
    width: calc(100% - 22px) !important;
    padding: 20px 15px !important;
  }
}

@media (max-width: 380px) {
  .container {
    width: calc(100% - 20px);
  }

  .mobile-quick-nav a {
    gap: 3px;
    font-size: 8px;
  }

  .mobile-quick-nav a i {
    font-size: 14px;
  }

  body[class*="market-page"] :is(.mp-shell, .nz-shell, .ie-shell, .sg-shell, .ca-shell, .au-shell, .de-shell, .ph-wrap),
  body[class*="market-page"] :is(.mp-header-inner, .nz-header-inner, .ie-header-inner, .sg-header-inner, .ca-header-inner, .au-header-inner, .de-header-inner, .ph-header-inner) {
    width: calc(100% - 20px);
  }

  .hero h1, .page-hero h1 {
    font-size: 1.85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
