/* The listening study. Calm and neutral on purpose: scales never use red or green, so the
   look cannot nudge a rating. Light and dark themes; motion only when the device allows it. */
:root {
  --bg: #f4f2ee; --bg-2: #ebe7f7; --card: #ffffff; --text: #1c1b29; --muted: #5f5d6e;
  --line: #dedbe8; --accent: #3d3a8c; --accent-2: #6a63d4; --accent-soft: #ecebfa;
  --on-accent: #ffffff; --focus: #e8a400; --error-bg: #fdecea; --error: #8a1c12;
  --shadow: 0 1px 2px rgb(28 27 41 / 6%), 0 8px 24px rgb(28 27 41 / 7%);
  --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14131c; --bg-2: #1d1a33; --card: #1f1e2b; --text: #ecebf4; --muted: #a9a7bb;
    --line: #34324a; --accent: #a7a1ff; --accent-2: #7f77f0; --accent-soft: #2a2747;
    --on-accent: #14131c; --error-bg: #3b1714; --error: #ffb4a9;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 10px 30px rgb(0 0 0 / 35%);
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; color: var(--text); font: 18px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 500px at 85% -10%, var(--bg-2), transparent 70%), var(--bg);
  background-attachment: fixed; min-height: 100vh;
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 8px; }

/* ---- header and journey ---- */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 20px;
  padding: 12px 20px; background: color-mix(in srgb, var(--card) 85%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 650; }
.journey { display: flex; gap: 6px; list-style: none; margin: 0 0 0 auto; padding: 0; }
.journey li { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .85rem; }
.journey li + li::before { content: ""; width: 22px; height: 2px; background: var(--line); border-radius: 2px; margin-right: 2px; }
.journey .dot {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--line); font-size: .78rem; font-weight: 700; background: var(--card);
}
.journey li.done { color: var(--text); }
.journey li.done .dot { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.journey li.done + li::before, .journey li.now::before { background: var(--accent); }
.journey li.now { color: var(--text); font-weight: 650; }
.journey li.now .dot { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

/* ---- page ---- */
main { max-width: 760px; margin: 0 auto; padding: 28px 20px 96px; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.2; letter-spacing: -.01em; margin: .2em 0 .4em; }
h2 { font-size: 1.25rem; margin: 2rem 0 .6rem; }
h3 { font-size: 1.02rem; margin: 1.4rem 0 .3rem; }
.eyebrow { margin: 0; color: var(--accent); font-weight: 700; font-size: .82rem; letter-spacing: .08em; text-transform: uppercase; }
.lede { font-size: 1.08rem; color: var(--muted); margin-top: 0; }
.muted, .hint { color: var(--muted); font-size: .92rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; margin: 24px 0; box-shadow: var(--shadow); }
.card h2:first-child { margin-top: 0; }
.letter ul { padding-left: 1.2em; }
.callout { background: var(--accent-soft); border-radius: 12px; padding: 12px 16px; }
.error { background: var(--error-bg); color: var(--error); padding: 12px 16px; border-radius: 12px; }
.page-note { max-width: 760px; margin: 0 auto 20px; }
.stack > * + * { margin-top: 18px; }

/* ---- welcome ---- */
.hero { display: grid; grid-template-columns: 180px 1fr; gap: 28px; align-items: center; margin: 12px 0 8px; }
.hero-art svg { width: 100%; height: auto; }
.hero-art .halo { fill: var(--accent-soft); }
.hero-art .band { stroke: var(--accent); }
.hero-art .cup { fill: var(--accent); }
.hero-art .waves { stroke: var(--accent-2); }
.facts { display: flex; flex-wrap: wrap; gap: 10px; list-style: none; padding: 0; margin: 14px 0 0; }
.facts li { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: .92rem; color: var(--muted); }
.facts strong { color: var(--text); }

/* ---- form controls ---- */
fieldset { border: 0; margin: 0; padding: 18px 20px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
legend { float: left; width: 100%; padding: 0; margin-bottom: 12px; font-weight: 650; font-size: 1.02rem; }
legend + * { clear: both; }
input[type=radio], input[type=checkbox] { accent-color: var(--accent); }
.pill input, .option input { position: absolute; opacity: 0; pointer-events: none; }
.pills { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.pill-face {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 76px;
  padding: 8px 6px; text-align: center; border: 2px solid var(--line); border-radius: 14px; cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}
.pill-face strong { font-size: 1.25rem; line-height: 1; }
.pill-face small { font-size: .75rem; color: var(--muted); line-height: 1.2; }
.pill:hover .pill-face, .option:hover .option-face { border-color: var(--accent-2); }
.pill input:checked + .pill-face { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.pill input:checked + .pill-face small { color: var(--text); }
.pill input:focus-visible + .pill-face, .option input:focus-visible + .option-face { outline: 3px solid var(--focus); outline-offset: 2px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.option-face {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 10px 14px; cursor: pointer;
  border: 2px solid var(--line); border-radius: 14px; transition: border-color .15s, background .15s;
}
.option-face::before { content: ""; flex: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); transition: border .15s; }
.option input:checked + .option-face { border-color: var(--accent); background: var(--accent-soft); }
.option input:checked + .option-face::before { border: 6px solid var(--accent); }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; cursor: pointer; }
.check input { width: 1.25em; height: 1.25em; margin-top: .2em; flex: none; }
.field { display: block; font-weight: 650; }
.field input, .field textarea {
  display: block; width: 100%; margin-top: 8px; font: inherit; font-weight: 400; padding: 12px 14px;
  border: 2px solid var(--line); border-radius: 12px; background: var(--card); color: var(--text);
}
.field input:focus, .field textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 4px var(--accent-soft); }
button { font: inherit; }
.primary {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 8px; padding: 14px 26px; border: 0; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--on-accent); font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent); transition: transform .15s, box-shadow .15s;
}
.primary:hover { transform: translateY(-1px); box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 40%, transparent); }
.start h2 { margin-top: 0; }

/* ---- player ---- */
.player {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 22px; align-items: center; margin: 22px 0 28px;
  padding: 22px; border-radius: 24px; color: #fff;
  background: radial-gradient(120% 140% at 0% 0%, #6a63d4 0%, #3d3a8c 55%, #24215c 100%);
  box-shadow: 0 14px 40px rgb(61 58 140 / 35%);
}
.play {
  position: relative; display: grid; place-items: center; width: 108px; height: 108px; border: 0; padding: 0;
  border-radius: 50%; background: rgb(255 255 255 / 12%); color: #fff; cursor: pointer; transition: transform .15s, background .15s;
}
.play:hover:not(:disabled) { transform: scale(1.04); background: rgb(255 255 255 / 18%); }
.play:disabled { cursor: default; }
.ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; }
.ring-track { stroke: rgb(255 255 255 / 20%); }
.ring-fill { stroke: #fff; stroke-linecap: round; transition: stroke-dashoffset .25s linear; }
.icon { position: relative; width: 38px; height: 38px; fill: #fff; stroke: #fff; }
.icon[hidden] { display: none; } /* the HTML hidden rule does not reach SVG elements */
.icon-play { margin-left: 4px; }
.player-body { min-width: 0; }
.player-label { margin: 0; font-weight: 700; font-size: 1.05rem; }
.bars { display: flex; align-items: center; gap: 4px; height: 38px; margin: 6px 0 2px; }
/* A waveform at rest (bar heights vary by position); it pulses while the clip plays. */
.bars span { flex: 1; max-width: 6px; height: 34%; border-radius: 3px; background: rgb(255 255 255 / 50%); transform-origin: center; }
.bars span:nth-child(3n+1) { height: 58%; } .bars span:nth-child(4n+2) { height: 82%; }
.bars span:nth-child(5n) { height: 44%; } .bars span:nth-child(7n+3) { height: 100%; } .bars span:nth-child(6n+5) { height: 24%; }
.player.is-playing .bars span { background: rgb(255 255 255 / 90%); animation: eq .8s ease-in-out infinite alternate; }
.bars span:nth-child(2n) { animation-delay: -.3s; } .bars span:nth-child(3n) { animation-delay: -.55s; }
.bars span:nth-child(5n+1) { animation-duration: 1.05s; } .bars span:nth-child(7n) { animation-duration: .65s; }
@keyframes eq { from { transform: scaleY(.3); } to { transform: scaleY(1); } }
.player.is-done .bars span { background: rgb(255 255 255 / 60%); }
.time { margin: 0; font-variant-numeric: tabular-nums; font-size: .95rem; }
.time .of { opacity: .7; }
.status { margin: 2px 0 0; font-size: .92rem; opacity: .9; }
.skip { grid-column: 1 / -1; justify-self: end; font-size: .8rem; color: rgb(255 255 255 / 75%); }
.reveal:not([hidden]) { animation: rise .35s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- finish ---- */
.finish { text-align: center; padding-top: 30px; }
.tick { width: 96px; height: 96px; }
.tick-ring { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 4; stroke-dasharray: 100; animation: draw 0.8s ease-out both; }
.tick-mark { fill: none; stroke: var(--accent); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 100; animation: draw .5s .6s ease-out both; }
@keyframes draw { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }

/* ---- admin ---- */
main:has(.admin) { max-width: 1120px; }
.admin a { color: var(--accent); }
table { width: 100%; border-collapse: collapse; margin: 12px 0 22px; font-size: .95rem; background: var(--card); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 650; background: var(--accent-soft); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 18px 0; }
.tiles div { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; color: var(--muted); box-shadow: var(--shadow); }
.tiles span { display: block; font-size: 1.8rem; font-weight: 750; color: var(--text); }
.findings li { margin-bottom: 8px; }
code { font-size: .9em; }

/* ---- small screens and reduced motion ---- */
@media (max-width: 720px) {
  .journey .name { display: none; }
  .journey li + li::before { width: 12px; }
  .brand span { display: none; }
}
@media (max-width: 560px) {
  body { font-size: 17px; }
  main { padding: 20px 16px 80px; }
  .hero { grid-template-columns: 1fr; gap: 8px; }
  .hero-art { max-width: 150px; }
  .pills { grid-template-columns: 1fr; }
  .pill-face { flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 52px; padding: 10px 14px; }
  .pill-face small { font-size: .9rem; }
  .player { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .bars { justify-content: center; }
  .skip { justify-self: center; }
  .card { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .player.is-playing .bars span { transform: none; }
}
