/* Course GPA — Catalog (school.html) only. Loads after site.css.
   Apple tokens from DESIGN.md; one definition per selector. */

/* ---------- page shell ---------- */

.catalog-page {
  padding-bottom: 2rem;
}

.catalog-page.is-picked .page-intro {
  display: none;
}

/* Search-first: the picker owns the first screen, so the notes below
   start under the fold instead of competing with the one input. */
.catalog-page:not(.is-picked) {
  min-height: calc(100vh - 52px);
}

.catalog-page .field input,
.catalog-page .field select,
.catalog-page .search-input,
.catalog-page .combo input[type="search"] {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
}

.catalog-page .field label {
  margin-bottom: 4px;
}

/* ---------- school picker (first screen) ---------- */

#school-picker {
  position: relative;
  min-height: 5.5rem;
  margin: 0 0 1rem;
}

#school-search {
  min-height: 48px;
  font-size: 17px;
}

.combo-list {
  margin: 0.45rem 0 0;
  padding: 0;
  max-height: min(52vh, 22rem);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  list-style: none;
}

.combo-list[hidden] {
  display: none;
}

.combo-list li {
  margin: 0;
}

.result-heading {
  padding: 0.7rem 0.15rem 0.2rem;
  color: var(--ink-muted-48);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.12px;
}

.opt {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0.55rem 0.65rem;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 17px;
  text-align: left;
  cursor: pointer;
}

.opt[aria-selected="true"] {
  background: var(--parchment);
}

.opt-name {
  display: block;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.opt-meta {
  display: block;
  margin-top: 0.1rem;
  color: var(--ink-muted-48);
  font-size: 12px;
  letter-spacing: -0.12px;
}

.opt-empty {
  margin: 0.5rem 0 0;
  padding: 0 0.15rem;
  color: var(--ink-muted-48);
  font-size: 14px;
}

/* ---------- error + notice ---------- */

.error-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.6rem;
  margin: 0.6rem 0 0;
  color: var(--ink-muted-80);
  font-size: 14px;
  letter-spacing: -0.224px;
}

.error-note[hidden] {
  display: none;
}

.link-btn {
  min-height: 44px;
  padding: 0 0.1rem;
  border: 0;
  background: none;
  color: var(--primary);
  font-family: inherit;
  font-size: 14px;
  letter-spacing: -0.224px;
  cursor: pointer;
}

.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.6rem;
  margin: 0 0 0.75rem;
  padding: 0.4rem 0.85rem;
  background: var(--parchment);
  border-radius: var(--radius-md);
  color: var(--ink-muted-80);
  font-size: 14px;
  letter-spacing: -0.224px;
}

.notice[hidden] {
  display: none;
}

/* ---------- school header row ---------- */

.school-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  margin: 0 0 0.75rem;
  padding: 0 0 0.7rem;
  border-bottom: 1px solid var(--hairline);
}

.school-id {
  min-width: 0;
}

.school-name {
  margin: 0;
  overflow: hidden;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.school-meta {
  margin: 0.1rem 0 0;
  color: var(--ink-muted-80);
  font-size: 12px;
  letter-spacing: -0.12px;
}

.meta-long {
  display: none;
}

.meta-short {
  display: inline;
}

.pill-ghost {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--pill);
  background: var(--canvas);
  color: var(--primary);
  font-family: inherit;
  font-size: 14px;
  letter-spacing: -0.224px;
  cursor: pointer;
}

.label-long {
  display: none;
}

.label-short {
  display: inline;
}

/* ---------- pinned summary (mobile) ---------- */

.dock {
  position: sticky;
  top: 52px;
  z-index: 14;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem;
  margin: 0 0 0.75rem;
  padding: 0.6rem 0 0.55rem;
  background: var(--parchment);
  border-bottom: 1px solid var(--hairline);
}

.dock-item {
  min-width: 0;
}

.dock-need {
  text-align: right;
}

.dock-value {
  display: block;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.dock-value[data-empty="true"] {
  color: var(--ink-muted-48);
  font-weight: 500;
}

.dock-need .dock-value {
  font-size: 1.35rem;
}

.dock-note {
  display: block;
  color: var(--ink-muted-80);
  font-size: 12px;
  letter-spacing: -0.12px;
}

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

.catalog-grid {
  display: grid;
  align-items: start;
  gap: 1rem;
}

.list-panel {
  margin: 0;
  padding: 0.9rem 1rem 0.75rem;
}

.result-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin: 0.9rem 0 0;
  padding: 1.15rem 1.25rem;
}

/* ---------- course search ---------- */

.course-combo {
  position: relative;
  margin: 0 0 0.5rem;
}

.course-combo .search-input {
  min-height: 48px;
}

.typeahead {
  position: absolute;
  z-index: 12;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  max-height: min(44vh, 20rem);
  margin: 0;
  padding: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
}

.typeahead[hidden] {
  display: none;
}

.hit {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.15rem 0.75rem;
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.85rem;
  border: 0;
  border-bottom: 1px solid var(--divider-soft);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 17px;
  text-align: left;
  cursor: pointer;
}

.hit:last-child {
  border-bottom: 0;
}

.hit[aria-selected="true"] {
  background: var(--parchment);
}

.hit-code {
  overflow: hidden;
  font-weight: 600;
  letter-spacing: -0.016em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hit-name {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-muted-80);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hit-meta {
  color: var(--ink-muted-48);
  font-size: 14px;
  white-space: nowrap;
}

.hit-add .hit-code {
  color: var(--primary);
}

.hit-empty {
  margin: 0;
  padding: 0.65rem 0.85rem;
  color: var(--ink-muted-48);
  font-size: 14px;
}

/* ---------- course list ---------- */

.legend {
  margin: 0 0 0.35rem;
  color: var(--ink-muted-48);
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: -0.12px;
}

.pick-head {
  display: none;
}

.term-heading {
  margin: 0.35rem 0 0;
  padding: 0.6rem 0 0.3rem;
  border-top: 1px solid var(--hairline);
  color: var(--ink-muted-48);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.12px;
}

.pick + .term-heading {
  margin-top: 0.15rem;
}

.term-heading:first-child {
  border-top: 0;
  padding-top: 0;
}

.cell-term {
  display: none;
}

.picks {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pick {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 0.5rem;
  align-items: center;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--hairline);
}

.pick:last-child {
  border-bottom: 0;
}

.pick-lead {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.pick-sub {
  display: block;
  overflow: hidden;
  color: var(--ink-muted-80);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: -0.224px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pick-custom {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  gap: 0.4rem 0.5rem;
}

.pick-remove {
  display: inline-flex;
  grid-column: 2;
  grid-row: 1;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--ink-muted-48);
  font-family: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.pick-fields {
  display: grid;
  grid-column: 1 / -1;
  grid-row: 2;
  grid-template-columns: minmax(0, 1fr) 92px 72px;
  gap: 0.5rem;
  align-items: center;
}

.pick-fields .field label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  border: 0;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.pick .cell-type label {
  position: static;
  width: auto;
  height: auto;
  margin: 0 0 4px;
  overflow: visible;
  clip: auto;
}

.cell-type {
  display: none;
}

.pick.is-weighted .cell-type {
  display: block;
  grid-column: 1 / -1;
}

.pick.is-planned .cell-term {
  display: block;
  grid-column: 1 / -1;
}

.seg {
  display: inline-flex;
  gap: 0;
  padding: 2px;
  border-radius: var(--pill);
  background: var(--parchment);
}

.seg button {
  flex: 1;
  min-height: 44px;
  padding: 0 12px;
  border: 2px solid transparent;
  border-radius: var(--pill);
  background: transparent;
  color: var(--ink-muted-80);
  font-family: inherit;
  font-size: 14px;
  letter-spacing: -0.224px;
  cursor: pointer;
}

.seg button[aria-pressed="true"] {
  border-color: var(--primary-focus);
  background: var(--canvas);
  color: var(--ink);
}

.picks-empty {
  margin: 0;
  padding: 0.8rem 0;
  color: var(--ink-muted-48);
  font-size: 14px;
}

.list-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 0.85rem;
  padding-top: 0.35rem;
}

/* ---------- result card ---------- */

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

.score-cell {
  min-width: 0;
}

.result-card .score-value {
  font-size: 2.75rem;
}

.result-math {
  margin: 0;
  padding: 0;
  background: none;
  color: var(--ink-muted-80);
  font-size: 14px;
  letter-spacing: -0.224px;
}

.result-math[hidden] {
  display: none;
}

.rule {
  height: 1px;
  background: var(--hairline);
}

.chips[hidden],
.chips[hidden] + .rule {
  display: none;
}

.plan[hidden],
.plan[hidden] + .rule {
  display: none;
}

.plan {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.plan-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.plan-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem;
  color: var(--ink-muted-80);
  font-size: 14px;
  letter-spacing: -0.224px;
}

.plan-term {
  color: var(--ink);
}

.plan-sep {
  color: var(--ink-muted-48);
}

.plan-after strong {
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.plan-open {
  color: var(--ink-muted-48);
}

.chips {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
}

.chip.is-native {
  border-color: var(--primary);
}

.chip-name {
  color: var(--ink-muted-48);
  font-size: 12px;
  letter-spacing: -0.12px;
}

.chip.is-native .chip-name {
  color: var(--primary);
}

.chip-gpa {
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.pair-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.target-block {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.target-block .field {
  max-width: 9rem;
}

.need-line {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
}

.need-line strong {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.need-line[data-state="idle"] {
  color: var(--ink-muted-48);
  font-size: 14px;
}

.need-line[data-state="impossible"] strong {
  color: var(--err);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.card-actions .btn {
  min-height: 44px;
}

.disclaimer {
  margin: 0.85rem 0 0;
  color: var(--ink-muted-48);
  font-size: 14px;
  letter-spacing: -0.224px;
}

/* ---------- desktop ---------- */

@media (min-width: 900px) {
  .dock {
    display: none;
  }

  .meta-long {
    display: inline;
  }

  .meta-short {
    display: none;
  }

  .label-long {
    display: inline;
  }

  .label-short {
    display: none;
  }

  .school-name {
    font-size: 27px;
    line-height: 1.1;
  }

  .school-meta {
    font-size: 14px;
    letter-spacing: -0.224px;
  }

  .pill-ghost {
    min-height: 36px;
  }

  .catalog-grid {
    grid-template-columns: minmax(0, 1fr) 22.5rem;
    gap: 1.5rem;
  }

  .list-panel {
    padding: 0.9rem 1.15rem 0.75rem;
  }

  .result-card {
    position: sticky;
    top: calc(52px + 1.25rem);
    gap: 1.1rem;
    margin: 0;
  }

  .pick-head {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) 130px 110px 74px 128px 44px;
    gap: 0.75rem;
    padding: 0.5rem 0 0.4rem;
    border-bottom: 1px solid var(--hairline);
    color: var(--ink-muted-48);
    font-size: 12px;
    letter-spacing: -0.12px;
  }

  .pick {
    grid-template-columns: minmax(0, 1.2fr) 130px 110px 74px 128px 44px;
    gap: 0.75rem;
    padding: 0.6rem 0;
  }

  .pick-custom {
    grid-template-columns: minmax(0, 1fr);
  }

  .pick-fields {
    display: contents;
  }

  .pick .seg {
    grid-column: 2;
    grid-row: 1;
  }

  .pick .cell-letter {
    grid-column: 3;
    grid-row: 1;
  }

  .pick .cell-credits {
    grid-column: 4;
    grid-row: 1;
  }

  .pick.is-planned .cell-term {
    grid-column: 5;
    grid-row: 1;
  }

  .pick.is-weighted .cell-type {
    grid-column: 2 / -1;
    grid-row: 2;
    max-width: 15rem;
  }

  .pick-remove {
    grid-column: -2;
    grid-row: 1;
    justify-self: center;
  }

  .seg button {
    min-height: 36px;
  }

  .card-actions .btn {
    min-height: 40px;
  }
}

/* ---------- pointer ---------- */

@media (hover: hover) and (pointer: fine) {
  .opt:hover,
  .hit:hover {
    background: var(--parchment);
  }

  .pill-ghost:hover {
    background: var(--pearl);
  }

  .link-btn:hover {
    text-decoration: underline;
  }

  .pick-remove:hover {
    color: var(--ink);
  }
}

/* ---------- print ---------- */

@media print {
  .site-head,
  .site-foot,
  .skip,
  .dock,
  .course-combo,
  .error-note,
  .notice,
  .card-actions,
  .pill-ghost,
  .pick-remove,
  .save-hint,
  .prose,
  .cell-term,
  #school-picker,
  #add-course {
    display: none;
  }

  .school-body {
    background: var(--canvas);
  }

  .catalog-grid {
    display: block;
  }

  .list-panel,
  .result-card {
    position: static;
    padding: 0;
    border: 0;
  }

  .result-card {
    margin-top: 1rem;
  }

  .seg button[aria-pressed="false"] {
    display: none;
  }
}
