/* The revenue card of a made-up homeware shop, Marrowby, on a soft light page. The bars are drawn by the browser and
   moved by a small hand written physics in script.js: gravity and a bounce when they fall, springs when they are
   dragged. Each bar is an element for the physics (.bar, its height and transform written every frame) with a child
   for the CSS (.bar__body, the colour, the light and the hover). */
:root {
  --page: #eceef2;          /* the page */
  --page-glow: #f8f9fb;     /* the light on the page, behind the card */
  --card: #ffffff;          /* the card */
  --ink: #15171d;           /* the big words */
  --muted: #8b909c;         /* the small words */
  --line: rgba(21, 23, 29, 0.07); /* the grid and the hairlines */
  --accent: #4f5bea;        /* the bar that is held, the peak and the chip */
  --accent-deep: #3a45cf;   /* the foot of the accent bar */
  --tint: #d7dbfb;          /* the other bars */
  --tint-low: #eceefe;      /* the foot of the other bars */
  --tip: #15171d;           /* the label over the held bar */
}

* {
  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% 30%, var(--page-glow), var(--page) 70%);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* a fine grain over the page */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0.16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.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;
}

.card {
  position: relative;
  width: min(100%, 460px);
  padding: clamp(14px, 3.4vh, 22px) clamp(14px, 4.6vw, 24px) clamp(12px, 2.8vh, 18px);
  border-radius: 22px;
  background: var(--card);
  box-shadow:
    inset 0 0 0 1px rgba(21, 23, 29, 0.06),
    0 1px 1px rgba(21, 23, 29, 0.04),
    0 8px 18px -10px rgba(21, 23, 29, 0.16),
    0 34px 60px -34px rgba(40, 46, 90, 0.32);
  opacity: 0;
  user-select: none;
  -webkit-user-select: none;
}

/* a soft light from the top left corner, like a studio window over the card */
.card__sheen {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(70% 50% at 12% 0%, rgba(79, 91, 234, 0.06), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 30%);
}

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

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

.brand__mark {
  width: 28px;
  height: 28px;
  flex: none;
}

.brand__mark rect {
  fill: var(--ink);
}

.brand__mark path {
  fill: none;
  stroke: #ffffff;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.brand__words {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}

.brand__name {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.brand__sub {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
}

.tabs {
  position: relative;
  display: flex;
  padding: 3px;
  border-radius: 999px;
  background: #f2f3f6;
  box-shadow: inset 0 0 0 1px rgba(21, 23, 29, 0.05);
  flex: none;
}

.tabs__pill {
  position: absolute;
  top: 3px;
  left: 0;
  height: calc(100% - 6px);
  width: 0;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(21, 23, 29, 0.1), 0 3px 8px -4px rgba(21, 23, 29, 0.2), inset 0 0 0 1px rgba(21, 23, 29, 0.04);
}

.tabs__btn {
  position: relative;
  z-index: 1;
  appearance: none;
  border: 0;
  background: none;
  padding: 6px 11px;
  font: inherit;
  font-size: 12px;
  font-weight: 560;
  font-stretch: 100%;
  color: var(--muted);
  cursor: pointer;
  border-radius: 999px;
  white-space: nowrap;
  transition: color 0.25s ease, font-stretch 0.35s ease;
}

.tabs__btn.is-on {
  color: var(--ink);
  font-stretch: 108%;
}

@media (hover: hover) {
  .tabs__btn:not(.is-on):hover {
    color: #4a4f5c;
  }
}

.tabs__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.total {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin: clamp(10px, 2.6vh, 18px) 0 clamp(8px, 2.4vh, 16px);
}

.total__amount {
  margin: 0;
  font-size: clamp(24px, min(7.4vw, 6.4vh), 32px);
  font-weight: 640;
  font-stretch: 104%;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.total__chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 6px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 560;
  color: var(--accent-deep);
  background: rgba(79, 91, 234, 0.09);
  font-variant-numeric: tabular-nums;
  transition: color 0.3s ease, background-color 0.3s ease;
}

.total__chip svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.4s cubic-bezier(0.3, 1.5, 0.5, 1);
}

.total__chip.is-down {
  color: #b24a3a;
  background: rgba(214, 92, 70, 0.1);
}

.total__chip.is-down svg {
  transform: rotate(180deg);
}

.chart {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
}

.chart__axis {
  position: relative;
  grid-row: 1;
  width: 30px;
  font-size: 10px;
  color: #a6aab4;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.chart__axis span {
  position: absolute;
  right: 0;
  transform: translateY(-50%);
  line-height: 1;
}

.chart__axis span:nth-child(1) { top: 0%; }
.chart__axis span:nth-child(2) { top: 20%; }
.chart__axis span:nth-child(3) { top: 40%; }
.chart__axis span:nth-child(4) { top: 60%; }
.chart__axis span:nth-child(5) { top: 80%; }
.chart__axis span:nth-child(6) { top: 100%; }

/* the plot: the bars fall from above its top edge, so it clips them */
.plot {
  position: relative;
  grid-row: 1;
  grid-column: 2;
  height: clamp(110px, 31vh, 210px);
  touch-action: none;
}

.plot__grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.plot__grid i {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--line) 0 3px, transparent 3px 7px);
}

.plot__grid i:nth-child(1) { top: 0%; }
.plot__grid i:nth-child(2) { top: 20%; }
.plot__grid i:nth-child(3) { top: 40%; }
.plot__grid i:nth-child(4) { top: 60%; }
.plot__grid i:nth-child(5) { top: 80%; }

.plot__floor {
  position: absolute;
  left: -2px;
  right: -2px;
  bottom: 0;
  height: 1px;
  background: rgba(21, 23, 29, 0.16);
  pointer-events: none;
}

/* where the held bar really stands, a dashed line while it is pulled away */
.plot__ghost {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  border-top: 1.5px dashed rgba(79, 91, 234, 0.55);
  opacity: 0;
  pointer-events: none;
}

.plot__cols {
  position: absolute;
  inset: 0;
  display: flex;
  clip-path: inset(-8px -20px -14px -20px);
}

.col {
  position: relative;
  flex: 1;
  height: 100%;
  cursor: grab;
}

.col.is-held {
  cursor: grabbing;
}

/* the soft shadow a bar throws on the floor, sharper as it comes down */
.col__shadow {
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: min(62%, 44px);
  height: 10px;
  margin-left: calc(min(62%, 44px) / -2);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(40, 46, 90, 0.28), transparent);
  opacity: 0;
  pointer-events: none;
}

.bar {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(58%, 40px);
  height: 0;
  margin-left: calc(min(58%, 40px) / -2);
  transform-origin: 50% 100%;
  will-change: transform, height;
}

.bar__body {
  position: absolute;
  inset: 0;
  border-radius: 9px 9px 3px 3px;
  background: linear-gradient(180deg, var(--tint), var(--tint-low));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), inset 0 0 0 1px rgba(79, 91, 234, 0.08);
  transition: box-shadow 0.35s ease, filter 0.35s ease;
  overflow: hidden;
}

/* the accent version of the bar, faded in over the tint so the colour change is smooth */
.bar__body::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  opacity: var(--lit, 0);
  transition: opacity 0.35s ease;
}

/* a thin light along the top edge of every bar */
.bar__body::after {
  content: '';
  position: absolute;
  left: 3px;
  right: 3px;
  top: 1px;
  height: 40%;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0));
  opacity: 0.7;
}

/* the grip that comes up on hover: two short lines at the top of the bar */
.bar__grip {
  position: absolute;
  left: 50%;
  top: 6px;
  width: 12px;
  height: 4px;
  margin-left: -6px;
  border-top: 1.5px solid rgba(255, 255, 255, 0.9);
  border-bottom: 1.5px solid rgba(255, 255, 255, 0.9);
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.col.is-lit .bar__body,
.col.is-held .bar__body {
  --lit: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 10px 22px -10px rgba(79, 91, 234, 0.7);
}

.col.is-peak .bar__body {
  --lit: 1;
}

.col.is-held .bar__grip,
.col.is-hover .bar__grip {
  opacity: 1;
  transform: none;
}

.col.is-hover .bar__body {
  --lit: 1;
}

.col.is-held .bar__body {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 16px 26px -10px rgba(79, 91, 234, 0.75), 0 0 0 3px rgba(79, 91, 234, 0.12);
}

.chart.is-busy .col:not(.is-held):not(.is-hover) .bar__body {
  filter: saturate(0.85);
}

.chart__days {
  grid-row: 2;
  grid-column: 2;
  display: flex;
  padding-top: 8px;
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 520;
}

.chart__days span {
  flex: 1;
  text-align: center;
  transition: color 0.3s ease, font-stretch 0.3s ease;
}

.chart__days span.is-on {
  color: var(--ink);
  font-stretch: 110%;
}

/* the label over the held bar */
.tip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 9px;
  background: var(--tip);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  box-shadow: 0 8px 18px -8px rgba(21, 23, 29, 0.5);
  opacity: 0;
  pointer-events: none;
  will-change: transform;
}

.tip::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  background: var(--tip);
  border-radius: 1.5px;
  transform: rotate(45deg);
}

.tip__delta {
  color: #aeb4ff;
  font-weight: 560;
}

.tip__delta:empty {
  display: none;
}

/* the drawn pointer of the autopilot */
.hand {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 10;
  width: 22px;
  height: 22px;
  pointer-events: none;
  opacity: 0;
  transform-origin: 20% 15%;
  filter: drop-shadow(0 3px 5px rgba(21, 23, 29, 0.28));
}

.hand path {
  fill: #15171d;
  stroke: #ffffff;
  stroke-width: 1.4;
  stroke-linejoin: round;
}

@media (max-width: 380px) {
  .tabs__btn {
    padding: 5px 8px;
    font-size: 11px;
  }
  .brand__sub {
    display: none;
  }
  .chart__axis {
    width: 26px;
  }
}
