/* ==========================================================================
   AI Training Crash Course — stylesheet
   Palette (kept deliberately restrained, per brief):
     --purple-primary   #4A154B  headers, active nav state, primary buttons
     --purple-secondary #836FFF  hover states, links, progress indicator
     --charcoal          #1D1C1D  body text (never pure black)
     white                background throughout
   ========================================================================== */

:root {
  --purple-primary: #4A154B;
  --purple-secondary: #836FFF;
  --charcoal: #1D1C1D;
  --border: #E7E1E8;
  --sidebar-bg: #FBFAFC;
  --sidebar-width: 300px;
  --mobile-bar-height: 56px;
  --max-content-width: 760px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #FFFFFF;
  color: var(--charcoal);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--purple-secondary); text-decoration: none; }
a:hover, a:focus { text-decoration: underline; }

h1, h2, h3, h4 { color: var(--purple-primary); line-height: 1.3; }
h1 { font-size: 1.9rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.35rem; margin: 2rem 0 0.75rem; }
h3 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
p { margin: 0 0 1rem; }
ul, ol { margin: 0 0 1rem; padding-left: 1.4rem; }
li { margin-bottom: 0.4rem; }

code {
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
  font-size: 0.9em;
}

/* --------------------------------------------------------------------
   Layout shell
   -------------------------------------------------------------------- */

.layout {
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
}

/* --------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------- */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  min-height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  overflow-y: auto;
}

.sidebar__top {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar__logo {
  display: block;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--purple-primary);
  line-height: 1.25;
  margin-bottom: 1rem;
}
.sidebar__logo:hover { text-decoration: none; opacity: 0.85; }

.back-to-courses {
  display: inline-block;
  font-size: 0.78rem;
  color: #6b6a6b;
  margin-bottom: 0.85rem;
}
.back-to-courses:hover { color: var(--purple-secondary); }
.back-to-courses--centered { display: block; text-align: center; margin-bottom: 1.5rem; }

.progress-wrap__label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--charcoal);
  margin-bottom: 0.35rem;
}
.progress-wrap__label #progressPercent {
  color: var(--purple-primary);
  font-weight: 700;
}

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar__fill {
  height: 100%;
  background: var(--purple-secondary);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.sidebar__nav {
  padding: 0.5rem 0.75rem 2rem;
}

.nav-chapter { margin-bottom: 0.25rem; }

.nav-chapter__title {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--charcoal);
  padding: 0.6rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
}
.nav-chapter__title:hover { background: #F1ECF2; text-decoration: none; }
.nav-chapter__title.is-active-chapter { color: var(--purple-primary); }

.nav-chapter__sections {
  list-style: none;
  margin: 0 0 0.25rem;
  padding: 0;
}

.nav-section a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.5rem 0.45rem 1.5rem;
  border-radius: 6px;
  font-size: 0.88rem;
  color: var(--charcoal);
}
.nav-section a:hover { background: #F1ECF2; text-decoration: none; color: var(--purple-secondary); }
.nav-section a.is-active {
  background: var(--purple-primary);
  color: #FFFFFF;
  font-weight: 600;
}
.nav-section a.is-active:hover { color: #FFFFFF; }

.nav-section__check {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid #C9C0CB;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: transparent;
}
.nav-section.is-complete .nav-section__check {
  background: var(--purple-secondary);
  border-color: var(--purple-secondary);
  color: #FFFFFF;
}
.nav-section a.is-active .nav-section__check {
  border-color: #FFFFFF;
}
.nav-section a.is-active.is-complete-active .nav-section__check {
  background: #FFFFFF;
  color: var(--purple-primary);
}

/* Sidebar backdrop for mobile */
.sidebar-backdrop {
  display: none;
}

/* --------------------------------------------------------------------
   Mobile top bar + hamburger
   -------------------------------------------------------------------- */

.mobile-bar {
  display: none;
  align-items: center;
  gap: 0.75rem;
  height: var(--mobile-bar-height);
  padding: 0 1rem;
  background: #FFFFFF;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.mobile-bar__title {
  font-weight: 700;
  color: var(--purple-primary);
  font-size: 1rem;
}

.hamburger {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  padding: 0;
}
.hamburger span {
  display: block;
  height: 2px;
  background: var(--purple-primary);
  border-radius: 2px;
}

/* --------------------------------------------------------------------
   Main content
   -------------------------------------------------------------------- */

.content {
  flex: 1;
  min-width: 0;
  padding: 3rem 2.5rem 4rem;
  max-width: var(--max-content-width);
  margin: 0 auto;
}

.learn-line {
  font-size: 0.95rem;
  color: var(--purple-primary);
  background: #F6F1F7;
  border-left: 3px solid var(--purple-secondary);
  padding: 0.6rem 0.9rem;
  border-radius: 4px;
  margin-bottom: 1.75rem;
}

.section-body { margin-bottom: 2rem; }

.example-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  margin: 1rem 0;
}
.example-box--weak { border-left: 4px solid #C9C0CB; }
.example-box--strong { border-left: 4px solid var(--purple-secondary); }
.example-box p { margin: 0; }
.example-box strong.tag {
  display: inline-block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--purple-primary);
  margin-bottom: 0.4rem;
}

.resource-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin: 1.25rem 0;
  background: var(--sidebar-bg);
}
.resource-card h3 { margin-top: 0; }

.callout {
  background: #F6F1F7;
  border-radius: 8px;
  padding: 1rem 1.1rem;
  margin: 1.25rem 0;
}

/* Buttons */

.btn {
  display: inline-block;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.65rem 1.2rem;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: center;
}
.btn:hover { text-decoration: none; }

.btn--primary {
  background: var(--purple-primary);
  color: #FFFFFF;
}
.btn--primary:hover { background: #5c1b5e; color: #FFFFFF; }

.btn--secondary {
  background: #FFFFFF;
  color: var(--purple-primary);
  border-color: var(--purple-primary);
}
.btn--secondary:hover { background: #F6F1F7; }

.btn--complete {
  background: #FFFFFF;
  color: var(--purple-primary);
  border-color: var(--purple-secondary);
}
.btn--complete:hover { background: #F6F1F7; }
.btn--complete.is-complete {
  background: var(--purple-secondary);
  color: #FFFFFF;
  border-color: var(--purple-secondary);
}

.section-actions {
  margin: 1.5rem 0;
}

/* Previous / Next */

.prev-next {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.prev-next__link {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  color: var(--charcoal);
  font-weight: 600;
}
.prev-next__link:hover {
  border-color: var(--purple-secondary);
  color: var(--purple-secondary);
  text-decoration: none;
}
.prev-next__link--next { text-align: right; }
.prev-next__link span { display: block; font-size: 0.75rem; font-weight: 400; color: #6b6a6b; margin-top: 0.15rem; }

.summary-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #F6F1F7;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
}
.summary-banner p { margin: 0; max-width: 32rem; }

/* --------------------------------------------------------------------
   Homepage (index.html) specific styles
   -------------------------------------------------------------------- */

.home {
  max-width: 880px;
  margin: 0 auto;
  padding: 4rem 1.5rem 5rem;
  text-align: center;
}
.home__eyebrow {
  color: var(--purple-secondary);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
}
.home h1 { font-size: 2.3rem; margin-bottom: 1rem; }
.home__lede {
  font-size: 1.1rem;
  color: var(--charcoal);
  max-width: 40rem;
  margin: 0 auto 2.75rem;
}

.entry-points {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  text-align: left;
}

.entry-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
}
.entry-card h2 {
  margin-top: 0;
  font-size: 1.2rem;
}
.entry-card__meta {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--purple-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}
.entry-card p { flex: 1; color: var(--charcoal); }
.entry-card .btn { align-self: flex-start; margin-top: 0.5rem; }

.home__footnote {
  margin-top: 3rem;
  font-size: 0.85rem;
  color: #6b6a6b;
}

/* --------------------------------------------------------------------
   Responsive: mobile-first breakpoints
   -------------------------------------------------------------------- */

@media (max-width: 860px) {
  .content { padding: 2rem 1.5rem 3rem; }
  .entry-points { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .mobile-bar { display: flex; }

  .layout { display: block; }

  .sidebar {
    position: fixed;
    top: var(--mobile-bar-height);
    left: 0;
    bottom: 0;
    width: 85%;
    max-width: 320px;
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: 2px 0 12px rgba(29, 28, 29, 0.15);
  }
  .sidebar.is-open { transform: translateX(0); }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: var(--mobile-bar-height) 0 0 0;
    background: rgba(29, 28, 29, 0.35);
    z-index: 35;
  }
  .sidebar-backdrop.is-open { display: block; }

  .content { max-width: 100%; }

  .prev-next { flex-direction: column; }
  .prev-next__link--next { text-align: left; }
}

@media (max-width: 480px) {
  .home h1 { font-size: 1.7rem; }
  .home__lede { font-size: 1rem; }
}

/* --------------------------------------------------------------------
   Access gate (password modal for the Full Course)
   -------------------------------------------------------------------- */

body.gate-locked .layout,
body.gate-locked .mobile-bar {
  display: none;
}

.gate-overlay {
  position: fixed;
  inset: 0;
  background: rgba(29, 28, 29, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1.5rem;
}

.gate-modal {
  background: #FFFFFF;
  border-radius: 12px;
  max-width: 420px;
  width: 100%;
  padding: 2rem;
  box-shadow: 0 24px 60px rgba(29, 28, 29, 0.25);
}

.gate-modal h2 {
  margin-top: 0;
  font-size: 1.3rem;
}

.gate-modal p {
  font-size: 0.92rem;
  color: var(--charcoal);
}

.gate-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--charcoal);
  margin: 0.9rem 0 0.3rem;
}
.gate-modal form > .gate-label:first-child { margin-top: 0.5rem; }

.gate-modal #gateEmail,
.gate-modal #gatePassword {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--charcoal);
}
.gate-modal #gateEmail:focus,
.gate-modal #gatePassword:focus {
  outline: none;
  border-color: var(--purple-secondary);
}

.gate-error {
  color: #C0392B;
  font-size: 0.85rem;
  margin: 0.6rem 0 0;
}

/* --------------------------------------------------------------------
   Signed-in-as / sign-out (sidebar)
   -------------------------------------------------------------------- */

.signed-in-as {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.76rem;
  color: #6b6a6b;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.85rem;
}
.signed-in-as__email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.signed-in-as__signout {
  background: none;
  border: none;
  color: var(--purple-secondary);
  font-size: 0.76rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  flex-shrink: 0;
  padding: 0;
}
.signed-in-as__signout:hover { color: var(--purple-primary); }

.gate-submit {
  width: 100%;
  margin-top: 0.25rem;
}

.gate-help {
  font-size: 0.82rem;
  color: #6b6a6b;
  margin-top: 1.25rem;
  margin-bottom: 0;
}

.gate-cancel {
  display: block;
  margin: 0.85rem auto 0;
  background: none;
  border: none;
  color: #6b6a6b;
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
}
.gate-cancel:hover { color: var(--purple-secondary); }
