/* ═══════════════════════════════════════════
   Komorebi — Main Stylesheet
   Dark Netflix-style theme
═══════════════════════════════════════════ */

:root {
  --bg:        #0a0a0f;
  --surface:   #111118;
  --card:      #16161f;
  --border:    rgba(255,255,255,.07);
  --border2:   rgba(255,255,255,.13);
  --text:      #e8e8f0;
  --muted:     #6b6b88;
  --accent:    #e50914;
  --accent2:   #b5000f;
  --gold:      #f5c518;
  --blue:      #6366f1;
  --r:         10px;
  --nav-h:     64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; border: none; }
select { font-family: inherit; }

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Scrollbar ─────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ══════════════════════════════════════
   NAVBAR
══════════════════════════════════════ */
#site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
}

.navbar {
  display: flex;
  align-items: center;
  gap: 24px;
  height: var(--nav-h);
  background: linear-gradient(to bottom, rgba(10,10,15,.98) 0%, rgba(10,10,15,.7) 100%);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -.02em;
  color: #fff;
  flex-shrink: 0;
}
.logo span { color: var(--accent); }

.nav-links {
  display: flex;
  gap: 6px;
}
.nav-links a {
  font-size: .875rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  color: var(--muted);
  transition: color .15s, background .15s;
}
.nav-links a:hover,
.nav-links a.active {
  color: #fff;
  background: rgba(255,255,255,.07);
}

.nav-search {
  position: relative;
  margin-left: auto;
  flex-shrink: 0;
}
.nav-search input {
  background: rgba(255,255,255,.07);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 8px 16px;
  color: var(--text);
  font-size: .875rem;
  width: 240px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.nav-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(229,9,20,.15);
}
.nav-search input::placeholder { color: var(--muted); }

.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  overflow: hidden;
  z-index: 200;
  display: none;
  box-shadow: 0 20px 60px rgba(0,0,0,.7);
}
.search-dropdown.open { display: block; }

.search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background .15s;
}
.search-item:hover { background: rgba(255,255,255,.06); }
.search-item img {
  width: 42px;
  height: 62px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
.search-item-info { flex: 1; min-width: 0; }
.search-item-title {
  font-size: .875rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-item-sub { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.search-item-type {
  font-size: .7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  background: var(--accent);
  color: #fff;
  flex-shrink: 0;
}
.search-item-type.tv { background: var(--blue); }

.hamburger {
  display: none;
  background: none;
  color: var(--text);
  font-size: 1.4rem;
  padding: 4px 8px;
  border-radius: 6px;
}

.mobile-menu {
  display: none;
  flex-direction: column;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 20px 12px;
}
.mobile-menu.open { display: flex; }
.mobile-menu a {
  padding: 10px 0;
  font-size: .9rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.mobile-menu a:last-child { border: none; }

/* ══════════════════════════════════════
   HERO
══════════════════════════════════════ */
.hero {
  position: relative;
  height: 90vh;
  min-height: 500px;
  max-height: 800px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center top;
  transition: background-image .4s;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to right,
    rgba(10,10,15,.95) 0%,
    rgba(10,10,15,.6) 50%,
    rgba(10,10,15,.1) 100%
  ),
  linear-gradient(
    to top,
    rgba(10,10,15,1) 0%,
    rgba(10,10,15,.4) 40%,
    transparent 100%
  );
}

.hero-content {
  position: relative;
  z-index: 1;
  padding-bottom: 60px;
  max-width: 580px;
}

.hero-badge {
  display: inline-block;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(229,9,20,.12);
  border: 1px solid rgba(229,9,20,.3);
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 14px;
}

.hero-title {
  font-size: clamp(28px, 5vw, 58px);
  font-weight: 900;
  color: #fff;
  letter-spacing: -.03em;
  line-height: 1.1;
  margin-bottom: 14px;
}

.hero-desc {
  font-size: clamp(13px, 1.6vw, 16px);
  color: rgba(232,232,240,.7);
  line-height: 1.65;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.hero-meta .tag {
  font-size: .75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  color: var(--muted);
}
.hero-meta .tag-star { color: var(--gold); border-color: rgba(245,197,24,.3); background: rgba(245,197,24,.08); }

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ── Buttons ─────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  padding: 12px 28px;
  border-radius: 40px;
  border: none;
  transition: background .2s, transform .1s, box-shadow .2s;
  box-shadow: 0 4px 14px rgba(229,9,20,.35);
}
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(229,9,20,.45); }
.btn-primary:active { transform: scale(.97); }
.btn-primary.btn-sm { font-size: 13px; padding: 8px 18px; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.1);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  padding: 12px 28px;
  border-radius: 40px;
  border: 1px solid rgba(255,255,255,.2);
  backdrop-filter: blur(4px);
  transition: background .2s, transform .1s;
}
.btn-secondary:hover { background: rgba(255,255,255,.18); transform: translateY(-1px); }
.btn-secondary:active { transform: scale(.97); }

/* ══════════════════════════════════════
   SHELVES  (horizontal scroll rows)
══════════════════════════════════════ */
.main {
  padding-top: 40px;
  padding-bottom: 80px;
}

.shelf {
  margin-bottom: 48px;
}

.shelf-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 16px;
}

.shelf-row {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 10px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.shelf-row::-webkit-scrollbar { height: 4px; }

/* ══════════════════════════════════════
   MOVIE CARD
══════════════════════════════════════ */
.card {
  position: relative;
  flex-shrink: 0;
  width: 160px;
  border-radius: var(--r);
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  cursor: pointer;
  scroll-snap-align: start;
  transition: transform .25s, box-shadow .25s, border-color .25s;
  group: true;
}
.card:hover {
  transform: translateY(-6px) scale(1.03);
  box-shadow: 0 20px 50px rgba(0,0,0,.7);
  border-color: var(--border2);
  z-index: 2;
}

.card-poster {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  display: block;
  background: #1a1a28;
}
.card-poster-placeholder {
  width: 100%;
  aspect-ratio: 2/3;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--muted);
}

.card-body {
  padding: 10px 10px 12px;
}

.card-title {
  font-size: .8rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .7rem;
  color: var(--muted);
}

.card-rating {
  color: var(--gold);
  font-weight: 700;
}

.card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(10,10,15,.97) 0%, rgba(10,10,15,.3) 60%, transparent 100%);
  opacity: 0;
  transition: opacity .25s;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 12px;
}
.card:hover .card-overlay { opacity: 1; }

.card-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 20px;
  gap: 6px;
  margin-bottom: 6px;
  transition: background .15s;
  border: none;
  cursor: pointer;
}
.card-play:hover { background: var(--accent2); }

.card-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: .75rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.2);
  cursor: pointer;
  transition: background .15s;
}
.card-more:hover { background: rgba(255,255,255,.22); }

.card-type-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--blue);
  color: #fff;
}
.card-type-badge.movie { background: var(--accent); }

/* ══════════════════════════════════════
   GRID VIEW  (browse pages)
══════════════════════════════════════ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 28px;
}
.page-header h1 {
  font-size: 1.8rem;
  font-weight: 900;
  color: #fff;
}

.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.filter-bar select {
  background: var(--card);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpolyline points='0,0 5,6 10,0' fill='none' stroke='%23e50914' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.filter-bar select:focus { border-color: var(--accent); }
.filter-bar select option { background: #111118; }

.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 20px;
  min-height: 300px;
}
.grid-view .card {
  width: 100%;
  flex-shrink: unset;
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, #1a1a28 25%, #222235 50%, #1a1a28 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r);
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-poster { width: 100%; aspect-ratio: 2/3; }
.skel-line { height: 12px; border-radius: 4px; margin-top: 8px; }
.skel-line-sm { width: 60%; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 40px;
  flex-wrap: wrap;
}
.page-btn {
  background: var(--card);
  border: 1px solid var(--border2);
  color: var(--text);
  font-weight: 600;
  font-size: .875rem;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.page-btn:hover { background: var(--surface); border-color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ══════════════════════════════════════
   PLAYER MODAL
══════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  backdrop-filter: blur(6px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 16px;
  width: 100%;
  max-width: 900px;
  overflow: hidden;
  box-shadow: 0 30px 100px rgba(0,0,0,.85);
  animation: modalIn .25s ease;
}
@keyframes modalIn {
  from { transform: scale(.92) translateY(20px); opacity: 0; }
  to   { transform: scale(1) translateY(0);       opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: .95rem;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.modal-close {
  background: rgba(255,255,255,.08);
  color: var(--text);
  font-size: 1rem;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--accent); color: #fff; }

.player-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
}

.player-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #04060c;
  z-index: 3;
  transition: opacity .3s;
}
.player-loader.hidden { opacity: 0; pointer-events: none; }
.player-loader p { font-size: .8rem; color: var(--muted); }

.spinner {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(229,9,20,.15);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.player-iframe {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  border: none;
}

/* Source bar */
.source-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--card);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.source-label {
  font-size: .75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-right: 4px;
}
.source-btn {
  font-size: .8rem;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.source-btn:hover { color: #fff; border-color: rgba(255,255,255,.25); }
.source-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* TV controls */
.tv-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--card);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.tv-controls label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.tv-controls select {
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--text);
  font-size: .85rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 7px;
  outline: none;
  cursor: pointer;
}

/* ══════════════════════════════════════
   INFO MODAL
══════════════════════════════════════ */
.modal-info-box {
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.modal-info-box .modal-close {
  position: sticky;
  top: 12px;
  float: right;
  margin: 12px 12px 0 0;
  z-index: 5;
}

.info-inner { padding: 0 0 28px; }

.info-backdrop {
  width: 100%;
  height: 260px;
  object-fit: cover;
  display: block;
}
.info-backdrop-placeholder {
  width: 100%;
  height: 260px;
  background: linear-gradient(135deg, #1a1a2e, #0f3460);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
}

.info-body { padding: 24px 24px 0; }

.info-title {
  font-size: 1.6rem;
  font-weight: 900;
  color: #fff;
  margin-bottom: 10px;
}

.info-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.info-tag {
  font-size: .75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  color: var(--muted);
}
.info-tag-rating { color: var(--gold); border-color: rgba(245,197,24,.3); background: rgba(245,197,24,.08); }
.info-tag-genre  { color: #fff; border-color: rgba(255,255,255,.15); }

.info-overview {
  font-size: .9rem;
  color: rgba(232,232,240,.75);
  line-height: 1.7;
  margin-bottom: 20px;
}

.info-details {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.info-detail-item { }
.info-detail-lbl {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.info-detail-val {
  font-size: .875rem;
  font-weight: 600;
  color: #fff;
}

.info-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ══════════════════════════════════════
   FOOTER
══════════════════════════════════════ */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 32px 0;
}
.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}
.footer p {
  font-size: .8rem;
  color: var(--muted);
}
.footer-note {
  font-size: .72rem !important;
  max-width: 500px;
  line-height: 1.5;
}

/* ══════════════════════════════════════
   TOAST
══════════════════════════════════════ */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--card);
  border: 1px solid var(--border2);
  color: var(--text);
  font-size: .85rem;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,.6);
  z-index: 9999;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .3s, transform .3s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }

/* ══════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════ */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-search input { width: 180px; }
  .hamburger { display: block; }
  .hero-content { max-width: 100%; }
  .hero { height: 65vh; }
  .grid-view { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .page-header { flex-direction: column; align-items: flex-start; }
  .search-dropdown { width: 280px; right: -60px; }
}

@media (max-width: 480px) {
  .filter-bar { width: 100%; }
  .filter-bar select { flex: 1; }
  .hero-actions { flex-direction: column; }
  .btn-primary, .btn-secondary { width: 100%; justify-content: center; }
  .tv-controls { flex-direction: column; align-items: flex-start; }
}
