/* ============================================
   ARCHIVO SONORO — Theme & Layout
   The one player component used across the whole site
   (home, /archivo-sonoro/, all landing pages).

   Inherits from style/style.css (already @imports
   variables.css, reset.css, typography.css, cards.css,
   responsive.css, utilities.css). Reuses as-is, unmodified:
     --bg-*, --surface-*, --text-*, --accent-primary*,
     --joia-radius, --joia-shadow-*, --spacing-*
     .btn-primary / .btn-accent / .btn-secondary
     .container-main / .container-narrow
     .contacto-fullscreen / .contacto-title / .contacto-desc /
       .contacto-action / .contacto-meta / .lang-block (contact screen)
     .lang-selector (language toggle, driven by inline page scripts)

   New tokens only where the system had nothing to reuse —
   all prefixed --demos- per project convention.

   PLAYER-SPEC.md v2: five contrast levels, no sticky bar
   (top progress line + ring on the active row instead), no
   language filter (language moved into the technical strip),
   waveform only on the open row, cover lightbox.
   ============================================ */

:root {
  --demos-tally: #E9A13B;                 /* status-light amber — "copied" confirmation flash */
  --demos-on-air: #2ECC71;                /* status-light green — Bypass / On Air indicator */
  --demos-ficha-border: rgba(255, 255, 255, 0.08);
  --demos-mono: 'SF Mono', Consolas, Monaco, 'Courier New', monospace;

  /* Five-level contrast ladder — same ivory as --text-primary at five
     fixed opacities, per PLAYER-SPEC.md §4.1. Amber is reserved for
     exactly one thing on screen at a time: the row that's playing. */
  --demos-level-1: var(--text-primary);        /* 100% — ficha title */
  --demos-level-2: rgba(242, 239, 234, 0.72);  /* description */
  --demos-level-3: rgba(242, 239, 234, 0.52);  /* category, duration, tags */
  --demos-level-4: rgba(242, 239, 234, 0.38);  /* ref number, technical strip */
  --demos-level-5: rgba(242, 239, 234, 0.10);  /* row separators */
  --demos-accent: var(--accent-primary);
  --demos-waveform-idle: rgba(242, 239, 234, 0.16);
  --demos-waveform-fill: var(--accent-primary);
}

html, body.archivo-page {
  min-height: 100%;
  background: var(--bg-0);
}

body.archivo-page {
  color: var(--text-primary);
  background:
    radial-gradient(circle at 85% 0%, rgba(212, 174, 89, 0.06), transparent 30%),
    linear-gradient(180deg, #070707 0%, var(--bg-0) 40%, #030303 100%);
}

/* ============================================
   TOP PROGRESS LINE — replaces the sticky bar.
   A 2px amber line pinned to the viewport top,
   present only while something is playing.
   ============================================ */
.archivo-top-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: var(--demos-accent);
  z-index: 60;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.archivo-top-progress.is-visible {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .archivo-top-progress {
    transition: none;
  }
}

/* ============================================
   NAV
   ============================================ */
.archivo-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px clamp(22px, 5vw, 72px);
  pointer-events: none;
  background: linear-gradient(180deg, rgba(5, 5, 5, 0.82) 0%, rgba(5, 5, 5, 0.5) 70%, transparent 100%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.archivo-nav a,
.archivo-nav .lang-selector {
  pointer-events: auto;
}

.archivo-brand {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 780;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.archivo-page .lang-selector {
  position: static !important;
}

/* ============================================
   OPENING SCREEN
   ============================================ */
.archivo-hero {
  position: relative;
  min-height: min(100svh, 780px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--spacing-md);
  padding: clamp(128px, 16vh, 176px) clamp(24px, 7vw, 112px) clamp(64px, 9vh, 110px);
}

.archivo-eyebrow {
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* Home page only: "Archivo Sonoro" as a real section title (matching
   the other h2s on the page, e.g. "Cómo trabajo"), not the small eyebrow
   tag used on the standalone /archivo-sonoro/ page above its own H1. */
.archivo-section-title {
  margin: 0 0 clamp(24px, 3vw, 40px);
}

.content-section:has(.archivo-section-title) {
  padding-top: clamp(96px, 12vw, 160px) !important;
}

.archivo-hero h1 {
  max-width: 18ch;
  margin: 0;
}

.archivo-hero-sub {
  max-width: 52ch;
  color: var(--text-secondary);
  font-size: clamp(16px, 1.6vw, 19px);
  line-height: var(--line-height-relaxed);
}

.archivo-hero-actions {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

.archivo-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.archivo-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-disabled);
  box-shadow: none;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.archivo-status.is-on .archivo-status-dot {
  background: var(--demos-on-air);
  box-shadow: 0 0 10px 2px rgba(46, 204, 113, 0.55);
}

.archivo-status.is-on {
  color: var(--demos-on-air);
}

/* ============================================
   FILTERS — category only. Language moved into
   the technical strip (PLAYER-SPEC.md §3.1).
   ============================================ */
.archivo-filters {
  padding: 0 clamp(24px, 7vw, 112px) var(--spacing-md);
}

.archivo-filters--flush {
  padding-left: 0;
  padding-right: 0;
}

/* The chips live in .archivo-filter-group (populated by js/archivo-sonoro.js),
   one level inside .archivo-filters — the flex/wrap/gap belongs here so it
   actually governs the chips instead of a single-child wrapper. */
.archivo-filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.archivo-filter-chip {
  appearance: none;
  border: 1px solid var(--demos-ficha-border);
  background: var(--surface-1);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: var(--joia-transition);
}

.archivo-filter-chip:hover,
.archivo-filter-chip:focus-visible {
  border-color: var(--accent-primary-light);
  color: var(--text-primary);
}

.archivo-filter-chip.is-active {
  background: var(--accent-primary-light);
  border-color: var(--accent-primary-medium);
  color: var(--demos-accent);
}

.archivo-filter-chip .count {
  color: var(--text-tertiary);
  margin-left: 4px;
}

.archivo-filter-chip.is-active .count {
  color: var(--demos-accent);
}

/* Mobile: horizontal-scrolling strip, no visible scrollbar, a fade at
   the trailing edge to signal there's more. */
@media (max-width: 640px) {
  .archivo-filter-group {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-mask-image: linear-gradient(to right, black 88%, transparent 100%);
    mask-image: linear-gradient(to right, black 88%, transparent 100%);
  }

  .archivo-filter-group::-webkit-scrollbar {
    display: none;
  }

  .archivo-filter-chip {
    flex-shrink: 0;
  }
}

/* ============================================
   ARCHIVE LIST
   ============================================ */
.archivo-list-wrap {
  padding: 0 clamp(24px, 7vw, 112px) var(--spacing-xxl);
}

.archivo-list-wrap--flush {
  padding-left: 0;
  padding-right: 0;
}

/* Table header — turns a stack of cards into a consultable archive */
.archivo-list-header {
  display: grid;
  grid-template-columns: 40px 1fr 140px 64px;
  align-items: center;
  gap: clamp(14px, 2vw, 28px);
  padding: 0 4px 10px;
  border-bottom: 1px solid var(--demos-level-5);
  font-family: var(--demos-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--demos-level-4);
}

.archivo-list-header span:last-child {
  text-align: right;
}

.archivo-list {
  display: flex;
  flex-direction: column;
}

/* Skeleton rows shown while the manifest script loads — fixed height so
   nothing jumps when real rows replace them. */
.archivo-skeleton-row {
  height: 72px;
  border-bottom: 1px solid var(--demos-level-5);
  position: relative;
  overflow: hidden;
}

.archivo-skeleton-row::after {
  content: "";
  position: absolute;
  inset: 18px 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 100%);
  background-size: 200% 100%;
  animation: archivo-skeleton-sweep 1.4s ease-in-out infinite;
}

@keyframes archivo-skeleton-sweep {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .archivo-skeleton-row::after {
    animation: none;
  }
}

.archivo-ficha {
  border-bottom: 1px solid var(--demos-level-5);
}

/* ---- Closed row ---- */
.archivo-ficha-row {
  display: grid;
  grid-template-columns: 40px 1fr 140px 64px;
  align-items: center;
  gap: clamp(14px, 2vw, 28px);
  width: 100%;
  min-height: 72px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  color: inherit;
  padding: 10px 4px;
  transition: background-color 0.12s ease;
}

.archivo-ficha-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.archivo-ficha-row:focus-visible {
  outline: 2px solid var(--demos-accent);
  outline-offset: -2px;
}

.archivo-ficha-play {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--demos-ficha-border);
  background: var(--surface-1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  transition: var(--joia-transition);
}

.archivo-ficha-row:hover .archivo-ficha-play {
  border-color: var(--accent-primary-medium);
  color: var(--demos-level-1);
}

/* The one place amber shows besides the top progress line: a ring
   traced around the play button of whichever row is currently playing,
   so scrolling back to it reads at a glance. */
.archivo-ficha.is-playing .archivo-ficha-play {
  border-color: transparent;
}

.archivo-ficha.is-playing .archivo-ficha-play::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  background: conic-gradient(var(--demos-accent) calc(var(--archivo-progress, 0) * 1%), var(--demos-ficha-border) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
}

.archivo-ficha-play .icon {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 6px 0 6px 9px;
  border-color: transparent transparent transparent var(--demos-level-3);
  margin-left: 2px;
  position: relative;
  z-index: 1;
  transition: border-color 0.12s ease;
}

.archivo-ficha-row:hover .archivo-ficha-play .icon,
.archivo-ficha.is-open .archivo-ficha-play .icon {
  border-color: transparent transparent transparent var(--demos-level-1);
}

.archivo-ficha.is-playing .archivo-ficha-play .icon {
  width: 9px;
  height: 11px;
  border-style: none;
  background:
    linear-gradient(to right, var(--demos-level-1) 3px, transparent 3px, transparent 6px, var(--demos-level-1) 6px);
  margin-left: 0;
}

.archivo-ficha-title {
  font-size: clamp(16px, 1.6vw, 18px);
  font-weight: 600;
  color: var(--demos-level-1);
  margin: 0;
  white-space: normal;
  line-height: 1.25;
}

.archivo-ficha-category {
  font-family: var(--demos-mono);
  font-size: 12px;
  color: var(--demos-level-3);
  white-space: nowrap;
}

.archivo-ficha-duration {
  font-family: var(--demos-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--demos-level-3);
  white-space: nowrap;
  text-align: right;
}

/* ---- Open state ---- */
.archivo-ficha-detail {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--spacing-md);
  align-items: start;
  padding: 0 4px var(--spacing-md);
  height: 0;
  overflow: hidden;
  opacity: 0;
  transition: height 0.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}

.archivo-ficha.is-open .archivo-ficha-detail {
  opacity: 1;
  /* height is set inline in px by JS (measured), so the transition has
     a real value to animate to/from — see js/archivo-sonoro.js */
}

@media (prefers-reduced-motion: reduce) {
  .archivo-ficha-detail {
    transition: none;
  }
}

/* ---- Cover thumbnail ---- */
.archivo-cover-wrap {
  position: relative;
  width: 200px;
  height: 200px;
  border-radius: var(--joia-radius);
  overflow: hidden;
  border: 1px solid var(--demos-ficha-border);
  cursor: zoom-in;
  flex-shrink: 0;
}

.archivo-cover-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.archivo-cover-expand {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(5, 5, 5, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.archivo-cover-wrap:hover .archivo-cover-expand,
.archivo-cover-wrap:focus-visible .archivo-cover-expand {
  opacity: 1;
}

.archivo-cover-expand svg {
  width: 14px;
  height: 14px;
  stroke: var(--demos-level-1);
}

.archivo-cover-wrap:focus-visible {
  outline: 2px solid var(--demos-accent);
  outline-offset: 2px;
}

/* No-cover placeholder — six of the thirteen demos have none; this is
   a normal state, not a broken image. */
.archivo-cover-wrap.is-empty {
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-1);
  color: var(--demos-level-5);
  font-family: var(--demos-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.archivo-detail-body {
  min-width: 0;
}

.archivo-ficha-notes {
  color: var(--demos-level-2);
  font-size: 15px;
  line-height: var(--line-height-relaxed);
  max-width: 62ch;
  margin: 0 0 10px;
}

/* ---- Waveform — only ever rendered inside the one open row ---- */
.archivo-waveform-wrap {
  position: relative;
  width: 100%;
  height: 48px;
  margin-bottom: 12px;
}

.archivo-waveform {
  width: 100%;
  height: 48px;
  display: block;
  cursor: pointer;
}

.archivo-waveform-time {
  position: absolute;
  top: -26px;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--demos-ficha-border);
  border-radius: 4px;
  padding: 2px 7px;
  font-family: var(--demos-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--demos-level-1);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  white-space: nowrap;
  z-index: 2;
}

.archivo-waveform-time.is-visible {
  opacity: 1;
}

.archivo-ficha-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.archivo-ficha-tags span {
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--demos-level-3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 3px 8px;
}

.archivo-technical {
  font-family: var(--demos-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--demos-level-4);
  white-space: nowrap;
}

.archivo-download {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--demos-accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.archivo-download:hover,
.archivo-download:focus-visible {
  border-bottom-color: var(--demos-accent);
}

/* ============================================
   LIGHTBOX
   ============================================ */
.archivo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 3, 3, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease;
}

.archivo-lightbox.is-open {
  opacity: 1;
  visibility: visible;
}

@media (prefers-reduced-motion: reduce) {
  .archivo-lightbox {
    transition: none;
  }
}

.archivo-lightbox img {
  max-width: min(90vw, 1200px);
  max-height: min(90vh, 1200px);
  width: auto;
  height: auto;
  border-radius: var(--joia-radius);
  cursor: zoom-out;
}

.archivo-lightbox-close {
  position: absolute;
  top: clamp(14px, 3vw, 28px);
  right: clamp(14px, 3vw, 28px);
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--demos-level-1);
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.archivo-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.12);
}

.archivo-lightbox-close:focus-visible,
.archivo-lightbox img:focus-visible {
  outline: 2px solid var(--demos-accent);
  outline-offset: 2px;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.archivo-empty {
  padding: var(--spacing-xl) 0;
  text-align: center;
  color: var(--text-secondary);
}

.archivo-empty button {
  margin-top: var(--spacing-sm);
}

/* ============================================
   CONTACT — reuses .contacto-* verbatim; only the
   copy-email affordance is new to this page.
   ============================================ */
.contacto-email-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.contacto-email {
  font-size: clamp(20px, 3vw, 30px);
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-primary-medium);
}

.contacto-email:hover,
.contacto-email:focus-visible {
  border-bottom-color: var(--accent-primary);
}

.archivo-copy-btn[data-copied="true"] {
  color: var(--demos-tally);
  border-color: var(--demos-tally);
}

.archivo-privacy-note {
  margin-top: var(--spacing-lg);
  font-size: 12px;
  color: var(--text-disabled);
  max-width: 52ch;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  /* Home-page only (the --flush variant): .container-main's mobile width
     formula (calc(100% - 44px)) adds a fixed side margin on top of its
     own padding, nearly doubling the gutter here versus the rest of the
     page and versus the standalone /archivo-sonoro/ page. Break out of
     that shrink and reapply the archive's own padding so both match. */
  .archivo-filters--flush,
  .archivo-list-wrap--flush {
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    padding-left: clamp(24px, 7vw, 112px);
    padding-right: clamp(24px, 7vw, 112px);
  }

  .archivo-list-header {
    display: none;
  }

  /* Explicit grid-column on every visible child: with .archivo-ficha-category
     display:none, relying on document-order auto-placement would shove the
     title into the play button's track instead of the freed-up space. */
  .archivo-ficha-row {
    grid-template-columns: 40px 1fr auto;
    min-height: 64px;
    gap: 12px;
  }

  .archivo-ficha-category {
    display: none;
  }

  .archivo-ficha-play {
    grid-column: 1;
  }

  .archivo-ficha-title {
    grid-column: 2;
  }

  .archivo-ficha-duration {
    grid-column: 3;
  }

  .archivo-ficha-detail {
    grid-template-columns: 1fr;
  }

  .archivo-cover-wrap {
    width: 100%;
    max-width: 420px;
    height: auto;
    aspect-ratio: 1 / 1;
  }

  .archivo-technical {
    white-space: normal;
    line-height: 1.6;
  }
}

@media (max-width: 480px) {
  .archivo-hero {
    padding-top: 108px;
  }
}

.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;
}
