/* ── tokens ── */
:root {
  --bg: #ffffff;
  --fg: #22282F;
  --panel: #F5ECDE;
  --accent-1: #2A7A6B; /* imagery */
  --accent-2: #1C516A; /* structure */
  --accent-3: #3B3931; /* characterization */
  --accent-4: #90BECD; /* conflict */
  --warm: #D7C8AE;
  --cream: #EEE1C1;
  --sage: #CDD5CA;
  --mono: 'Courier New', Courier, monospace;
  --serif: 'Instrument Serif', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --ease-accordion: cubic-bezier(0.645, 0.045, 0.355, 1);
}

/* ── reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── base ── */
html {
  font-size: 17px;
  scroll-behavior: smooth;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overscroll-behavior: none;
  overflow: hidden;
}

/* ── layout: full-bleed image + text panel ── */
.page-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
}

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

.page-panel {
  position: relative;
  z-index: 1;
  background: var(--bg);
  max-width: 560px;
  height: 100vh;
  margin-left: 1.5rem;
  padding: 6rem 2.5rem 8rem;
  animation: fadeIn 0.4s ease;
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (max-width: 768px) {
  .page-panel {
    margin-left: 0;
    max-width: none;
    padding: 3rem 1.25rem 5rem;
  }
}

/* ── typography ── */
h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 3.4rem;
  line-height: 1.15;
  margin-bottom: 0.2em;
  color: var(--fg);
}

h2 {
  font-size: 1.6rem;
  line-height: 1.3;
  margin-top: 3.5rem;
  margin-bottom: 1rem;
}

h3 {
  margin-top: 2.5rem;
  margin-bottom: 0.6rem;
  font-family: var(--sans);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.75rem;
}

p {
  margin-bottom: 1.2em;
}

/* ── header ── */
.author {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.01em;
  opacity: 0.52;
  margin-bottom: 3rem;
}

.thesis {
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.6;
  margin-bottom: 4rem;
  opacity: 0.8;
}

/* ── dropdowns ── */
.section-list {
  list-style: none;
  border-top: 1px solid rgba(34, 40, 47, 0.15);
}

.section-item {
  border-bottom: 1px solid rgba(34, 40, 47, 0.15);
}

/* per-section accent colors */
.section-item:nth-child(1) { --section-accent: var(--accent-1); }
.section-item:nth-child(2) { --section-accent: var(--accent-2); }
.section-item:nth-child(3) { --section-accent: var(--accent-3); }
.section-item:nth-child(4) { --section-accent: var(--accent-4); }

.section-toggle {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  width: 100%;
  padding: 0.85rem 0 0.65rem;
  background: none;
  border: none;
  color: var(--fg);
  font-family: var(--serif);
  font-size: 1.25rem;
  cursor: pointer;
  transition: color 0.2s ease;
  text-align: left;
}

.section-toggle:hover {
  color: var(--section-accent);
}

.section-item.open .section-toggle {
  color: var(--section-accent);
}

.section-toggle .toggle-author {
  font-family: var(--serif);
  font-size: 0.92rem;
  font-style: italic;
  font-weight: 400;
  opacity: 0.48;
  letter-spacing: 0.01em;
}

.section-toggle .toggle-icon {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.75rem;
  opacity: 0.4;
  margin-left: 0.75rem;
  transform: rotate(0deg);
  transform-origin: center;
  transition: transform 0.6s var(--ease-accordion);
}

.section-item.open .toggle-icon {
  transform: rotate(90deg);
}

.section-body {
  overflow: hidden;
  height: 0;
  transition: height 0.62s var(--ease-accordion);
}

.section-body-inner {
  padding: 0.5rem 0 2rem;
  opacity: 0;
  transform: translateY(-0.35rem);
  transition:
    opacity 0.52s var(--ease-accordion),
    transform 0.62s var(--ease-accordion);
}

.section-item.open .section-body-inner {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .section-body,
  .section-body-inner,
  .section-toggle .toggle-icon {
    transition-duration: 0.01ms;
  }
}

.section-body-inner .passage:first-child {
  margin-top: 0;
}

.section-body-inner .passage:first-child h2 {
  margin-top: 0;
}

/* ── passages ── */
.passage {
  margin-top: 2rem;
  margin-bottom: 2.5rem;
}

.passage blockquote {
  font-family: var(--serif);
  font-size: 1.1rem;
  line-height: 1.7;
  padding-left: 1.25rem;
  border-left: 2px solid var(--warm);
  margin-bottom: 0.5rem;
}

.passage .cite {
  font-family: var(--mono);
  font-size: 0.7rem;
  opacity: 0.35;
  margin-bottom: 1.5rem;
  display: block;
}

/* ── annotated highlights ── */
/* cycle annotation colors within each passage */
.highlight:nth-of-type(3n+1) { --hl: var(--accent-1); }
.highlight:nth-of-type(3n+2) { --hl: var(--accent-2); }
.highlight:nth-of-type(3n+3) { --hl: var(--accent-3); }

/* override with palette-wide variation per section */
.section-item:nth-child(1) .highlight:nth-of-type(3n+1) { --hl: #2A7A6B; }
.section-item:nth-child(1) .highlight:nth-of-type(3n+2) { --hl: #1C516A; }
.section-item:nth-child(1) .highlight:nth-of-type(3n+3) { --hl: #3B3931; }

.section-item:nth-child(2) .highlight:nth-of-type(3n+1) { --hl: #1C516A; }
.section-item:nth-child(2) .highlight:nth-of-type(3n+2) { --hl: #2A7A6B; }
.section-item:nth-child(2) .highlight:nth-of-type(3n+3) { --hl: #90BECD; }

.section-item:nth-child(3) .highlight:nth-of-type(3n+1) { --hl: #3B3931; }
.section-item:nth-child(3) .highlight:nth-of-type(3n+2) { --hl: #2A7A6B; }
.section-item:nth-child(3) .highlight:nth-of-type(3n+3) { --hl: #1C516A; }

.section-item:nth-child(4) .highlight:nth-of-type(3n+1) { --hl: #90BECD; }
.section-item:nth-child(4) .highlight:nth-of-type(3n+2) { --hl: #1C516A; }
.section-item:nth-child(4) .highlight:nth-of-type(3n+3) { --hl: #2A7A6B; }

.highlight {
  color: var(--fg);
  cursor: pointer;
  position: relative;
  background-color: color-mix(in srgb, var(--hl, var(--section-accent)) 18%, transparent);
  border-radius: 2px;
  padding: 0 2px;
  transition: background-color 0.3s ease;
}

.highlight:hover {
  background-color: color-mix(in srgb, var(--hl, var(--section-accent)) 35%, transparent);
}

/* ── tooltip ── */
.tooltip {
  position: fixed;
  width: max(280px, 28vw);
  max-width: 400px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--hl, var(--warm));
  padding: 1rem 1.2rem;
  font-family: var(--sans);
  font-size: 0.82rem;
  line-height: 1.55;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

/* ── dividers ── */
hr {
  border: none;
  border-top: 1px solid var(--fg);
  margin: 2rem 0;
  opacity: 0.2;
}

/* ── ascii decoration ── */
.ascii-rule {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--fg);
  opacity: 0.3;
  margin: 0 0 2rem;
  white-space: pre;
  overflow: hidden;
}

/* ── placeholder ── */
.placeholder {
  font-style: italic;
  opacity: 0.3;
}

/* ── page enter ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
