/* ============================================================
   Ricardo J. Huamán — style.css
   Manuscript palette · Cormorant Garant / EB Garamond / Montserrat
   ============================================================ */

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

/* ── Tokens (light / parchment) ───────────────────────────── */
:root {
  --bg:         #F5EDDA;  /* Parchment */
  --surface:    #E3D7B5;  /* Vellum */
  --surface-2:  #D9CEAD;  /* slightly deeper vellum */
  --text:       #1E100A;  /* Iron Gall Ink */
  --text-muted: #4B6174;  /* Scriptorium Slate */
  --accent:     #A83C20;  /* Vermillion */
  --gold:       #BB9149;  /* Antique Gold */
  --sage:       #677449;  /* Folio Sage */
  --border:     rgba(187,145,73,0.30);
  --nav-bg:     rgba(245,237,218,0.96);

  --font-display: 'Cormorant Garant', 'Palatino Linotype', Georgia, serif;
  --font-body:    'EB Garamond', Georgia, 'Times New Roman', serif;
  --font-ui:      'Montserrat', 'Helvetica Neue', Arial, sans-serif;
}

/* ── Dark theme ───────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:         #1A0F08;  /* Dark Vellum */
    --surface:    #2A1A0E;
    --surface-2:  #3A2515;
    --text:       #EDE3CC;
    --text-muted: #A89880;
    --border:     rgba(187,145,73,0.20);
    --nav-bg:     rgba(26,15,8,0.96);
  }
}
:root[data-theme="dark"] {
  --bg:         #1A0F08;
  --surface:    #2A1A0E;
  --surface-2:  #3A2515;
  --text:       #EDE3CC;
  --text-muted: #A89880;
  --border:     rgba(187,145,73,0.20);
  --nav-bg:     rgba(26,15,8,0.96);
}

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

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

img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Typography ───────────────────────────────────────────── */
h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  line-height: 1.2;
  text-wrap: balance;
  color: var(--text);
}

h1 { font-size: 2.8rem; font-weight: 600; }
h2 { font-size: 2rem;   font-weight: 500; margin-bottom: 0.5rem; }
h3 { font-size: 1.4rem; font-weight: 500; margin-bottom: 0.4rem; }

p { margin-bottom: 1.1rem; }
p:last-child { margin-bottom: 0; }

em, i { font-style: italic; }

.label {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Layout wrapper ───────────────────────────────────────── */
.site-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ── Navigation ───────────────────────────────────────────── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  max-width: 960px;
  margin: 0 auto;
}

.nav-brand {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-brand:hover { text-decoration: none; color: var(--accent); }

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.25rem;
  list-style: none;
  align-items: center;
}

.nav-links a,
.nav-links span.active-page {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.3rem 0.55rem;
  border-radius: 2px;
  transition: color 0.15s, background 0.15s;
  color: var(--text-muted);
  display: block;
}
.nav-links a:hover { color: var(--accent); background: rgba(168,60,32,0.07); text-decoration: none; }
.nav-links span.active-page { color: var(--accent); font-weight: 600; cursor: default; }

.nav-links a[target="_blank"]::after {
  content: " ↗";
  font-size: 0.6em;
  vertical-align: super;
}

/* ── Divider rule ─────────────────────────────────────────── */
.rule {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* ── Page header ──────────────────────────────────────────── */
.page-header {
  padding: 3.5rem 0 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
}

.page-header .label { margin-bottom: 0.5rem; display: block; }
.page-header h1 { color: var(--text); }

/* ── Ornamental dropcap initial ───────────────────────────── */
.dropcap::first-letter {
  font-family: var(--font-display);
  font-size: 3.8em;
  font-weight: 700;
  color: var(--accent);
  float: left;
  line-height: 0.82;
  margin-right: 0.06em;
  margin-top: 0.08em;
}

/* ── Bio / Home layout ────────────────────────────────────── */
.bio-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 3rem;
  align-items: start;
  padding: 3rem 0;
}

.bio-portrait {
  position: sticky;
  top: 5rem;
}

.bio-portrait img {
  width: 100%;
  border-radius: 4px;
  border: 3px solid var(--border);
  box-shadow: 0 4px 20px rgba(30,16,10,0.15);
}

.bio-portrait .portrait-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
  margin-top: 0.75rem;
  color: var(--text);
}

.bio-portrait .portrait-title {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.bio-portrait .portrait-links {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 1rem;
}

.portrait-link {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text-muted);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  display: block;
}
.portrait-link:hover { color: var(--accent); border-color: var(--accent); background: rgba(168,60,32,0.05); text-decoration: none; }

/* ── Credential list ──────────────────────────────────────── */
.credentials {
  margin: 1.5rem 0;
}
.credential-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.credential-item:first-child { border-top: 1px solid var(--border); }
.credential-abbr {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  padding-top: 0.1rem;
  white-space: nowrap;
}
.credential-detail { font-size: 0.9rem; }
.credential-detail strong { font-weight: 500; }
.credential-detail .inst {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

/* ── Section heading with ornament ───────────────────────────*/
.section-heading {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--gold);
  display: inline-block;
  margin-bottom: 1.2rem;
}

/* ── Content area (inner pages) ───────────────────────────── */
.content-area {
  padding: 3rem 0 4rem;
  max-width: 700px;
}

.content-area p {
  font-size: 1.05rem;
  line-height: 1.8;
}

/* ── Publications ─────────────────────────────────────────── */
.pub-entry {
  padding: 1.25rem 0 1.25rem 1.25rem;
  border-left: 3px solid var(--gold);
  margin-bottom: 1.5rem;
}

.pub-entry p {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  margin-bottom: 0;
}

/* ── Evaluations ──────────────────────────────────────────── */
.eval-quote {
  background: var(--surface);
  border-left: 4px solid var(--accent);
  border-radius: 0 4px 4px 0;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  font-size: 1rem;
  line-height: 1.75;
  font-style: italic;
}

.eval-source {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1rem;
  display: block;
}

.chart-figure {
  margin: 2rem 0;
  text-align: center;
}

.chart-figure img {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin: 0 auto;
}

.scribd-wrapper {
  margin: 2rem 0;
  overflow-x: auto;
}

/* ── Instruction links ────────────────────────────────────── */
.instruction-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1.5rem 0;
}

.instruction-list li a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 0.65rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 2px;
  transition: background 0.15s;
}
.instruction-list li a:hover { background: rgba(168,60,32,0.08); text-decoration: none; }
.instruction-list li a::before { content: "▶"; font-size: 0.6em; }

.instruction-list li:nth-child(2) a::before { content: "↓"; font-size: 0.75em; }
.instruction-list li:nth-child(3) a::before { content: "▶"; font-size: 0.6em; }

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 1.75rem 1.5rem;
  text-align: center;
  font-family: var(--font-ui);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Contact form ─────────────────────────────────────────── */
.contact-form {
  margin: 2rem 0 3rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.form-group input,
.form-group textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.65rem 0.85rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(168,60,32,0.12);
}

.form-group textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.6;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 540px) {
  .form-row { grid-template-columns: 1fr; }
}

.btn-submit {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.75rem 2rem;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s;
  display: inline-block;
  margin-top: 0.5rem;
}
.btn-submit:hover { background: #8e3219; }

.form-status {
  margin-top: 1rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--sage);
}
.form-status.error { color: var(--accent); }

/* ── Sidebar brand mark (R image on home page) ────────────── */
.sidebar-mark {
  margin-top: 1.25rem;
}
.sidebar-mark img {
  width: 100%;
  border-radius: 3px;
  border: 1.5px solid rgba(187,145,73,0.45);
  box-shadow: 0 2px 12px rgba(30,16,10,0.12);
}

/* ── Theme toggle ─────────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 2px;
  cursor: pointer;
  padding: 0.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
  vertical-align: middle;
}
.theme-toggle:hover {
  border-color: var(--gold);
  background: rgba(187,145,73,0.10);
}
.theme-toggle svg { display: block; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 680px) {
  html { font-size: 16px; }
  h1 { font-size: 2rem; }

  .bio-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .bio-portrait {
    position: static;
    max-width: 200px;
    margin: 0 auto;
  }
  .bio-portrait .portrait-links {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }
  .nav-inner { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .nav-links { gap: 0.1rem; }
}
