:root {
  color-scheme: light;
  --ink: #1f2623;
  --muted: #5f6965;
  --line: #d8ded8;
  --paper: #fbfaf5;
  --surface: #ffffff;
  --saffron: #d97824;
  --green: #1f7a55;
  --blue: #285b8f;
  --maroon: #8b2f35;
  --gold: #bf8b28;
  --shadow: 0 18px 44px rgba(31, 38, 35, 0.1);
  --topbar-bg: rgba(251, 250, 245, 0.94);
  --topbar-border: rgba(31, 38, 35, 0.12);
  --btn-text: #ffffff;
}

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e8ebe7;
  --muted: #8fa899;
  --line: #2e3730;
  --paper: #111714;
  --surface: #1a211d;
  --saffron: #e8943a;
  --green: #3daa78;
  --blue: #5b8ec9;
  --maroon: #c4565d;
  --gold: #d4a03a;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.4);
  --topbar-bg: rgba(17, 23, 20, 0.94);
  --topbar-border: rgba(232, 235, 231, 0.1);
  --btn-text: #111714;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: var(--base-font-size, 16px);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.55;
}

a {
  color: inherit;
}

button,
input,
textarea {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
  padding: 12px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--topbar-border);
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  display: block;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: contain;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 0.82rem;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.nav a,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}

.nav a {
  color: var(--muted);
}

.nav a:hover {
  color: var(--ink);
  background: rgba(31, 122, 85, 0.08);
}

.button {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--btn-text);
}

.button.secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--blue);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: clamp(22px, 4vw, 54px);
  align-items: center;
  padding: clamp(34px, 6vw, 74px) clamp(18px, 5vw, 72px) 28px;
  background:
    linear-gradient(
      105deg,
      color-mix(in srgb, var(--paper) 97%, transparent) 0%,
      color-mix(in srgb, var(--paper) 92%, transparent) 45%,
      color-mix(in srgb, var(--paper) 55%, transparent) 100%
    ),
    url("/indianmilitaryheroes/images/heroes/Heroes.png");
  background-position: center right;
  background-size: cover;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--maroon);
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.12;
  letter-spacing: 0;
}

h1 {
  max-width: 820px;
  font-size: clamp(2.25rem, 6vw, 5rem);
}

h2 {
  font-size: clamp(1.65rem, 3vw, 2.5rem);
}

h3 {
  font-size: 1.2rem;
}

.lead {
  max-width: 760px;
  margin: 18px 0 0;
  color: var(--ink);
  font-size: clamp(1.04rem, 1.8vw, 1.25rem);
}

.hero-actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.hero-panel {
  align-self: stretch;
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--topbar-border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stat strong {
  display: block;
  color: var(--green);
  font-size: 1.55rem;
  line-height: 1;
}

.stat span {
  color: var(--muted);
  font-size: 0.86rem;
}

.section {
  padding: 42px clamp(18px, 5vw, 72px);
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 20px;
}

.section-head p {
  max-width: 620px;
  margin: 8px 0 0;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(31, 38, 35, 0.05);
}

.module-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
}

.module-meta,
.lesson-meta,
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Keep week + lesson-count pills on one non-wrapping line */
.module-meta {
  flex-wrap: nowrap;
  align-items: center;
  min-height: 28px;
}

/* Focus text and hero pill-row take up available height so the footer
   (progress bar + button) is always pushed to the bottom of every card */
.module-card > .mod-focus,
.module-card > .pill-row {
  flex: 1 0 auto;
}

/* Footer: progress bar, optional quiz badge, and open/resume button */
.module-card-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
  flex-shrink: 0;
}

.module-open-btn {
  align-self: flex-start;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(40, 91, 143, 0.09);
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 700;
}

.pill.green {
  background: rgba(31, 122, 85, 0.09);
  color: var(--green);
}

.pill.gold {
  background: rgba(191, 139, 40, 0.12);
  color: #775215;
}

.pill.optional {
  background: rgba(139, 47, 53, 0.09);
  color: var(--maroon);
}

.progress-wrap {
  display: grid;
  gap: 6px;
  width: 100%;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
}

.progress-track {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: var(--line);
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--saffron), var(--green));
  transition: width 180ms ease;
}

.module-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 20px;
  padding: 28px clamp(18px, 5vw, 72px) 48px;
}

.sidebar {
  position: sticky;
  top: 92px;
  align-self: start;
  display: grid;
  gap: 12px;
}

.lesson-list {
  display: grid;
  gap: 8px;
}

.lesson-tab {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.lesson-tab.active {
  border-color: var(--green);
  box-shadow: inset 4px 0 0 var(--green);
}

.lesson-tab.complete::after {
  content: "Complete";
  display: block;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 700;
}

.lesson {
  display: grid;
  gap: 16px;
}

.lesson-hero {
  padding: 24px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  position: relative;
}

.hero-photo {
  float: right;
  margin: 0 0 16px 24px;
  width: 200px;
  height: 250px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 3px solid var(--gold);
}

.hero-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@media (max-width: 768px) {
  .hero-photo {
    float: none;
    margin: 0 auto 16px;
    width: 160px;
    height: 200px;
  }
}

.story-blocks {
  display: grid;
  gap: 12px;
}

.life-story,
.story-block {
  padding: 16px;
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  background: var(--paper);
}

.life-story {
  border-left-color: var(--green);
  background: var(--paper);
}

.life-story h2 {
  margin-bottom: 8px;
  font-size: 1.35rem;
}

.life-story p {
  margin: 0;
}

.story-block h3 {
  margin-bottom: 6px;
  color: var(--maroon);
  font-size: 1rem;
}

.story-block p,
.activity p,
.reflection p,
.quiz p {
  margin: 0;
}

.story-block p {
  text-align: justify;
  hyphens: auto;
}

.story-block p + p {
  margin-top: 12px;
}

.activity,
.reflection,
.quiz,
.certificate {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.activity {
  border-left: 5px solid var(--blue);
}

.reflection {
  border-left: 5px solid var(--green);
}

.quiz {
  display: grid;
  gap: 16px;
}

.question {
  display: grid;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.question:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.option input {
  margin-top: 4px;
}

.option.correct {
  border-color: var(--green);
  background: rgba(31, 122, 85, 0.08);
}

.option.wrong {
  border-color: var(--maroon);
  background: rgba(139, 47, 53, 0.07);
}

.feedback {
  min-height: 28px;
  color: var(--muted);
  font-weight: 700;
}

.textarea {
  width: 100%;
  min-height: 110px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
}

.empty-state {
  padding: 44px 18px;
  text-align: center;
}

.certificate {
  max-width: 860px;
  margin: 0 auto;
  text-align: center;
}

.certificate-name {
  width: min(100%, 460px);
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
}

.certificate-preview {
  margin-top: 20px;
  padding: 28px;
  border: 3px double var(--gold);
  border-radius: 8px;
  background: var(--paper);
}

.badge-wall {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

@media (max-width: 980px) {
  .hero,
  .module-layout {
    grid-template-columns: 1fr;
  }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar {
    position: static;
  }
}

@media (max-width: 660px) {
  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .nav {
    justify-content: flex-start;
  }

  .grid,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .lesson-hero,
  .activity,
  .reflection,
  .quiz {
    padding: 16px;
  }
}

/* ── New components for 6-week military heroes course ─────────────────── */

.mod-war {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.source-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

/* Summary tab in lesson list */
.summary-tab {
  border-top: 2px solid var(--gold);
  margin-top: 4px;
  background: var(--paper);
  font-style: italic;
}

.summary-tab.active {
  border-color: var(--gold);
  box-shadow: inset 4px 0 0 var(--gold);
}

.summary-tab:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Module summary header */
.summary-header {
  background: var(--paper);
  border-left: 5px solid var(--gold);
}

.summary-block {
  border-left-color: var(--maroon);
  background: var(--paper);
}

/* Activity section on summary page */
.activity-section {
  padding: 18px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  background: var(--surface);
  display: grid;
  gap: 8px;
}

.activity-section h2 {
  margin-bottom: 2px;
}

.activity-section p {
  margin: 0;
}

/* Hero roll on summary page */
.hero-roll {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.hero-roll h2 {
  margin-bottom: 14px;
}

.hero-roll-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.hero-roll-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  display: grid;
  gap: 4px;
  font-size: 0.88rem;
  color: var(--muted);
}

.hero-roll-card strong {
  color: var(--ink);
  font-size: 0.9rem;
}

.hero-roll-card.done {
  border-color: var(--green);
  background: rgba(31, 122, 85, 0.05);
}

.hero-roll-years {
  font-size: 0.78rem;
}

.badge-check {
  color: var(--green);
  font-weight: 700;
  font-size: 0.8rem;
}

/* Module quiz section */
.quiz-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Badge cards on certificate page */
.badge-wall {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

.badge-card {
  display: grid;
  gap: 3px;
  min-width: 130px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  text-align: center;
  font-size: 0.86rem;
  color: var(--muted);
}

.badge-card strong {
  color: var(--ink);
  font-size: 0.95rem;
}

.badge-card.earned {
  border-color: var(--gold);
  background: rgba(191, 139, 40, 0.07);
}

.badge-status {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--green);
}

.badge-card:not(.earned) .badge-status {
  color: var(--muted);
}

/* Certificate status line */
.cert-status {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Reflection prompt text */
.reflection-prompt {
  margin: 0 0 10px;
  font-style: italic;
  color: var(--ink);
}

/* ─── Optional bonus module section ────────────────────────────────────── */

.optional-section {
  border-top: 1px dashed var(--line);
  background: rgba(139, 47, 53, 0.025);
}

.optional-section-inner {
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
}

.optional-eyebrow {
  color: var(--maroon);
}

.optional-desc {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.92rem;
}

.optional-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.optional-card {
  text-align: left;
  border-style: dashed;
  border-color: rgba(139, 47, 53, 0.3);
  background: var(--paper);
}

@media (max-width: 680px) {
  .optional-section-inner {
    max-width: 100%;
  }
}

/* ─── Locked module card ────────────────────────────────────────────────── */

.module-card.locked {
  opacity: 0.6;
  background: var(--paper);
  border-style: dashed;
  pointer-events: none;   /* prevents accidental clicks on the whole card */
}

/* Re-enable pointer on the lock text so it's still readable on hover */
.module-card.locked .locked-msg {
  pointer-events: auto;
}

.pill.locked-pill {
  background: rgba(95, 105, 101, 0.1);
  color: var(--muted);
}

.locked-msg {
  margin: 0;
  font-size: 0.84rem;
  font-style: italic;
  color: var(--muted);
}

/* ─── Story Prev / Next navigation ─────────────────────────────────────── */

.lesson-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.lesson-nav-btn {
  flex: 0 1 auto;
  max-width: 42%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lesson-nav-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .lesson-nav {
    flex-wrap: wrap;
    justify-content: center;
  }

  .lesson-nav-btn {
    max-width: 100%;
    width: 100%;
  }

  .lesson-nav-count {
    order: -1;
    width: 100%;
    text-align: center;
  }
}

/* ─── Settings panel ────────────────────────────────────────────────────── */

.settings-wrap {
  position: relative;
}

.settings-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 120ms, background 120ms;
}

.settings-trigger:hover,
.settings-trigger[aria-expanded="true"] {
  color: var(--ink);
  background: rgba(31, 122, 85, 0.08);
}

.settings-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  min-width: 210px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
}

.settings-panel[hidden] {
  display: none;
}

.settings-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.font-size-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.settings-btn:hover {
  background: rgba(31, 122, 85, 0.08);
  border-color: var(--green);
}

.settings-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.font-size-val {
  flex: 1;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.settings-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 2px 0;
}

.theme-toggle {
  width: 100%;
  justify-content: flex-start;
  gap: 8px;
}

/* ── Site footer ─────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.25rem 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.site-footer a {
  color: var(--saffron);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}
