/* ═════════════════════ Enhanced Theme ═════════════════════ */
:root{
  --primary:#0a1a4f; --primary-600:#0b235f; --primary-700:#081640; --primary-light:#1a2d6b;
  --accent:#3b82f6; --accent-light:#60a5fa;
  --ink:#101828; --muted:#5b677a; --line:#e5e7eb; --card:#ffffff; --bg:#f6f8fc;
  --shadow:0 10px 30px rgba(10,26,79,.08); --shadow-lg:0 20px 50px rgba(10,26,79,.12);
  --gradient-primary:linear-gradient(135deg,var(--primary) 0%,var(--primary-600) 100%);
  --gradient-accent:linear-gradient(135deg,#3b82f6 0%,#2563eb 100%);
}

html,body{margin:0;padding:0;}
header .logo-section .umak-text{font-family:"Marcellus",serif!important;}

.moves-page{margin-top:60px;}
.moves-page *{scroll-margin-top:60px;box-sizing:border-box;}

/* Desktop: only middle column scrolls */
@media (min-width:1025px){ html,body{height:100%;overflow:hidden;} }

/* ═════════════════════ Layout ═════════════════════ */
.anime-layout{
  font-family:'Metropolis','Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
  background:var(--bg); color:var(--ink);
  display:grid; grid-template-columns:300px 1fr 400px; gap:0;
  min-height:calc(100vh - 60px);
}
@media (min-width:1025px){ .anime-layout{height:calc(100vh - 60px);min-height:auto;} }

/* ═════════════════════ LEFT SIDEBAR: Videos ═════════════════════ */
/* Make the whole sidebar sticky but only the episode list scrolls */
.episode-sidebar{
  background:var(--card); color:var(--ink);
  height:calc(100vh - 60px);
  position:sticky; top:60px;
  border-right:1px solid var(--line);
  max-width:100%;

  display:flex; flex-direction:column;
  overflow:hidden;                     /* ⟵ stop scrolling here */
}
.episode-header{
  padding:28px 24px;
  background:linear-gradient(180deg, rgba(10,26,79,.03) 0%, rgba(255,255,255,0) 100%);
  border-bottom:1px solid var(--line);
  position:relative;
  flex:0 0 auto;                       /* header never scrolls */
}

.episode-list{
  list-style:none; margin:0; padding:12px 0; width:100%;
  overflow-x:hidden!important;
  flex:1 1 auto;                       /* take remaining space */
  overflow-y:auto;                     /* ⟵ only this scrolls */
}

.header-icon-wrapper{width:48px;height:48px;background:var(--gradient-primary);border-radius:12px;display:flex;align-items:center;justify-content:center;margin-bottom:16px;box-shadow:0 4px 12px rgba(10,26,79,.15);}
.header-icon{color:#fff;font-size:22px;}
.episode-heading{margin:0 0 6px 0;font-size:20px;font-weight:800;color:var(--primary);letter-spacing:-.3px;}
.episode-subheading{margin:0;font-size:13px;color:var(--muted);font-weight:500;}

.episode-item{margin:0 12px 8px;overflow-x:hidden!important;border-radius:10px;transition:all .2s ease;}
.episode-link{display:flex;align-items:center;gap:14px;width:100%;max-width:100%;box-sizing:border-box;padding:14px 16px;color:#334155;text-decoration:none;transition:all .25s ease;position:relative;overflow:hidden;white-space:normal!important;border-radius:10px;background:transparent;}
.episode-link:hover{background:linear-gradient(135deg,rgba(59,130,246,.06) 0%,rgba(59,130,246,.02) 100%);transform:translateX(4px);}
.episode-item.active{background:linear-gradient(135deg,rgba(10,26,79,.08) 0%,rgba(59,130,246,.06) 100%);box-shadow:0 4px 12px rgba(10,26,79,.08);}
.episode-item.active .episode-link{font-weight:700;position:relative;}
.episode-item.active::before{content:'';position:absolute;left:0;top:0;bottom:0;width:4px;background:var(--gradient-primary);border-radius:0 4px 4px 0;}

.episode-number-badge{flex:0 0 36px;width:36px;height:36px;background:linear-gradient(135deg,#e2e8f0 0%,#cbd5e1 100%);border-radius:8px;display:flex;align-items:center;justify-content:center;transition:all .25s ease;}
.episode-item.active .episode-number-badge{background:var(--gradient-primary);box-shadow:0 4px 12px rgba(10,26,79,.2);}
.episode-number{font-size:14px;font-weight:700;color:#64748b;transition:color .25s ease;}
.episode-item.active .episode-number{color:#fff;}

.episode-content{flex:1 1 auto;min-width:0;max-width:100%;display:flex;flex-direction:column;gap:4px;}
.episode-title{display:block;font-size:14px;line-height:1.4;min-width:0;max-width:100%;white-space:normal!important;overflow-wrap:anywhere;word-break:break-word;color:#1e293b;font-weight:600;}
.episode-item.active .episode-title{color:var(--primary);}

.episode-status{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--accent);font-weight:600;text-transform:uppercase;letter-spacing:.5px;}
.pulse-dot{font-size:6px;animation:pulse 2s ease-in-out infinite;}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.4}}

.episode-play-icon{flex:0 0 auto;color:var(--primary);font-size:16px;opacity:.8;transition:all .25s ease;}
.episode-item.active .episode-play-icon{opacity:1;animation:playPulse 1.5s ease-in-out infinite;}
@keyframes playPulse{0%,100%{transform:scale(1)}50%{transform:scale(1.15)}}

/* ═════════════════════ CENTER: Video Player ═════════════════════ */
.video-section{background:var(--card);padding:32px;overflow-y:auto;}
@media (max-width:1024px){ .video-section{overflow:visible;} }

.video-container{background:#000;border-radius:16px;overflow:hidden;aspect-ratio:16/9;margin-bottom:24px;box-shadow:var(--shadow-lg);position:relative;}
.video-container::before{content:'';position:absolute;inset:0;border-radius:16px;padding:2px;background:linear-gradient(135deg,rgba(59,130,246,.3),rgba(10,26,79,.3));-webkit-mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);-webkit-mask-composite:xor;mask-composite:exclude;pointer-events:none;opacity:.5;}
.lesson-video,.lesson-embed{width:100%;height:100%;display:block;border:none;}
.no-video{display:flex;align-items:center;justify-content:center;height:100%;color:rgba(255,255,255,.6);font-size:16px;}

/* Video Description Card (preserve DB newlines without extra space) */
.video-description-card{background:#fff;border:1px solid #e4e8f4;border-radius:16px;overflow:hidden;box-shadow:var(--shadow);transition:all .3s ease;}
.video-description-card:hover{box-shadow:var(--shadow-lg);transform:translateY(-2px);}
.video-description-card .vd-head{display:flex;align-items:center;gap:12px;padding:16px 20px;font-weight:800;letter-spacing:.5px;text-transform:uppercase;font-size:12px;background:linear-gradient(135deg,rgba(10,26,79,.06) 0%,rgba(59,130,246,.04) 100%);color:var(--primary);border-bottom:1px solid #e4e8f4;}
.vd-head-icon{width:28px;height:28px;background:var(--gradient-primary);border-radius:6px;display:flex;align-items:center;justify-content:center;color:#fff;font-size:12px;}
.video-description-card .vd-body{padding:20px;overflow-x:hidden;overflow-y:auto;word-wrap:break-word;overflow-wrap:break-word;max-height:220px;}
/* KEY FIX: tighter line-height + pre-line (treat \n as breaks, collapse spaces) */
.video-description-card .vd-body p{margin:0;font-size:14px;line-height:1.5;color:#374151;white-space:pre-line;}
@media (max-width:640px){ .video-description-card .vd-body{max-height:260px;} }

/* ═════════════════════ RIGHT SIDEBAR: Info & Notes ═════════════════════ */
.info-sidebar{
  background:var(--card); padding:32px 24px; overflow-y:auto; overflow-x:hidden;
  height:calc(100vh - 60px); position:sticky; top:60px; border-left:1px solid var(--line);
}

.material-card{display:flex;flex-direction:column;gap:20px;margin-bottom:28px;padding-bottom:28px;border-bottom:2px solid #edf2ff;}
.material-thumb{width:100%;height:200px;border-radius:16px;overflow:hidden;flex-shrink:0;background:var(--gradient-primary);display:flex;align-items:center;justify-content:center;color:#fff;position:relative;box-shadow:var(--shadow-lg);}
.material-thumb::before{content:'';position:absolute;inset:0;background:linear-gradient(135deg,rgba(255,255,255,.1) 0%,rgba(255,255,255,0) 100%);pointer-events:none;}
.material-thumb img{width:100%;height:100%;object-fit:cover;}
.thumb-overlay{position:absolute;inset:0;background:linear-gradient(180deg,transparent 0%,rgba(10,26,79,.3) 100%);pointer-events:none;}
.thumb-placeholder{color:rgba(255,255,255,.7);font-size:48px;position:relative;z-index:1;}

.material-info{flex:1;min-width:0;}
.material-title{margin:0 0 12px 0;font-size:24px;font-weight:800;color:var(--ink);line-height:1.3;letter-spacing:-.5px;}
.material-category{font-size:13px;font-weight:700;color:var(--primary);background:linear-gradient(135deg,#eef2ff 0%,#e0e7ff 100%);border:1px solid #c7d2fe;display:inline-flex;align-items:center;gap:6px;padding:6px 14px;border-radius:999px;box-shadow:0 2px 8px rgba(10,26,79,.06);}
.material-category i{font-size:11px;}

/* Description Section (same newline behavior as DB) */
.description-section{margin-bottom:28px;}
.section-header{display:flex;align-items:center;gap:12px;margin-bottom:16px;padding-bottom:12px;border-bottom:2px solid #edf2ff;}
.section-icon{width:36px;height:36px;background:var(--gradient-accent);border-radius:8px;display:flex;align-items:center;justify-content:center;color:#fff;font-size:16px;box-shadow:0 4px 12px rgba(59,130,246,.25);}
.section-title{margin:0;font-size:17px;font-weight:800;color:var(--primary);letter-spacing:-.2px;}
.description-box{background:linear-gradient(135deg,#fff 0%,#f8fafc 100%);padding:20px;border-radius:14px;border:1px solid #e4e8f4;box-shadow:var(--shadow);max-height:240px;overflow-x:hidden;overflow-y:auto;transition:all .3s ease;word-wrap:break-word;overflow-wrap:break-word;}
.description-box:hover{box-shadow:var(--shadow-lg);}
.description-box p{margin:0;font-size:14px;line-height:1.5;color:#374151;white-space:pre-line;}
@media (max-width:640px){ .description-box{max-height:300px;} }

/* Notes Section */
.notes-section{margin-bottom:20px;}
.notes-heading{margin:0;font-size:17px;font-weight:800;color:var(--primary);letter-spacing:-.2px;}
.notes-list{display:flex;flex-direction:column;gap:12px;}
.note-item{background:#fff;border:1px solid #e4e8f4;border-radius:14px;overflow:hidden;box-shadow:0 4px 12px rgba(16,24,40,.06);transition:all .3s ease;}
.note-item:hover{box-shadow:var(--shadow-lg);transform:translateY(-2px);}
.note-item[open]{box-shadow:var(--shadow-lg);border-color:#c7d2fe;}
.note-summary{display:flex;align-items:center;gap:14px;padding:16px 18px;cursor:pointer;list-style:none;user-select:none;background:linear-gradient(135deg,#fbfcff 0%,#f8fafc 100%);transition:all .25s ease;font-weight:600;}
.note-summary::-webkit-details-marker{display:none;}
.note-summary:hover{background:linear-gradient(135deg,#f0f4ff 0%,#e8f0fe 100%);}
.note-item[open] .note-summary{background:linear-gradient(135deg,rgba(59,130,246,.08) 0%,rgba(10,26,79,.04) 100%);}
.note-number{flex:0 0 32px;width:32px;height:32px;background:var(--gradient-primary);color:#fff;border-radius:8px;display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:800;box-shadow:0 4px 12px rgba(10,26,79,.15);}
.note-title{flex:1;font-size:14px;color:#0f172a;line-height:1.4;}
.note-arrow{flex:0 0 auto;font-size:12px;color:#64748b;transition:transform .3s ease;}
.note-item[open] .note-arrow{transform:rotate(180deg);color:var(--primary);}
.note-content{padding:18px 20px;background:#fff;border-top:1px solid #e4e8f4;}

.note-bullets{list-style:disc outside;padding-left:1.25rem;margin:0;}
.note-bullets li{
  display:list-item;margin:10px 0;font-size:13px;line-height:1.6;color:#374151;
  white-space:normal;overflow-wrap:break-word;word-break:break-word;padding-left:0;background:none!important;
}
.note-bullets li::before{content:none!important;}
.note-bullets li::marker{color:var(--primary);}
.note-empty{margin:0;font-size:13px;color:#94a3b8;font-style:italic;}

/* ═════════════════════ Responsive Design ═════════════════════ */
@media (max-width:1400px){ .anime-layout{grid-template-columns:280px 1fr 380px;} }
@media (max-width:1200px){ .anime-layout{grid-template-columns:260px 1fr 360px;} }

/* Mobile/tablet stacking + 5-item cap for the episode list */
@media (max-width:1024px){
  html,body{overflow:auto;}
  .anime-layout{grid-template-columns:1fr;grid-template-rows:auto 1fr auto;height:auto;}

  .episode-sidebar,.info-sidebar{position:static;height:auto;max-height:unset;}
  .episode-sidebar{order:2;border-right:none;border-top:1px solid var(--line);}

  /* Show max ~5 items then scroll */
  .episode-list{
    max-height:340px;       /* ~5 items */
    overflow-y:auto;
  }

  .video-section{order:1;overflow:visible;}
  .info-sidebar{order:3;border-left:none;border-top:1px solid var(--line);}
}
@media (max-width:768px){
  .material-card{align-items:center;text-align:center;}
  .material-thumb{width:100%;height:180px;}
  .material-title{font-size:22px;}
}
@media (max-width:640px){
  .video-section{padding:20px;}
  .info-sidebar{padding:20px;}
  .episode-header{padding:20px;}
  .material-title{font-size:20px;}
  .video-container{border-radius:12px;}
}

/* ═════════════════════ Custom Scrollbars ═════════════════════ */
.episode-list::-webkit-scrollbar,
.episode-sidebar::-webkit-scrollbar,
.info-sidebar::-webkit-scrollbar,
.description-box::-webkit-scrollbar,
.video-description-card .vd-body::-webkit-scrollbar{width:8px;height:8px;}
.episode-list::-webkit-scrollbar-track,
.episode-sidebar::-webkit-scrollbar-track,
.info-sidebar::-webkit-scrollbar-track,
.description-box::-webkit-scrollbar-track,
.video-description-card .vd-body::-webkit-scrollbar-track{background:#f3f5fb;border-radius:4px;}
.episode-list::-webkit-scrollbar-thumb,
.episode-sidebar::-webkit-scrollbar-thumb,
.info-sidebar::-webkit-scrollbar-thumb,
.description-box::-webkit-scrollbar-thumb,
.video-description-card .vd-body::-webkit-scrollbar-thumb{background:var(--gradient-primary);border-radius:4px;transition:background .3s ease;}
.episode-list::-webkit-scrollbar-thumb:hover,
.episode-sidebar::-webkit-scrollbar-thumb:hover,
.info-sidebar::-webkit-scrollbar-thumb:hover,
.description-box::-webkit-scrollbar-thumb:hover,
.video-description-card .vd-body::-webkit-scrollbar-thumb:hover{background:var(--primary-700);}

/* ═════════════════════ Animations ═════════════════════ */
@keyframes fadeIn{from{opacity:0;transform:translateY(10px);}to{opacity:1;transform:translateY(0);}}
.note-item,.episode-item{animation:fadeIn .3s ease;}

/* ═════════════════════ Focus States ═════════════════════ */
.episode-link:focus-visible,.note-summary:focus-visible{outline:2px solid var(--accent);outline-offset:2px;}

/* ═════════════════════ Print Styles ═════════════════════ */
@media print{
  .episode-sidebar,.header{display:none;}
  .anime-layout{grid-template-columns:1fr;}
  .video-container{display:none;}
}
