/* The guided breathing card: a frosted glass card in a warm dark room, two soft lights behind it and a fine grain.
   In the middle a soft shape of glass with a light inside, moved by script.js: the box .orb is scaled by GSAP, its
   child .orb__shape changes its soft outline, the light inside (.orb__core) and the halo take the colour of the phase
   from the variables --core and --halo, which GSAP tweens on the card. */
:root {
  --page: #120e0c;            /* the warm dark room */
  --room-a: #8a4a26;          /* the warm light behind the glass */
  --room-b: #3b2c4a;          /* the dusky light on the other side */
  --glass: rgba(30, 25, 23, 0.6); /* the body of the glass card */
  --edge: rgba(255, 240, 225, 0.11); /* its edge */
  --ink: #f5efe8;             /* the words */
  --muted: #9a8f86;           /* the small words */
  --cool: #8fb2e6;            /* the light when the shape is empty: cool */
  --warm: #ffbe7a;            /* the light when the shape is full: warm */
  --rose: #f29a92;            /* the light while it empties: rose */
  --ring-off: rgba(255, 240, 225, 0.12); /* the breaths still to come */
  --ring-on: #f6dcc0;         /* the breaths done */
  --well: min(300px, 46vh, 66vw); /* the size of the shape's room */
}

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

/* the grain over everything */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.1;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><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 1 0'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
  z-index: 5;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 1.5px solid var(--warm);
  outline-offset: 3px;
}

p {
  margin: 0;
}

.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 12px 16px;
  overflow: hidden;
  isolation: isolate;
}

/* the two lights of the room */
.room {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(74vw, 74vh, 560px);
  aspect-ratio: 1;
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;
}

.room--a {
  margin: calc(min(74vw, 74vh, 560px) * -0.84) 0 0 calc(min(74vw, 74vh, 560px) * -0.98);
  background: radial-gradient(circle, var(--room-a), color-mix(in srgb, var(--room-a) 45%, transparent) 30%, color-mix(in srgb, var(--room-a) 12%, transparent) 52%, transparent 70%);
  opacity: 0.62;
}

.room--b {
  margin: calc(min(74vw, 74vh, 560px) * -0.22) 0 0 calc(min(74vw, 74vh, 560px) * -0.04);
  background: radial-gradient(circle, var(--room-b), color-mix(in srgb, var(--room-b) 45%, transparent) 30%, color-mix(in srgb, var(--room-b) 12%, transparent) 52%, transparent 70%);
  opacity: 0.7;
}

/* the glass card */
.card {
  --mx: 50%;
  --my: 0%;
  --core: var(--cool);
  --halo: var(--cool);
  position: relative;
  width: min(660px, 92vw, 100%);
  min-width: 0;
  padding: clamp(10px, 2.6vh, 20px) clamp(14px, 4vw, 24px) clamp(10px, 2.4vh, 18px);
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255, 245, 235, 0.07), rgba(255, 245, 235, 0.015) 40%, rgba(255, 245, 235, 0)),
    var(--glass);
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 245, 235, 0.16),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35),
    0 1px 1px rgba(0, 0, 0, 0.3),
    0 18px 40px -16px rgba(0, 0, 0, 0.7),
    0 50px 90px -40px rgba(0, 0, 0, 0.85);
  opacity: 0;
  overflow: hidden;
}

/* the light on the glass that follows the pointer */
.card__sheen {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.card__sheen::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(300px 200px at var(--mx) var(--my), rgba(255, 230, 205, 0.07), transparent 70%);
}

.card__sheen::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: radial-gradient(220px 140px at var(--mx) var(--my), rgba(255, 222, 186, 0.5), transparent 70%);
  -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);
}

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

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

.brand__mark {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.7;
  stroke-linecap: round;
}

.brand__name {
  font-size: 15px;
  font-weight: 640;
  font-variation-settings: 'wdth' 112;
  letter-spacing: 0.01em;
}

.meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 0;
  text-align: right;
}

.meta__title {
  font-size: 13px;
  font-weight: 560;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.meta__sub {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* the room of the shape: the ring around it, the shape, the words on it */
.well {
  position: relative;
  width: var(--well);
  height: var(--well);
  margin: clamp(4px, 1.4vh, 12px) auto;
  display: grid;
  place-items: center;
}

/* the soft reflection of the light on the floor of the glass card */
.well__floor {
  position: absolute;
  left: 50%;
  bottom: -2%;
  width: 70%;
  height: 16%;
  margin-left: -35%;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--halo), color-mix(in srgb, var(--halo) 35%, transparent) 45%, transparent);
  opacity: 0.2;
  pointer-events: none;
}

.ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: rotate(-90deg);
}

.ring path {
  fill: none;
  stroke-width: 1.3;
  stroke-linecap: round;
}

.ring .seg-off {
  stroke: var(--ring-off);
}

.ring .seg-on {
  stroke: var(--ring-on);
  stroke-linecap: butt;
}

.orb {
  position: absolute;
  left: 11%;
  top: 11%;
  width: 78%;
  height: 78%;
  will-change: transform;
}

/* the glow of the light outside the glass */
.orb__halo {
  position: absolute;
  inset: -26%;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--halo), color-mix(in srgb, var(--halo) 40%, transparent) 40%, color-mix(in srgb, var(--halo) 10%, transparent) 65%, transparent 85%);
  opacity: 0.32;
}

/* the glass shape: soft outline, frosted body, light inside */
.orb__shape {
  position: absolute;
  inset: 0;
  border-radius: 50% 48% 52% 50% / 49% 52% 48% 51%;
  overflow: hidden;
  background:
    radial-gradient(120% 120% at 30% 22%, rgba(255, 250, 244, 0.16), rgba(255, 250, 244, 0.03) 46%, rgba(255, 250, 244, 0) 70%),
    radial-gradient(90% 90% at 50% 60%, color-mix(in srgb, var(--core) 18%, transparent), transparent 75%),
    rgba(255, 244, 232, 0.05);
  box-shadow:
    inset 0 0 0 1px rgba(255, 245, 235, 0.16),
    inset 0 2px 1px rgba(255, 255, 255, 0.18),
    inset 0 -14px 28px -10px rgba(0, 0, 0, 0.35),
    0 24px 44px -22px rgba(0, 0, 0, 0.75);
}

/* the light inside the glass */
.orb__core {
  position: absolute;
  left: 14%;
  top: 18%;
  width: 72%;
  height: 72%;
  border-radius: 50%;
  background:
    radial-gradient(closest-side, color-mix(in srgb, var(--core) 70%, white) 0%, var(--core) 26%, color-mix(in srgb, var(--core) 55%, transparent) 50%, color-mix(in srgb, var(--core) 20%, transparent) 74%, transparent 100%);
  opacity: 0.72;
}

/* a slow caustic turning inside the glass */
.orb__caustic {
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(255, 250, 240, 0) 0%, rgba(255, 250, 240, 0.02) 12%, rgba(255, 250, 240, 0.13) 25%, rgba(255, 250, 240, 0.02) 38%, rgba(255, 250, 240, 0) 50%, rgba(255, 250, 240, 0.08) 70%, rgba(255, 250, 240, 0) 86%);
  -webkit-mask: radial-gradient(closest-side, #000 40%, transparent 100%);
  mask: radial-gradient(closest-side, #000 40%, transparent 100%);
  mix-blend-mode: screen;
}

/* the highlight on the top left of the glass */
.orb__spec {
  position: absolute;
  left: 17%;
  top: 9%;
  width: 40%;
  height: 22%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.18) 50%, rgba(255, 255, 255, 0));
  transform: rotate(-24deg);
  opacity: 0.8;
}

/* the thin edge of the glass, brighter on top and on the bottom where it takes the light inside */
.orb__rim {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.2px;
  background: linear-gradient(170deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.04) 38%, rgba(255, 255, 255, 0) 60%, color-mix(in srgb, var(--core) 70%, transparent) 100%);
  -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);
}

/* the word of the phase and the seconds, on the glass */
.readout {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(2px, 0.6vh, 6px);
  pointer-events: none;
  text-shadow: 0 1px 12px rgba(30, 16, 8, 0.45);
}

.phase {
  position: relative;
  display: grid;
  height: 1.25em;
  font-size: clamp(19px, 4.6vh, 30px);
  font-weight: 520;
  letter-spacing: -0.005em;
  white-space: nowrap;
}

.phase__word {
  grid-area: 1 / 1;
  justify-self: center;
  font-variation-settings: 'wdth' 100;
  opacity: 0;
}

.count {
  display: flex;
  align-items: center;
  gap: 1px;
  height: 1.2em;
  line-height: 1.2em;
  font-size: clamp(14px, 3vh, 19px);
  font-weight: 540;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 245, 235, 0.82);
}

.roll {
  position: relative;
  display: inline-block;
  width: 0.62em;
  height: 1.2em;
  overflow: hidden;
  vertical-align: bottom;
  text-align: center;
}

.roll > span {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  line-height: 1.2em;
}

.count__unit {
  opacity: 0.7;
}

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

.tally {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tally__breaths {
  display: flex;
  align-items: center;
  line-height: 1.2em;
  gap: 4px;
  font-size: 13px;
  font-weight: 580;
  white-space: nowrap;
}

.roll--small {
  width: 0.66em;
}

.tally__left {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.controls {
  display: flex;
  gap: 8px;
  flex: none;
}

.ctl {
  position: relative;
  height: 38px;
  border-radius: 999px;
}

.ctl__face {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 100%;
  padding: 0 15px;
  border-radius: inherit;
  font-size: 13px;
  font-weight: 580;
  font-variation-settings: 'wdth' 100;
  transition: background-color 0.3s, box-shadow 0.3s, font-variation-settings 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.ctl--pause .ctl__face {
  min-width: 104px;
  background: rgba(255, 245, 235, 0.92);
  color: #1d1410;
  box-shadow: inset 0 1px 0 #fff, inset 0 -1px 0 rgba(0, 0, 0, 0.12), 0 6px 16px -8px rgba(0, 0, 0, 0.7);
}

.ctl--end .ctl__face {
  background: rgba(255, 245, 235, 0.05);
  box-shadow: inset 0 0 0 1px rgba(255, 245, 235, 0.13), inset 0 1px 0 rgba(255, 245, 235, 0.06);
  color: var(--ink);
}

.ctl__icon {
  width: 14px;
  height: 14px;
  flex: none;
  fill: currentColor;
  overflow: visible;
}

.ctl__bars,
.ctl__play {
  transform-box: fill-box;
  transform-origin: 50% 50%;
}

.ctl__play {
  opacity: 0;
}

.ctl[disabled] {
  cursor: default;
  opacity: 0.38;
}

@media (hover: hover) {
  .ctl:not([disabled]):hover .ctl__face {
    font-variation-settings: 'wdth' 112;
  }

  .ctl--pause:not([disabled]):hover .ctl__face {
    background: #fff;
  }

  .ctl--end:not([disabled]):hover .ctl__face {
    background: rgba(255, 245, 235, 0.1);
  }
}

@media (max-width: 420px) {
  .meta__sub {
    display: none;
  }

  .ctl {
    height: 34px;
  }

  .ctl__face {
    padding: 0 12px;
    font-size: 12.5px;
  }

  .ctl--pause .ctl__face {
    min-width: 92px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ctl__face {
    transition: background-color 0.3s;
  }
}
