/* ============================================================
   Audio Regenerate — project page
   Palette & layout follow Descript's brand academic template
   (Red & Maroon ramps), cf. descriptinc.github.io/ATS
   ============================================================ */

:root {
  /* Descript brand palette — Red & Maroon ramps */
  --rec-red:     #F73B3B; /* CTA */
  --rec-red-dk:  #B81B1E; /* CTA hover */
  --red-50:      #FFE8DB;
  --light-peach: #FFD6C5;
  --peach:       #FF8969;
  --canvas:      #FFF8F4; /* page section background */
  --edit-maroon: #651A39; /* primary accent */
  --maroon-900:  #390A1A;
  --neutral-50:  #F1EAED;
  --neutral-100: #E4DDE0;
  --neutral-200: #D1C7CB;
  --neutral-600: #715661;
  --screen-black:#110A0D;

  /* Semantic tokens (consumed by JS figures too) */
  --bg:          #ffffff;
  --bg-elev:     #ffffff;
  --bg-sunken:   var(--neutral-50);
  --ink:         var(--screen-black);
  --ink-soft:    var(--neutral-600);
  --ink-faint:   #9c8890;
  --line:        var(--neutral-100);
  --accent:      var(--edit-maroon);
  --accent-2:    var(--rec-red);
  --accent-soft: var(--light-peach);
  --edit:        var(--rec-red-dk);
  --edit-soft:   var(--light-peach);

  --maxw: 1100px;
  --maxw-narrow: 760px;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(57, 10, 26, .05), 0 10px 30px rgba(57, 10, 26, .07);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 18px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 32px; }
.narrow { max-width: var(--maxw-narrow); margin-left: auto; margin-right: auto; }
.container.narrow {
  max-width: var(--maxw);
}
.container.narrow > p,
.container.narrow > .pills,
.container.narrow > .bib {
  max-width: var(--maxw-narrow);
}
.container > p.narrow {
  margin-left: 0;
  margin-right: 0;
}

section { padding: 56px 0; border-bottom: 1px solid var(--line); }
section:last-of-type { border-bottom: none; }
#abstract > .container,
#samples > .container,
#impact > .container {
  text-align: left;
}

.edit-list { padding-left: 1.4em; margin: 0 0 16px; }
.edit-list li { color: var(--ink); margin-bottom: 14px; }
.edit-list li:last-child { margin-bottom: 0; }
.edit-list li::marker { color: var(--accent); font-weight: 600; }

h1, h2, h3 { color: var(--ink); font-weight: 600; letter-spacing: -.01em; }
h2 {
  font-size: 30px; margin: 0 0 24px; padding-bottom: 8px;
  border-bottom: 2px solid var(--accent); display: inline-block;
}
h3 { font-size: 22px; margin: 44px 0 16px; }
p { color: var(--ink); }
em { color: var(--accent); font-style: italic; }
strong { font-weight: 600; }

/* ---------- Buttons (Descript pills) ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; margin: 4px; border-radius: 999px;
  background: var(--rec-red); color: #fff; font-size: 16px; font-weight: 600;
  letter-spacing: .01em; border: 1px solid transparent; cursor: pointer;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--rec-red-dk); text-decoration: none; }
.btn svg { width: 18px; height: 18px; fill: currentColor; }
.btn--sm { padding: 8px 15px; font-size: 14px; }
.btn--dark { background: var(--screen-black); }
.btn--dark:hover { background: var(--maroon-900); }
.btn--ghost { background: transparent; color: var(--edit-maroon); border-color: var(--neutral-200); }
.btn--ghost:hover { background: var(--canvas); color: var(--edit-maroon); border-color: var(--edit-maroon); }

/* ---------- Header ---------- */
.site-header { background: var(--canvas); padding: 64px 0 44px; text-align: center; }
.eyebrow {
  font-family: var(--font-mono); font-size: 13px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--rec-red); margin: 0 0 14px;
}
.site-header h1 { font-size: clamp(42px, 7vw, 64px); line-height: 1.05; margin: 0 0 14px; }
.subtitle { font-size: 21px; color: var(--ink-soft); margin: 0 auto 20px; max-width: 900px; }
.authors { font-size: 19px; color: var(--ink-soft); margin: 0 0 6px; line-height: 1.5; }
.authors span { display: inline-block; margin: 0 8px; }
.affiliations { font-size: 16px; color: var(--edit-maroon); font-weight: 600; margin-bottom: 4px; }

/* ---------- Teaser ---------- */
.teaser { background: var(--canvas); text-align: center; padding-top: 8px; }
.teaser__h { border: none; display: block; font-size: 26px; margin: 0 0 12px; padding: 0; }
.teaser__h strong { font-weight: 700; }
.caption { max-width: 720px; margin: 0 auto 28px; color: var(--ink-soft); font-size: 17px; }
.viz {
  position: relative; max-width: 900px; margin: 0 auto 24px; background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  overflow: hidden;
}
#heroWave { display: block; width: 100%; height: 130px; }
.viz__label {
  position: absolute; right: 16px; top: 14px; font-size: 12px; color: var(--ink-faint);
  font-family: var(--font-mono); display: flex; align-items: center; gap: 7px;
}
.viz__label .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--rec-red); box-shadow: 0 0 0 4px var(--light-peach); }
.teaser__cta { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }

/* ---------- Pills ---------- */
.pills { list-style: none; display: flex; flex-wrap: wrap; gap: 9px; padding: 0; margin: 26px 0 0; }
.pills li {
  font-family: var(--font-mono); font-size: 12.5px; color: var(--edit-maroon);
  padding: 6px 13px; border: 1px solid var(--neutral-200); border-radius: 999px; background: var(--canvas);
}

/* ---------- Pipeline ---------- */
.pipeline {
  margin: 8px 0 8px; padding: 26px 18px; display: flex; align-items: flex-end;
  justify-content: space-between; gap: 6px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.pipeline__stage { flex: 1 1 0; min-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 10px 6px; }
.pipeline__icon { width: 100%; max-width: 120px; height: 56px; color: var(--edit-maroon); display: grid; place-items: center; }
.pipeline__cap { font-size: 13px; line-height: 1.3; color: var(--ink-soft); font-weight: 500; text-align: center; min-height: 2.6em; }
.pipeline__arrow { align-self: flex-end; margin-bottom: 44px; color: var(--neutral-200); font-size: 22px; }

/* The model block — latent frames + text in are processed here */
.pipeline__stage--model { gap: 6px; }
.pipeline__model {
  width: 100%; max-width: 120px; min-height: 56px; border-radius: 12px;
  background: var(--edit-maroon);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px;
  letter-spacing: .02em;
}

/* "Text in" — second input (alongside the latent frames) into the model */
.pipeline__textin {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  background: var(--canvas); border: 1px dashed var(--peach); border-radius: 8px;
  padding: 6px 11px; max-width: 140px;
}
.pipeline__textin-tag { font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--rec-red); }
.pipeline__textin-words { font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; }
.pipeline__down { color: var(--peach); font-size: 16px; line-height: 1; margin-bottom: 2px; }
.pl-wave { stroke-dasharray: 260; stroke-dashoffset: 260; animation: draw 2.4s ease forwards infinite; }
.pl-wave--out { animation-delay: 1.2s; }
@keyframes draw { 0%{stroke-dashoffset:260} 40%{stroke-dashoffset:0} 90%{stroke-dashoffset:0} 100%{stroke-dashoffset:0} }
/* edited samples in the output waveform: different colour + shape (diamonds) */
.pl-edit path { fill: var(--rec-red); animation: editPop 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.pl-edit path:nth-child(2) { animation-delay: .15s; }
.pl-edit path:nth-child(3) { animation-delay: .3s; }
.pl-edit path:nth-child(4) { animation-delay: .45s; }
@keyframes editPop { 0%,100%{ opacity:.55; transform: scale(.7); } 50%{ opacity:1; transform: scale(1.15); } }
.pipeline__cap small { color: var(--ink-faint); font-weight: 400; }

/* latent frames = a few discrete vertical bars (far fewer than audio samples) */
.pipeline__grid { display: flex; align-items: flex-end; justify-content: center; gap: 4px; width: 100%; max-width: 120px; height: 48px; }
.pipeline__grid i { display: block; flex: 0 0 auto; width: 10px; border-radius: 2px; background: color-mix(in srgb, var(--edit-maroon) 38%, transparent); transition: background .3s; }
.pipeline__grid--gen i.is-mask { background: var(--rec-red); animation: pulseMask 1.6s ease-in-out infinite; }
.pipeline__grid--gen i.is-filled { background: var(--rec-red-dk); }
@keyframes pulseMask { 0%,100%{opacity:.5} 50%{opacity:1} }

/* ---------- Two-column text + figure ---------- */
.cols { display: grid; grid-template-columns: 1.45fr 1fr; gap: 32px; align-items: stretch; }
.cols { text-align: left; }
.col-text { align-self: start; }
.col-text p { color: var(--ink-soft); }
.col-text strong { color: var(--ink); }
.col-fig { align-self: center; }

/* ---------- Paper callout ---------- */
.paper-callout {
  background: var(--canvas); border: 1px solid var(--neutral-200); border-left: 4px solid var(--rec-red);
  border-radius: var(--radius); padding: 22px;
  text-align: left;
  align-self: end;
}
.paper-callout__tag { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--rec-red); margin-bottom: 10px; }
.paper-callout__title { font-size: 17px; font-weight: 600; line-height: 1.35; margin: 0 0 8px; color: var(--ink); }
.paper-callout__authors { font-size: 13.5px; color: var(--ink-faint); margin: 0 0 16px; }

/* ---------- Denoise demo ---------- */
.denoise {
  margin: 0; background: var(--bg-sunken); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; display: flex; flex-direction: column;
}
.denoise__row { display: grid; gap: 3px; margin-bottom: 16px; grid-auto-rows: 1fr; min-height: 120px; }
.denoise__cell {
  border-radius: 2px; opacity: .2;
  background: var(--edit-maroon); will-change: opacity;
}
.denoise__cell.is-mask { background: var(--rec-red); }
.denoise__controls { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.denoise__step { font-family: var(--font-mono); font-size: 13px; color: var(--ink-faint); }
.denoise__cap { font-size: 13.5px; color: var(--ink-soft); margin: 0; }

/* ---------- Samples ---------- */
.samples { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; }
.sample {
  background: #fff;
  border: 1px solid color-mix(in srgb, var(--rec-red) 28%, var(--line));
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  transition: border-color .25s, box-shadow .25s;
  text-align: left;
}
.sample.is-revealed { border-color: color-mix(in srgb, var(--rec-red) 45%, var(--line)); }
.sample__top { display: flex; align-items: center; margin-bottom: 14px; }
.sample__title { font-weight: 600; font-size: 15px; color: var(--ink-soft); }
.sample__audio audio { width: 100%; max-width: 520px; height: 40px; margin-bottom: 14px; }
.sample__transcript {
  font-size: 20px; line-height: 1.7; color: var(--ink); padding: 4px 0;
}
.sample__transcript .seg { transition: background .35s ease, color .35s ease, box-shadow .35s ease; border-radius: 5px; }
.sample.is-revealed .sample__transcript .seg.edited {
  background: var(--light-peach); color: var(--rec-red-dk);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--rec-red) 35%, transparent); font-style: italic;
}
.sample__hint { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sample__hint-text { font-size: 13.5px; color: var(--ink-faint); }
.sample.is-revealed .sample__hint-text { color: var(--rec-red-dk); }
.reveal-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--neutral-200); background: #fff; color: var(--edit-maroon); font-weight: 600;
  font-size: 13.5px; cursor: pointer; transition: .2s;
}
.reveal-btn:hover { border-color: var(--rec-red); color: var(--rec-red-dk); }
.sample.is-revealed .reveal-btn { background: var(--light-peach); color: var(--rec-red-dk); border-color: transparent; }

/* ---------- Impact (flip cards) ---------- */
.impact { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 28px; }
.impact__item.flip-card {
  appearance: none; -webkit-appearance: none; background: transparent; border: 0; padding: 0;
  margin: 0; font: inherit; text-align: left; cursor: pointer; perspective: 1200px;
}
.flip-card__inner {
  position: relative; width: 100%; min-height: 240px; height: 100%;
  transition: transform .55s cubic-bezier(.4, .2, .2, 1); transform-style: preserve-3d;
}
.flip-card.is-flipped .flip-card__inner { transform: rotateY(180deg); }
.flip-card__front, .flip-card__back {
  position: absolute; inset: 0; -webkit-backface-visibility: hidden; backface-visibility: hidden;
  display: flex; flex-direction: column; padding: 24px;
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow);
}
.flip-card__front { align-items: flex-start; justify-content: center; }
.flip-card__back { transform: rotateY(180deg); justify-content: center; }
.impact__item.flip-card:hover .flip-card__front,
.impact__item.flip-card:hover .flip-card__back { border-color: color-mix(in srgb, var(--rec-red) 40%, var(--line)); }
.impact__item.flip-card:focus-visible { outline: 2px solid var(--rec-red); outline-offset: 3px; border-radius: var(--radius); }
.impact__big { font-size: 22px; font-weight: 700; margin-bottom: 10px; color: var(--edit-maroon); }
.flip-card__hint {
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .04em; color: var(--ink-faint);
  text-transform: uppercase;
}
.flip-card__back p { color: var(--ink-soft); font-size: 15px; margin: 0; }

/* ---------- BibTeX ---------- */
.bib { position: relative; }
.bib { text-align: left; }
.bib__copy {
  position: absolute; top: 12px; right: 12px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--neutral-200); background: #fff; color: var(--edit-maroon); font-size: 13px;
  font-weight: 600; cursor: pointer; transition: .2s;
}
.bib__copy:hover { border-color: var(--rec-red); color: var(--rec-red-dk); }
.bib__copy.copied { background: var(--light-peach); border-color: transparent; }
pre {
  background: var(--neutral-50); border: 1px solid var(--line); border-radius: 6px; padding: 18px;
  overflow-x: auto; font-size: 14px; line-height: 1.55; font-family: var(--font-mono); color: var(--ink);
}

/* ---------- Footer ---------- */
footer { padding: 36px 0; text-align: center; }
footer .footer-logo { margin-bottom: 14px; line-height: 0; }
footer .footer-logo img { display: inline-block; width: auto; height: 22px; max-height: 22px; max-width: 120px; opacity: .75; }
footer .muted { color: var(--ink-faint); font-size: 14px; }

/* ---------- Reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .7s ease, transform .7s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .cols { grid-template-columns: 1fr; gap: 24px; }
  .col-fig { align-self: start; }
  .paper-callout { align-self: start; }
  .impact { grid-template-columns: 1fr; }
  .flip-card__inner { min-height: 0; transform: none; }
  .flip-card.is-flipped .flip-card__inner { transform: none; }
  .flip-card__front, .flip-card__back {
    position: static; transform: none; -webkit-backface-visibility: visible; backface-visibility: visible;
  }
  .flip-card__back { display: none; }
  .impact__item.flip-card.is-flipped .flip-card__front { display: none; }
  .impact__item.flip-card.is-flipped .flip-card__back { display: flex; }
  .pipeline { flex-direction: column; align-items: center; }
  .pipeline__arrow { transform: rotate(90deg); align-self: center; margin-bottom: 0; }
  .pipeline__stage { min-width: 0; }
  .pipeline__cap { min-height: 0; }
}

/* Phones */
@media (max-width: 560px) {
  body { font-size: 16px; }
  .container { padding: 0 18px; }
  section { padding: 40px 0; }

  h2 { font-size: 24px; margin-bottom: 20px; }
  h3 { font-size: 19px; margin: 32px 0 14px; }

  .site-header { padding: 44px 0 32px; }
  .subtitle { font-size: 18px; }
  .authors { font-size: 16px; }
  .authors span { margin: 0 5px; }

  .teaser__h { font-size: 22px; }
  .caption { font-size: 16px; }
  #heroWave { height: 104px; }
  .viz { padding: 12px; }
  .viz__label { right: 10px; top: 10px; }
  .btn { padding: 10px 18px; font-size: 15px; }

  .pipeline { padding: 20px 12px; }

  .denoise { padding: 16px; }
  .denoise__row { min-height: 110px; }

  .sample { padding: 18px; }
  .sample__transcript { font-size: 17px; line-height: 1.6; }
  .sample__audio audio { max-width: 100%; }

  .flip-card__front, .flip-card__back { padding: 20px; }
  .impact__big { font-size: 20px; }

  pre { font-size: 12.5px; padding: 14px; }
  .bib__copy { top: 8px; right: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto; }
}
