/*
  Klid Piano Lessons (demo) - art direction
  Scene:   a concert hall with the house lights down. A black, glossy
           instrument, shafts of stage light, and a polished floor that
           throws everything back. The only colour is the light of the
           notes themselves.
  Palette: near-black ground, warm ivory text, hairlines of white. Seven
           note colours appear only as light: on the next key, in the
           falling beams, in the sparks.
  Type:    Heebo at its thinnest for headlines and at regular weight for
           text; Bona Nova italic for the one phrase that sings.
  Shape:   pills with a fine outline, bracketed asides, numbered movements.
*/

:root {
  --black: #020203;
  --coal: #0b0b0e;
  --ivory: #f2efe8;
  --dim: #9a978f;
  --line: rgba(242, 239, 232, 0.18);
  --gold: #f4d27a;
  --sans: 'Heebo', system-ui, sans-serif;
  --serif: 'Bona Nova', 'Times New Roman', serif;
  --gutter: clamp(1rem, 4vw, 3.5rem);
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  background: var(--black);
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--black);
  color: var(--ivory);
  font-family: var(--sans);
  font-size: 1.0625rem;
  font-weight: 300;
  line-height: 1.55;
  overflow-x: clip;
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
em { font-family: var(--serif); font-style: italic; font-weight: 400; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.ribbon-bar {
  position: sticky;
  top: 0;
  z-index: 6;
  padding: 0.4rem var(--gutter);
  border-bottom: 1px solid var(--line);
  background: #08080a;
  font-size: 0.875rem;
  font-weight: 400;
  text-align: center;
}

.top {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  block-size: 4.5rem;
  padding: 1.1rem var(--gutter) 0;
}
.brand { color: var(--dim); letter-spacing: 0.08em; font-size: 0.9375rem; font-weight: 400; }
.brand strong {
  margin-inline-end: 0.5em;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 2rem;
  letter-spacing: 0;
  color: var(--ivory);
}
.lang { padding: 0.5rem 0; font-weight: 400; text-underline-offset: 0.3em; }

.mark {
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0.22em;
  color: var(--dim);
}

/* ---------- ( I. ) The opening ---------- */

.hero {
  position: relative;
  display: grid;
  place-items: start center;
  min-block-size: calc(100vh - 2.6rem);
  min-block-size: calc(100svh - 2.6rem);
  margin-top: -4.5rem;
  padding: clamp(8rem, 19vh, 12rem) var(--gutter) 5rem;
  overflow: hidden;
  isolation: isolate;
  text-align: center;
}

/* Shafts of stage light, drifting very slowly. */
.beams { position: absolute; inset: 0; z-index: -2; }
.beams i {
  position: absolute;
  top: -30%;
  inline-size: 9rem;
  block-size: 160%;
  background: linear-gradient(rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0));
  filter: blur(26px);
  transform: rotate(24deg);
  animation: drift 16s ease-in-out infinite alternate;
}
.beams i:nth-child(1) { left: 6%; }
.beams i:nth-child(2) { left: 34%; inline-size: 5rem; opacity: 0.6; animation-duration: 21s; animation-direction: alternate-reverse; }
.beams i:nth-child(3) { left: 62%; inline-size: 12rem; opacity: 0.75; animation-duration: 26s; }
.beams i:nth-child(4) { left: 86%; inline-size: 4rem; opacity: 0.5; animation-duration: 18s; animation-direction: alternate-reverse; }
@keyframes drift {
  from { translate: -3rem 0; }
  to { translate: 3rem 0; }
}

/* A keyboard that runs to the horizon, glossy under the lights. */
.road {
  position: absolute;
  inset-inline: -30%;
  bottom: 0;
  z-index: -1;
  block-size: 31%;
  perspective: 520px;
  perspective-origin: 50% 0;
  -webkit-mask-image: linear-gradient(to top, #000 15%, transparent 92%);
  mask-image: linear-gradient(to top, #000 15%, transparent 92%);
  filter: brightness(0.82);
}
.road-keys {
  --k: 4.4rem;
  position: absolute;
  inset: 0;
  block-size: 260%;
  transform: rotateX(74deg);
  transform-origin: 50% 0;
  background:
    linear-gradient(90deg, transparent calc(var(--k) * 0.68), #060607 0 calc(var(--k) * 1.32), transparent 0) 0 0 / calc(var(--k) * 7) 58% repeat-x,
    linear-gradient(90deg, transparent calc(var(--k) * 1.68), #060607 0 calc(var(--k) * 2.32), transparent 0) 0 0 / calc(var(--k) * 7) 58% repeat-x,
    linear-gradient(90deg, transparent calc(var(--k) * 3.68), #060607 0 calc(var(--k) * 4.32), transparent 0) 0 0 / calc(var(--k) * 7) 58% repeat-x,
    linear-gradient(90deg, transparent calc(var(--k) * 4.68), #060607 0 calc(var(--k) * 5.32), transparent 0) 0 0 / calc(var(--k) * 7) 58% repeat-x,
    linear-gradient(90deg, transparent calc(var(--k) * 5.68), #060607 0 calc(var(--k) * 6.32), transparent 0) 0 0 / calc(var(--k) * 7) 58% repeat-x,
    repeating-linear-gradient(90deg, #dedad0 0 calc(var(--k) - 3px), #050506 0 var(--k));
}
/* A slow sweep of light across the keys. */
.road-keys::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 35%, rgba(255, 255, 255, 0.55) 50%, transparent 65%) 0 0 / 250% 100%;
  mix-blend-mode: overlay;
  animation: sweep 9s ease-in-out infinite;
}
@keyframes sweep {
  from { background-position: 120% 0; }
  to { background-position: -40% 0; }
}

.hero-words {
  display: grid;
  justify-items: center;
  gap: 1.3rem;
  max-inline-size: 60rem;
}
h1 {
  font-weight: 200;
  font-size: clamp(2.9rem, 10.5vw, 7rem);
  line-height: 1;
  text-wrap: balance;
  /* A whisper of colour at the edges, like light through a lens. */
  text-shadow: -0.018em 0 rgba(255, 60, 110, 0.32), 0.018em 0 rgba(60, 200, 255, 0.32);
}
h1 em, h2 em { display: block; color: #fff6dc; }
.lede { max-inline-size: 34ch; color: #d6d2c8; font-size: 1.125rem; }
.hint { font-size: 0.8125rem; font-weight: 400; letter-spacing: 0.16em; color: var(--dim); }

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-block-size: 3.25rem;
  padding: 0.5rem 2.2rem;
  border: 1.5px solid var(--ivory);
  border-radius: 999px;
  background: rgba(2, 2, 3, 0.4);
  font-weight: 400;
  letter-spacing: 0.04em;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}
.pill:hover { background: rgba(242, 239, 232, 0.14); }
.pill-main,
.pill[aria-pressed='true'] { background: var(--ivory); color: var(--black); font-weight: 600; }
.pill-main:hover,
.pill[aria-pressed='true']:hover { background: #fff; box-shadow: 0 0 34px rgba(255, 255, 255, 0.35); }

/* ---------- ( II. ) The playing ---------- */

.studio, .lessons {
  padding: 5rem var(--gutter) 3rem;
  border-top: 1px solid var(--line);
}
h2 {
  margin-top: 0.8rem;
  font-weight: 200;
  font-size: clamp(2.1rem, 6.5vw, 4.2rem);
  line-height: 1.04;
  text-wrap: balance;
}

.picks { display: grid; gap: 1.2rem; margin-top: 2.2rem; scroll-margin-top: 0.5rem; }
.modes { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.modes .pill { min-block-size: 2.9rem; padding: 0.4rem 1.2rem; font-size: 0.9375rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chips button {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  min-block-size: 2.75rem;
  padding: 0.35rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-weight: 400;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.chips button:hover { border-color: var(--ivory); }
.chips button[aria-pressed='true'] { background: var(--ivory); border-color: var(--ivory); color: var(--black); }
.chips b { font-weight: 600; color: var(--gold); white-space: nowrap; }
.chips button[aria-pressed='true'] b { color: #7a5600; }
.chips-small button { min-block-size: 2.4rem; font-size: 0.9375rem; }

.instrument {
  position: relative;
  /* When it is scrolled into view, it sits just under the demo ribbon. */
  scroll-margin-block: 4.2rem 6.5rem;
  max-inline-size: 54rem;
  margin: 2.2rem auto 0;
  padding: 0.9rem clamp(0.3rem, 2vw, 0.9rem) 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 1.4rem 1.4rem 0 0;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.09), transparent 30%),
    linear-gradient(#101014, #050506);
}
.coach-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  min-block-size: 3.2rem;
  padding: 0.2rem 0.4rem 0.6rem;
}
.coach { font-weight: 400; }
.progress { color: var(--dim); font-size: 0.875rem; white-space: nowrap; font-variant-numeric: tabular-nums; }

#fall {
  display: block;
  inline-size: 100%;
  block-size: clamp(7.5rem, 26vh, 18rem);
  border-radius: 0.7rem 0.7rem 0 0;
  background: linear-gradient(#030304, #0a0a0d);
}

.keys {
  position: relative;
  display: flex;
  block-size: clamp(9rem, 32vw, 14.5rem);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.key {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.15rem;
  padding: 0 0 0.5rem;
  border: 1px solid #050506;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.06s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.key.white {
  flex: 1 1 0;
  min-inline-size: 0;
  border-radius: 0 0 0.5rem 0.5rem;
  background: linear-gradient(#fffdf8, #ece7da 82%, #c9c2b1);
  box-shadow: inset 0 -0.5rem 0 rgba(0, 0, 0, 0.1), inset 2px 0 0 rgba(255, 255, 255, 0.7);
  color: #4c4840;
}
.key.black {
  position: absolute;
  top: 0;
  left: calc(var(--after) * 100% / var(--whites));
  z-index: 2;
  inline-size: calc(100% / var(--whites) * 0.62);
  block-size: 61%;
  translate: -50% 0;
  border-radius: 0 0 0.35rem 0.35rem;
  background: linear-gradient(100deg, #3a3a42, #0b0b0d 38%, #020203);
  box-shadow: inset 0 -0.45rem 0 rgba(255, 255, 255, 0.08), 0 4px 6px rgba(0, 0, 0, 0.55);
  color: #b9b6ad;
}
.key-name {
  font-size: clamp(0.6875rem, 2.4vw, 0.875rem);
  font-weight: 600;
  line-height: 1;
  padding-bottom: 0.3rem;
  border-bottom: 3px solid var(--paint);
}
.key-typed {
  font-family: var(--sans);
  font-size: 0.625rem;
  font-weight: 600;
  color: #6a655b;
}
.key.black .key-typed { color: #b9b6ad; }
@media (hover: none) {
  .key-typed, .typed-hint { display: none; }
}

/* The key the lesson is waiting for, and a key the playback is sounding. */
.key.is-next,
.key.is-lit {
  z-index: 3;
  box-shadow: 0 0 0 1px var(--paint), 0 0 34px 4px var(--paint), inset 0 -0.5rem 0 rgba(0, 0, 0, 0.12);
}
/* A lit white key stays under its black neighbours. */
.key.white.is-next,
.key.white.is-lit { z-index: 1; background: linear-gradient(#fffdf8, var(--paint)); color: #17140f; }
.key.black.is-next,
.key.black.is-lit { background: linear-gradient(#17171b, var(--paint)); color: #fff; }
.key.is-next { animation: breathe 1.3s ease-in-out infinite; }
@keyframes breathe {
  50% { box-shadow: 0 0 0 1px var(--paint), 0 0 14px 1px var(--paint), inset 0 -0.5rem 0 rgba(0, 0, 0, 0.12); }
}
.key.is-down { transform: translateY(3px); }
.key.white.is-down { background: linear-gradient(#f1ecdf, var(--paint)); box-shadow: inset 0 -0.2rem 0 rgba(0, 0, 0, 0.15); }
.key.black.is-down { background: linear-gradient(#0b0b0d, var(--paint)); }
.key.is-wrong { animation: wrong 0.3s ease; }
@keyframes wrong {
  25% { translate: -3px 0; }
  75% { translate: 3px 0; }
}
.key.black.is-wrong { animation-name: wrong-black; }
@keyframes wrong-black {
  25% { translate: calc(-50% - 3px) 0; }
  75% { translate: calc(-50% + 3px) 0; }
}

/* The polished floor throws the keys back, faintly. */
.floor {
  position: absolute;
  inset-inline: clamp(0.3rem, 2vw, 0.9rem);
  top: 100%;
  block-size: 6rem;
  background: repeating-linear-gradient(90deg, rgba(242, 239, 232, 0.2) 0 calc(10% - 2px), transparent 0 10%);
  -webkit-mask-image: linear-gradient(rgba(0, 0, 0, 0.75), transparent 85%);
  mask-image: linear-gradient(rgba(0, 0, 0, 0.75), transparent 85%);
  filter: blur(1.5px);
  pointer-events: none;
}

.stars {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 6.5rem;
  font-size: 2.6rem;
  line-height: 1;
  color: rgba(242, 239, 232, 0.18);
}
.stars[hidden] { display: none; }
.stars .is-on { color: var(--gold); text-shadow: 0 0 26px rgba(244, 210, 122, 0.8); animation: pop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) backwards; }
.stars .is-on:nth-child(2) { animation-delay: 0.15s; }
.stars .is-on:nth-child(3) { animation-delay: 0.3s; }
@keyframes pop {
  from { transform: scale(0.2) rotate(-40deg); opacity: 0; }
}
.after { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; margin-top: 1.4rem; }
.after[hidden] { display: none; }
.stars[hidden] + .after[hidden] + .sr-only + .extras { margin-top: 7rem; }

.extras {
  display: grid;
  justify-items: center;
  gap: 0.8rem;
  margin-top: 2.5rem;
  text-align: center;
}
.typed-hint { color: var(--dim); font-size: 0.9375rem; }
.fallback { padding: 2rem; text-align: center; }

/* ---------- ( III. ) The beginning ---------- */

.form { display: grid; gap: 0; margin-top: 2rem; max-inline-size: 48rem; }
.step { padding: 1.4rem 0; border-top: 1px solid var(--line); }
.step h3 { margin-bottom: 0.8rem; font-size: 1.25rem; font-weight: 300; }
.field { display: grid; gap: 0.5rem; padding: 1.4rem 0; border-top: 1px solid var(--line); }
.field span { font-size: 1.25rem; }
.field input {
  max-inline-size: 22rem;
  min-block-size: 3rem;
  padding: 0.4rem 0;
  border: 0;
  border-bottom: 1.5px solid var(--ivory);
  border-radius: 0;
  background: transparent;
  font-size: 1.25rem;
}

.summary {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.6rem 1rem;
  margin-inline: calc(var(--gutter) * -1);
  padding: 0.9rem var(--gutter) 1rem;
  border-top: 1px solid var(--ivory);
  background: rgba(2, 2, 3, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.summary-line { font-weight: 400; }
.total { font-weight: 200; font-size: 2.4rem; line-height: 1; }
.summary .pill { grid-column: 1 / -1; justify-self: start; }

/* ---------- Facts and footer ---------- */

.facts { display: grid; padding: 0 var(--gutter); border-top: 1px solid var(--line); }
.facts article { padding: 2.2rem 0; border-bottom: 1px solid var(--line); }
.facts h2 { margin: 0.6rem 0 0.5rem; font-size: 1.7rem; font-weight: 300; line-height: 1.15; }
.facts article > p:last-child { color: #c9c5bb; max-inline-size: 34ch; }

.foot {
  display: grid;
  gap: 1.6rem;
  justify-items: center;
  padding: 5rem var(--gutter) 5.5rem;
  text-align: center;
}
.foot p { font-weight: 200; font-size: clamp(1.7rem, 4.5vw, 2.7rem); line-height: 1.12; max-inline-size: 22ch; text-wrap: balance; }

/* ---------- Sheet ---------- */

dialog {
  inline-size: min(31rem, calc(100vw - 2rem));
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: 1.4rem;
  background: #0c0c0f;
  color: var(--ivory);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.78); }
dialog h2 { margin: 0; font-size: 1.7rem; font-weight: 300; line-height: 1.2; }
.bubble {
  margin: 1.25rem 0;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: #16161b;
  font-weight: 400;
  white-space: pre-line;
  text-align: start;
  overflow-wrap: anywhere;
}
.note { margin-bottom: 1.5rem; color: #c9c5bb; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

@media (min-width: 48rem) {
  .picks { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .summary { grid-template-columns: minmax(0, 1fr) auto auto; margin-inline: 0; padding-inline: 0; }
  .summary .pill { grid-column: auto; }
  .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .facts article { padding-block: 3rem; padding-inline: 0 2rem; border-bottom: 0; }
  .facts article + article { padding-inline-start: 2rem; border-inline-start: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .beams i, .road-keys::after, .key.is-next, .key.is-wrong, .stars .is-on { animation: none; }
  .key, .pill, .chips button { transition: none; }
  .key.is-down { transform: none; }
}
