/* The monthly budget card of Tally, an invented finance app, on pure black: a half ring of the month's budget,
   the spent part in four tones of lime, the mark of today, the money left in the middle, and under it a drawer
   that holds the legend or the payments of one category. */
:root {
  --page: #000000;        /* the page */
  --card: #0f1012;        /* the body of the card */
  --card-top: #17191c;    /* the light at the top of the card */
  --edge: rgba(255, 255, 255, 0.07); /* the edge of the card */
  --edge-lit: rgba(255, 255, 255, 0.16); /* the top edge, where the light hits */
  --ink: #f1f2ee;         /* the words */
  --muted: #8b8e86;       /* the small words */
  --faint: #55584f;       /* the faintest words */
  --track: #1d1f1c;       /* the empty ring */
  --accent: #c8f169;      /* the lime of the spent part */
  --ghost: #ffffff;       /* the drawn pointer */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--page);
  color: var(--ink);
  font-family: "Mona Sans Variable", "Mona Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

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

/* ---------- the card ---------- */
.budget {
  position: relative;
  width: min(392px, 100%);
  border-radius: 24px;
  padding: clamp(13px, 3.2vh, 20px) clamp(14px, 4.4vw, 20px) clamp(10px, 2.6vh, 16px);
  background:
    radial-gradient(120% 70% at 20% -10%, var(--card-top), transparent 60%),
    var(--card);
  box-shadow:
    inset 0 1px 0 var(--edge-lit),
    inset 0 0 0 1px var(--edge),
    0 1px 1px rgba(0, 0, 0, 0.6),
    0 18px 40px -16px rgba(0, 0, 0, 0.9),
    0 40px 90px -40px rgba(200, 241, 105, 0.09);
  isolation: isolate;
}

/* a fine grain and a soft sheen that follows the pointer */
.budget::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.07;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: -1;
}

.budget__sheen {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(240px 160px at var(--sx, 30%) var(--sy, 0%), rgba(200, 241, 105, 0.06), transparent 70%);
  z-index: -1;
}

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

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

.budget__mark {
  width: 28px;
  height: 28px;
  flex: none;
  padding: 5px;
  border-radius: 9px;
  background: linear-gradient(180deg, #23261f, #16170f);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-linecap: round;
}

.budget__name { font-size: 14px; font-weight: 620; letter-spacing: -0.01em; line-height: 1.2; white-space: nowrap; }
.budget__total { font-size: 11.5px; color: var(--muted); line-height: 1.3; white-space: nowrap; }

.budget__day {
  flex: none;
  font-size: 11px;
  color: var(--muted);
  padding: 5px 9px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}
.budget__day span { color: var(--ink); font-weight: 560; }

/* ---------- the half ring ---------- */
.gauge {
  position: relative;
  width: min(100%, 52vh);
  margin: clamp(6px, 2vh, 14px) auto 0;
}

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

.gauge__track { fill: none; stroke: var(--track); stroke-linecap: butt; }
.gauge__left {
  fill: none;
  stroke: rgba(255, 255, 255, 0.13);
  stroke-width: 1;
  stroke-dasharray: 1.2 3.2;
}
.gauge__glow { filter: blur(7px); opacity: 0.32; pointer-events: none; }

.slice { cursor: pointer; }
.slice path { fill: none; stroke-linecap: butt; }
.slice .slice__hi { stroke: rgba(255, 255, 255, 0.38); stroke-width: 0.7; pointer-events: none; }

.gauge__pace line { stroke: var(--ink); stroke-width: 1.4; stroke-linecap: round; }
.gauge__pace text { font-size: 8px; font-weight: 560; fill: var(--muted); letter-spacing: 0.02em; }

.gauge__end {
  position: absolute;
  bottom: -2px;
  font-size: 10px;
  color: var(--faint);
  transform: translateX(-50%);
  white-space: nowrap;
}
.gauge__end--a { left: 8.2%; }
.gauge__end--b { left: 91.8%; }

.gauge__center {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 62%;
  text-align: center;
  pointer-events: none;
}

.gauge__label { font-size: 11.5px; color: var(--muted); line-height: 1.3; white-space: nowrap; }
.gauge__value {
  display: flex;
  justify-content: center;
  font-size: clamp(30px, min(10.4vw, 9.6vh), 40px);
  font-weight: 640;
  font-variation-settings: "wdth" 92;
  letter-spacing: -0.035em;
  line-height: 1.08;
  margin: 1px 0 2px;
}
.gauge__note { font-size: 11px; color: var(--muted); line-height: 1.3; white-space: nowrap; }

/* rolling digits: a window one line tall with a column of 0-9 inside */
.roll { display: inline-block; height: 1.08em; overflow: hidden; position: relative; }
.roll__col { display: flex; flex-direction: column; }
.roll__col span { display: block; height: 1.08em; line-height: 1.08em; text-align: center; }
.roll--sym { line-height: 1.08em; }

/* ---------- the drawer: the legend or the payments ---------- */
.drawer {
  position: relative;
  height: clamp(108px, 24vh, 114px);
  margin-top: clamp(10px, 2.6vh, 16px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: clamp(8px, 1.8vh, 12px);
}

.legend {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 8px;
}

.cat {
  width: 100%;
  text-align: left;
  padding: 7px 9px 8px;
  border-radius: 12px;
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}
.cat.is-on {
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.cat:focus-visible { outline: 1.5px solid var(--accent); outline-offset: 1px; }

.cat__top, .cat__bar, .cat__fill { display: block; }
.cat__top { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.cat__name { font-size: 12px; font-weight: 540; white-space: nowrap; }
.cat__amt { font-size: 12px; font-weight: 600; white-space: nowrap; }
.cat__amt small { font-size: 10.5px; font-weight: 450; color: var(--faint); margin-left: 2px; }
.cat__bar { margin-top: 6px; height: 2px; border-radius: 2px; background: rgba(255, 255, 255, 0.07); overflow: hidden; }
.cat__fill { height: 100%; width: 100%; border-radius: 2px; transform-origin: 0 50%; transform: scaleX(0); }

.list { position: absolute; inset: clamp(8px, 1.8vh, 12px) 0 0; }
.list[hidden] { display: none; }

.list__head { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.list__back {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.03);
  transition: background-color 0.2s ease;
}
.list__back svg { width: 13px; height: 13px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.list__back:focus-visible { outline: 1.5px solid var(--accent); outline-offset: 1px; }
@media (hover: hover) { .list__back:hover { background: rgba(255, 255, 255, 0.08); } }
.list__name { font-size: 12.5px; font-weight: 600; }
.list__count { margin-left: auto; font-size: 11px; color: var(--muted); }

.list__rows { list-style: none; }
.pay {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  column-gap: 8px;
  padding: clamp(3px, 0.8vh, 5px) 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.045);
}
.pay:last-child { border-bottom: 0; }
.pay__who { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pay__who small { font-size: 10.5px; color: var(--faint); font-weight: 450; margin-left: 6px; }
.pay__amt { font-size: 12px; font-weight: 580; white-space: nowrap; }

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

@media (max-width: 370px) {
  .cat { padding: 6px 7px 7px; }
  .cat__name, .cat__amt { font-size: 11.5px; }
  .budget__name { font-size: 13px; }
}
