/* KosherMusik — YouTube channel page (/youtube) */

.km-yt-page .km-yt {
  --yt-red: #ff0033;
  --yt-card: rgba(255, 255, 255, 0.04);
  --yt-chip: rgba(255, 255, 255, 0.1);
  --yt-chip-hover: rgba(255, 255, 255, 0.18);
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  width: 100%;
  min-width: 0; /* the Shorts row scrolls inside; don't let it widen the page */
  max-width: 1280px;
  margin: 0 auto;
  /* --km-yt-top is the measured site header height (set in koshermusik-youtube.js) */
  padding: calc(var(--km-yt-top, 88px) + 1rem) clamp(1rem, 3vw, 2rem) 4rem;
  font-family: var(--font-body);
  color: var(--text);
}

/* ── banner + channel header ─────────────────────────── */
.km-yt-banner {
  height: clamp(90px, 16vw, 206px);
  border-radius: 16px;
  background: linear-gradient(120deg, #2a0a0a, #111 55%, #0b1a24) center / cover no-repeat;
  box-shadow: 0 0 0 1px var(--line) inset;
}

.km-yt-head {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 3vw, 1.75rem);
  padding: 1.5rem 0 1rem;
}

.km-yt-avatar {
  flex: none;
  width: clamp(72px, 14vw, 160px);
  height: clamp(72px, 14vw, 160px);
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  box-shadow: 0 0 0 1px var(--line-strong);
}

.km-yt-id { min-width: 0; }

/* the site styles bare <section>s with big hero padding */
.km-yt-page .km-yt-panel { padding: 0; }

.km-yt-name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.6rem, 4.5vw, 2.6rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.km-yt-meta,
.km-yt-tagline {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.km-yt-tagline { color: var(--text-dim); }

.km-yt-actions,
.km-yt-player-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.9rem;
}

/* ── buttons ─────────────────────────────────────────── */
.km-yt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 40px;
  padding: 0 1.1rem;
  border-radius: 999px;
  font: 600 0.92rem/1 var(--font-body);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.18s, transform 0.18s var(--ease-spring), color 0.18s;
}

.km-yt-btn svg { width: 18px; height: 18px; fill: currentColor; }
.km-yt-btn:active { transform: scale(0.96); }
.km-yt-btn:focus-visible,
.km-yt-tab:focus-visible,
.km-yt-thumb:focus-visible,
.km-yt-more:focus-visible,
.km-yt-chip:focus-visible,
.km-yt-x:focus-visible,
.km-yt-step:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

.km-yt-btn--sub { background: var(--text); color: var(--bg); }
.km-yt-btn--sub:hover { background: var(--yt-red); color: #fff; }

.km-yt-btn--ghost { background: var(--yt-chip); color: var(--text); }
.km-yt-btn--ghost:hover { background: var(--yt-chip-hover); }

.km-yt-btn--song { background: var(--yt-red); color: #fff; }
.km-yt-btn--song:hover { background: #d9002b; }

/* ── tabs ────────────────────────────────────────────── */
.km-yt-tabs {
  display: flex;
  gap: 0.25rem;
  margin: 0.5rem 0 1.5rem;
  border-bottom: 1px solid var(--line-strong);
  overflow-x: auto;
  scrollbar-width: none;
}

.km-yt-tabs::-webkit-scrollbar { display: none; }

.km-yt-tab {
  flex: none;
  min-height: 48px;
  padding: 0 1.1rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-muted);
  font: 600 0.98rem/1 var(--font-body);
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s;
}

.km-yt-tab:hover { color: var(--text); }
.km-yt-tab[aria-selected='true'] { color: var(--text); border-bottom-color: var(--text); }

/* ── featured ────────────────────────────────────────── */
.km-yt-featured {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: clamp(1rem, 3vw, 2rem);
  align-items: center;
  padding-bottom: 2rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.km-yt-kicker {
  margin: 0 0 0.4rem;
  color: var(--yt-red);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.km-yt-featured-info h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 3vw, 2rem);
  line-height: 1.15;
}

/* ── shelves + grids ─────────────────────────────────── */
.km-yt-shelf { margin-bottom: 2.25rem; }

.km-yt-shelf-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.9rem;
}

.km-yt-shelf-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.km-yt-more {
  min-height: 36px;
  padding: 0 0.9rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text-muted);
  font: 600 0.88rem/1 var(--font-body);
  cursor: pointer;
}

.km-yt-more:hover { background: var(--yt-chip); color: var(--text); }

.km-yt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.75rem 1rem;
}

.km-yt-grid--shorts { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1.5rem 0.75rem; }

.km-yt-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(150px, 190px);
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.km-yt-row > * { scroll-snap-align: start; }

/* ── cards ───────────────────────────────────────────── */
.km-yt-card { min-width: 0; }

.km-yt-thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  padding: 0;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
  cursor: pointer;
}

.km-yt-card--short .km-yt-thumb { aspect-ratio: 9 / 16; }

.km-yt-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s var(--ease-out-expo), filter 0.35s;
}

.km-yt-thumb:hover img { transform: scale(1.04); filter: brightness(0.8); }

.km-yt-play {
  position: absolute;
  inset: 50% auto auto 50%;
  display: grid;
  place-items: center;
  width: 54px;
  height: 38px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  transform: translate(-50%, -50%);
  transition: background-color 0.18s;
}

.km-yt-play svg { width: 24px; height: 24px; fill: currentColor; }
.km-yt-thumb:hover .km-yt-play { background: var(--yt-red); }
.km-yt-play--big { width: 72px; height: 50px; border-radius: 14px; background: var(--yt-red); }
.km-yt-play--big svg { width: 30px; height: 30px; }

.km-yt-featured-thumb { border-radius: 16px; }

.km-yt-card-body { padding: 0.6rem 0.1rem 0; }

.km-yt-card-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.km-yt-card--short .km-yt-card-title { font-size: 0.88rem; }

.km-yt-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.45rem;
  min-height: 30px;
  padding: 0 0.7rem;
  border-radius: 999px;
  background: var(--yt-chip);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
}

.km-yt-chip svg { width: 14px; height: 14px; fill: var(--yt-red); }
.km-yt-chip:hover { background: var(--yt-chip-hover); }

.km-yt-empty { color: var(--text-muted); }
.km-yt-empty a { color: var(--text); }

/* ── player dialog ───────────────────────────────────── */
.km-yt-player {
  width: min(1100px, 100vw);
  max-width: 100vw;
  max-height: 100dvh;
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  overflow: visible;
}

.km-yt-player::backdrop { background: rgba(0, 0, 0, 0.88); backdrop-filter: blur(6px); }

.km-yt-player-inner { position: relative; padding: 3.25rem 1rem 1rem; }

.km-yt-x {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
}

.km-yt-x svg,
.km-yt-step svg { width: 24px; height: 24px; fill: currentColor; }
.km-yt-x:hover,
.km-yt-step:hover { background: rgba(255, 255, 255, 0.24); }

.km-yt-player-stage {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
}

.km-yt-step {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
}

.km-yt-step[hidden] { display: none; }

.km-yt-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100dvh - 12rem);
  margin: 0 auto;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
}

.km-yt-player.is-short .km-yt-frame {
  aspect-ratio: 9 / 16;
  width: auto;
  height: min(78dvh, 820px);
  max-width: 100%;
}

.km-yt-frame iframe { width: 100%; height: 100%; border: 0; display: block; }

.km-yt-player-info { max-width: 720px; margin: 1rem auto 0; text-align: center; }

.km-yt-player-info h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 2.5vw, 1.4rem);
}

.km-yt-player-info .km-yt-player-actions { justify-content: center; }
.km-yt-player .km-yt-btn--ghost { background: rgba(255, 255, 255, 0.12); color: #fff; }

/* ── responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .km-yt-banner { border-radius: 12px; }
  .km-yt-head { align-items: flex-start; }
  .km-yt-featured { grid-template-columns: 1fr; }
  .km-yt-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .km-yt-grid--shorts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .km-yt-player-inner { padding: 3.25rem 0.5rem 0.75rem; }
  .km-yt-player-stage { grid-template-columns: minmax(0, 1fr); }
  .km-yt-step { display: none; }
  .km-yt-player.is-short .km-yt-frame { height: min(70dvh, 760px); }
}

@media (max-width: 420px) {
  .km-yt-actions .km-yt-btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  .km-yt-thumb img,
  .km-yt-btn { transition: none; }
  .km-yt-thumb:hover img { transform: none; }
}

/* ── light theme ─────────────────────────────────────── */
html[data-theme='light'] .km-yt-page .km-yt {
  --yt-card: rgba(0, 0, 0, 0.03);
  --yt-chip: rgba(0, 0, 0, 0.06);
  --yt-chip-hover: rgba(0, 0, 0, 0.12);
}
