/* =========================================================
   Optimal – Responsive Layout Overrides
   ========================================================= */

/* =========================================================
   Shared page wrapper (single source of truth)

   Apply .page-shell to the outer wrapper that sits directly
   under the header on EVERY page (dashboard, plan, track,
   learn, library, articles, etc.)

   This is the ONE place we control:
   - top gap under header
   - side gutters
   - bottom breathing room
   - centring behaviour
   - minimum page height
   ========================================================= */

.page-shell {
  /* Standard gap under header */
  padding-top: 20px;

  /* Standard gutters + bottom spacing */
  padding-left: 20px;
  padding-right: 20px;
  padding-bottom: 40px;

  /* Standard layout behaviour */
  display: flex;
  justify-content: center;
  align-items: flex-start;

  /* Ensure pages feel “full height” */
  min-height: 100vh;

  /* Safety */
  box-sizing: border-box;
}

/* Always hide hamburger by default (desktop + safety) */
.nav-toggle { display: none; }

/* Optional helper (for later gradual adoption)
   If a page wants a consistent max-width inner column:
   <main class="page-shell"><div class="page-inner">...</div></main>
*/
.page-shell .page-inner {
  width: 100%;
  box-sizing: border-box;
}

/* =========================================================
   Mobile + tablet portrait (<=768px)
   ========================================================= */
@media (max-width: 768px) {

  /* Keep spacing consistent on mobile to preserve current design */
  .page-shell {
    padding-top: 20px;
    padding-left: 20px;
    padding-right: 20px;
    padding-bottom: 40px;
  }

  /* Header layout: allow wrapping on tablets */
  .site-header .header-bar {
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
  }

  .site-header .header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative; /* anchor dropdown */
  }

  /* Hamburger button */
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 38px;
    border: 1px solid rgba(33, 76, 117, 0.18);
    background: #fff;
    border-radius: 10px;
    cursor: pointer;
    padding: 0;
    margin: 0; /* prevent accidental centering */
  }

  /* Simple hamburger icon */
  .nav-toggle-bars {
    width: 18px;
    height: 2px;
    background: #214c75;
    position: relative;
    display: block;
    border-radius: 2px;
  }
  .nav-toggle-bars::before,
  .nav-toggle-bars::after {
    content: "";
    position: absolute;
    left: 0;
    width: 18px;
    height: 2px;
    background: #214c75;
    border-radius: 2px;
  }
  .nav-toggle-bars::before { top: -6px; }
  .nav-toggle-bars::after  { top:  6px; }

  /* Main nav becomes a dropdown panel */
  .main-nav {
    display: none; /* closed by default */
    position: absolute;
    right: 12px;
    top: calc(100% + 10px);
    background: #fff;
    border: 1px solid rgba(33, 76, 117, 0.14);
    border-radius: 14px;
    padding: 10px;
    box-shadow: 0 14px 44px rgba(30, 42, 55, 0.18);
    width: min(320px, calc(100vw - 24px));
    z-index: 1500;
  }

  .main-nav.is-open {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  /* Nav links: bigger tap targets */
  .main-nav .nav-link {
    display: block;
    padding: 10px 10px;
    border-radius: 10px;
    text-decoration: none;
  }

  /* Optional: subtle active background */
  .main-nav .nav-link.active {
    background: rgba(61, 127, 189, 0.10);
  }

  /* Divider between nav + account actions (works even if hidden inline) */
  .main-nav .nav-divider {
    height: 1px;
    margin: 8px 8px;
    background: rgba(0,0,0,.10);
  }

  /* If account links are hidden inline in header.php, force them visible when menu is open */
  .main-nav.is-open .nav-divider,
  .main-nav.is-open .nav-account-link {
    display: block !important;
  }
}

/* =========================================================
   OR-53: Small phones (<=600px)
   Goal: single-row header (logo left, hamburger right) + bigger logo
   ========================================================= */
@media (max-width: 600px) {

  /* Force single row header: prevents hamburger dropping under logo */
  .site-header .header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;   /* <-- critical override (kills wrap from 768px) */
    gap: 12px;
  }

  /* Right side stays tight and right-aligned */
  .site-header .header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 0 0 auto;
    width: auto;
    position: relative;
  }

  /* Bigger logo (roughly ~2× vs your 34px/1.35rem attempt) */
  .site-header .brand {
    align-items: center !important;
    flex: 0 0 auto;
  }

  .site-header .brand-mark {
    width: 56px;
    height: 56px;
  }

  .site-header .brand-title {
    font-size: 2.5rem;
    line-height: 1;
  }

  /* Keep [alpha] sitting nicely with the larger logo */
  #headerAlpha {
    top: 1.5em !important;
  }

  /* Hide avatar entirely on mobile (all actions live in hamburger) */
  .site-header .header-avatar {
    display: none !important;
  }

  /* Hamburger should never be centered */
  .site-header .nav-toggle {
  width: 48px;      /* was ~42 */
  height: 44px;     /* was ~38 */
  margin: 0 !important;
}

  /* Keep dropdown aligned to the hamburger/right edge */
  .site-header .main-nav {
    right: 0;
  }
}

/* =========================================================
   Small phones (<=480px) – gutters + minor tap refinements
   ========================================================= */
@media (max-width: 480px) {
  /* Slightly tighter gutters to avoid cramped content */
  .page-shell {
    padding-left: 14px;
    padding-right: 14px;
    padding-bottom: 32px;
  }

  /* Tighten header spacing */
  .site-header .header-bar {
    padding: 8px 12px;
    gap: 8px;
  }

  .nav-toggle {
    width: 40px;
    height: 36px;
    border-radius: 10px;
  }

  /* Keep mobile nav dropdown comfortably inside narrow screens */
  .main-nav {
    right: 8px;
    width: min(320px, calc(100vw - 16px));
  }

  .main-nav .nav-link {
    padding: 10px 12px;
  }
}

/* =========================================================
   Desktop safety
   ========================================================= */

/* Desktop: FORCE hide nav toggle (kills the white rectangle) */
@media (min-width: 769px) {
  .site-header .nav-toggle { display: none !important; }

  /* Desktop: hide duplicated mobile-only items if they exist in markup */
  .site-header .main-nav .nav-divider,
  .site-header .main-nav .nav-account-link {
    display: none !important;
  }
}