/* ABDELCARO Learning - single stylesheet.
   Sections: tokens, base, layout, header/footer, components, forms, prose, utilities. */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --surface: #f6f7f9;
  --surface-raised: #ffffff;
  --text: #1a1d23;
  --text-muted: #4f5663;
  --border: #d9dde4;
  --accent: #2456d6;
  --accent-hover: #1a43b0;
  --accent-contrast: #ffffff;
  --free: #11693a;
  --free-bg: #dcf5e6;
  --locked: #7a4a00;
  --locked-bg: #fdecc8;
  --done: #1a43b0;
  --done-bg: #dfe8fb;
  --danger: #b3261e;
  --code-bg: #f0f2f6;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 10px;
  --space: 1rem;
  --content-width: 68rem;
  --prose-width: 44rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --surface: #171b23;
    --surface-raised: #1c212b;
    --text: #e8eaee;
    --text-muted: #a7afbc;
    --border: #2d3441;
    --accent: #7ba2ff;
    --accent-hover: #a3bfff;
    --accent-contrast: #0b1020;
    --free: #7fe0a8;
    --free-bg: #12301f;
    --locked: #ffd48a;
    --locked-bg: #3a2a0a;
    --done: #a3bfff;
    --done-bg: #1a2a52;
    --danger: #ff8a80;
    --code-bg: #1c212b;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.6 var(--font);
}

main { flex: 1; padding-block: 2rem 3rem; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); }
h2 { font-size: 1.5rem; margin-top: 2.5rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

img, iframe, video { max-width: 100%; }

/* ---------- Layout ---------- */
.container { width: min(100% - 2rem, var(--content-width)); margin-inline: auto; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: var(--space);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0.5rem 1rem;
  z-index: 10;
}
.skip-link:focus { left: 0; }

/* ---------- Header / footer ---------- */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 1.5rem;
  padding-block: 0.25rem;
}
.logo {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
}
/* Links are 44px tall for touch; the horizontal padding is part of the gap, not extra space. */
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0 0.6rem; margin-left: -0.25rem; }
.nav a, .nav .link-button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 0.25rem;
}
.nav .inline-form { display: flex; }
.nav a { color: var(--text); text-decoration: none; }
.nav a:hover { color: var(--accent); text-decoration: underline; }
.nav a.button { color: var(--accent-contrast); padding-inline: 0.8rem; margin-left: 0.25rem; }
.nav a.button:hover { color: var(--accent-contrast); text-decoration: none; }

.site-footer { border-top: 1px solid var(--border); background: var(--surface); color: var(--text-muted); font-size: 0.9rem; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.5rem; padding-block: 0.5rem; align-items: center; }
.footer-inner p { margin: 0; }
.footer-inner nav { display: flex; gap: 0 0.5rem; flex-wrap: wrap; margin-inline: -0.5rem; }
.footer-inner nav a { display: inline-flex; align-items: center; min-height: 44px; padding-inline: 0.5rem; }

.messages { margin-top: 1rem; }
.message { padding: 0.75rem 1rem; border-radius: var(--radius); background: var(--done-bg); color: var(--done); margin: 0 0 0.5rem; }
.message-error { background: var(--locked-bg); color: var(--danger); }

/* ---------- Components ---------- */
.button, .link-button {
  font: inherit;
  cursor: pointer;
}

.button {
  display: inline-block;
  padding: 0.6rem 1.15rem;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: background-color 0.15s ease-out, border-color 0.15s ease-out;
}
.button:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-contrast); }
.button:active { filter: brightness(0.9); transform: translateY(1px); }
.button-secondary { background: transparent; color: var(--accent); }
.button-secondary:hover { background: var(--surface); color: var(--accent-hover); }
.button-secondary:active { background: var(--border); color: var(--accent-hover); filter: none; }
.button-small { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0.3rem 0.8rem; }

.link-button { background: none; border: 0; padding: 0; color: var(--text); }
.link-button:hover { color: var(--accent); text-decoration: underline; }
.inline-form { display: inline; margin: 0; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }

.hero { padding-block: 2rem 1rem; max-width: var(--prose-width); }
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); }
.lead { font-size: 1.15rem; color: var(--text-muted); }

.card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.card h3 { margin-bottom: 0.35em; }
.card > :last-child { margin-bottom: 0; }
.card-meta { color: var(--text-muted); font-size: 0.9rem; }

/* Whole card is one link (stretched title link); secondary actions sit above it. */
.card-course { position: relative; transition: border-color 0.15s ease-out; }
.card-course:hover, .card-course:focus-within { border-color: var(--accent); }
.card-link { color: var(--text); text-decoration: none; }
.card-link::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.card-link:hover { color: var(--text); text-decoration: underline; }
.card-link:focus-visible { outline: none; }
.card-link:focus-visible::after { outline: 3px solid var(--accent); outline-offset: 2px; }
.card-stats { margin-bottom: 0.5rem; }
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0 0.75rem; }
.card-action { position: relative; z-index: 1; display: inline-flex; align-items: center; min-height: 44px; }
.track-icon { font-size: 2rem; margin: 0 0 0.25rem; line-height: 1; }

.plan .price { font-size: 2rem; font-weight: 700; margin-bottom: 0; }
.plan .per { font-size: 1rem; font-weight: 400; color: var(--text-muted); }
.checklist { list-style: none; padding: 0; margin: 0 0 1.25rem; }
.checklist li { padding-left: 1.5rem; position: relative; margin-bottom: 0.35rem; }
.checklist li::before { content: "\2713"; position: absolute; left: 0; color: var(--free); font-weight: 700; }

.steps { padding-left: 1.25rem; }
.steps li { margin-bottom: 0.5rem; }

.faq details { border-bottom: 1px solid var(--border); padding-block: 0; }
/* Keeps display: list-item so the disclosure marker stays; padding builds the 44px target. */
.faq summary { cursor: pointer; font-weight: 600; min-height: 44px; padding-block: 0.6rem; }
.faq details p { margin: 0 0 0.75rem; color: var(--text-muted); }

.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 0 0.15rem; color: var(--text-muted); font-size: 0.9rem; margin: 0 0 0.5rem -0.25rem; }
.breadcrumb a { display: inline-flex; align-items: center; min-height: 44px; padding-inline: 0.25rem; }
.page-header { margin-bottom: 1.5rem; }

.module { margin-bottom: 1.5rem; }
.lesson-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.lesson-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface-raised);
}
.lesson-list li + li { border-top: 1px solid var(--border); }
.lesson-meta { color: var(--text-muted); font-size: 0.9rem; display: flex; gap: 0.5rem; align-items: center; }

.badge {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.5;
}
.badge-free { background: var(--free-bg); color: var(--free); }
.badge-locked { background: var(--locked-bg); color: var(--locked); }
.badge-done { background: var(--done-bg); color: var(--done); }

.paywall {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 2rem 1.5rem;
  max-width: var(--prose-width);
}
.paywall h2 { margin-top: 0; }

.pager { display: flex; justify-content: space-between; gap: 0.5rem 1rem; margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.pager a { display: inline-flex; align-items: center; min-height: 44px; }
.pager-next { margin-left: auto; text-align: right; justify-content: flex-end; }

.video { position: relative; aspect-ratio: 16 / 9; margin-bottom: 1.5rem; max-width: var(--prose-width); }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: var(--radius); }

.notice { background: var(--locked-bg); color: var(--locked); padding: 0.6rem 1rem; border-radius: var(--radius); }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: var(--space); margin: 0 0 1.5rem; }
.stat { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.stat dt { color: var(--text-muted); font-size: 0.9rem; }
.stat dd { margin: 0; font-size: 2rem; font-weight: 700; }

.details { max-width: 32rem; margin: 0 0 1.5rem; }
.details div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.details dt { color: var(--text-muted); }
.details dd { margin: 0; text-align: right; }

/* ---------- Forms ---------- */
.form-card { max-width: 26rem; margin-inline: auto; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.field input:not([type="checkbox"]), .field select, .field textarea {
  width: 100%;
  font: inherit;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: var(--text);
}
.help { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.25rem; }
.help ul { margin: 0.25rem 0 0; padding-left: 1.25rem; }
.field-error, .form-errors { color: var(--danger); font-size: 0.9rem; margin: 0.25rem 0 0; }
.form-errors { margin-bottom: 1rem; }

/* ---------- Prose (rendered markdown and static pages) ---------- */
.prose { max-width: var(--prose-width); }
.prose h2 { margin-top: 2rem; }
.prose pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.9rem;
}
.prose code { font-family: var(--font-mono); background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px; font-size: 0.9em; }
.prose pre code { background: none; padding: 0; }
.prose table { border-collapse: collapse; width: 100%; margin-bottom: 1em; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 0.5rem 0.75rem; text-align: left; }
.prose th { background: var(--surface); }
.prose blockquote { margin: 0 0 1em; padding-left: 1rem; border-left: 4px solid var(--border); color: var(--text-muted); }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
  .button:active { transform: none; }
}
