/* The dashboard tabs with the sliding glass lens: the analytics card of an AI writing assistant on a black page.
   The tabs sit in a dark track; over the active one a lens of liquid glass (an element moved by script.js on a spring)
   carries a magnified copy of the labels, bent at the rim by an SVG displacement map, with a highlight on top.
   Under the tabs the content of the view changes, sliding the way the lens went. */
:root {
  --page: #000000;            /* the page */
  --card: #0d0e12;            /* the body of the card */
  --card-top: #15161c;        /* the top of the card, where the light falls */
  --edge: rgba(255, 255, 255, 0.075); /* the 1px edge of the card */
  --track: #08090c;           /* the well the tabs sit in */
  --glass: #1c1d25;           /* the body of the lens */
  --ink: #f1f1f4;             /* the words */
  --muted: #7d7f8c;           /* the small words */
  --faint: rgba(255, 255, 255, 0.06); /* grid lines and empty bars */
  --accent: #a48bff;          /* the one colour: line, bars, lens rim */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.defs {
  position: absolute;
  width: 0;
  height: 0;
}

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

/* ---------------------------------------------------------------- the card */
.dash {
  position: relative;
  width: min(520px, 92vw);
  padding: clamp(12px, 3.4vh, 22px) clamp(12px, 4vw, 22px) clamp(12px, 3.2vh, 20px);
  border-radius: 22px;
  background:
    radial-gradient(120% 70% at 30% -10%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 60%),
    linear-gradient(180deg, var(--card-top), var(--card) 46%);
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 1px 1px rgba(0, 0, 0, 0.6),
    0 12px 24px -12px rgba(0, 0, 0, 0.9),
    0 40px 80px -40px color-mix(in srgb, var(--accent) 22%, transparent);
  isolation: isolate;
  opacity: 0;
}

/* the top edge catching the light, brighter in the middle */
.dash__sheen {
  position: absolute;
  left: 14%;
  right: 14%;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.32), transparent);
  pointer-events: none;
}

.dash__grain {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-size: 128px 128px;
  opacity: 0.07;
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 3;
}

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

.dash__brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 600;
  font-variation-settings: 'wdth' 106;
  white-space: nowrap;
}

.dash__mark {
  width: 15px;
  height: 15px;
  fill: var(--accent);
}

.dash__crumb {
  color: var(--muted);
  font-weight: 450;
  font-variation-settings: 'wdth' 100;
  padding-left: 9px;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.dash__range {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px 5px 10px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.dash__range svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------------------------------------------------------------- the tabs */
.tabs {
  margin-top: clamp(10px, 2.6vh, 16px);
}

.tabs__track {
  position: relative;
  display: flex;
  height: 40px;
  padding: 4px;
  border-radius: 13px;
  background: var(--track);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.8),
    inset 0 0 0 1px rgba(255, 255, 255, 0.045),
    0 1px 0 rgba(255, 255, 255, 0.045);
}

.tabs__tab,
.lens__text > span {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(11.5px, 3.3vw, 13.5px);
  font-weight: 520;
  font-variation-settings: 'wdth' 100;
  letter-spacing: 0.005em;
  white-space: nowrap;
}

.tabs__tab {
  position: relative;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--muted);
  font-family: inherit;
  cursor: pointer;
  transition: color 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}

.tabs__tab:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--track), 0 0 0 3px color-mix(in srgb, var(--accent) 80%, transparent);
}

@media (hover: hover) {
  .tabs__tab:hover {
    color: #b9bbc6;
  }
}

/* the lens: left, top, width and height are set every frame by script.js */
.lens {
  position: absolute;
  left: 4px;
  top: 4px;
  width: 0;
  height: 32px;
  border-radius: 9px;
  pointer-events: none;
  z-index: 2;
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.7),
    0 6px 14px -6px rgba(0, 0, 0, 0.9),
    0 8px 22px -12px color-mix(in srgb, var(--accent) 60%, transparent);
  opacity: 0;
}

.lens__glass {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0) 55%),
    var(--glass);
}

/* the bend sits inside the clip of the glass, so the rounded corners stay clean */
.lens__bend {
  position: absolute;
  inset: 0;
  filter: url(#lens-bend);
}

/* the magnified copy of the labels: same layout as the track, moved and scaled by script.js */
.lens__text {
  position: absolute;
  left: 0;
  top: 0;
  height: 40px;
  display: flex;
  padding: 4px;
  color: var(--ink);
  text-shadow: 0 0 10px color-mix(in srgb, var(--accent) 45%, transparent);
  will-change: transform;
}

.lens__text > span {
  font-weight: 560;
}

/* the rim of the glass: light on top, a thread of the accent at the bottom */
.lens__rim {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.34),
    inset 0 0 0 1px rgba(255, 255, 255, 0.09),
    inset 0 -1px 0 color-mix(in srgb, var(--accent) 55%, transparent),
    inset 0 -6px 10px -8px color-mix(in srgb, var(--accent) 70%, transparent);
}

/* the highlight that slides inside the glass against the direction of travel */
.lens__shine {
  position: absolute;
  left: 8%;
  top: 1px;
  width: 46%;
  height: 46%;
  border-radius: 999px;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
  mix-blend-mode: screen;
}

/* ---------------------------------------------------------------- the views */
.panes {
  display: grid;
  margin-top: clamp(12px, 3vh, 20px);
}

.pane {
  grid-area: 1 / 1;
  min-width: 0;
}

.pane[hidden] {
  display: block;
  visibility: hidden;
}

.pane__label {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.pane__figure {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.num {
  display: inline-flex;
  font-size: clamp(28px, min(9vw, 8.6vh), 40px);
  line-height: 1;
  height: 1em;
  overflow: hidden;
  font-weight: 620;
  font-variation-settings: 'wdth' 94;
  letter-spacing: -0.025em;
  /* a soft fade at the top and the bottom of the window of the drums */
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 14%, #000 86%, transparent);
  mask-image: linear-gradient(180deg, transparent, #000 14%, #000 86%, transparent);
}

.num__dg {
  position: relative;
  display: inline-block;
}

.num__ghost--digit {
  color: transparent;
}

.num__strip {
  position: absolute;
  left: 50%;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.num__strip > span {
  display: block;
  height: 1em;
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 7px 3px 4px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 560;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 11%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
}

.delta svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* the chart: an SVG drawn by script.js, plus a cursor that follows the pointer */
.chart {
  position: relative;
  height: clamp(44px, 15vh, 112px);
  margin-top: clamp(8px, 2.2vh, 14px);
}

.chart svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart__grid {
  stroke: var(--faint);
  stroke-width: 1;
  stroke-dasharray: 2 4;
  vector-effect: non-scaling-stroke;
}


.chart__line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.chart__front {
  stroke: color-mix(in srgb, var(--accent) 70%, #ffffff);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  opacity: 0;
}

.chart__cursor {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.35));
  opacity: 0;
  pointer-events: none;
}

.chart__tip {
  position: absolute;
  top: -4px;
  left: 0;
  padding: 3px 6px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 560;
  white-space: nowrap;
  color: var(--ink);
  background: rgba(22, 23, 30, 0.92);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 4px 10px -4px rgba(0, 0, 0, 0.8);
  opacity: 0;
  pointer-events: none;
}

.rows {
  list-style: none;
  margin: clamp(8px, 2.2vh, 14px) 0 0;
  padding: 0;
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  height: clamp(20px, 5.2vh, 30px);
  font-size: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.row__name {
  color: #b6b8c3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row__bar {
  position: relative;
  height: 4px;
  border-radius: 4px;
  background: var(--faint);
  overflow: hidden;
}

.row__bar i {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 45%, transparent), var(--accent));
  transform-origin: 0 50%;
}

.row__val {
  min-width: 46px;
  text-align: right;
  font-weight: 560;
}

@media (max-width: 380px) {
  .dash__crumb {
    display: none;
  }
}

@media (max-height: 460px) {
  .row:nth-child(3) {
    display: none;
  }
}
