/* ==========================================================================
   Excel Learning Hub — responsive.css
   Modern, bulletproof responsive styling for mobile, tablet, and desktop.
   Breakpoints:
     - Small Mobile: < 480px
     - Mobile: < 640px
     - Tablet / Mobile Menu: < 1024px
     - Tablet Grid: 640px - 1023px
     - Desktop: 1024px+
     - Large Desktop: 1280px+
   ========================================================================== */

/* ---- Base Hamburger Button ---------------------------------------------- */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.menu-toggle:hover {
  background: var(--primary-light);
}
.menu-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transform-origin: center;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.2s ease,
              background-color 0.15s ease;
}

/* Hamburger active transformation into 'X' */
.menu-toggle.is-active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.menu-toggle.is-active span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.menu-toggle.is-active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ==========================================================================
   TABLET & MOBILE (Screen width < 1024px)
   ========================================================================== */
@media (max-width: 1023px) {
  .menu-toggle {
    display: flex;
  }

  /* Keep header bar tight, clean, single row */
  .site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
  }
  .site-header__inner {
    flex-wrap: nowrap;
    position: relative;
  }

  /* ---- Standalone Floating Mobile Drawer --------------------------------- */
  /* Without JS: stacked links fallback */
  .nav-links {
    flex-basis: 100%;
    order: 3;
  }
  .nav-links ul {
    flex-direction: column;
    gap: 2px;
    padding: var(--space-2) 0;
  }
  .nav-links a {
    display: block;
    padding: var(--space-2) var(--space-3);
  }

  /* With JS active: clean dropdown drawer container with solid background & shadow */
  body.nav--js .nav-links {
    display: block;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    width: 100%;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 20px 30px -10px rgba(15, 23, 42, 0.22),
                0 4px 6px -2px rgba(15, 23, 42, 0.06);
    z-index: 999;
    padding: var(--space-3) var(--space-4) var(--space-4);
    box-sizing: border-box;
    max-height: calc(100vh - var(--header-height));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.22s;
    pointer-events: none;
  }

  body.nav--js .nav-links.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
  }

  .nav-links ul {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0;
    margin: 0 0 var(--space-3);
    list-style: none;
  }
  .nav-links li {
    width: 100%;
  }
  .nav-links ul a {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
  }
  .nav-links ul a:hover,
  .nav-links ul a:focus {
    background: var(--primary-light);
    color: var(--primary-dark);
    text-decoration: none;
  }
  .nav-links ul a[aria-current="page"] {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 700;
    border-left: 4px solid var(--primary);
    border-bottom: none;
    padding-left: 10px;
  }

  /* Drawer bottom CTA */
  .nav-links__footer {
    display: block;
    padding-top: var(--space-3);
    border-top: 1px solid var(--border);
  }
  .nav-links__footer .button {
    width: 100%;
    justify-content: center;
    padding: 12px 20px;
    color: #fff;
  }

  /* Backdrop overlay */
  .nav-backdrop {
    display: block;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
    pointer-events: none;
  }
  body.nav--open .nav-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  body.nav--open {
    overflow: hidden;
  }

  /* Layout grids on tablet */
  .hero__inner {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
  .hero h1 {
    font-size: 2.25rem;
  }

  .site-footer__grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
  }

  .lesson-layout {
    grid-template-columns: 1fr;
  }
  .lesson-sidebar {
    display: none;
  }
}

/* ==========================================================================
   TABLET GRID OVERRIDES (640px - 1023px)
   ========================================================================== */
@media (min-width: 640px) and (max-width: 1023px) {
  .grid--3,
  .grid--4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .feature-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==========================================================================
   MOBILE PHONES (Screen width < 640px)
   ========================================================================== */
@media (max-width: 639px) {
  /* Hide top-bar "Start Learning" CTA on small screens to prevent header wrap */
  .site-header__cta {
    display: none !important;
  }
  .site-header__actions {
    gap: var(--space-2);
  }

  .site-logo span {
    font-size: 1.05rem;
  }
  .site-logo svg {
    width: 26px;
    height: 26px;
  }

  /* Breadcrumbs horizontal scrolling without wrapping */
  .breadcrumbs {
    overflow: hidden;
  }
  .breadcrumbs ol {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 10px var(--space-3);
    white-space: nowrap;
    gap: 4px 8px;
  }
  .breadcrumbs ol::-webkit-scrollbar {
    display: none;
  }
  .breadcrumbs li {
    flex-shrink: 0;
  }

  /* Hero section */
  .hero {
    padding: var(--space-5) 0 var(--space-4);
  }
  .hero h1 {
    font-size: 1.85rem;
    line-height: 1.25;
    margin-bottom: var(--space-2);
  }
  .hero p.lead {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: var(--space-4);
  }
  .hero__actions {
    flex-direction: column;
    gap: var(--space-2);
    width: 100%;
    margin-top: var(--space-3);
  }
  .hero__actions .button {
    width: 100%;
    justify-content: center;
    padding: 13px 20px;
    font-size: 1rem;
  }
  .hero__graphic {
    margin-top: var(--space-3);
    border-radius: var(--radius-md);
  }

  /* Sections & cards */
  .section {
    padding: var(--space-5) 0;
  }
  .section-heading {
    margin-bottom: var(--space-4);
  }
  .section-heading h2 {
    font-size: 1.5rem;
  }

  .grid--3,
  .grid--4 {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
  .card {
    padding: var(--space-3);
  }
  .card h3 {
    font-size: 1.15rem;
  }

  /* Chips */
  .chip-grid {
    gap: 6px;
  }
  .chip {
    padding: 6px 13px;
    font-size: 0.85rem;
  }

  /* Formula search box */
  .search-box {
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    gap: var(--space-2);
  }
  .search-box input {
    width: 100%;
    font-size: 16px; /* prevent iOS auto-zoom */
    padding: 12px 14px;
  }
  .search-box .button {
    width: 100%;
    justify-content: center;
  }

  /* Formula boxes: copy button stays clean and code doesn't overlap */
  .formula-box {
    padding: var(--space-3);
    padding-top: calc(var(--space-3) + 30px);
    margin: var(--space-3) 0;
  }
  .formula-box__copy {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    padding: 4px 10px;
    font-size: 0.78rem;
  }
  .formula-box__code {
    padding-right: 0;
    padding-bottom: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
    font-size: 0.88rem;
  }

  /* Shortcuts rows */
  .shortcut {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 0;
    align-items: center;
  }
  .shortcut__keys {
    flex-shrink: 0;
  }
  .shortcut span:not(.badge):not(.key) {
    flex: 1 1 160px;
    font-size: 0.95rem;
  }
  .shortcut .badge {
    margin-left: auto;
  }

  /* Feature list */
  .feature-list {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  /* Callout banners */
  .callout {
    padding: var(--space-4) var(--space-3);
  }
  .callout h2 {
    font-size: 1.45rem;
  }
  .callout .button {
    width: 100%;
    max-width: 280px;
  }

  /* Tables: smooth horizontal scrolling without page blowout */
  .lesson-main table,
  .sample-data-table,
  .interactive-demo table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
    margin: var(--space-3) 0;
  }
  .lesson-main table th,
  .lesson-main table td,
  .sample-data-table th,
  .sample-data-table td,
  .interactive-demo table th,
  .interactive-demo table td {
    white-space: nowrap;
    padding: 8px 10px;
    font-size: 0.85rem;
  }

  /* Lesson detail pages */
  .page-header h1 {
    font-size: 1.75rem;
  }
  .lesson-box {
    padding: var(--space-3);
  }
  .mark-complete-button {
    width: 100%;
    justify-content: center;
  }
  .lesson-nav-buttons {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }
  .lesson-nav-buttons__next {
    text-align: left;
    grid-column: 1;
  }

  /* Interactive demos */
  .interactive-demo {
    padding: var(--space-3);
  }
  .interactive-demo input[type="number"],
  .interactive-demo input[type="text"] {
    max-width: 100%;
    width: 100%;
    font-size: 16px;
  }
  .interactive-demo__result {
    display: block;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
  }

  /* Quizzes */
  .quiz-question {
    padding: var(--space-3);
    border-radius: var(--radius-md);
  }
  .quiz-answer {
    padding: 12px 14px;
    min-height: 48px;
    font-size: 0.95rem;
    border-radius: var(--radius-md);
  }
  .quiz-answer input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    flex-shrink: 0;
  }
  #quiz-form .button {
    width: 100%;
    justify-content: center;
  }

  /* Contact / Admin Forms */
  .admin-form input[type="text"],
  .admin-form input[type="email"],
  .admin-form input[type="password"],
  .admin-form textarea,
  .admin-form select {
    font-size: 16px; /* prevent iOS zoom */
  }
  .admin-form .button {
    width: 100%;
    justify-content: center;
  }

  /* Footer on mobile */
  .site-footer {
    padding: var(--space-5) 0 var(--space-4);
    margin-top: var(--space-5);
  }
  .site-footer__grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
  .site-footer__bottom {
    text-align: center;
  }
}

/* ==========================================================================
   EXTRA SMALL SCREENS (< 360px)
   ========================================================================== */
@media (max-width: 359px) {
  .site-logo span {
    font-size: 0.95rem;
  }
  .hero h1 {
    font-size: 1.6rem;
  }
}

/* ==========================================================================
   LARGE DESKTOPS (1280px+)
   ========================================================================== */
@media (min-width: 1280px) {
  :root {
    --container-width: 1280px;
  }
}
