/* ================================================
   OPUS — Style
   Parchment ground. Gold ink. Let the words breathe.
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400;1,600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:         #f0e6d3;
  --bg-raised:  #e8dcc6;
  --bg-code:    #e3d7c0;
  --gold:       #6a4e04;
  --gold-dim:   #7a5c10;
  --gold-glow:  rgba(139, 105, 20, 0.08);
  --text:       #110e08;
  --text-dim:   #4a3f30;
  --text-bright:#110e08;
  --border:     rgba(100, 80, 40, 0.15);
  --serif:      'Cormorant Garamond', 'Georgia', serif;
  --mono:       'JetBrains Mono', 'Consolas', monospace;
}

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

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  line-height: 1.75;
  min-height: 100vh;
}

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

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem;
  position: relative;
}

/* ---- Navigation ---- */

nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(240, 230, 211, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.8rem 0;
}

nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

nav .logo {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
  text-decoration: none;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

nav .nav-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}

nav .nav-links a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  transition: color 0.2s;
}

nav .nav-links a:hover,
nav .nav-links a.active {
  color: var(--gold);
}

/* ---- Hero (index only) ---- */

.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 6rem 1.5rem 4rem;
}

.hero h1 {
  font-family: var(--serif);
  font-size: 4.5rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}

.hero .subtitle {
  font-family: var(--serif);
  font-size: 2.5rem;
  font-style: italic;
  color: var(--text-dim);
  max-width: 700px;
  line-height: 1.5;
  margin-bottom: 3rem;
}

.hero .numbers {
  display: flex;
  gap: 3rem;
  margin-bottom: 3rem;
  flex-wrap: wrap;
  justify-content: center;
}

.hero .number-block {
  text-align: center;
}

.hero .number-block .value {
  font-family: var(--mono);
  font-size: 2.2rem;
  font-weight: 500;
  color: var(--text-bright);
  display: block;
}

.hero .number-block .label {
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 0.25rem;
  display: block;
}

.hero .enter {
  display: inline-block;
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 600;
  color: var(--gold);
  border: 1px solid var(--gold-dim);
  padding: 0.75rem 2.5rem;
  text-decoration: none;
  letter-spacing: 0.1em;
  transition: all 0.3s;
}

.hero .enter:hover {
  background: var(--gold-glow);
  border-color: var(--gold);
}

.hero .scroll-arrow {
  display: block;
  margin-top: 4rem;
  color: var(--gold-dim);
  text-decoration: none;
  transition: color 0.3s, transform 0.3s;
  animation: arrowBounce 2.5s ease-in-out infinite;
}

.hero .scroll-arrow svg {
  width: 44px;
  height: 44px;
}

.hero .scroll-arrow:hover {
  color: var(--gold);
  transform: translateY(4px);
}

@keyframes arrowBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(10px); }
}

/* ---- Implications section ---- */

.implications-section {
  padding: 5rem 0;
  border-top: 1px solid var(--border);
}

.implications-section h2 {
  font-family: var(--serif);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 1rem;
  text-align: center;
}

.implications-intro {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-style: italic;
  color: var(--text-dim);
  text-align: center;
  max-width: 640px;
  margin: 0 auto 2.5rem;
  line-height: 1.8;
}

.implications-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.implication-card {
  border: 1px solid var(--border);
  padding: 1.8rem;
  transition: background 0.2s;
}

.implication-card:hover {
  background: var(--gold-glow);
}

.implication-card h3 {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 0.8rem;
}

.implication-card p {
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--text-dim);
  line-height: 1.75;
}

.implications-cta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  font-family: var(--mono);
  font-size: 0.9rem;
}

.implications-cta code {
  background: var(--bg-code);
  padding: 0.4rem 0.8rem;
  border-radius: 3px;
  color: var(--gold);
  font-size: 0.85rem;
}

.implications-cta a {
  color: var(--gold-dim);
  text-decoration: none;
  transition: color 0.2s;
}

.implications-cta a:hover {
  color: var(--gold);
}

.implications-cta span {
  color: var(--border);
}

@media (max-width: 680px) {
  .implications-grid { grid-template-columns: 1fr; }
  .implications-cta { flex-direction: column; gap: 0.5rem; }
}

/* ---- Chapter index (index page) ---- */

.chapters-section {
  padding: 5rem 0;
  border-top: 1px solid var(--border);
}

.chapters-section h2 {
  font-family: var(--serif);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold-dim);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 2.5rem;
}

.chapter-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.chapter-list li {
  border-top: 1px solid var(--border);
}

.chapter-list li:last-child {
  border-bottom: 1px solid var(--border);
}

.chapter-list a {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  padding: 1.25rem 0;
  text-decoration: none;
  transition: background 0.2s;
}

.chapter-list a:hover {
  background: var(--gold-glow);
  padding-left: 1rem;
  margin-left: -1rem;
  padding-right: 1rem;
  margin-right: -1rem;
}

.chapter-list .ch-num {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--gold-dim);
  min-width: 2rem;
}

.chapter-list .ch-title {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-bright);
}

.chapter-list .ch-desc {
  font-family: var(--serif);
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-left: auto;
}

/* ---- Projects grid (index page) ---- */

.projects-section {
  padding: 5rem 0;
  border-top: 1px solid var(--border);
}

.projects-section h2 {
  font-family: var(--serif);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold-dim);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 2.5rem;
}

.projects-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}

.project-card {
  background: var(--bg);
  padding: 1.5rem;
  text-decoration: none;
  transition: background 0.2s;
}

.project-card:hover {
  background: var(--bg-raised);
}

.project-card .p-name {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 0.35rem;
}

.project-card .p-lang {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--gold-dim);
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.project-card .p-desc {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ---- Chapter pages ---- */

.chapter-header {
  padding: 7rem 0 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.chapter-header .ch-number {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--gold-dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 1rem;
  display: block;
}

.chapter-header h1 {
  font-family: var(--serif);
  font-size: 3rem;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 1.5rem;
}

.chapter-header .epigraph {
  font-style: italic;
  color: var(--text-dim);
  font-size: 1rem;
  line-height: 1.8;
  border-left: 2px solid var(--gold-dim);
  padding-left: 1.25rem;
}

.chapter-header .epigraph cite {
  display: block;
  font-size: 0.8rem;
  margin-top: 0.5rem;
  font-style: normal;
  color: var(--gold-dim);
}

/* ---- Chapter body ---- */

.chapter-body {
  padding-bottom: 6rem;
  font-size: 1.2rem;
  line-height: 1.75;
}

.chapter-body h2 {
  font-family: var(--serif);
  font-size: 1.92rem;
  font-weight: 700;
  color: var(--text-bright);
  margin-top: 3.5rem;
  margin-bottom: 1.25rem;
}

.chapter-body h3 {
  font-family: var(--serif);
  font-size: 1.38rem;
  font-weight: 600;
  color: var(--gold);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}

.chapter-body p {
  margin-bottom: 1.25rem;
}

.chapter-body strong {
  color: var(--text-bright);
  font-weight: 600;
}

.chapter-body em {
  font-style: italic;
}

.chapter-body blockquote {
  border-left: 2px solid var(--gold-dim);
  padding-left: 1.25rem;
  margin: 2rem 0;
  color: var(--text-dim);
  font-style: italic;
}

.chapter-body ul, .chapter-body ol {
  margin: 1.25rem 0;
  padding-left: 1.5rem;
}

.chapter-body li {
  margin-bottom: 0.5rem;
}

.chapter-body code {
  font-family: var(--mono);
  font-size: 0.96rem;
  background: var(--bg-code);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  color: var(--gold);
}

.chapter-body pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  border-radius: 3px;
}

.chapter-body pre code {
  background: none;
  padding: 0;
  font-size: 0.94rem;
  line-height: 1.6;
  color: var(--text);
}

.chapter-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 3rem 0;
}

/* ---- Chapter nav (bottom) ---- */

.chapter-nav {
  display: flex;
  justify-content: space-between;
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--border);
}

.chapter-nav a {
  color: var(--gold-dim);
  text-decoration: none;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  transition: color 0.2s;
  font-family: var(--serif);
}

.chapter-nav a:hover {
  color: var(--gold);
}

/* ---- Evidence table ---- */

.evidence-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

.evidence-table th {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--gold-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: left;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.evidence-table td {
  font-size: 0.9rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.evidence-table td:first-child {
  color: var(--text-bright);
  font-weight: 600;
}

.evidence-table td:last-child {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: right;
}

/* ---- Disclaimer bubble ---- */

.disclaimer-bubble {
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  margin: 2rem 0;
  padding: 1rem 1.4rem;
  border: 1.5px dashed var(--gold-dim);
  border-radius: 12px;
  transition: all 0.3s ease;
  background: transparent;
}

.disclaimer-bubble:hover {
  background: var(--gold-glow);
  border-color: var(--gold);
}

.bubble-icon {
  width: 70px;
  height: 50px;
  flex-shrink: 0;
}

.bubble-label {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-style: italic;
  color: var(--gold-dim);
  transition: color 0.2s;
}

.disclaimer-bubble:hover .bubble-label {
  color: var(--gold);
}

.bubble-content {
  display: none;
  margin-top: 1rem;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-style: italic;
  color: var(--text-dim);
  line-height: 1.8;
}

.bubble-content p {
  margin: 0;
}

.disclaimer-bubble.expanded {
  flex-direction: column;
  align-items: flex-start;
}

.disclaimer-bubble.expanded .bubble-content {
  display: block;
}

.disclaimer-bubble.expanded .bubble-label {
  color: var(--gold);
}

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

footer {
  border-top: 1px solid var(--border);
  padding: 2.5rem 0;
  text-align: center;
}

footer p {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-style: italic;
}

footer .author {
  font-style: normal;
  color: var(--gold-dim);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  margin-top: 0.75rem;
}

/* ---- Playground embed ---- */

.playground-section {
  padding: 5rem 0;
  border-top: 1px solid var(--border);
}

.playground-section .container {
  max-width: 1100px;
}

.playground-section h2 {
  font-family: var(--serif);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold-dim);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}

.playground-section p {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
}

.playground-frame {
  width: 100%;
  height: 90vh;
  border: 1px solid var(--border);
  border-radius: 3px;
}

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

@media (max-width: 680px) {
  html { font-size: 16px; }

  .hero h1 { font-size: 2.8rem; }
  .hero .numbers { gap: 1.5rem; }

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

  .chapter-header h1 { font-size: 2.2rem; }

  .chapter-list a { flex-direction: column; gap: 0.25rem; }
  .chapter-list .ch-desc { margin-left: 0; font-size: 0.8rem; }

  nav .nav-links { gap: 0.8rem; }
  nav .nav-links a { font-size: 0.7rem; }
}

/* ---- Currently section ---- */

.currently-section {
  padding: 4rem 0 3rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.currently-section .container {
  max-width: 640px;
}

.currently-section .currently-label {
  font-family: var(--serif);
  font-size: 0.82rem;
  color: var(--gold);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 1.2rem;
}

.currently-section .currently-body {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-style: italic;
  color: var(--text-dim);
  line-height: 1.65;
}

.currently-section .currently-body a {
  color: var(--gold);
  text-decoration: underline;
  text-decoration-color: rgba(106, 78, 4, 0.35);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s;
}

.currently-section .currently-body a:hover {
  text-decoration-color: var(--gold);
}

/* ---- Chapter offline download link ---- */

.chapter-offline {
  text-align: center;
  margin-top: 2.5rem;
  font-family: var(--serif);
  font-size: 0.95rem;
  color: var(--text-dim);
  font-style: italic;
}

.chapter-offline a {
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px solid rgba(106, 78, 4, 0.3);
  padding-bottom: 2px;
  transition: border-color 0.2s;
}

.chapter-offline a:hover {
  border-color: var(--gold);
}
