/* ============================================================
   RESPONSIVE — tablet (≤1024px) + mobile (≤768px)
   Overrides inline styles via !important under media queries.
   Mobile-first touch targets, fluid type, carousel hero rows.
   ============================================================ */

/* ---------- FLUID TYPE (all breakpoints, clamp-based) ---------- */
/* Already using clamp() on the hero headline in direction-a; add global body scale */
@media (max-width: 1024px) {
  html, body { font-size: 15px; }
}
@media (max-width: 480px) {
  html, body { font-size: 14.5px; }
}

/* Hide desktop-only elements */
@media (max-width: 1599px) {
  .hans-desktop-only { display: none !important; }
}

/* ---------- CONTAINERS ---------- */
@media (max-width: 1024px) {
  .container,
  .container-wide {
    padding: 0 20px !important;
  }
  .section { padding: 80px 0 !important; }
  .section-tight { padding: 56px 0 !important; }
}
@media (max-width: 640px) {
  .container,
  .container-wide {
    padding: 0 16px !important;
  }
  .section { padding: 64px 0 !important; }
  .section-tight { padding: 44px 0 !important; }
}

/* ---------- HEADER ---------- */
/* The mobile hamburger UI is added by JS; hide the desktop nav + CTA cluster
   on small screens and show the menu button instead. */
.mobile-menu-button { display: none; }
@media (max-width: 900px) {
  .desktop-nav-links,
  .desktop-nav-cta { display: none !important; }
  .mobile-menu-button { display: inline-flex !important; }
}

/* Desktop theme toggle — hover/focus state */
.theme-toggle-btn:hover {
  background: hsl(var(--card) / 0.8) !important;
  border-color: hsl(var(--primary) / 0.5) !important;
  color: hsl(var(--primary)) !important;
}
.theme-toggle-btn:focus-visible {
  outline: 2px solid hsl(var(--primary));
  outline-offset: 2px;
}

/* Header positions lower on mobile since direction bar shrinks too */
@media (max-width: 768px) {
  header[data-plaza-header] {
    top: 48px !important;
  }
  header[data-plaza-header] .container {
    padding: 12px 16px !important;
  }
}

/* ---------- HERO GRIDS → single column ---------- */
@media (max-width: 1024px) {
  [data-grid="hero-a"],
  [data-grid="tier-switch"],
  [data-grid="terminal-env"] {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 40px !important;
  }
  [data-grid="hero-a"] > *,
  [data-grid="tier-switch"] > *,
  [data-grid="terminal-env"] > * {
    min-width: 0 !important;
    max-width: 100% !important;
  }
}

/* ---------- TOWER (Dir A) — horizontal carousel on mobile ---------- */
/* On mobile, flip tower from vertical-stacked floors into a swipe carousel */
@media (max-width: 768px) {
  [data-tower-wrap] {
    max-width: none !important;
    margin: 0 -16px !important;
    padding: 16px 16px 28px !important;
    overflow: visible !important;
  }
  footer .container:first-child { gap: 32px !important; grid-template-columns: 1fr 1fr !important; }
[data-tower-wrap] [data-tower-floors] {
    flex-direction: row !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x mandatory !important;
    -webkit-overflow-scrolling: touch !important;
    gap: 14px !important;
    padding: 4px 8px 16px !important;
    margin: 0 -16px !important;
    scrollbar-width: none !important;
  }
  [data-tower-wrap] [data-tower-floors]::-webkit-scrollbar { display: none !important; }
  [data-tower-wrap] [data-tower-floor] {
    flex: 0 0 78vw !important;
    max-width: 320px !important;
    scroll-snap-align: center !important;
    height: 168px !important;
  }
  /* hide dimension rail, antenna, ground plate on mobile */
  [data-tower-wrap] [data-tower-dims],
  [data-tower-wrap] [data-tower-antenna],
  [data-tower-wrap] [data-tower-ground],
  [data-tower-wrap] [data-tower-shadow] {
    display: none !important;
  }
  /* Scroll hint under the carousel */
  [data-tower-wrap]::after {
    content: '← swipe through the tiers →';
    display: block;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    color: hsl(var(--muted-foreground));
    text-transform: uppercase;
    margin-top: 10px;
  }
}

/* ---------- SPEC GRID / FEATURE GRIDS ---------- */
@media (max-width: 900px) {
  [data-grid="specs-3"],
  [data-grid="features-3"],
  [data-grid="steps-3"],
  [data-grid="testimonials-3"],
  [data-grid="pain-4"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 16px !important;
  }
  [data-grid="features-3"] > * {
    border-top: 1px solid hsl(var(--border)) !important;
  }
}

@media (max-width: 560px) {
  [data-grid="specs-3"],
  [data-grid="features-3"],
  [data-grid="steps-3"],
  [data-grid="testimonials-3"],
  [data-grid="pain-4"],
  [data-grid="tiers-4"] {
    grid-template-columns: 1fr !important;
  }
}

/* ---------- LOGO BAR ---------- */
@media (max-width: 768px) {
  [data-grid="logos-6"] {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 14px !important;
  }
}

/* ---------- TIER SWITCHER SEGMENTED ---------- */
@media (max-width: 560px) {
  [data-grid="tier-seg-4"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ---------- TERMINAL / ENV STACK ---------- */
@media (max-width: 1024px) {
  [data-grid="env-tabs-4"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ---------- DECK CARDS (Dir B) — horizontal carousel on mobile ---------- */
@media (max-width: 768px) {
  [data-grid="tiers-4"][data-carousel],
  [data-grid="pain-4"][data-carousel] {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    scroll-snap-type: x mandatory !important;
    -webkit-overflow-scrolling: touch !important;
    grid-template-columns: none !important;
    gap: 12px !important;
    padding: 4px 16px 16px !important;
    margin: 0 -16px !important;
    scrollbar-width: none !important;
    max-width: none !important;
  }
  [data-grid="tiers-4"][data-carousel]::-webkit-scrollbar,
  [data-grid="pain-4"][data-carousel]::-webkit-scrollbar { display: none !important; }

  [data-grid="tiers-4"][data-carousel] > *,
  [data-grid="pain-4"][data-carousel] > * {
    flex: 0 0 80vw !important;
    max-width: 320px !important;
    scroll-snap-align: center !important;
  }

  /* scroll hint under the deck carousel */
  [data-grid="tiers-4"][data-carousel]::after,
  [data-grid="pain-4"][data-carousel]::after {
    content: '';
  }
  [data-carousel-hint]::after {
    content: '← swipe →';
    display: block;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    color: hsl(var(--muted-foreground));
    text-transform: uppercase;
    margin-top: 12px;
  }
}

/* ---------- BUTTONS — make sure 44px on all screens ---------- */
@media (max-width: 768px) {
  .btn { height: 46px !important; }
  .btn-lg { height: 52px !important; }
  .btn-sm { height: 40px !important; }
}

/* Groups of buttons (primary + outline hero) stack */
@media (max-width: 560px) {
  [data-buttons="hero"] {
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
  }
  [data-buttons="hero"] .btn { width: 100% !important; justify-content: center !important; }
}

/* ---------- HERO TYPE ---------- */
@media (max-width: 768px) {
  [data-hero-headline] {
    font-size: clamp(2.4rem, 9vw, 3.6rem) !important;
    line-height: 1.04 !important;
    letter-spacing: -0.03em !important;
  }
  [data-hero-sub] {
    font-size: 1.02rem !important;
  }
  [data-pill-row] {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
}
@media (max-width: 400px) {
  [data-hero-headline] {
    font-size: clamp(2.1rem, 10vw, 3rem) !important;
  }
}

/* ---------- TYPOGRAPHY: headings ---------- */
@media (max-width: 900px) {
  [data-section-title] {
    font-size: clamp(1.8rem, 5vw, 2.6rem) !important;
    line-height: 1.1 !important;
  }
}

/* ---------- FOOTER ---------- */
@media (max-width: 600px) {
  footer .container {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
    text-align: left !important;
  }
  footer .container > div:last-child {
    flex-wrap: wrap !important;
    gap: 14px !important;
  }
}

/* ---------- FANNED DECK HAND (Dir B hero) — carousel on mobile ---------- */
@media (max-width: 900px) {
  [data-deck-hand] {
    height: auto !important;
    display: block !important;
    margin: 20px -16px 0 !important;
  }
  [data-deck-hand] > div {
    width: auto !important;
    height: auto !important;
    display: flex !important;
    overflow-x: auto !important;
    scroll-snap-type: x mandatory !important;
    gap: 14px !important;
    padding: 32px 16px 24px !important;
    scrollbar-width: none !important;
  }
  [data-deck-hand] > div::-webkit-scrollbar { display: none !important; }
  [data-deck-hand] > div > div {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    flex: 0 0 auto !important;
    scroll-snap-align: center !important;
    transform: none !important;
    z-index: auto !important;
  }
}

/* ---------- MOBILE DRAWER ---------- */
.mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  background: hsl(var(--background) / 0.98);
  backdrop-filter: blur(28px) saturate(150%);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
  border-bottom: 1px solid hsl(var(--border));
  padding: 80px 24px 32px;
  transform: translateY(-100%);
  transition: transform 360ms cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 20px 60px -20px rgba(0,0,0,0.6);
}
.mobile-drawer[data-open="true"] {
  transform: translateY(0);
}

.mobile-drawer nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mobile-drawer nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 4px;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  text-decoration: none;
  border-bottom: 1px solid hsl(var(--border) / 0.4);
  letter-spacing: -0.01em;
}
.mobile-drawer nav a::after {
  content: '›';
  color: hsl(var(--muted-foreground));
  font-size: 1.6rem;
}
.mobile-drawer .drawer-theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
  padding: 14px 16px;
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  background: hsl(var(--card) / 0.4);
}
.mobile-drawer .drawer-theme-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
}
/* Drawer theme picker: let segmented picker wrap + expand if needed */
.mobile-drawer .drawer-theme-row > [role="group"] {
  flex: 0 1 auto;
  flex-wrap: wrap;
}
@media (max-width: 420px) {
  .mobile-drawer .drawer-theme-row {
    flex-direction: column;
    align-items: stretch;
  }
  .mobile-drawer .drawer-theme-row > [role="group"] {
    width: 100%;
    justify-content: space-between;
  }
  .mobile-drawer .drawer-theme-row > [role="group"] > button {
    flex: 1 1 0;
    justify-content: center;
  }
}

.mobile-drawer .drawer-ctas {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 28px;
}
.mobile-drawer .drawer-ctas .btn {
  justify-content: center;
  width: 100%;
  height: 48px !important;
}

/* Menu button */
.mobile-menu-button {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  align-items: center;
  justify-content: center;
  padding: 0;
}
.mobile-menu-button:active { background: hsl(var(--muted)); }

/* Scrim behind drawer */
.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(0,0,0,0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms;
}
.drawer-scrim[data-open="true"] {
  opacity: 1;
  pointer-events: auto;
}
