:root {
  --paper: #f3ece1;
  --ink: #202523;
  --muted: #6f756d;
  --line: rgba(35, 39, 36, 0.18);
  --panel: rgba(247, 241, 232, 0.72);
  --panel-strong: rgba(255, 252, 246, 0.86);
  --shadow: rgba(29, 32, 30, 0.18);
  --word-color: #202523;
  --word-family: "Cormorant Garamond", Georgia, serif;
  --word-weight: 600;
  --word-style: normal;
  --word-scale: 1;
  --word-width: 1.9;
  --word-size: 12rem;
  --word-x: 0em;
  --word-y: 0em;
  --word-rotation: 0deg;
  --word-skew: 0deg;
  --word-soft: 55;
  --word-wonk: 0;
  --word-opsz: 72;
  --drift-opacity: 0.56;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 252, 245, 0.82), rgba(214, 226, 216, 0.34)),
    url("assets/ambient-paper.webp") center / cover no-repeat,
    var(--paper);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background:
    linear-gradient(90deg, rgba(24, 30, 27, 0.09), transparent 24%, transparent 76%, rgba(255, 253, 247, 0.2)),
    linear-gradient(180deg, rgba(255, 252, 246, 0.18), transparent 28%, rgba(35, 43, 39, 0.07));
  mix-blend-mode: multiply;
}

body::after {
  opacity: 0.12;
  background-image:
    repeating-linear-gradient(0deg, rgba(32, 37, 35, 0.08) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.1) 0 1px, transparent 1px 4px);
  mix-blend-mode: soft-light;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

#atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  opacity: var(--drift-opacity);
  pointer-events: none;
  mix-blend-mode: multiply;
}

.experience {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 100svh;
  padding: clamp(18px, 3vw, 42px);
}

.word-stage {
  display: grid;
  place-items: center;
  min-height: 0;
}

.word-frame {
  position: relative;
  width: min(94vw, 1480px);
  height: clamp(12rem, 36vw, 31rem);
  display: grid;
  place-items: center;
  isolation: isolate;
}

.word-layer {
  position: absolute;
  width: 100%;
  max-width: 100%;
  color: var(--word-color);
  font-family: var(--word-family);
  font-size: var(--word-size);
  font-style: var(--word-style);
  font-weight: var(--word-weight);
  font-variation-settings: "SOFT" var(--word-soft), "WONK" var(--word-wonk), "opsz" var(--word-opsz);
  letter-spacing: 0;
  line-height: 0.82;
  overflow-wrap: anywhere;
  text-align: center;
  text-rendering: geometricPrecision;
  text-shadow: 0 0.025em 0.16em rgba(255, 252, 246, 0.42), 0 0.12em 0.5em rgba(33, 38, 35, 0.1);
  transform: translate(var(--word-x), calc(var(--word-y) + 0.18em)) rotate(var(--word-rotation)) skewX(var(--word-skew)) scale(calc(var(--word-scale) * var(--word-width) * 0.985), calc(var(--word-scale) * 0.985));
  transform-origin: center center;
  opacity: 0;
  filter: blur(14px);
  transition:
    opacity 980ms cubic-bezier(0.19, 1, 0.22, 1),
    color 420ms linear,
    font-weight 420ms linear,
    font-variation-settings 420ms linear,
    filter 1040ms cubic-bezier(0.19, 1, 0.22, 1),
    transform 1120ms cubic-bezier(0.19, 1, 0.22, 1);
  user-select: none;
  will-change: opacity, filter, transform;
}

.word-layer.is-active {
  opacity: 1;
  filter: blur(0);
  transform: translate(var(--word-x), var(--word-y)) rotate(var(--word-rotation)) skewX(var(--word-skew)) scale(calc(var(--word-scale) * var(--word-width)), var(--word-scale));
}

.word-layer.is-receding {
  transform: translate(var(--word-x), calc(var(--word-y) - 0.16em)) rotate(var(--word-rotation)) skewX(var(--word-skew)) scale(calc(var(--word-scale) * var(--word-width) * 1.018), calc(var(--word-scale) * 1.018));
}

.screen-reader-word {
  position: fixed;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.controls {
  display: grid;
  grid-template-columns: 2.75rem minmax(4.6rem, 5.8rem) 2.75rem repeat(4, minmax(6.8rem, 1fr));
  gap: 0.68rem;
  align-items: center;
  justify-content: center;
  width: min(100%, 64rem);
  margin: 0 auto;
  padding: 0.62rem;
  border: 1px solid rgba(35, 39, 36, 0.08);
  border-radius: 8px;
  background: rgba(247, 241, 232, 0.05);
  box-shadow: none;
  opacity: 0.32;
  transform: translateY(0);
  transition: opacity 220ms ease, border-color 220ms ease, background 220ms ease, transform 360ms ease;
}

.controls:hover,
.controls:focus-within {
  border-color: rgba(35, 39, 36, 0.18);
  background: rgba(247, 241, 232, 0.13);
  opacity: 0.96;
  transform: translateY(0);
}

.controls.is-resting:not(:hover):not(:focus-within) {
  border-color: rgba(35, 39, 36, 0.02);
  background: rgba(247, 241, 232, 0.015);
  opacity: 0.055;
  transform: translateY(calc(100% - 0.95rem));
}

.icon-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.75rem;
  aspect-ratio: 1;
  border: 1px solid rgba(30, 35, 32, 0.1);
  border-radius: 8px;
  background: rgba(255, 252, 246, 0.16);
  color: var(--ink);
  cursor: pointer;
  transition: background 180ms ease, transform 180ms ease, border-color 180ms ease;
}

.icon-button:hover {
  background: rgba(255, 254, 250, 0.46);
  border-color: rgba(30, 35, 32, 0.24);
}

.icon-button:active {
  transform: translateY(1px);
}

.icon-button:focus-visible,
.range-control input:focus-visible {
  outline: 2px solid rgba(42, 81, 87, 0.62);
  outline-offset: 3px;
}

.pause-icon,
.pause-icon::before,
.pause-icon::after,
.skip-icon,
.skip-icon::before,
.skip-icon::after {
  display: block;
}

.pause-icon {
  position: relative;
  width: 1rem;
  height: 1rem;
}

.pause-icon::before,
.pause-icon::after {
  content: "";
  position: absolute;
  top: 0.09rem;
  width: 0.24rem;
  height: 0.82rem;
  border-radius: 2px;
  background: currentColor;
}

.pause-icon::before {
  left: 0.22rem;
}

.pause-icon::after {
  right: 0.22rem;
}

.icon-button.is-paused .pause-icon::before {
  top: 0.05rem;
  left: 0.31rem;
  width: 0;
  height: 0;
  border-top: 0.46rem solid transparent;
  border-bottom: 0.46rem solid transparent;
  border-left: 0.72rem solid currentColor;
  border-radius: 0;
  background: transparent;
}

.icon-button.is-paused .pause-icon::after {
  display: none;
}

.skip-icon {
  position: relative;
  width: 1.08rem;
  height: 1rem;
}

.skip-icon::before {
  content: "";
  position: absolute;
  top: 0.08rem;
  left: 0.12rem;
  width: 0;
  height: 0;
  border-top: 0.42rem solid transparent;
  border-bottom: 0.42rem solid transparent;
  border-left: 0.58rem solid currentColor;
}

.skip-icon::after {
  content: "";
  position: absolute;
  top: 0.1rem;
  right: 0.14rem;
  width: 0.18rem;
  height: 0.8rem;
  border-radius: 2px;
  background: currentColor;
}

.range-control,
.pace-readout {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr);
  gap: 0.54rem;
  align-items: center;
  min-width: 0;
  color: rgba(32, 37, 35, 0.58);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: uppercase;
}

.pace-readout output {
  color: rgba(32, 37, 35, 0.72);
  font-variant-numeric: tabular-nums;
}

.range-control input {
  width: 100%;
  min-width: 0;
  accent-color: #344f50;
  opacity: 0.5;
}

.controls:hover .range-control input,
.controls:focus-within .range-control input {
  opacity: 0.86;
}

@media (max-width: 660px) {
  :root {
    --word-size: 5.8rem;
  }

  .experience {
    padding: 18px;
  }

  .word-frame {
    width: min(100%, calc(100svw - 36px));
    height: 48vh;
    min-height: 17rem;
  }

  .controls {
    grid-template-columns: 2.75rem minmax(0, 1fr) 2.75rem;
    width: min(100%, calc(100svw - 36px));
    max-width: calc(100svw - 36px);
  }

  .range-control {
    grid-template-columns: 2.8rem minmax(0, 1fr);
  }

  .range-control {
    grid-column: 1 / -1;
    padding: 0 0.15rem 0.15rem;
  }
}

@media (min-width: 661px) and (max-width: 980px) {
  :root {
    --word-size: 8.6rem;
  }
}

@media (min-width: 981px) and (max-width: 1320px) {
  :root {
    --word-size: 10.4rem;
  }
}

@media (min-width: 1680px) {
  :root {
    --word-size: 14.2rem;
  }
}

@media (max-width: 420px) {
  :root {
    --word-size: 4.7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .word-layer {
    transition-duration: 1ms;
  }

  #atmosphere {
    opacity: 0.18;
  }
}
