/* ============================
   RESPONSIVE LAYOUTS & BREAKPOINTS
   ============================ */

@media (max-width: 1200px) {
  main {
    max-width: 960px;
  }
}

@media (max-width: 1024px) {
  .featured-articles {
    grid-template-columns: 1fr;
  }
  .featured-sidebar {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    display: grid;
  }
}

@media (max-width: 900px) {
  /* True 2×2 grid: Logo|Calc / Resources|Newsletter */
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 32px 40px;
  }

  /* Remove any spanning — let 4 cols flow naturally into 2 rows of 2 */
  .footer-col:first-child,
  .footer-col:last-child {
    grid-column: auto;
  }

  .newsletter-form {
    max-width: 100%;
  }

  .footer-desc {
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  main {
    padding: 24px 16px 60px;
  }

  .instrument {
    padding: 36px 24px;
  }

  .article-container,
  .page-container {
    padding: 36px 24px;
  }

  .site-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--panel);
    border-bottom: 1px solid var(--hairline);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 12px 20px 24px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity var(--transition-fast), transform var(--transition-fast), visibility var(--transition-fast);
    box-shadow: var(--shadow-md);
  }

  .site-nav.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .site-nav > a {
    padding: 14px 0;
    border-bottom: 1px solid var(--hairline-light);
    font-size: 13px;
  }

  .site-nav > a:last-of-type {
    border-bottom: none;
  }

  .nav-dropdown {
    border-bottom: 1px solid var(--hairline-light);
  }

  .dropdown-trigger {
    width: 100%;
    justify-content: space-between;
    padding: 14px 0;
    font-size: 13px;
  }

  .dropdown-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    background: var(--panel-light);
    border: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-smooth);
  }

  .nav-dropdown.open .dropdown-menu {
    max-height: 300px;
    margin-bottom: 10px;
  }

  .dropdown-menu a {
    padding: 12px 20px;
    font-size: 12px;
  }

  .nav-toggle {
    display: block;
  }

  /* Tablet footer: same true 2×2 grid, inherited from 900px */
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 28px 36px;
  }

  .footer-col:first-child,
  .footer-col:last-child {
    grid-column: auto;
  }

  .newsletter-form {
    max-width: 100%;
  }
}

@media (max-width: 540px) {
  form.calc-form {
    flex-direction: column;
    align-items: stretch;
  }

  form.calc-form button {
    width: 100%;
  }

  .footer-grid {
    /* Logo full-width, Calc+Resources side-by-side, Newsletter full-width */
    grid-template-columns: 1fr 1fr;
    gap: 24px 28px;
  }

  /* Logo spans both columns */
  .footer-col:first-child {
    grid-column: 1 / -1;
  }

  /* Newsletter spans both columns */
  .footer-col:last-child {
    grid-column: 1 / -1;
  }

  /* Calculators and Resources sit side-by-side (cols 2 & 3) */
  .footer-col:nth-child(2),
  .footer-col:nth-child(3) {
    grid-column: auto;
  }

  .footer-desc {
    max-width: 100%;
  }

  .newsletter-form {
    max-width: 100%;
    flex-direction: column;
  }

  .newsletter-input {
    width: 100%;
    flex: none;
  }

  .newsletter-btn {
    width: 100%;
    text-align: center;
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .footer-legal-links {
    justify-content: flex-start;
  }
}

@media (max-width: 480px) {
  .instrument {
    padding: 30px 25px 24px;
  }

  .odo-digit {
    font-size: 38px;
    line-height: 50px;
  }

  .odo-window {
    height: 50px;
  }

  .article-container,
  .page-container {
    padding: 30px 16px;
  }

  .contact-form .form-row {
    flex-direction: column;
    gap: 20px;
  }

  .footer-grid {
    gap: 20px;
  }

  .back-to-top {
    bottom: 20px;
    right: 16px;
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 374px) {
  /* Keep the same 2x2 grid structure already used on 375px+ */
  .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 24px 16px !important;
  }

  .footer-col:first-child,
  .footer-col:nth-child(2),
  .footer-col:nth-child(3),
  .footer-col:last-child {
    grid-column: auto !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  .site-footer {
    padding: 40px 12px 24px !important;
  }

  .footer-desc {
    max-width: 100% !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-size: 13px !important;
  }

  .footer-links a,
  .footer-col h3,
  .copyright,
  .footer-legal-links a {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .newsletter-form {
    width: 100% !important;
    max-width: 100% !important;
    flex-direction: column !important;
    gap: 8px !important;
  }

  .newsletter-input {
    width: 100% !important;
    flex: none !important;
    box-sizing: border-box !important;
    padding: 8px 10px !important;
    font-size: 12px !important;
  }

  .newsletter-btn {
    width: 100% !important;
    text-align: center !important;
    box-sizing: border-box !important;
    padding: 8px 10px !important;
    font-size: 12px !important;
  }

  .social-links {
    gap: 6px !important;
    flex-wrap: wrap !important;
  }

  .social-icon {
    width: 30px !important;
    height: 30px !important;
  }

  .social-icon svg {
    width: 13px !important;
    height: 13px !important;
  }

  .footer-bottom {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
    width: 100% !important;
  }

  .footer-legal-links {
    width: 100% !important;
    justify-content: flex-start !important;
    gap: 10px 14px !important;
  }

  .back-to-top {
    bottom: 16px !important;
    right: 16px !important;
  }
}

/* Reduced Motion Settings */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto !important;
  }

  .odo-digit.rolling {
    animation: none !important;
  }

  .cookie-banner {
    animation: none !important;
  }

  *,
  ::before,
  ::after {
    animation-delay: -1ms !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    background-attachment: initial !important;
    scroll-behavior: auto !important;
    transition-duration: 0s !important;
    transition-delay: 0s !important;
  }
}
