/* ——— Radio Mercato Centrale ———
   Scala tipografica ispirata a The Lot Radio (titoli giganti condensati, etichette
   12/14 maiuscole, gap 8px), identità del Mercato Centrale Roma (nero/bianco, rosso
   gomitolo #e2231a, giallo #ffdd0f come tocco, Sofia Pro → anteprima Sofia Sans).
   Layout: header + player in alto; a sinistra la diretta fissa a tutta altezza,
   a destra "riascolta" che scorre, con footer minimale in fondo. */
:root {
  --black: #000000;
  --white: #ffffff;
  --light: #efefec;
  --red: #e2231a;              /* 4.68:1 su bianco */
  --red-hover: #c41b13;
  --yellow: #ffdd0f;

  --bg: var(--light);
  --fg: var(--black);
  --card: var(--white);
  --muted-op: .5;

  --gap: 8px;
  --pad: 12px;
  --header-h: 44px;
  --bar-h: 60px;
  --top-h: calc(var(--header-h) + var(--bar-h));

  --font: "Sofia Pro", "Sofia Sans", Arial, sans-serif;
  --font-display: "Sofia Pro Condensed", "Sofia Sans Condensed", "Arial Narrow", sans-serif;
  --blob: 47% 53% 44% 56% / 55% 42% 58% 45%;
  color-scheme: light dark;
}
@media (min-width: 1280px) { :root { --pad: 16px; } }
@media (prefers-color-scheme: dark) {
  :root { --bg: #111111; --fg: #ffffff; --card: #1c1c1c; }
}

/* ——— Scala tipografica ——— */
.t-h1 {
  font-family: var(--font-display); font-weight: 800; text-transform: uppercase;
  font-size: clamp(64px, 9vw, 150px); line-height: .84; letter-spacing: -0.02em;
}
.t-body { font-size: 15px; line-height: 20px; }
.t-small { font-size: 12px; line-height: 14px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; }
.dim { opacity: var(--muted-op); }

/* ——— Base ——— */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: var(--top-h); }
body {
  margin: 0;
  background: var(--bg); color: var(--fg);
  font-family: var(--font); font-size: 15px; line-height: 20px;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--yellow); color: #000; }
p, h2, h3, ul, figure { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 50; background: var(--fg); color: var(--bg); padding: 10px 14px; text-decoration: none; }
.skip:focus { top: 8px; }

.tag {
  display: inline-flex; align-items: center;
  font-size: 11px; line-height: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  padding: 3px 5px 2px;
}
.tag-live { background: var(--red); color: #fff; }

/* ——— Header + player (blocco fisso in alto) ——— */
.top { position: sticky; top: 0; z-index: 30; background: var(--black); color: var(--white); }
.site-header {
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 var(--pad);
}
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; white-space: nowrap; }
.brand-mark { width: 18px; height: auto; }
.header-aside { display: flex; align-items: center; gap: 16px; }
.onair { display: inline-flex; align-items: center; gap: 6px; }
.onair-mark { width: 14px; height: auto; }
.onair[data-status="off"], .onair[data-status="unknown"] { opacity: .5; }
.onair[data-status="off"] .onair-mark, .onair[data-status="unknown"] .onair-mark { filter: grayscale(1); }
body[data-mode="live"][data-state="playing"] .onair-mark { animation: tangle 3.2s linear infinite; }
@keyframes tangle { 0% { transform: rotate(0) scale(1); } 50% { transform: rotate(180deg) scale(1.18); } 100% { transform: rotate(360deg) scale(1); } }
.clock { font-variant-numeric: tabular-nums; opacity: .6; }

.player-bar {
  height: var(--bar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 var(--pad);
  border-top: 1px solid #2a2a2a;
  background: #0d0d0d;
}
.bar-play { width: 40px; height: 43px; border-radius: var(--blob); background: var(--white); color: var(--black); }
.bar-play[data-ui="playing"], .bar-play[data-ui="loading"] { background: var(--red); color: #fff; }
.bar-play svg { width: 16px; height: 16px; }
.bar-skip { display: flex; gap: 4px; }
.bar-skip button { min-width: 40px; height: 30px; padding: 0 6px; background: #222; }
.bar-skip button:hover { background: #333; }
.bar-meta { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 0; }
.bar-cover { width: 36px; height: 36px; object-fit: cover; flex: none; }
.bar-text { min-width: 0; }
.bar-title, .bar-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-title { font-size: 14px; line-height: 18px; font-weight: 700; }
.bar-sub { opacity: .6; min-height: 14px; margin-top: 2px; }
body[data-state="error"] .bar-sub { opacity: 1; color: #ff6a5f; }
.bar-progress { display: flex; align-items: center; gap: 10px; flex: 1.3 1 0; min-width: 0; }
.time { font-variant-numeric: tabular-nums; min-width: 3.4em; opacity: .7; }
.time:last-child { text-align: right; }
#seek { flex: 1; min-width: 0; accent-color: var(--red); height: 22px; }

body[data-mode="live"] .archive-only,
body[data-mode="archive"] .live-only { display: none; }

/* ——— Split ——— */
.split { display: grid; grid-template-columns: 1fr; }
@media (min-width: 960px) { .split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

/* ——— Sinistra: diretta ——— */
.hero {
  position: relative; overflow: hidden;
  height: min(78svh, 680px);
  background: var(--black); color: var(--white);
}
@media (min-width: 960px) {
  .hero { position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); height: calc(100dvh - var(--top-h)); }
}
.live-art { position: absolute; inset: 0; }
.la-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block; opacity: 0;
  filter: grayscale(1) contrast(1.05) brightness(.9);
  transform: scale(1.02);
  transition: opacity .9s ease, filter 1.2s ease, transform 10s ease-out;
}
.la-img.is-on { opacity: 1; }
body[data-mode="live"][data-state="playing"] .la-img { filter: none; }
body[data-mode="live"][data-state="playing"] .la-img.is-on { transform: scale(1.08); }
.hero-shade {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.85) 0%, rgba(0,0,0,.5) 40%, rgba(0,0,0,0) 70%);
}
.hero-content {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 0 var(--pad) 20px;
  display: grid; gap: 24px;
}
.np[hidden] { display: block; visibility: hidden; }
.np-kicker { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.np-artist { font-family: var(--font-display); font-weight: 800; text-transform: uppercase; font-size: clamp(44px, 6vw, 96px); line-height: .86; overflow-wrap: anywhere; }
.np-title  { font-weight: 300; font-size: clamp(26px, 3.2vw, 52px); line-height: 1; letter-spacing: -0.03em; margin-top: 8px; overflow-wrap: anywhere; }

.live-cta { display: flex; align-items: center; gap: 14px; }
.viz { display: block; flex: 1; min-width: 0; height: 36px; }

/* ——— Play toggles ——— */
.play-toggle { position: relative; display: grid; place-items: center; flex: none; }
.play-toggle svg { fill: currentColor; }
.play-toggle .i-pause, .play-toggle .spinner { display: none; }
.play-toggle[data-ui="playing"] .i-play { display: none; }
.play-toggle[data-ui="playing"] .i-pause { display: block; }
.play-toggle[data-ui="loading"] .i-play { display: none; }
.play-toggle[data-ui="loading"] .spinner { display: block; }
.spinner { width: 40%; height: 40%; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.big-play {
  width: 84px; height: 90px; border-radius: var(--blob);
  background: var(--white); color: var(--black);
  transition: transform .2s ease, background-color .2s ease;
}
.big-play svg { width: 30px; height: 30px; }
.big-play:hover { transform: rotate(-4deg) scale(1.03); }
.big-play[data-ui="playing"], .big-play[data-ui="loading"] { background: var(--red); color: #fff; animation: breathe 4s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { border-radius: 47% 53% 44% 56% / 55% 42% 58% 45%; } 50% { border-radius: 55% 45% 52% 48% / 46% 56% 44% 54%; } }

/* ——— Destra: riascolta ——— */
.side { display: flex; flex-direction: column; min-height: calc(100dvh - var(--top-h)); }
.archive { flex: 1; padding: 20px var(--pad) 64px; }
.sec-title { padding-top: .1em; margin-bottom: 24px; }

.archive-controls { display: grid; gap: 16px; margin-bottom: 24px; max-width: 640px; }
.intro { max-width: 46ch; }
.search input {
  width: 100%; font: inherit; font-size: 15px;
  color: inherit; background: transparent;
  border: 0; border-bottom: 1px solid currentColor; border-radius: 0;
  padding: 8px 0; -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: inherit; opacity: .5; }
.search input:focus-visible { outline: none; border-bottom-width: 2px; }
.filter-block { display: grid; gap: 8px; }
.filter-label { opacity: .5; }
.segmented { display: flex; gap: 2px; }
.segmented button { flex: 1; padding: 8px 6px; min-height: 34px; font-size: 12px; line-height: 14px; text-transform: uppercase; letter-spacing: .06em; font-weight: 500; background: var(--card); }
.segmented button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 12px; line-height: 14px; text-transform: uppercase; letter-spacing: .06em; font-weight: 500; padding: 7px 9px; background: var(--card); }
.chip:hover { outline: 1px solid currentColor; outline-offset: -1px; }
.chip[aria-pressed="true"] { background: var(--red); color: #fff; }
.count { opacity: .5; }

.ep-list { list-style: none; padding: 0; display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 600px) and (max-width: 959px) { .ep-list { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1200px) { .ep-list { grid-template-columns: 1fr 1fr; } }

/* Card: angolo piegato, copertina piccola */
.ep-card {
  position: relative; min-height: 132px; height: 100%;
  display: flex; flex-direction: column; gap: 12px;
  padding: var(--gap);
  background: var(--card); color: var(--fg);
  font-size: 12px; line-height: 15px;
}
.ep-card::before {
  content: ""; position: absolute; top: 0; right: 0;
  border-top: 26px solid var(--bg);
  border-left: 26px solid transparent;
}
.ep-head { display: grid; grid-template-columns: 64px minmax(0, 1fr) minmax(0, .75fr); gap: 10px; min-height: 64px; }
.ep-cover { width: 64px; height: 64px; object-fit: cover; background: #000; display: block; }
.ep-title { font-size: 14px; line-height: 17px; font-weight: 700; }
.ep-host, .ep-genre { opacity: var(--muted-op); }
.ep-right { padding-right: 18px; }
.ep-type { font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: 11px; }
.ep[data-type="podcast"] .ep-type { color: var(--red); }
.ep-actions { display: flex; gap: var(--gap); margin-top: auto; }
.ep-play {
  flex: 1; display: flex; align-items: center; justify-content: space-between;
  min-height: 34px; padding: 4px 10px;
  background: var(--red); color: #fff;
  font-size: 12px; line-height: 14px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
  transition: background-color .15s ease;
}
.ep-play:hover { background: var(--red-hover); }
.ep-play svg { width: 12px; height: 12px; fill: currentColor; }
.ep-play .i-pause { display: none; }
.ep-dur {
  display: flex; align-items: center; padding: 4px 10px;
  background: var(--bg); font-variant-numeric: tabular-nums;
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
}
.ep[aria-current="true"] .ep-card { outline: 2px solid var(--red); outline-offset: -2px; }
.ep[data-playing="true"] .ep-play { background: var(--black); }
@media (prefers-color-scheme: dark) { .ep[data-playing="true"] .ep-play { background: #fff; color: #000; } }
.ep[data-playing="true"] .ep-play .i-play { display: none; }
.ep[data-playing="true"] .ep-play .i-pause { display: block; }
.ep-empty { opacity: .6; }

/* ——— Footer minimale ——— */
.site-footer {
  display: flex; align-items: center; gap: 14px;
  padding: 16px var(--pad) 20px;
  border-top: 1px solid currentColor;
}
.footer-logo { width: 34px; height: auto; flex: none; }
.footer-text { display: grid; gap: 3px; }
@media (prefers-color-scheme: dark) { .footer-logo { filter: invert(1) hue-rotate(180deg) saturate(1.4); } }

/* ——— Mobile ——— */
@media (max-width: 767px) {
  body[data-mode="archive"] { --bar-h: 96px; }
  .clock { display: none; }
  .big-play { width: 72px; height: 78px; }
  .viz { display: none; }
  .ep-head { grid-template-columns: 64px minmax(0, 1fr); }
  .ep-right { grid-column: 2; padding-right: 0; display: flex; gap: 8px; flex-wrap: wrap; }
  .player-bar { flex-wrap: wrap; gap: 0 10px; align-content: center; }
  .bar-progress { order: 5; flex: 1 0 100%; gap: 8px; }
  .bar-cover { display: none; }
}

/* ——— Motion ——— */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .spinner { animation: none; border-right-color: currentColor; opacity: .6; }
}
