/* The budget donut chart with the thread that runs round to the slice: the October card of a made-up finance app,
   white on a warm paper page. The ring is SVG (viewBox 200 x 200); the number in the middle is HTML laid over it and
   sized on the donut's own width (container units), so it scales with the ring at every size. */
:root {
  --page: #efece6;          /* the page */
  --card: #ffffff;          /* the card */
  --ink: #15171a;           /* the words and the thread */
  --muted: #7d8087;         /* the small words */
  --line: rgba(21, 23, 26, 0.08); /* hairlines */
  --accent: #0f766e;        /* the one colour: the five slices are its tones */
  --good: #0f766e;          /* the under-budget arrow */
}

* { box-sizing: border-box; }

html { touch-action: manipulation; }

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background:
    radial-gradient(120% 80% at 50% 0%, #f6f4ef 0%, var(--page) 62%, #e7e3db 100%);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

p { margin: 0; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 14px;
  overflow: hidden;
}

/* ---------- the card ---------- */
.card {
  position: relative;
  width: min(94vw, 580px);
  padding: clamp(14px, 4vh, 24px) clamp(14px, 4.6vw, 28px) clamp(12px, 3.2vh, 20px);
  border-radius: 22px;
  background: var(--card);
  box-shadow:
    inset 0 0 0 1px rgba(21, 23, 26, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 1),
    0 1px 2px rgba(40, 32, 20, 0.05),
    0 8px 18px -8px rgba(40, 32, 20, 0.12),
    0 34px 60px -30px rgba(40, 32, 20, 0.28);
  opacity: 0;
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.card__mark {
  width: 28px;
  height: 28px;
  flex: none;
  padding: 5px;
  border-radius: 9px;
  background: #f3f2ee;
  box-shadow: inset 0 0 0 1px var(--line);
  fill: none;
  stroke-linecap: round;
}
.card__mark circle { stroke: rgba(21, 23, 26, 0.22); stroke-width: 2.4; }
.card__mark path { stroke: var(--accent); stroke-width: 2.4; }

.card__name {
  font-size: clamp(13px, 3.6vw, 15px);
  font-weight: 620;
  font-variation-settings: 'wdth' 104;
  letter-spacing: -0.005em;
}

.card__sub {
  margin-top: 1px;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.card__chip {
  flex: none;
  font-size: 11px;
  font-weight: 520;
  color: var(--muted);
  padding: 5px 9px;
  border-radius: 999px;
  background: #f6f5f2;
  box-shadow: inset 0 0 0 1px var(--line);
}

.card__body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: clamp(12px, 4vw, 34px);
  margin-top: clamp(10px, 3vh, 20px);
}

/* ---------- the donut ---------- */
.donut {
  position: relative;
  width: min(44vw, 42vh, 236px);
  aspect-ratio: 1;
  container-type: inline-size;
}

.donut__svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.donut__bed { fill: none; stroke: #f1f0ec; stroke-width: 20; }
.donut__gloss { fill: none; stroke: #ffffff; stroke-width: 0.7; opacity: 0.42; pointer-events: none; }
.donut__inner { fill: none; stroke: rgba(21, 23, 26, 0.07); stroke-width: 0.8; pointer-events: none; }

.tick { stroke: var(--ink); stroke-width: 0.6; stroke-linecap: round; }

.slice__paint { fill: none; stroke-width: 20; stroke-linecap: butt; pointer-events: none; }
.slice__hit { fill: none; stroke: transparent; stroke-width: 30; pointer-events: stroke; cursor: pointer; }
.slice__shade { fill: none; stroke-width: 18; stroke-linecap: butt; filter: url(#shade); opacity: 0; }

.thread { pointer-events: none; opacity: 0; }
.thread__arc { fill: none; stroke: var(--ink); stroke-width: 1.1; stroke-linecap: round; }
.thread__end { fill: none; stroke: var(--ink); stroke-width: 1.1; stroke-linecap: round; }
.thread__caret { fill: var(--ink); }

.donut__center {
  position: absolute;
  inset: 22%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.donut__label {
  font-size: 6.6cqi;
  font-weight: 540;
  color: var(--muted);
  white-space: nowrap;
}

.donut__value {
  display: flex;
  align-items: baseline;
  margin: 1.2cqi 0 1cqi;
  font-size: 15cqi;
  line-height: 1;
  font-weight: 660;
  font-variation-settings: 'wdth' 92;
  letter-spacing: -0.035em;
}

.donut__cur {
  font-size: 0.62em;
  font-weight: 560;
  margin-right: 0.06em;
  color: #3c3f45;
  align-self: flex-start;
  margin-top: 0.08em;
}

.donut__note {
  font-size: 6cqi;
  color: var(--muted);
  white-space: nowrap;
}

/* the rolling number: one window per digit, a strip of 0 to 9 inside */
.roll { display: inline-flex; }
.roll__slot {
  position: relative;
  display: inline-block;
  height: 1em;
  overflow: hidden;
  width: 0.6em;
  text-align: center;
}
.roll__slot--comma { width: 0.3em; }
.roll__strip {
  display: flex;
  flex-direction: column;
}
.roll__strip span { display: block; height: 1em; line-height: 1; }

/* ---------- the legend ---------- */
.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: clamp(4px, 1.5vh, 10px);
}

.row {
  position: relative;
  padding: clamp(3px, 0.9vh, 6px) 6px clamp(4px, 1vh, 7px);
  margin: 0 -6px;
  border-radius: 9px;
  outline: none;
  cursor: pointer;
}

.row__wash {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: #f5f4f0;
  box-shadow: inset 0 0 0 1px var(--line);
  opacity: 0;
}

.row__top {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: clamp(11.5px, 3.3vw, 13px);
}

.row__name {
  font-weight: 500;
  font-variation-settings: 'wdth' 100;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row__amt {
  color: #44474d;
  white-space: nowrap;
}

.row__bar {
  position: relative;
  display: block;
  height: 3px;
  margin-top: clamp(3px, 0.9vh, 6px);
  border-radius: 3px;
  background: #f0efeb;
  overflow: hidden;
}

.row__fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  transform-origin: 0 50%;
}

.row:focus-visible .row__wash { opacity: 1; box-shadow: inset 0 0 0 1.5px var(--accent); }

/* ---------- footer ---------- */
.card__foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: clamp(10px, 3vh, 18px);
  padding-top: clamp(8px, 2.2vh, 12px);
  border-top: 1px solid var(--line);
}
.card__trend { width: 14px; height: 14px; flex: none; fill: none; stroke: var(--good); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.card__insight { font-size: 11.5px; color: var(--muted); }
.card__insight b { color: var(--ink); font-weight: 600; }

/* ---------- the drawn pointer of the autopilot ---------- */
.ghost {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  fill: #15171a;
  stroke: #ffffff;
  stroke-width: 1.4;
  stroke-linejoin: round;
  pointer-events: none;
  opacity: 0;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.18));
  z-index: 5;
}

@media (max-width: 380px) {
  .card__sub { font-size: 10.5px; }
  .card__chip { font-size: 10px; padding: 4px 7px; }
}
