/* The Charles-vs-the-S&P app, layered on site.css (the getponzi.com homepage styles, verbatim).
   Everything here is prefixed ap- so it never collides with a homepage class. */
:root {
  --ink-mute: #7A7872;
  --series-charles: #B8860B; /* validated pair (dataviz validator, light, #FAFAF7): all checks pass */
  --series-spx: #3B5BA9;
}
body { background: var(--bg); overflow-x: hidden; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
@media (max-width: 560px) { .wrap { padding: 0 16px; } }

.ap-ref { background: var(--ink); color: var(--bg); font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; text-align: center; padding: 10px 16px; }
.ap-ref b { color: var(--gold); font-weight: 500; }

/* ------- § 03 layout: header + standing Charles, form beside the live certificate, numbers + chart ------- */
.ap-section .wrap { position: relative; }
.ap-head { position: relative; z-index: 2; max-width: 64%; }
/* Full-length Charles stands in the header's right side; his shoes land on the certificate's corner. */
.ap-standing { position: absolute; right: -56px; top: -84px; width: 300px; z-index: 7; pointer-events: none; }
.ap-standing img { display: block; width: 100%; height: auto; }
.ap-bubble { position: absolute; right: 232px; top: 10px; width: 210px; background: #fff; border: 1px solid var(--ink); border-radius: 14px; padding: 10px 12px; font-family: var(--font-display); font-style: italic; font-size: 19px; line-height: 1.15; box-shadow: 3px 3px 0 var(--ink); }
.ap-deal { display: grid; grid-template-columns: 340px 1fr; gap: 40px; align-items: start; margin: 28px 0 4vw; position: relative; z-index: 3; }
.ap-form { display: grid; gap: 22px; }
.ap-field { display: grid; gap: 8px; }
@media (max-width: 900px) {
  .ap-head { max-width: 72%; }
  .ap-standing { width: 150px; right: -22px; top: -30px; }
  .ap-bubble { display: none; }
  .ap-deal { grid-template-columns: 1fr; gap: 28px; }
}
.ap-money { display: flex; align-items: center; border: 1px solid var(--ink); border-radius: var(--radius); background: #fff; }
.ap-money span { padding: 0 2px 0 14px; font-family: var(--font-mono); font-size: 22px; color: var(--ink-soft); }
.ap-money input { border: 0; background: transparent; font-family: var(--font-mono); font-weight: 500; font-size: 22px; padding: 10px 14px 10px 4px; width: 100%; min-width: 0; color: var(--ink); }
.ap-input { border: 1px solid var(--ink); border-radius: var(--radius); background: #fff; font-family: var(--font-body); font-size: 17px; padding: 12px 14px; width: 100%; min-width: 0; color: var(--ink); }
.ap-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ap-chip { border: 1px solid var(--rule); background: #fff; border-radius: 999px; padding: 8px 14px; min-height: 36px; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; transition: border-color 150ms ease; }
.ap-chip:hover { border-color: var(--ink); }
.ap-chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.ap-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.ap-actions .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; flex: 1 1 170px; text-align: center; white-space: nowrap; }
.ap-actions .btn:disabled { opacity: .5; cursor: default; animation: none; }
.ap-chip:focus-visible, .btn:focus-visible, .ap-input:focus-visible, .ap-money input:focus-visible { outline: 2px solid var(--series-spx); outline-offset: 2px; }

.ap-results { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: 24px; align-items: start; position: relative; z-index: 3; }
.ap-results-side { display: grid; gap: 16px; min-width: 0; }
@media (max-width: 900px) { .ap-results { grid-template-columns: 1fr; } }
.ap-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .ap-stats { grid-template-columns: 1fr; } }
.ap-stat { padding: 16px 18px; background: #fff; }
.ap-stat .label { display: flex; align-items: center; gap: 8px; }
.ap-swatch { width: 12px; height: 3px; border-radius: 2px; display: inline-block; flex-shrink: 0; }
.ap-v { font-family: var(--font-mono); font-weight: 500; font-size: clamp(22px, 3vw, 30px); margin-top: 6px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.ap-sub { font-size: 13px; color: var(--ink-mute); margin-top: 2px; }
.ap-verdict { font-family: var(--font-display); font-style: italic; font-size: clamp(24px, 3vw, 32px); line-height: 1.15; margin: 4px 0; }
sup.ap-exp { font-size: .6em; line-height: 0; vertical-align: .7em; }

.ap-chart { position: relative; padding: 12px 8px 8px; background: #fff; margin: 0; }
.ap-legend { display: flex; gap: 16px; padding: 0 8px 6px; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-soft); }
.ap-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ap-chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.ap-chart .grid line { stroke: var(--rule); stroke-width: 1; }
.ap-chart .axis text { fill: var(--ink-mute); font-family: var(--font-mono); font-size: 11px; }
.ap-chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ap-chart .end-label { fill: var(--ink); font-size: 12px; font-weight: 600; font-family: var(--font-body); }
.ap-chart .cross { stroke: var(--ink-mute); stroke-width: 1; }
.ap-chart .dot { stroke: #fff; stroke-width: 2; }
@media (prefers-reduced-motion: no-preference) { .ap-chart .line.draw { animation: ap-draw .9s ease-out both; } }
@keyframes ap-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
.ap-tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); border-radius: var(--radius); padding: 8px 10px; font-size: 12px; line-height: 1.5; white-space: nowrap; transform: translate(-50%, -100%); display: none; z-index: 2; }
.ap-tip .mono { font-family: var(--font-mono); font-weight: 500; }
.ap-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.ap-table { font-size: 13px; padding: 0 8px; }
.ap-table summary { cursor: pointer; color: var(--ink-soft); padding: 6px 0; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.ap-table table { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 12px; }
.ap-table th, .ap-table td { text-align: right; padding: 4px 6px; border-bottom: 1px solid var(--rule); }
.ap-table th:first-child, .ap-table td:first-child { text-align: left; }

/* ------- certificate (live canvas) ------- */
.ap-cert { min-width: 0; }
.ap-cert .meta-row { margin-bottom: 10px; justify-content: flex-start; gap: 18px; }
.ap-cert-frame { padding: 10px; background: #fff; }
.ap-cert-frame canvas { width: 100%; height: auto; display: block; border-radius: 2px; }
.ap-actions[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) { .ap-cert-frame.slam { animation: ap-slam .45s cubic-bezier(.3,.7,.3,1); } }
@keyframes ap-slam { 0% { transform: none; } 25% { transform: scale(.975) rotate(-.8deg); } 55% { transform: scale(1.012) rotate(.4deg); } 100% { transform: none; } }
.ap-cert .ap-actions { margin-top: 16px; }
.ap-hint { font-size: 13px; color: var(--ink-mute); margin: 10px 0 0; }

/* ------- the 1920 ledger ------- */
.ap-owed { font-family: var(--font-mono); font-weight: 500; font-size: clamp(18px, 3.2vw, 34px); line-height: 1.25; color: var(--money); word-break: break-all; overflow-wrap: anywhere; margin: 8px 0 20px; transition: color .6s; font-variant-numeric: tabular-nums; }
.ap-owed.flash { color: var(--series-charles); }
.ap-owed-meta { display: flex; flex-wrap: wrap; gap: 8px 28px; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-soft); }
.ap-owed-meta b { color: var(--ink); font-weight: 500; }

/* ------- withdraw dialog ------- */
.ap-dlg { border: 1px solid var(--ink); border-radius: 8px; padding: 0; max-width: min(560px, calc(100vw - 32px)); width: 100%; background: var(--bg); color: var(--ink); box-shadow: 6px 6px 0 var(--ink); }
.ap-dlg::backdrop { background: rgba(10,10,10,.55); }
.ap-dlg-body { padding: 24px; display: grid; gap: 16px; }
.ap-dlg h3 { font-size: 36px; margin: 0; }
.ap-bar { height: 8px; border-radius: 4px; background: var(--rule); overflow: hidden; }
.ap-bar i { display: block; height: 100%; width: 0; background: var(--ink); transition: width .6s cubic-bezier(.3,.7,.4,1); }
.ap-wd-result { display: grid; gap: 16px; }
.ap-wd-result[hidden], #wdProcessing[hidden] { display: none; }
.ap-denied { justify-self: start; font-family: var(--font-mono); font-weight: 500; font-size: 26px; letter-spacing: .08em; color: var(--fed); border: 3px double var(--fed); padding: 4px 14px; transform: rotate(-4deg); }
.ap-reason { font-size: 17px; margin: 0; }
.ap-pyramid svg { width: 100%; height: auto; display: block; }
.ap-pyramid text { font-family: var(--font-mono); font-size: 11px; fill: var(--ink-soft); }
.ap-pyramid .you { fill: var(--fed); }
.ap-earth { font-size: 14px; color: var(--ink-soft); margin: 0; }
.ap-reflink { display: flex; gap: 8px; }
.ap-reflink input { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 12px; border: 1px solid var(--rule); border-radius: var(--radius); padding: 8px 10px; background: #fff; }
.ap-close { justify-self: end; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-soft); text-decoration: underline; padding: 8px 0; }

.ap-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--radius); font-family: var(--font-mono); font-size: 12px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; }
.ap-toast.on { opacity: 1; }
