/* =============================================================================
   TOFFEHA — RESPONSIVE
   Mobile-first breakpoint overrides: sm 640px, md 768px, lg 1024px, xl 1280px
   ============================================================================= */

/* ---------------------------------------------------------------------------
   Base / mobile defaults
   (These are already set mobile-first in the other files — this file adds
   the overrides that kick in at larger screens where needed, plus the
   mobile-specific overrides below 640px.)
   --------------------------------------------------------------------------- */

/* ---------------------------------------------------------------------------
   Below 1024px — lg breakpoint
   Collapse multi-column layouts to single-column
   --------------------------------------------------------------------------- */
@media (max-width: 1023px) {

  /* Marketplace: hide sidebar filters, go single-column */
  .toffeha-marketplace-layout {
    grid-template-columns: 1fr;
  }

  /* Marketplace filters become offcanvas drawer */
  .toffeha-marketplace-filters {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(360px, 90vw);
    z-index: var(--z-overlay);
    background: var(--surface);
    box-shadow: var(--shadow-xl);
    transform: translateX(-110%);
    transition: transform var(--dur-base) var(--ease-entrance);
    border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
    max-height: 100vh;
    overflow-y: auto;
    padding: var(--space-6);
  }

  .toffeha-marketplace-filters.is-open {
    transform: translateX(0);
  }

  /* Dashboard: collapse sidebar to slide-in drawer */
  .toffeha-dashboard-layout {
    grid-template-columns: 1fr;
  }

  .toffeha-dashboard-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 85vw);
    z-index: var(--z-modal);
    transform: translateX(-110%);
    transition: transform var(--dur-base) var(--ease-entrance);
    height: auto;
  }

  .toffeha-dashboard-sidebar.is-open {
    transform: translateX(0);
  }

  /* Plan detail: stack buy panel below content */
  .toffeha-plan-layout {
    grid-template-columns: 1fr;
  }

  .toffeha-plan-buy-panel {
    position: static;
  }

  /* Hero split / editorial: go single column */
  .toffeha-hero--split .toffeha-hero__content,
  .toffeha-hero--editorial .toffeha-hero__content {
    grid-template-columns: 1fr;
    max-width: 720px;
  }

  /* 4-column grids collapse to 2 */
  .toffeha-grid--4 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Analytics row: 2 columns */
  .toffeha-analytics-row {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Header nav hidden on smaller screens */
  .toffeha-header__nav {
    display: none;
  }
}

/* ---------------------------------------------------------------------------
   Below 768px — md breakpoint
   --------------------------------------------------------------------------- */
@media (max-width: 767px) {

  /* 3 and 4 column grids → 2 columns */
  .toffeha-grid--3,
  .toffeha-grid--4 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Analytics: 2 columns */
  .toffeha-analytics-row {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Hero shorter on tablets */
  .toffeha-hero {
    min-height: 70vh;
  }

  /* Sections slightly tighter */
  .toffeha-section {
    padding-top: var(--space-9);    /* 64px */
    padding-bottom: var(--space-9);
  }

  .toffeha-section--lg {
    padding-top: var(--space-10);
    padding-bottom: var(--space-10);
  }

  /* Dashboard main: reduce horizontal padding */
  .toffeha-dashboard-main {
    padding: var(--space-5) var(--space-5);
  }

  /* Sort bar: stack on small viewports */
  .toffeha-sort-bar {
    flex-wrap: wrap;
    gap: var(--space-3);
  }

  /* Plan card grid gap tighten */
  .toffeha-grid {
    gap: var(--space-4);
  }

  /* Profile hero ratio looser */
  .toffeha-profile-hero {
    aspect-ratio: 3 / 1;
  }

  /* Section header: stack */
  .toffeha-section-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ---------------------------------------------------------------------------
   Below 640px — sm breakpoint (true mobile)
   --------------------------------------------------------------------------- */
@media (max-width: 639px) {

  /* All multi-column grids → single column */
  .toffeha-grid--2,
  .toffeha-grid--3,
  .toffeha-grid--4 {
    grid-template-columns: 1fr;
  }

  /* Analytics → single column stacked */
  .toffeha-analytics-row {
    grid-template-columns: 1fr;
  }

  /* Smaller auto-fill card min-width */
  .toffeha-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  /* Search hero: tighter radius */
  .toffeha-search-hero {
    border-radius: var(--radius-lg);
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
    padding: var(--space-4);
  }

  .toffeha-search-hero__divider {
    width: 100%;
    height: 1px;
  }

  /* Shorter header on mobile */
  .toffeha-header {
    height: 60px;
  }

  /* Sticky buy panel at bottom on mobile */
  .toffeha-buy-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    z-index: var(--z-overlay);
    box-shadow: var(--shadow-xl);
    max-height: 80vh;
    overflow-y: auto;
    padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
  }

  /* Greeting smaller name on mobile */
  .toffeha-dash-greeting__name {
    font-size: var(--text-xl);
  }

  /* Plan detail: full-width buy action bar at bottom already covered by
     .toffeha-buy-panel fixed positioning above */

  /* Section tighter */
  .toffeha-section {
    padding-top: var(--space-8);
    padding-bottom: var(--space-8);
  }

  .toffeha-section--sm {
    padding-top: var(--space-6);
    padding-bottom: var(--space-6);
  }

  .toffeha-section--lg {
    padding-top: var(--space-9);
    padding-bottom: var(--space-9);
  }

  /* Hero height */
  .toffeha-hero {
    min-height: 60vh;
  }

  /* Creator card stats row — allow wrapping */
  .toffeha-creator-card__stats {
    gap: var(--space-2);
  }

  /* Empty state less padding */
  .toffeha-empty {
    padding: var(--space-9) var(--space-5);
  }

  /* Dashboard main padding */
  .toffeha-dashboard-main {
    padding: var(--space-4);
  }

  /* Profile avatar smaller */
  .toffeha-profile-avatar {
    width: 72px;
    height: 72px;
    bottom: -36px;
  }

  .toffeha-profile-info {
    padding-top: calc(36px + var(--space-4));
  }

  /* Shrink buy panel price on tiny screens */
  .toffeha-buy-panel__price {
    font-size: var(--text-2xl);
  }
}

/* ---------------------------------------------------------------------------
   Mobile Menu (.toffeha-mobile-menu)
   Full-screen overlay drawer with glass background
   --------------------------------------------------------------------------- */
.toffeha-mobile-menu {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: var(--glass-bg-dark);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  transform: translateX(100%);
  transition: transform var(--dur-base) var(--ease-entrance);
  display: flex;
  flex-direction: column;
  padding: var(--space-6);
  overflow-y: auto;
}

.toffeha-mobile-menu.is-open {
  transform: translateX(0);
}

.toffeha-mobile-menu__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.toffeha-mobile-menu__close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: var(--text-on-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toffeha-mobile-menu__nav {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
}

.toffeha-mobile-menu__nav a {
  display: block;
  padding: var(--space-4);
  font-size: var(--text-lg);
  font-weight: var(--fw-semibold);
  color: var(--text-on-dark);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: background var(--dur-fast);
}

.toffeha-mobile-menu__nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  text-decoration: none;
}

.toffeha-mobile-menu__footer {
  padding-top: var(--space-6);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Safe-area spacing for phones with notches */
@supports (padding: env(safe-area-inset-bottom)) {
  .toffeha-mobile-menu {
    padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
  }

  .toffeha-buy-panel {
    padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
  }
}

/* =============================================================================
   MOBILE / TABLET REFINEMENTS (added Jun 2026)
   Homepage hero + mobile menu — elegant, decluttered.
   ============================================================================= */

/* --- Homepage hero on tablet & mobile --- */
@media (max-width: 1023px) {
  /* Decorative floating chips (Djerba pill, 184km route, compass orb, sparkles)
     are positioned in the desktop right gutter; on narrower screens they collide
     with the headline and the Search button. They are aria-hidden, so hide them. */
  .toffeha-hero__floats { display: none !important; }
}

@media (max-width: 767px) {
  .toffeha-hero--fullbleed .toffeha-hero__inner { padding-left: 22px; padding-right: 22px; }
  .toffeha-hero__title { font-size: clamp(2.05rem, 8.2vw, 2.85rem); line-height: 1.12; }
  .toffeha-hero__subtitle { font-size: 1.02rem; line-height: 1.6; max-width: 42ch; }
  .toffeha-hero__stats { gap: 1rem 1.4rem; flex-wrap: wrap; }
  .toffeha-hero__copy { padding-bottom: 6px; }
}

/* --- Mobile menu: elegant accordion (matches header-template.php markup) --- */
.toffeha-mobile-menu {
  background: linear-gradient(165deg, #0E2042 0%, #0a1a37 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  gap: 0;
}
.toffeha-mobile-menu__header { margin-bottom: var(--space-5); }
.toffeha-mobile-menu .toffeha-header__wordmark { color: #fff; font-weight: 800; }
.toffeha-mobile-menu .toffeha-header__wordmark-a { color: var(--brand, #E11217); }
.toffeha-mobile-menu__close-btn {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  background: #fff; color: var(--ink, #0E2042); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.toffeha-mobile-menu__nav { display: flex; flex-direction: column; flex: 1; }
.toffeha-mobile-menu__acc { border-bottom: 1px solid rgba(255, 255, 255, 0.10); }
.toffeha-mobile-menu__acc summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  padding: 17px 2px; color: #fff; font-size: 1.15rem; font-weight: 700;
}
.toffeha-mobile-menu__acc summary::-webkit-details-marker { display: none; }
.toffeha-mobile-menu__acc summary svg {
  color: rgba(255, 255, 255, 0.5); flex: none;
  transition: transform 0.25s var(--ease-entrance, ease), color 0.2s;
}
.toffeha-mobile-menu__acc[open] summary svg { transform: rotate(180deg); color: var(--brand, #E11217); }
.toffeha-mobile-menu__acc-body { padding: 0 2px 14px; }
.toffeha-mobile-menu__group {
  font-family: var(--font-mono, ui-monospace, monospace);
  text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.66rem;
  color: rgba(255, 255, 255, 0.45); margin: 14px 0 4px;
}
.toffeha-mobile-menu__nav a,
.toffeha-mobile-menu__sublink {
  display: block; padding: 9px 2px; border-radius: 8px;
  color: rgba(255, 255, 255, 0.80); font-size: 1rem; font-weight: 500;
  text-decoration: none; transition: color var(--dur-fast, 0.15s);
}
.toffeha-mobile-menu__nav a:hover,
.toffeha-mobile-menu__sublink:hover { color: #fff; background: transparent; text-decoration: none; }
.toffeha-mobile-menu__ctas {
  margin-top: auto; padding-top: var(--space-5);
  display: flex; flex-direction: column; gap: 12px;
}
.toffeha-mobile-menu__ctas .toffeha-btn { width: 100%; justify-content: center; }
