/* School (core/school_page.py): the School page, and the school chip that
   leads to it from Classes, Assignments and Home and opens Change school
   (change_school.js).

   Loaded after redesign.css so it can spend the design tokens; it mints
   none. Every rule is scoped to .view-myschool, .ms-*, .school-chip*,
   .dash-school-line, the School rows of the sidebar and the More sheet,
   and the Assignments header while it holds the chip. */

/* ── the sidebar row, under Tools, right after Grades ────────────────────── */
.nav-item[data-nav-key="myschool"] { order: 8 !important; }
/* The phone's More sheet rounds a group's last row from the label after it
   (soft.css). School is the last row of "Your school" and is hidden on an
   account that keeps no school: Grades, the row before it, is then the last
   one showing, and takes the rounding. */
@supports selector(:has(*)) {
  body:not(#_) .mms-item:has(+ #mobile-more-school[hidden]) {
    border-bottom-left-radius: var(--soft-panel) !important;
    border-bottom-right-radius: var(--soft-panel) !important;
  }
}

/* ── the school chip ─────────────────────────────────────────────────────── */
.school-chip-host { min-width: 0; max-width: 100%; }
.school-chip-host[hidden] { display: none !important; }
.projects-modebar > .school-chip-host { margin-left: auto; }
.school-chip {
  display: inline-flex;
  align-items: stretch;
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface-strong);
  overflow: hidden;
}
.school-chip-main,
.school-chip-switch {
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  min-height: 32px;
}
.school-chip-main {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 5px 12px 5px 11px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}
.school-chip-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--text-tertiary, var(--text-muted)); }
.school-chip.is-on .school-chip-dot { background: var(--success); }
.school-chip.is-off .school-chip-dot { background: var(--warning); }
.school-chip-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.school-chip-via { flex: none; color: var(--text-muted); font-weight: 500; white-space: nowrap; }
.school-chip-via::before { content: "\00B7"; margin-right: 7px; }
.school-chip-switch {
  flex: none;
  padding: 5px 13px 5px 11px;
  border-left: 1px solid var(--border);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
}
.school-chip-main:hover,
.school-chip-switch:hover { background: rgb(var(--accent-rgb) / 0.08); }
.school-chip-main:focus-visible,
.school-chip-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* Assignments: the chip sits beside the title, where the platform pill was,
   centred on it the way that pill is (redesign.css, #tasks-platform-label). */
.view > .topbar > .topbar-left > #tasks-platform-label:has(.school-chip) { align-self: center; }
.view > .topbar > .topbar-left:has(> #tasks-platform-label .school-chip) > .page-title {
  align-self: center;
  padding-block: calc((var(--ink-guard) + 0.12em) / 2);
}
@supports (text-box: trim-both cap alphabetic) {
  .view > .topbar > .topbar-left:has(> #tasks-platform-label .school-chip) > .page-title {
    text-box: trim-both cap alphabetic;
    padding-block: calc((1lh - 1cap) / 2 + (var(--ink-guard) + 0.12em) / 2);
  }
}
#tasks-platform-label .school-chip { vertical-align: middle; max-width: min(46vw, 420px); }
#tasks-platform-label .school-chip-main { min-height: 26px; padding-block: 3px; font-size: 12px; }
/* Home, on the Your classes card: one quiet line above the classes. */
.dash-school-line { margin: -2px 0 12px; }
.dash-school-line .school-chip { width: 100%; }
.dash-school-line .school-chip-main { flex: 1 1 auto; }

/* ── the view ────────────────────────────────────────────────────────────── */
body[data-view="myschool"] .view-myschool { display: grid; grid-template-rows: auto 1fr; }
.ms-page {
  overflow-y: auto;
  padding: var(--page-pad-y) var(--gutter) 80px;
  width: 100%;
  max-width: calc(var(--reading-max) + 2 * var(--gutter));
  margin: 0 auto;
}
.ms-body { display: grid; gap: var(--page-pad-y); align-content: start; }
.ms-card {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--card-shadow);
  padding: var(--page-pad-y) var(--gutter);
  display: grid;
  gap: var(--grid-gap);
  min-width: 0;
}
.ms-card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.ms-h { margin: 0; font-size: 1.02rem; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
.ms-h small { margin-left: 8px; font-size: 0.82rem; font-weight: 500; color: var(--text-muted); letter-spacing: 0; }
.ms-link {
  border: 0;
  background: none;
  padding: 4px 0;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  border-radius: 6px;
}
.ms-link:hover { text-decoration: underline; }
.ms-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ms-muted { margin: 0; color: var(--text-muted); font-size: 13px; line-height: 1.5; }

/* the school itself */
.ms-hero { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--grid-gap); padding: var(--page-pad-y) var(--gutter); }
.ms-hero-art {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: rgb(var(--accent-rgb) / 0.12);
  color: var(--accent);
}
.ms-hero-art svg { width: 30px; height: 30px; }
.ms-hero-copy { display: grid; gap: 4px; min-width: 0; }
.ms-name { margin: 0; font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; color: var(--text); overflow-wrap: anywhere; }
.ms-place { margin: 0; color: var(--text-muted); font-size: 14px; }
.ms-links { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.ms-plat {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.ms-plat i { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.ms-plat.is-off i { background: var(--warning); }
.ms-plat small { font-weight: 500; color: var(--text-muted); font-size: 12px; }
.ms-stats { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ms-stat { border: 0; text-align: left; font: inherit; padding: 12px 14px; border-radius: 16px; background: rgb(var(--accent-rgb) / 0.06); display: grid; gap: 2px; cursor: pointer; color: inherit; }
.ms-stat:hover { background: rgb(var(--accent-rgb) / 0.11); }
.ms-stat:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ms-stat strong { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); line-height: 1.15; }
.ms-stat span { font-size: 12.5px; color: var(--text-muted); }
.ms-stat.is-bad strong { color: var(--danger); }

/* what to do next: up to four steps, two to a row where there is room so
   the card stays about as tall as the one under it. An odd one out takes
   the whole row. */
.ms-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ms-step { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 12px; align-content: start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 16px; }
.ms-step:last-child:nth-child(odd) { grid-column: 1 / -1; }
.ms-step-n { grid-row: 1 / span 3; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: rgb(var(--accent-rgb) / 0.12); color: var(--accent); font-size: 12.5px; font-weight: 700; }
.ms-step strong { font-size: 14px; color: var(--text); overflow-wrap: anywhere; }
.ms-step p { margin: 0; color: var(--text-muted); font-size: 13px; line-height: 1.45; }
.ms-step-go { display: flex; flex-wrap: wrap; gap: 4px 16px; }

/* rows: classes, the record */
.ms-rows { list-style: none; margin: 0; padding: 0; display: grid; }
.ms-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px 14px;
  padding: 14px 2px;
  border-top: 1px solid var(--border);
  min-width: 0;
}
/* A row that opens something is a button inside its list item: the divider
   is the item's, so the button's own corners never bend it. */
.ms-rows > li { border-top: 1px solid var(--border); min-width: 0; }
.ms-rows > li:first-child { border-top: 0; }
.ms-rows > li > .ms-row { border-top: 0; }
.ms-rows > li:first-child > .ms-row { padding-top: 2px; }
button.ms-row { width: 100%; border: 0; border-radius: 8px; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
button.ms-row:hover .ms-row-title { text-decoration: underline; }
button.ms-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ms-row-main { min-width: 0; display: grid; gap: 1px; }
.ms-row-title { font-size: 14px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-row-sub { font-size: 12.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-row-end { font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; }
.ms-row-end.is-none { color: var(--text-muted); font-weight: 500; }

/* the record, by school */
.ms-school { display: grid; gap: 12px; padding: 18px 20px; border: 1px solid var(--border); border-radius: 18px; min-width: 0; }
.ms-school-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.ms-school-head strong { font-size: 14.5px; color: var(--text); overflow-wrap: anywhere; }
.ms-school-head span { font-size: 12.5px; color: var(--text-muted); }
.ms-tag { padding: 2px 9px; border-radius: var(--r-pill); background: rgb(var(--accent-rgb) / 0.12); color: var(--accent); font-size: 11.5px; font-weight: 700; }
.ms-sub { margin: 4px 0 0; font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
.ms-school .ms-row { padding: 10px 2px; }
.ms-school-head .ms-back { margin-left: auto; }
/* Classes kept from a school left, once Restore has ended: one row a class. */
.ms-kept { display: grid; gap: 4px; padding-top: 10px; border-top: 1px solid var(--border); min-width: 0; }
.ms-kept-head { margin: 0; font-size: 12.5px; color: var(--text-muted); }
.ms-kept-head strong { font-size: 13px; color: var(--text); margin-right: 4px; }
.ms-kept .ms-row { align-items: center; gap: 10px; }
.ms-kept .ms-row-title { overflow-wrap: anywhere; }
.ms-kept .ms-back { flex: none; }
.ms-back { border: 1px solid var(--border); background: none; border-radius: var(--r-pill); padding: 5px 12px; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--accent); cursor: pointer; min-height: 32px; }
.ms-back:hover { background: rgb(var(--accent-rgb) / 0.08); }
.ms-back:disabled { opacity: 0.6; cursor: default; }
.ms-back:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* nothing yet, or it did not load */
.ms-empty { display: grid; gap: 10px; justify-items: start; }
.ms-skel { height: 132px; border-radius: var(--r-card); }

@media (max-width: 760px) {
  .ms-page { padding: 16px 14px 96px; }
  .ms-body { gap: var(--grid-gap); }
  .ms-card { padding: 18px 16px; border-radius: 22px; }
  .ms-hero { grid-template-columns: minmax(0, 1fr); padding: 18px 16px; }
  .ms-hero-art { width: 52px; height: 52px; border-radius: 16px; }
  .ms-name { font-size: 1.25rem; }
  .school-chip-main, .school-chip-switch, .ms-back, .ms-link { min-height: var(--tap-min, 44px); }
  .ms-stat { min-height: var(--tap-min, 44px); }
  .ms-steps { grid-template-columns: minmax(0, 1fr); }
  .projects-modebar > .school-chip-host { margin-left: 0; flex: 1 1 100%; }
  .projects-modebar > .school-chip-host .school-chip { width: 100%; }
  .projects-modebar > .school-chip-host .school-chip-main { flex: 1 1 auto; }
}
