/* ==========================================================================
   Data repository chart builder (dataset pages) and dataset chart embeds
   (/embed/data/<slug>): the form, the SVG chart drawn by data-chart.js and the
   embed code. Uses the site tokens (site.css, or embed.css in an embed).
   ========================================================================== */

.dc { --dc-s0: var(--accent, #6E42A6); --dc-s1: #B8862B; }
.dc-embed-fig { --dc-s0: var(--accent, #6E42A6); --dc-s1: #B8862B; }
.dc-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.dc-form {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 14px; margin: 14px 0 0; padding: 14px 16px;
  background: var(--mist, #F4F2F7); border: 1px solid var(--line, #E4E1EA); border-radius: 6px 6px 0 0; border-bottom: 0;
}
.dc-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; margin: 0; padding: 0; border: 0; }
.dc-field label, .dc-field legend { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted, #5D5B54); padding: 0; }
.dc-field select {
  max-width: 15rem; padding: 0.5rem 2rem 0.5rem 0.7rem; font: 0.9rem var(--font); color: var(--text, #1C1C19);
  background: var(--paper, #fff) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%235D5B54' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 0.7rem center;
  border: 1px solid var(--line, #E4E1EA); border-radius: 4px; -webkit-appearance: none; appearance: none;
}
.dc-field select:focus-visible, .dc-type input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.dc-types { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0; }
.dc-types legend { width: 100%; margin-bottom: 4px; }
.dc-type { position: relative; cursor: pointer; }
.dc-type input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.dc-type span { display: inline-block; padding: 0.45rem 0.9rem; font-size: 0.88rem; font-weight: 500; color: var(--ink); background: var(--paper, #fff); border: 1px solid var(--line, #E4E1EA); }
.dc-type:first-of-type span { border-radius: 4px 0 0 4px; }
.dc-type:last-of-type span { border-radius: 0 4px 4px 0; margin-left: -1px; }
.dc-type input:checked + span { color: #fff; background: var(--ink); border-color: var(--ink); }

.dc-figure { margin: 0; padding: 16px 16px 10px; background: var(--paper, #fff); border: 1px solid var(--line, #E4E1EA); border-radius: 0 0 6px 6px; }
.dc-figure[hidden], .dc-embed[hidden], .dc-open[hidden] { display: none; }
.dc-cap { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 14px; margin-bottom: 8px; }
.dc-cap-t { font-family: var(--font-serif); font-size: 1.3rem; font-weight: 560; line-height: 1.2; color: var(--ink); }
.dc-cap-n { font-size: 0.8rem; color: var(--muted); }
.dc-stage { position: relative; min-height: 260px; }
.dc-svg { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--font); }
.dc-grid line { stroke: var(--line, #E4E1EA); stroke-width: 1; }
.dc-grid line.dc-zero { stroke: var(--muted, #5D5B54); }
.dc-grid text, .dc-x text { fill: var(--muted, #5D5B54); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.dc-bar.dc-s0 { fill: var(--dc-s0); }
.dc-bar.dc-s1 { fill: var(--dc-s1); }
.dc-bar:hover { opacity: 0.82; }
.dc-line { fill: none; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.dc-line.dc-s0 { stroke: var(--dc-s0); }
.dc-line.dc-s1 { stroke: var(--dc-s1); }
.dc-area { fill: var(--dc-s0); opacity: 0.1; }
.dc-dot { stroke: var(--paper, #fff); stroke-width: 1.5; }
.dc-dot.dc-s0 { fill: var(--dc-s0); }
.dc-dot.dc-s1 { fill: var(--dc-s1); }
.dc-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 6px; font-size: 0.82rem; color: var(--text); }
.dc-key::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -1px; border-radius: 2px; background: var(--dc-s0); }
.dc-key.dc-s1::before { background: var(--dc-s1); }

@media (prefers-reduced-motion: no-preference) {
  .dc-svg.is-anim .dc-bar { transform-box: fill-box; transform-origin: 50% 100%; animation: dc-grow 0.7s cubic-bezier(.2,.75,.25,1) both; animation-delay: var(--d, 0ms); }
  .dc-svg.is-anim .dc-line { stroke-dasharray: 1; animation: dc-draw 1.2s cubic-bezier(.4,0,.2,1) both; }
  .dc-svg.is-anim .dc-dot, .dc-svg.is-anim .dc-area { animation: dc-fade 0.5s ease 0.8s both; }
}
@keyframes dc-grow { from { transform: scaleY(0); } }
@keyframes dc-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes dc-fade { from { opacity: 0; } }

.dc-embed { margin-top: 14px; }
.dc-embed-l { display: block; margin-bottom: 4px; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.dc-code { width: 100%; padding: 10px 12px; font: 0.8rem/1.5 ui-monospace, 'SFMono-Regular', Menlo, monospace; color: var(--ink); background: var(--mist, #F4F2F7); border: 1px solid var(--line); border-radius: 4px; resize: vertical; }
.dc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 8px; font-size: 0.9rem; }
.dc-actions a { color: var(--accent-dark); font-weight: 600; }
.dc-actions a:hover { text-decoration: underline; }
.dc-status { font-size: 0.85rem; color: var(--muted); }

/* The embed page */
.dc-embed-fig .dc-stage { margin-top: 10px; min-height: 0; }
.dc-data { margin-top: 10px; font-size: 0.85rem; }
.dc-data summary { cursor: pointer; font-weight: 600; color: var(--accent-dark); }
.dc-table { width: 100%; margin-top: 6px; border-collapse: collapse; font-size: 0.85rem; }
.dc-table th, .dc-table td { padding: 5px 8px; text-align: left; border-bottom: 1px solid var(--line); }
.dc-table thead th { font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.dc-table .dc-num { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .dc-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .dc-field select { max-width: none; width: 100%; }
  .dc-types { grid-column: 1 / -1; }
  .dc-open { grid-column: 1 / -1; }
}
