/* styles.css — global theme (the "Field Manual" aesthetic), app-shell layout,
 * and the app's own accessibility baseline. The shell renders in light DOM, so
 * these rules style it directly. Design tokens live on :root and inherit across
 * shadow boundaries (custom properties cascade through), so the demo components
 * read the same palette.
 *
 * Aesthetic: warm paper ground, near-black warm ink, hairline rules, inverted
 * dark code panels. Libre Franklin (display/UI), Newsreader (prose), IBM Plex
 * Mono (code). High-contrast, editorial/textbook.
 */

:root {
  /* Paper + ink */
  --paper: #f4efe3;
  --paper-raised: #fbf7ee;
  --paper-sunken: #eae1ce;
  --ink: #1d1a15;
  --ink-soft: #564e40;
  --ink-faint: #6f6757;
  --rule: #d9cfba;
  --rule-strong: #b9ad93;

  /* Inverted panels */
  --invert-bg: #1c1a16;
  --invert-ink: #ece3d2;
  --invert-soft: #a79e8b;

  /* The three capability buckets */
  --bucket-form: #0c6e6c; /* teal — form association */
  --bucket-valid: #b15117; /* burnt orange — constraint validation */
  --bucket-aom: #6a4ba6; /* violet — accessibility object model */

  /* Two worlds */
  --native: #2f6d3b; /* the platform-backed baseline */
  --naive: #a23627; /* the anti-pattern */

  /* Plain-language primers — a calm slate-blue, distinct from the three
     bucket hues, so a "new to this concept?" aside reads as a sidebar note. */
  --primer: #345b7d;

  /* Type */
  --font-display: 'Libre Franklin', system-ui, -apple-system, sans-serif;
  --font-body: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', monospace;

  /* Metrics */
  --maxw: 1180px;
  --rad: 5px;
  --nav-w: 280px;
}

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

html {
  font-size: 17px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background-color: var(--paper);
  /* Subtle warm paper grain via layered gradients (atmosphere, not noise). */
  background-image:
    radial-gradient(circle at 18% 12%, rgba(180, 160, 120, 0.08), transparent 45%),
    radial-gradient(circle at 88% 8%, rgba(150, 130, 90, 0.06), transparent 40%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* --- Skip link + focus baseline ------------------------------------------- */

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  z-index: 100;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-display);
  font-weight: 600;
  padding: 0.55rem 0.9rem;
  border-radius: 0 0 var(--rad) var(--rad);
  transition: top 0.16s ease;
}
.skip-link:focus {
  top: 0;
}

:focus-visible {
  outline: 3px solid var(--bucket-aom);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --- App shell ------------------------------------------------------------ */

ei-curriculum {
  display: block;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem 2rem;
  padding: 1.5rem 0 1.1rem;
  border-bottom: 2px solid var(--ink);
  margin-bottom: 1.5rem;
}
.kicker {
  font-family: var(--font-display);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 0.2rem;
}
.wordmark {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(1.6rem, 1.1rem + 2.4vw, 2.5rem);
  line-height: 1;
  letter-spacing: -0.01em;
  margin: 0;
}
.wordmark span {
  font-weight: 700;
}

.progress {
  min-width: 220px;
  flex: 0 1 280px;
}
.progress-bar {
  height: 6px;
  background: var(--paper-sunken);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  display: block;
  block-size: 100%;
  background: var(--bucket-form);
  transition: inline-size 0.3s ease;
}
.progress-label {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--ink-soft);
  margin: 0.35rem 0 0;
  text-align: right;
}

.app-body {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  gap: 2.4rem;
  align-items: start;
}

/* --- Navigation rail ------------------------------------------------------ */

.app-nav {
  position: sticky;
  top: 1rem;
}
.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: none;
}
.nav-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.6rem;
  text-decoration: none;
  color: var(--ink);
  border-left: 3px solid transparent;
  border-radius: 0 var(--rad) var(--rad) 0;
}
.nav-item:hover {
  background: var(--paper-raised);
}
.nav-item[aria-current='page'] {
  background: var(--paper-raised);
  border-left-color: var(--ink);
}
.nav-num {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--paper);
  background: var(--rule-strong);
  inline-size: 1.5rem;
  block-size: 1.5rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
}
.nav-item[aria-current='page'] .nav-num {
  background: var(--ink);
}
.nav-item[data-state='complete'] .nav-num {
  background: var(--native);
}
.nav-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.nav-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.92rem;
}
.nav-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ink-faint);
  margin-top: 0.1rem;
}
.nav-state {
  font-size: 0.95rem;
  color: var(--native);
  width: 1rem;
  text-align: center;
}
.nav-item[data-state='visited'] .nav-state {
  color: var(--ink-faint);
}

/* --- Main + footer -------------------------------------------------------- */

main {
  min-width: 0; /* allow children to shrink / scroll instead of overflowing */
}
main:focus {
  outline: none; /* tabindex=-1 programmatic focus target; no focus ring */
}

/* "Next module" call-to-action, revealed once a module's gate is passed.
   Deliberately a green "go" CTA — not the charcoal of a code block. */
.next-module {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.75rem;
  padding: 0.9rem 1.25rem;
  text-decoration: none;
  color: var(--paper);
  background: var(--native);
  border: 1px solid var(--native);
  border-radius: var(--rad);
  box-shadow: 0 1px 0 var(--rule-strong);
  transition: background-color 0.15s ease, transform 0.15s ease;
}
.next-module:hover {
  background: #245530;
  border-color: #245530;
}
.next-module:hover .next-arrow {
  transform: translateX(3px);
}
.next-module:focus-visible {
  outline: 3px solid var(--bucket-aom);
  outline-offset: 3px;
}
.next-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.next-kicker {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--paper);
}
.next-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.12rem;
}
.next-arrow {
  font-size: 1.5rem;
  line-height: 1;
  flex: 0 0 auto;
  transition: transform 0.15s ease;
}
.course-complete {
  margin-top: 2.75rem;
  padding: 1rem 1.25rem;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--rad);
  font-size: 1.02rem;
}
.course-complete a {
  color: var(--native);
  font-weight: 600;
}

.app-footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.86rem;
  color: var(--ink-soft);
  max-width: 70ch;
}

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 860px) {
  .app-body {
    grid-template-columns: 1fr;
    gap: 1.4rem;
  }
  .app-nav {
    position: static;
  }
  .nav-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.3rem;
  }
}

/* --- Motion --------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
