/* ─────────────────────────────────────────────────────────
   Echo — Stimmen-Album
   A wall of voice tiles with hover-to-listen, click-to-jump.
   Mosaic grid, micro-drift on idle, equaliser bars on the
   hovered/playing tile. Owns: .echo-hero, .echo-wall, .echo-tile.
   ───────────────────────────────────────────────────────── */

:root {
  --echo-tile-size: 220px;
  --echo-shadow-offset: 8px;
  --echo-shadow-color: var(--fynbos-pomegranate, #c43f2c);
  --echo-tile-bg: var(--color-bg-warm, #efeadd);
  --echo-tile-border-radius: 14px;
}

/* ─── Hero ─── */
.echo-hero {
  padding: calc(var(--header-height, 72px) + var(--space-xl)) 0 var(--space-lg);
  background: var(--color-bg-main);
}
.echo-hero__eyebrow {
  display: inline-block;
  font-family: 'Syne', system-ui, sans-serif;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--color-accent, #c43f2c);
  margin-bottom: 14px;
}
.echo-hero__title {
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-weight: 700;
  font-size: clamp(3.4rem, 9vw, 6.4rem);
  line-height: 0.92;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-md);
  color: var(--color-text-primary);
}
.echo-hero__title-period { color: var(--echo-shadow-color); }
.echo-hero__sub {
  max-width: 60ch;
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-sm);
}
.echo-hero__hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Syne', system-ui, sans-serif;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-text-muted, var(--color-text-secondary));
  margin: 0;
}
.echo-hero__hint::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--echo-shadow-color);
  animation: echo-hint-pulse 2.4s ease-in-out infinite;
}
@keyframes echo-hint-pulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50%      { transform: scale(1.4); opacity: 1; }
}

/* ─── The wall ─── */
.echo-wall {
  padding: var(--space-md) 0 var(--space-2xl);
  background: var(--color-bg-main);
  /* Subtle dimming overlay when one tile is playing — JS toggles
     `.is-playing-any` on .echo-wall to focus attention on the
     active tile. */
}
.echo-wall .container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--echo-tile-size), 1fr));
  gap: var(--space-xl);
  padding-top: var(--space-md);
  padding-bottom: var(--space-md);
}

/* When any tile is playing, all NON-playing tiles dim down. The
   active tile is unaffected (and gets a slight lift). */
.echo-wall.is-playing-any .echo-tile:not(.is-playing) {
  opacity: 0.42;
  filter: saturate(0.6);
}

/* ─── A single tile ─── */
.echo-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: 0;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: opacity 280ms ease, filter 280ms ease, transform 280ms cubic-bezier(0.16, 1, 0.3, 1);
  /* Each tile drifts slowly on its own phase so the wall feels
     alive, not like a static contact sheet. JS sets --drift-offset
     per-tile so each one moves independently. */
  animation: echo-drift 9s ease-in-out infinite;
  animation-delay: var(--echo-drift-delay, 0s);
}

@keyframes echo-drift {
  0%, 100% { transform: translate3d(0, 0, 0); }
  25%      { transform: translate3d(2px, -3px, 0); }
  50%      { transform: translate3d(-2px, 1px, 0); }
  75%      { transform: translate3d(1px, 2px, 0); }
}

.echo-tile:hover,
.echo-tile:focus-visible {
  outline: none;
  transform: translate3d(0, -4px, 0) scale(1.02);
  animation-play-state: paused;
}
.echo-tile:focus-visible .echo-tile__cover {
  box-shadow:
    var(--echo-shadow-offset) var(--echo-shadow-offset) 0 var(--echo-shadow-color),
    0 0 0 3px var(--color-accent, #c43f2c);
}

/* The square portrait area with the signature pomegranate offset
   shadow that's the Schulcast brand mark. */
.echo-tile__cover {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--echo-tile-bg);
  border-radius: var(--echo-tile-border-radius);
  overflow: hidden;
  box-shadow: var(--echo-shadow-offset) var(--echo-shadow-offset) 0 var(--echo-shadow-color);
  transition: box-shadow 220ms ease;
}
.echo-tile:hover .echo-tile__cover,
.echo-tile.is-playing .echo-tile__cover {
  box-shadow: calc(var(--echo-shadow-offset) + 4px) calc(var(--echo-shadow-offset) + 4px) 0 var(--echo-shadow-color);
}
.echo-tile__cover img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 30%;
  display: block;
  transition: transform 480ms cubic-bezier(0.16, 1, 0.3, 1);
}
.echo-tile:hover .echo-tile__cover img,
.echo-tile.is-playing .echo-tile__cover img {
  transform: scale(1.04);
}

/* Animated equaliser fallback (covers without a portrait). Reuses
   the existing .freq-visual `.bar` bars from style.css. */
.echo-tile__freq {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 5px;
  width: 100%; height: 100%;
  padding: 28%;
  box-sizing: border-box;
}
.echo-tile__freq .bar {
  flex: 1;
  border-radius: 3px;
  min-height: 8%;
}

/* Explicit play overlay — sits centred on the cover. Clicking it
   plays the snippet without navigating; clicking elsewhere on the
   tile follows the data-echo-href to the episode page. The overlay
   exists because hover-to-play fails on cold visits in browsers
   that block autoplay until a user gesture has happened. */
.echo-tile__play {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--sc-cream, #f4efe2);
  color: var(--echo-shadow-color);
  cursor: pointer;
  pointer-events: auto;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 200ms ease, transform 200ms cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 8px 18px -4px rgba(0, 0, 0, 0.4);
  z-index: 3;
}
.echo-tile__play svg { padding-left: 3px; }
.echo-tile:hover .echo-tile__play,
.echo-tile:focus-visible .echo-tile__play,
.echo-tile__play:focus-visible {
  opacity: 1;
  transform: scale(1);
}
/* When the tile is actively playing, swap to a stop-style indicator
   inside the overlay (we just leave it at full opacity so the eq
   bars at the corner do the talking). */
.echo-tile.is-playing .echo-tile__play {
  opacity: 1;
  transform: scale(1);
  background: var(--echo-shadow-color);
  color: var(--sc-cream, #f4efe2);
}
.echo-tile__play:hover {
  transform: scale(1.08);
}
@media (prefers-reduced-motion: reduce) {
  .echo-tile__play { transition: opacity 120ms linear; }
}

/* Equaliser bars overlay shown when the tile is playing — sits in
   the bottom-left corner of the cover, made of 4 thin pomegranate
   bars that animate to fake an audio meter. */
.echo-tile__eq {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  width: 28px;
  height: 28px;
  padding: 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 220ms ease, transform 220ms ease;
  pointer-events: none;
  z-index: 2;
}
.echo-tile__eq i {
  width: 3px;
  border-radius: 2px;
  background: var(--echo-shadow-color);
  height: 30%;
}
.echo-tile.is-playing .echo-tile__eq {
  opacity: 1;
  transform: translateY(0);
}
.echo-tile.is-playing .echo-tile__eq i {
  animation: echo-eq-bounce 0.9s ease-in-out infinite;
}
.echo-tile.is-playing .echo-tile__eq i:nth-child(1) { animation-delay: 0s;    }
.echo-tile.is-playing .echo-tile__eq i:nth-child(2) { animation-delay: 0.12s; }
.echo-tile.is-playing .echo-tile__eq i:nth-child(3) { animation-delay: 0.06s; }
.echo-tile.is-playing .echo-tile__eq i:nth-child(4) { animation-delay: 0.18s; }
@keyframes echo-eq-bounce {
  0%, 100% { height: 30%; }
  50%      { height: 100%; }
}

/* Caption block beneath the cover */
.echo-tile__caption {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 4px;
}
.echo-tile__ep {
  font-family: 'Syne', system-ui, sans-serif;
  font-weight: 800;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--color-accent, #c43f2c);
}
.echo-tile__name {
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-weight: 600;
  font-size: 1.15rem;
  line-height: 1.15;
  color: var(--color-text-primary);
}
.echo-tile__quote {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 400;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--color-text-secondary);
  /* Truncate long quotes to two lines to keep the tile sizes
     consistent across the wall. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.echo-tile__quote--muted {
  font-family: 'Syne', system-ui, sans-serif;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-text-muted, var(--color-text-secondary));
  opacity: 0.6;
}

/* Tiles without audio look slightly different: dotted shadow
   instead of solid, signalling "no preview yet". */
.echo-tile:not([data-echo-audio]) .echo-tile__cover {
  box-shadow: var(--echo-shadow-offset) var(--echo-shadow-offset) 0 transparent;
  outline: 1.5px dashed var(--echo-shadow-color);
  outline-offset: -1.5px;
}
.echo-tile:not([data-echo-audio]):hover .echo-tile__cover {
  box-shadow: calc(var(--echo-shadow-offset) + 4px) calc(var(--echo-shadow-offset) + 4px) 0 transparent;
}

/* Responsive */
@media (max-width: 720px) {
  :root { --echo-tile-size: 160px; --echo-shadow-offset: 6px; }
  .echo-wall .container { gap: var(--space-lg); }
  .echo-tile__name { font-size: 1rem; }
  .echo-tile__quote { font-size: 0.8rem; }
}

/* Reduced motion: drop the drift + equaliser animations. */
@media (prefers-reduced-motion: reduce) {
  .echo-tile { animation: none; }
  .echo-tile.is-playing .echo-tile__eq i { animation: none; height: 60%; }
  .echo-hero__hint::before { animation: none; }
}
