/* =========================
   THEME TOKENS
   ========================= */

/* Light */
:root {
  --bg: #f9fbfc;
  --card: #ffffff;
  --text: #222;
  --muted: #6b7280;
  --line: #e5e7eb;
  /* Or black/grey characters */
  --accent: #181b19;
  /* Blue characters */
  /* --accent: #2563eb; */
  /* New purple buttons */
  --button-accent: #846bff;
  /* Purple accent-strong */
  --accent-strong: #684AE0;
  /* --accent-strong: #1e40af; */
  --accent-soft: #eef2ff;
  --success: #16a34a;
  --success-strong: #166534;
}

/* Dark (black + purple) */
body.dark {
  --bg: #111111;
  --card: #1f1f1f;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --line: #2d2d2d;
  --accent: #967EFC;        /* purple accent */
  --accent-strong: #5a3ae6; /* hover purple */
  --accent-soft: #2a2147;   /* soft bg */
  --success: #a78bfa;
  --success-strong: #8b5cf6;
}

/* =========================
   BASE / LAYOUT
   ========================= */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/Inter-4.1/InterVariable.ttf") format('truetype-variations'),
       url("/static/fonts/Inter-4.1/web/Inter-Regular.woff2") format('woff2');
}

html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  line-height: 1.6;
}

.page {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 2rem;
  box-sizing: border-box;
}

.content { flex: 1; }

/* Footer */
.footer {
  border-top: 1px solid var(--line);
  padding: 1rem;
  text-align: center;
  background: var(--card);
  color: var(--muted);
}

/* Header */
header {
  background: var(--bg);        /* match page background */
  /* border-bottom: 1px solid var(--line);  */
  padding: 1rem;
  font-size: 0.9em;
}

/* footer  */
footer {
  background: var(--card);  
  border-top: 1px solid var(--line);
  padding: 1rem;
  text-align: center;
  color: var(--muted);
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -.01em;
}

/* Links */

a { text-decoration: none; transition: color .2s ease, background .2s ease; }
body:not(.dark) a { color: var(--accent); }
body:not(.dark) a:hover { text-decoration: underline; }
body.dark a { color: #6D4AFF; }
body.dark a:hover { color: color-mix(in oklab, #6D4AFF 80%, white); }

/* Nav bar */
.nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

.nav-home {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--accent);
}

.nav-home:hover {
  text-decoration: none;
  opacity: 0.85;
}

/* Navbar left section (logo + company name) */
.nav-left {
  display: flex;
  align-items: center;   /* vertically center logo + text */
  gap: 0.2rem;           /* space between logo and text */
}

.navbar-logo {
  height: 92px;          /* consistent height for logo */
  width: auto;           /* keep aspect ratio */
  display: block;
  text-decoration: none;
}

.nav-left span {
  font-weight: 600;
  font-size: 1.50rem;
  color: var(--accent);
}

.site-title { flex: 2; margin: 0; text-align: center; font-size: 1.5rem; line-height: 1.3; }
.site-title a { color: var(--accent); }
.nav-right { flex: 1; display: flex; justify-content: flex-end; align-items: center; gap: .75rem; }

/* Logo */
.logo {
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.01em;
}

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

.link-btn {
  background: none; border: none; color: var(--accent); cursor: pointer; font-weight: 500; padding: 0;
}
.link-btn:hover { color: var(--button-accent); }
.btn-ghost {
  border: 1px solid var(--line); background: var(--card); color: var(--accent);
  padding: .35rem .7rem; border-radius: 6px;
}
.btn-ghost:hover { border-color: var(--accent); }
.icon-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 50%; width: 2.1rem; height: 2.1rem; display: inline-grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); }
.user-pill { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Containers */
.container { max-width: 960px; margin: 2rem auto; padding: 0 1rem; }
.module-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

button {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: .45rem .9rem; font-weight: 600; cursor: pointer; transition: background .2s;
}
button:hover { background: var(--accent-strong); }
button.completed { background: var(--success); }
button.completed:hover { background: var(--success-strong); }

/* =========================
   LANDING / CARDS
   ========================= */

.hero {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 3rem 1.5rem;
  box-shadow: none;
  box-shadow: 0 2px 6px rgba(0,0,0,.06);
  margin-bottom: 2rem;
}
.hero-inner { max-width: 960px; margin: 0 auto; text-align: center; }
.hero-title { font-size: 2.25rem; line-height: 1.2; margin: 0 0 .75rem; color: var(--accent); }
.hero-tagline { color: var(--muted); margin: 0 auto 1.25rem; max-width: 720px; }
.hero-ctas { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }
button.btn-primary, .btn-primary {
  background: var(--button-accent); color: #fff !important; border: none; padding: .6rem 1rem; border-radius: 8px; font-weight: 600;
}
button.btn-primary:hover, .btn-primary:hover { background: var(--accent-strong); }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 400px));
  justify-content: center;   /* center cards if fewer than fill row */
  gap: 1.5rem;
}

.feature {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  max-width: 400px;   /* prevents it from being *too* wide */
  margin: 0 auto;     /* keeps it centered */
}

@media (max-width: 900px) { .features { grid-template-columns: 1fr; } }

/* Catalog course cards */
.feature h3 {
  margin: 0 0 .5rem;
  font-size: 1.4rem;       /* larger title */
  font-weight: 600;
  color: var(--accent);
}

.feature p {
  margin: 0.35rem 0;
  color: var(--muted);
  line-height: 1.5;
}

/* =========================
   COURSE PAGE LAYOUT
   ========================= */

.split {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1rem;
}
@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
}

/* Sidebar */
.split-sidebar {
  padding: 1rem;
  border-right: 1px solid var(--line);
  position: sticky;
  top: 1rem;
  height: fit-content;
  border-radius: 10px;
  background: var(--card);
}
body.dark .split-sidebar { border-color: #444; }

/* Module headers (details/summary) */

/* Kill I-beam on module titles and keep arrow cursor */
/* Kill I-beam on module titles and keep pointer cursor */
.split-sidebar * {
  cursor: pointer !important;
}

/* Hide native disclosure marker consistently */
.split-sidebar summary::-webkit-details-marker { display: none; }
.split-sidebar summary::marker { content: ""; }

.split-sidebar summary:hover,
.split-sidebar .mod-head:hover {
  background: rgba(0,0,0,0.05);
  border-radius: 6px;
}

body.dark .split-sidebar summary:hover,
body.dark .split-sidebar .mod-head:hover {
  background: rgba(255,255,255,0.08);
}


.split-sidebar details { margin-bottom: 0.75rem; }
.split-sidebar summary {
  cursor: pointer; font-weight: 600; padding: 0.25rem 0; list-style: none; position: relative; color: var(--accent);
}
.split-sidebar summary::marker { display: none; }
.split-sidebar summary::after {
  content: "▸"; position: absolute; right: 0; transition: transform .2s ease;
}
.split-sidebar details[open] summary::after { transform: rotate(90deg); }

/* Lessons */
.lesson-list { margin: 0.25rem 0 0.5rem 0.5rem; padding-left: 0; list-style: none; }
.lesson-list li { margin-bottom: 0.25rem; }

.lesson-link {
  display: block;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  color: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.lesson-link:hover { background: rgba(0,0,0,0.05); }
body.dark .lesson-link:hover { background: rgba(255,255,255,0.08); }

.lesson-link.is-active {
  background: var(--accent-soft);
  font-weight: 600;
}

.lesson-link .lesson-done {
  float: right; font-size: 0.75rem;
  color: #2b8a3e;
}
body.dark .lesson-link .lesson-done { color: #4ade80; }

/* =========================
   CONTENT PANEL (article)
   ========================= */

#content.split-content {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.course-title { font-family: Inter;
   font-size: 2rem;
   font-weight: 700;
   color: var(--accent);
   margin: 0 0 .5rem;
   letter-spacing: 0.05rem; 
  }

/* Markdown typography */
.md-body {
  max-width: 900px;
}
.md-body h1, .md-body h2, .md-body h3 {
  line-height: 1.25;
  margin: 1.25rem 0 .75rem;
}
.md-body h1 { font-size: 1.9rem; }
.md-body h2 { font-size: 1.6rem; }
.md-body h3 { font-size: 1.3rem; }
.md-body p { margin: .6rem 0; }
.md-body img { max-width: 100%; height: auto; border-radius: 6px; }
.md-body hr { border: none; border-top: 1px solid var(--line); margin: 1.25rem 0; }
.md-body ul, .md-body ol { margin: .6rem 0 .6rem 1.25rem; }
.md-body code, .md-body pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.md-body pre {
  background: var(--card);
  border: 1px solid var(--line);
  padding: .75rem;
  border-radius: 6px;
  overflow: auto;
}
.md-body blockquote {
  border-left: 4px solid var(--line);
  margin: .75rem 0;
  padding: .25rem .75rem;
  color: var(--muted);
}
.md-body table { border-collapse: collapse; width: 100%; }
.md-body th, .md-body td { border: 1px solid var(--line); padding: .4rem .5rem; text-align: left; }

/* HTMX indicator inside content */
#content .htmx-indicator { display: none; }
#content .htmx-request .htmx-indicator,
#content.htmx-request .htmx-indicator { display: block; }

/* =========================
   MISC
   ========================= */

.module-desc { color: var(--muted); margin:.5rem 0 1rem; }

/* content placeholder */

.placeholder {
  min-height: 55vh;
  display: grid;
  place-items: center;
  text-align: center;
  gap: .75rem;
  color: var(--muted);
}
.placeholder-art {
  width: 220px;
  height: auto;
  opacity: .9;
  margin-bottom: .25rem;
}
.placeholder h2 {
  margin: .25rem 0 0;
  color: var(--text);
}

/* =========================
   MOBILE VIEW
   ========================= */

/* Sooner single-column: tablets and down */
@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
}

/* Handset adjustments */
@media (max-width: 640px) {
  /* Global spacing & type */
  .page { padding: 1rem; }
  header { padding: .75rem 0; }
  .site-title { font-size: 1.2rem; }
  .md-body h1 { font-size: clamp(1.35rem, 4.5vw, 1.6rem); }
  .md-body h2 { font-size: clamp(1.15rem, 4vw, 1.35rem); }
  .md-body h3 { font-size: clamp(1rem, 3.5vw, 1.2rem); }
  body { line-height: 1.55; }

  /* Logo + brand tighter */
  .navbar-logo { height: 52px; }
  .nav-left span { font-size: 1.12rem; }

  /* Nav layout: menu button shows on mobile, actions collapse */
  .hide-desktop { display: inline-grid; }          /* the ☰ button */
  .nav-right { gap: .5rem; }
  .nav-actions { 
    position: absolute;
    top: 64px;                /* sits just under header */
    right: 1rem;
    left: 1rem;
    display: none;
    flex-direction: column;
    gap: .5rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: .75rem;
    box-shadow: 0 8px 20px rgba(0,0,0,.15);
    z-index: 20;
  }
  .nav-actions.open { display: flex; }

  /* Make links & buttons easier to tap */
  .link-btn, .btn-ghost, button, .icon-btn {
    min-height: 44px;
  }
  .btn-ghost, button { width: 100%; } /* stacked buttons fill width in menu */

  /* Keep theme button tappable without huge spacing */
  #theme-toggle { margin-left: .25rem; }

  /* Hero/cards: reduce padding, prevent over-wide cards */
  .hero { padding: 1.5rem 1rem; }
  .hero-title { font-size: 1.6rem; }
  .features { grid-template-columns: 1fr; gap: 1rem; }
  .feature { padding: 1rem; }

  /* Sidebar panel becomes unobtrusive */
  .split-sidebar {
    position: static;  /* remove sticky to avoid jumpy scroll on small screens */
    padding: .75rem;
    margin-bottom: .75rem;
  }

  /* Lesson link hit area + active visibility */
  .lesson-link { padding: .5rem .6rem; border: 1px solid transparent; }
  .lesson-link.is-active { border-color: var(--accent); }

  /* Content panel breathing room */
  #content.split-content { padding: 1rem; }

  /* Footer spacing */
  .footer { padding: .75rem; }
}

/* Make the desktop hamburger hidden; mobile block above shows it */
@media (max-width: 640px){ .hide-desktop { display:inline-grid; } }
@media (min-width: 641px) {
  .hide-desktop { display: none !important; }
  .nav-actions { display: flex; position: static; flex-direction: row; gap: .75rem; padding: 0; border: 0; box-shadow: none; background: transparent; }
  .btn-ghost, button { width: auto; }
}

/* Improve focus states (keyboard users) */
a:focus-visible, button:focus-visible, .lesson-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Drawer styles for mobile lessons menu */
@media (max-width: 640px) {
  .lessons-btn { margin-top: .5rem; }

  .drawer-panel {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    width: min(92vw, 360px);
    transform: translateX(-105%);
    transition: transform .25s ease;
    z-index: 50;
    border-radius: 0;          /* flush edge */
    border-right: 1px solid var(--line);
    overflow: auto;
  }
  .drawer-panel.open {
    transform: translateX(0);
  }

  .drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 40;
    border: 0;
  }
}

/* Desktop: overlay never shows, sidebar is static */
@media (min-width: 641px) {
  .drawer-panel { position: sticky; top: 1rem; height: fit-content; transform: none !important; }
  .drawer-overlay { display: none !important; }
}

/* Notebook iframe responsiveness */
.nb-embed iframe { width: 100%; height: 70dvh; max-height: 85dvh; }

/* Phones: don't auto-embed heavy notebook */
@media (max-width: 640px) {
  .nb-embed iframe { display: none; }
  .show-inline-btn { display: inline-block; }
}

/* Larger screens: always show the inline notebook, hide the opt-in button */
@media (min-width: 641px) {
  .show-inline-btn { display: none !important; }
}

/* Notebook iframe sizing on desktop */
.nb-embed iframe {
  width: 100%;
  height: 70dvh;
  max-height: 85dvh;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

/* Align all nav actions perfectly */
.nav-right .link-btn,
.nav-right .btn-ghost,
.nav-right .btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;          /* uniform height */
  line-height: 1;        /* avoid baseline sag */
}

/* Keep padding consistent */
.nav-right .link-btn { padding: 0 .35rem; }
.nav-right .btn-ghost,
.nav-right .btn-primary { padding: 0 .7rem; }

/* Make the theme toggle match height */
.nav-right .icon-btn { width: 36px; height: 36px; }

/* Align user pill and logout */
.nav-right .user-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;          /* match the nav action height */
  line-height: 1;        /* kill baseline sag */
  padding: 0 .5rem;
  border-radius: 999px;
}

/* Ensure the logout form doesn't baseline misalign */
.nav-right form {
  display: flex;
  align-items: center;
  margin: 0;             /* just in case */
}

/* Make the logout button match the nav action box model */
.nav-right form .link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  line-height: 1;
  padding: 0 .35rem;
}


/* Application form */

/* ---------- Form layout polish ---------- */
.form-row {
  display: grid;
  grid-template-columns: 220px 1fr;   /* label | control */
  gap: .75rem 1rem;
  align-items: start;
  margin-bottom: .9rem;
}

.form-row > label {
  margin: .5rem 0 0;
  font-weight: 600;
  color: var(--text);
}

.form-row .control :where(input, select, textarea) {
  width: 100%;
  box-sizing: border-box;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .55rem .65rem;
  font: inherit;
}

.form-row .control textarea {
  min-height: 120px;             /* consistent textareas */
  resize: vertical;
}

.form-row .control :where(input, select, textarea):focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 20%, transparent);
}

/* Two inputs side-by-side (country/timezone, session/availability) */
.form-row.two-up {
  grid-template-columns: 1fr;    /* container is a single row; inner divs handle columns */
}
.form-row.two-up > div {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: .75rem 1rem;
  align-items: start;
}
@media (max-width: 900px) {
  .form-row,
  .form-row.two-up > div {
    grid-template-columns: 1fr;  /* stack on mobile: label above field */
  }
  .form-row > label { margin: 0; }
}

/* Checkbox line */
.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin: .75rem 0 1rem;
  cursor: pointer;
}
.checkbox-row input[type="checkbox"] {
  width: 1.1rem; height: 1.1rem;
}

/* Error styles (Django adds .errors / helptext if you render them) */
ul.errorlist { margin: .25rem 0; padding-left: 1.1rem; color: #b91c1c; }
.form-row .control .errorlist + :where(input, select, textarea) {
  border-color: #b91c1c;
  box-shadow: 0 0 0 3px rgba(185,28,28,.15);
}



/* Inline, vertically centered radios */
.inline-radios { 
  display: flex; 
  gap: 1rem; 
  align-items: center; 
  margin: 0; 
  padding: 0; 
}

/* Django may render radios as <div><label><input>Text</label></div> (Django 5) */
.inline-radios > div > label {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin: 0;
  line-height: 1.2;
}

/* If your renderer uses <ul><li><label>…</label></li></ul> */
.inline-radios li { 
  list-style: none; 
  display: inline-flex; 
  align-items: center; 
  gap: .4rem; 
  margin: 0; 
  padding: 0; 
}

/* Tighter control on the input alignment */
.inline-radios input[type="radio"] {
  margin: 0;
  vertical-align: middle;
}
