/* ==================================================================
   Home page (2026-09 facelift). Scoped to body.home-atlas and built
   only on static/tokens.css. Overrides the legacy reading-room chip
   styles in main.css without touching other pages.
   ================================================================== */

body.home-atlas {
  /* Two type families on the home page: Fraunces + IBM Plex Sans. */
  --font-body: var(--tz-font-ui);
  background: var(--tz-paper);
  color: var(--tz-ink);
}
/* Flat surfaces: no paper-grain overlay on top of the illustrations. */
body.home-atlas .grain { display: none; }

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

body.home-atlas .masthead { padding-bottom: 0; }

/* ---------- Shared type ------------------------------------------- */
.atlas-kicker {
  margin: 0 0 var(--tz-space-2);
  font-family: var(--tz-font-ui);
  font-size: var(--tz-label-size);
  font-weight: 600;
  letter-spacing: var(--tz-label-track);
  text-transform: uppercase;
  color: var(--tz-accent-text);
}
.atlas-title {
  margin: 0 0 var(--tz-space-3);
  font-family: var(--tz-font-display);
  font-size: var(--tz-h1-size);
  line-height: var(--tz-h1-lh);
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--tz-ink);
  text-wrap: balance;
}
.atlas-lede {
  margin: 0 0 var(--tz-space-5);
  font-family: var(--tz-font-ui);
  font-size: var(--tz-body-lg-size);
  line-height: var(--tz-body-lg-lh);
  color: var(--tz-ink-2);
  max-width: 34em;
}
.atlas-h2 {
  margin: 0;
  font-family: var(--tz-font-display);
  font-size: var(--tz-h2-size);
  line-height: var(--tz-h2-lh);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--tz-ink);
}
.atlas-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--tz-space-4);
  margin-bottom: var(--tz-space-4);
}
.atlas-status,
.compare-count {
  margin: 0;
  font-family: var(--tz-font-ui);
  font-size: var(--tz-meta-size);
  color: var(--tz-muted);
}
.atlas-link {
  font-family: var(--tz-font-ui);
  font-size: var(--tz-button-size);
  font-weight: 500;
  color: var(--tz-accent);
  text-decoration: none;
}
.atlas-link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Intro + toolbar ---------------------------------------- */
.atlas-intro { padding: var(--tz-space-4) 0 var(--tz-space-4); }
body.home-atlas .atlas-title { font-size: clamp(26px, 3.2vw, 34px); margin-bottom: var(--tz-space-2); }
body.home-atlas .atlas-lede { font-size: var(--tz-body-size); margin: 0; }

.rr-toolbar {
  display: flex;
  align-items: center;
  gap: var(--tz-space-3);
  margin-bottom: var(--tz-space-3);
}
.atlas-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 1 320px;
}
.atlas-search-icon {
  position: absolute;
  left: 12px;
  color: var(--tz-muted);
  pointer-events: none;
}
.atlas-search-input {
  width: 100%;
  height: 42px;
  padding: 0 var(--tz-space-3) 0 38px;
  font-family: var(--tz-font-ui);
  font-size: 16px;
  color: var(--tz-ink);
  background: var(--tz-surface);
  border: var(--tz-border) solid var(--tz-line-strong);
  border-radius: var(--tz-radius);
  transition: box-shadow var(--tz-dur-fast) var(--tz-ease);
  -webkit-appearance: none;
  appearance: none;
}
.atlas-search-input::placeholder { color: var(--tz-muted); }
.atlas-search-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--tz-select-bg), 0 0 0 1px var(--tz-focus);
}
.rr-toolbar .atlas-status { flex: 1 1 auto; white-space: nowrap; }

/* ---------- Word list: every word, checkbox style, scroll box -------- */
body.home-atlas .reading-room.atlas {
  padding: 0 0 var(--tz-space-7);
  margin: 0;
  background: none;
  border: 0;
}
body.home-atlas .reading-room.atlas::before,
body.home-atlas .reading-room.atlas::after { display: none; }

body.home-atlas .word-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0 var(--tz-space-3);
  align-content: start;
  max-height: 336px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: var(--tz-space-2) var(--tz-space-1);
  margin: 0;
  border: 0;
  border-top: var(--tz-border) solid var(--tz-line-strong);
  border-bottom: var(--tz-border) solid var(--tz-line-strong);
  scrollbar-width: thin;
}
body.home-atlas .word-list::before,
body.home-atlas .word-list::after { display: none; }

body.home-atlas .word-list .rr-chip {
  display: flex;
  align-items: center;
  gap: var(--tz-space-2);
  width: 100%;
  min-width: 0;
  min-height: 30px;
  margin: 0;
  padding: 4px var(--tz-space-1);
  font-family: var(--tz-font-ui);
  font-size: 14px;
  line-height: 1.25;
  font-weight: 400;
  text-align: left;
  white-space: normal;
  color: var(--tz-ink-2);
  background: none;
  border: 0;
  border-radius: var(--tz-radius-sm);
  cursor: pointer;
  transition: background var(--tz-dur-fast) var(--tz-ease), color var(--tz-dur-fast) var(--tz-ease);
}
body.home-atlas .word-list .rr-chip::before { display: none; }
body.home-atlas .word-list .rr-chip[hidden] { display: none; }
.rr-chip-label { min-width: 0; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; }
.rr-chip-box {
  position: relative;
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  border: 1.5px solid var(--tz-muted);
  border-radius: 3px;
  background: var(--tz-surface);
  transition: background var(--tz-dur-fast) var(--tz-ease), border-color var(--tz-dur-fast) var(--tz-ease);
}
@media (hover: hover) {
  body.home-atlas .word-list .rr-chip:hover { background: var(--tz-hover-bg); color: var(--tz-ink); }
  body.home-atlas .word-list .rr-chip:hover .rr-chip-box { border-color: var(--tz-ink); }
}
body.home-atlas .word-list .rr-chip:focus-visible { outline: 2px solid var(--tz-focus); outline-offset: 1px; }
/* Checked: filled box + check mark + bold ink label (not color alone). */
body.home-atlas .word-list .rr-chip.is-on {
  color: var(--tz-ink);
  font-weight: 600;
  background: none;
}
body.home-atlas .word-list .rr-chip.is-on .rr-chip-box {
  background: var(--pip-color, var(--tz-accent));
  border-color: var(--pip-color, var(--tz-accent));
}
body.home-atlas .word-list .rr-chip.is-on .rr-chip-box::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 0;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.atlas-empty {
  margin: var(--tz-space-4) 0;
  font-family: var(--tz-font-ui);
  color: var(--tz-muted);
}
body.home-atlas .compare-clear {
  font-family: var(--tz-font-ui);
  font-size: var(--tz-button-size);
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
  color: var(--tz-ink);
  background: transparent;
  border: var(--tz-border) solid var(--tz-line-strong);
  border-radius: var(--tz-radius);
  padding: 8px var(--tz-space-4);
  cursor: pointer;
}
body.home-atlas .compare-clear:hover { background: var(--tz-ink); color: var(--tz-paper); }
body.home-atlas .compare-clear:focus-visible { outline: 2px solid var(--tz-focus); outline-offset: 2px; }
body.home-atlas .compare-clear[hidden] { display: none; }

/* ---------- Graph box: illustration plates embedded above the chart - */
.compare-panel {
  margin-top: var(--tz-space-5);
  padding: var(--tz-space-5);
  background: var(--tz-surface);
  border: var(--tz-border) solid var(--tz-line);
  border-radius: var(--tz-radius-lg);
  scroll-margin-top: var(--tz-space-4);
}
.compare-empty {
  margin: 0;
  font-family: var(--tz-font-ui);
  font-size: 15px;
  color: var(--tz-muted);
}
.compare-empty[hidden] { display: none; }
.compare-count {
  margin: var(--tz-space-3) 0 0;
  font-family: var(--tz-font-ui);
  font-size: var(--tz-meta-size);
  color: var(--tz-muted);
  text-align: right;
}
.compare-count:empty { display: none; }

.compare-plates {
  display: flex;
  flex-wrap: wrap;
  gap: var(--tz-space-2);
  list-style: none;
  margin: 0;
  padding: 0;
}
.compare-plates:empty { display: none; }
/* Each charted word: a label ringed in its line color (the legend). */
.compare-plate {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--tz-space-2);
  padding: 4px 4px 4px var(--tz-space-3);
  background: var(--tz-paper);
  border: var(--tz-border-strong) solid var(--pip-color, var(--tz-accent));
  border-radius: 999px;
  animation: atlas-pop var(--tz-dur) var(--tz-ease);
}
.compare-plate::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pip-color, var(--tz-accent));
}
.plate-caption {
  display: inline-flex;
  align-items: baseline;
  gap: var(--tz-space-2);
}
.plate-name {
  font-family: var(--tz-font-display);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--tz-ink);
  text-decoration: none;
}
.plate-name:hover { text-decoration: underline; text-underline-offset: 3px; }
.plate-trend {
  font-family: var(--tz-font-ui);
  font-size: var(--tz-caption-size);
  font-weight: 600;
  white-space: nowrap;
}
.plate-trend.is-rise    { color: var(--tz-rise); }
.plate-trend.is-decline { color: var(--tz-decline); }
.plate-x {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  color: var(--tz-ink-2);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.plate-x:hover { background: var(--tz-hover-bg); color: var(--tz-ink); }
.plate-x:focus-visible { outline: 2px solid var(--tz-focus); outline-offset: 1px; }

/* One word: its name becomes the chart's title. */
.compare-plates.is-single .compare-plate {
  width: 100%;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}
.compare-plates.is-single .compare-plate::before { display: none; }
.compare-plates.is-single .plate-caption { flex: 1 1 auto; gap: var(--tz-space-3); }
.compare-plates.is-single .plate-name {
  font-size: var(--tz-h1-size);
  line-height: var(--tz-h1-lh);
}
.compare-plates.is-single .plate-trend { font-size: 15px; }

body.home-atlas .compare-panel .rr-chart-wrap {
  margin-top: var(--tz-space-5);
  padding: var(--tz-space-4) 0 0;
  height: 340px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
body.home-atlas .compare-panel .rr-chart-wrap::before { display: none; }

/* ---------- Explainer (text-dense break between visual sections) ---- */
.atlas-explain {
  padding: var(--tz-space-6) 0 var(--tz-space-7);
  border-top: var(--tz-border) solid var(--tz-line);
}
.explain-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--tz-space-5);
  margin-top: var(--tz-space-4);
}
.explain-h3 {
  margin: 0 0 var(--tz-space-2);
  font-family: var(--tz-font-display);
  font-size: var(--tz-h3-size);
  line-height: var(--tz-h3-lh);
  font-weight: 600;
}
.explain-item p {
  margin: 0;
  font-family: var(--tz-font-ui);
  font-size: 15px;
  line-height: var(--tz-body-lh);
  color: var(--tz-ink-2);
}

/* ---------- Community ---------------------------------------------- */
/* The section h2 names it; keep the embed's CTA link, drop its title. */
body.home-atlas .atlas-community .ce-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
body.home-atlas .atlas-community .ce-head { justify-content: flex-end; margin-top: calc(-1 * var(--tz-space-7)); }
.atlas-community {
  padding: var(--tz-space-6) 0 var(--tz-space-7);
  border-top: var(--tz-border) solid var(--tz-line);
}

/* ---------- Compare dock (appears once something is selected and the
   compare panel is off screen) --------------------------------------- */
.compare-dock {
  position: fixed;
  left: 50%;
  bottom: var(--tz-space-5);
  z-index: 70;
  display: flex;
  align-items: center;
  gap: var(--tz-space-3);
  padding: var(--tz-space-2) var(--tz-space-2) var(--tz-space-2) var(--tz-space-4);
  font-family: var(--tz-font-ui);
  font-size: 14px;
  white-space: nowrap;
  color: var(--tz-paper);
  background: var(--tz-ink);
  border-radius: 999px;
  box-shadow: var(--tz-shadow-lift);
  transform: translateX(-50%);
  animation: atlas-dock-in var(--tz-dur) var(--tz-ease);
}
.compare-dock[hidden] { display: none; }
.compare-dock-go {
  padding: 8px var(--tz-space-4);
  font-weight: 600;
  color: var(--tz-ink);
  background: var(--tz-paper);
  border-radius: 999px;
  text-decoration: none;
}
.compare-dock-go:focus-visible { outline: 2px solid var(--tz-focus); outline-offset: 2px; }

/* ---------- Motion -------------------------------------------------- */
@keyframes atlas-pop {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
@keyframes atlas-dock-in {
  from { transform: translate(-50%, 12px); opacity: 0; }
  to   { transform: translate(-50%, 0);    opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  body.home-atlas *, body.home-atlas *::before, body.home-atlas *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Tablet / small laptop ------------------------------------ */
@media (min-width: 721px) and (max-width: 1099px) {
  body.home-atlas .word-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 721px) and (max-width: 959px) {
  body.home-atlas .word-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .explain-grid { grid-template-columns: 1fr; }
}

/* ---------- Mobile -------------------------------------------------- */
@media (max-width: 720px) {
  .atlas-intro { padding: var(--tz-space-2) 0 var(--tz-space-3); }
  body.home-atlas .atlas-lede { font-size: 15px; }
  .atlas-search { flex: 1 1 auto; }

  /* Dense three-column list, as before the facelift. */
  body.home-atlas .word-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0 var(--tz-space-2);
    max-height: 264px;
    padding: var(--tz-space-1) 0;
  }
  body.home-atlas .word-list .rr-chip {
    min-height: 0;
    gap: 6px;
    padding: 4px 2px;
    font-size: 13px;
  }
  .rr-chip-box { width: 13px; height: 13px; }
  body.home-atlas .word-list .rr-chip.is-on .rr-chip-box::after { left: 3px; width: 3px; height: 7px; }

  .compare-panel { padding: var(--tz-space-4); }
  .plate-name { font-size: 15px; }
  .compare-plates.is-single .plate-name { font-size: 28px; }
  body.home-atlas .compare-panel .rr-chart-wrap { height: 280px; margin-top: var(--tz-space-4); }

  .explain-grid { grid-template-columns: 1fr; gap: var(--tz-space-4); }
  .compare-dock { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
