@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=Source+Sans+3:wght@400;600&display=swap');

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

:root {
  --ink:       #1a1a1a;
  --mid:       #4a4a4a;
  --rule:      #c8c0b0;
  --paper:     #f7f5f1;
  --white:     #ffffff;
  --accent:    #2b4a7a;
  --accent-lt: #e8eef5;
}

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

body {
  font-family: 'Source Sans 3', sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.7;
}

/* ── Header ── */
header {
  border-bottom: 2px solid var(--ink);
  padding: 1.5rem 0 0;
  background: var(--white);
}

.header-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.site-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mid);
  margin-bottom: 0.25rem;
}

.site-subtitle {
  font-family: 'Libre Baskerville', serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  margin-bottom: 1.25rem;
}

/* ── Nav toggle button (hidden on desktop) ── */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem 0;
  margin-bottom: 0.75rem;
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--ink);
  margin: 5px 0;
  transition: transform 0.2s, opacity 0.2s;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}
.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ── Nav ── */
nav {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--rule);
}

nav a {
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--mid);
  padding: 0.65rem 1.1rem 0.65rem 0;
  margin-right: 1.1rem;
  border-bottom: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

nav a:hover,
nav a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Main ── */
main {
  max-width: 860px;
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}

/* ── Page title ── */
.page-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
}

/* ── Tradition block ── */
.tradition-block {
  background: var(--accent-lt);
  border-left: 4px solid var(--accent);
  padding: 1.5rem 1.75rem;
  margin: 2rem 0;
  font-family: 'Libre Baskerville', serif;
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--ink);
}

.tradition-block cite {
  display: block;
  margin-top: 0.75rem;
  font-style: normal;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--mid);
}

/* ── Prose ── */
h2 {
  font-family: 'Libre Baskerville', serif;
  font-size: 1.25rem;
  font-weight: 700;
  margin: 2.5rem 0 0.75rem;
  color: var(--ink);
}

p { margin-bottom: 1.1rem; color: var(--mid); }
p:last-child { margin-bottom: 0; }

/* ── Structure diagram ── */
.structure {
  margin: 2rem 0;
  border: 1px solid var(--rule);
  background: var(--white);
}

.structure-level {
  display: flex;
  align-items: center;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--rule);
  gap: 1rem;
}

.structure-level:last-child { border-bottom: none; }

.level-label {
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--white);
  background: var(--accent);
  padding: 0.2rem 0.55rem;
  white-space: nowrap;
  min-width: 5rem;
  text-align: center;
}

.level-name {
  font-family: 'Libre Baskerville', serif;
  font-size: 1rem;
  color: var(--ink);
}

.level-desc {
  font-size: 0.85rem;
  color: var(--mid);
  margin-left: auto;
  text-align: right;
  max-width: 320px;
}

/* ── Diagram frame ── */
.diagram-frame {
  margin: 2rem 0;
  padding: 1.5rem;
  background: var(--white);
  border: 1px solid var(--rule);
}

/* ── Downloads ── */
.file-list {
  list-style: none;
  margin: 1.5rem 0;
}

.file-list li {
  border-bottom: 1px solid var(--rule);
}

.file-list li:first-child {
  border-top: 1px solid var(--rule);
}

.file-list a {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0.25rem;
  text-decoration: none;
  color: var(--ink);
  transition: background 0.1s;
}

.file-list a:hover { background: var(--accent-lt); padding-left: 0.75rem; }

.file-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.file-name {
  font-family: 'Libre Baskerville', serif;
  font-size: 0.95rem;
}

.file-type {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--mid);
  background: var(--rule);
  padding: 0.15rem 0.45rem;
}

/* ── Footer ── */
footer {
  border-top: 1px solid var(--rule);
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--mid);
}

/* ── Responsive ── */
@media (max-width: 660px) {
  .level-desc { display: none; }
  .site-subtitle { font-size: 1.3rem; }
  .page-title { font-size: 1.5rem; }

  .nav-toggle {
    display: block;
  }

  nav {
    flex-direction: column;
    border-top: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
  }

  nav.open {
    max-height: 400px;
    border-top: 1px solid var(--rule);
  }

  nav a {
    display: block;
    padding: 0.75rem 0;
    margin-right: 0;
    border-bottom: 1px solid var(--rule);
    border-left: 3px solid transparent;
    font-size: 0.9rem;
  }

  nav a:hover,
  nav a.active {
    border-bottom-color: var(--rule);
    border-left-color: var(--accent);
    padding-left: 0.75rem;
    color: var(--accent);
  }
}
