/* ============================================================
   layout.css — Header, Sidebar, Main, Footer, Responsive
   ============================================================ */

/* --- Progress Bar (top of page) --- */
#progress-bar {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  height: var(--progress-height);
  background: rgba(224, 122, 95, 0.18);
  z-index: 1000;
}

#progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent));
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 0 2px 2px 0;
}

/* --- Header --- */
#main-header {
  position: fixed;
  top: var(--progress-height);
  right: 0;
  left: 0;
  height: var(--header-height);
  background: var(--bg-card);
  box-shadow: 0 2px 12px var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 900;
  gap: 16px;
}

.logo {
  font-family: 'Heebo', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  flex-shrink: 0;
  text-decoration: none;
}

.logo:hover {
  color: var(--accent);
}

#progress-text {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-warm);
  padding: 4px 12px;
  border-radius: 20px;
  white-space: nowrap;
  margin-right: auto;
}

/* --- Hamburger Button --- */
#hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-size: 1.4rem;
  color: var(--text-primary);
  background: transparent;
  transition: background var(--transition);
  flex-shrink: 0;
  order: -1;
}

#hamburger-btn:hover {
  background: var(--bg-warm);
}

/* --- Sidebar --- */
#sidebar {
  position: fixed;
  top: calc(var(--progress-height) + var(--header-height));
  right: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--progress-height) - var(--header-height));
  background: var(--bg-warm);
  border-right: 1px solid rgba(156, 132, 112, 0.18);  /* border-right = in RTL this is the inner edge */
  border-left: 1px solid rgba(156, 132, 112, 0.12);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 800;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 20px 18px 12px;
  border-bottom: 1px solid rgba(156, 132, 112, 0.18);
  flex-shrink: 0;
}

.sidebar-header h2 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 16px 4px;
  opacity: 0.7;
}

/* --- Sidebar List Items --- */
#sidebar-list {
  flex: 1;
  padding: 8px 0 20px;
}

#sidebar-list li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 400;
  color: var(--text-soft);
  text-decoration: none;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  position: relative;
  line-height: 1.4;
}

#sidebar-list li a:hover {
  background: rgba(224, 122, 95, 0.1);
  color: var(--text-primary);
}

/* Status indicator dot/check */
#sidebar-list li a .status-indicator {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  border-radius: 50%;
}

/* Completed lesson */
#sidebar-list li.section-completed > a {
  color: var(--text-soft);
}

#sidebar-list li.section-completed > a .status-indicator {
  background: var(--herb);
  color: #fff;
  font-size: 0.7rem;
}

#sidebar-list li.section-completed > a .status-indicator::after {
  content: '✓';
}

/* Active lesson */
#sidebar-list li.section-active > a {
  color: var(--accent-dark);
  font-weight: 600;
  background: rgba(224, 122, 95, 0.08);
}

#sidebar-list li.section-active > a .status-indicator {
  background: var(--accent);
  border-radius: 50%;
}

#sidebar-list li.section-active > a .status-indicator::after {
  content: '●';
  color: #fff;
  font-size: 0.5rem;
}

/* Active indicator bar on right side (RTL: right = start) */
#sidebar-list li.section-active > a::before {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

/* Todo lesson */
#sidebar-list li.section-todo > a {
  color: var(--text-muted);
}

#sidebar-list li.section-todo > a .status-indicator {
  border: 1.5px solid var(--text-muted);
  opacity: 0.5;
}

#sidebar-list li.section-todo > a .status-indicator::after {
  content: '';
}

.sidebar-lesson-num {
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 22px;
}

/* --- Sidebar Overlay (mobile) --- */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(61, 40, 23, 0.45);
  z-index: 799;
  backdrop-filter: blur(2px);
}

/* --- Main Content --- */
#main-content {
  margin-right: var(--sidebar-width);
  padding-top: calc(var(--progress-height) + var(--header-height) + 40px);
  padding-left: 40px;
  padding-right: 48px;
  padding-bottom: 80px;
  min-height: 100vh;
}

/* --- Hero Section (home) --- */
.hero {
  padding: 40px 0 32px;
  border-bottom: 2px solid rgba(156, 132, 112, 0.12);
  margin-bottom: 40px;
}

.hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.25;
  margin-bottom: 12px;
}

.hero-sub {
  font-size: 1.05rem;
  color: var(--text-soft);
  margin: 0;
}

/* --- Course Section (home) --- */
.course-section {
  margin-bottom: 48px;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--bg-warm);
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 1.2em;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}

/* --- Lesson Grid --- */
.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

/* --- Footer --- */
footer {
  text-align: center;
  padding: 24px 24px 32px;
  color: var(--text-muted);
  font-size: 0.82rem;
  border-top: 1px solid rgba(156, 132, 112, 0.12);
  margin-right: var(--sidebar-width);
}

footer p {
  color: var(--text-muted);
  margin: 0;
}

/* ============================================================
   Responsive — Mobile / Tablet
   ============================================================ */
@media (max-width: 768px) {
  html {
    font-size: 16px;
  }

  /* Show hamburger */
  #hamburger-btn {
    display: flex;
  }

  /* Sidebar becomes off-canvas drawer from the right */
  #sidebar {
    top: 0;
    height: 100vh;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    box-shadow: -4px 0 24px rgba(61, 40, 23, 0.18);
    padding-top: calc(var(--progress-height) + var(--header-height));
  }

  /* Open state */
  #sidebar.sidebar-open {
    transform: translateX(0);
  }

  /* Show overlay when open */
  #sidebar-overlay.visible {
    display: block;
  }

  /* Main content full width */
  #main-content {
    margin-right: 0;
    padding-left: 20px;
    padding-right: 20px;
    padding-top: calc(var(--progress-height) + var(--header-height) + 24px);
    padding-bottom: 60px;
  }

  .hero h1 {
    font-size: 1.6rem;
  }

  .lesson-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  footer {
    margin-right: 0;
  }

  #progress-text {
    display: none;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  #main-content {
    padding-left: 24px;
    padding-right: 32px;
  }

  .lesson-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}
