/* Finder. Scarlet is structural here, not decorative: it marks the course
   record and nothing else, so the eye learns one meaning for it. */

:root {
  --paper: #ffffff;
  --wash: #f0f1f4;
  --sunk: #e7e9ee;
  --ink: #16171a;
  --mute: #5f646c;
  --rule: #dee0e5;
  --field: #80858c;
  --scarlet: #bb0000;
  --open: #0e7a50;
  --wait: #a65b00;
  --closed: #686d76;

  --display: "Bricolage Grotesque", "Trebuchet MS", sans-serif;
  --body: "IBM Plex Sans", system-ui, sans-serif;
  --data: "IBM Plex Mono", ui-monospace, monospace;

  --gap: clamp(1rem, 2.5vw, 1.75rem);
  --radius: 3px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131417;
    --wash: #1a1c20;
    --sunk: #232529;
    --ink: #eceef2;
    --mute: #9aa1ab;
    --rule: #2c2f35;
    --field: #6b7079;
    --scarlet: #ff5c4d;
    --open: #4cc38a;
    --wait: #e0a44a;
    --closed: #868d97;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--wash);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

:focus-visible {
  outline: 2px solid var(--scarlet);
  outline-offset: 2px;
}

.search button:focus-visible { outline-color: var(--ink); }

@media (forced-colors: active) {
  :focus-visible { outline: 2px solid Highlight; }
}

/* Three-pane shell --------------------------------------------------------

   Desktop is a real three-column application: filters, results, detail.
   Below the breakpoint it becomes one column, because three panes squeezed
   into a phone is worse than one pane at a time, and registration happens
   on a phone. */

.app {
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr) 23rem;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem var(--gap);
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  flex-wrap: wrap;
}

.wordmark {
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0;
  line-height: 1;
}

.tagline {
  margin: 0;
  color: var(--mute);
  font-size: 0.85rem;
}

.rail {
  overflow-y: auto;
  padding: var(--gap);
  background: var(--paper);
  border-right: 1px solid var(--rule);
}

.rail-empty { margin: 0; color: var(--mute); font-size: 0.85rem; }

.centre {
  overflow-y: auto;
  padding: var(--gap);
  min-width: 0;
}

.detail {
  overflow-y: auto;
  padding: var(--gap);
  background: var(--paper);
  border-left: 1px solid var(--rule);
}

.detail-idle { margin: 0; color: var(--mute); font-size: 0.9rem; }

/* The rail toggle and the detail back button exist only in the collapsed
   layout, so they are hidden by default rather than created conditionally. */
.rail-toggle,
.detail-back { display: none; }

/* Search ------------------------------------------------------------------ */

.search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.5rem;
  margin-left: auto;
  min-width: min(28rem, 100%);
}

.search input,
.search select,
.search button {
  font: inherit;
  min-height: 2.75rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0.6rem 0.75rem;
  background: transparent;
  color: inherit;
}

.search input {
  min-width: 0;
  border-color: var(--field);
  background: var(--wash);
}

.search input::placeholder { color: var(--mute); }

.search select {
  border-color: var(--field);
  background: var(--paper);
  cursor: pointer;
}

.search button {
  background: var(--scarlet);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  border-color: var(--scarlet);
}

.search button:hover { filter: brightness(1.08); }
.search button[aria-disabled="true"] {
  background: var(--mute);
  border-color: var(--mute);
  cursor: default;
}
.search button[aria-disabled="true"]:hover { filter: none; }

@media (prefers-color-scheme: dark) {
  .search button { color: #16171a; }
}

/* Status ------------------------------------------------------------------ */

.status {
  margin: 0 0 0.9rem;
  color: var(--mute);
  font-size: 0.95rem;
  overflow-wrap: break-word;
}

.status:empty { margin: 0; }
.status[data-kind="error"] { color: var(--scarlet); font-weight: 500; }

/* Course records ---------------------------------------------------------- */

.results { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.75rem; }

.course {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--scarlet);
  border-radius: var(--radius);
  overflow: hidden;
}

.course-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--rule);
}

.course-title,
.teacher-name,
.section-when,
.section-where,
.section-who { overflow-wrap: break-word; }

.course-code {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.course-title { font-weight: 600; }

.course-meta {
  margin-left: auto;
  color: var(--mute);
  font-family: var(--data);
  font-size: 0.8rem;
  white-space: nowrap;
}

/* Sections ---------------------------------------------------------------- */

.sections { list-style: none; margin: 0; padding: 0; }

.section {
  display: grid;
  grid-template-columns: 5.5rem 1fr auto;
  gap: 0.25rem 0.9rem;
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--rule);
  align-items: baseline;
}

.sections > .section:first-child { border-top: 0; }

.section-number {
  font-family: var(--data);
  font-size: 0.85rem;
  color: var(--mute);
}

.section-when { font-size: 0.95rem; }

.section-where,
.section-who {
  grid-column: 2;
  color: var(--mute);
  font-size: 0.85rem;
}

.section-who { color: var(--ink); }

.component {
  font-family: var(--data);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mute);
  background: var(--sunk);
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius);
}

/* Small screens ----------------------------------------------------------- */

/* Collapsed layout --------------------------------------------------------

   One column. The rail becomes a sheet the top bar opens, and the detail pane
   becomes a full view pushed over the results with a way back. */

@media (max-width: 64rem) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .rail {
    display: none;
    grid-column: 1;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  .app[data-rail="open"] .rail { display: block; }

  .rail-toggle {
    display: inline-block;
    font: inherit;
    font-size: 0.85rem;
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--field);
    border-radius: var(--radius);
    background: var(--wash);
    color: inherit;
    cursor: pointer;
  }

  .rail-toggle[aria-expanded="true"] {
    background: var(--scarlet);
    border-color: var(--scarlet);
    color: var(--paper);
  }

  .centre { grid-column: 1; }

  .detail {
    display: none;
    grid-column: 1;
    border-left: 0;
  }

  /* Detail replaces the results rather than sitting beside them. */
  .app[data-view="detail"] .detail { display: block; }
  .app[data-view="detail"] .centre { display: none; }

  .app[data-view="detail"] .detail-back {
    display: inline-block;
    font: inherit;
    font-size: 0.85rem;
    margin-bottom: 0.9rem;
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--field);
    border-radius: var(--radius);
    background: var(--wash);
    color: inherit;
    cursor: pointer;
  }

  .tagline { display: none; }
  .search { margin-left: 0; width: 100%; min-width: 0; }
}

@media (max-width: 34rem) {
  .search { grid-template-columns: minmax(0, 1fr); }
  .section { grid-template-columns: minmax(0, 1fr) auto; }
  .section-number { grid-column: 1; }
  .section-when,
  .section-where,
  .section-who { grid-column: 1 / -1; }
  .seats { grid-column: 1 / -1; text-align: left; }
  .course-meta { margin-left: 0; width: 100%; white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Instructor blocks. The teacher is the heading and sections nest under them,
   which is the inversion the whole project exists for. */

.teacher { border-top: 1px solid var(--rule); }
.course > .teacher:first-of-type { border-top: 0; }

.teacher-name {
  margin: 0;
  padding: 0.7rem 1rem 0.2rem;
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.teacher-name.is-unlisted {
  font-family: var(--body);
  font-weight: 500;
  color: var(--mute);
}

.teacher .sections > .section:first-child { border-top: 0; }
.teacher .section { padding-top: 0.35rem; padding-bottom: 0.6rem; }

/* Related courses stay reachable without competing with the answer. */

.related {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
}

.related > summary {
  padding: 0.75rem 1rem;
  cursor: pointer;
  color: var(--mute);
  font-size: 0.9rem;
}

.related > summary:hover { color: var(--ink); }
.related[open] > summary { border-bottom: 1px solid var(--rule); }
.related > .course { border: 0; border-radius: 0; border-top: 1px solid var(--rule); }

/* Ratings. The name is the link, so an unrated instructor costs nothing. */

.teacher-link { color: inherit; text-decoration-color: var(--rule); text-underline-offset: 3px; }
.teacher-link:hover { text-decoration-color: var(--scarlet); }

.score {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  margin-left: 0.5rem;
  font-family: var(--data);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--mute);
  vertical-align: baseline;
}

.score::before { content: "★"; color: var(--scarlet); font-size: 0.75rem; }
.score[data-thin="true"]::before { color: var(--mute); }
/* Parenthesised, because "2.7 / 3" reads as a score out of three when 3 is
   actually how many people rated them. */
.score-count { font-size: 0.7rem; color: var(--mute); }
.score-count::before { content: "("; }
.score-count::after { content: ")"; }

/* Seat counts. Full is the state worth spotting while scanning ten sections. */

.seats {
  grid-column: 3;
  font-family: var(--data);
  font-size: 0.78rem;
  color: var(--mute);
  text-align: right;
  white-space: nowrap;
}

.seats[data-state="full"] { color: var(--scarlet); font-weight: 500; }
.waitlist { margin-left: 0.25rem; }

@media (max-width: 34rem) {
  .seats { grid-column: 1 / -1; text-align: left; }
}

/* Selection --------------------------------------------------------------- */

.section { cursor: pointer; }
.section:hover { background: var(--wash); }

.section.is-selected {
  background: var(--wash);
  box-shadow: inset 3px 0 0 var(--scarlet);
}

.detail .h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  margin: 0 0 0.6rem;
}

/* Detail pane ------------------------------------------------------------- */

.eyebrow {
  font-family: var(--data);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mute);
  margin: 0 0 0.4rem;
}

.d-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  margin: 0 0 0.15rem;
  overflow-wrap: break-word;
}

.d-name.is-none { color: var(--mute); font-family: var(--body); font-weight: 500; }

.d-sub { margin: 0 0 1rem; color: var(--mute); font-size: 0.85rem; }

.d-figs { display: flex; gap: 1.25rem; align-items: flex-end; margin-bottom: 0.9rem; flex-wrap: wrap; }

.d-num {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.9rem;
  letter-spacing: -0.03em;
  line-height: 1;
}

.d-num.is-rating { color: var(--scarlet); }
.d-num.is-none { color: var(--mute); }

.d-cap {
  font-family: var(--data);
  font-size: 0.62rem;
  color: var(--mute);
  margin-top: 0.2rem;
}

.d-block { margin-bottom: 1.1rem; }

.d-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.85rem;
  padding: 0.32rem 0;
  border-bottom: 1px solid var(--rule);
}

.d-row > span:first-child { color: var(--mute); }
.d-val { font-family: var(--data); font-size: 0.8rem; text-align: right; }
.d-val.is-full { color: var(--scarlet); font-weight: 500; }
.d-val.is-open { color: var(--open); }
.d-val.is-none { color: var(--mute); }

.d-note { margin: 0.4rem 0 0; font-size: 0.78rem; color: var(--mute); }
.d-prose { margin: 0; font-size: 0.84rem; color: var(--mute); }

.bar {
  height: 4px;
  background: var(--sunk);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.bar i { display: block; height: 100%; background: var(--open); }
.bar i.f { background: var(--scarlet); }

.section:focus-visible {
  outline: 2px solid var(--scarlet);
  outline-offset: -2px;
}

/* Filter rail ------------------------------------------------------------- */

.f-set { border: 0; margin: 0 0 1.25rem; padding: 0; }
.f-set .eyebrow { padding: 0; }

.f-days { display: flex; gap: 0.3rem; flex-wrap: wrap; }

.f-day {
  font: inherit;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.f-day span {
  display: block;
  min-width: 2.1rem;
  text-align: center;
  padding: 0.35rem 0.3rem;
  border: 1px solid var(--field);
  border-radius: var(--radius);
  font-family: var(--data);
  font-size: 0.78rem;
  color: var(--mute);
}

.f-day[data-state="require"] span {
  background: var(--scarlet);
  border-color: var(--scarlet);
  color: var(--paper);
  font-weight: 600;
}

/* Avoided reads as struck out, which needs no legend to understand. */
.f-day[data-state="avoid"] span {
  border-style: dashed;
  border-color: var(--mute);
  color: var(--mute);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.f-day:focus-visible span { outline: 2px solid var(--scarlet); outline-offset: 2px; }

.f-hint { margin: 0.45rem 0 0; font-size: 0.72rem; color: var(--mute); }

.f-label { display: block; font-size: 0.78rem; color: var(--mute); margin: 0.5rem 0 0.25rem; }

.f-ctl {
  width: 100%;
  font: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--field);
  border-radius: var(--radius);
  background: var(--wash);
  color: inherit;
  cursor: pointer;
}

.f-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--mute);
  margin-top: 0.5rem;
  cursor: pointer;
}

.f-check input { accent-color: var(--scarlet); width: 0.95rem; height: 0.95rem; }

.f-clear {
  font: inherit;
  font-size: 0.8rem;
  width: 100%;
  padding: 0.45rem;
  border: 1px solid var(--field);
  border-radius: var(--radius);
  background: transparent;
  color: var(--mute);
  cursor: pointer;
}

.f-clear:hover { color: var(--ink); border-color: var(--ink); }

.hidden-note {
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  color: var(--mute);
  font-size: 0.85rem;
}

.hidden-note button {
  font: inherit;
  background: none;
  border: 0;
  padding: 0;
  color: var(--scarlet);
  cursor: pointer;
  text-decoration: underline;
}

/* Calendar ---------------------------------------------------------------- */

.view-bar { display: flex; margin-bottom: 0.8rem; }

/* No overflow:hidden here: it clipped the focus ring off both buttons, which
   #38 measured at 0 visible pixels. The corners round on the buttons instead. */
.view-toggle { display: inline-flex; border: 1px solid var(--field); border-radius: var(--radius); }

.view-toggle button {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.32rem 0.8rem;
  border: 0;
  background: transparent;
  color: var(--mute);
  cursor: pointer;
}

.view-toggle button:first-child { border-radius: calc(var(--radius) - 1px) 0 0 calc(var(--radius) - 1px); }
.view-toggle button:last-child { border-radius: 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0; }
.view-toggle button + button { border-left: 1px solid var(--field); }
.view-toggle button.is-on { background: var(--scarlet); color: var(--paper); font-weight: 600; }

.cal-scroll { overflow-x: auto; }
.cal-scroll:focus-visible { outline: 2px solid var(--scarlet); outline-offset: 2px; }

.cal {
  display: grid;
  grid-template-columns: 3rem repeat(var(--cal-days), minmax(9rem, 1fr));
  /* fit-content, not auto: with a floor under the columns the grid is wider
     than a phone, and it has to say so or overflow:hidden eats the difference
     instead of handing it to .cal-scroll. */
  width: fit-content;
  min-width: 100%;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  overflow: hidden;
}

.cal-head {
  font-family: var(--data);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mute);
  text-align: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--rule);
}

.cal-col { border-left: 1px solid var(--rule); min-width: 0; }
.cal-body { position: relative; }
.cal-line { border-bottom: 1px solid var(--sunk); }

.cal-gutter { min-width: 0; }

.cal-hour {
  position: relative;
  border-bottom: 1px solid transparent;
}

.cal-hour span {
  position: absolute;
  top: -0.42rem;
  right: 0.35rem;
  font-family: var(--data);
  font-size: 0.62rem;
  color: var(--mute);
}

.cal-slot {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: var(--radius);
  border-left: 3px solid var(--open);
  background: var(--wash);
  padding: 0.2rem 0.3rem;
  overflow: hidden;
}

.cal-slot.is-full { border-left-color: var(--scarlet); }
.cal-slot.is-part { border-left-color: var(--wait); }

.cal-time, .cal-count {
  margin: 0;
  font-family: var(--data);
  font-size: 0.6rem;
  color: var(--mute);
}

.cal-count { color: var(--scarlet); font-weight: 500; }

.cal-item {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
  width: 100%;
  font: inherit;
  font-size: 0.72rem;
  text-align: left;
  background: none;
  border: 0;
  padding: 0.08rem 0;
  color: inherit;
  cursor: pointer;
}

.cal-item:hover .cal-who { text-decoration: underline; }
.cal-item.is-selected { outline: 2px solid var(--scarlet); outline-offset: -1px; border-radius: 2px; }

.cal-who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.cal-rate { font-family: var(--data); font-size: 0.62rem; color: var(--scarlet); flex: none; }
.cal-seats { font-family: var(--data); font-size: 0.62rem; color: var(--mute); margin-left: auto; flex: none; }
.cal-seats.is-full { color: var(--scarlet); }

.cal-unscheduled { margin-top: 1rem; }
.cal-empty { color: var(--mute); font-size: 0.9rem; }

.cal-more { margin: 0; font-family: var(--data); font-size: 0.6rem; color: var(--scarlet); }

/* Course pickers ---------------------------------------------------------- */

.picker { margin-bottom: 1.25rem; padding-bottom: 1.1rem; border-bottom: 1px solid var(--rule); }
.picker .f-ctl { cursor: text; }
.picker .f-ctl:disabled { opacity: 0.5; cursor: default; }
.picker .f-ctl::placeholder { color: var(--mute); }

/* Landing screen ---------------------------------------------------------- */

.welcome { max-width: 34rem; }

.w-stats {
  margin: 0 0 1.4rem;
  font-family: var(--data);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mute);
}

.w-head {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem;
}

.w-sub { margin: 0 0 1rem; color: var(--mute); font-size: 0.85rem; }

.w-list { list-style: none; margin: 0; padding: 0; }

.w-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 0.75rem;
  align-items: baseline;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--rule);
}

.w-name {
  font: inherit;
  font-weight: 600;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  cursor: pointer;
}

.w-name:hover { text-decoration: underline; text-decoration-color: var(--scarlet); }

.w-score {
  font-family: var(--data);
  font-size: 0.95rem;
  color: var(--scarlet);
}

.w-meta {
  grid-column: 1 / -1;
  font-size: 0.75rem;
  color: var(--mute);
}

.w-foot { margin: 1.2rem 0 0; font-size: 0.85rem; color: var(--mute); }

.w-example {
  font: inherit;
  font-family: var(--data);
  font-size: 0.82rem;
  background: none;
  border: 0;
  padding: 0;
  color: var(--scarlet);
  cursor: pointer;
  text-decoration: underline;
}
