@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&display=swap');

/* ============================================================
   account-rail.css: the account sidebar on the pages it links to
   (owner 2026-11-21). Drawn by mnAccountRenderRail() in
   includes/account-shell.php; includes/header.php loads this sheet
   only on the pages that draw it, and only for a signed-in student.

   ⛔ It must look exactly like the sidebar on /dashboard, /my-purchases
   and /payments, whose rules live in committee-control-center.css
   (".sidebar" to ".user-status", and the 680px strip). That sheet cannot
   be loaded here: it resets every element on the page and makes <body> a
   flex row. So the same rules are repeated below, each one scoped under
   .mn-acct-rail so nothing else on the page is touched.
   ⛔ Change the sidebar's look in BOTH files, or the two drift apart.
   ============================================================ */

body:has(> .mn-acct-rail) {
  --mn-acct-rail-w: 240px;
}

/* ⛔ The full-width bands (the hero, the section heads, the FAQ, the course
   masthead, the semester bands) reach the window's edges with
   calc(50% - 50vw), which assumes the page column is centred in the window.
   Beside the sidebar it is centred in what is left of the window, so the bands
   read half of THAT width instead, and stop at the sidebar's edge rather than
   running under it. Every such rule reads var(--mn-bleed-half, 50vw)
   (resource-modern-shell.css, qp-subject-page.css, semester-bundle.css), so a
   page without the sidebar is unchanged. */
@media (min-width: 681px) {
  body:has(> .mn-acct-rail) {
    --mn-bleed-half: calc(50vw - var(--mn-acct-rail-w) / 2);
  }
}

.mn-acct-rail {
  --blue-200: #c4d8fd;
  --green: #0d9f57;
  --radius-sm: 8px;
  --f-sans: 'Lora', Georgia, Cambria, serif;
  --f-mono: 'DM Mono', monospace;
}

/* The page's own rules never reach in: the account pages start from a reset. */
.mn-acct-rail *,
.mn-acct-rail *::before,
.mn-acct-rail *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.mn-acct-rail a {
  color: inherit;
  text-decoration: none;
}

/* The bar stays put, as it does over the account pages: the sidebar hangs
   from its bottom edge, so a bar that scrolled away would leave a gap. */
body:has(> .mn-acct-rail) > .mn-res-topnav {
  position: sticky;
  top: 0;
}

/* The page moves over by the sidebar's width, so the sidebar never covers it.
   The footer sits inside .mn-standalone-root, so it moves with it. */
body:has(> .mn-acct-rail) > .mn-standalone-root,
body:has(> .mn-acct-rail) > .mn-course-ask {
  margin-left: var(--mn-acct-rail-w);
  width: calc(100% - var(--mn-acct-rail-w));
  max-width: calc(100% - var(--mn-acct-rail-w));
  min-width: 0;
}

/* ⛔ WHAT THE READING PAGES PIN (owner 2026-11-21: the sidebar on every page
   under its sections). Without the sidebar the bar scrolls away, so these pin to
   the top of the window; here the bar stays (layer 100), and anything pinned at
   the very top would sit behind it. So each one pins under the bar instead, and
   whatever is centred on the window or runs its full width keeps to the part of
   the window beside the sidebar. */
body:has(> .mn-acct-rail) .mn-res-content .topbar {
  top: var(--mn-topnav-h, 61px);
}
body:has(> .mn-acct-rail) #pdf-viewer.qp-live-pdf-stage #pdf-viewer-container:not(.pdf-boxed) > .toolbar {
  top: calc(var(--mn-topnav-h, 61px) + 60px);
}
body:has(> .mn-acct-rail) .mn-res-content:has(.topbar.is-crumbbar-away) #pdf-viewer.qp-live-pdf-stage #pdf-viewer-container:not(.pdf-boxed) > .toolbar {
  top: var(--mn-topnav-h, 61px);
}
body:has(> .mn-acct-rail) .sticky-pricing {
  top: calc(var(--mn-topnav-h, 61px) + var(--topbar-h, 3.5rem) + 0.85rem);
}
body:has(> .mn-acct-rail) .mn-res-content .mn-bookui-head {
  top: var(--mn-topnav-h, 61px);
}
@media (min-width: 681px) {
  body:has(> .mn-acct-rail) .mn-res-content .mn-bookui-head {
    left: calc(50% + var(--mn-acct-rail-w) / 2);
    width: calc(100% - var(--mn-acct-rail-w));
  }
  body:has(> .mn-acct-rail) .mn-res-content .mn-bookui-chip {
    left: calc(50% + var(--mn-acct-rail-w) / 2);
  }
  body:has(> .mn-acct-rail) .mn-res-content .mn-bookui-progress,
  body:has(> .mn-acct-rail) .mob-cta-bar,
  body:has(> .mn-acct-rail) .tsx-buybar {
    left: var(--mn-acct-rail-w);
  }
}

.mn-acct-rail > .sidebar {
  width: var(--mn-acct-rail-w, 240px);
  flex-shrink: 0;
  background: var(--mn-topnav-bg, #04101f);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: var(--mn-topnav-h, 0px);
  left: 0;
  bottom: 0;
  z-index: 90;
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  background-image: none !important;
  font-family: var(--f-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mn-acct-rail .sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem 0;
}

.mn-acct-rail .nav-section-label {
  padding: 0.7rem 1.3rem 0.3rem;
  font-size: 0.56rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.2);
  font-family: var(--f-mono);
}

.mn-acct-rail .nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 1.3rem;
  margin: 1px 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.81rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  position: relative;
}

.mn-acct-rail .nav-item:hover {
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.06);
}

.mn-acct-rail .nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.mn-acct-rail .nav-item.active::before {
  content: '';
  position: absolute;
  left: -0.65rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 1.4rem;
  border-radius: 0 3px 3px 0;
  background: rgba(255, 255, 255, 0.8);
}

.mn-acct-rail .nav-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  opacity: 0.65;
}

.mn-acct-rail .nav-item.active .nav-icon {
  opacity: 1;
}

.mn-acct-rail .nav-badge {
  margin-left: auto;
  background: rgba(34, 96, 245, 0.35);
  border: 1px solid rgba(85, 133, 248, 0.35);
  color: var(--blue-200);
  font-size: 0.59rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-family: var(--f-mono);
}

.mn-acct-rail .nav-badge.red {
  background: rgba(212, 42, 42, 0.25);
  border-color: rgba(212, 42, 42, 0.3);
  color: #fca5a5;
}

.mn-acct-rail .sidebar-footer {
  padding: 0.85rem 1.3rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.15);
}

.mn-acct-rail .sidebar-logout {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.7rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  transition: all 0.15s;
}

.mn-acct-rail .sidebar-logout:hover,
.mn-acct-rail .sidebar-logout:focus-visible {
  background: rgba(220, 38, 38, 0.16);
  color: #fca5a5;
}

.mn-acct-rail .sidebar-logout .nav-icon {
  opacity: 0.8;
}

/* ⭐ A visitor's Sign in at the sidebar's foot (owner 2026-11-30: "make it same for non logged in
   user as well"). On a computer the strip over the page, which held the visitor's other Sign in, is
   not drawn (.mn-acct-strip-off, site-topnav.css), so this one is drawn as that strip's white button
   was (.mn-res-topnav-account .mn-res-crumb-action, site-topnav.css): the same colours, size and
   weight, and no red, which is Log out's. Folded to 72px: account-sidebar-collapse.css. */
.mn-acct-rail .sidebar-logout.sidebar-signin {
  justify-content: center;
  margin-top: 0;
  padding: 8px 14px;
  border-radius: 8px;
  background: #fff;
  color: #0b2447;
  font-size: 13px;
  font-weight: 700;
}

.mn-acct-rail .sidebar-logout.sidebar-signin:hover,
.mn-acct-rail .sidebar-logout.sidebar-signin:focus-visible {
  background: rgba(255, 255, 255, 0.88);
  color: #0b2447;
}

.mn-acct-rail .sidebar-logout.sidebar-signin .nav-icon {
  opacity: 1;
}

.mn-acct-rail .user-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.mn-acct-rail .user-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  border: 1.5px solid rgba(255, 255, 255, 0.24);
  overflow: hidden;
}

.mn-acct-rail .user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mn-acct-rail .avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  line-height: 1;
}

.mn-acct-rail .user-avatar.has-image .avatar-fallback {
  display: none;
}

.mn-acct-rail .user-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  letter-spacing: -0.01em;
}

.mn-acct-rail .user-role {
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 1px;
  font-family: var(--f-mono);
  letter-spacing: 0.03em;
}

.mn-acct-rail .user-status {
  width: 0.5rem;
  height: 0.5rem;
  min-width: 0.5rem;
  min-height: 0.5rem;
  flex: 0 0 0.5rem;
  aspect-ratio: 1 / 1;
  border-radius: 999px;
  display: block;
  background: var(--green);
  margin-left: auto;
  box-shadow: 0 0 0 2px rgba(13, 159, 87, 0.25);
}

/* The installed app's bottom tabs: the sidebar's foot stays above them, as on
   the account pages (app-layer.css). */
@media (display-mode: standalone) and (min-width: 681px) {
  html:has(.mn-tabbar) .mn-acct-rail > .sidebar {
    bottom: var(--mn-tabbar-space, 0px);
  }
}

/* ⭐ No elastic bounce on a computer, on the pages that build their own head and never load
   site-topnav.css (the AIBE and MHT-CET exam screens), as site-topnav.css does for every other
   page (owner 2026-11-29: the header must not drop down past the top). Phones keep theirs. */
@media (hover: hover) and (pointer: fine) {
  html:has(> body > .mn-acct-rail),
  body:has(> .mn-acct-rail) {
    overscroll-behavior-y: none;
  }
}

/* ⛔ AN AD MUST NEVER SIT UNDER THE SIDEBAR (2026-11-29). Google's automatic ads put one slot
   after the page, as a child of <body> (div.google-auto-placed, inline width 100%), so beside
   the sidebar it started at the window's left edge and the fixed sidebar covered its first
   240px (72px folded): measured on /question-papers/ at 1600px, the ad 0 to 1600px under a
   sidebar ending at 240px. Its box is padded by the sidebar's width so the ad lays out in the
   part of the window beside the sidebar (measured after: 240 to 1600px, no sideways scroll).
   Placement and size stay Google's; only the space under our own sidebar is taken out. */
@media (min-width: 681px) {
  body:has(> .mn-acct-rail) > .google-auto-placed {
    box-sizing: border-box;
    padding-left: var(--mn-acct-rail-w);
  }
}

/* Phones: the page takes the full width. The sidebar itself is the phone menu
   behind the ☰ in the bar (account-phone-menu.css, the one place it lives). */
@media (max-width: 680px) {
  body:has(> .mn-acct-rail) > .mn-standalone-root,
  body:has(> .mn-acct-rail) > .mn-course-ask {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
  }
}
