/* ═══════════════════════════════════════════════════════════════
   Advantage Gold chart core — shared chrome for every chart card.

   One engine, three renderers (see chart-core.js):
     milestone  — sparse readings with a labelled strip beneath
     series     — dense time series with callouts and stat pills
     projection — the parametric cash-vs-gold calculator

   Everything sizes in em off a 1cqi root, so a card is resolution
   independent: the same markup renders as a 2000px poster for the
   PNG export and as a phone-width card, with one breakpoint that
   restacks rather than shrinks.
   ═══════════════════════════════════════════════════════════════ */

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: transparent;
}
body.dg-export {
  background: #1f2130;
}

.dg-wrap {
  container-type: inline-size;
  width: 100%;
}

.dg {
  position: relative;
  width: 100%;
  color: #fdfaf6;
  border-radius: 14px;
  overflow: hidden;
  background:
    radial-gradient(
      48% 40% at 88% 2%,
      rgba(217, 198, 133, 0.13),
      rgba(217, 198, 133, 0) 70%
    ),
    linear-gradient(165deg, #272937 0%, #1b1d2b 55%, #14161f 100%);
  font-size: 1cqi;
  padding: 3.4em 4em 3em;
}

/* ── HEADER ── */
.dg__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2.5em;
}
.dg__logo {
  height: 2.4em;
  width: auto;
  display: block;
  margin-bottom: 1.6em;
}
.dg__title {
  font-size: 3.1em;
  font-weight: 200;
  letter-spacing: -0.024em;
  line-height: 1.12;
  color: #fdfaf6;
}
.dg__title em {
  font-style: normal;
  font-weight: 300;
  color: #d9c685;
}
.dg__subtitle {
  margin-top: 1.05em;
  font-size: 1.08em;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: rgba(253, 250, 246, 0.55);
}
.dg__head-aside {
  flex-shrink: 0;
  padding-top: 0.4em;
}

/* ── LEGEND ── */
.dg__legend {
  display: flex;
  flex-direction: column;
  gap: 0.75em;
}
.dg__legend--row {
  flex-direction: row;
  align-items: center;
  gap: 1.98em;
}
.dg__legend-item {
  display: flex;
  align-items: center;
  gap: 0.7em;
  font-size: 0.85em;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: rgba(253, 250, 246, 0.72);
  white-space: nowrap;
}
.dg__swatch {
  flex: none;
  width: 2.2em;
  height: 0.26em;
  border-radius: 2px;
  background: #d9c685;
}

/* ── PLOT ── */
.dg__plot {
  position: relative;
  margin-top: 1.5em;
  display: flex;
  align-items: center;
  gap: 1.6em;
}
.dg__plot-inner {
  position: relative;
  flex: 1;
  min-width: 0;
}
.dg__svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  touch-action: pan-y;
}
.dg__svg:focus {
  outline: none;
}
.dg__svg:focus-visible {
  outline: 2px solid #d9c685;
  outline-offset: 4px;
  border-radius: 6px;
}

/* rotated axis caption, e.g. "COMMODITIES ÷ S&P 500" */
.dg__axis-title {
  flex: none;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 0.72em;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(253, 250, 246, 0.35);
  white-space: nowrap;
}

/* ── CALLOUT PILLS over the plot ── */
.dg__annot {
  position: absolute;
  z-index: 3;
  transform: translateX(-50%);
  padding: 0.5em 0.95em;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.8em;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(253, 250, 246, 0.82);
  white-space: nowrap;
  pointer-events: none;
}
.dg__annot--plain {
  background: none;
  border: 0;
  padding: 0;
  text-align: center;
  line-height: 1.35;
}
.dg__annot-eyebrow {
  display: block;
  font-size: 0.82em;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: rgba(253, 250, 246, 0.45);
}
.dg__annot-value {
  display: block;
  font-weight: 700;
  color: #d9c685;
}

/* ── STAT PILLS beside the plot ── */
.dg__stats {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 1.4em;
  width: 11.5em;
}
.dg__stat {
  padding: 1em 1.2em;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.dg__stat--tight {
  text-align: center;
  padding: 0.9em 1em;
}
.dg__stat-eyebrow {
  font-size: 0.68em;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: rgba(253, 250, 246, 0.45);
}
.dg__stat-value {
  margin-top: 0.25em;
  font-family: Roboto, sans-serif;
  font-size: 1.9em;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: #d9c685;
}
.dg__stat-value--plain {
  color: #fdfaf6;
}
.dg__stat-note {
  margin-top: 0.5em;
  font-size: 0.78em;
  font-weight: 300;
  line-height: 1.45;
  color: rgba(253, 250, 246, 0.6);
}
.dg__stat-foot {
  margin-top: 0.6em;
  font-size: 0.66em;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: rgba(253, 250, 246, 0.35);
}

/* ── TOOLTIP ── */
.dg__tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -112%);
  transition:
    opacity 0.12s ease,
    left 0.12s ease,
    top 0.12s ease;
  font-size: clamp(11px, 0.72em, 15px);
  background: rgba(15, 16, 24, 0.97);
  border: 1px solid rgba(217, 198, 133, 0.32);
  border-radius: 0.6em;
  padding: 0.85em 1.1em;
  min-width: 11em;
  box-shadow: 0 1.2em 2.4em rgba(0, 0, 0, 0.45);
}
.dg__tip.is-on {
  opacity: 1;
}
.dg__tip-date {
  font-size: 0.82em;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: #8f95aa;
  margin-bottom: 0.6em;
}
.dg__tip-date--proj {
  color: #a99c74;
}
.dg__tip-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.4em;
  font-size: 1.05em;
  line-height: 1.5;
}
.dg__tip-key {
  color: #a9aec1;
  font-weight: 400;
  white-space: nowrap;
}
.dg__tip-val {
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}
.dg__tip-val--gold {
  color: #e0cd92;
}

/* ── MILESTONE STRIP ── */
.dg__strip {
  display: grid;
  padding: 0 8.334%;
  margin-top: 0.3em;
}
.dg__ms {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.22em;
  padding: 0.8em 0.2em 0.9em;
  border: 0;
  border-radius: 0.5em;
  background: transparent;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: center;
  transition: background 0.16s ease;
}
.dg__ms:hover,
.dg__ms.is-on {
  background: rgba(217, 198, 133, 0.09);
}
.dg__ms:focus-visible {
  outline: 2px solid #d9c685;
  outline-offset: 2px;
}
.dg__ms-alt {
  font-size: 1em;
  font-weight: 700;
  color: #fdfaf6;
  white-space: nowrap;
}
.dg__ms-gold {
  font-size: 1.3em;
  font-weight: 700;
  letter-spacing: -0.014em;
  line-height: 1.2;
  color: #d9c685;
  white-space: nowrap;
}
.dg__ms-label {
  margin-top: 0.5em;
  padding: 0.4em 0.95em;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: rgba(253, 250, 246, 0.65);
  white-space: nowrap;
}
.dg__ms.is-on .dg__ms-label {
  border-color: rgba(217, 198, 133, 0.55);
  color: #e0cd92;
}

/* ── FOOTER ── */
.dg__foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 3em;
  margin-top: 1.5em;
  padding-top: 1.7em;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.dg__note {
  font-size: 1.18em;
  font-weight: 300;
  line-height: 1.5;
  color: #c7cbd9;
}
.dg__note strong {
  font-weight: 700;
  color: #d9c685;
}
.dg__source {
  font-size: 0.78em;
  font-weight: 700;
  letter-spacing: 0.115em;
  text-transform: uppercase;
  color: #6d7286;
  text-align: right;
  line-height: 1.7;
  white-space: nowrap;
  flex-shrink: 0;
}
.dg__hint {
  font-size: 0.88em;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #6d7286;
  margin-top: 1em;
}
body.dg-export .dg__hint {
  display: none;
}

/* ═══ PROJECTION renderer extras ═══ */
.dg__amount {
  display: flex;
  flex-direction: column;
  gap: 0.55em;
}
body.dg-export .dg__amount {
  display: none;
}
.dg__amount-label {
  font-size: 0.78em;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: rgba(253, 250, 246, 0.45);
}
.dg__amount-field {
  display: flex;
  align-items: center;
  gap: 0.3em;
  border: 1.5px solid rgba(217, 198, 133, 0.35);
  border-radius: 0.5em;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.6em 0.9em;
  transition: border-color 0.15s ease;
}
.dg__amount-field:focus-within {
  border-color: #d9c685;
}
.dg__amount-field span {
  font-family: Roboto, sans-serif;
  font-size: 1.5em;
  font-weight: 700;
  color: rgba(253, 250, 246, 0.55);
}
.dg__amount-field input {
  width: 6.2em;
  border: 0;
  outline: none;
  background: transparent;
  font-family: Roboto, sans-serif;
  font-size: 1.5em;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #d9c685;
}

.dg__cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.73em;
  margin-top: 2.7em;
}
.dg__card {
  display: flex;
  align-items: center;
  gap: 1.73em;
  padding: 1.73em 1.98em;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.dg__card--gold {
  background: rgba(217, 198, 133, 0.07);
  border-color: rgba(217, 198, 133, 0.28);
}
.dg__card img {
  flex: none;
  height: auto;
}
.dg__card-art--cash {
  width: 17.9em;
}
.dg__card-art--coin {
  width: 14.8em;
}
.dg__card-body {
  flex: 1;
  min-width: 0;
}
.dg__card-name {
  font-size: 1.85em;
  font-weight: 300;
  letter-spacing: -0.013em;
  color: #fdfaf6;
}
.dg__card--gold .dg__card-name {
  color: #d9c685;
}
.dg__card-rate {
  display: flex;
  align-items: center;
  gap: 0.62em;
  margin-top: 0.62em;
}
.dg__card-rate svg {
  display: block;
  width: 1.05em;
  height: auto;
}
.dg__card-rate span {
  font-family: Roboto, sans-serif;
  font-size: 1.36em;
  font-weight: 700;
  letter-spacing: -0.014em;
}
.dg__card--cash .dg__card-rate span {
  color: #e0736b;
}
.dg__card--gold .dg__card-rate span {
  color: #8fbf9f;
}
.dg__card-eyebrow {
  margin-top: 1.23em;
  font-size: 0.8em;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(253, 250, 246, 0.45);
}
.dg__card-value {
  margin-top: 0.37em;
  font-family: Roboto, sans-serif;
  font-size: 3.58em;
  font-weight: 700;
  letter-spacing: -0.034em;
  line-height: 1.05;
  color: #fdfaf6;
}
.dg__card--gold .dg__card-value {
  color: #d9c685;
}
.dg__card-delta {
  margin-top: 0.49em;
  font-family: Roboto, sans-serif;
  font-size: 1.05em;
  font-weight: 500;
  color: rgba(253, 250, 246, 0.6);
}
.dg__card-delta b {
  font-weight: 700;
}
.dg__card--cash .dg__card-delta b {
  color: #e0736b;
}
.dg__card--gold .dg__card-delta b {
  color: #8fbf9f;
}

.dg__chart-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2.5em;
  margin: 2.96em 0 0.4em;
}
.dg__chart-label {
  font-size: 0.8em;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(253, 250, 246, 0.45);
}

.dg__benefits {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin-top: 2.7em;
  padding-top: 2.1em;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.dg__benefit {
  padding: 0 1.73em;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}
.dg__benefit:first-child {
  padding-left: 0;
}
.dg__benefit:last-child {
  padding-right: 0;
  border-right: 0;
}
.dg__benefit svg {
  display: block;
  width: 2.1em;
  height: 2.1em;
  fill: none;
  stroke: #d9c685;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.dg__benefit h3 {
  margin-top: 0.99em;
  font-size: 1.17em;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: #fdfaf6;
}
.dg__benefit p {
  margin-top: 0.62em;
  font-size: 0.99em;
  font-weight: 300;
  line-height: 1.6;
  color: rgba(253, 250, 246, 0.6);
}
.dg__disclaimer {
  font-size: 0.84em;
  font-weight: 300;
  line-height: 1.6;
  color: rgba(253, 250, 246, 0.45);
}

/* ═══ CALCULATOR renderer ═══ */
.dg__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1.6em 2.2em;
  align-items: flex-end;
  margin-top: 2.2em;
}
body.dg-export .dg__controls {
  /* the static export is not interactive, so the controls are just noise —
     the index and period they encode move to .dg__result-context instead */
  display: none;
}
body.dg-export .dg__results-lead {
  /* without the controls above it, this needs its own breathing room */
  margin-top: 2em;
}
.dg__ctrl {
  display: flex;
  flex-direction: column;
  gap: 0.55em;
}
.dg__ctrl-label {
  font-size: 0.76em;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: rgba(253, 250, 246, 0.45);
}
.dg__toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
}
.dg__toggle {
  padding: 0.62em 1.1em;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.03);
  font: inherit;
  font-size: 0.86em;
  font-weight: 600;
  color: rgba(253, 250, 246, 0.72);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}
.dg__toggle:hover {
  border-color: rgba(217, 198, 133, 0.6);
  color: #fdfaf6;
}
.dg__toggle.is-on {
  background: #d9c685;
  border-color: #d9c685;
  color: #272937;
}
.dg__toggle:focus-visible {
  outline: 2px solid #d9c685;
  outline-offset: 2px;
}

.dg__results-lead {
  margin-top: 2.2em;
  font-size: 1.15em;
  font-weight: 300;
  color: rgba(253, 250, 246, 0.75);
}
.dg__results-lead strong {
  font-weight: 700;
  color: #fdfaf6;
}
.dg__results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2em;
  margin-top: 0.9em;
}
.dg__result {
  padding: 1.5em 1.8em;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}
.dg__result--gold {
  background: rgba(217, 198, 133, 0.07);
  border-color: rgba(217, 198, 133, 0.28);
}
.dg__result-name {
  font-size: 0.8em;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(253, 250, 246, 0.5);
}
.dg__result--gold .dg__result-name {
  color: #d9c685;
}
.dg__result-value {
  margin-top: 0.3em;
  font-family: Roboto, sans-serif;
  font-size: 3em;
  font-weight: 700;
  letter-spacing: -0.032em;
  line-height: 1.08;
  color: #fdfaf6;
}
.dg__result--gold .dg__result-value {
  color: #d9c685;
}
.dg__result-change {
  margin-top: 0.5em;
  font-family: Roboto, sans-serif;
  font-size: 1.05em;
  font-weight: 500;
  color: rgba(253, 250, 246, 0.55);
}
.dg__result--gold .dg__result-change {
  color: rgba(217, 198, 133, 0.85);
}
.dg__result-context {
  margin-top: 0.9em;
  text-align: center;
  font-size: 0.78em;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(253, 250, 246, 0.42);
}
.dg__winner {
  margin-top: 0.5em;
  text-align: center;
  font-size: 1.15em;
  font-weight: 300;
  color: rgba(253, 250, 246, 0.75);
}
.dg__winner strong {
  font-weight: 700;
  color: #d9c685;
}

/* ═══ NARROW ═══ */
@container (max-width: 760px) {
  .dg {
    font-size: 11.5px;
    padding: 20px 16px 18px;
    border-radius: 10px;
  }
  .dg__head {
    flex-direction: column;
    gap: 1.1em;
  }
  .dg__head-aside {
    padding-top: 0;
  }
  .dg__logo {
    height: 2em;
    margin-bottom: 1.1em;
  }
  .dg__title {
    font-size: 2.05em;
    font-weight: 300;
  }
  .dg__subtitle {
    font-size: 1em;
  }
  .dg__legend {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.8em 1.4em;
  }
  .dg__plot {
    flex-direction: column;
    align-items: stretch;
    gap: 1em;
  }
  .dg__axis-title {
    display: none;
  }
  .dg__stats {
    flex-direction: row;
    width: auto;
    gap: 0.7em;
  }
  .dg__stat {
    flex: 1;
    padding: 0.8em 0.9em;
  }
  .dg__annot {
    font-size: 0.72em;
    padding: 0.35em 0.7em;
  }
  .dg__strip {
    padding: 0;
    gap: 0.3em;
    margin-top: 1em;
  }
  .dg__ms {
    background: rgba(255, 255, 255, 0.035);
    padding: 0.65em 0.4em 0.7em;
  }
  .dg__controls {
    gap: 1.1em 1.4em;
    margin-top: 1.5em;
  }
  .dg__results {
    grid-template-columns: 1fr;
    gap: 0.7em;
  }
  .dg__result-value {
    font-size: 2.4em;
  }
  .dg__results-lead,
  .dg__winner {
    font-size: 1.05em;
  }
  .dg__cards {
    grid-template-columns: 1fr;
    gap: 1em;
    margin-top: 1.6em;
  }
  .dg__card {
    gap: 1.2em;
    padding: 1.2em 1.3em;
  }
  .dg__card-art--cash {
    width: 8.5em;
  }
  .dg__card-art--coin {
    width: 7.2em;
  }
  .dg__card-value {
    font-size: 2.6em;
  }
  .dg__chart-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.8em;
    margin: 1.8em 0 0.4em;
  }
  .dg__benefits {
    grid-template-columns: 1fr 1fr;
    gap: 1.4em 0;
    margin-top: 1.8em;
    padding-top: 1.5em;
  }
  .dg__benefit {
    padding: 0 1em;
  }
  .dg__benefit:nth-child(odd) {
    padding-left: 0;
  }
  .dg__benefit:nth-child(even) {
    padding-right: 0;
    border-right: 0;
  }
  .dg__benefit:last-child {
    grid-column: span 2;
  }
  .dg__foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 1em;
    margin-top: 1.4em;
    padding-top: 1.3em;
  }
  .dg__source {
    text-align: left;
    white-space: normal;
  }
  .dg__note {
    font-size: 1.06em;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dg *,
  .dg *::before,
  .dg *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
