/* ==========================================================================
   IlmOS · shell.css
   Phone first: topbar + content + bottom tabs. From 1024px the rail replaces
   the tabs and the topbar becomes a slim bar above the content.
   ========================================================================== */

/* --------------------------------------------------------------- monogram */
.monogram {
  --monogram: var(--pine);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 11px;
  border: 0;
  background: var(--grad-brand);
  color: var(--pine-fg);
  box-shadow: var(--glow);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.02em;
  overflow: hidden;
}

/* A school that uploaded its crest: the image fills the same square, so the
   header does not change shape when branding is turned on. */
.monogram--logo {
  padding: 0;
  /* A crest is drawn for white paper: it keeps a white tile in both themes. */
  background: #fff;
  box-shadow: var(--lift-1);
}

.monogram--logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* ----------------------------------------------------------------- topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-h);
  padding: 0 var(--gut);
  background: var(--glass);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--rule);
}

.topbar__menu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  margin-left: -8px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}

.topbar__menu:active {
  background: var(--paper-2);
}

.topbar__id {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.topbar__names {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.topbar__names strong {
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--name-color, inherit);
}

.topbar__names span {
  font-size: 11.5px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar__user {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--grad-brand);
  color: var(--pine-fg);
  box-shadow: var(--glow);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* campus picker */
.picker {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 2px 2px 8px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
}

.picker__label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}

.picker__select {
  border: 0;
  background: transparent;
  font-size: 12.5px;
  font-weight: 600;
  max-width: 120px;
  padding: 4px 0;
}

.picker__go {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: var(--pine);
  color: var(--pine-fg);
  cursor: pointer;
}

/* With two or more campuses the picker joins the bar. Without limits flexbox
   squeezed the school block to 0px: its crest spilled under the search icon
   and the user badge was pushed off a 360px phone. The school block now keeps
   at least its crest, the icons never shrink, and only the picker gives way. */
.topbar__id {
  flex: 1 1 auto;
  min-width: 34px;
}

.topbar__right {
  flex: 0 1 auto;
  min-width: 0;
}

.topbar__right > * {
  flex-shrink: 0;
}

.topbar__right > .picker {
  flex-shrink: 1;
  min-width: 0;
}

.picker__select {
  min-width: 0;
}

@media (max-width: 599px) {
  .picker {
    padding-left: 6px;
  }

  .picker__label {
    display: none;
  }

  .picker__select {
    max-width: 104px;
  }

  /* the page title under the school name has no room next to a picker */
  .topbar:has(.picker) .topbar__names span {
    display: none;
  }
}

@media (max-width: 479px) {
  /* the menu sheet has its own search box, and the select submits on change;
     the picker already names the campus, so the crest alone stands for it */
  .topbar:has(.picker) .topbar__search,
  .topbar:has(.picker) .topbar__names,
  .picker__go {
    display: none;
  }

  .picker__select {
    max-width: 150px;
  }
}

/* ------------------------------------------------------------------ main */
.main {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--gut);
  padding-bottom: calc(var(--tabs-h) + 34px);
}

.main--wide {
  max-width: 1320px;
}

/* ------------------------------------------------------------ bottom tabs */
.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--glass);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--rule);
}

.tabs__tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: var(--tabs-h);
  padding-top: 6px;
  color: var(--ink-3);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tabs__tab.is-active {
  color: var(--zone-accent, var(--pine));
}

.tabs__tab.is-active::before {
  content: "";
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--zone-accent, var(--pine)) 16%, transparent);
  z-index: -1;
}

.tabs__tab {
  isolation: isolate;
}

.tabs__tab:active {
  background: var(--surface-2);
}

/* ------------------------------------------------------------------ rail */
.rail {
  display: none;
}

@media (min-width: 1024px) {
  .tabs {
    display: none;
  }

  .topbar__menu {
    display: none;
  }

  .main {
    margin-left: var(--rail-w);
    max-width: none;
    padding: 22px 30px 48px;
  }

  .main > * {
    max-width: var(--page-max);
  }

  .main--wide > * {
    max-width: 1320px;
  }

  .rail {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    width: var(--rail-w);
    background: var(--rail-bg, var(--surface));
    border-right: 1px solid var(--rail-rule, var(--rule));
  }

  .rail__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--rail-rule, var(--rule));
    color: var(--rail-ink, var(--ink));
  }

  .rail__brand strong {
    display: block;
    font-family: var(--font-serif);
    font-size: 15px;
    line-height: 1.2;
    color: var(--name-color, var(--ink));
  }

  .rail__brand em {
    font-style: normal;
    font-size: 10.5px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--rail-ink-3, var(--ink-3));
  }

  

  .rail__foot {
    padding: 12px;
    border-top: 1px solid var(--rail-rule, var(--rule));
    background: var(--rail-surface-2, var(--surface-2));
  }

  .rail__user {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 9px;
  }

  .rail__user-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--grad-brand);
    color: var(--pine-fg);
    font-size: 11px;
    font-weight: 700;
  }

  .rail__user strong {
    display: block;
    font-size: 12.5px;
    color: var(--rail-ink, var(--ink));
  }

  .rail__user em {
    font-style: normal;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--rail-ink-3, var(--ink-3));
  }
}

/* ----------------------------------------------------------- menu sheet */
.sheet {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 70;
  width: 100%;
  max-width: none;
  max-height: 88vh;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 16px 16px 0 0;
  background: var(--surface);
  box-shadow: var(--lift-2);
  overflow: hidden;
}

.sheet:not([open]) {
  display: none;
}

.sheet[open] {
  display: flex;
  flex-direction: column;
  animation: sheet-rise 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.sheet::backdrop {
  background: var(--overlay);
}

@keyframes sheet-rise {
  from {
    transform: translateY(14px);
    opacity: 0.4;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.sheet__grab {
  width: 42px;
  height: 4px;
  margin: 8px auto 2px;
  border-radius: 99px;
  background: var(--rule-2);
}

.sheet__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule);
}

.sheet__id {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sheet__id strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 15px;
  color: var(--name-color, var(--ink));
}

.sheet__id em {
  font-style: normal;
  font-size: 11px;
  color: var(--ink-3);
}

.sheet__close {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}

.sheet__body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 16px;
  -webkit-overflow-scrolling: touch;
}

.sheet__foot {
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
  background: var(--surface-2);
}

@media (min-width: 720px) {
  .sheet {
    left: auto;
    right: 18px;
    bottom: 18px;
    width: 384px;
    border-radius: var(--r-lg);
  }
}

/* ---------------------------------------------------------------- toasts */
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabs-h) + 14px + env(safe-area-inset-bottom));
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: min(92vw, 460px);
  padding: 11px 12px;
  border-radius: var(--r);
  border: 1px solid var(--rule-2);
  /* Toasts stay dark in both themes: they float over everything. */
  background: #1b1e33;
  color: #f4f5ff;
  font-size: 13.5px;
  box-shadow: var(--lift-2);
  animation: toast-in 0.24s ease-out;
}

.toast--ok {
  background: #065f46;
}

.toast--bad {
  background: #9f1239;
}

.toast--warn {
  background: #92400e;
}

.toast--info {
  background: #1e3a8a;
}

.toast__close {
  margin-left: 4px;
  border: 0;
  background: transparent;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
  line-height: 1;
}

@keyframes toast-in {
  from {
    transform: translate(-50%, 10px);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

@media (min-width: 1024px) {
  .toast {
    bottom: 22px;
  }
}

/* The signed-in shell: <body class="app zone--*"> wraps every screen ------- */
.app {
  min-height: 100vh;
}

/* Signed-out pages (login, setup) ---------------------------------------- */
.app--bare .main {
  padding-bottom: 32px;
}

.app--bare {
  background-image:
    radial-gradient(1100px 520px at 50% -180px, color-mix(in srgb, var(--pine) 16%, transparent), transparent),
    radial-gradient(700px 420px at 100% 100%, color-mix(in srgb, #ec4899 8%, transparent), transparent);
}

/* ----------------------------------------------------------- theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 36px;
  height: 36px;
  padding: 0 9px;
  border: 1px solid var(--rule-2);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 650;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.theme-toggle:hover {
  color: var(--pine);
  border-color: var(--pine);
}

.theme-toggle--label {
  width: 100%;
  justify-content: flex-start;
  margin-bottom: 8px;
  border-radius: var(--r-sm);
}

.theme-toggle__icon,
.theme-toggle__word {
  display: none;
}

.theme-toggle__icon {
  line-height: 0;
}

:root:not([data-theme-choice]) .theme-toggle__icon--auto,
:root:not([data-theme-choice]) .theme-toggle__word--auto,
[data-theme-choice="auto"] .theme-toggle__icon--auto,
[data-theme-choice="auto"] .theme-toggle__word--auto,
[data-theme-choice="light"] .theme-toggle__icon--light,
[data-theme-choice="light"] .theme-toggle__word--light,
[data-theme-choice="dark"] .theme-toggle__icon--dark,
[data-theme-choice="dark"] .theme-toggle__word--dark {
  display: inline;
}

/* A mouse wheel cannot scroll sideways and the scrollbar is hidden, so with a
   mouse the row wraps onto more lines instead; touch screens keep the swipe. */
