/* ══════════════════════════════════════════════════════════════════════
   WeissGuitar Learn — Layout
   Header, sidebar, main content area, mobile nav, responsive.
   ══════════════════════════════════════════════════════════════════════ */

/* ── Header ────────────────────────────────────────────────────────── */
.header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-height);
  background: rgba(30, 25, 45, 0.85); backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; padding: 0 28px; z-index: 100; gap: 20px;
}
.header::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px;
  background: var(--glass-line); filter: blur(0.5px);
}
[data-theme="light"] .header {
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.02);
}

.hamburger {
  display: none; background: none; border: none; color: var(--text-primary);
  font-size: 22px; cursor: pointer; padding: 8px; border-radius: 8px;
  transition: background 0.2s; min-width: 44px; min-height: 44px;
}
.hamburger:hover { background: var(--bg-hover); }

.header-logo {
  font-family: var(--font-display); font-size: 22px; font-weight: 700;
  color: #fff; letter-spacing: -0.01em; text-shadow: 0 0 30px rgba(96,54,232,0.3);
  text-decoration: none; white-space: nowrap;
}
.header-logo span {
  background: linear-gradient(135deg, #6036e8, #ca3fa0);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
[data-theme="light"] .header-logo { color: var(--text-primary); text-shadow: none; }

.header-sep { width: 1px; height: 28px; background: linear-gradient(180deg, transparent, var(--border-hover), transparent); }
.header-course { color: var(--text-secondary); font-size: 14px; font-weight: 500; text-decoration: none; transition: color 0.2s; }
.header-course:hover { color: var(--text-primary); }

.header-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.progress-wrap { display: flex; align-items: center; gap: 12px; }
.progress-ring { width: 36px; height: 36px; position: relative; }
.progress-ring svg { transform: rotate(-90deg); width: 36px; height: 36px; }
.progress-ring .ring-bg { fill: none; stroke: var(--border-subtle); stroke-width: 3; }
.progress-ring .ring-fill { fill: none; stroke: url(#progressGrad); stroke-width: 3; stroke-linecap: round; transition: stroke-dashoffset 0.6s var(--ease-out); }
.progress-pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--text-secondary); }
.progress-text { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.header-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: white;
  box-shadow: 0 0 0 2px rgba(96,54,232,0.3);
}
[data-theme="light"] .header-avatar { box-shadow: 0 0 0 2px rgba(96, 54, 232, 0.15); }

/* Hub nav link */
.header-hub {
  color: var(--text-muted); font-size: 12px; font-weight: 500; text-decoration: none;
  transition: color 0.2s; padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--border-subtle);
}
.header-hub:hover { color: var(--text-primary); border-color: var(--border-hover); }

/* Back button (mobile) */
.header-back {
  display: none; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px;
  color: var(--text-secondary); text-decoration: none;
  transition: background 0.2s, color 0.2s; flex-shrink: 0;
}
.header-back:hover { background: var(--bg-hover); color: var(--text-primary); }

/* User menu */
#wg-user-menu { display: none; align-items: center; gap: 10px; margin-left: auto; }
#wg-user-name { display: none; color: var(--text-secondary); font-size: 0.85rem; font-weight: 500; }
#wg-logout-btn {
  background: none; border: 1px solid var(--border-subtle); color: var(--text-muted);
  padding: 6px 14px; border-radius: 8px; font-size: 0.8rem; cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease; font-family: inherit;
}
#wg-logout-btn:hover { border-color: var(--border-hover); color: var(--text-primary); }
#wg-login-btn {
  min-height: 44px; min-width: 44px; padding: 10px 20px;
  font-size: 0.85rem; color: var(--text-secondary); text-decoration: none;
  display: flex; align-items: center;
}


/* ── Sidebar ───────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: var(--header-height); left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: rgba(30, 25, 45, 0.92); backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto; z-index: 90;
  transition: transform 0.35s var(--ease-out);
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
[data-theme="light"] .sidebar {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 1px 0 8px rgba(0, 0, 0, 0.03);
}
.sidebar::before {
  content: ''; position: absolute; top: 0; right: -1px; bottom: 0; width: 1px;
  background: linear-gradient(180deg, transparent, rgba(96,54,232,0.25) 30%, rgba(202,63,160,0.2) 70%, transparent);
  z-index: 1; pointer-events: none;
}
.sidebar::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 200px;
  background: radial-gradient(ellipse at 50% 0%, rgba(96,54,232,0.06), transparent 65%);
  pointer-events: none; z-index: 0;
}
[data-theme="light"] .sidebar::before { background: linear-gradient(180deg, transparent, rgba(96, 54, 232, 0.1) 30%, rgba(202, 63, 160, 0.06) 70%, transparent); }
[data-theme="light"] .sidebar::after { background: radial-gradient(ellipse at 50% 0%, rgba(96, 54, 232, 0.03), transparent 65%); }

.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

.sidebar-header { padding: 20px 22px 16px; border-bottom: none; }
.sidebar-header h3 { font-family: var(--font-display); font-size: 16px; font-weight: 700; color: var(--text-primary); margin-bottom: 2px; }
.sidebar-header span { font-size: 12px; color: var(--text-muted); }

/* Sidebar stone row: compact earned stones below course name */
.sidebar-stones {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  min-height: 0;
}
.sidebar-stones:empty { display: none; }

.module-group { border-bottom: none; }
.module-header {
  padding: 16px 22px 10px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.5px;
  display: flex; align-items: center; gap: 10px;
  cursor: default; text-shadow: 0 0 20px currentColor;
}
.module-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.lesson-item {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 22px; text-decoration: none;
  transition: all 0.25s var(--ease-out);
  border-left: 3px solid transparent; position: relative;
  opacity: 0; animation: fadeUp 0.4s var(--ease-out) both;
}
.lesson-item:hover { background: var(--bg-hover); box-shadow: inset 0 0 30px rgba(96,54,232,0.04), 0 0 0 1px rgba(96,54,232,0.06); }
.lesson-item:focus-visible { outline: 2px solid var(--pink); outline-offset: -2px; }
.lesson-item.active { background: rgba(96, 54, 232, 0.12); border-left-color: var(--purple); }
.lesson-item.active::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--purple), var(--pink)); border-radius: 0 2px 2px 0;
}

.lesson-num {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border-subtle);
  color: var(--text-muted); flex-shrink: 0; transition: all 0.25s var(--ease-spring);
}
[data-theme="light"] .lesson-num { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.08); }
.lesson-item.active .lesson-num { background: var(--purple); border-color: var(--purple); color: white; box-shadow: 0 0 16px rgba(96,54,232,0.4); }
.lesson-item.completed .lesson-num { background: rgba(52, 211, 153, 0.15); border-color: rgba(52, 211, 153, 0.3); color: var(--green); }
[data-theme="light"] .lesson-item.completed .lesson-num { background: rgba(5, 150, 105, 0.08); border-color: rgba(5, 150, 105, 0.2); }
.lesson-item.completed .lesson-num-text { display: none; }
.lesson-item.completed .lesson-check { display: flex; }
.lesson-check { display: none; align-items: center; justify-content: center; }
.lesson-item.just-completed .lesson-num { animation: checkIn 0.4s var(--ease-spring) both; }

.lesson-title-text { font-size: 14px; color: var(--text-secondary); line-height: 1.4; transition: color 0.2s; }
.lesson-item.active .lesson-title-text { color: var(--text-primary); font-weight: 500; }

/* Sidebar progress */
.sidebar-progress { padding: 12px 22px; border-bottom: 1px solid var(--border-subtle); display: flex; align-items: center; gap: 10px; }
.sidebar-progress-bar { flex: 1; height: 4px; background: var(--border-subtle); border-radius: 2px; overflow: hidden; }
.sidebar-progress-fill { height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--green), #34d399); transition: width 0.6s var(--ease-out); min-width: 2px; }
.sidebar-progress-text { font-size: 11px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }

/* Sidebar mentorship */
.sidebar-mentorship { padding: 20px 22px; border-top: 1px solid var(--border-subtle); margin-top: auto; }
.sidebar-mentorship-title { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.sidebar-mentorship-desc { font-size: 11px; color: var(--text-muted); line-height: 1.4; margin-bottom: 8px; }
.sidebar-mentorship-link { font-size: 12px; font-weight: 600; color: var(--purple); text-decoration: none; transition: all 0.2s; opacity: 0.8; }
.sidebar-mentorship-link:hover { opacity: 1; }
.sidebar-back-link { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); text-decoration: none; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border-subtle); transition: color 0.2s; }
.sidebar-back-link:hover { color: var(--text-secondary); }
.sidebar-back-link svg { vertical-align: middle; margin-right: 4px; }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: var(--sidebar-overlay); backdrop-filter: blur(4px); z-index: 91; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.sidebar-overlay.show { display: block; }

/* Sidebar must be above overlay when open */
.sidebar.open { z-index: 92; }


/* ── Main Content Area ─────────────────────────────────────────────── */
.main {
  position: relative; z-index: 1;
  margin-left: var(--sidebar-width); margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
  background: rgba(30, 25, 45, 0.55); backdrop-filter: blur(40px) saturate(180%) brightness(1.05);
  -webkit-backdrop-filter: blur(40px) saturate(180%) brightness(1.05);
  -webkit-overflow-scrolling: touch;
}
[data-theme="light"] .main { background: rgba(248, 246, 243, 0.6); backdrop-filter: blur(40px) saturate(120%); -webkit-backdrop-filter: blur(40px) saturate(120%); }

.lesson-container {
  max-width: 860px; margin: 32px auto; padding: 48px 56px 100px;
  position: relative; overflow: hidden;
  background: var(--bg-card); backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.lesson-container::before {
  content: ''; position: absolute; top: 0; left: 5%; right: 5%; height: 2px;
  background: var(--glass-line); filter: blur(0.5px); z-index: 1;
}
.lesson-container::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 200px;
  background: radial-gradient(ellipse at 50% 0%, rgba(96,54,232,0.06), transparent 65%);
  pointer-events: none; z-index: 0;
}
[data-theme="light"] .lesson-container::after { background: radial-gradient(ellipse at 50% 0%, rgba(96, 54, 232, 0.02), transparent 65%); }


/* ── Mobile Bottom Nav ─────────────────────────────────────────────── */
/* Hide bottom nav on all lesson pages at all screen sizes */
.wg-lesson-page .mobile-bottom-nav { display: none !important; }

.mobile-bottom-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; height: 56px;
  background: rgba(30, 25, 45, 0.95); backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--border-subtle); z-index: 100;
  justify-content: space-around; align-items: center; padding: 0 8px;
  transition: transform 0.3s ease;
}
.mobile-bottom-nav::before {
  content: ''; position: absolute; top: -1px; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent 0%, rgba(96,54,232,0.3) 30%, rgba(202,63,160,0.25) 70%, transparent 100%);
  filter: blur(0.5px);
}
[data-theme="light"] .mobile-bottom-nav {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.04);
}
.mobile-bottom-nav.nav-hidden { transform: translateY(100%); }
.mobile-nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-decoration: none; color: var(--text-muted);
  font-size: 11px; font-weight: 600; padding: 6px 12px; border-radius: 8px; transition: all 0.2s;
}
.mobile-nav-item:hover, .mobile-nav-item.active { color: var(--purple); background: var(--bg-hover); }
.mobile-nav-item svg { width: 20px; height: 20px; }


/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: block; }
  .lesson-container { padding: 36px 28px 80px; }
  .header-course { display: none; }
  .header-sep { display: none; }
  .mobile-bottom-nav { display: flex; }
  .wg-lesson-page .mobile-bottom-nav { display: none !important; }
  .lesson-container { padding-bottom: 120px; }
  .header-back { display: flex; }
}
@media (max-width: 767px) {
  /* On phone-size screens, hide the old Lessons/Watch/Resources nav
     when the lesson action bar (Prev/Complete/Next) is present */
  .wg-lesson-page .mobile-bottom-nav { display: none !important; }
}
@media (max-width: 600px) {
  .lesson-container { padding: 28px 20px 120px; }
  .progress-text { display: none; }
}

/* ── iOS Safe Areas ────────────────────────────────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .mobile-bottom-nav { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .lesson-container { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
}

/* ── Sticky Video (mobile) ─────────────────────────────────────────── */
@media (max-width: 1024px) {
  .lesson-container { overflow: clip; }
  #wg-video-slot .vimeo-embed {
    position: sticky; top: 64px; z-index: 10;
    margin-left: -20px; margin-right: -20px; width: calc(100% + 40px);
    border-radius: 0; transition: box-shadow 0.3s ease;
  }
  #wg-video-slot .vimeo-embed.is-stuck { box-shadow: 0 8px 32px rgba(0,0,0,0.6); }
}
@media (max-width: 600px) {
  #wg-video-slot .vimeo-embed { margin-left: -20px; margin-right: -20px; width: calc(100% + 40px); }
}


/* ══════════════════════════════════════════════════════════════════════
   FEATURE: Mobile Lesson Action Bar (Prev / Mark Complete / Next)
   Only visible on screens < 768px. Replaces the old mobile-bottom-nav
   content with lesson-specific actions.
   ══════════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  /* Hide the inline Mark Complete button on mobile (bottom bar replaces it) */
  .mark-complete-wrap { display: none; }

  /* The action bar container */
  .mobile-lesson-bar {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: 56px;
    background: rgba(30, 25, 45, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid var(--border-subtle);
    z-index: 110;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 12px;
    transition: transform 0.3s ease;
  }
  .mobile-lesson-bar::before {
    content: ''; position: absolute; top: -1px; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, transparent 0%, rgba(96,54,232,0.3) 30%, rgba(202,63,160,0.25) 70%, transparent 100%);
    filter: blur(0.5px);
  }
  [data-theme="light"] .mobile-lesson-bar {
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.04);
  }
  .mobile-lesson-bar.bar-hidden { transform: translateY(100%); }

  /* Shared button base */
  .mlb-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 10px 14px; min-height: 40px;
    border-radius: 10px; border: 1px solid var(--border-subtle);
    background: transparent; color: var(--text-secondary);
    font-size: 13px; font-weight: 600; font-family: inherit;
    cursor: pointer; text-decoration: none;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .mlb-btn:active { transform: scale(0.96); }
  .mlb-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

  /* Ghost prev/next */
  .mlb-prev, .mlb-next {
    flex: 0 0 auto;
  }
  .mlb-prev:hover, .mlb-next:hover {
    border-color: var(--border-hover); background: var(--bg-hover);
  }
  .mlb-prev.mlb-disabled, .mlb-next.mlb-disabled {
    opacity: 0.3; pointer-events: none;
  }

  /* Mark Complete center button */
  .mlb-complete {
    flex: 1 1 auto; max-width: 200px;
    justify-content: center;
    border: none;
    background: linear-gradient(135deg, var(--purple), var(--pink));
    color: #fff;
    box-shadow: 0 4px 16px rgba(96, 54, 232, 0.3);
  }
  .mlb-complete:hover { box-shadow: 0 4px 20px rgba(96, 54, 232, 0.45); }
  .mlb-complete:active { transform: scale(0.96); }

  /* Completed state */
  .mlb-complete.mlb-done {
    background: rgba(52, 211, 153, 0.15);
    color: var(--green);
    box-shadow: none;
    pointer-events: none;
  }
  [data-theme="light"] .mlb-complete.mlb-done {
    background: rgba(5, 150, 105, 0.1);
  }

  /* Celebrating pulse */
  .mlb-complete.mlb-celebrating {
    animation: mlbPulse 0.35s var(--ease-spring);
  }
  @keyframes mlbPulse {
    0% { transform: scale(1); }
    40% { transform: scale(1.06); }
    100% { transform: scale(1); }
  }
}

/* iOS safe area for the lesson bar */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 767px) {
    .mobile-lesson-bar {
      height: calc(56px + env(safe-area-inset-bottom));
      padding-bottom: env(safe-area-inset-bottom);
    }
  }
}


/* ══════════════════════════════════════════════════════════════════════
   FEATURE: Floating Mini-Player (mobile only, < 768px)
   When the video scrolls out of view, a small floating player appears
   above the lesson action bar.
   ══════════════════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  /* When mini-player is active, remove the sticky behavior */
  .mini-player-active #wg-video-slot .vimeo-embed {
    position: relative !important; top: auto !important;
  }

  /* Placeholder shown in the original video spot */
  .video-placeholder {
    width: 100%; aspect-ratio: 16/9;
    background: rgba(30, 25, 45, 0.6);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 13px; font-weight: 500;
  }
  [data-theme="light"] .video-placeholder {
    background: rgba(0, 0, 0, 0.04);
  }

  /* The floating mini-player */
  .wg-mini-player {
    position: fixed;
    bottom: 80px; /* above the 56px bar + gap */
    right: 12px;
    width: 40%; aspect-ratio: 16/9;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 105;
    overflow: hidden;
    transform: translateY(20px) scale(0.9);
    opacity: 0;
    transition: transform 0.35s var(--ease-out), opacity 0.35s ease;
    pointer-events: none;
  }
  .wg-mini-player.visible {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
  }
  .wg-mini-player iframe {
    width: 100%; height: 100%; border: none; display: block;
  }

  /* Close button on mini-player */
  .wg-mini-player-close {
    position: absolute; top: 4px; right: 4px;
    width: 24px; height: 24px; border-radius: 50%;
    background: rgba(0, 0, 0, 0.6); border: none;
    color: #fff; font-size: 14px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 2;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
  }
  .wg-mini-player-close:hover { background: rgba(0, 0, 0, 0.8); }
}

/* iOS safe area offset for mini-player */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 767px) {
    .wg-mini-player {
      bottom: calc(68px + env(safe-area-inset-bottom));
    }
  }
}


/* ══════════════════════════════════════════════════════════════════════
   LIGHT THEME — Apple-Level Overrides (Layout)
   ══════════════════════════════════════════════════════════════════════ */

/* Sidebar overlay: soft dim */
[data-theme="light"] .sidebar-overlay.show { background: rgba(0,0,0,0.12); }

/* Mini player */
[data-theme="light"] .wg-mini-player { border-color: rgba(0,0,0,0.08); background: rgba(255,255,255,0.95); }

/* Header course/hub links */
[data-theme="light"] .header-hub:hover { background: rgba(96,54,232,0.06); }
[data-theme="light"] .header-course { color: var(--text-secondary); }
