/* Study the Greats — Editorial Layout & Manuscript Theme
   Adapted from scripture-folios: vellum, iron-gall ink, vermilion rubrics, Fraunces + Literata.
   Light palette only, whatever the system preference. */

:root {
  color-scheme: light;
  --paper: #f4eee1;
  --panel: #faf5ec;
  --card-bg: #fdfbf7;
  --ink: #2b2118;
  --muted: #6e5a44;
  --faint: #8e7a64;
  --rule: #d6c6a6;
  --rule-light: #e8dcc6;
  --accent: #9a2b1b;
  --accent-soft: rgba(154, 43, 27, 0.08);
  --hl: rgba(190, 140, 50, 0.18);
  --hover: rgba(110, 75, 25, 0.05);
  --scrim: rgba(40, 25, 10, 0.35);
  --edge: rgba(150, 105, 40, 0.08);
  --gutter: rgba(90, 60, 20, 0.10);
  --display: "Fraunces", Georgia, serif;
  --text: "Literata", Georgia, serif;
  --code: "JetBrains Mono", "SF Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --panel-w: 38rem;
  --page-w: 44rem;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: radial-gradient(ellipse 120% 90% at 50% 30%, transparent 60%, var(--edge)) fixed, var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-size: 1.22rem;
  line-height: 1.7;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--hl); }
.sc { font-variant-caps: small-caps; letter-spacing: 0.04em; }

/* Header & Top Navigation */
.site-header {
  border-bottom: 1px solid var(--rule-light);
  background: rgba(244, 238, 225, 0.94);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.header-inner {
  max-width: var(--page-w);
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--ink);
}

.brand-title {
  font-family: var(--display);
  font-variation-settings: "opsz" 36, "SOFT" 60;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.brand-mark {
  font-family: var(--display);
  color: var(--accent);
  font-size: 1.15rem;
}

.dossier-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(154, 43, 27, 0.25);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dossier-pill-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(154, 43, 27, 0.2);
}

.nav-back-link {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--card-bg);
  transition: all 0.15s ease;
}

.nav-back-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--hover);
}

/* Page Container */
.page {
  max-width: var(--page-w);
  margin: 0 auto;
  padding: 3rem 1.5rem 6rem;
}

/* Portrait Headings */
.portrait-head {
  margin: 1.5rem 0 3rem;
  text-align: left;
}

.portrait-head-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
}

.portrait-head-text {
  flex: 1;
  min-width: 0;
}

.portrait-figure {
  flex-shrink: 0;
  margin: 0;
}

.portrait-hedcut {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  mix-blend-mode: multiply;
  display: block;
}

@media (max-width: 640px) {
  .portrait-head-inner {
    flex-direction: column-reverse;
    gap: 1.25rem;
  }
  .portrait-hedcut {
    width: 110px;
    height: 110px;
  }
}

h1.title {
  font-family: var(--display);
  font-weight: 400;
  font-variation-settings: "opsz" 144, "SOFT" 40;
  font-size: clamp(2.4rem, 6.5vw, 3.8rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 0.85rem;
  color: var(--ink);
}

.subtitle {
  font-family: var(--display);
  font-style: italic;
  font-variation-settings: "opsz" 36;
  font-size: 1.35rem;
  line-height: 1.35;
  color: var(--muted);
  margin: 0;
}

/* Portrait Prose */
.prose {
  font-family: var(--text);
  font-size: 1.22rem;
  line-height: 1.72;
  color: var(--ink);
}

.prose p {
  margin: 0 0 1.45rem;
}

.prose h2, .prose h3 {
  font-family: var(--display);
  font-weight: 500;
  font-variation-settings: "opsz" 48, "SOFT" 40;
  color: var(--ink);
  margin: 2.75rem 0 1rem;
  line-height: 1.2;
}

.prose h2 {
  font-size: 1.7rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule-light);
}

.prose h3 {
  font-size: 1.35rem;
}

.prose blockquote {
  margin: 2rem 0;
  padding: 1rem 1.75rem;
  border-left: 3px solid var(--accent);
  background: rgba(154, 43, 27, 0.03);
  border-radius: 0 6px 6px 0;
  font-style: italic;
  font-size: 1.15rem;
  color: var(--ink);
}

.prose blockquote p:last-child {
  margin-bottom: 0;
}

hr.divider, .prose hr {
  border: 0;
  text-align: center;
  margin: 1.25rem 0;
  color: var(--rule);
}

hr.divider::before, .prose hr::before {
  content: "❧";
  font-family: var(--display);
  color: var(--accent);
  font-size: 1.15rem;
}

.prose code {
  font-family: var(--code);
  font-size: 0.9em;
  background: rgba(110, 75, 25, 0.08);
  padding: 0.15em 0.35em;
  border-radius: 4px;
  color: #731e13;
}

.prose pre {
  background: #251d18;
  color: #f5eedf;
  padding: 1.25rem 1.5rem;
  border-radius: 8px;
  overflow-x: auto;
  font-family: var(--code);
  font-size: 0.92rem;
  line-height: 1.55;
  border: 1px solid rgba(214, 198, 166, 0.2);
  margin: 2rem 0;
}

.prose pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

/* Quotes Section at End of Article */
.quotes-section {
  margin: 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.quote-item {
  margin: 0;
  padding: 0;
  border: none;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.98rem;
  line-height: 1.45;
  color: var(--ink);
}

.quote-item p {
  margin: 0;
}

.quote-author {
  display: inline;
  font-family: var(--sans);
  font-style: normal;
  font-size: 0.8em;
  letter-spacing: 0.02em;
  color: var(--faint);
  margin-left: 0.35rem;
  white-space: nowrap;
}

/* Main Works Section at End of Article */
.works-list {
  list-style: none;
  margin: 0.75rem 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.works-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.25rem 0;
  border-bottom: 1px dashed var(--rule-light);
  font-size: 0.98rem;
}

.work-title {
  font-family: var(--display);
  font-style: italic;
  color: var(--ink);
}

.work-year {
  font-family: var(--code);
  font-size: 0.85rem;
  color: var(--faint);
}

/* Action Buttons Row at End of Article */
.action-buttons-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin: 1.75rem 0 2rem;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1.15rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: all 0.18s ease;
}

.action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--hover);
  box-shadow: 0 2px 8px rgba(154, 43, 27, 0.08);
}

.action-btn .action-icon {
  font-size: 0.9em;
  color: var(--muted);
  transition: transform 0.15s ease, color 0.15s ease;
}

.action-btn:hover .action-icon {
  color: var(--accent);
  transform: translate(2px, -2px);
}

.action-btn-dossier {
  background: var(--accent-soft);
  border-color: rgba(154, 43, 27, 0.35);
  color: var(--accent);
  font-weight: 600;
}

.action-btn-dossier:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 3px 10px rgba(154, 43, 27, 0.22);
}

.action-btn-dossier .action-icon {
  color: var(--accent);
}

.action-btn-dossier:hover .action-icon {
  color: #fff;
  transform: translateX(3px);
}

/* Standalone Dossier Page Elements */
.dossier-preamble-card {
  padding: 1.5rem 1.75rem;
  background: var(--card-bg);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--muted);
  margin-bottom: 2rem;
}

.dossier-preamble-card p:last-child {
  margin-bottom: 0;
}

.dossier-controls-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1.25rem;
}

.dossier-footer-nav {
  margin: 3rem 0;
  text-align: center;
}

/* Dossier Callout Card */
.dossier-callout-card {
  margin: 1.5rem 0 2rem;
  padding: 1.5rem 1.75rem;
  background: var(--card-bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(70, 45, 20, 0.04);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.dossier-callout-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.dossier-callout-title {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0;
}

.dossier-callout-desc {
  font-size: 1.05rem;
  color: var(--muted);
  margin: 0;
}

/* Next / Prev Navigation at Bottom */
.portrait-footer-nav {
  margin-top: 4.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.footer-nav-card {
  display: block;
  text-decoration: none;
  padding: 1.25rem;
  background: var(--card-bg);
  border: 1px solid var(--rule-light);
  border-radius: 6px;
  color: inherit;
  transition: all 0.2s ease;
}

.footer-nav-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(154, 43, 27, 0.08);
}

.footer-nav-card.next {
  text-align: right;
}

.footer-nav-label {
  font-family: var(--sans);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--faint);
  display: block;
  margin-bottom: 0.4rem;
}

.footer-nav-title {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
}

.footer-nav-card:hover .footer-nav-title {
  color: var(--accent);
}

/* Bottom Popup Dossier Sheet (All Viewports) */
.scrim {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s;
  z-index: 20;
}

.panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  height: 88vh;
  height: 88dvh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -10px 40px rgba(43, 33, 24, 0.25);
  transform: translateY(100%);
  visibility: hidden;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
  z-index: 25;
}

.panel::before {
  content: "";
  display: block;
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--rule);
  margin: 10px auto 2px;
  flex-shrink: 0;
}

.is-panel-open .scrim { opacity: 1; visibility: visible; }
.is-panel-open .panel { transform: translateY(0); visibility: visible; }
html.is-panel-open, body.is-panel-open { overflow: hidden; }

@media (max-width: 960px) {
  .panel {
    border-left: none;
    border-right: none;
    border-radius: 14px 14px 0 0;
  }
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--rule);
  background: rgba(250, 245, 236, 0.95);
  position: sticky;
  top: 0;
  z-index: 2;
}

.panel-title-group h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.35rem;
  line-height: 1.2;
  color: var(--ink);
}

.panel-subtitle {
  font-family: var(--sans);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  margin-top: 0.2rem;
}

.panel-controls {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.panel-btn {
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.35rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.panel-btn:hover {
  background: var(--hover);
  color: var(--ink);
  border-color: var(--faint);
}

.panel-close {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1.8rem;
  line-height: 1;
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  cursor: pointer;
}

.panel-close:hover {
  color: var(--accent);
  background: var(--hover);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.5rem 1.75rem 4rem;
}

/* Expandable Dossier Sections (Accordion) */
.dossier-section {
  background: var(--card-bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  margin-bottom: 1.25rem;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(70, 45, 20, 0.03);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.dossier-section[open] {
  border-color: rgba(154, 43, 27, 0.35);
  box-shadow: 0 4px 16px rgba(70, 45, 20, 0.06);
}

.dossier-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.15rem 1.35rem;
  cursor: pointer;
  user-select: none;
  background: transparent;
  list-style: none;
  transition: background 0.15s ease;
}

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

.dossier-summary:hover {
  background: var(--hover);
}

.dossier-summary-left {
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
}

.dossier-num {
  font-family: var(--display);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.dossier-heading {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.18rem;
  color: var(--ink);
  line-height: 1.3;
}

.dossier-chevron {
  font-size: 0.85rem;
  color: var(--faint);
  transition: transform 0.2s ease;
}

.dossier-section[open] .dossier-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

.dossier-content {
  padding: 0 1.5rem 1.75rem;
  border-top: 1px solid var(--rule-light);
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--ink);
}

.dossier-content h3 {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 1.75rem 0 0.6rem;
  color: var(--ink);
}

.dossier-content h4 {
  font-family: var(--sans);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 1.25rem 0 0.4rem;
  color: var(--muted);
}

.dossier-content p {
  margin: 0 0 1.15rem;
}

.dossier-content ul, .dossier-content ol {
  padding-left: 1.4rem;
  margin: 0 0 1.25rem;
}

.dossier-content li {
  margin-bottom: 0.45rem;
}

.dossier-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin: 1.5rem 0;
}

.dossier-content th, .dossier-content td {
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--rule);
  text-align: left;
}

.dossier-content th {
  background: rgba(110, 75, 25, 0.05);
  font-family: var(--sans);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* Claims Register Badges */
.claim-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-family: var(--code);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
}

.claim-v { background: #e3f2e6; color: #1e6b2c; border: 1px solid #b7dfbc; }
.claim-c { background: #e8f4fc; color: #1b639e; border: 1px solid #b5dcf6; }
.claim-s { background: #fff8e6; color: #8a6409; border: 1px solid #f4dfa1; }
.claim-i { background: #f5edf9; color: #6f2b8a; border: 1px solid #ddc3e9; }
.claim-u { background: #fdeeee; color: #a32222; border: 1px solid #f6bebe; }

/* Index / Catalog Page */
.index-hero {
  margin: 2.5rem 0 3.5rem;
  text-align: left;
}

.index-title {
  font-family: var(--display);
  font-weight: 400;
  font-variation-settings: "opsz" 144, "SOFT" 40;
  font-size: clamp(2.8rem, 8vw, 4.6rem);
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
  color: var(--ink);
}

.index-lead {
  font-family: var(--display);
  font-style: italic;
  font-variation-settings: "opsz" 36;
  font-size: 1.4rem;
  line-height: 1.4;
  color: var(--muted);
  max-width: 36rem;
  margin: 0;
}

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

.great-item {
  border-top: 1px solid var(--rule);
  padding: 2.25rem 1.25rem;
  margin: 0 -1.25rem;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  display: block;
  color: inherit;
  transition: all 0.18s ease;
}

.great-item:hover {
  background: var(--hover);
  box-shadow: inset 3px 0 0 var(--accent);
}

.great-item:last-child {
  border-bottom: 1px solid var(--rule);
}

.great-grid {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 1.75rem;
  align-items: flex-start;
}

.great-portrait-col {
  width: 88px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
}

.great-num {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.35rem;
  color: var(--accent);
  letter-spacing: 0.05em;
  padding-top: 0.25rem;
}

.great-thumb {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  mix-blend-mode: multiply;
  display: block;
}

.great-main h2 {
  font-family: var(--display);
  font-weight: 500;
  font-variation-settings: "opsz" 72, "SOFT" 30;
  font-size: 2.1rem;
  line-height: 1.15;
  margin: 0 0 0.4rem;
  color: var(--ink);
  transition: color 0.15s ease;
}

.great-item:hover .great-main h2 {
  color: var(--accent);
}

.great-subtitle {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--muted);
  margin: 0;
}

.great-act {
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--ink);
  margin: 0 0 1rem;
  max-width: 40rem;
}

.great-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.great-tag {
  font-family: var(--sans);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.5rem;
  background: rgba(110, 75, 25, 0.06);
  border-radius: 4px;
  color: var(--muted);
}

/* Site Footer */
.site-footer {
  margin-top: 5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--muted);
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
}

/* Dossier Sheet Desktop Padding */
@media (min-width: 961px) {
  .panel-head { padding: 1.25rem 2.25rem; }
  .panel-body { padding: 1.5rem 2.25rem 4rem; }
}

@media (max-width: 768px) {
  body { font-size: 1.15rem; }
  .header-inner { padding: 0.75rem 1rem; }
  .great-grid { grid-template-columns: 68px 1fr; gap: 1.15rem; align-items: flex-start; }
  .great-portrait-col { width: 68px; }
  .great-thumb { width: 68px; height: 68px; }
  .portrait-footer-nav { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .page, .panel, .scrim, .dossier-chevron { transition: none; }
}

/* ==========================================================================
   PWA Install Button
   ========================================================================== */
.install-pwa-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--card-bg);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
}

.install-pwa-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.install-pwa-btn.hidden {
  display: none !important;
}
