/* PM-SETU DPR Reference Site — formal, light, print-report styling */

:root {
  --page-bg: #f6f7f5;
  --paper-bg: #ffffff;
  --ink: #1f2a24;
  --ink-soft: #4a564e;
  --ink-faint: #7a867d;
  --rule: #dde3dd;
  --rule-strong: #c3ccc3;
  --accent: #275842;
  --accent-soft: #e8efe9;
  --accent-strong: #163c2c;
  --code-bg: #eef1ee;
  --sidebar-bg: #14261e;
  --sidebar-ink: #dfe8e1;
  --sidebar-ink-dim: #9fb0a6;
  --sidebar-active-bg: #23412f;
  --shadow: 0 1px 3px rgba(20, 30, 24, 0.08);
  --max-width: 860px;
  --sidebar-width: 268px;
  --header-height: 56px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: "Source Serif Pro", Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

body, input, button { font-family: "Source Serif Pro", Georgia, "Times New Roman", serif; }

a { color: var(--accent-strong); text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

.ui, .sidebar, .topbar, .toc, button, .breadcrumb, .tag {
  font-family: "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Layout shell ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  overflow-y: auto;
  z-index: 40;
  transform: translateX(0);
  transition: transform 0.22s ease;
}

.sidebar-brand {
  padding: 20px 20px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand .brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  line-height: 1.35;
}
.sidebar-brand .brand-sub {
  font-size: 11.5px;
  color: var(--sidebar-ink-dim);
  margin-top: 4px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.sidebar-nav { padding: 10px 0 28px; }
.sidebar-section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-ink-dim);
  padding: 14px 20px 6px;
}
.sidebar-nav a.nav-link {
  display: block;
  padding: 9px 20px;
  color: var(--sidebar-ink);
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.sidebar-nav a.nav-link:hover { background: rgba(255,255,255,0.05); }
.sidebar-nav a.nav-link.active {
  background: var(--sidebar-active-bg);
  border-left-color: #6fbf95;
  color: #fff;
  font-weight: 600;
}
.sidebar-nav a.nav-link .doc-count {
  color: var(--sidebar-ink-dim);
  font-size: 11.5px;
  margin-left: 4px;
}
.sidebar-nav a.nav-link.gallery-link {
  margin-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 14px;
}

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(10, 16, 12, 0.45);
  z-index: 35;
}

.main-col {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-height);
  background: var(--paper-bg);
  border-bottom: 1px solid var(--rule);
  align-items: center;
  gap: 12px;
  padding: 0 14px;
}
.topbar .hamburger {
  width: 38px; height: 38px;
  border: 1px solid var(--rule-strong);
  background: #fff;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.topbar .hamburger span, .topbar .hamburger::before, .topbar .hamburger::after {
  content: ""; display: block; width: 16px; height: 2px; background: var(--ink);
  position: relative;
}
.topbar .hamburger { flex-direction: column; gap: 3px; }
.topbar .topbar-title {
  font-size: 14px; font-weight: 700; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.content-area {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 40px 32px 100px;
}

.content-inner {
  width: 100%;
  max-width: var(--max-width);
  min-width: 0;
}

/* ---------- Home page ---------- */

.hero {
  background: var(--paper-bg);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 40px 36px;
  box-shadow: var(--shadow);
}
.hero .eyebrow {
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 12px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 10px;
}
.hero h1 {
  font-size: 30px;
  margin: 0 0 12px;
  line-height: 1.25;
  color: var(--accent-strong);
}
.hero p.lede {
  font-size: 17px;
  color: var(--ink-soft);
  max-width: 60ch;
  margin: 0 0 6px;
}

.doc-grid {
  margin-top: 30px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.doc-card {
  display: block;
  background: var(--paper-bg);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 20px 20px 18px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.15s ease;
  font-family: "Helvetica Neue", Arial, sans-serif;
}
.doc-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.doc-card .doc-index {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.doc-card h3 {
  font-family: "Source Serif Pro", Georgia, serif;
  margin: 8px 0 8px;
  font-size: 19px;
  color: var(--accent-strong);
}
.doc-card p {
  margin: 0 0 12px;
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.55;
}
.doc-card .doc-meta {
  font-size: 12px;
  color: var(--ink-faint);
  display: flex;
  gap: 14px;
}

.gallery-cta {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--accent-soft);
  border: 1px solid #c9dccd;
  border-radius: 10px;
  padding: 18px 22px;
  font-family: "Helvetica Neue", Arial, sans-serif;
}
.gallery-cta a {
  font-weight: 700;
  color: var(--accent-strong);
  text-decoration: none;
  font-size: 15px;
}
.gallery-cta a:hover { text-decoration: underline; }
.gallery-cta .cta-desc { color: var(--ink-soft); font-size: 13.5px; }

/* ---------- Document page ---------- */

.doc-cover {
  border-bottom: 3px double var(--rule-strong);
  padding-bottom: 22px;
  margin-bottom: 8px;
}
.doc-cover .letterhead {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.doc-cover .letterhead img {
  max-height: 46px;
  width: auto;
}
.doc-cover h1 {
  font-size: 26px;
  line-height: 1.3;
  color: var(--accent-strong);
  margin: 0 0 10px;
  white-space: pre-line;
}
.doc-cover .cover-meta {
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.6;
}
.doc-cover .source-note {
  margin-top: 14px;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 11.5px;
  color: var(--ink-faint);
}

details.source-toc {
  margin: 18px 0 28px;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  color: var(--ink-soft);
  background: #fafbf9;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 4px 14px;
}
details.source-toc summary {
  cursor: pointer;
  padding: 10px 0;
  font-weight: 600;
  color: var(--ink);
}
details.source-toc .toc-lines { padding: 4px 0 14px; white-space: pre-line; line-height: 1.6; }

.doc-content h2 {
  font-size: 22px;
  color: var(--accent-strong);
  margin: 44px 0 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--rule-strong);
  scroll-margin-top: 20px;
}
.doc-content h3 {
  font-size: 18.5px;
  color: var(--accent-strong);
  margin: 32px 0 10px;
  scroll-margin-top: 20px;
}
.doc-content h4 {
  font-size: 16px;
  color: var(--ink);
  font-weight: 700;
  margin: 24px 0 8px;
  scroll-margin-top: 20px;
}
.doc-content h5 {
  font-size: 14.5px;
  color: var(--ink-soft);
  font-weight: 700;
  font-style: italic;
  margin: 18px 0 6px;
  scroll-margin-top: 20px;
}
.doc-content p { margin: 0 0 14px; }
.doc-content p.caption-note {
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  font-style: italic;
  color: var(--ink-faint);
}

.doc-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
}
.doc-list li {
  display: flex;
  gap: 8px;
  margin: 0 0 8px;
  padding-left: 0;
}
.doc-list li .marker {
  flex: none;
  color: var(--accent);
  font-weight: 700;
  min-width: 1.6em;
}
.doc-list li.lvl-1 { margin-left: 1.6em; }
.doc-list li.lvl-2 { margin-left: 3.2em; }
.doc-list li.lvl-3 { margin-left: 4.8em; }
.doc-list li.lvl-4 { margin-left: 6.4em; }

.table-wrap {
  overflow-x: auto;
  margin: 8px 0 26px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
table.doc-table {
  border-collapse: collapse;
  width: 100%;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  min-width: 480px;
}
table.doc-table th, table.doc-table td {
  border: 1px solid var(--rule);
  padding: 9px 12px;
  text-align: left;
  vertical-align: top;
  white-space: pre-line;
}
table.doc-table tr:first-child th,
table.doc-table tr:first-child td {
  background: var(--accent-soft);
  font-weight: 700;
  color: var(--accent-strong);
}
table.doc-table tr:nth-child(even):not(:first-child) td { background: #fafbf9; }

figure.diagram-figure {
  margin: 26px 0;
  padding: 16px;
  background: var(--paper-bg);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
figure.diagram-figure img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 4px;
  cursor: zoom-in;
  background: #fff;
}
figure.diagram-figure figcaption {
  margin-top: 12px;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
}
figure.diagram-figure .zoom-hint {
  display: inline-block;
  margin-top: 8px;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 11.5px;
  color: var(--ink-faint);
}

/* ---------- In-page TOC (right rail on desktop) ---------- */

.page-with-toc {
  display: flex;
  gap: 40px;
  align-items: flex-start;
  max-width: 1180px;
  margin: 0 auto;
  width: 100%;
}
.page-with-toc .content-inner { flex: 1; min-width: 0; }

.page-toc {
  flex: none;
  width: 230px;
  position: sticky;
  top: 24px;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}
.page-toc .page-toc-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-faint);
  font-weight: 700;
  margin-bottom: 10px;
}
.page-toc ul { list-style: none; margin: 0; padding: 0; }
.page-toc li a {
  display: block;
  padding: 5px 0 5px 10px;
  color: var(--ink-soft);
  text-decoration: none;
  border-left: 2px solid var(--rule);
  line-height: 1.4;
}
.page-toc li.lvl-3 a { padding-left: 22px; font-size: 12.3px; }
.page-toc li.lvl-4 a { padding-left: 34px; font-size: 12px; color: var(--ink-faint); }
.page-toc li a:hover { color: var(--accent-strong); }
.page-toc li a.active {
  border-left-color: var(--accent);
  color: var(--accent-strong);
  font-weight: 700;
}

.mobile-toc {
  display: none;
  margin: 0 0 28px;
  font-family: "Helvetica Neue", Arial, sans-serif;
}
.mobile-toc summary {
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--accent-strong);
  padding: 12px 14px;
  background: var(--accent-soft);
  border: 1px solid #c9dccd;
  border-radius: 8px;
}
.mobile-toc[open] summary { border-radius: 8px 8px 0 0; }
.mobile-toc .mobile-toc-list {
  border: 1px solid #c9dccd; border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 10px 16px 14px;
  font-size: 13.5px;
}
.mobile-toc .mobile-toc-list a {
  display: block; padding: 5px 0; color: var(--ink-soft); text-decoration: none;
}
.mobile-toc .mobile-toc-list li.lvl-3 { margin-left: 14px; }
.mobile-toc .mobile-toc-list li.lvl-4 { margin-left: 28px; font-size: 12.5px; }

/* ---------- Back to top ---------- */

.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent-strong);
  color: #fff;
  border: none;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(20,30,24,0.28);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 25;
}
.back-to-top.visible { display: flex; }

/* ---------- Diagrams gallery ---------- */

.gallery-header {
  margin-bottom: 24px;
}
.gallery-header h1 {
  font-size: 27px;
  color: var(--accent-strong);
  margin: 0 0 8px;
}
.gallery-header p { color: var(--ink-soft); max-width: 66ch; }

.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 30px;
  font-family: "Helvetica Neue", Arial, sans-serif;
}
.gallery-filters button {
  border: 1px solid var(--rule-strong);
  background: #fff;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 7px 15px;
  font-size: 13px;
  cursor: pointer;
}
.gallery-filters button.active {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #fff;
  font-weight: 600;
}

.gallery-doc-section { margin-bottom: 40px; }
.gallery-doc-section h2 {
  font-size: 19px;
  color: var(--accent-strong);
  border-bottom: 2px solid var(--rule-strong);
  padding-bottom: 8px;
  margin: 0 0 16px;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}
.gallery-item {
  background: var(--paper-bg);
  border: 1px solid var(--rule);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: zoom-in;
}
.gallery-item .thumb-wrap {
  background: #f2f4f1;
  display: flex; align-items: center; justify-content: center;
  height: 150px;
  overflow: hidden;
}
.gallery-item img { max-width: 100%; max-height: 100%; object-fit: contain; }
.gallery-item .gallery-caption {
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 12px;
  color: var(--ink-soft);
  padding: 10px 12px 12px;
  line-height: 1.45;
}
.gallery-item .gallery-caption .section-tag {
  display: block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 3px;
}

/* ---------- Lightbox ---------- */

.lightbox-overlay {
  position: fixed; inset: 0;
  background: rgba(10, 14, 11, 0.92);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 26px;
  flex-direction: column;
}
.lightbox-overlay.open { display: flex; }
.lightbox-overlay img {
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 4px;
  background: #fff;
}
.lightbox-caption {
  color: #eef1ee;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 13.5px;
  margin-top: 14px;
  max-width: 800px;
  text-align: center;
  line-height: 1.5;
}
.lightbox-close {
  position: absolute;
  top: 18px; right: 22px;
  background: none;
  border: none;
  color: #fff;
  font-size: 30px;
  cursor: pointer;
  line-height: 1;
}
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  font-size: 22px;
  width: 46px; height: 46px;
  border-radius: 50%;
  cursor: pointer;
}
.lightbox-nav.prev { left: 18px; }
.lightbox-nav.next { right: 18px; }

/* ---------- Footer ---------- */

.site-footer {
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 12px;
  color: var(--ink-faint);
  text-align: center;
  padding: 30px 20px 50px;
}

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .page-toc { display: none; }
  .mobile-toc { display: block; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open { display: block; }
  .main-col { margin-left: 0; }
  .topbar { display: flex; }
  .content-area { padding: 24px 16px 90px; }
  .hero { padding: 28px 20px; }
  .hero h1 { font-size: 24px; }
}

@media (max-width: 520px) {
  body { font-size: 16px; }
  .doc-cover h1 { font-size: 21px; }
  .doc-content h2 { font-size: 19px; }
  .doc-content h3 { font-size: 17px; }
  .doc-list li.lvl-1 { margin-left: 1.1em; }
  .doc-list li.lvl-2 { margin-left: 2.2em; }
  .doc-list li.lvl-3 { margin-left: 3.3em; }
  .doc-list li.lvl-4 { margin-left: 4.4em; }
  figure.diagram-figure { padding: 10px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .gallery-item .thumb-wrap { height: 120px; }
}
