/* Stingray Bookkeeping, pass 3: CHARTS (the "Bars | Pie" chart of the client Breakdown). Goes with
   charts-pass3.js (global StingrayCharts). Rule: INTEGRATION-CONTRACT.md section 9 CHART LOOK. Plain ASCII.
   Load order on a client page: fonts.css, portal.css, client-pass3.css, <page>.css, charts-pass3.css.

   THE COLORS (PC 2 fix step, Oct 17, after the verify review: the bright blue and hot magenta of the dataviz
   default order read off brand next to Look A's navy, teal and gold).
   - BARS (the R2 picture he approved): every group's bar is the ONE aurora teal (--sc-bar), "Taxes paid" gold,
     "Other" (and every group under 2% folded into it) the quiet neutral. One series, so one color: the length
     carries the amount.
   - PIE: a donut needs one color per part, so the parts take a fixed Look A order in the books' own order
     (never by size, so a group keeps its color from month to month): 1 aurora teal, 2 steel blue (the navy
     sky), 3 aurora violet, 4 aurora rose, with "Taxes paid" always gold and "Other" the neutral. In Pie each
     row's bar turns into the dot of the legend in its part's color, so the dot, the part and the tooltip key
     always match. At most 4 colored parts + Taxes paid + Other = 6 parts.
   Text never wears a series color (the words stay in --ink / --soft / --quiet).
   Checked with the dataviz skill's validator (scripts/validate_palette.js), ALL PAIRS (a donut sorted by size
   can put any two parts side by side), Oct 17 2026, log in tools\pass3-pc2\charts-palette-fix.log:
     dark cards (aurora, nightsky, engraved-dark), surface #0f2030, 4 colors + gold: lightness band PASS,
       chroma PASS, color blind PASS (worst 8.9), normal vision PASS (worst 17.1), contrast PASS (all 3:1+).
     cream card (engraved-cream), surface #fbf8f2, 4 colors + gold: every check PASS (worst color blind 8.8,
       normal 17.0).
     The neutral "Other" is gray on purpose (the lightness band and chroma checks flag any gray); next to every
       color it keeps color blind 8.9 / normal 17.1 on dark and 8.8 / 17.0 on cream (the worst pairs stay the
       colored ones); on cream it is lighter than 3:1, so it always has its words in the list and its share. */

:root,
[data-theme="aurora"],
[data-theme="nightsky"],
[data-theme="engraved-dark"],
[data-theme="engraved-cream"] {
  --sc-1: #1aa697;       /* aurora teal */
  --sc-2: #336ea7;       /* steel blue */
  --sc-3: #a17adb;       /* aurora violet */
  --sc-4: #b04e6f;       /* aurora rose */
  --sc-bar: var(--sc-1); /* Bars: one teal for every group (R2) */
  --sc-tax: #b48b39;     /* gold: Taxes paid, always */
  --sc-other: #c9c2b4;   /* quiet neutral: Other */
  --sc-on-light-ink: #06141f;
  --sc-on-dark-ink: #ffffff;
  --sc-track: rgba(200, 226, 236, .14);
  --sc-tip-bg: linear-gradient(180deg, rgba(20, 38, 53, .94), rgba(10, 24, 37, .96));
  --sc-tip-line: rgba(176, 222, 232, .28);
  --sc-tip-shadow: 0 18px 40px -16px rgba(0, 0, 0, .8), inset 0 1px 0 rgba(255, 255, 255, .08);
  --sc-btn-on-bg: #d4af6a;
  --sc-btn-on-ink: #1b1405;
  --sc-btn-hover: rgba(212, 175, 106, .14);
  --sc-glow: .55;
}

/* the cream cards: the same order, stepped for a light card */
[data-theme="engraved-cream"] .panel,
[data-theme="engraved-cream"] .popup-box {
  --sc-1: #069a82;
  --sc-2: #136095;
  --sc-3: #9865c1;
  --sc-4: #9f3656;
  --sc-bar: var(--sc-1);
  --sc-tax: #9c721c;
  --sc-other: #bab5ad;
  --sc-track: rgba(10, 24, 38, .1);
  --sc-tip-bg: linear-gradient(180deg, #fffdf8, #f7f1e4);
  --sc-tip-line: #b08a4a;
  --sc-tip-shadow: 0 18px 40px -18px rgba(10, 24, 38, .45);
  --sc-btn-on-bg: #0b7470;
  --sc-btn-on-ink: #ffffff;
  --sc-btn-hover: rgba(11, 116, 112, .1);
  --sc-glow: .35;
}

/* one color per part of the donut (and its dot in the list) */
[data-sc-slot="1"] { --sc-c: var(--sc-1); }
[data-sc-slot="2"] { --sc-c: var(--sc-2); }
[data-sc-slot="3"] { --sc-c: var(--sc-3); }
[data-sc-slot="4"] { --sc-c: var(--sc-4); }
[data-sc-slot="tax"] { --sc-c: var(--sc-tax); }
[data-sc-slot="other"] { --sc-c: var(--sc-other); }

/* Bars (R2): every group in the one teal; Taxes paid stays gold and Other stays neutral */
.sc-chart[data-sc-kind="bars"] .sc-row:is([data-sc-slot="1"], [data-sc-slot="2"], [data-sc-slot="3"], [data-sc-slot="4"]) {
  --sc-c: var(--sc-bar);
}

.sc-chart {
  position: relative;
}


/* ==========================================================================
   THE SWITCH: "Bars | Pie", two buttons with a small picture and a word (48px)
   ========================================================================== */

.sc-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  justify-self: start;
  width: min(100%, 17.5rem);
  margin: 2px 0 4px;
  padding: 4px;
  border: 1px solid var(--panel-line);
  border-radius: 13px;
  background: var(--p3-line-bg, transparent);
}

.sc-switch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 4px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font: 600 1.125rem/1.1 var(--sans);
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease;
}

.sc-switch-btn:hover {
  background: var(--sc-btn-hover);
}

.sc-switch-btn[aria-pressed="true"] {
  background: var(--sc-btn-on-bg);
  color: var(--sc-btn-on-ink);
}

.sc-switch-btn:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.sc-switch-ico {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}


/* ==========================================================================
   BARS: one teal bar per group (gold for Taxes paid), growing from the left (40 ms apart)
   ========================================================================== */

.sc-chart .sc-row .sc-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: visible;
  background: var(--sc-track);
  transition: background-color .3s ease, height .35s ease;
}

.sc-chart .sc-row .sc-bar > .sc-fill {
  flex: none;
  min-width: 6px;
  border-radius: 999px;
  background: var(--sc-c);
  transition:
    background-color .35s ease,
    width .62s cubic-bezier(.22, .8, .24, 1) calc(var(--sc-i, 0) * 40ms),
    min-width .62s cubic-bezier(.22, .8, .24, 1) calc(var(--sc-i, 0) * 40ms),
    height .35s ease,
    opacity .25s ease,
    box-shadow .25s ease;
}

/* before the card comes into sight: every bar at zero, then they grow */
.sc-chart.sc-pre .sc-row .sc-bar > .sc-fill {
  width: 0;
  min-width: 0;
}

/* the share, shown in Pie beside the dot */
.sc-pct {
  display: none;
  color: var(--soft);
  font: 600 var(--text-quiet)/1.2 var(--sans);
  font-variant-numeric: lining-nums tabular-nums;
  white-space: nowrap;
}


/* ==========================================================================
   PIE: the donut opens above the rows; each bar shrinks into the dot of the legend
   ========================================================================== */

.sc-chart[data-sc-kind="pie"] .sc-row .sc-bar {
  height: 1.5rem;
  background: transparent;
}

.sc-chart[data-sc-kind="pie"] .sc-row .sc-bar > .sc-fill {
  width: 14px;
  min-width: 14px;
  height: 14px;
  transition-delay: calc(var(--sc-i, 0) * 30ms);
}

.sc-chart[data-sc-kind="pie"] .sc-pct {
  display: inline;
}

.sc-stage {
  display: grid;
  justify-items: center;
  overflow: hidden;
  transition: height .38s cubic-bezier(.3, .7, .2, 1);
}

.sc-stage[hidden] {
  display: none;
}

.sc-donut-wrap {
  position: relative;
  width: 15rem;
  max-width: 100%;
  margin: 8px auto 6px;
  aspect-ratio: 1 / 1;
}

.sc-donut {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  border-radius: 50%;
}

.sc-donut-wrap {
  border-radius: 50%;
}

.sc-donut-wrap:focus {
  outline: none;
}

.sc-donut-wrap:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 6px;
}

.sc-slice {
  fill: var(--sc-c);
  cursor: pointer;
  transform-box: view-box;
  transition: transform .25s cubic-bezier(.3, .7, .2, 1), opacity .25s ease, filter .25s ease;
}

.sc-lab {
  font: 700 18px/1 var(--sans);
  font-variant-numeric: lining-nums tabular-nums;
  pointer-events: none;
  transform-box: view-box;
  transition: opacity .25s ease, transform .25s cubic-bezier(.3, .7, .2, 1);
}

.sc-lab.sc-on-light { fill: var(--sc-on-light-ink); }
.sc-lab.sc-on-dark { fill: var(--sc-on-dark-ink); }

/* the words in the middle of the ring: the total, or the share of the part that is lit */
.sc-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0 3.4rem;
  text-align: center;
  pointer-events: none;
}

.sc-center-n {
  color: var(--ink);
  font: var(--w-fig, 660) 1.75rem/1.05 var(--font-fig, var(--serif));
  font-variant-numeric: lining-nums tabular-nums;
  white-space: nowrap;
}

.sc-center-small {
  color: var(--soft);
  font: 500 var(--text-quiet)/1.15 var(--sans);
}

.sc-center-name {
  color: var(--ink);
  font: var(--w-head, 600) 1.25rem/1.15 var(--font-head, var(--serif));
  text-wrap: balance;
}


/* ==========================================================================
   THE PART THAT IS LIT: it lifts and glows, the others dim to 40%
   ========================================================================== */

.sc-chart[data-sc-hot] .sc-slice {
  opacity: .4;
}

.sc-chart[data-sc-hot] .sc-slice.is-hot {
  opacity: 1;
  transform: translate(var(--sc-dx, 0), var(--sc-dy, 0));
  filter: drop-shadow(0 0 9px var(--sc-c));
}

.sc-chart[data-sc-hot] .sc-row .sc-bar > .sc-fill {
  opacity: .4;
}

.sc-chart[data-sc-hot] .sc-row.is-hot .sc-bar > .sc-fill {
  opacity: 1;
  box-shadow: 0 0 14px -1px var(--sc-c);
}

.sc-chart[data-sc-hot] .sc-lab:not(.is-hot) {
  opacity: .55;
}

.sc-chart[data-sc-hot] .sc-lab.is-hot {
  transform: translate(var(--sc-dx, 0), var(--sc-dy, 0));
}

/* the glass tooltip: the amount first, then the name with its color line, the share and the change */
.sc-tip {
  position: absolute;
  z-index: 5;
  display: grid;
  gap: 2px;
  min-width: 11rem;
  max-width: min(18rem, calc(100% - 16px));
  padding: 10px 14px 11px;
  border: 1px solid var(--sc-tip-line);
  border-radius: 12px;
  background: var(--sc-tip-bg);
  box-shadow: var(--sc-tip-shadow);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  backdrop-filter: blur(12px) saturate(1.2);
  color: var(--ink);
  pointer-events: none;
  animation: sc-tip-in .18s ease-out;
}

.sc-tip[hidden] {
  display: none;
}

.sc-tip-n {
  font: var(--w-fig, 660) 1.5rem/1.15 var(--font-fig, var(--serif));
  font-variant-numeric: lining-nums tabular-nums;
}

.sc-tip-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 600 var(--text-quiet)/1.25 var(--sans);
}

.sc-tip-key {
  flex: none;
  width: 14px;
  height: 3px;
  border-radius: 2px;
  background: var(--sc-c);
}

.sc-tip-p,
.sc-tip-c {
  color: var(--soft);
  font: 500 var(--text-quiet)/1.25 var(--sans);
  font-variant-numeric: lining-nums tabular-nums;
}

@keyframes sc-tip-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}


/* ==========================================================================
   SIZES, STILL, PAPER
   ========================================================================== */

@media (min-width: 900px) {
  .sc-donut-wrap {
    width: 16.25rem;
  }
}

@media (max-width: 699px) {
  .sc-switch {
    width: 100%;
  }

  .sc-center {
    padding: 0 3.4rem;
  }

  .sc-center-n {
    font-size: 1.625rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sc-chart .sc-row .sc-bar,
  .sc-chart .sc-row .sc-bar > .sc-fill,
  .sc-stage,
  .sc-slice,
  .sc-lab,
  .sc-switch-btn {
    transition: none !important;
  }

  .sc-tip {
    animation: none;
  }

  .sc-chart[data-sc-hot] .sc-slice.is-hot,
  .sc-chart[data-sc-hot] .sc-lab.is-hot {
    transform: none;
  }
}

@media print {
  .sc-switch,
  .sc-tip {
    display: none !important;
  }

  .sc-chart .sc-row .sc-bar > .sc-fill,
  .sc-slice {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    opacity: 1 !important;
    box-shadow: none !important;
    filter: none !important;
  }

  .sc-chart.sc-pre .sc-row .sc-bar > .sc-fill {
    width: var(--p3-part, 0%);
    min-width: 6px;
  }

  .sc-center-n,
  .sc-center-l,
  .sc-pct {
    color: #000 !important;
  }
}

@media (forced-colors: active) {
  .sc-chart .sc-row .sc-bar > .sc-fill,
  .sc-slice {
    forced-color-adjust: none;
  }
}


/* ==========================================================================
   THE OWNER MONEY MONTH CHART (StingrayCharts.months, joining step Oct 17 2026, contract section 9)
   One series (paid per month), so one color: the aurora teal bar. The headline figure big in the figure font,
   a direct label on every bar, no grid boxes, no axis clutter, 4px rounded data ends. A computer shows columns
   on one baseline; a phone shows one row per month with the label at the end of the bar.
   ========================================================================== */
.sc-months {
  display: grid;
  gap: 18px;
  margin: 0;
}

.sc-m-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
}

.sc-m-kicker {
  color: var(--soft);
  font: var(--w-ui) 1.125rem/1.3 var(--font-ui);
}

.sc-m-big {
  color: var(--fig);
  font: var(--w-fig) var(--fig-size)/1.05 var(--font-fig);
  font-variant-numeric: tabular-nums;
}

.sc-m-plot {
  display: grid;
  grid-template-columns: repeat(var(--sc-n, 4), minmax(0, 1fr));
  align-items: end;
}

.sc-m-col {
  position: relative;
  display: grid;
  grid-template-rows: 14rem auto;
  justify-items: stretch;
  transition: opacity .2s ease-out;
}

.sc-m-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  height: 100%;
  border-bottom: 1px solid var(--rule);
}

.sc-m-val {
  color: var(--ink);
  font: 600 1.125rem/1.2 var(--font-ui);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sc-m-track {
  display: block;
  width: min(4.5rem, 64%);
  height: calc((100% - 2.25rem) * var(--sc-f, 0));
  min-height: 3px;
}

.sc-m-bar {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 4px 4px 0 0;
  background: var(--sc-bar);
  transform-origin: 50% 100%;
  animation: sc-m-grow .6s cubic-bezier(.22, .61, .36, 1) both;
  animation-delay: calc(var(--sc-i, 0) * 40ms);
}

@keyframes sc-m-grow {
  from { transform: scaleY(0); }
  to { transform: none; }
}

@keyframes sc-m-grow-x {
  from { transform: scaleX(0); }
  to { transform: none; }
}

.sc-m-name {
  padding-top: 8px;
  color: var(--soft);
  font: var(--w-ui) 1.125rem/1.3 var(--font-ui);
  text-align: center;
}

.sc-m-sofar {
  color: var(--quiet);
}

/* the glass tip: only for a pointer, and display:none until then (so it never widens the page) */
.sc-m-tip {
  display: none;
}

@media (hover: hover) {
  .sc-m-plot:hover .sc-m-col {
    opacity: .4;
  }

  .sc-m-plot:hover .sc-m-col:hover {
    opacity: 1;
  }

  .sc-m-col:hover .sc-m-bar {
    box-shadow: 0 0 22px -4px var(--sc-bar);
  }

  .sc-m-col:hover .sc-m-tip {
    position: absolute;
    z-index: 3;
    bottom: calc(100% - 2rem);
    left: 50%;
    display: block;
    width: max-content;
    max-width: 15rem;
    padding: 10px 14px;
    transform: translateX(-50%);
    border: 1px solid var(--sc-tip-line);
    border-radius: 12px;
    background: var(--sc-tip-bg);
    box-shadow: var(--sc-tip-shadow);
    color: var(--soft);
    font: var(--w-ui) 1.125rem/1.35 var(--font-ui);
    pointer-events: none;
  }

  .sc-m-col:first-child:hover .sc-m-tip {
    left: 0;
    transform: none;
  }

  .sc-m-col:last-child:hover .sc-m-tip {
    right: 0;
    left: auto;
    transform: none;
  }

  .sc-m-tip b {
    color: var(--ink);
  }
}

/* a phone: one row per month (name, bar, amount at its end) */
@media (max-width: 699px) {
  .sc-m-plot {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .sc-m-col {
    grid-template-columns: 5.5rem minmax(0, 1fr);
    grid-template-rows: auto;
    align-items: center;
  }

  .sc-m-name {
    grid-row: 1;
    grid-column: 1;
    padding-top: 0;
    text-align: left;
  }

  .sc-m-stack {
    grid-row: 1;
    grid-column: 2;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 10px;
    height: auto;
    border-bottom: 0;
    border-left: 1px solid var(--rule);
  }

  .sc-m-track {
    width: calc((100% - 6.25rem) * var(--sc-f, 0));
    min-width: 3px;
    height: 1.375rem;
  }

  .sc-m-bar {
    border-radius: 0 4px 4px 0;
    transform-origin: 0 50%;
    animation-name: sc-m-grow-x;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sc-m-bar {
    animation: none;
  }

  .sc-m-col {
    transition: none;
  }
}
