/*
  Splendid writing modules - shared styles for the reusable article modules.

  This file is ADDITIVE. It holds the newer, self-contained writing modules
  (interactive charts, the editorial timeline). The older module classes
  (.article-fold, .pull-quote, .pop-viz, .rank-list, .ratio-icons, .offer-card,
  .move-list, .reveal, .talking-head, etc.) still live in custom.css and are
  catalogued in writing/MODULES.md. Editing a module here updates every article
  that links this file, because there is no build step and the stylesheet is shared.

  Brand rules that apply to everything here (see our-brand SKILL §5-§8):
  - Data viz palette: Lagoon primary, Poppy + Lake as accents, Daffodil sparingly.
  - Body in Mulish, display/labels in Big Shoulders Display (Hanley substitute).
  - Reduced motion is always honored: no movement, final state shown immediately.

  Load order in an article: bootstrap.min.css -> custom.css -> modules.css.
*/

/* ============================================================
   Chart module (charts.js)
   <figure class="se-chart" data-se-chart> + a JSON <script>.
   ============================================================ */
.se-chart {
  margin: 2.25rem 0;
}
.se-chart-title {
  font-family: 'Big Shoulders Display', 'Mulish', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 1.05rem;
  color: var(--lagoon);
  margin-bottom: 0.85rem;
  line-height: 1.15;
}
.se-chart-surface {
  position: relative;
  width: 100%;
}
.se-chart-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

/* Axes + grid: quiet, editorial. The data carries the color, not the chrome. */
.se-chart-grid {
  stroke: var(--line);
  stroke-width: 1;
  shape-rendering: crispEdges;
}
.se-chart-axis {
  font-family: 'Mulish', system-ui, sans-serif;
  font-size: 12px;
  fill: var(--muted);
}
.se-chart-axis-y { text-anchor: end; }
.se-chart-axis-x { text-anchor: middle; }

/* Marks. Lines echo the 2.5px brand stroke; bars get a hairline tidy radius. */
.se-chart-bar { transition: opacity 0.15s ease; }
.se-chart-bar:hover { opacity: 0.86; }
.se-chart-line {
  fill: none;
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.se-chart-area { opacity: 0.12; }
.se-chart-dot {
  stroke: var(--snow);
  stroke-width: 2;
  transition: r 0.12s ease;
}
.se-chart-dot:hover { r: 6; }
.se-chart-bar:focus-visible,
.se-chart-dot:focus-visible {
  outline: 2px solid var(--poppy);
  outline-offset: 2px;
}

/* Hover / focus readout. */
.se-chart-tip {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  background: var(--lagoon);
  color: #fff;
  font-family: 'Mulish', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(21, 48, 71, 0.18);
}

/* Legend = toggle chips for multi-series charts. */
.se-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin-top: 1rem;
}
.se-chart-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--snow);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.85rem 0.35rem 0.6rem;
  font-family: 'Mulish', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--lagoon);
  cursor: pointer;
  transition: border-color 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}
.se-chart-chip:hover { border-color: var(--lagoon); }
.se-chart-chip.is-off { opacity: 0.45; }
.se-chart-chip.is-off .se-chart-swatch { background: var(--muted) !important; }
.se-chart-chip:focus-visible { outline: 2px solid var(--poppy); outline-offset: 2px; }
.se-chart-swatch {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 3px;
  flex: none;
}

/* Visible data table (no-JS fallback or reduced-data view). */
.se-chart-table table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Mulish', sans-serif;
  font-size: 0.95rem;
  margin-top: 1rem;
}
.se-chart-table th,
.se-chart-table td {
  border: 1px solid var(--line);
  padding: 0.5rem 0.75rem;
  text-align: right;
}
.se-chart-table th:first-child,
.se-chart-table td:first-child { text-align: left; }
.se-chart-table thead th {
  background: var(--ash);
  font-family: 'Big Shoulders Display', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.8rem;
}

/* On a Lagoon surface, flip the chrome to light (charts usually live on light). */
.bg-lagoon .se-chart-title { color: #fff; }
.bg-lagoon .se-chart-axis { fill: rgba(255, 255, 255, 0.7); }
.bg-lagoon .se-chart-grid { stroke: rgba(255, 255, 255, 0.18); }
.bg-lagoon .se-chart-chip { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.3); }
.bg-lagoon .se-chart-dot { stroke: var(--lagoon); }

@media (prefers-reduced-motion: reduce) {
  .se-chart-bar,
  .se-chart-line,
  .se-chart-dot,
  .se-chart-area { transition: none !important; }
}

/* ============================================================
   Timeline module (CSS only; pairs with .reveal for animate-in)
   <ol class="se-timeline"> <li class="se-timeline-item reveal"> ...
   ============================================================ */
.se-timeline {
  list-style: none;
  margin: 2.25rem 0;
  padding: 0;
  position: relative;
}
/* The spine. */
.se-timeline::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--line);
}
.se-timeline-item {
  position: relative;
  padding: 0 0 1.75rem 2.5rem;
}
.se-timeline-item:last-child { padding-bottom: 0; }
/* The node on the spine. */
.se-timeline-item > .se-timeline-marker {
  position: absolute;
  left: 0;
  top: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--snow);
  border: 3px solid var(--poppy);
  box-sizing: border-box;
}
.bg-ash .se-timeline-item > .se-timeline-marker,
.bg-ash-warm .se-timeline-item > .se-timeline-marker { background: var(--ash); }
.se-timeline-date {
  display: inline-block;
  font-family: 'Big Shoulders Display', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.8125rem;
  color: var(--poppy);
  margin-bottom: 0.25rem;
}
.se-timeline-title {
  font-size: 1.25rem;
  margin: 0 0 0.4rem;
  line-height: 1.15;
}
.longform .se-timeline-item p { margin-bottom: 0; }

/* ============================================================
   ASCII art module (ascii.js)
   <figure class="se-ascii"> + <pre class="se-ascii-art"> ; generate with
   scripts/asciify.mjs. The JS scales the glyphs so the art fits any width.
   ============================================================ */
.se-ascii {
  margin: 2.25rem 0;
  text-align: center;
}
.se-ascii-art {
  display: block;
  width: fit-content;             /* shrink to the art so margin auto centers it in the column */
  max-width: 100%;
  margin: 0 auto;
  font-family: var(--op-mono, ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace);
  font-size: 9px;                 /* a sane base; ascii.js overrides to fit the container */
  line-height: 1;
  white-space: pre;
  overflow: hidden;               /* ascii.js fits the art to the column; clip rather than become a scroll container */
  color: var(--lagoon);
  text-align: left;
  -webkit-font-smoothing: none;   /* crisper glyph grid */
}
.se-ascii-caption {
  margin-top: 0.85rem;
  font-family: 'Mulish', sans-serif;
  font-size: 0.9rem;
  color: var(--muted);
}
.se-ascii.poppy .se-ascii-art { color: var(--poppy); }
.se-ascii.lake  .se-ascii-art { color: var(--lake); }
/* Lagoon surface: pair with `asciify --invert` so the art reads light-on-dark. */
.se-ascii.on-lagoon {
  background: var(--lagoon);
  padding: 2rem 1rem;
  border-radius: 6px;
}
.se-ascii.on-lagoon .se-ascii-art { color: var(--snow); }
.se-ascii.on-lagoon .se-ascii-caption { color: rgba(255, 255, 255, 0.7); }

/* ============================================================
   Framework matrix module (matrix.js)
   <figure class="se-matrix" data-se-matrix> + a JSON <script>. A labeled grid;
   each cell reveals its detail on hover, tap, or keyboard focus.
   ============================================================ */
.se-matrix {
  margin: 2.25rem 0;
}
.se-matrix-title {
  font-family: 'Big Shoulders Display', 'Mulish', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 1.05rem;
  color: var(--lagoon);
  margin-bottom: 0.85rem;
  line-height: 1.15;
}
.se-matrix-wrap {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}
.se-matrix-ylabel {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  align-self: center;
  font-family: 'Big Shoulders Display', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--muted);
}
.se-matrix-grid {
  display: grid;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.se-matrix-colhead,
.se-matrix-rowhead {
  font-family: 'Big Shoulders Display', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  color: var(--lagoon);
  display: flex;
  align-items: center;
}
.se-matrix-colhead { justify-content: center; text-align: center; padding: 0.25rem; }
.se-matrix-rowhead { justify-content: flex-end; text-align: right; padding-right: 0.6rem; }
.se-matrix-cell {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  align-items: flex-start;
  text-align: left;
  background: var(--ash);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.7rem 0.8rem;
  min-height: 64px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.se-matrix-cell:hover { border-color: var(--lagoon); }
.se-matrix-cell.is-active {
  border-color: var(--poppy);
  background: var(--snow);
  box-shadow: 0 4px 16px rgba(21, 48, 71, 0.08);
}
.se-matrix-cell:focus-visible { outline: 2px solid var(--poppy); outline-offset: 2px; }
.se-matrix-cell.is-empty { background: transparent; border-style: dashed; cursor: default; }
.se-matrix-cell-title {
  font-family: 'Mulish', sans-serif;
  font-weight: 700;
  font-size: 0.98rem;
  line-height: 1.2;
  color: var(--lagoon);
}
.se-matrix-cell-tag {
  font-family: 'Big Shoulders Display', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.68rem;
  color: var(--poppy);
}
.se-matrix-xlabel {
  text-align: center;
  font-family: 'Big Shoulders Display', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.5rem;
  margin-left: 1.5rem;
}
.se-matrix-detail {
  margin-top: 1.25rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  min-height: 4.5rem;
}
.se-matrix-detail-coord {
  display: block;
  font-family: 'Big Shoulders Display', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  color: var(--poppy);
  margin-bottom: 0.3rem;
}
.se-matrix-detail-title {
  display: block;
  font-family: 'Big Shoulders Display', 'Mulish', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 1.2rem;
  color: var(--lagoon);
  line-height: 1.1;
  margin-bottom: 0.35rem;
}
.se-matrix-detail-body {
  font-family: 'Mulish', sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--lagoon);
  margin: 0;
}
@media (max-width: 600px) {
  .se-matrix-cell { padding: 0.5rem 0.55rem; min-height: 52px; }
  .se-matrix-cell-title { font-size: 0.85rem; }
  .se-matrix-colhead, .se-matrix-rowhead { font-size: 0.68rem; letter-spacing: 0.04em; }
}
@media (prefers-reduced-motion: reduce) {
  .se-matrix-cell { transition: none; }
}

/* ============================================================
   Subscribe (mailing list) - posts to a HubSpot form
   ============================================================ */
.se-subscribe {
  max-width: 30rem;
  margin: 0 auto;
  text-align: center;
}
.se-subscribe-eyebrow {
  font-family: 'Big Shoulders Display', sans-serif;
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--poppy);
  margin: 0 0 0.4rem;
}
.se-subscribe-title {
  font-size: 1.5rem;
  line-height: 1.15;
  margin: 0 0 1rem;
}
.se-subscribe-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
.se-subscribe-input {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: 1rem;
  padding: 0.7rem 0.9rem;
  color: var(--lagoon);
  background: var(--snow, #fff);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  appearance: none;
}
.se-subscribe-input::placeholder { color: var(--muted); }
.se-subscribe-input:focus-visible {
  outline: none;
  border-color: var(--lagoon);
  box-shadow: 0 0 0 3px rgba(55, 123, 219, 0.25);
}
.se-subscribe-btn {
  flex: 0 0 auto;
  font-family: 'Big Shoulders Display', sans-serif;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.95rem;
  color: #fff;
  background: var(--poppy);
  border: 1.5px solid var(--poppy);
  border-radius: 8px;
  padding: 0.7rem 1.4rem;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.se-subscribe-btn:hover { filter: brightness(0.94); }
.se-subscribe-btn:focus-visible { outline: 3px solid var(--lake, #377BDB); outline-offset: 2px; }
.se-subscribe-btn:disabled { opacity: 0.6; cursor: default; }
.se-subscribe-msg {
  margin: 0.7rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
  min-height: 1.2em;
}
.se-subscribe-msg.is-error { color: var(--poppy); }
.se-subscribe.is-done .se-subscribe-row { display: none; }
.se-subscribe.is-done .se-subscribe-msg { font-size: 1.05rem; color: var(--lagoon); }

/* On a dark Lagoon band */
.se-subscribe.on-lagoon .se-subscribe-title { color: #fff; }
.se-subscribe.on-lagoon .se-subscribe-input { background: rgba(255,255,255,0.96); border-color: transparent; }
.se-subscribe.on-lagoon .se-subscribe-msg { color: rgba(255,255,255,0.85); }
.se-subscribe.on-lagoon.is-done .se-subscribe-msg { color: #fff; }

@media (max-width: 540px) {
  .se-subscribe-row { flex-direction: column; }
}

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