/* The watchlist to stock chart transition. One app panel (.app) holds three layers: the list of rows, the plate that
   grows from the tapped row into the sheet (.plate, a clip-path), the stock's page (.detail) and, over everything,
   one SVG (.line) that draws the shared line: the row's small line at the start, the big chart at the end. GSAP
   moves the rows and the detail's shared pieces; their children are styled only by CSS. */
:root {
  --page: #07080a;            /* the page */
  --panel: #0e0f12;           /* the app */
  --sheet: #15171b;           /* the stock's page, grown from the row */
  --row-hot: #15171b;         /* a row under the finger, the same colour as the sheet */
  --edge: rgba(255, 255, 255, 0.08); /* the 1px edges */
  --ink: #eef0f3;             /* the words */
  --muted: #858a94;           /* the small words */
  --up: #3ddc97;              /* a stock going up */
  --down: #ff6b6b;            /* a stock going down */
  --button: #eef0f3;          /* the Buy button */
  --button-ink: #07080a;      /* the words on it */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

body {
  min-height: 100svh;
  background:
    radial-gradient(60% 46% at 50% 8%, color-mix(in srgb, var(--up) 9%, transparent), transparent 70%),
    radial-gradient(50% 40% at 50% 100%, rgba(120, 140, 255, 0.06), transparent 70%),
    var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* a fine grain over the page, so the dark never looks flat */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  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='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.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: 16px;
  overflow: hidden;
}

/* ---------------------------------------------------------------- the app */
.app {
  position: relative;
  width: min(100%, 360px);
  height: min(calc(100svh - 32px), 580px);
  border-radius: clamp(22px, 5vh, 30px);
  background: linear-gradient(180deg, #121317, var(--panel) 40%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 0 0 1px var(--edge),
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 24px 50px -20px rgba(0, 0, 0, 0.85),
    0 60px 110px -50px color-mix(in srgb, var(--up) 22%, transparent);
  overflow: hidden;
  opacity: 0;
  isolation: isolate;
}

/* a soft light on the glass that follows the finger */
.app__light {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: radial-gradient(220px 180px at var(--mx, 50%) var(--my, 20%), rgba(255, 255, 255, 0.045), transparent 70%);
}

/* ---------------------------------------------------------------- the list */
.list {
  position: absolute;
  inset: 0;
  z-index: 1;
  padding: clamp(14px, 3.6vh, 22px) clamp(10px, 3vw, 14px);
  display: flex;
  flex-direction: column;
}

.list__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  padding: 0 8px clamp(10px, 2.6vh, 16px);
}

.list__kicker {
  margin: 0 0 4px;
  font-size: 11.5px;
  font-weight: 560;
  font-variation-settings: 'wdth' 112;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.list__title {
  margin: 0;
  font-size: clamp(20px, 5.4vh, 26px);
  line-height: 1;
  font-weight: 640;
  font-variation-settings: 'wdth' 96;
  letter-spacing: -0.02em;
}

.list__total {
  display: grid;
  justify-items: end;
  gap: 3px;
}

.list__sum {
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.list__day {
  font-size: 11.5px;
  color: var(--up);
  font-variant-numeric: tabular-nums;
}

.list__rows {
  display: grid;
  gap: 2px;
}

.row {
  position: relative;
  display: block;
  width: 100%;
  height: clamp(44px, 10vh, 60px);
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.row:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--up) 70%, transparent);
  outline-offset: 1px;
}

/* the face of the row: GSAP scales it on the press, CSS colours it */
.row__in {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 64px auto;
  align-items: center;
  gap: clamp(8px, 2.6vw, 12px);
  padding: 0 8px;
  border-radius: inherit;
  transition: background-color 0.35s ease, box-shadow 0.35s ease;
}

.row.is-hot .row__in {
  background: var(--row-hot);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

@media (hover: hover) {
  .row:hover .row__in {
    background: var(--row-hot);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  }
}

/* the rows between hairlines */
.row + .row::before {
  content: '';
  position: absolute;
  left: 52px;
  right: 8px;
  top: -1px;
  height: 1px;
  background: rgba(255, 255, 255, 0.045);
}

.row__names {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.row__ticker {
  justify-self: start;
  font-size: 14px;
  line-height: 1.1;
  font-weight: 620;
  font-variation-settings: 'wdth' 108;
  letter-spacing: 0.01em;
  transform-origin: 0 0;
}

.row__name {
  justify-self: start;
  max-width: 100%;
  font-size: 11.5px;
  line-height: 1.2;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transform-origin: 0 0;
}

.row__spark {
  display: block;
  width: 64px;
  height: 24px;
  overflow: visible;
}

.row__spark path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.row__right {
  display: grid;
  justify-items: end;
  gap: 4px;
}

.row__price {
  font-size: 14px;
  line-height: 1.1;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* ---------------------------------------------------------------- the logos */
.logo {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(150deg, var(--a, #3a4150), var(--b, #1b1e25));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 4px 10px -4px rgba(0, 0, 0, 0.7);
  transform-origin: 0 0;
}

.logo svg {
  width: 52%;
  height: 52%;
  fill: none;
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------------------------------------------------------------- the change pill */
.pill {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 7px;
  font-size: 11.5px;
  line-height: 1.15;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--c, var(--up));
  background: color-mix(in srgb, var(--c, var(--up)) 13%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c, var(--up)) 18%, transparent);
  transform-origin: 0 0;
}

.is-down {
  --c: var(--down);
}

/* ---------------------------------------------------------------- the plate */
.plate {
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(255, 255, 255, 0.035), transparent 60%),
    var(--sheet);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  clip-path: inset(50% round 14px);
  opacity: 0;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the stock's page */
.detail {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  padding: clamp(10px, 2.8vh, 18px) clamp(14px, 4.4vw, 20px) clamp(12px, 3vh, 20px);
  visibility: hidden;
  pointer-events: none;
}

.detail.is-open {
  visibility: visible;
  pointer-events: auto;
}

.detail__bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 -6px;
}

.detail__back,
.detail__save {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 34px;
  padding: 0 10px 0 4px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 540;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.3s ease, background-color 0.3s ease;
}

.detail__save {
  width: 34px;
  padding: 0;
  justify-content: center;
  color: var(--ink);
}

.detail__back svg,
.detail__save svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.detail__save svg path {
  fill: currentColor;
  fill-opacity: 0.9;
  transition: fill-opacity 0.3s ease;
}

.detail__save[aria-pressed='false'] svg path {
  fill-opacity: 0;
}

@media (hover: hover) {
  .detail__back:hover,
  .detail__save:hover {
    color: var(--ink);
    background: rgba(255, 255, 255, 0.05);
  }
}

.detail__back:focus-visible,
.detail__save:focus-visible,
.tabs__tab:focus-visible,
.buy:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--up) 70%, transparent);
  outline-offset: 2px;
}

.detail__head {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: clamp(4px, 1.4vh, 10px);
}

.detail__head .logo {
  width: clamp(32px, 8vh, 42px);
  height: clamp(32px, 8vh, 42px);
  border-radius: clamp(10px, 2.5vh, 13px);
}

.detail__names {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.detail__sub {
  display: flex;
  gap: 5px;
  align-items: baseline;
  min-width: 0;
}

.detail__ex {
  font-size: 12.5px;
  line-height: 1.2;
  color: var(--muted);
  white-space: nowrap;
}

.detail__name {
  justify-self: start;
  font-size: 12.5px;
  line-height: 1.2;
  color: var(--muted);
  white-space: nowrap;
  transform-origin: 0 0;
}

.detail__ticker {
  justify-self: start;
  font-size: clamp(16px, 4vh, 19px);
  line-height: 1.1;
  font-weight: 640;
  font-variation-settings: 'wdth' 108;
  letter-spacing: 0.01em;
  transform-origin: 0 0;
}

/* the big price: each figure is a column of 0 to 9 that rolls */
.detail__price {
  display: flex;
  align-self: flex-start;
  margin: clamp(8px, 2.2vh, 16px) 0 0;
  font-size: clamp(28px, 8vh, 40px);
  line-height: 1;
  height: 1em;
  font-weight: 640;
  font-variation-settings: 'wdth' 94;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  transform-origin: 0 0;
}

.dg {
  display: block;
  height: 1em;
  overflow: hidden;
}

.dg__s {
  display: flex;
  flex-direction: column;
}

.dg__s span {
  display: block;
  height: 1em;
}

.dg-c {
  display: block;
}

.detail__move {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: clamp(6px, 1.6vh, 10px) 0 0;
}

.detail__move .pill {
  font-size: 12px;
}

.detail__delta {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.detail__chart {
  position: relative;
  flex: 1 1 auto;
  min-height: 70px;
  margin: clamp(6px, 1.6vh, 12px) -2px 0;
  touch-action: pan-y;
  cursor: crosshair;
}

/* the range tabs, with a pill that slides */
.tabs {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: clamp(6px, 1.6vh, 12px);
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.tabs__pill {
  position: absolute;
  left: 0;
  top: 3px;
  bottom: 3px;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.07));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 2px 6px -2px rgba(0, 0, 0, 0.6);
}

.tabs__tab {
  position: relative;
  height: clamp(24px, 6vh, 30px);
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  font-variation-settings: 'wdth' 108;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.3s ease;
}

.tabs__tab.is-on {
  color: var(--ink);
}

/* open, high, low and volume: only when the app is tall enough */
.stats {
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 14px 0 0;
}

.stats div {
  display: grid;
  gap: 3px;
}

.stats dt {
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.stats dd {
  margin: 0;
  font-size: 12.5px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
}

@media (min-height: 640px) {
  .stats {
    display: grid;
  }
}

.buy {
  position: relative;
  flex: none;
  height: clamp(42px, 10vh, 54px);
  margin-top: clamp(8px, 2vh, 14px);
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, var(--button));
  color: var(--button-ink);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.12), 0 8px 20px -10px rgba(255, 255, 255, 0.35);
  font: inherit;
  font-size: 14.5px;
  font-weight: 620;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.buy__words {
  display: inline-block;
  font-variation-settings: 'wdth' 100;
  transition: font-variation-settings 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (hover: hover) {
  .buy:hover .buy__words {
    font-variation-settings: 'wdth' 114;
  }
}

/* ---------------------------------------------------------------- the shared line */
.line {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  color: var(--up);
  opacity: 0;
  transition: color 0.6s ease;
}

.line.is-down {
  color: var(--down);
}

.line__path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* a soft copy of the line under it, the light the line throws */
.line__glow {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: blur(6px);
}

.line__base {
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 1;
  stroke-dasharray: 2 4;
}

.line__cross {
  opacity: 0;
}

.line__cross-x {
  stroke: rgba(255, 255, 255, 0.28);
  stroke-width: 1;
}

.line__ring {
  fill: var(--sheet);
  stroke: currentColor;
  stroke-width: 2;
}

.line__when {
  fill: var(--muted);
  font-size: 10.5px;
  font-weight: 540;
  font-variant-numeric: tabular-nums;
}
