/* ==========================================================
   Mobile menu: hamburger button + slide-out sidebar
   Used by every admin and teacher page.
   Load this file LAST in the <head> so it wins over the page's own css.
   ========================================================== */

/* Hidden on computers. The javascript adds these elements. */
.mobile-bar,
.menu-overlay,
.menu-close { display: none; }

@media (max-width: 820px) {

  /* ---------- Top bar with the hamburger ---------- */
  .mobile-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 56px;
    padding: 0 12px;
    color: #fff;
    background: linear-gradient(90deg, var(--brand) 0%, var(--brand-mid) 100%);
    box-shadow: 0 2px 8px rgba(11, 30, 70, 0.25);
  }

  .menu-toggle {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.12);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .menu-toggle:hover { background: rgba(255, 255, 255, 0.2); }

  .menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    border-radius: 2px;
    background: #fff;
  }

  .mobile-title {
    font-family: "Lora", Georgia, serif;
    font-size: 17px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Space for the fixed top bar */
  .layout { padding-top: 56px; }

  /* ---------- The sidebar becomes a drawer ---------- */
  .layout > .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    width: min(280px, 84vw);
    height: 100%;
    padding: 22px 14px 18px;
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.28s ease, visibility 0s linear 0.28s;
  }

  body.nav-open .layout > .sidebar {
    transform: translateX(0);
    visibility: visible;
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.3);
    transition: transform 0.28s ease;
  }

  /* Put the menu back to the tall list shape (the old phone css laid it out in a row) */
  .layout > .sidebar .brand { padding: 4px 8px 22px; }
  .layout > .sidebar .nav { flex-direction: column; flex-wrap: nowrap; }
  .layout > .sidebar .nav a { padding: 12px; font-size: 14px; }

  .layout > .sidebar .user {
    display: block;
    margin-top: auto;
    padding-top: 18px;
  }

  .layout > .sidebar .user-name { margin: 0 0 8px; }
  .layout > .sidebar .logout { padding: 10px; }

  /* Close (x) button inside the drawer */
  .menu-close {
    position: absolute;
    top: 10px;
    right: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .menu-close:hover { background: rgba(255, 255, 255, 0.24); }

  /* ---------- Dark layer behind the drawer ---------- */
  .menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: block;
    background: rgba(8, 30, 70, 0.55);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0s linear 0.28s;
  }

  body.nav-open .menu-overlay {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.28s ease;
  }

  /* Stops the page behind from scrolling while the menu is open */
  body.nav-open { overflow: hidden; }

  /* ---------- Small comfort fixes for phones ---------- */
  .main { padding: 20px 14px 48px; }
  .page-head h1 { font-size: 21px; }

  /* 16px stops iPhones from zooming in when you tap a box */
  .input,
  .search,
  .select-wrap select { font-size: 16px; }

  .quick .button-gold,
  .quick .btn { flex: 1 1 100%; text-align: center; }

  .sheet-head,
  .sheet-body,
  .sheet-foot { padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 420px) {
  .mobile-title { font-size: 16px; }
  .main { padding: 18px 12px 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .layout > .sidebar,
  .menu-overlay { transition: none; }
}