/* ============================================================================
   Mateo Cámara — research demos. Design system.
   Light, technical, academic. One accent (pink-noise magenta).
   Type: Space Grotesk (display) · Inter (body) · Space Mono (data).
   ========================================================================== */

:root {
  /* color */
  --bg:        #fbfbfd;
  --surface:   #ffffff;
  --ink:       #15171c;
  --muted:     #5b6170;
  --faint:     #8b91a1;
  --hairline:  #e6e8ee;
  --hairline-2:#eef0f5;
  --accent:    #c81e78;   /* pink noise / pink trombone */
  --accent-ink:#a3175f;
  --accent-wash:#fdeef6;
  --focus:     #2563eb;

  /* type */
  --display: "Space Grotesk", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Space Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* scale */
  --step--1: clamp(.78rem, .76rem + .1vw, .84rem);
  --step-0:  clamp(1rem, .97rem + .14vw, 1.075rem);
  --step-1:  clamp(1.2rem, 1.12rem + .35vw, 1.45rem);
  --step-2:  clamp(1.5rem, 1.32rem + .8vw, 2rem);
  --step-3:  clamp(2rem, 1.6rem + 1.9vw, 3.1rem);

  /* layout */
  --measure: 46rem;     /* prose column */
  --wide: 70rem;        /* audio matrices, figures */
  --pad: clamp(1.1rem, .7rem + 2vw, 2rem);
  --radius: 10px;
  --radius-sm: 7px;

  --shadow: 0 1px 2px rgba(21,23,28,.04), 0 8px 24px -16px rgba(21,23,28,.22);
}

/* --- reset / base ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: var(--step-0);
  line-height: 1.65;
  font-feature-settings: "kern", "liga", "calt";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* --- layout shells --------------------------------------------------------- */
.page { padding: 0 var(--pad) 5rem; }
.wrap { max-width: var(--measure); margin-inline: auto; }
.wrap--wide { max-width: var(--wide); margin-inline: auto; }

/* --- site header ----------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .85rem var(--pad);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--hairline);
}
.site-header__brand {
  font-family: var(--display); font-weight: 700; font-size: 1.02rem;
  letter-spacing: -.01em; color: var(--ink); text-decoration: none;
}
.site-header__brand:hover { color: var(--accent); }
.site-header__nav { display: flex; gap: 1.25rem; font-family: var(--mono); font-size: var(--step--1); }
.site-header__nav a {
  color: var(--muted); text-decoration: none; text-transform: lowercase;
  letter-spacing: .02em;
}
.site-header__nav a:hover { color: var(--accent); }

/* --- hero ------------------------------------------------------------------ */
.hero { max-width: var(--measure); margin: clamp(2.5rem,6vw,4.5rem) auto 0; }
.hero__eyebrow {
  font-family: var(--mono); font-size: var(--step--1); letter-spacing: .12em;
  text-transform: uppercase; color: var(--accent); margin: 0 0 1rem;
}
.hero__title {
  font-family: var(--display); font-weight: 600; font-size: var(--step-3);
  line-height: 1.05; letter-spacing: -.025em; margin: 0;
  text-wrap: balance;
}
.hero__authors { font-size: var(--step-0); color: var(--ink); margin: 1.1rem 0 .15rem; }
.hero__authors .me { color: var(--accent-ink); font-weight: 500; }
.hero__affil { color: var(--muted); font-size: var(--step--1); display: block; margin-bottom: .9rem; }

.hero__badges { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.1rem 0 0; padding: 0; list-style: none; }
.badge {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--hairline); border-radius: 999px;
  padding: .26rem .7rem; background: var(--surface);
}
.badge--accent { color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 35%, var(--hairline)); background: var(--accent-wash); }

.hero__actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1.4rem 0 0; }
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  font-family: var(--mono); font-size: var(--step--1); letter-spacing: .01em;
  text-decoration: none; color: var(--ink);
  border: 1px solid var(--hairline); border-radius: var(--radius-sm);
  padding: .5rem .85rem; background: var(--surface);
  transition: border-color .15s ease, transform .15s ease, color .15s ease, background .15s ease;
}
.btn:hover { border-color: var(--ink); color: var(--ink); transform: translateY(-1px); }
.btn--primary {
  color: #fff; background: var(--accent); border-color: var(--accent);
}
.btn--primary:hover { color: #fff; background: var(--accent-ink); border-color: var(--accent-ink); }
.btn__arrow { transition: transform .15s ease; }
.btn:hover .btn__arrow { transform: translateX(2px); }

/* --- waveform signature ---------------------------------------------------- */
.waveform { display: block; width: 100%; height: 44px; margin: 1.9rem 0 0; overflow: hidden; }
.waveform rect { fill: var(--hairline); }
.waveform .lead { fill: var(--accent); }

/* --- abstract -------------------------------------------------------------- */
.abstract {
  max-width: var(--measure); margin: 2.4rem auto 0;
  border-left: 2px solid var(--accent); padding: .2rem 0 .2rem 1.3rem;
}
.abstract__label {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--faint); margin: 0 0 .5rem;
}
.abstract p { margin: 0; color: var(--muted); font-size: var(--step-0); }

/* --- project body (rendered markdown) -------------------------------------- */
.project-body { max-width: var(--measure); margin: 3rem auto 0; }
.project-body > section, .project-body > * { margin-inline: auto; }
.project-body h2 {
  font-family: var(--display); font-weight: 600; font-size: var(--step-2);
  letter-spacing: -.02em; margin: 2.8rem 0 1rem; line-height: 1.15;
}
.project-body h3 {
  font-family: var(--display); font-weight: 600; font-size: var(--step-1);
  letter-spacing: -.01em; margin: 2rem 0 .6rem;
}
.project-body p { margin: 0 0 1.05rem; }
.project-body ul, .project-body ol { margin: 0 0 1.1rem; padding-left: 1.3rem; }
.project-body li { margin: .3rem 0; }
.project-body li::marker { color: var(--accent); }
.project-body blockquote {
  margin: 1.4rem 0; padding: .1rem 0 .1rem 1.2rem;
  border-left: 2px solid var(--hairline); color: var(--muted);
}
.project-body hr { border: 0; border-top: 1px solid var(--hairline); margin: 2.6rem 0; }
.project-body a { font-weight: 500; }

/* code */
.project-body code {
  font-family: var(--mono); font-size: .88em;
  background: var(--hairline-2); padding: .12em .4em; border-radius: 4px;
}
.project-body pre {
  font-family: var(--mono); font-size: var(--step--1); line-height: 1.55;
  background: #14161b; color: #e7e9f0; border-radius: var(--radius);
  padding: 1rem 1.1rem; overflow-x: auto; margin: 0 0 1.3rem;
}
.project-body pre code { background: none; padding: 0; color: inherit; font-size: inherit; }

/* callout (e.g. the Spanish-film note) */
.note {
  max-width: var(--measure); margin: 1.6rem auto;
  background: var(--accent-wash); border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--hairline));
  border-radius: var(--radius); padding: 1rem 1.15rem;
  font-size: var(--step--1); color: var(--accent-ink);
}
.note strong { color: var(--accent-ink); }

/* --- audio matrix ---------------------------------------------------------- */
.audio-matrix { max-width: var(--wide); margin: 2.6rem auto 0; }
.audio-matrix__title {
  font-family: var(--display); font-weight: 600; font-size: var(--step-1);
  letter-spacing: -.01em; margin: 0 0 .25rem;
}
.audio-matrix__note { font-size: var(--step--1); color: var(--muted); margin: 0 0 1rem; }
.audio-matrix__scroll {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--hairline); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
.audio-matrix__table { border-collapse: collapse; width: 100%; }
.audio-matrix__table th, .audio-matrix__table td {
  padding: .7rem .8rem; text-align: left; vertical-align: middle;
  border-bottom: 1px solid var(--hairline-2);
}
.audio-matrix__table thead th {
  position: sticky; top: 0; z-index: 2;
  font-family: var(--mono); font-size: .72rem; font-weight: 400;
  letter-spacing: .03em; text-transform: uppercase; color: var(--muted);
  background: var(--surface); border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
.audio-matrix__table tbody tr:last-child th,
.audio-matrix__table tbody tr:last-child td { border-bottom: 0; }
.audio-matrix__table tbody tr:hover td,
.audio-matrix__table tbody tr:hover .audio-matrix__rowlabel { background: #fafbfe; }

.audio-matrix__corner { position: sticky; left: 0; z-index: 3; background: var(--surface) !important; }
.audio-matrix__rowlabel {
  position: sticky; left: 0; z-index: 1; background: var(--surface);
  font-family: var(--mono); font-size: var(--step--1); font-weight: 700;
  color: var(--ink); white-space: nowrap;
  border-right: 1px solid var(--hairline);
}
.audio-matrix__empty { color: var(--faint); }

/* native audio players, tidied into a consistent footprint */
.audio-matrix audio, .audio-player audio {
  width: 232px; height: 38px; display: block; border-radius: 999px;
}
.audio-matrix audio::-webkit-media-controls-panel,
.audio-player audio::-webkit-media-controls-panel { background: var(--hairline-2); }

/* standalone single player */
.audio-player { margin: 1.2rem auto; max-width: var(--measure); }
.audio-player figcaption, .figure figcaption {
  font-family: var(--mono); font-size: var(--step--1); color: var(--muted);
  margin-top: .55rem; line-height: 1.5;
}

/* --- figures --------------------------------------------------------------- */
.figure { max-width: var(--measure); margin: 2.2rem auto; }
.figure img {
  border: 1px solid var(--hairline); border-radius: var(--radius);
  background: var(--surface); margin-inline: auto;
}
.figure-grid {
  max-width: var(--wide); margin: 2.2rem auto;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem;
}
.figure-grid figure { margin: 0; }

/* --- youtube --------------------------------------------------------------- */
.embed { max-width: var(--measure); margin: 2.2rem auto; }
.embed__frame {
  position: relative; aspect-ratio: 16 / 9;
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--hairline);
  background: #000; box-shadow: var(--shadow);
}
.embed__frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* --- bibtex ---------------------------------------------------------------- */
.cite { max-width: var(--measure); margin: 1.2rem auto 0; }

/* --- footer ---------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--hairline);
  padding: 2.2rem var(--pad) 3rem; margin-top: 4rem;
}
.site-footer__inner {
  max-width: var(--wide); margin-inline: auto;
  display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: baseline; justify-content: space-between;
  font-size: var(--step--1); color: var(--muted);
}
.site-footer__links { display: flex; flex-wrap: wrap; gap: 1.25rem; font-family: var(--mono); }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

/* --- redirect landing card ------------------------------------------------- */
body.landing {
  min-height: 100svh; display: grid; place-items: center; padding: 2rem;
}
.landing__card {
  max-width: 32rem; width: 100%; text-align: center;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 16px; padding: clamp(1.8rem, 5vw, 3rem); box-shadow: var(--shadow);
}
.landing__card h1 {
  font-family: var(--display); font-weight: 600; font-size: var(--step-2);
  letter-spacing: -.02em; margin: 0 0 .4rem;
}
.landing__redirect { color: var(--muted); margin: 0 0 1.6rem; font-size: var(--step--1); }
.landing__list { list-style: none; padding: 0; margin: 0; text-align: left; }
.landing__list li { border-top: 1px solid var(--hairline-2); }
.landing__list li:first-child { border-top: 0; }
.landing__list a {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .7rem .2rem; text-decoration: none; color: var(--ink);
  font-family: var(--mono); font-size: var(--step--1);
}
.landing__list a:hover { color: var(--accent); }
.landing__list a::after { content: "→"; color: var(--faint); }
.landing__list a:hover::after { color: var(--accent); }

/* --- responsive ------------------------------------------------------------ */
@media (max-width: 560px) {
  .site-header__nav { gap: .9rem; }
  .audio-matrix audio { width: 190px; }
  .hero__actions .btn { flex: 1 1 auto; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
