/* The garden sprinklers toggle with the water that flows through the track: the irrigation card of a made-up smart
   garden app, Loam, on white. A white card with a 1px edge and soft layered shadows; the switch is a long glass pipe
   with a glazed ceramic knob; one accent, a clear garden-hose blue, that only shows up with the water. */
:root {
  --page: #ffffff;              /* the page */
  --card: #ffffff;              /* the body of the card */
  --card-low: #fafaf8;          /* the bottom of the card, a touch warmer */
  --ink: #15171a;               /* the words */
  --muted: #7d8087;             /* the small words */
  --faint: #b4b7bd;             /* the readings at rest */
  --line: rgba(20, 24, 30, 0.07); /* the thin lines */
  --glass: #eef0f2;             /* the empty pipe */
  --water: #2f8ff0;             /* the one accent: the water */
  --water-top: #8fd0ff;         /* the light on top of the water */
  --water-deep: #1559c9;        /* the deep bottom of the water */
}

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

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

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

/* the wrap is GSAP's (entrance), the card is CSS's */
.wrap {
  width: min(384px, 90vw);
  opacity: 0;
}

.card {
  position: relative;
  isolation: isolate;
  border-radius: 24px;
  padding: clamp(14px, 3.8vh, 22px) clamp(14px, 4.6vw, 22px) clamp(12px, 3.2vh, 18px);
  background: linear-gradient(180deg, var(--card), var(--card-low));
  box-shadow:
    0 0 0 1px rgba(20, 24, 30, 0.06),
    0 1px 2px rgba(20, 24, 30, 0.05),
    0 8px 20px -10px rgba(20, 30, 50, 0.14),
    0 34px 70px -34px rgba(20, 40, 80, 0.22);
  overflow: clip;
}

/* the 1px edge that turns faintly blue on the side of the pipe while the water runs */
.card__edge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 40%);
  -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: 3;
}

.card__edge::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(90% 70% at 15% 100%, rgba(47, 143, 240, 0.55), rgba(47, 143, 240, 0) 70%);
  opacity: var(--wet, 0);
}

/* the cool light that rises from under the pipe */
.card__glow {
  position: absolute;
  left: -20%;
  bottom: -70%;
  width: 120%;
  aspect-ratio: 1.6;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(47, 143, 240, 0.13), rgba(47, 143, 240, 0.04) 60%, transparent 80%);
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

/* a very fine grain, so the white is paper and not a screen */
.card__grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------------------------------------------------------------- the head */
.head {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: clamp(10px, 3vw, 14px);
}

.tile {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #f7f8f9, #eceef1);
  box-shadow: inset 0 0 0 1px rgba(20, 24, 30, 0.06), inset 0 1px 0 #fff, 0 1px 2px rgba(20, 24, 30, 0.06);
  color: #5d6168;
  transition: color 0.5s ease;
}

.tile.is-on {
  color: var(--water-deep);
}

.tile__svg {
  width: 30px;
  height: 30px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tile__head rect,
.tile__body {
  fill: rgba(255, 255, 255, 0.9);
}

.tile__lawn {
  stroke: #8fb46a;
}

/* the jets are dashed droplets: GSAP runs their dash offset, so they spray out of the nozzle */
.tile__jet {
  stroke: var(--water);
  stroke-width: 1.5;
  stroke-dasharray: 0.1 2.9;
  opacity: 0;
}

.head__copy {
  min-width: 0;
}

.head__title {
  margin: 0;
  font-size: clamp(15px, 4.2vw, 16.5px);
  font-weight: 620;
  font-stretch: 104%;
  letter-spacing: -0.01em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.head__sub {
  margin: 3px 0 0;
  font-size: 12.5px;
  line-height: 1.3;
  color: var(--muted);
}

/* two faces of the same line: one rolls out up, the other rolls in from below */
.roll {
  position: relative;
  display: block;
  height: 1.3em;
  overflow: hidden;
}

.roll__face {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
}

.roll__face--on {
  color: var(--water-deep);
  font-weight: 560;
  opacity: 0;
}

/* ---------------------------------------------------------------- the pipe (the switch) */
.pipe {
  --h: clamp(46px, 11vh, 56px);
  position: relative;
  display: block;
  width: 100%;
  height: var(--h);
  margin: clamp(12px, 3.4vh, 20px) 0 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.pipe:focus-visible {
  outline: 2px solid var(--water);
  outline-offset: 4px;
}

.pipe__glass {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  background: linear-gradient(180deg, #e6e9ec, var(--glass) 40%, #f6f7f8);
  box-shadow:
    inset 0 2px 5px rgba(20, 30, 45, 0.12),
    inset 0 0 0 1px rgba(20, 30, 45, 0.07),
    inset 0 -1px 0 rgba(255, 255, 255, 0.9),
    0 1px 0 rgba(255, 255, 255, 1);
  transition: box-shadow 0.25s ease;
}

.pipe__svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.water__front {
  fill: none;
  stroke: rgba(255, 255, 255, 0.55);
  stroke-width: 1.2;
}

.streak {
  stroke: rgba(255, 255, 255, 0.5);
  stroke-linecap: round;
  fill: none;
}

.bubble {
  fill: rgba(255, 255, 255, 0.18);
  stroke: rgba(255, 255, 255, 0.75);
  stroke-width: 0.8;
}

.drop {
  fill: rgba(47, 143, 240, 0.22);
  stroke: rgba(255, 255, 255, 0.8);
  stroke-width: 0.6;
}

/* the long highlight of the glass, above the water */
.pipe__shine {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 14%;
  height: 22%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0));
  opacity: 0.75;
  pointer-events: none;
}

.pipe__word {
  position: absolute;
  top: 50%;
  font-size: 12px;
  font-weight: 600;
  font-stretch: 112%;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
  transform: translateY(-50%);
  pointer-events: none;
}

.pipe__word--off {
  right: calc(var(--h) * 0.5);
  color: #969aa1;
}

.pipe__word--on {
  left: calc(var(--h) * 0.5);
  color: #fff;
  opacity: 0;
  text-shadow: 0 1px 2px rgba(10, 50, 120, 0.35);
}

/* the knob is GSAP's (x), the body is GSAP's too (press), the ceramic inside is CSS's */
.knob {
  position: absolute;
  left: 4px;
  top: 4px;
  width: calc(var(--h) - 8px);
  height: calc(var(--h) - 8px);
  pointer-events: none;
}

.knob__body {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  box-shadow:
    0 1px 1px rgba(20, 30, 45, 0.12),
    0 3px 8px -2px rgba(20, 30, 45, 0.25),
    0 10px 18px -8px rgba(20, 40, 80, 0.3);
}

.knob__ceramic {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(80% 60% at 36% 24%, #ffffff 0%, rgba(255, 255, 255, 0) 64%),
    radial-gradient(120% 120% at 50% 110%, #dfe3e8 0%, #f6f7f9 55%, #ffffff 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.95), inset 0 -2px 3px rgba(20, 30, 45, 0.1), inset 0 0 0 0.5px rgba(20, 30, 45, 0.12);
}

.knob__drop {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46%;
  height: 46%;
  transform: translate(-50%, -50%);
  overflow: visible;
}

.knob__drop path {
  fill: none;
  stroke: #9aa0a8;
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.knob__drop .knob__glint {
  stroke: rgba(255, 255, 255, 0);
  stroke-width: 1.2;
}

@media (hover: hover) {
  .pipe:hover .pipe__glass {
    box-shadow:
      inset 0 2px 5px rgba(20, 30, 45, 0.14),
      inset 0 0 0 1px rgba(47, 143, 240, 0.18),
      inset 0 -1px 0 rgba(255, 255, 255, 0.9),
      0 0 0 4px rgba(47, 143, 240, 0.06);
  }
}

/* ---------------------------------------------------------------- the readings */
.meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: clamp(12px, 3.2vh, 18px) 0 0;
  padding-top: clamp(10px, 2.6vh, 14px);
  border-top: 1px solid var(--line);
}

.meta__cell {
  min-width: 0;
}

.meta__cell + .meta__cell {
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.meta dt {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.meta dd {
  margin: 3px 0 0;
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-size: clamp(16px, 4.6vw, 18px);
  font-weight: 600;
  font-stretch: 96%;
  letter-spacing: -0.01em;
  color: var(--faint);
  transition: color 0.5s ease;
}

.meta dd small {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

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

/* the numbers: every character in its own little window, so only the digits that change roll */
.num {
  display: inline-flex;
}

.ch {
  position: relative;
  display: inline-block;
  overflow: hidden;
  height: 1.15em;
  line-height: 1.15em;
}

.ch > span {
  display: block;
}

.ch > span + span {
  position: absolute;
  left: 0;
  top: 0;
}
