/* Political families short read: seat charts, the state-by-state mosaic and,
 * when a state is opened, its family trees, each with its label and key beside
 * it. Info blue marks people in office today; Brass marks relatives who held
 * office before; a Deep Basalt edge marks PM, CM, Deputy CM or Governor. */

/* ---------- figure panel ---------- */
/* The figure footer (brand, source and data tools, shared with the AI Data
 * Byte) closes the panel edge to edge, so the panel has no bottom padding. */
.mosaic {
  --mosaic-pad: 32px;
  padding: 24px var(--mosaic-pad) 0;
}
.mosaic > .byte-figure-footer {
  margin: 24px calc(-1 * var(--mosaic-pad)) 0;
}
/* All figure text is sans and follows the shared chart type scale in
 * foundation.css: title, subtitle, legend and notes. Serif stays outside the
 * figure, for the page headline and the story heading. No divider sits
 * directly below the figure title. */
.mosaic__header {
  margin-bottom: 24px;
}
.mosaic__header h2 {
  max-width: 48rem;
  font-size: var(--chart-title-size);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.012em;
  text-wrap: pretty;
}
.mosaic__header p {
  max-width: 46rem;
  margin-top: 8px;
  color: var(--graphite);
  font-size: var(--chart-subtitle-size);
  line-height: 1.5;
}
.mosaic__part + .mosaic__part {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--limestone);
}
.mosaic__head {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}
.mosaic__head h3 {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
}
.mosaic__head p,
.mosaic__notes {
  max-width: 760px;
  color: var(--graphite);
  line-height: 1.5;
}
.mosaic__head p {
  font-size: var(--chart-subtitle-size);
}
.mosaic__head a {
  color: var(--ink);
  text-underline-offset: 3px;
}
/* Each key sits directly above the marks it explains. Swatches are pinned to
 * the first line of their label, as in the two-choices story, so a wrapped
 * label keeps its swatch beside the words. */
.mosaic__key {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin: 0 0 16px;
  padding: 0;
  color: var(--graphite);
  font-size: var(--chart-label-size);
  line-height: 1.4;
  list-style: none;
}
.mosaic__key li {
  position: relative;
  padding-left: 20px;
}
.mosaic__dot,
.mosaic__swatch {
  position: absolute;
  top: calc((1.4em - 12px) / 2);
  left: 0;
  width: 12px;
  height: 12px;
}
.mosaic__dot {
  border-radius: 50%;
  background: var(--info);
}
.mosaic__dot--other {
  background: var(--border);
}
.mosaic__swatch--serving {
  background: var(--info);
}
.mosaic__swatch--former {
  background: var(--brass);
}
/* The chart draws top offices as blue or Brass squares with a Deep Basalt
 * edge, so the swatch shows both fills inside that edge. */
.mosaic__swatch--top {
  background: linear-gradient(135deg, var(--info) 50%, var(--brass) 50%);
  outline: 2px solid var(--basalt-deep);
  outline-offset: -2px;
}
.mosaic__notes {
  margin-top: 16px;
  font-size: var(--chart-meta-size);
}
.mosaic__seats svg,
.mosaic__india svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

/* ---------- sticky navigation and search ---------- */
.mosaic__bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  min-height: 62px;
  margin: 0 calc(-1 * var(--mosaic-pad)) 16px;
  padding: 8px var(--mosaic-pad);
  background: var(--pearl);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.mosaic__where {
  display: flex;
  flex: 1 1 420px;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  min-width: 0;
}
.mosaic__here {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}
.mosaic__hint {
  color: var(--graphite);
  font-size: var(--chart-label-size);
}
.mosaic__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--white);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color 160ms;
}
.mosaic__button:hover {
  border-color: var(--graphite);
}
.mosaic__button[disabled] {
  border-color: var(--limestone);
  color: var(--mist);
  cursor: default;
}
.mosaic__button--step {
  min-width: 44px;
  padding-inline: 0;
  font-size: 20px;
}
.mosaic__button--home {
  gap: 6px;
}
.mosaic__search {
  position: relative;
  flex: 1 1 260px;
  max-width: 400px;
}
.mosaic__search input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--graphite);
  border-radius: 0;
  background: var(--white);
  font-size: 15px;
  appearance: none;
}
.mosaic__search input:focus-visible {
  outline: 0;
  box-shadow: inset 0 0 0 2px var(--info);
}
.mosaic__search ul {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  z-index: 25;
  max-height: 360px;
  margin: 0;
  padding: 4px;
  overflow: auto;
  background: var(--white);
  border: 1px solid var(--basalt);
  list-style: none;
}
.mosaic__search li {
  display: grid;
  padding: 8px 10px;
  cursor: pointer;
}
.mosaic__search li b {
  font-size: 15px;
  font-weight: 600;
}
.mosaic__search li span {
  color: var(--graphite);
  font-size: 13px;
}
.mosaic__search li:hover,
.mosaic__search li[aria-selected="true"] {
  background: var(--pearl-warm);
}

/* ---------- live SVG states ---------- */
.mosaic-block {
  cursor: pointer;
}
.mosaic-block:focus {
  outline: none;
}
.mosaic-block__area {
  transition: fill 120ms;
}
.mosaic-block:hover .mosaic-block__area {
  fill: rgb(228 225 218 / 55%);
}
.mosaic-block:focus-visible .mosaic-block__area {
  stroke: var(--info);
  stroke-width: 3px;
}
.mosaic-family__outline {
  stroke: transparent;
  stroke-width: 2px;
  pointer-events: none;
}
.mosaic-family--active .mosaic-family__outline {
  stroke: var(--ink);
}
.mosaic__seats [data-person] {
  cursor: pointer;
}
.mosaic__seats [data-person]:hover {
  fill: var(--ink);
}

/* ---------- one state: every family as a tree ---------- */
.mosaic-state {
  animation: mosaic-enter 240ms ease;
}
@keyframes mosaic-enter {
  from {
    opacity: 0;
  }
}
.mosaic-state__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 24px;
  padding: 4px 0 24px;
}
.mosaic-state__head h3 {
  font-size: var(--chart-title-size);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.012em;
}
.mosaic-state__head h3:focus {
  outline: none;
}
.mosaic-state__head h3:focus-visible {
  outline: 3px solid var(--info);
  outline-offset: 4px;
}
.mosaic-state__stat {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  color: var(--graphite);
  font-size: 15px;
}
.mosaic-state__stat strong {
  color: var(--info);
  font-size: var(--chart-title-size);
  line-height: 1;
}
.mosaic-state__share {
  width: 150px;
  height: 6px;
  fill: var(--limestone);
}
.mosaic-state__share-fill {
  fill: var(--info);
}
.mosaic-state__note {
  flex-basis: 100%;
  color: var(--graphite);
  font-size: var(--chart-meta-size);
}
.mosaic-state__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(202px, 1fr));
  grid-auto-flow: row dense;
  grid-auto-rows: 4px;
  column-gap: 14px;
}
.mosaic-family {
  align-self: start;
  min-width: 0;
  padding: 14px 12px 12px;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--white);
  border: 1px solid var(--limestone);
  outline: 3px solid transparent;
  outline-offset: 2px;
}
.mosaic-family:focus-visible {
  outline-color: var(--info);
}
.mosaic-family--flash {
  animation: mosaic-flash 1.6s ease 2;
}
@keyframes mosaic-flash {
  30% {
    outline-color: var(--info);
  }
}
.mosaic-family__state {
  margin: -4px 0 8px;
  color: var(--graphite);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.mosaic-state__stepper {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* ---------- family trees (state view and tooltip) ---------- */
.mosaic-tree {
  --tile: 168px;
  --gap: 20px;
  width: max-content;
  margin: 0 auto;
}
.mosaic-tree ul {
  position: relative;
  display: flex;
  justify-content: center;
  margin: 0;
  padding: var(--gap) 0 0;
  list-style: none;
}
.mosaic-tree .mosaic-tree__top {
  align-items: flex-start;
  gap: 16px;
  padding: 0;
}
.mosaic-tree li {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--gap) 5px 0;
}
.mosaic-tree .mosaic-tree__top > li {
  padding: 0;
}
/* Set by political-families.js when a family is wider than its card. Top-level
 * branches are separate subtrees with their own captions and no connecting
 * lines, so they can stack without breaking the tree; narrower tiles keep the
 * widest branch from needing to shrink. */
.mosaic-tree--wrap {
  --tile: 140px;
  max-width: 100%;
}
.mosaic-tree--wrap .mosaic-tree__top {
  flex-wrap: wrap;
  justify-content: safe center;
  row-gap: 20px;
}
.mosaic-tree li > ul::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  height: var(--gap);
  border-left: 1.5px solid var(--slate);
}
.mosaic-tree ul:not(.mosaic-tree__top) > li::before,
.mosaic-tree ul:not(.mosaic-tree__top) > li::after {
  content: "";
  position: absolute;
  top: 0;
  right: 50%;
  width: 50%;
  height: var(--gap);
  border-top: 1.5px solid var(--slate);
}
.mosaic-tree ul:not(.mosaic-tree__top) > li::after {
  right: auto;
  left: 50%;
  border-left: 1.5px solid var(--slate);
}
.mosaic-tree ul:not(.mosaic-tree__top) > li:first-child::before,
.mosaic-tree ul:not(.mosaic-tree__top) > li:last-child::after {
  border: 0;
}
.mosaic-tree ul:not(.mosaic-tree__top) > li:last-child::before {
  border-right: 1.5px solid var(--slate);
}
.mosaic-tree ul:not(.mosaic-tree__top) > li:only-child {
  padding-top: 0;
}
.mosaic-tree ul:not(.mosaic-tree__top) > li:only-child::before,
.mosaic-tree ul:not(.mosaic-tree__top) > li:only-child::after {
  display: none;
}
.mosaic-tree__relation,
.mosaic-tree__caption {
  max-width: var(--tile);
  padding: 2px 0 4px;
  color: var(--graphite);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.2;
  text-align: center;
  text-transform: uppercase;
}
.mosaic-tree__caption {
  padding: 0 0 6px;
}
.mosaic-tree__unit {
  display: flex;
  align-items: stretch;
}
.mosaic-tree__wed {
  flex: none;
  align-self: center;
  width: 14px;
  height: 6px;
  border-top: 1.5px solid var(--slate);
  border-bottom: 1.5px solid var(--slate);
}
.mosaic-tile {
  display: grid;
  align-content: start;
  gap: 2px;
  width: var(--tile);
  padding: 8px 10px 9px;
  text-align: left;
}
.mosaic-tile b {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}
.mosaic-tile span {
  font-size: 12px;
  line-height: 1.3;
}
.mosaic-tile--serving {
  background: var(--info);
  color: var(--white);
}
.mosaic-tile--former {
  background: var(--brass);
  color: var(--ink);
}
.mosaic-tile--top {
  outline: 2.5px solid var(--basalt-deep);
  outline-offset: -2.5px;
}
.mosaic-tile--serving.mosaic-tile--top {
  outline-color: var(--ink);
}
.mosaic-tile--none {
  background: var(--white);
  color: var(--graphite);
  outline: 1.5px solid var(--mist);
  outline-offset: -1.5px;
}
/* Set by political-families.js when even a stacked tree would have to shrink
 * below three quarters (phones): the family becomes an indented list, each
 * generation under its parent along one rule, so every member shows at full
 * size by scrolling down. Selectors mirror the connector rules they cancel. */
.mosaic-tree--list {
  width: auto;
}
.mosaic-tree--list ul,
.mosaic-tree--list .mosaic-tree__top {
  display: grid;
  gap: 8px;
}
.mosaic-tree--list .mosaic-tree__top {
  gap: 16px;
}
.mosaic-tree--list ul:not(.mosaic-tree__top) {
  margin-left: 12px;
  padding: 8px 0 0 12px;
  border-left: 1.5px solid var(--slate);
}
.mosaic-tree--list li {
  align-items: stretch;
  padding: 0;
}
.mosaic-tree--list li > ul::before,
.mosaic-tree--list ul:not(.mosaic-tree__top) > li::before,
.mosaic-tree--list ul:not(.mosaic-tree__top) > li::after {
  display: none;
}
.mosaic-tree--list .mosaic-tree__relation,
.mosaic-tree--list .mosaic-tree__caption {
  max-width: none;
  text-align: left;
}
/* A couple stacks, joined by the marriage mark turned upright. */
.mosaic-tree--list .mosaic-tree__unit {
  flex-direction: column;
}
.mosaic-tree--list .mosaic-tile {
  width: auto;
}
.mosaic-tree--list .mosaic-tree__wed {
  align-self: flex-start;
  width: 6px;
  height: 12px;
  margin-left: 16px;
  border: 0;
  border-inline: 1.5px solid var(--slate);
}

/* ---------- tooltip ---------- */
/* The card sizes itself to the family tree, whatever its position; the
 * script stacks or shrinks the tree only when the window cannot hold it. */
.mosaic-tip {
  position: fixed;
  z-index: 40;
  width: max-content;
  max-width: calc(100vw - 20px);
  padding: 12px 14px 14px;
  overflow: hidden;
  background: var(--white);
  border: 1px solid var(--basalt);
  pointer-events: none;
}
.mosaic-tip--pinned {
  max-height: calc(100vh - 20px);
  overflow: auto;
  pointer-events: auto;
}
.mosaic-tip__title {
  margin-bottom: 10px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
}
.mosaic-tip__title span {
  color: var(--graphite);
  font-size: 13px;
  font-weight: 400;
}
.mosaic-tip .mosaic-tree {
  --tile: 132px;
  --gap: 14px;
  margin: 0;
}
.mosaic-tip .mosaic-tile {
  padding: 6px 8px 7px;
}
.mosaic-tip .mosaic-tile b {
  font-size: 13px;
}
.mosaic-tip__open {
  display: none;
  margin-top: 12px;
}
.mosaic-tip--pinned .mosaic-tip__open {
  display: inline-flex;
}

/* ---------- tables, notes and sources ---------- */
.mosaic-data thead th:not(:first-child) {
  text-align: right;
}
.mosaic-data tbody th sup {
  margin-left: 2px;
}
.mosaic-data tfoot :is(th, td) {
  border-top: 2px solid var(--basalt);
  font-weight: 700;
}
.mosaic-data > p {
  color: var(--graphite);
  line-height: 1.55;
}

@media (max-width: 760px) {
  .mosaic {
    --mosaic-pad: 16px;
    padding-block: 20px 0;
  }
  .mosaic__bar {
    gap: 8px 12px;
    padding-block: 6px;
  }
  .mosaic__where {
    flex-wrap: nowrap;
  }
  .mosaic__here {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mosaic__search {
    flex-basis: 100%;
    max-width: none;
  }
  /* The sticky bar must stay short on phones: the hint repeats the key text,
   * and the back button keeps its words for screen readers only. */
  .mosaic__hint {
    display: none;
  }
  .mosaic__button--home {
    min-width: 44px;
    padding-inline: 0;
  }
  .mosaic__button-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .mosaic-state__grid {
    grid-template-columns: minmax(0, 1fr);
  }
  /* Two tiles and the marriage mark fit a 375px screen. */
  .mosaic-tree {
    --tile: 136px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .mosaic-state,
  .mosaic-family--flash {
    animation: none;
  }
  .mosaic-family--flash {
    outline-color: var(--info);
  }
  .mosaic-block__area,
  .mosaic__button {
    transition: none;
  }
}
@media print {
  .mosaic__bar,
  .mosaic-tip {
    display: none;
  }
}
