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

:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --text: #2c2416;
  --text-muted: #6b5f4e;
  --border: #e8dfd0;
  --accent-ink: #5c4030;
  --link: #6b3f1d;
  --link-hover: #3d2410;
  --shadow: 0 8px 32px rgba(44, 36, 22, 0.08);
  --radius: 16px;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Source Sans 3", system-ui, sans-serif;
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--text);
  background:
    radial-gradient(ellipse at top, #fff8ee 0%, transparent 60%),
    var(--bg);
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

a {
  color: var(--link);
}

a:hover {
  color: var(--link-hover);
}

.page-nav {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  font-weight: 500;
  color: var(--text-muted);
}

.back-link:hover {
  color: var(--link);
}

.site-header {
  text-align: center;
  padding: 2rem 1.25rem 1rem;
  max-width: 52rem;
  margin: 0 auto;
}

.eyebrow {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.site-header h1,
.hub-intro h1 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(1.5rem, 3.5vw, 2.25rem);
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.35;
}

.subtitle {
  margin: 0.5rem 0 0;
  color: var(--text-muted);
  font-size: 1rem;
}

/* —— Hub landing —— */
.page-hub {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.hub-shell {
  flex: 1;
  display: grid;
  gap: 1.5rem;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 2rem 1.5rem 1.5rem 0;
  align-items: start;
}

@media (min-width: 700px) {
  .hub-shell {
    grid-template-columns: minmax(14rem, 18rem) 1fr;
    gap: 2.5rem;
    padding: 3rem 2rem 1.5rem 0;
    align-items: start;
  }

  .hub-side {
    justify-self: start;
    width: 100%;
    max-width: 18rem;
    padding-left: 0;
  }
}

.hub-side {
  min-width: 0;
}

.hub-side-label {
  margin: 0 0 0.5rem;
  padding-left: 0.85rem;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
}

.hub-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}

.hub-list li {
  margin: 0;
  border-bottom: 1px solid var(--border);
}

.hub-list a {
  display: block;
  padding: 0.55rem 0.85rem;
  text-decoration: none;
  color: var(--accent-ink) !important;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
}

.hub-list a:hover,
.hub-list a:focus-visible {
  color: var(--link-hover) !important;
  background: #fcf9f4;
  outline: none;
}

.hub-list a:visited {
  color: var(--accent-ink) !important;
}

.hub-link-with-logo {
  display: flex !important;
  align-items: center;
  justify-content: flex-start;
  gap: 0.65rem;
}

.hub-link-logo {
  width: 2.4rem;
  height: 2.4rem;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 4px;
}

.hub-intro {
  text-align: left;
  padding-top: 0.15rem;
  max-width: 40rem;
}

.hub-intro .subtitle {
  max-width: 32rem;
}

.hub-footer {
  border-top: none;
  padding-bottom: 1.5rem;
}

.layout {
  display: grid;
  gap: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem 2.5rem;
}

@media (min-width: 900px) {
  .layout {
    grid-template-columns: 1fr 1fr;
    align-items: start;
    gap: 2rem;
  }
}

.pyramid-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.pyramid-wrapper {
  position: relative;
  width: 100%;
  max-width: 560px;
  aspect-ratio: 1536 / 1024;
}

.pyramid-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.pyramid-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.level-hit {
  fill: transparent;
  stroke: transparent;
  stroke-width: 3;
  pointer-events: all;
  cursor: pointer;
  transition: fill 0.2s ease, stroke 0.2s ease;
}

.level-hit:hover,
.level-hit:focus {
  fill: rgba(255, 255, 255, 0.18);
  outline: none;
}

.level-hit.active {
  fill: rgba(255, 255, 255, 0.28);
  stroke: rgba(255, 255, 255, 0.7);
}

.content-section {
  min-height: 280px;
}

.content-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.75rem;
  max-height: 70vh;
  overflow-y: auto;
}

@media (min-width: 900px) {
  .content-panel {
    position: sticky;
    top: 1.5rem;
    max-height: calc(100vh - 3rem);
  }
}

.placeholder {
  margin: 0;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem 0;
}

.layer-content {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.layer-content h2 {
  margin: 0 0 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 3px solid var(--accent, #ccc);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(1.4rem, 3vw, 1.75rem);
  font-weight: 600;
  line-height: 1.3;
}

.layer-content h3 {
  margin: 1.25rem 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.layer-content ul {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

.layer-content li {
  margin-bottom: 0.6rem;
}

.layer-content li:last-child {
  margin-bottom: 0;
}

.layer-list {
  list-style: none;
  padding-left: 0;
}

.layer-list li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.layer-list li:last-child {
  border-bottom: none;
}

.doc-wrap {
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

.doc-intro {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
}

.lead {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  line-height: 1.45;
}

.arrow-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.arrow-list li {
  position: relative;
  padding-left: 1.4rem;
  margin-bottom: 0.55rem;
  color: var(--text-muted);
}

.arrow-list li::before {
  content: "⇒";
  position: absolute;
  left: 0;
  color: var(--accent-ink);
}

.section-title {
  margin: 2rem 0 0.35rem;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.65rem;
  font-weight: 600;
  color: var(--accent-ink);
}

.section-hint {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.collapse {
  background: transparent;
  border: none;
  border-radius: 0;
  margin-bottom: 0.85rem;
  overflow: visible;
}

.collapse-indent {
  margin-left: 4.5rem;
  max-width: calc(100% - 4.5rem);
}

.collapse summary {
  cursor: pointer;
  list-style: none;
  padding: 0.85rem 1.1rem;
  font-weight: 600;
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.collapse summary::-webkit-details-marker {
  display: none;
}

.collapse summary::after {
  content: "+";
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1;
}

.collapse[open] summary::after {
  content: "−";
}

.collapse summary:hover {
  background: #fcf9f4;
}

.collapse[open] summary {
  border-radius: 12px;
}

.collapse-body,
.collapse > ul {
  margin: 0.55rem 0 0 2.75rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  max-width: calc(100% - 2.75rem);
}

.collapse-body p {
  margin: 0 0 0.85rem;
}

.collapse-body p:last-child {
  margin-bottom: 0;
}

.collapse-body ul {
  margin: 0.35rem 0 0.85rem;
  padding-left: 1.2rem;
}

.collapse-body ul:last-child {
  margin-bottom: 0;
}

.collapse > ul {
  padding-left: 2.2rem;
}

.inline-jump {
  display: inline;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.relationship-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 700px) {
  .relationship-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.rel-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow);
}

.rel-block h2 {
  margin: 0 0 0.75rem;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--accent-ink);
}

.rel-block ul {
  margin: 0;
  padding-left: 1.2rem;
}

.rel-block li {
  margin-bottom: 0.4rem;
}

.chart-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

.chart-table-scroll {
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}

.chart-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 860px;
  font-size: 0.92rem;
}

.chart-table th,
.chart-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 0.9rem;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.chart-table thead th {
  background: #f3ebe0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  box-shadow: 0 1px 0 var(--border);
}

.chart-table .col-level {
  width: 5.75rem;
  min-width: 5.75rem;
  max-width: 5.75rem;
  padding: 0.7rem 0.55rem;
  white-space: normal;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--border);
  font-size: 0.82rem;
  line-height: 1.3;
  color: var(--level-color, var(--text));
  font-weight: 600;
}

.chart-table thead .col-level {
  background: #f3ebe0;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.chart-table tbody tr:nth-child(even) .col-level {
  background: #fcf9f4;
}

.chart-table tbody tr:nth-child(odd) .col-level {
  background: var(--surface);
}

.level-pip {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--level-color, #999);
  margin-right: 0.3rem;
  vertical-align: middle;
  flex-shrink: 0;
}

.level-label {
  vertical-align: middle;
}

.chart-table tbody tr:last-child th,
.chart-table tbody tr:last-child td {
  border-bottom: none;
}

.site-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
}

.site-footer p {
  margin: 0;
}

/* —— Mobile polish —— */
@media (max-width: 699px) {
  body {
    font-size: 1rem;
    line-height: 1.6;
  }

  .page-nav {
    padding: 0.9rem 1rem 0;
  }

  .site-header {
    padding: 1.25rem 1rem 0.75rem;
    text-align: left;
  }

  .site-header h1,
  .hub-intro h1 {
    font-size: clamp(1.35rem, 6vw, 1.7rem);
  }

  .subtitle {
    font-size: 0.95rem;
  }

  .hub-shell {
    padding: 1.25rem 1rem 1rem 0;
    gap: 1.25rem;
  }

  .hub-side-label {
    padding-left: 0.75rem;
  }

  .hub-list a {
    padding: 0.7rem 0.75rem;
    font-size: 0.95rem;
  }

  .hub-link-logo {
    width: 2.2rem;
    height: 2.2rem;
  }

  .doc-wrap,
  .chart-wrap,
  .layout {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .doc-intro {
    padding: 1.15rem 1.1rem;
  }

  .collapse-indent {
    margin-left: 1.25rem;
    max-width: calc(100% - 1.25rem);
  }

  .collapse summary {
    padding: 0.9rem 1rem;
    font-size: 0.98rem;
    gap: 0.75rem;
  }

  .collapse-body,
  .collapse > ul {
    margin-left: 1.35rem;
    max-width: calc(100% - 1.35rem);
    padding: 0.9rem 1rem;
  }

  .content-panel {
    max-height: none;
    padding: 1.15rem 1.1rem;
  }

  .pyramid-wrapper {
    max-width: 100%;
    border-radius: 12px;
  }

  .pyramid-image {
    border-radius: 12px;
  }

  .chart-wrap {
    padding-bottom: 2rem;
  }

  .chart-table-scroll {
    overflow: auto;
    max-height: min(72vh, 28rem);
    border-radius: 12px;
    overscroll-behavior: contain;
  }

  .chart-table {
    min-width: 760px;
    font-size: 0.88rem;
  }

  .chart-table th,
  .chart-table td {
    padding: 0.7rem 0.65rem;
  }

  .chart-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
  }

  .chart-table .col-level {
    position: sticky;
    left: 0;
    z-index: 1;
    width: 6.5rem;
    min-width: 6.5rem;
    max-width: 6.5rem;
    padding: 0.55rem 0.45rem;
    font-size: 0.72rem;
    line-height: 1.25;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
  }

  .chart-table thead .col-level {
    top: 0;
    left: 0;
    z-index: 3;
  }

  .level-pip {
    display: none;
  }

  .level-label {
    display: block;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .relationship-grid {
    grid-template-columns: 1fr;
  }

  .rel-block {
    padding: 1.05rem 1.1rem;
  }

  .section-hint {
    font-size: 0.88rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* CMS-rendered content */
.cms-image-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  margin: 1rem 0;
}

.cms-figure {
  margin: 0;
}

.cms-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
}

.cms-section + .cms-section {
  margin-top: 0.35rem;
}

.cms-indent {
  margin: 0.15rem 0;
}

.cms-break {
  height: 0.65rem;
}

.hub-loading {
  color: var(--text-muted);
  font-size: 0.95rem;
}
