/*
 * Maternity edition — UI components. Each block styles one component from
 * assets/js/components/. Components render light DOM, so tokens apply.
 */

/* ---- <m-figure>: the frame every chart sits in ----------------------------- */
/* A bounded card: name and units on top, key numbers in an inset, the plot,
   and a bar with About · Link · PNG. Method text opens in the About panel. */
m-figure { display: block; width: 100%; max-width: var(--fig-max); margin: 0 auto; container-type: inline-size; scroll-margin-top: calc(var(--nav-h) + 16px); }
.fig { width: 100%; margin: 0; color: var(--ink); }
.fig-frame {
  position: relative;
  border: 1px solid var(--fig-border);
  border-radius: var(--radius-m);
  background: var(--fig-bg);
  padding: 22px 26px 10px;
}
.fig-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 14px 28px; }
.fig-title {
  font-family: var(--font-display);
  font-size: var(--fs-fig-title);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -.005em;
  color: var(--ink);
  max-width: 40ch;
  margin: 0;
}
.fig-sub { margin: 7px 0 0; font-family: var(--font-mono); font-size: 11px; line-height: 1.5; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); max-width: 70ch; }
/* key numbers, boxed at the top right */
.fig-inset { border: 1px solid var(--fig-border); border-radius: var(--radius-s); padding: 10px 14px; background: var(--bg); min-width: 200px; }
.fig-inset dl { margin: 0; display: grid; gap: 7px; }
.fig-inset div { display: flex; justify-content: space-between; align-items: baseline; gap: 18px; }
.fig-inset dt { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.fig-inset dd { margin: 0; font-family: var(--font-mono); font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; }
.fig-controls:not(:empty) { margin-top: 22px; }
.fig-body { position: relative; }
.fig-plot { position: relative; min-width: 0; margin-top: 18px; overflow: visible; }
.fig-note:not(:empty) { margin-top: 18px; }
/* the bar: About · Link · PNG */
.fig-bar { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 16px; }   /* no rule above the bar */
.fig-status { margin-right: auto; font-family: var(--font-mono); font-size: var(--fs-ui); color: rgba(var(--ink-rgb), .6); }
.fig-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px 0 9px;
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .02em;
  color: rgba(var(--ink-rgb), .62);
  background: none;
  border: 1px solid var(--fig-border);
  border-radius: 0;   /* square buttons, like the square chart cards */
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.fig-btn:hover, .fig-btn[aria-expanded="true"] { background: rgba(var(--ink-rgb), .06); color: var(--ink); border-color: rgba(var(--ink-rgb), .3); }
.fig-btn:focus-visible, .fig-info-close:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
/* About this chart: a paper panel over the plot */
.fig-info {
  position: absolute; inset: 8px 0 0; z-index: 5;
  overflow: auto;
  padding: 18px 22px 20px;
  background: var(--fig-bg);
  border: 1px solid var(--fig-border);
  border-radius: 0;
  box-shadow: 0 18px 44px -18px rgba(var(--ink-rgb), .38);
  outline: none;
}
.fig-info[hidden] { display: none; }
.fig-info-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; }
.fig-info-kicker { margin: 0; font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.fig-info-close { display: grid; place-items: center; width: 30px; height: 30px; color: var(--ink); background: none; border: 1px solid var(--fig-border); border-radius: 0; cursor: pointer; }
.fig-info-body { max-width: 68ch; }
.fig-info-body h3 { margin: 16px 0 6px; font-family: var(--font-display); font-size: 17px; font-weight: 550; line-height: 1.3; }
.fig-info-body p, .fig-info-body li { margin: 0; font-family: var(--font-sans); font-size: 14.5px; line-height: 1.6; color: rgba(var(--ink-rgb), .85); }
.fig-info-body ul { margin: 0; padding-left: 1.1em; display: grid; gap: 4px; }
/* the plot needs room for the panel when it opens over a short chart */
m-figure.info-open .fig-body { min-height: 300px; }

@container (width <= 640px) {
  .fig-frame { padding: 16px 14px 8px; border-radius: var(--radius-s); }
  .fig-head { grid-template-columns: minmax(0, 1fr); }
  .fig-title { max-width: none; font-size: 19px; }
  .fig-inset { min-width: 0; }
  .fig-inset dl { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; }
  .fig-inset div { flex-direction: column-reverse; align-items: flex-start; gap: 2px; min-width: 0; }
  .fig-inset dt { font-size: 10px; letter-spacing: .06em; }
  .fig-inset dd { white-space: normal; overflow-wrap: anywhere; font-size: 14px; line-height: 1.2; }
  .fig-plot { margin-top: 14px; }
  .fig-btn { padding: 0 10px; min-height: 36px; }
  .fig-btn span { display: none; }
  .fig-info { padding: 14px 14px 16px; }
}

/* ---- icon button (journey, sheets) -------------------------------------------- */
.btn-icon {
  display: flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 11px 0 9px;
  color: rgba(var(--ink-rgb), .62);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.btn-icon span { font-family: var(--font-mono); font-size: var(--fs-ui); letter-spacing: .02em; white-space: nowrap; }
.btn-icon:hover { background: rgba(var(--ink-rgb), .06); color: var(--ink); border-color: rgba(var(--ink-rgb), .2); }

/* ---- tooltip layer (one per chart) ------------------------------------------ */
.tip-layer { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.tip {
  position: absolute; top: 0; left: 0;
  width: max-content; max-width: 300px;
  padding: 8px 10px;
  font-family: var(--font-mono);
  color: var(--tooltip-ink);
  background: var(--bg);
  border: 1px solid var(--tooltip-line);
  border-radius: var(--radius-s);
  opacity: 0;
}
.tip.ready { opacity: 1; }
.tip.glide { transition: translate .15s var(--rv-ease); }
.tip .tt-title { font-size: 11px; font-weight: 500; letter-spacing: .02em; white-space: nowrap; margin-bottom: 3px; }
.tip .tt-hero { font-size: 13px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; margin: -1px 0 3px; }
.tip .tt-row { display: flex; align-items: baseline; gap: 10px; font-size: 11px; font-weight: 300; line-height: 1.45; white-space: nowrap; }
.tip .tt-row strong { margin-left: auto; padding-left: 10px; font-weight: 500; font-variant-numeric: tabular-nums; }
.tip .tt-row .tt-sub { opacity: .6; padding-left: 8px; font-size: 10px; font-weight: 300; font-variant-numeric: tabular-nums; }
.tip .tt-swatch { flex: none; width: 8px; height: 8px; border-radius: 50%; }
.tip .tt-note { opacity: .72; white-space: normal; margin-top: 5px; font-size: 10px; font-weight: 300; line-height: 1.45; }
@media (prefers-reduced-motion: reduce) { .tip.glide { transition: none; } }

/* ---- legend ----------------------------------------------------------------- */
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0 0; padding: 0; list-style: none; }
.legend-item {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: var(--fs-ui); font-weight: 500; color: var(--ink);
}
.swatch { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--swatch, var(--ink)); }
.chart > .legend { gap: 6px 22px; margin-top: 14px; padding-left: 4px; }
.chart > .legend .legend-item { font-size: 13px; font-weight: 400; color: rgba(var(--ink-rgb), .6); }
.chart > .legend .swatch { width: 9px; height: 9px; }

/* ---- pills / segmented tabs ------------------------------------------------- */
.pills { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.pill {
  font-family: var(--font-mono); font-size: var(--fs-ui); letter-spacing: .02em;
  padding: 5px 12px;
  color: rgba(var(--ink-rgb), .7);
  background: transparent;
  border: 1px solid rgba(var(--ink-rgb), .2);
  border-radius: 96px;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.pill:hover { color: var(--ink); border-color: rgba(var(--ink-rgb), .5); }
.pill[aria-pressed="true"], .pill[aria-selected="true"] { color: var(--bg); background: var(--ink); border-color: var(--ink); }

/* ---- <m-theme-toggle> ------------------------------------------------------- */
.theme-toggle {
  position: relative; flex: none;
  width: 32px; height: 32px; padding: 0;
  color: var(--ink);
  background: none;
  border: 1.1px solid rgba(var(--ink-rgb), .2);
  border-radius: 50%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.theme-toggle:hover { border-color: rgba(var(--ink-rgb), .5); }
.theme-toggle .icon { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }

/* ---- navigation: <m-brandbar>, <m-contents> → styles/parts/nav.css ---------- */

/* ---- the standard bar at the foot of a chart card (bare figures: the pictograms) ------------------------------- */
.fig-card-bar { margin-top: 24px; }
.fig-card-bar .fig-replay { order: -1; }
.fig-card-bar .fig-status { margin-left: 4px; }
/* a chart card's About: a panel over the card's chart, above its bar (the card is the positioning box) */
.fig-bare > :first-child { position: relative; }
.fig-info.fig-info-card { position: absolute; top: auto; left: clamp(14px, 2vw, 24px); right: clamp(14px, 2vw, 24px); bottom: 64px; max-height: min(70vh, calc(100% - 96px)); z-index: 6; margin: 0; overflow: auto; }   /* anchored just above the bar, growing upward, so it opens where it was clicked */
