/* =============================================
   SOLVERSTOP — Responsive Styles
   ============================================= */

/* --- Large Desktop (≥ 1600px) — breathe on ultra-wide --- */
@media (min-width: 1600px) {
  :root {
    --container-max: 1600px;
  }
  .section-header p { max-width: 780px; }
  .hero-content { max-width: 860px; }
  .footer-brand-desc { max-width: 380px; }
}

/* --- Small Desktop / Large Laptop (≤ 1280px) --- */
@media (max-width: 1280px) {
  .footer-row1-inner { grid-template-columns: 1.4fr 1fr 1.2fr 0.8fr; }
  .card-grid-2 { gap: clamp(14px, 2vw, 24px); }
}

/* --- Tablet + Navbar Mobile (≤ 1024px) — hamburger menu --- */
@media (max-width: 1024px) {

  /* Grid adjustments */
  .card-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .card-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .card-grid-2 { grid-template-columns: repeat(2, 1fr); }
  .footer-row1-inner { grid-template-columns: 1fr 1fr; gap: 28px; }
  .footer-col-brand { grid-column: span 2; }

  /* Navbar — hide links, show hamburger */
  .nav-menu {
    display: none;
    position: fixed;
    top: 70px;
    left: 0;
    width: 100%;
    height: calc(100vh - 70px);
    background: var(--white);
    flex-direction: column;
    align-items: flex-start;
    padding: 24px 1.25rem;
    overflow-y: auto;
    gap: 0;
    border-top: 1px solid var(--grey-border);
    z-index: 998;
  }
  .nav-menu.open { display: flex; }
  .nav-hamburger { display: flex; }

  .nav-item { width: 100%; }
  .nav-link {
    width: 100%;
    padding: 14px 12px;
    font-size: 1rem;
    border-radius: 0;
    border-bottom: 1px solid var(--grey-border);
    justify-content: space-between;
  }
  .nav-link-cta {
    margin-top: 16px;
    border-radius: var(--radius);
    justify-content: center;
    border-bottom: none;
  }
  .nav-item-lang {
    margin-left: 0 !important;
    margin-top: 12px;
  }
  .nav-link-lang {
    border: none !important;
    padding: 14px 12px !important;
    font-size: 1rem !important;
    border-bottom: 1px solid var(--grey-border) !important;
    border-radius: 0 !important;
  }
  .dropdown-lang {
    left: 0 !important;
    right: auto;
  }

  /* Dropdown mobile */
  .dropdown {
    position: static;
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 0 0 0 16px;
    opacity: 1;
    visibility: visible;
    transform: none;
    background: var(--grey-light);
    display: none;
  }
  .dropdown.open { display: block; }
  .dropdown-item {
    border-bottom: 1px solid var(--grey-border);
    padding: 12px 16px;
    font-size: 0.92rem;
    color: var(--black);
    white-space: normal;
  }
  .dropdown-item:hover {
    background: var(--gold-light);
    color: var(--gold);
  }
  .dropdown-item.dropdown-item-overview {
    background: var(--grey-light);
    color: var(--black);
    font-weight: 700;
    margin: 0;
    border-radius: 0;
    border-bottom: 1px solid var(--grey-border);
  }
  .dropdown-item.dropdown-item-overview:hover {
    color: var(--gold);
    background: var(--gold-light);
  }
  .dropdown-divider {
    display: none;
  }
}

/* --- Tablet / Large Mobile (≤ 768px) --- */
@media (max-width: 768px) {

  /* CRITICAL: Disable scroll-snap on main element used by subpages
     This prevents content from being trapped in a viewport-height
     scroll container where overflow causes section overlap. */
  main {
    scroll-snap-type: none !important;
    height: auto !important;
    overflow-y: visible !important;
  }
  /* Also disable on html (used by homepage) */
  html {
    scroll-snap-type: none !important;
  }

  /* Cards */
  .card-grid-2,
  .card-grid-3,
  .card-grid-4 { grid-template-columns: 1fr; }

  /* Hero — buttons stack */
  .hero-buttons { flex-direction: column; align-items: flex-start; }
  .hero-buttons .btn { width: 100%; justify-content: center; }

  /* Button text wrapping on mobile */
  .btn { white-space: normal; text-align: center; }

  /* Cards — ensure min-width:0 for flex children to prevent overflow */
  .card { min-width: 0; }

  /* Footer row 1 columns */
  .footer-row1-inner {
    grid-template-columns: 1fr;
    gap: 36px;
    text-align: center;
  }
  .footer-col-brand { display: flex; flex-direction: column; align-items: center; grid-column: span 1; }
  .footer-brand-desc { max-width: 100%; }

  /* Footer row 2 */
  .footer-row2-inner {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
  }
  .footer-bottom-left { flex-direction: column; align-items: center; gap: 10px; }
  .footer-bottom-right { justify-content: center; }
  .lang-toggle-wrap { justify-content: center; }
  .footer-social { justify-content: center; }

  /* Disable hover-only transform effects on touch (prevents stuck states) */
  .card:hover { transform: none; }
  .partner-card:hover { transform: none; }

  /* Ensure all interactive elements have proper touch targets */
  .learn-more { min-height: 44px; display: inline-flex; align-items: center; }

  /* Hero note — prevent overflow */
  .hero-note { max-width: 100%; }
}

/* --- Small Mobile (≤ 480px) --- */
@media (max-width: 480px) {
  .btn-lg { padding: 14px 24px; font-size: 0.95rem; }

  /* Buttons — full width on small phones */
  .hero-buttons { flex-direction: column; align-items: stretch; }
  .hero-buttons .btn { width: 100%; justify-content: center; }

  /* Prevent text overflow in constrained containers */
  .container { overflow-wrap: break-word; }

  /* CTA strip text — prevent overflow */
  .cta-strip p { max-width: 100%; }
  .cta-strip h2 { font-size: clamp(1.2rem, 4vw, 1.6rem); }
}

/* =============================================
   ARTICLE PAGES — Mobile Fixes
   Addresses inline styles (flex:0 0 300px) that
   cause horizontal overflow on small screens.
   ============================================= */
@media (max-width: 768px) {
  /* Section-intro flex layout — stack on mobile */
  .section-intro [style*="display:flex"][style*="gap:40px"] {
    flex-direction: column !important;
    gap: 24px !important;
  }
  /* Left metadata column — full width on mobile */
  .section-intro [style*="flex:0 0 300px"] {
    flex: 1 1 100% !important;
    min-width: 0 !important;
  }
  /* Right summary column — remove left border, add top border on mobile */
  .section-intro [style*="border-left:3px solid"] {
    border-left: none !important;
    padding-left: 0 !important;
    border-top: 3px solid var(--gold) !important;
    padding-top: 16px !important;
    min-width: 0 !important;
  }
  /* Article section — auto height on mobile */
  .article-section {
    min-height: auto !important;
    padding: 36px 0 !important;
  }
  /* Article hero image — shorter on mobile */
  .article-hero-img {
    height: 200px !important;
  }
  /* Pillar cards — stack vertically */
  .pillar-row {
    flex-direction: column !important;
  }
  /* Sticky bar — compact on mobile */
  .article-sticky-inner {
    gap: 8px !important;
  }
  .article-sticky-meta {
    display: none !important;
  }
  .article-sticky-title {
    font-size: 0.72rem !important;
  }
  /* Chapter nav blocks — scrollable row */
  .article-sticky-chapters {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px !important;
  }
  .article-sticky-chapters::-webkit-scrollbar { display: none; }
  .article-sticky-chapters button {
    font-size: 0.64rem !important;
    padding: 4px 10px !important;
    white-space: nowrap !important;
    min-height: 36px;
  }
  /* Snap section 1 hero — auto height
     NOTE: On solution subpages, solution-journey.css loads AFTER this file
     and provides more detailed .snap-section-1 overrides (flex column layout,
     4 breakpoints). These rules here serve ARTICLE pages which do NOT load
     solution-journey.css. */
  .snap-section-1 {
    min-height: auto !important;
    height: auto !important;
    display: block !important;
    scroll-snap-align: none !important;
  }
  .snap-section-1 .page-hero {
    height: auto !important;
    min-height: 0 !important;
    padding: 32px 0 24px !important;
  }
  .snap-section-1 .page-hero h1 {
    font-size: clamp(1.4rem, 5vw, 2rem) !important;
    line-height: 1.3 !important;
    overflow-wrap: break-word;
    word-break: normal;
  }
  .snap-section-1 .page-hero p {
    font-size: 0.88rem !important;
  }
  .snap-section-1 .section-intro {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    padding: 28px 0 !important;
  }
  .snap-section-1 .hero-img-banner {
    height: 200px !important;
  }
  /* Article close CTA */
  .article-close {
    padding: 32px 16px !important;
  }

  /* --- Solutions overview page (solutions/index.html) --- */
  /* Solution rows — stack on mobile */
  .sol-row-inner {
    flex-direction: column !important;
    gap: 20px !important;
  }
  .sol-row-inner > * {
    max-width: 100% !important;
    flex: 1 1 100% !important;
  }
  .sol-row.reverse .sol-row-inner {
    flex-direction: column !important;
  }

  /* --- Partners page --- */
  .partner-card {
    padding: 20px 16px !important;
  }

  /* --- Contact page form --- */
  .form-row {
    grid-template-columns: 1fr !important;
  }

  /* --- Company pages (about, values, global-presence) --- */
  .expand-card,
  .value-card {
    padding: 20px 16px !important;
  }

  /* --- Legal pages --- */
  .legal-section {
    padding: 32px 0 !important;
  }
}

/* =============================================
   ARTICLE PAGES — Fine-grained breakpoints
   These complement the 768px block above with
   tighter spacing for modern phones.
   ============================================= */

/* --- iPhone 12 / Modern phones (≤ 430px) --- */
@media (max-width: 430px) {
  .snap-section-1 .page-hero {
    padding: 24px 0 18px !important;
  }
  .snap-section-1 .page-hero h1 {
    font-size: clamp(1.25rem, 5vw, 1.7rem) !important;
    line-height: 1.35 !important;
    margin-bottom: 12px !important;
  }
  .snap-section-1 .page-hero p {
    font-size: 0.84rem !important;
    line-height: 1.6 !important;
  }
  .snap-section-1 .page-hero .breadcrumb {
    font-size: 0.75rem !important;
    margin-bottom: 10px !important;
  }
  .snap-section-1 .section-intro {
    padding: 20px 0 !important;
  }
  .snap-section-1 .hero-img-banner {
    height: 160px !important;
  }

  /* Article sticky bar — smaller on narrow phones */
  .article-sticky-title {
    font-size: 0.68rem !important;
  }
  .article-sticky-chapters button {
    font-size: 0.6rem !important;
    padding: 3px 8px !important;
  }

  /* Article intro two-column — tighter spacing */
  .section-intro [style*="display:flex"][style*="gap:40px"] {
    gap: 18px !important;
  }
  .section-intro [style*="border-left:3px solid"] {
    padding-top: 12px !important;
  }

  /* Article hero image — shorter */
  .article-hero-img {
    height: 160px !important;
  }

  /* Article close CTA — compact */
  .article-close {
    padding: 24px 12px !important;
  }
  .article-close h2 {
    font-size: clamp(1.1rem, 4vw, 1.4rem) !important;
  }

  /* Solutions overview — tighter on narrow phones */
  .sol-row-inner {
    gap: 16px !important;
  }

  /* Partner cards */
  .partner-card {
    padding: 16px 12px !important;
  }

  /* Legal pages */
  .legal-section {
    padding: 24px 0 !important;
  }
}

/* --- Small phones (≤ 375px) — iPhone SE --- */
@media (max-width: 375px) {
  .snap-section-1 .page-hero {
    padding: 20px 0 16px !important;
  }
  .snap-section-1 .page-hero h1 {
    font-size: 1.2rem !important;
    line-height: 1.35 !important;
  }
  .snap-section-1 .page-hero p {
    font-size: 0.82rem !important;
  }
  .snap-section-1 .section-intro {
    padding: 16px 0 !important;
  }
  .snap-section-1 .hero-img-banner {
    height: 140px !important;
  }

  /* Article hero image */
  .article-hero-img {
    height: 140px !important;
  }

  /* Sticky bar chapters — even more compact */
  .article-sticky-chapters button {
    font-size: 0.56rem !important;
    padding: 3px 6px !important;
    min-height: 32px;
  }

  /* CTA strip text */
  .final-cta-intro h2 {
    font-size: clamp(1.1rem, 4vw, 1.4rem) !important;
  }
  .final-cta-intro p {
    font-size: 0.88rem !important;
  }
}

/* --- Very small phones (≤ 320px) — iPhone 5/SE 1st gen --- */
@media (max-width: 320px) {
  .snap-section-1 .page-hero h1 {
    font-size: 1.1rem !important;
  }
  .snap-section-1 .hero-img-banner {
    height: 120px !important;
  }
  .article-hero-img {
    height: 120px !important;
  }

  /* Ensure container padding doesn't eat into content */
  .container {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
}
