/* =========================================================
   Automatek — Responsive overrides
   --------------------------------------------------------
   Every rule in this file lives inside a media query that
   ONLY matches viewports < 1024px wide. Desktop (≥1024px)
   gets zero CSS from this file — the existing inline-styled
   layout is preserved exactly as designed.
   ========================================================= */


/* ===============================================================
   TABLET   — 1023.98px and below
   =============================================================== */
@media (max-width: 1023.98px) {

  /* No horizontal scroll allowed on narrow screens */
  html, body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
  }

  /* Grid + flex children shrink to fit (default min-width: auto causes overflow) */
  [style*="display: grid"] > *,
  [style*="display:grid"] > *,
  [style*="display: flex"] > *,
  [style*="display:flex"] > * {
    min-width: 0 !important;
  }

  /* ----- SECTION PADDING -----
     Desktop sections use 96–128px vertical and 24px horizontal.
     Compress to keep content readable on narrow screens. */
  section {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }
  section[style*="padding: 120px"],
  section[style*="padding: 128px"],
  section[style*="padding: 112px"] {
    padding-top: 64px !important;
    padding-bottom: 64px !important;
  }
  section[style*="padding: 96px"],
  section[style*="padding: 88px"],
  section[style*="padding: 80px"] {
    padding-top: 48px !important;
    padding-bottom: 48px !important;
  }
  section[style*="padding: 64px"] {
    padding-top: 40px !important;
    padding-bottom: 40px !important;
  }

  /* ----- MAX WIDTHS + INNER PADDING -----
     Let content fill the viewport at narrow widths and remove the
     redundant 24px horizontal padding the inner content wrappers have
     (the outer section already provides padding). */
  div[style*="max-width: var(--max-w-marketing)"] {
    max-width: 100% !important;
  }
  div[style*="padding: 88px 24px"],
  div[style*="padding: 96px 24px"],
  div[style*="padding: 112px 24px"],
  div[style*="padding: 120px 24px"],
  div[style*="padding: 128px 24px"],
  div[style*="padding: 64px 24px"],
  div[style*="padding: 48px 24px"],
  div[style*="padding: 32px 24px"],
  div[style*="padding: '0 24px'"] {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* ----- MULTI-COLUMN GRIDS → 2 COLUMNS -----
     Inline styles like grid-template-columns: repeat(3, 1fr) etc.
     We force them to 2 columns on tablet. */
  [style*="grid-template-columns: repeat(3, 1fr)"],
  [style*="grid-template-columns: repeat(4, 1fr)"],
  [style*="grid-template-columns: repeat(5, 1fr)"],
  [style*="grid-template-columns: repeat(6, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Footer 6-col mega grid → 2 col on tablet */
  [style*="grid-template-columns: 2fr 1fr 1fr 1fr 1fr"],
  [style*="grid-template-columns: 2fr 1fr 1fr 1fr 1.1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 32px !important;
  }

  /* ----- 2-COLUMN HERO/SPLIT LAYOUTS → STACK -----
     Many heroes use unequal 2-col grids (1.1fr 0.9fr, 1.2fr 0.8fr,
     0.95fr 1.05fr, etc.). Stack them. */
  [style*="grid-template-columns: 1.1fr"],
  [style*="grid-template-columns: 1.15fr"],
  [style*="grid-template-columns: 1.2fr"],
  [style*="grid-template-columns: 1.25fr"],
  [style*="grid-template-columns: 1.3fr"],
  [style*="grid-template-columns: 1.4fr"],
  [style*="grid-template-columns: 1.05fr"],
  [style*="grid-template-columns: 0.95fr"],
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Photo-sidebar layouts (cards with fixed-width image rail) → stack */
  [style*="grid-template-columns: 220px"],
  [style*="grid-template-columns: 200px"],
  [style*="grid-template-columns: 180px"],
  [style*="grid-template-columns: 160px"],
  [style*="grid-template-columns: 140px"] {
    grid-template-columns: 1fr !important;
  }

  /* Process timeline 60px/280px/1fr — stack */
  [style*="grid-template-columns: 60px"] {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  /* Blog post list cards (160px sidebar + 1fr + auto) → stack metadata */
  [style*="grid-template-columns: 160px 1fr auto"] {
    grid-template-columns: 1fr !important;
  }

  /* ----- HERO FONT SIZES -----
     Massive 56-84px h1s scale down to readable sizes */
  h1[style*="font-size: 84"],
  h1[style*="font-size: 76"],
  h1[style*="font-size: 72"],
  h1[style*="font-size: 68"],
  h1[style*="font-size: 64"],
  h1[style*="font-size: 60"],
  h1[style*="font-size: 56"],
  h1[style*="font-size: 52"] {
    font-size: 44px !important;
    line-height: 1.08 !important;
    letter-spacing: -0.02em !important;
  }

  h2[style*="font-size: 56"],
  h2[style*="font-size: 52"],
  h2[style*="font-size: 48"] {
    font-size: 36px !important;
    line-height: 1.1 !important;
  }

  h3[style*="font-size: 52"],
  h3[style*="font-size: 48"],
  h3[style*="font-size: 38"],
  h3[style*="font-size: 36"] {
    font-size: 28px !important;
    line-height: 1.15 !important;
  }

  /* Display classes from colors_and_type.css */
  .display-xl { font-size: 48px !important; line-height: 1.1 !important; }
  .display-lg { font-size: 40px !important; line-height: 1.1 !important; }
  .display-md { font-size: 30px !important; line-height: 1.15 !important; }
  .h1         { font-size: 30px !important; }
  .h2         { font-size: 24px !important; }

  /* ----- BIG NUMERIC DISPLAYS (pricing, hero stats) ----- */
  div[style*="font-size: 56"][style*="font-weight: 600"],
  div[style*="font-size: 48"][style*="font-weight: 600"] {
    font-size: 38px !important;
  }

  /* ----- MIN-HEIGHTS -----
     Heroes with min-height: 680px etc. — let them shrink */
  [style*="min-height: 680"],
  [style*="min-height: 620"],
  [style*="min-height: 560"],
  [style*="min-height: 480"],
  [style*="min-height: 460"] {
    min-height: auto !important;
  }

  /* ----- DECORATIVE RIGHT-COLUMN CARDS -----
     The floating "live ops" cards in heroes are decorative.
     Hide on tablet to keep hero compact. */
  section[style*="position: relative"] div[style*="rgba(17,19,22"][style*="backdropFilter"],
  section[style*="position: relative"] div[style*="rgba(17, 19, 22"] {
    /* keep these — they're useful at tablet width with stacked layout */
  }

  /* ----- BLOG POST CARDS -----
     The blog card with grid 160px / 1fr / auto — stack everything */
  a[style*="grid-template-columns: 160px"] {
    grid-template-columns: 1fr !important;
  }

  /* ----- PORTFOLIO + SERVICE CARDS WITH IMAGE RAIL -----
     Web-design portfolio cards use grid 220px+1fr — stack */
  a[style*="grid-template-columns: 220px"],
  a[style*="grid-template-columns: 180px"] {
    grid-template-columns: 1fr !important;
  }

  /* ----- HOMEPAGE INTHEFIELD (carousel) -----
     The carousel uses absolute-positioned slides with 640px height.
     Reduce height. */
  section[style*="height: 640"] {
    /* selector might not match because height is on inner div */
  }

  /* ----- NAV — TABLET BEHAVIOR -----
     We rely on a class hook the JSX adds. Hide horizontal nav items,
     hide the phone pill text. The hamburger button (added in JSX)
     becomes visible. */
  .atk-nav-items, .atk-nav-spacer, .atk-nav-phone, .atk-nav-cta {
    display: none !important;
  }
  .atk-nav-hamburger {
    display: inline-flex !important;
  }

  /* Hide horizontal nav items in the STICKY desktop nav only.
     This MUST NOT match items inside the mobile drawer (which is also
     a <nav>). Scope to nav with sticky positioning in its inline style. */
  nav[style*="position: sticky"] > div > div:not(:first-child),
  nav[style*="position: sticky"] > div > a:not(:first-of-type) {
    display: none !important;
  }
}


/* ===============================================================
   PHONE   — 639.98px and below
   =============================================================== */
@media (max-width: 639.98px) {

  /* Universal box-sizing on phone */
  *, *::before, *::after {
    box-sizing: border-box !important;
  }

  /* Grid + flex children must shrink within their container.
     min-width: auto is the default and lets children overflow.
     min-width: 0 forces them to respect the cell width. */
  [style*="display: grid"] > *,
  [style*="display:grid"] > *,
  [style*="display: flex"] > *,
  [style*="display:flex"] > * {
    min-width: 0 !important;
  }

  /* All block-level text content respects parent width */
  h1, h2, h3, h4, h5, p, span, a, div, ul, ol, li, blockquote {
    max-width: 100% !important;
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
  }

  /* Universal font cap — anything sized 30px+ inline gets capped */
  [style*="font-size: 84"], [style*="font-size: 76"], [style*="font-size: 72"],
  [style*="font-size: 68"], [style*="font-size: 64"], [style*="font-size: 60"],
  [style*="font-size: 56"], [style*="font-size: 52"], [style*="font-size: 48"],
  [style*="font-size: 44"], [style*="font-size: 40"], [style*="font-size: 38"],
  [style*="font-size: 36"], [style*="font-size: 32"] {
    font-size: 26px !important;
    line-height: 1.15 !important;
    letter-spacing: -0.01em !important;
  }

  /* Force EVERY grid to single column */
  [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  /* Tighter padding */
  section {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
  section[style*="padding: 120px"],
  section[style*="padding: 128px"],
  section[style*="padding: 112px"],
  section[style*="padding: 96px"],
  section[style*="padding: 88px"] {
    padding-top: 44px !important;
    padding-bottom: 44px !important;
  }

  /* Smaller hero text on phone */
  h1[style*="font-size:"] {
    font-size: 28px !important;
    line-height: 1.1 !important;
    letter-spacing: -0.02em !important;
  }
  h2[style*="font-size:"] {
    font-size: 22px !important;
    line-height: 1.2 !important;
  }
  h3[style*="font-size:"] {
    font-size: 20px !important;
  }
  .display-xl { font-size: 32px !important; line-height: 1.1 !important; }
  .display-lg { font-size: 28px !important; line-height: 1.1 !important; }
  .display-md { font-size: 24px !important; line-height: 1.15 !important; }
  .h1 { font-size: 24px !important; }
  .h2 { font-size: 20px !important; }

  /* Body / paragraph text */
  p[style*="font-size: 20"], p[style*="font-size: 19"], p[style*="font-size: 18"], p[style*="font-size: 17"] {
    font-size: 15px !important;
    line-height: 1.55 !important;
  }
  .body-lg { font-size: 15px !important; line-height: 1.55 !important; }

  /* Constrain images that have fixed widths */
  img {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Big stat numbers shrink */
  div[style*="font-size: 56"],
  div[style*="font-size: 52"],
  div[style*="font-size: 48"],
  div[style*="font-size: 38"][style*="font-weight: 500"] {
    font-size: 30px !important;
  }

  /* Buttons / pricing card — full width on phone */
  div[style*="display: flex"][style*="gap: 12"] > a[href*="contact"],
  div[style*="display: flex"][style*="gap: 12"] > a[href*="web-design-portfolio"] {
    flex: 1 1 100% !important;
  }

  /* Cards keep their padding but tighter */
  div[style*="padding: 40px 36"],
  div[style*="padding: 36px 36"],
  div[style*="padding: 32px 36"] {
    padding: 24px 22px !important;
  }
  div[style*="padding: 28px 30"],
  div[style*="padding: 28px 32"],
  div[style*="padding: 26px 28"] {
    padding: 22px 20px !important;
  }

  /* Blog card vertical spacing tighter */
  a[href^="#/blog/"] {
    padding: 20px !important;
  }

  /* Pagination wraps cleanly */
  nav[aria-label="Blog pagination"] {
    gap: 4px !important;
  }
  nav[aria-label="Blog pagination"] button {
    min-width: 32px !important;
    padding: 6px 8px !important;
    font-size: 11px !important;
  }

  /* Footer stacks fully */
  footer > div > div:first-child {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
  }
  footer > div > div:nth-child(2) {
    flex-direction: column !important;
    gap: 12px !important;
    text-align: center !important;
  }

  /* Breadcrumbs wrap */
  ol[style*="flex-wrap"] {
    font-size: 10px !important;
  }

  /* Tighter spacing for inline gaps */
  div[style*="gap: 64"] { gap: 32px !important; }
  div[style*="gap: 48"] { gap: 24px !important; }
}


/* ===============================================================
   NAV HAMBURGER + MOBILE DRAWER
   --------------------------------------------------------
   The hamburger button + drawer are added by the JSX. They use
   classes we set up here:
     .atk-nav-hamburger    — the hamburger button
     .atk-mobile-drawer    — the slide-in menu
     .atk-mobile-drawer.is-open — drawer visible
     .atk-mobile-overlay   — dim backdrop
   At desktop these are always display:none so they have zero
   effect on the existing layout.
   =============================================================== */

/* Default (desktop): hide the hamburger + drawer entirely */
.atk-nav-hamburger,
.atk-mobile-drawer,
.atk-mobile-overlay {
  display: none !important;
}

@media (max-width: 1023.98px) {
  .atk-nav-hamburger {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--border-default);
    color: var(--fg-1);
    cursor: pointer;
    margin-left: auto;
    transition: all 150ms;
  }
  .atk-nav-hamburger:hover {
    border-color: var(--border-accent);
    background: var(--accent-muted);
    color: var(--accent);
  }

  .atk-mobile-overlay {
    display: block !important;
    position: fixed;
    inset: 0;
    background: rgba(10, 11, 13, 0.6);
    backdrop-filter: blur(4px);
    z-index: 49;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
  }
  .atk-mobile-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .atk-mobile-drawer {
    /* Default closed: completely removed from layout to prevent overflow */
    display: none !important;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 84%;
    max-width: 380px;
    background: linear-gradient(180deg, rgba(20,22,26,0.98), rgba(10,11,13,0.96));
    border-left: 1px solid rgba(255,255,255,0.08);
    box-shadow: -16px 0 40px rgba(0,0,0,0.5);
    backdrop-filter: saturate(180%) blur(22px);
    z-index: 50;
    flex-direction: column;
    overflow-y: auto;
    padding: 0;
    animation: atkDrawerIn 240ms var(--ease-out-expo, cubic-bezier(0.22,1,0.36,1));
  }
  .atk-mobile-drawer.is-open {
    display: flex !important;
  }
  @keyframes atkDrawerIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
  }

  .atk-mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 22px;
    border-bottom: 1px solid var(--border-subtle);
  }
  .atk-mobile-drawer-close {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--fg-1);
    cursor: pointer;
  }

  .atk-mobile-drawer-list {
    display: flex;
    flex-direction: column;
    padding: 12px 14px;
    gap: 2px;
  }
  .atk-mobile-drawer-list a,
  .atk-mobile-drawer-list button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 8px;
    color: var(--fg-1);
    font-size: 15px;
    font-weight: 500;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background 120ms;
  }
  .atk-mobile-drawer-list a:hover,
  .atk-mobile-drawer-list button:hover {
    background: var(--bg-3);
  }
  .atk-mobile-drawer-list .group-label {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--fg-3);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 18px 14px 6px;
  }
  .atk-mobile-drawer-list .sub a {
    padding-left: 28px;
    font-size: 14px;
    color: var(--fg-2);
  }

  .atk-mobile-drawer-footer {
    margin-top: auto;
    padding: 18px 22px 28px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .atk-mobile-drawer-footer a.phone {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-default);
    color: var(--fg-1);
    font-family: var(--font-mono);
    font-size: 13px;
    background: transparent;
  }
  .atk-mobile-drawer-footer a.cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 8px;
    background: var(--accent);
    color: var(--accent-fg);
    font-weight: 600;
    font-size: 14px;
  }

  /* When the drawer is open, lock body scroll */
  body.atk-no-scroll {
    overflow: hidden !important;
  }
}
