/* Morphology Hub — shared by the dashboard slide (morphology-hub.php) and the public /morphology/ page. */

.morphology-hub.teacherdashpages {
  background-color: #ecf5e3;
}

/* .dashslide's overflow:auto would kill position:sticky on the toolbar. It never
   actually engages on this slide anyway (min-height only, so the document scrolls —
   same reasoning as the .dashsummary note above), so dropping it costs nothing. */
.dashslide.morphology-hub {
  overflow: visible;
}

/* Two sticky bars, kept short deliberately: the hub is used mid-lesson and the first
   row of boards has to stay above the fold at 1280x720. */
.mh {
  --mh-ink: #273d24;
  --mh-muted: #56735b;
  --mh-line: #c9e0c7;
  /* Both offsets are re-measured by js/morphology-hub.js — the dashboard's fixed nav
     changes height with the viewport, and a stale guess hides the search box under it. */
  --mh-nav: var(--dashboard-nav-height, 54px);
  --mh-bar1: 4rem;
  /* One height for every control in the toolbar — most of the "messy" look was three
     different ones sharing a line. Coarse pointers get a bigger target. */
  --mh-ctl: 2.5rem;
  padding-bottom: 2rem;
}

.mh-bar {
  position: sticky;
  z-index: 3;
  background-color: #ecf5e3;
}

/* The banner is a title, not a control: it scrolls away, which is what keeps the sticky
   chrome (the toolbar alone) inside its height budget while the banner stays 130px. */
/* 1fr|auto|1fr: the empty left column mirrors the button so the banner centres
   independent of the button's width (absolute placement overlapped when tight). */
.mh-bar--identity {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 2rem;
}

.mh-request-btn {
  grid-column: 3;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: var(--mh-ctl);
  padding: 0 1rem;
  border: 0;
  border-radius: 999px;
  background-color: #fff;
  color: var(--mh-ink);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: inset 0 0 0 2px var(--mh-line);
}

.mh-request-btn:hover {
  box-shadow: inset 0 0 0 2px #b79cc4;
}

/* The banner is the page title and carries the prefix/base/suffix colour key. */
.mh-banner {
  grid-column: 2;
  height: 170px;
  width: auto;
  border-radius:15px;
}

.mh-search {
  position: relative;
  width: 100%;
  max-width: 12rem;
}

.mh-search-input {
  width: 100%;
  height: var(--mh-ctl);
  padding: 0 2.25rem;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  background-color: rgba(255, 255, 255, 0.45);
  color: #4a3050;
  font-size: 0.95rem;
}

.mh-search-input:focus {
  outline: none;
  background-color: #fff;
  box-shadow: 0 0 0 2px rgba(74, 48, 80, 0.2);
}

.mh-search-input::placeholder {
  color: #4a3050;
  opacity: 1;
}

.mh-search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: #4a3050;
  pointer-events: none;
}

.mh-search-key {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  border: 1px solid var(--mh-line);
  border-radius: 0.3rem;
  padding: 0 0.35rem;
  font-size: 0.75rem;
  color: var(--mh-muted);
  background-color: #f7f2fa;
}

/* Grid areas, so the wrap points are a decision rather than whatever the flex row does
   when it runs out of room. Three columns at desktop, two then one as they collide. */
.mh-toolbar {
  top: var(--mh-nav);
  display: grid;
  align-items: center;
  gap: 0.5rem 1rem;
  grid-template-columns: 1fr auto;
  grid-template-areas: "filter view";
  padding: 0.4rem 2rem 0.5rem;
  border-bottom: 1px solid var(--mh-line);
}

/* Measured, not guessed at device widths: this is where the three groups actually collide. */
/* Below this the chips stop fitting on one line. Scrolling rather than wrapping keeps the
   toolbar's height fixed — a wrapping filter row shifts the page under a teacher mid-scroll. */
@media (max-width: 1180px) {
  /* Too narrow for the side columns: stack the button under the banner, both centred. */
  .mh-bar--identity {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .mh-banner,
  .mh-request-btn {
    grid-column: auto;
    justify-self: center;
  }

  .mh-toolbar .tb-filter {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 3px 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 1.5rem), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 1.5rem), transparent);
  }

  .mh-toolbar .tb-filter::-webkit-scrollbar {
    display: none;
  }

  .mh-toolbar .tb-filter > * {
    flex-shrink: 0;
  }
}

@media (max-width: 860px) {
  .mh-toolbar {
    /* Stacked, three rows of controls would eat a quarter of a phone viewport, well past
       the height budget — so here the toolbar scrolls away with the content instead. */
    position: static;
    grid-template-columns: 1fr;
    grid-template-areas: "filter" "view";
  }
}

@media (pointer: coarse) {
  .mh {
    --mh-ctl: 2.75rem;
  }
}

.tb-filter {
  grid-area: filter;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
}

/* Year labels are two characters, so they don't need a full chip's side padding —
   this is what keeps the filter group on one line, and the sticky bar inside budget. */
.tb-filter .mh-year {
  padding: 0 0.5rem;
}

.tb-filter .mh-strand {
  padding: 0 0.75rem;
}

.tb-filter .mh-type {
  padding: 0 0.7rem;
}

.tb-view {
  grid-area: view;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  justify-self: end;
}

.mh-control-label {
  color: var(--mh-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.mh-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.mh-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: var(--mh-ctl);
  padding: 0 0.9rem;
  border: 0;
  border-radius: 999px;
  background-color: #fff;
  color: var(--mh-ink);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: inset 0 0 0 2px var(--mh-line);
}

.mh-chip-btn:hover {
  box-shadow: inset 0 0 0 2px #b79cc4;
}

.mh-chip-btn.is-on {
  background-color: var(--mh-ink);
  color: #fff;
  box-shadow: none;
}

/* Segmented group: one white track, the active segment filled inside it. */
.mh-chips--segmented {
  gap: 0;
  height: var(--mh-ctl);
  background-color: #fff;
  border-radius: 999px;
  padding: 0.2rem;
  box-shadow: inset 0 0 0 2px var(--mh-line);
}

.mh-chips--segmented .mh-chip-btn {
  height: 100%;
  background-color: transparent;
  box-shadow: none;
}

.mh-chips--segmented .mh-chip-btn.is-on {
  background-color: var(--mh-ink);
}

.mh-swatch {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 0.25rem;
  background-color: transparent;
  box-shadow: inset 0 0 0 1px rgba(74, 48, 80, 0.3);
  flex-shrink: 0;
}

.mh-type--base .mh-swatch { background-color: #ffe288; }
.mh-type--prefix .mh-swatch { background-color: #a6e088; }
.mh-type--suffix .mh-swatch { background-color: #f97473; }

/* Years carry no fill of their own — the type swatches are the page's only colour key,
   so a year chip is a plain chip and just takes the purple ink. */
.mh-year[data-year]:not(.is-on),
.mh-strand:not(.is-on) {
  color: #4a3050;
}

/* Game chooser — opened by a card, so the board is already chosen by the time it appears. */
.mh-chooser {
  border: 3px solid var(--mh-ink);
  border-radius: 1rem;
  padding: 1.5rem;
  max-width: min(42rem, 92vw);
  background-color: #fff;
  color: var(--mh-ink);
}

.mh-chooser::backdrop {
  background-color: rgba(74, 48, 80, 0.55);
}

.mh-chooser-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  border: 0;
  background: none;
  color: var(--mh-muted);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
}

.mh-chooser-title {
  margin: 0 0 1rem;
  font-size: 1.5rem;
  padding-right: 2rem;
  text-align: center;
}

.mh-chooser-board {
  background-color: #ffe288;
  border-radius: 0.4rem;
  padding: 0 0.4rem;
}

.mh-chooser-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
}

/* One engine's column: the game card plus its Live Play companion underneath. */
.mh-chooser-slot {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1 1 11rem;
}

.mh-chooser-option {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1 1 auto;
  padding: 0.75rem;
  border: 2px solid var(--mh-line);
  border-radius: 0.8rem;
  color: var(--mh-ink);
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.mh-chooser-option:hover {
  color: var(--mh-ink);
  text-decoration: none;
  border-color: var(--mh-ink);
  transform: translateY(-3px);
}

.mh-chooser-thumb {
  width: 100%;
  border-radius: 15px;
}

.mh-chooser-phrase {
  font-size: 1.3rem;
  line-height: 1.3;
}

.mh-chooser-live {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  border: 2px solid var(--mh-line);
  border-radius: 0.8rem;
  background-color: #fff;
  color: var(--mh-ink);
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.mh-chooser-live:hover {
  border-color: var(--mh-ink);
}

.mh-chooser-live-icon {
  width: 26px;
  height: 26px;
  border-radius: 5px;
}

.mh-chooser-class {
  margin: 0 0.25rem;
  padding: 0.15rem 0.4rem;
  border: 2px solid var(--mh-line);
  border-radius: 0.5rem;
  background-color: #fff;
  color: var(--mh-ink);
  font-size: 0.85rem;
  font-style: normal;
  cursor: pointer;
}

.mh-chooser-note {
  margin: 1rem 0 0;
  color: var(--mh-muted);
  font-size: 0.85rem;
  font-style: italic;
}

/* Request form — the chooser's panel, a stack of fields instead of a row of games. */
.mh-request {
  max-width: min(30rem, 92vw);
}

.mh-request-intro {
  margin: 0 0 1rem;
  color: var(--mh-muted);
  font-size: 0.9rem;
}

.mh-request-label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--mh-ink);
}

.mh-request-input {
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--mh-line);
  border-radius: 0.6rem;
  background-color: #fff;
  color: var(--mh-ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.95rem;
}

.mh-request-send {
  height: var(--mh-ctl);
  padding: 0 1.25rem;
  border: 0;
  border-radius: 999px;
  background-color: var(--mh-ink);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.mh-request-send[disabled] {
  opacity: 0.6;
  cursor: default;
}

.mh-request-status {
  margin: 0.75rem 0 0;
  min-height: 1.2em;
  font-size: 0.9rem;
  color: var(--mh-muted);
}

.mh-request-status.is-error {
  color: #a33;
}

@media (prefers-reduced-motion: reduce) {
  .mh-chooser-option:hover {
    transform: none;
  }
}

.mh-subbar {
  display: grid;
  /* A definite last column, or the search box shrinks to its content; recent takes the slack. */
  grid-template-columns: auto 1fr minmax(7rem, 12rem);
  grid-template-areas: "fav recent search";
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.75rem 2rem 0;
}

.mh-subbar .mh-fav-only {
  grid-area: fav;
}

.mh-recent {
  grid-area: recent;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  min-width: 0;
}

.mh-subbar .mh-search {
  grid-area: search;
  justify-self: end;
}

@media (max-width: 860px) {
  .mh-subbar {
    grid-template-columns: auto 1fr;
    grid-template-areas: "fav recent" "search search";
  }

  .mh-subbar .mh-search {
    justify-self: stretch;
    max-width: none;
  }
}

.mh-recent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* Each recent item wears its own morpheme colour — the yellow is the BASE colour, not a
   background for the row. */
.mh-recent-item {
  padding: 0.25rem 0.9rem;
  border: 2px solid #d9b23c;
  border-radius: 999px;
  background-color: #ffe288;
  color: var(--mh-ink);
  font-weight: 600;
  font-size: 0.9rem;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.mh-recent-item.mh-card--prefix {
  background-color: #a6e088;
  border-color: #6fae55;
}

.mh-recent-item.mh-card--suffix {
  background-color: #f9a3a2;
  border-color: #cf6f6e;
}

.mh-recent-item:hover {
  color: var(--mh-ink);
  text-decoration: underline;
}

.mh-status {
  padding: 0.6rem 2rem 0;
  margin: 0;
  color: var(--mh-muted);
  font-size: 0.85rem;
}

.mh-note,
.mh-empty {
  padding: 0.5rem 2rem;
  margin: 0;
  color: var(--mh-muted);
  font-style: italic;
}

.mh-section {
  padding: 0.75rem 2rem 0.5rem;
  /* Matches the sticky stack (nav + toolbar), which js/morphology-hub.js measures, so an
     anchor jump can't land underneath the bar. */
  scroll-margin-top: calc(var(--mh-nav) + var(--mh-bar1) + 0.5rem);
}

.mh-section .mh-section {
  padding: 0.5rem 0 0;
}

.mh-section-title {
  color: var(--mh-ink);
  font-size: 2rem;
  margin: 0 0 0.5rem;
}

.mh-section .mh-section .mh-section-title {
  color: var(--mh-muted);
  font-size: 1.1rem;
}

.mh-section-note {
  color: var(--mh-muted);
  font-size: 0.85rem;
  margin: -0.25rem 0 0.6rem;
  max-width: 60ch;
}

.mh-view[data-view="az"] .mh-grid {
  padding: 0.75rem 2rem 0;
}

/* Fixed columns, not content-width: ragged card widths destroy the vertical scan
   this page exists for. */
.mh-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  align-items: stretch;
}

@media (min-width: 640px) {
  .mh-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1040px) {
  .mh-grid { grid-template-columns: repeat(4, 1fr); }
}

/* The star sits alongside the card, not inside it — a <button> can't hold another. */
.mh-card-wrap {
  position: relative;
  display: flex;
}

.mh-card-wrap > .mh-card {
  flex: 1 1 auto;
}

.mh-fav {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: none;
  color: rgba(74, 48, 80, 0.28);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0;
}

.mh-fav:hover {
  color: rgba(74, 48, 80, 0.6);
}

.mh-fav.is-on {
  color: #4a3050;
}

.mh-fav-count:not(:empty) {
  background-color: rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  padding: 0 0.4em;
  font-size: 0.85em;
}

.mh-chip-btn.mh-fav-only.is-on .mh-fav-count:not(:empty) {
  background-color: rgba(255, 255, 255, 0.25);
}

.mh-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2em;
  position: relative;
  padding: 0.7em 2.4em 0.8em 0.9em;
  border: 2px solid #d9b23c;
  border-radius: 0.7em;
  background-color: #ffe288;
  color: var(--mh-ink);
  font: inherit;
  font-size: 1rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mh-card--prefix {
  background-color: #a6e088;
  border-color: #6fae55;
}

/* A lighter sibling of the game's own #f97473 suffix tile — the full-strength red
   drops the card's ink under 4.5:1. */
.mh-card--suffix {
  background-color: #f9a3a2;
  border-color: #cf6f6e;
}

.mh-card:not([disabled]):hover {
  color: var(--mh-ink);
  text-decoration: none;
  transform: translateY(-3px);
  box-shadow: 0 4px 10px rgba(74, 48, 80, 0.28);
}

.mh-card--pending {
  background-color: #e5dbea;
  border-color: #bdaac7;
  color: #7b6a86;
  cursor: default;
}

.mh-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25em;
  margin-bottom: 0.1em;
}

/* Arial, not llamarollFont: at 0.7em the house font loses legibility, and these tags are
   the smallest text on the page. Anything this size or below should do the same. */
.mh-tag {
  background-color: rgba(74, 48, 80, 0.14);
  color: var(--mh-ink);
  border-radius: 999px;
  padding: 0.1em 0.5em;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.02em;
}

/* The type leads the card, so it carries the strongest tint; the week tags sit back. */
.mh-tag--type {
  background-color: #8a6d12;
  color: #fff;
  text-transform: uppercase;
}

.mh-card--prefix .mh-tag--type { background-color: #3f6b2a; }
.mh-card--suffix .mh-tag--type { background-color: #8f3b3f; }

.mh-tag--slot {
  color: #4a3050;
}

/* Orthography weeks teach the joining rule, not the morpheme, so their weeks sit back from
   the morphology ones rather than reading as equals — the scheme's own tags decide which. */
.mh-tag--rule {
  background-color: transparent;
  box-shadow: inset 0 0 0 1px rgba(74, 48, 80, 0.35);
  color: var(--mh-muted);
}

.mh-tag--slot[data-strand="orthography"] {
  background-color: rgba(74, 48, 80, 0.07);
  color: var(--mh-muted);
}

/* The type tag earns its place only in A-Z, where types are interleaved; the other
   views already say it in the section heading. */
.mh-tag--type,
.mh-tag--pending {
  display: none;
}

/* ...and in any section that mixes types, where colour would otherwise be carrying
   the distinction on its own. */
.mh[data-view="az"] .mh-tag--type,
.mh-section--mixed .mh-tag--type {
  display: inline-block;
}

.mh-card--pending .mh-tag--pending {
  display: inline-block;
}

.mh-card-morpheme {
  font-family: llamarollFont, sans-serif;
  font-size: 1.35em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

/* An affix keeps its hyphen: browsers break after one by default, and the title's
   overflow-wrap:anywhere makes it worse, so "-ence" ends up split across lines. */
.mh-morph {
  white-space: nowrap;
}

.mh-card-gloss {
  font-size: 1rem;
  line-height: 1.3;
  color: #58405f;
}

.mh-card-variants {
  font-size: 0.9rem;
  font-style: italic;
  color: #58405f;
}

.mh-card-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25em;
  margin-top: auto;
  padding-top: 0.45em;
}

/* Arial for the example words too: they are read as spellings, so letterform clarity
   matters more here than house style. */
.mh-chip {
  background-color: #fff;
  color: var(--mh-ink);
  border-radius: 999px;
  padding: 0.15em 0.55em;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.78em;
}

.mh-chip mark {
  background-color: #ffd849;
  color: var(--mh-ink);
  padding: 0;
  border-radius: 0.2em;
}

.mh .is-hidden {
  display: none !important;
}

.mh :focus-visible {
  outline: 3px solid #733381;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .mh-card {
    transition: none;
  }
  .mh-card:not([disabled]):hover {
    transform: none;
  }
}

/* ---------- Public /morphology/ page (morphology/index.php): the hub inside the site header/footer shell ---------- */

/* Scrolls inside .mh-guest-scroll so the scrollbar starts under the sticky site header (tools/index.php pattern). */
body.mh-guest {
  font-family: llamarollFont;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

body.mh-guest .mh-guest-scroll {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

body.mh-guest .mh-guest-main {
  flex: 1 0 auto;
  background-color: #ecf5e3;
}

/* Crumb row joins the page rather than the header; dark ink because white fails on #ecf5e3 (roll-call.css precedent). */
body.mh-guest .crumbs {
  background-color: #ecf5e3;
}

body.mh-guest .crumbs,
body.mh-guest .crumbs .crumbs__link,
body.mh-guest .crumbs .crumbs__current,
body.mh-guest .crumbs .crumbs__sep {
  color: #4a3050;
}

body.mh-guest .footer {
  margin-top: 0;
}

body.mh-guest .content-max-width {
  max-width: 1100px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}
