:root {
  font-family: system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --bg: #0d1017;
  --bg-soft: #11151e;
  --surface: #161c27;
  --surface-2: #1c2330;
  --border: #283041;
  --border-soft: #1f2735;
  --text: #edf0f4;
  --text-soft: #c3cad6;
  --muted: #8b93a3;
  --accent: #4f8df9;
  --accent-hover: #7aaaff;
  --accent-2: #f97583;
  --yt: #ff0033;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  line-height: 1.6;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(79, 141, 249, 0.35); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.wrap {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3.5rem;
  width: 100%;
  flex: 1;
}

/* ---------- Header ---------- */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 2.25rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--border-soft);
}

.brand {
  text-decoration: none;
  color: var(--text);
  position: relative;
  padding-left: 1rem;
}

/* le "due linee" del brand */
.brand::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.25rem;
  bottom: 0.25rem;
  width: 0.28rem;
  border-radius: 99px;
  background: var(--accent);
}

.brand-title {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.025em;
  color: var(--text);
}

.brand-tag {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.1rem;
  letter-spacing: 0.01em;
}

nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  margin-left: 0.35rem;
  padding: 0.35rem 0.7rem;
  border-radius: 99px;
}

nav a[aria-current="page"] {
  color: var(--accent-hover);
  background: rgba(79, 141, 249, 0.12);
  font-weight: 600;
}

.lang-switch {
  margin-left: 0.6rem;
  display: inline-flex;
  gap: 0.2rem;
  padding: 0.18rem;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 99px;
  vertical-align: middle;
}

.lang-link {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.22rem 0.5rem !important;
  border-radius: 99px;
  margin-left: 0 !important;
}

.lang-link.is-active {
  color: #fff;
  background: var(--accent);
}

/* ---------- Hero / titoli ---------- */

.hero-emoji {
  font-size: 3rem;
  margin: 0 0 0.5rem;
  line-height: 1;
  filter: drop-shadow(0 6px 18px rgba(79, 141, 249, 0.35));
}

h1.page-title {
  font-size: clamp(1.5rem, 4vw, 1.9rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.25;
  margin: 0 0 0.6rem;
}

.lead {
  color: var(--text-soft);
  font-size: 1.08rem;
  line-height: 1.65;
  margin: 0 0 1.75rem;
  max-width: 38rem;
}

.muted { color: var(--muted); }

/* ---------- Card ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin: 0 0 0.7rem;
  color: var(--accent-hover);
}

.card p, .card ul { margin: 0.45rem 0 0; color: var(--text-soft); font-size: 0.95rem; }
.card ul { padding-left: 1.2rem; }
.card li { margin: 0.35rem 0; }
.card li::marker { color: var(--accent); }

/* ---------- Bottoni ---------- */

.icon-yt {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
  vertical-align: -0.2em;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--accent);
  color: #fff !important;
  text-decoration: none;
  padding: 0.55rem 1.15rem;
  border-radius: 99px;
  font-size: 0.92rem;
  font-weight: 700;
  margin-top: 0.5rem;
  box-shadow: 0 4px 14px -4px rgba(79, 141, 249, 0.55);
}

.btn-yt {
  background: var(--yt);
  box-shadow: 0 4px 14px -4px rgba(255, 0, 51, 0.5);
}

/* ---------- Pills ---------- */

.pills { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.85rem; }

.pill, a.pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.82rem;
  color: var(--text-soft);
  text-decoration: none;
}

/* ---------- Liste episodi ---------- */

.episode-list, .episode-grid { list-style: none; padding: 0; margin: 0; }

.episode-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-soft);
  margin: 0 -0.6rem;
  padding: 0 0.6rem;
  border-radius: var(--radius-sm);
}

.episode-row:last-child { border-bottom: none; }

.episode-row-main {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0;
  text-decoration: none;
  color: var(--text);
  flex: 1;
  min-width: 0;
}

.ep-body { display: flex; flex-direction: column; gap: 0.18rem; min-width: 0; }
.ep-meta-line { display: flex; flex-wrap: wrap; gap: 0.55rem; font-size: 0.8rem; color: var(--muted); }
.yt-link {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 99px;
  background: rgba(255, 0, 51, 0.12);
  color: #ff8093;
  text-decoration: none;
  font-size: 0.8rem;
  border: 1px solid rgba(255, 0, 51, 0.28);
}

.yt-link .icon-yt { width: 1.05rem; height: 1.05rem; }

.yt-link-card {
  width: auto;
  height: auto;
  padding: 0.4rem 0.65rem;
  margin: 0 0.9rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 600;
  display: flex;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.yt-link-card .icon-yt { width: 0.95rem; height: 0.95rem; }

/* ---------- Griglia catalogo ---------- */

.episode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.85rem;
}

.episode-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.episode-card-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 1rem;
  gap: 0.4rem;
  min-height: 100%;
  flex: 1;
  text-decoration: none;
  color: var(--text);
}

.ep-emoji { font-size: 1.4rem; flex-shrink: 0; line-height: 1; }
.ep-title { flex: 1; font-weight: 600; line-height: 1.4; }
.ep-serie { font-size: 0.78rem; color: var(--muted); }

.ep-badge {
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 0.12rem 0.5rem;
  color: var(--muted);
}

/* ---------- Ordinamento ---------- */

.sort-nav { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: -0.5rem 0 1.25rem; }

.sort-link {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  padding: 0.3rem 0.75rem;
  border-radius: 99px;
  border: 1px solid var(--border);
}

.sort-link.is-active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

/* ---------- Player episodio ---------- */

.video-wrap {
  position: relative;
  width: 100%;
  max-width: 340px;
  margin: 1.25rem auto;
  aspect-ratio: 9 / 16;
  background: #000;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow:
    0 0 0 6px rgba(79, 141, 249, 0.06),
    0 22px 50px -18px rgba(0, 0, 0, 0.75);
}

.video-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.cta-yt { text-align: center; margin: 1.25rem 0; }

/* ---------- Dialogo ---------- */

.dialogue-list { margin: 0; }

.dialogue-list dt {
  font-weight: 700;
  color: var(--accent-hover);
  margin-top: 0.85rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dialogue-list dt:nth-of-type(even) { color: var(--accent-2); }
.dialogue-list dt:first-of-type { margin-top: 0.25rem; }

.dialogue-list dd {
  margin: 0.25rem 0 0;
  color: var(--text-soft);
  padding: 0.5rem 0.8rem;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 4px 14px 14px 14px;
  width: fit-content;
  max-width: 100%;
}

.ep-meta { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.5rem; }
.ep-meta a { color: var(--accent-hover); text-decoration: none; }

/* ---------- Paginazione ---------- */

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1.75rem;
  justify-content: center;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.1rem;
  padding: 0.38rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
}

.page-link.is-current {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

/* ---------- Footer ---------- */

.site-footer {
  text-align: center;
  padding: 1.5rem 1.25rem;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--border-soft);
  background: var(--bg-soft);
}

.site-footer a { color: var(--text-soft); text-decoration: none; }

/* ---------- Pagine legali ---------- */

.legal h2 {
  font-size: 1.1rem;
  margin: 1.75rem 0 0.5rem;
  color: var(--text);
  letter-spacing: -0.01em;
}

.legal h2:first-of-type { margin-top: 0; }
.legal p, .legal ul { color: var(--text-soft); font-size: 0.95rem; }
.legal .meta { color: var(--muted); font-size: 0.88rem; margin-bottom: 1.5rem; }

.legal hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.75rem 0;
}

a.ext { color: var(--accent-hover); }

code {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  padding: 0.12rem 0.4rem;
  border-radius: 6px;
  font-size: 0.85em;
}

/* ---------- Breadcrumb ---------- */

.breadcrumb {
  margin: -1.25rem 0 1.4rem;
  font-size: 0.82rem;
}

.breadcrumb ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  color: var(--muted);
}

.breadcrumb li + li::before {
  content: "›";
  margin-right: 0.4rem;
  color: #525a6a;
}

.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb [aria-current="page"] { color: var(--text-soft); }

/* ---------- Sinossi / commenti ---------- */

.seo-synopsis { border-left: 3px solid var(--accent); }
.seo-synopsis p { margin: 0; color: var(--text-soft); font-size: 0.97rem; line-height: 1.65; }
.seo-synopsis .muted { margin-top: 0.6rem; font-size: 0.9rem; }

.comments-list { list-style: none; padding: 0; margin: 0; }

.comment-item {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border-soft);
}

.comment-item:last-child { border-bottom: none; padding-bottom: 0.25rem; }

.comment-head {
  margin: 0 0 0.3rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: baseline;
}

.comment-author { color: var(--text); font-size: 0.88rem; }
.comment-author::before { content: "@"; color: var(--accent); font-weight: 700; }
.comment-date { color: var(--muted); font-size: 0.76rem; }
.comment-body { margin: 0; color: var(--text-soft); font-size: 0.92rem; line-height: 1.55; }

.related-episodes .episode-list { margin-top: 0.25rem; }

/* ---------- Responsive ---------- */

@media (max-width: 540px) {
  .wrap { padding: 1.1rem 1rem 2.5rem; }
  .site-header { margin-bottom: 1.6rem; }
  nav a { margin-left: 0; padding: 0.3rem 0.55rem; font-size: 0.88rem; }
  .episode-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.6rem; }
  .card { padding: 1.05rem 1.05rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
  html { scroll-behavior: auto; }
}
