/* Abiegnus Base Camp — CORE
   Structure, layout and type scale. No colour, no typeface choices.
   Everything visual comes from tokens defined in themes.css. */

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

html { -webkit-text-size-adjust: 100%; background: var(--ground); }

body {
  margin: 0;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  color: var(--text);
  background: var(--ground);
  font-family: var(--font-body);
  font-size: var(--size-body);
  line-height: var(--leading-body);
  font-optical-sizing: auto;
}

/* the atmosphere layer; themes that want none set --atmosphere: none */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--atmosphere);
}

body > * { position: relative; z-index: 1; }

.wrap { max-width: calc(var(--measure) + 5rem); margin: 0 auto; }

/* ---------- masthead ---------- */

.masthead {
  position: relative;
  overflow: hidden;
  padding: var(--masthead-pad);
  border-bottom: var(--masthead-border, 1px solid var(--rule));
  background: var(--masthead-bg);
  background-size: cover;
  background-position: center;
}

/* shafts of light. Themes control angle, softness and how far they fall. */
.masthead::before {
  content: "";
  position: absolute;
  inset: -30% -15%;
  pointer-events: none;
  background: var(--masthead-rays);
  filter: blur(var(--rays-blur, 2px));
  opacity: var(--rays-opacity, 1);
  -webkit-mask-image: var(--rays-mask, none);
  mask-image: var(--rays-mask, none);
}

.masthead-inner {
  position: relative;
  z-index: 1;
  max-width: calc(var(--measure) + 5rem);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--size-wordmark);
  font-weight: var(--weight-wordmark);
  line-height: 1.1;
  letter-spacing: var(--track-display);
  color: var(--heading);
}

.wordmark a { color: inherit; text-decoration: none; }
.wordmark a:hover { color: var(--accent-bright); }

.tagline {
  margin: 0;
  flex-basis: 100%;
  max-width: 32rem;
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: var(--weight-tagline);
  line-height: 1.5;
  /* themes with light shafts in the banner override this: the ray crests move
     with viewport width, so the tagline cannot sit at the dim text tone */
  color: var(--tagline-color, var(--text-dim));
}

/* ---------- navigation + theme control ---------- */

.nav {
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--rule);
  background: var(--nav-bg);
  backdrop-filter: var(--nav-blur);
  -webkit-backdrop-filter: var(--nav-blur);
  /* body > * sets z-index 1 on every band; the nav must outrank the page so
     the open menu panel is not painted over by the content below it */
  position: relative;
  z-index: 40;
}

.nav-inner {
  max-width: calc(var(--measure) + 5rem);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* A single hamburger menu at every width, holding both navigation and the
   theme control. It is a native <details>, so it opens and closes without
   JavaScript; the room to grow is the point — new pages just join the list. */
.menu { position: relative; }

.menu > summary {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: max-content;
  list-style: none;
  cursor: pointer;
  padding: 0.6rem 0.9rem;
  margin: 0.55rem 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  background: var(--card-bg);
}

.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover { color: var(--accent-bright); border-color: var(--accent); }

.menu > summary svg { fill: currentColor; flex: none; display: block; }
.menu[open] > summary .bar-mid { opacity: 0; }

/* the panel floats over the page rather than displacing it */
.menu-panel {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 30;
  width: 19rem;
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 6.5rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  margin-top: -0.2rem;
  padding: 1.15rem 1.15rem 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel-solid);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.6);

  /* a recessed gripper rather than the OS scrollbar, on the rare tall list */
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}

.menu-panel::-webkit-scrollbar { width: 6px; }
.menu-panel::-webkit-scrollbar-track { background: transparent; }

.menu-panel::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 3px;
}

.menu-panel::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); }

/* theme control — revealed by theme.js, so it never shows as a dead widget */
.theme {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  /* negative margins let the rule span the panel edge to edge */
  margin: 1.1rem -1.15rem 0;
  padding: 0.85rem 1.15rem 0.95rem;
  border-top: 1px solid var(--rule);
}

.theme[hidden] { display: none; }

.theme label {
  font-family: var(--font-display);
  font-size: 0.8125rem;
  color: var(--text-dim);
}

.theme select {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
  background: var(--card-bg);
  border: 1px solid var(--rule);
}

.theme select:hover { border-color: var(--accent); }

/* visually hidden, still read aloud */
.vh {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- page frame ---------- */

.page {
  max-width: calc(var(--measure) + 5rem);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.content {
  max-width: var(--measure);
  margin: 0 auto;
  padding: var(--panel-pad);
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  border-top-color: var(--rule-top);
  background: var(--panel);
  box-shadow: var(--panel-shadow);
}

/* ---------- menu links ----------
   Every item here is a working link. No static or pending entries — a
   tap-first menu is for actionable wayfinding only. */

.menu-links {
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-display);
}

.menu-links li {
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.35;
  color: var(--text-dim);
}

.menu-links a {
  display: block;
  padding: 0.6rem 0.5rem;
  margin: 0 -0.5rem;
  border-radius: var(--radius-sm);
  color: inherit;
  text-decoration: none;
}

.menu-links a:hover { color: var(--accent-bright); background: var(--card-bg-hover); }

.menu-links li[aria-current="page"] a { color: var(--accent-bright); font-weight: 600; }

/* ---------- typography ---------- */

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--heading);
  line-height: 1.22;
  letter-spacing: var(--track-display);
}

h1 { font-size: var(--size-h1); font-weight: var(--weight-heading); margin: 0 0 1.4rem; }

h2 {
  font-size: var(--size-h2);
  font-weight: var(--weight-heading);
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule);
}

h3 { font-size: 1.0625rem; font-weight: var(--weight-heading); margin: 1.9rem 0 0.6rem; }

p { margin: 0 0 1.2rem; }

a { color: var(--accent); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-bright); }

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

.formula {
  margin: 0 0 1.6rem;
  font-style: italic;
  font-size: 1.1875rem;
  color: var(--warm);
}

.formula-close {
  margin: 2.75rem 0 0;
  padding-top: 1.3rem;
  border-top: 1px solid var(--rule);
  font-style: italic;
  font-size: 1.1875rem;
  color: var(--warm);
}

blockquote {
  margin: 1.6rem 0;
  padding: 0.2rem 0 0.2rem 1.3rem;
  border-left: 2px solid var(--accent);
  font-style: italic;
}

/* ---------- lists ---------- */

.content ul, .content ol { margin: 0 0 1.4rem; padding-left: 1.4rem; }
.content li { margin-bottom: 0.6rem; }
.content ul { list-style: none; }
.content ul > li { position: relative; }

.content ul > li::before {
  content: "";
  position: absolute;
  left: -1.15rem;
  top: 0.66em;
  width: var(--bullet-size);
  height: var(--bullet-size);
  border-radius: var(--bullet-radius);
  transform: var(--bullet-transform);
  background: var(--bullet-bg);
  box-shadow: var(--bullet-glow);
}

/* ---------- module index ---------- */

.index { margin: 1.75rem 0 0; padding: 0; list-style: none; }

.index li {
  margin: 0 0 0.6rem;
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border: 1px solid var(--rule);
  border-left: 2px solid var(--accent);
  background: var(--card-bg);
}

.index li::before { display: none; }
.index li:hover { border-left-color: var(--accent-bright); background: var(--card-bg-hover); }

.index .title {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 500;
}

.index .title a { text-decoration: none; color: var(--heading); }
.index .title a:hover { color: var(--accent-bright); }

.index .state {
  flex: none;
  padding: 0.22rem 0.7rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--badge-text);
  background: var(--accent);
}

.index .state.pending {
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--rule);
}

/* ---------- assignment brief ---------- */

.brief {
  margin: 1.75rem 0;
  padding: 1.5rem 1.6rem 0.4rem;
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  border-left: 2px solid var(--warm);
  background: var(--card-bg);
}

.prompt {
  margin: 0 0 1.75rem;
  font-family: var(--font-display);
  font-size: var(--size-prompt);
  font-weight: var(--weight-prompt);
  line-height: 1.35;
  letter-spacing: var(--track-display);
  color: var(--heading);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-block;
  padding: 0.85rem 1.75rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--btn-text);
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  box-shadow: var(--btn-glow);
}

.btn:hover { color: var(--btn-text); background: var(--btn-bg-hover); box-shadow: var(--btn-glow-hover); }
.btn:active { box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.28); }

.btn-quiet {
  display: inline-block;
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--rule);
  background: var(--card-bg);
}

.btn-quiet:hover { color: var(--accent-bright); border-color: var(--accent); }

/* ---------- page-to-page movement ---------- */

.seam {
  margin-top: 2.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.seam .spacer { visibility: hidden; }

/* ---------- footer ---------- */

.foot {
  border-top: 1px solid var(--rule);
  padding: 2.25rem 1.5rem 3rem;
  font-family: var(--font-display);
  font-size: 0.875rem;
  color: var(--text-dim);
  background: var(--nav-bg);
}

.foot-inner { max-width: calc(var(--measure) + 5rem); margin: 0 auto; }
.foot p { margin: 0 0 0.35rem; }
.foot a { color: var(--accent); }
.foot a:hover { color: var(--accent-bright); }

/* ---------- narrow screens ---------- */

@media (max-width: 46rem) {
  .page { padding: 1.75rem 1rem 3rem; }
  .content { padding: 1.6rem 1.4rem 1.75rem; }

  .nav { padding: 0 1rem; }

  /* touch targets: measured at 35px and 32px, below the 44px minimum.
     min-height guarantees it rather than inferring it from padding. */
  .menu-links a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0.5rem 0.5rem;
  }

  .theme select { min-height: 44px; padding: 0.5rem; }
  .menu > summary { min-height: 44px; padding: 0.6rem 0.95rem; }

  .masthead { padding: 2.5rem 1.25rem 2rem; }
  .wordmark { font-size: 1.5rem; }
  h1 { font-size: 1.625rem; }
  .prompt { font-size: 1.1875rem; }
  body { font-size: 1.0625rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  body::before, .masthead::before, .nav, .seam { display: none !important; }
  body { background: #fff; color: #000; }
  .content { border: 0; box-shadow: none; background: #fff; padding: 0; max-width: none; }
  .page { display: block; padding: 0; }
}
