/* ============================================================
   Unseen Stream — flat, full-bleed feed
   Tokens: one dark surface, one accent, no borders anywhere.
   ============================================================ */

:root {
  --bg: #08080a;
  --surface: #141416;
  --surface-1: rgba(255, 255, 255, 0.08);
  --surface-2: rgba(255, 255, 255, 0.14);
  --text: #f5f5f7;
  --muted: rgba(245, 245, 247, 0.6);
  --accent: #ff2b2b;
  --radius: 18px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
    "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: pan-y;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}

button:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.7);
  outline-offset: 2px;
}

/* ---------- Stage ---------------------------------------- */

#video-container {
  position: fixed;
  inset: 0;
  background: #000;
  overflow: hidden;
}

#player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#native-player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #000;
  object-fit: contain;
  display: none;
  z-index: 2;
}

#embed-player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
  display: none;
  z-index: 2;
}

body.archive-mode #native-player {
  display: block;
}
body.archive-mode #player {
  display: none;
}

body.embed-mode #embed-player {
  display: block;
}
body.embed-mode #player {
  display: none;
}

/* Auf Touch-Geraeten liegt eine transparente Ebene ueber dem Player:
   Swipes gehen sonst im YouTube-iframe verloren. */
#swipe-layer {
  display: none;
}

@media (pointer: coarse) {
  #swipe-layer {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 3;
    touch-action: none;
  }
}

/* Slide transitions when changing video */
@keyframes slideOutUp {
  to {
    opacity: 0;
    transform: translateY(-22px) scale(0.985);
  }
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(22px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes slideOutDown {
  to {
    opacity: 0;
    transform: translateY(22px) scale(0.985);
  }
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-22px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

#player.slide-out-up,
#native-player.slide-out-up,
#embed-player.slide-out-up {
  animation: slideOutUp 0.28s ease forwards;
}

#player.slide-in-up,
#native-player.slide-in-up,
#embed-player.slide-in-up {
  animation: slideInUp 0.28s ease forwards;
}

#player.slide-out-down,
#native-player.slide-out-down,
#embed-player.slide-out-down {
  animation: slideOutDown 0.28s ease forwards;
}

#player.slide-in-down,
#native-player.slide-in-down,
#embed-player.slide-in-down {
  animation: slideInDown 0.28s ease forwards;
}

/* ---------- Loading -------------------------------------- */

#loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0 24px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  z-index: 3;
  animation: breathe 2.4s ease-in-out infinite;
}

#loading.hidden {
  display: none;
}

@keyframes breathe {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 0.95;
  }
}

/* ---------- Overlay (info + action rail) ------------------ */

#overlay {
  position: absolute;
  right: 20px;
  bottom: 152px;
  z-index: 4;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

body:not(.controls-visible) #overlay {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.footer-info {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

#brand-mark {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  flex: none;
  opacity: 0.55;
}

#video-info-text {
  min-width: 0;
  flex: 1;
}

#video-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  min-width: 0;
}

#video-stats {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-badge {
  flex: none;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: rgba(245, 245, 247, 0.9);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Action rail on the right */
.action-rail {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: none;
}

.action-rail button {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--surface-1);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--text);
  display: grid;
  place-items: center;
  font-size: 21px;
  line-height: 1;
  transition: background 0.15s ease, transform 0.15s ease;
}

.action-rail button:hover {
  background: var(--surface-2);
}

.action-rail button:active {
  transform: scale(0.94);
}

.action-rail button svg {
  width: 19px;
  height: 19px;
}

#heart-btn.saved {
  background: var(--accent);
}

#library-btn svg {
  width: 19px;
  height: 19px;
}

#download-btn svg {
  width: 19px;
  height: 19px;
}

.action-rail button:disabled {
  opacity: 0.32;
  cursor: default;
}

.action-rail button:disabled:hover {
  background: var(--surface-1);
}

/* ---------- Bottom bar ------------------------------------ */

/* Timeline / scrubber */
#timeline {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 16px;
  cursor: pointer;
  touch-action: none;
  z-index: 1;
}

#timeline-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 3px;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.18);
}

#timeline-fill {
  position: absolute;
  left: 0;
  top: 50%;
  height: 3px;
  width: 0;
  transform: translateY(-50%);
  background: #fff;
}

#timeline-head {
  position: absolute;
  top: 50%;
  left: 0;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.12s ease;
}

#timeline.dragging #timeline-head {
  transform: scale(1.35);
}

#timeline:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.7);
  outline-offset: 2px;
}

#controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 20px 14px;
  background: rgba(8, 8, 10, 0.94);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  z-index: 5;
  transition: transform 0.28s ease, opacity 0.28s ease;
}

#controls.hidden {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

.footer-controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.controls-side {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.controls-left {
  justify-content: flex-start;
}

.controls-right {
  justify-content: flex-end;
}

/* Source segmented control */
#source-toggle {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-1);
}

.source-btn[hidden] {
  display: none;
}

.source-btn {
  position: relative;
  width: 30px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  opacity: 0.35;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.source-btn:hover {
  opacity: 0.7;
}

.source-btn.active {
  opacity: 1;
  background: rgba(255, 255, 255, 0.12);
}

.source-btn img {
  display: block;
}

.source-btn::after,
.sort-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(3px);
  padding: 5px 8px;
  border-radius: 6px;
  background: #1c1c1f;
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 20;
}

.source-btn:hover::after,
.source-btn:focus-visible::after,
.sort-btn:hover::after,
.sort-btn:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#sort-toggle {
  display: flex;
  gap: 2px;
  margin-left: 8px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-1);
}

.sort-btn {
  position: relative;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.sort-btn:hover {
  color: var(--text);
}

.sort-btn.active {
  background: #fff;
  color: var(--bg);
}

/* Autoplay pill */
#autoplay-btn {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.unseen-count {
  margin-right: 12px;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#autoplay-btn:hover {
  color: var(--text);
}

#autoplay-btn.active {
  background: #fff;
  color: var(--bg);
}

/* Navigation */
.nav-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface-1);
  color: var(--text);
  display: grid;
  place-items: center;
  transition: background 0.15s ease, transform 0.15s ease;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn:hover {
  background: var(--surface-2);
}

.icon-btn:active {
  transform: scale(0.94);
}

.play-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #fff;
  color: var(--bg);
  display: grid;
  place-items: center;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.play-btn svg {
  width: 22px;
  height: 22px;
}

.play-btn .pause-icon {
  display: none;
}

.play-btn.playing .play-icon {
  display: none;
}

.play-btn.playing .pause-icon {
  display: block;
}

.play-btn:hover {
  transform: scale(1.04);
}

.play-btn:active {
  transform: scale(0.96);
}

.play-btn:disabled {
  background: var(--surface-1);
  color: var(--muted);
  cursor: default;
  transform: none;
}

/* Hide/show UI */
#fade-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-1);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--text);
  display: grid;
  place-items: center;
  z-index: 6;
  transition: background 0.15s ease;
}

#fade-btn:hover {
  background: var(--surface-2);
}

#fade-btn svg {
  width: 16px;
  height: 16px;
  transition: transform 0.25s ease;
}

#fade-btn.rotated svg {
  transform: rotate(180deg);
}

/* ---------- Modals --------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.78);
  z-index: 20;
}

.modal.show {
  display: flex;
}

.modal-content {
  width: 100%;
  max-width: 440px;
  max-height: 82vh;
  overflow-y: auto;
  padding: 26px;
  border-radius: 22px;
  background: var(--surface);
}

.modal-mark {
  display: block;
  width: 64px;
  height: 64px;
  margin-bottom: 18px;
}

.modal h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.modal .lede {
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.55;
  color: rgba(245, 245, 247, 0.78);
}

.modal .body {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.primary-btn {
  width: 100%;
  margin-top: 22px;
  padding: 13px;
  border-radius: 14px;
  background: #fff;
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  transition: opacity 0.15s ease;
}

.primary-btn:hover {
  opacity: 0.9;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-head h2 span {
  color: var(--muted);
  font-weight: 500;
}

.close-btn {
  padding: 2px 6px;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
}

.close-btn:hover {
  color: var(--text);
}

.video-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.video-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: background 0.15s ease;
}

.video-item:hover {
  background: rgba(255, 255, 255, 0.09);
}

.video-item img {
  width: 96px;
  height: 54px;
  flex: none;
  border-radius: 10px;
  object-fit: cover;
  background: #000;
}

.video-item-info {
  min-width: 0;
}

.video-item-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-item-stats {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--muted);
}

.empty-state {
  padding: 28px 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.empty-state-icon {
  margin-bottom: 8px;
  font-size: 30px;
  color: rgba(255, 255, 255, 0.3);
}

@media (max-width: 720px) {
  #source-toggle,
  #sort-toggle {
    padding: 2px;
  }

  #sort-toggle {
    margin-left: 6px;
  }

  .source-btn {
    width: 26px;
    height: 24px;
  }

  .source-btn img {
    width: 15px;
    height: auto;
  }

  .sort-btn {
    padding: 4px 8px;
    font-size: 10px;
  }

  .unseen-count {
    margin-right: 8px;
    font-size: 10px;
  }

  .unseen-label {
    display: none;
  }

  #autoplay-btn {
    padding: 6px 9px;
    font-size: 10px;
  }
}

/* ---------- Mobile --------------------------------------- */

@media (max-width: 720px) {
  #controls {
    gap: 8px;
    padding: 16px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .footer-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .nav-buttons {
    order: 1;
    flex-basis: 100%;
    justify-content: center;
  }

  .controls-left {
    order: 2;
  }

  .controls-right {
    order: 3;
  }

  #overlay {
    bottom: 196px;
    right: 14px;
  }

  #video-title {
    font-size: 13.5px;
  }

  .action-rail button {
    width: 42px;
    height: 42px;
    font-size: 19px;
  }

  #fade-btn {
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: 12px;
  }
}

/* ---------- Reduced motion -------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.icon-btn:disabled {
  opacity: 0.32;
  cursor: default;
}

.icon-btn:disabled:hover {
  background: var(--surface-1);
}

/* Toast (Link kopiert etc.) */
#toast {
  position: fixed;
  left: 50%;
  bottom: 172px;
  transform: translate(-50%, 8px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(20, 20, 22, 0.96);
  color: var(--text, #f5f5f7);
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 3000;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ghost-btn {
  padding: 7px 11px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-1, rgba(255, 255, 255, 0.08));
  color: var(--muted, rgba(245, 245, 247, 0.6));
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.ghost-btn:hover {
  background: var(--surface-2, rgba(255, 255, 255, 0.14));
  color: var(--text, #fff);
}
