/* ==========================================================================
   RABBANI — Application Shell
   Desktop: a quiet top bar with five student destinations.
   Mobile:  a bottom bar with the same five.
   The permanent sidebar is deliberately gone: it made a learning product read
   as an operations console, and it put scholar/admin tooling in a student's
   line of sight all day.
   ========================================================================== */

.app-shell { min-height: 100vh; display: flex; flex-direction: column; background: var(--ivory); }

/* ---------- Top navigation (desktop / tablet) ---------------------------- */
.topnav {
  position: sticky; top: 0; z-index: 60;
  height: var(--topnav-h);
  display: flex; align-items: center; gap: var(--s-6);
  padding-inline: clamp(var(--s-4), 3vw, var(--s-10));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.1) blur(10px);
  border-block-end: 1px solid var(--line-hair);
}
/* One hairline of gold under the bar: the only ornament in the chrome. */
.topnav::after {
  content: ''; position: absolute; inset-inline: 0; bottom: -1px; height: 1px;
  background: linear-gradient(to left, transparent, var(--gold-300), transparent);
  opacity: 0.5;
}

.brand { display: flex; align-items: baseline; gap: var(--s-2); text-decoration: none; flex-shrink: 0; }
.brand-mark {
  font-family: var(--font-display); font-size: 1.5rem; font-weight: var(--fw-bold);
  color: var(--green-800); letter-spacing: var(--tracking-tight); line-height: 1;
}
.brand-latin {
  font-size: var(--fs-micro); letter-spacing: 0.18em; color: var(--ink-400);
  text-transform: uppercase; font-weight: var(--fw-medium);
}
.brand-rule { inline-size: 1px; block-size: 20px; background: var(--line); margin-inline: var(--s-1); }

.topnav-links { display: flex; align-items: center; gap: var(--s-1); margin-inline-end: auto; }
.topnav-link {
  position: relative; padding: var(--s-2) var(--s-4);
  font-size: var(--fs-body); font-weight: var(--fw-medium);
  color: var(--ink-500); text-decoration: none; border-radius: var(--r-md);
  transition: color var(--t-fast), background var(--t-fast);
  white-space: nowrap;
}
.topnav-link:hover { color: var(--green-800); background: var(--green-50); }
.topnav-link.active { color: var(--green-800); font-weight: var(--fw-bold); }
/* Current destination is marked by weight AND a rule — never colour alone. */
.topnav-link.active::after {
  content: ''; position: absolute; inset-inline: var(--s-4); bottom: -22px; height: 2px;
  background: var(--brand-fill-hover); border-radius: var(--r-pill);
}
.topnav-actions { display: flex; align-items: center; gap: var(--s-2); flex-shrink: 0; }

/* ---------- Review count -------------------------------------------------- */
.nav-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-inline-size: 20px; block-size: 20px; padding-inline: 6px; margin-inline-start: var(--s-2);
  font-size: var(--fs-micro); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums;
  color: var(--green-900); background: var(--gold-300); border-radius: var(--r-pill);
}

/* ---------- Profile menu -------------------------------------------------- */
.profile-btn {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-1) var(--s-2) var(--s-1) var(--s-3);
  background: transparent; border: 1px solid var(--line-hair); border-radius: var(--r-pill);
  cursor: pointer; font-family: inherit; transition: border-color var(--t-fast), background var(--t-fast);
}
.profile-btn:hover { border-color: var(--line); background: var(--surface-raised); }
.avatar {
  inline-size: 30px; block-size: 30px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  background: var(--brand-fill-hover); color: var(--brand-fill-ink);
  font-size: var(--fs-caption); font-weight: var(--fw-bold);
}
.profile-name { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--ink-700); }

.profile-menu {
  position: absolute; inset-block-start: calc(var(--topnav-h) - 8px); inset-inline-end: clamp(var(--s-4), 3vw, var(--s-10));
  min-inline-size: 244px; padding: var(--s-2);
  background: var(--surface-raised); border: 1px solid var(--line-hair);
  border-radius: var(--r-lg); box-shadow: var(--e-3); z-index: 70;
}
.profile-menu[hidden] { display: none; }
.profile-menu-head { padding: var(--s-3); border-block-end: 1px solid var(--line-hair); margin-block-end: var(--s-2); }
.profile-menu-name { font-weight: var(--fw-bold); color: var(--ink-900); }
.profile-menu-role { font-size: var(--fs-caption); color: var(--ink-400); margin-block-start: 2px; }
.profile-menu-item {
  display: block; inline-size: 100%; text-align: start;
  padding: var(--s-3); font-size: var(--fs-body); font-family: inherit;
  color: var(--ink-700); text-decoration: none; background: none; border: 0;
  border-radius: var(--r-sm); cursor: pointer;
}
.profile-menu-item:hover { background: var(--green-50); color: var(--green-800); }
.profile-menu-item.danger:hover { background: var(--danger-bg); color: var(--danger); }
.profile-menu-sep { block-size: 1px; background: var(--line-hair); margin: var(--s-2) 0; }

/* ---------- Workspace switch ---------------------------------------------
   The single doorway between the student experience and scholar/admin tooling.
   Shown only when the server-issued profile carries the entitlement; the
   backend remains authoritative on every route regardless. */
.workspace-switch {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); font-family: inherit;
  color: var(--green-800); text-decoration: none;
  background: var(--green-50); border: 1px solid var(--green-100);
  border-radius: var(--r-pill); cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.workspace-switch:hover { background: var(--green-100); border-color: var(--green-500); }
.workspace-switch[hidden] { display: none; }

/* A standing marker while inside the privileged workspace, so it is never
   mistaken for the student product. */
.workspace-banner {
  display: flex; align-items: center; justify-content: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-4);
  background: var(--brand-fill-strong); color: var(--brand-fill-ink);
  font-size: var(--fs-sm); letter-spacing: var(--tracking-wide);
}
.workspace-banner a { color: var(--gold-300); text-decoration: underline; text-underline-offset: 3px; }
.workspace-banner[hidden] { display: none; }

/* ---------- Main ---------------------------------------------------------- */
.app-main { flex: 1; inline-size: 100%; }
.page {
  inline-size: min(var(--content-max), 100%);
  margin-inline: auto;
  padding: clamp(var(--s-6), 4vw, var(--s-12)) clamp(var(--s-4), 3vw, var(--s-8)) var(--s-20);
}
.page-reading { inline-size: min(var(--reading-max), 100%); }
.page-narrow  { inline-size: min(var(--narrow-max), 100%); }

/* ---------- Bottom navigation (mobile) ------------------------------------ */
.bottomnav { display: none; }

@media (max-width: 860px) {
  .topnav-links { display: none; }
  .topnav { gap: var(--s-2); padding-inline: var(--s-4); }
  .profile-name { display: none; }
  /* The switch becomes a labelled icon: its full label pushed the avatar off
     the edge on a 375px viewport. */
  .workspace-switch span { display: none; }
  .workspace-switch { padding: var(--s-2); }
  .brand-latin { display: none; }
  .brand-rule { display: none; }

  .bottomnav {
    position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 60;
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    block-size: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
    padding-block-end: env(safe-area-inset-bottom, 0px);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: saturate(1.1) blur(12px);
    border-block-start: 1px solid var(--line-hair);
  }
  .bottomnav-item {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; text-decoration: none; color: var(--ink-400);
    font-size: var(--fs-micro); font-weight: var(--fw-medium);
    min-block-size: 48px;
    /* Five equal columns on a 375px screen leaves little room; the label must
       shrink to fit rather than spill past the edge. */
    min-inline-size: 0; padding-inline: 2px; text-align: center;
    overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
    transition: color var(--t-fast);
  }
  .bottomnav-item > span:not(.nav-count) {
    max-inline-size: 100%; overflow: hidden; text-overflow: ellipsis;
  }
  .bottomnav-item .ic { inline-size: 22px; block-size: 22px; flex-shrink: 0; }
  /* The count rides the icon instead of taking a row of its own. */
  .bottomnav-item .nav-count {
    position: absolute; inset-block-start: 4px;
    inset-inline-end: calc(50% - 20px);
    margin: 0; min-inline-size: 17px; block-size: 17px; font-size: 10px;
  }
  .bottomnav-item.active { color: var(--green-800); font-weight: var(--fw-bold); }
  .bottomnav-item.active .ic { stroke-width: 2.1; }
  .bottomnav-item:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm); }

  .app-main { padding-block-end: calc(var(--bottomnav-h) + var(--s-4)); }
  .profile-menu { inset-inline-end: var(--s-3); }
}

/* ---------- Skip link ----------------------------------------------------- */
.skip-link {
  position: absolute; inset-inline-start: 50%; transform: translate(50%, -120%);
  z-index: 100; padding: var(--s-3) var(--s-5);
  background: var(--brand-fill); color: var(--brand-fill-ink);
  border-radius: 0 0 var(--r-md) var(--r-md); text-decoration: none;
  transition: transform var(--t-fast);
}
.skip-link:focus { transform: translate(50%, 0); }

:where(a, button, [tabindex]):focus-visible {
  outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm);
}
