/* The minute by minute rain forecast: a dark glass widget of a made-up weather app on pure black. Sixty thin bars
   fill up from the left, a glass handle scrubs the hour (time and millimetres roll), drops condense on the glass when
   the rain is heavy and the widget ends on «Dry by 10:52» with the sun out from behind the cloud. */
:root {
  --page: #000000;            /* the page */
  --ink: #f3f5f7;             /* the words */
  --muted: #8a929c;           /* the small words */
  --faint: #3a4049;           /* the dry minutes and the hairlines */
  --rain: #6cb8ff;            /* the colour of the rain */
  --rain-deep: #7c86ff;       /* the colour of the heavy rain, at the top of the bars */
  --dry: #ffcf7a;             /* the colour of the dry weather */
  --acc: #6cb8ff;             /* the colour of the light right now (the script moves it) */
  --glass: rgba(255, 255, 255, 0.055); /* the tint of the glass */
}

* {
  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;
}

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

.widget {
  position: relative;
  width: min(90vw, 348px, calc((100vh - 28px) * 0.98));
}

/* the light behind the glass */
.widget__glow {
  position: absolute;
  left: 50%;
  top: 58%;
  width: 118%;
  aspect-ratio: 1.5;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--acc) 34%, transparent), color-mix(in srgb, var(--acc) 9%, transparent) 55%, transparent);
  filter: blur(8px);
  pointer-events: none;
  opacity: 0;
}

.widget__shadow {
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: -12px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.9);
  filter: blur(14px);
  pointer-events: none;
}

/* the glass */
.card {
  --mx: 72%;
  --my: -8%;
  position: relative;
  display: grid;
  gap: clamp(8px, 2.2vh, 14px);
  padding: clamp(14px, 3.6vh, 20px) clamp(14px, 4.4vw, 20px) clamp(12px, 3vh, 16px);
  border-radius: 28px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02) 46%, rgba(255, 255, 255, 0.045)),
    linear-gradient(180deg, #11151b, #0a0c10);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.13),
    inset 0 -1px 0 rgba(255, 255, 255, 0.03),
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 14px 28px -12px rgba(0, 0, 0, 0.7),
    0 44px 80px -36px rgba(0, 0, 0, 0.9);
  overflow: hidden;
  opacity: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* the 1px edge: faint everywhere, bright where the light is */
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background:
    radial-gradient(170px circle at var(--mx) var(--my), rgba(255, 255, 255, 0.8), color-mix(in srgb, var(--acc) 45%, transparent) 36%, transparent 70%),
    linear-gradient(170deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.04) 45%, rgba(255, 255, 255, 0.09));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  pointer-events: none;
  z-index: 4;
}

.card__grain,
.card__spot,
.card__wet {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.card__grain {
  opacity: 0.08;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.9 0'/></filter><rect width='140' height='140' filter='url(%23n)'/></svg>");
}

.card__spot {
  background:
    radial-gradient(240px circle at var(--mx) var(--my), rgba(255, 255, 255, 0.06), transparent 65%),
    radial-gradient(120% 70% at 50% 120%, color-mix(in srgb, var(--acc) 12%, transparent), transparent 70%);
}

.card__wet {
  width: 100%;
  height: 100%;
  z-index: 1;
}

.head,
.hero,
.read,
.chart,
.axis {
  position: relative;
  z-index: 2;
}

/* the top row */
.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  line-height: 1;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 640;
  font-stretch: 112%;
  letter-spacing: 0.01em;
}

.brand svg {
  width: 17px;
  height: 17px;
  fill: color-mix(in srgb, var(--acc) 85%, #ffffff);
  transition: fill 0.6s;
}

.place {
  color: var(--muted);
  font-weight: 480;
}

/* the icon and the big line */
.hero {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon {
  flex: none;
  width: clamp(34px, 8.6vh, 44px);
  height: clamp(34px, 8.6vh, 44px);
  overflow: visible;
}

.icon__sun circle {
  fill: none;
  stroke: var(--dry);
  stroke-width: 2.2;
}

.icon__rays path {
  fill: none;
  stroke: var(--dry);
  stroke-width: 2.1;
  stroke-linecap: round;
}

.icon__cloud {
  fill: #1b2129;
  stroke: #dfe6ee;
  stroke-width: 2.1;
  stroke-linejoin: round;
}

.icon__rain path {
  fill: none;
  stroke: var(--rain);
  stroke-width: 2.3;
  stroke-linecap: round;
}

.title {
  position: relative;
  display: grid;
  margin: 0;
  font-size: clamp(22px, 6.4vh, 29px);
  font-weight: 560;
  font-stretch: 104%;
  letter-spacing: -0.02em;
  line-height: 1.1;
  white-space: nowrap;
}

.title__line {
  grid-area: 1 / 1;
  display: inline-flex;
  align-items: center;
  gap: 0.26em;
}

.title__line[data-line="during"],
.title__line[data-line="after"] {
  opacity: 0;
}

/* the rolling digits: one column of 0-9 for each slot, inside a soft mask */
.roll {
  display: inline-flex;
  align-items: center;
  font-variant-numeric: tabular-nums;
}

.slot {
  position: relative;
  display: inline-block;
  width: 0.62em;
  height: 1.12em;
  overflow: hidden;
  -webkit-mask: linear-gradient(transparent, #000 22%, #000 78%, transparent);
  mask: linear-gradient(transparent, #000 22%, #000 78%, transparent);
}

.slot__col {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.slot__col span {
  height: 1.12em;
  line-height: 1.12em;
  text-align: center;
}

.sep {
  display: inline-block;
  line-height: 1.12em;
}

/* the reading under the cursor */
.read {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 540;
  color: var(--ink);
}

.read__time {
  color: var(--ink);
}

.read__mm {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: color-mix(in srgb, var(--acc) 70%, #ffffff);
  transition: color 0.6s;
}

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

.read__word {
  margin-left: auto;
  display: inline-block;
  height: 1.2em;
  overflow: hidden;
  font-size: 12px;
  font-weight: 560;
  font-stretch: 110%;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.word {
  display: inline-block;
  line-height: 1.2em;
}

/* the chart */
.chart {
  position: relative;
  height: clamp(74px, 22vh, 118px);
  margin-top: 2px;
  touch-action: none;
  cursor: ew-resize;
}

.bars {
  position: absolute;
  inset: 0;
}

.bar {
  position: absolute;
  bottom: 0;
  height: 100%;
  border-radius: 2px 2px 1px 1px;
  transform-origin: 50% 100%;
  transform: scaleY(0);
  will-change: transform, opacity;
}

.bar--rain {
  background: linear-gradient(to top, color-mix(in srgb, var(--rain) 70%, #10151c), var(--rain) 55%, var(--rain-deep));
  box-shadow: 0 0 10px -3px color-mix(in srgb, var(--rain) 60%, transparent);
}

.bar--dry {
  background: var(--faint);
}

.guide {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 1px dashed rgba(255, 255, 255, 0.09);
}

.guide span {
  position: absolute;
  right: 0;
  bottom: 3px;
  font-size: 9.5px;
  font-weight: 520;
  letter-spacing: 0.04em;
  color: #5d6570;
}

.now {
  position: absolute;
  left: 0;
  top: -2px;
  bottom: 0;
  width: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.22);
}

.now span {
  position: absolute;
  left: 5px;
  top: -1px;
  font-size: 9.5px;
  font-weight: 560;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* the cursor: a hairline and a glass handle at the foot */
.cursor {
  position: absolute;
  left: 0;
  top: -6px;
  bottom: -9px;
  width: 0;
  opacity: 0;
}

.cursor__line {
  position: absolute;
  left: -0.5px;
  top: 0;
  bottom: 9px;
  width: 1px;
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.85) 18%, rgba(255, 255, 255, 0.85));
}

.cursor__knob {
  position: absolute;
  left: -9px;
  bottom: -6px;
  width: 18px;
  height: 26px;
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0.12));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -1px 0 rgba(255, 255, 255, 0.08),
    0 0 0 1px rgba(255, 255, 255, 0.22),
    0 4px 10px rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  cursor: grab;
  outline: none;
  transform-origin: 50% 100%;
}

.cursor__grip {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 10px;
  margin: -5px 0 0 -3px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0.75)) 0 0 / 1px 100% no-repeat,
    linear-gradient(rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0.75)) 100% 0 / 1px 100% no-repeat;
}

.cursor__knob:focus-visible {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.4),
    0 0 0 4px color-mix(in srgb, var(--acc) 55%, transparent),
    0 4px 10px rgba(0, 0, 0, 0.55);
}

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

/* the time axis */
.axis {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.ghost {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  pointer-events: none;
  opacity: 0;
  z-index: 6;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

.ghost path {
  fill: #ffffff;
  stroke: #000000;
  stroke-width: 1.4;
  stroke-linejoin: round;
}

@media (max-width: 360px) {
  .read {
    gap: 9px;
    font-size: 13px;
  }
}
