/* styles.css — Archivo Histórico Mágico Rosales
   CSS externo compartido para mejorar el rendimiento */

/* ═══════════════════════════════════════════
   DESIGN TOKENS — LIGHT & DARK
 ═══════════════════════════════════════════ */
:root {
  --paper: #ffffff;
  --paper-2: #ebe9e9;
  --paper-3: #dddbd9;
  --ink: #3a3a3a;
  --ink-2: #545454;
  --ink-3: #7a7878;
  --ink-4: #a8a5a3;
  --rule: rgba(58, 58, 58, 0.10);
  --rule-strong: rgba(58, 58, 58, 0.20);
  --accent: #7a2d3a;
  --accent-2: #a84455;
  --accent-3: #3d5a4a;
  --accent-bg: rgba(122, 45, 58, 0.07);
  --gold: #7a2d3a;
  --gold-light: rgba(122, 45, 58, 0.10);
  --nav-h: 56px;
  --sidebar-w: 260px;
  --max-w: 1380px;
  --text-max: 720px;
  --serif-display: 'Cormorant', 'Cormorant Garamond', Georgia, serif;
  --serif-sc: 'Cormorant SC', 'Cormorant Garamond', Georgia, serif;
  --serif-body: 'EB Garamond', Georgia, serif;
  --sans: 'DM Sans', system-ui, sans-serif;
  --shadow-sm: 0 1px 3px rgba(58, 58, 58, 0.08), 0 1px 2px rgba(58, 58, 58, 0.04);
  --shadow-md: 0 4px 16px rgba(58, 58, 58, 0.10), 0 2px 4px rgba(58, 58, 58, 0.06);
  --shadow-lg: 0 16px 48px rgba(58, 58, 58, 0.12), 0 4px 12px rgba(58, 58, 58, 0.07);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 0.25s var(--ease-in-out);
}

/* ═══════════════════════════════════════════
   RESET & BASE
 ═══════════════════════════════════════════ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  text-size-adjust: 100%;
}

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background var(--transition), color var(--transition);
}

::selection {
  background: var(--accent);
  color: #fff;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  display: block;
  max-width: 100%;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ═══════════════════════════════════════════
   MASTHEAD
 ═══════════════════════════════════════════ */
.masthead-wrap {
  position: relative;
  z-index: 300;
  overflow: hidden;
  max-height: 200px;
  transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
  opacity: 1;
}

.masthead-wrap.hidden {
  max-height: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.masthead {
  background: var(--paper-2);
  border-top: 3px solid var(--accent);
  border-bottom: 1px solid var(--rule-strong);
  position: relative;
  overflow: hidden;
}

.masthead::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent, transparent 19px, var(--rule) 19px, var(--rule) 20px);
  opacity: 0.4;
}

.masthead-inner {
  position: relative;
  z-index: 1;
  max-width: var(--max-w);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  align-items: stretch;
  min-height: 88px;
}

.masthead-legal {
  padding: 0.1rem 1.5rem 0.1rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.35rem;
}

.masthead-eyebrow {
  font-family: var(--serif-sc);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.32em;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.masthead-eyebrow::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 1px;
  background: var(--accent);
  opacity: 0.6;
  flex-shrink: 0;
}

.masthead-legal-title {
  font-family: var(--serif-display);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.masthead-legal-title em {
  font-style: italic;
  color: var(--accent);
  font-weight: 400;
}

.masthead-legal-body {
  font-family: var(--serif-body);
  font-size: 0.95rem;
  font-style: italic;
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 520px;
}

.masthead-legal-body strong {
  font-style: normal;
  font-weight: 600;
  color: var(--ink);
}

.masthead-legal-link {
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--sans);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
  width: fit-content;
  border-bottom: 1px solid rgba(122, 45, 58, 0.3);
  padding-bottom: 1px;
  transition: border-color 0.2s, color 0.2s;
  margin-top: 0.1rem;
}

.masthead-legal-link::after {
  content: ' →';
}

.masthead-legal-link:hover {
  color: var(--accent-2);
  border-color: var(--accent-2);
  text-decoration: none;
}

.masthead-divide {
  background: var(--rule-strong);
  align-self: stretch;
}

.masthead-count {
  padding: 0.1rem 1.5rem 0.1rem 1rem;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 1.5rem;
  justify-content: center;
}

.masthead-count-number {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex-shrink: 0;
}

.masthead-count-fig {
  font-family: var(--serif-display);
  font-size: clamp(2.8rem, 4vw, 3.8rem);
  font-weight: 300;
  line-height: 0.88;
  color: var(--ink);
  letter-spacing: -0.04em;
  display: block;
}

.masthead-count-fig span {
  font-size: 0.55em;
  font-weight: 300;
  color: var(--accent);
  vertical-align: top;
  line-height: 1.2;
  letter-spacing: 0;
}

.masthead-count-rule {
  width: 100%;
  height: 1px;
  background: var(--rule-strong);
  margin: 0.4rem 0 0.3rem;
  display: block;
}

.masthead-count-label {
  font-family: var(--serif-sc);
  font-size: 0.7rem;
  letter-spacing: 0.24em;
  color: var(--ink-3);
  display: block;
  white-space: nowrap;
}

.masthead-count-desc {
  min-width: 0;
}

.masthead-count-desc p {
  font-family: var(--serif-body);
  font-size: 0.95rem;
  font-style: italic;
  line-height: 1.65;
  color: var(--ink-3);
}

.masthead-count-desc strong {
  font-style: normal;
  color: var(--ink-2);
  font-weight: 600;
}

.masthead-count-note {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.4rem;
  font-family: var(--sans);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-4);
}

.masthead-count-note::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.6;
  animation: countPulse 2.4s ease-in-out infinite;
}

@keyframes countPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 0.15; }
}

@media (max-width: 1024px) {
  .masthead-count-desc { display: none; }
  .masthead-count { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .masthead-count-number { align-items: center; }
}

@media (max-width: 720px) {
  .masthead-inner { grid-template-columns: 1fr; }
  .masthead-divide { display: none; }
  .masthead-legal { padding: 0.85rem 1.25rem 0.5rem; }
  .masthead-count { padding: 0.5rem 1.25rem 0.85rem; grid-template-columns: auto 1fr; }
  .masthead-count-desc { display: block; }
  .masthead-count-fig { font-size: 2.4rem; }
  .masthead-legal-title { font-size: 1.1rem; }
}

@media (max-width: 480px) {
  .masthead-legal-body { display: none; }
  .masthead-count-desc { display: none; }
}

/* ═══════════════════════════════════════════
   SITE HEADER
 ═══════════════════════════════════════════ */
.site-header {
  background: var(--paper-2);
  border-bottom: 1px solid var(--rule-strong);
  overflow: hidden;
  position: relative;
}

.site-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 39px, var(--rule) 39px, var(--rule) 40px);
  opacity: 0.35;
  pointer-events: none;
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 2rem 2.5rem;
  position: relative;
  z-index: 1;
}

.header-eyebrow {
  font-family: var(--serif-sc);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  color: var(--accent);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-eyebrow::before,
.header-eyebrow::after {
  content: '';
  flex: 0 0 40px;
  height: 1px;
  background: var(--accent);
  opacity: 0.5;
}

.site-title {
  font-family: var(--serif-display);
  font-size: clamp(2.8rem, 7vw, 6.5rem);
  font-weight: 300;
  line-height: 0.92;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-align: center;
  margin-bottom: 0.6rem;
}

.site-title em {
  font-style: italic;
  font-weight: 300;
  color: var(--accent-2);
}

.header-rule {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem auto;
  max-width: 480px;
}

.header-rule-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--rule-strong));
}

.header-rule-line:last-child {
  background: linear-gradient(to left, transparent, var(--rule-strong));
}

.header-rule-ornament {
  font-family: var(--serif-display);
  font-size: 1.2rem;
  color: var(--accent);
  opacity: 0.7;
  line-height: 1;
}

.header-tagline {
  font-family: var(--serif-body);
  font-size: clamp(0.95rem, 1.5vw, 1.1rem);
  font-style: italic;
  color: var(--ink-3);
  text-align: center;
  line-height: 1.6;
  max-width: 560px;
  margin: 0 auto;
}

/* ═══════════════════════════════════════════
   NAVIGATION
 ═══════════════════════════════════════════ */
.nav-wrap {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--paper);
  border-bottom: 1px solid var(--rule-strong);
  box-shadow: var(--shadow-sm);
  transition: background var(--transition);
}

.nav-inner {
  max-width: var(--max-w);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
  height: 100px;
}

.nav-logo-img {
  height: 100%;
  width: auto;
  display: block;
  object-fit: contain;
  transition: opacity 0.2s;
}

.nav-logo:hover .nav-logo-img {
  opacity: 0.8;
}

.nav-logo:hover {
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0;
  list-style: none;
}

.nav-links a {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0 1.1rem;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
  text-decoration: none;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.nav-mobile-toggle {
  display: none;
  width: 36px;
  height: 36px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
}

.nav-mobile-toggle span {
  display: block;
  width: 22px;
  height: 1.5px;
  background: var(--ink);
  transition: transform var(--transition), background var(--transition);
}

.nav-mobile {
  display: none;
  background: var(--paper);
  border-bottom: 1px solid var(--rule-strong);
  padding: 1rem 1.5rem 1.5rem;
}

.nav-mobile.open {
  display: block;
}

.nav-mobile a {
  display: block;
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
}

.nav-mobile a:last-child {
  border-bottom: none;
}

/* ═══════════════════════════════════════════
   PAGE LAYOUT
 ═══════════════════════════════════════════ */
.page-layout {
  max-width: var(--max-w);
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 0;
  min-height: 80vh;
}

/* ═══════════════════════════════════════════
   SIDEBAR
 ═══════════════════════════════════════════ */
.sidebar {
  border-right: 1px solid var(--rule);
  padding: 2rem 1.5rem 3rem;
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--rule-strong) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 3px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--rule-strong);
  border-radius: 2px;
}

.sidebar-section {
  margin-bottom: 2rem;
}

.sidebar-label {
  font-family: var(--serif-sc);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-4);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 0.75rem;
}

.sidebar-nav {
  list-style: none;
}

.sidebar-nav li {
  border-bottom: 1px solid var(--rule);
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--ink-2);
  transition: color var(--transition), padding-left var(--transition);
}

.sidebar-nav a:hover {
  color: var(--accent);
  padding-left: 0.3rem;
  text-decoration: none;
}

.sidebar-nav a.active {
  color: var(--accent);
  font-weight: 500;
}

.sidebar-count {
  font-family: var(--sans);
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--ink-4);
  background: var(--paper-3);
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
  flex-shrink: 0;
}

.sidebar-quick a {
  display: block;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.73rem;
  color: var(--ink-2);
  line-height: 1.4;
  transition: color var(--transition), padding-left var(--transition);
}

.sidebar-quick a:hover {
  color: var(--accent);
  padding-left: 0.25rem;
  text-decoration: none;
}

.sidebar-stat {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
}

.sidebar-stat-num {
  font-size: 1.3rem;
  font-weight: 700;
  font-family: var(--serif-display);
  color: var(--ink);
  line-height: 1;
}

.sidebar-stat-lbl {
  font-size: 0.7rem;
  color: var(--ink-3);
}

/* ═══════════════════════════════════════════
   DESIGN TOKENS — LIGHT & DARK
 ═══════════════════════════════════════════ */
:root {
  --paper: #ffffff;
  /* off-white base — as requested */
  --paper-2: #ebe9e9;
  /* subtle warm gray */
  --paper-3: #dddbd9;
  /* divider-level gray */
  --ink: #3a3a3a;
  /* charcoal — matches logo text */
  --ink-2: #545454;
  /* secondary headings */
  --ink-3: #7a7878;
  /* body secondary */
  --ink-4: #a8a5a3;
  /* captions, metadata */
  --rule: rgba(58, 58, 58, 0.10);
  --rule-strong: rgba(58, 58, 58, 0.20);
  --accent: #7a2d3a;
  /* burdeos — warm contrast on silver */
  --accent-2: #a84455;
  /* burdeos light */
  --accent-3: #3d5a4a;
  /* forest green secondary */
  --accent-bg: rgba(122, 45, 58, 0.07);
  --gold: #7a2d3a;
  /* repurpose gold slot → burdeos for consistency */
  --gold-light: rgba(122, 45, 58, 0.10);
  --nav-h: 56px;
  --sidebar-w: 260px;
  --max-w: 1380px;
  --text-max: 720px;
  --serif-display: 'Cormorant', 'Cormorant Garamond', Georgia, serif;
  --serif-sc: 'Cormorant SC', 'Cormorant Garamond', Georgia, serif;
  --serif-body: 'EB Garamond', Georgia, serif;
  --sans: 'DM Sans', system-ui, sans-serif;
  --shadow-sm: 0 1px 3px rgba(58, 58, 58, 0.08), 0 1px 2px rgba(58, 58, 58, 0.04);
  --shadow-md: 0 4px 16px rgba(58, 58, 58, 0.10), 0 2px 4px rgba(58, 58, 58, 0.06);
  --shadow-lg: 0 16px 48px rgba(58, 58, 58, 0.12), 0 4px 12px rgba(58, 58, 58, 0.07);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 0.25s var(--ease-in-out);
}

/* ═══════════════════════════════════════════
   GLOBAL RESPONSIVE FIXES
 ═══════════════════════════════════════════ */

/* Prevent horizontal overflow on all elements */
* { max-width: 100%; }

/* Improve touch experience */
a, button, .nav-mobile-toggle, .hs-dot, .hs-btn, .pag-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(122, 45, 58, 0.15);
}

/* scroll-margin-top for anchor headings (avoid sticky header overlap) */
h1, h2, h3, h4, h5, h6,
.article-page-title, .section-h2, .section-h3,
.page-h1, .site-title, .hs-title, .feat-title {
  scroll-margin-top: calc(var(--nav-h) + 1rem);
}

/* text-wrap: balance for headings (better typography) */
h1, h2, h3,
.article-page-title, .section-block-title, .page-h1, .site-title, .hs-title, .feat-title {
  text-wrap: balance;
}

/* min-width: 0 for flex children (prevent overflow) */
.sidebar-nav a, .sidebar-quick a,
.feat-title, .feat-excerpt, .feat-footer,
.heraldry-desc, .log-text, .prose p, .lead-paragraph {
  min-width: 0;
}

/* ═══════════════════════════════════════════
   ARTICLE HERO
 ═══════════════════════════════════════════ */
.article-hero {
  padding: 2.5rem 2.5rem 0;
  border-bottom: 1px solid var(--rule);
}

.article-page-title {
  font-family: var(--serif-display);
  font-size: clamp(1.8rem, 3.5vw, 3rem);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 0.35rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--ink);
}

.article-subtitle {
  font-family: var(--serif-body);
  font-size: 0.9rem;
  font-style: italic;
  color: var(--ink-3);
  margin-bottom: 1.5rem;
}

.infobox {
  float: right;
  margin: 0 0 1.5rem 2rem;
  width: clamp(200px, 28%, 280px);
  border: 1px solid var(--rule-strong);
  background: var(--paper-2);
  font-size: 0.78rem;
  box-shadow: var(--shadow-sm);
}

.infobox-head {
  background: var(--ink);
  color: var(--accent);
  font-family: var(--serif-display);
  font-size: 0.95rem;
  font-style: italic;
  text-align: center;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--rule);
}

.infobox-img {
  width: 100%;
  aspect-ratio: 3/2;
  object-fit: cover;
  filter: sepia(20%) contrast(1.05);
  display: block;
}

.infobox-caption {
  font-family: var(--sans);
  font-size: 0.65rem;
  color: var(--ink-3);
  text-align: center;
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--rule);
  font-style: italic;
}

.infobox table {
  width: 100%;
  border-collapse: collapse;
}

.infobox td {
  padding: 0.3rem 0.65rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
  font-family: var(--sans);
  line-height: 1.4;
}

.infobox td:first-child {
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  width: 42%;
  font-size: 0.7rem;
}

.toc {
  float: left;
  margin: 0 2rem 1rem 0;
  min-width: 180px;
  max-width: 230px;
  border: 1px solid var(--rule-strong);
  background: var(--paper-2);
  padding: 0.85rem 1rem;
  font-size: 0.8rem;
}

.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.6rem;
}

.toc-toggle-btn {
  font-size: 0.62rem;
  color: var(--accent);
  font-weight: 400;
  background: none;
  border: none;
  cursor: pointer;
}

.toc ol {
  padding-left: 1.2rem;
  margin: 0;
}

.toc li {
  margin-bottom: 0.2rem;
  line-height: 1.4;
}

.toc a {
  color: var(--accent);
  font-size: 0.75rem;
  font-family: var(--sans);
}

.toc a:hover {
  text-decoration: underline;
}

.toc .sub {
  padding-left: 0.75rem;
  font-size: 0.7rem;
}

.lead-paragraph {
  font-family: var(--serif-body);
  font-size: clamp(1rem, 1.4vw, 1.1rem);
  line-height: 1.75;
  color: var(--ink);
  margin-bottom: 1.25rem;
  text-align: justify;
  hyphens: auto;
}

.dropcap {
  float: left;
  font-family: var(--serif-display);
  font-size: clamp(4rem, 6vw, 5rem);
  font-weight: 300;
  line-height: 0.78;
  margin-right: 0.1em;
  margin-top: 0.07em;
  color: var(--accent);
  font-style: italic;
}

.prose p {
  font-family: var(--serif-body);
  font-size: clamp(0.95rem, 1.2vw, 1.05rem);
  line-height: 1.75;
  color: var(--ink-2);
  margin-bottom: 1rem;
  text-align: justify;
  hyphens: auto;
}

.prose .clearfix::after {
  content: '';
  display: table;
  clear: both;
}

.section-h2 {
  font-family: var(--sans);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0;
  border-bottom: 1px solid var(--rule-strong);
  padding-bottom: 0.25rem;
  margin: 2.5rem 0 0.9rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-h2::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 1.05rem;
  background: var(--accent);
  flex-shrink: 0;
  border-radius: 1px;
}

.section-h3 {
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  margin: 1.75rem 0 0.5rem;
}

.article-body {
  padding: 1.75rem 2.5rem 2.5rem;
}

/* ═══════════════════════════════════════════
   HERÁLDICA GRID
 ═══════════════════════════════════════════ */
.section-block {
  padding: 2rem 2.5rem;
  border-top: 1px solid var(--rule);
}

.section-block-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.section-block-title {
  font-family: var(--serif-display);
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.section-block-meta {
  font-family: var(--sans);
  font-size: 0.7rem;
  color: var(--ink-4);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.heraldry-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule-strong);
}

.heraldry-card {
  background: var(--paper);
  padding: 1.5rem 1.25rem 1.25rem;
  text-align: center;
  transition: background var(--transition);
}

.heraldry-card:hover {
  background: var(--paper-2);
}

.heraldry-img-wrap {
  width: 80px;
  height: 96px;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.heraldry-img-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.heraldry-placeholder {
  width: 80px;
  height: 96px;
  border: 1px dashed var(--rule-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--rule-strong);
  font-family: var(--serif-display);
  font-style: italic;
}

.heraldry-name {
  font-family: var(--serif-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.2rem;
}

.heraldry-type {
  font-family: var(--sans);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: 0.5rem;
}

.heraldry-desc {
  font-family: var(--sans);
  font-size: 0.73rem;
  color: var(--ink-3);
  line-height: 1.5;
}

/* ═══════════════════════════════════════════
   FEATURED STUDIES GRID
 ═══════════════════════════════════════════ */
.featured-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1px;
  gap: 1rem;
}

.featured-header-rule {
  flex: 1;
  height: 1px;
  background: var(--rule-strong);
}

.featured-header-label {
  font-family: var(--serif-sc);
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  color: var(--ink-3);
  white-space: nowrap;
  flex-shrink: 0;
}

.featured-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule-strong);
  margin-top: 1px;
}

.feat-card {
  background: var(--paper);
  padding: 1.25rem;
  transition: background var(--transition);
  display: flex;
  flex-direction: column;
}

.feat-card:hover {
  background: var(--paper-2);
}

.feat-cat {
  font-family: var(--sans);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.feat-cat::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.cat-etymology { color: #7a2d3a; }
.cat-heraldry { color: #2a5070; }
.cat-geography { color: #3d5a4a; }
.cat-archive { color: #5a4530; }
.cat-sociology { color: #5c3860; }
.cat-lineage { color: #7a3535; }
.cat-history { color: #4a3535; }
.cat-modern { color: #2a4a6a; }

.feat-title {
  font-family: var(--serif-display);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink);
  margin-bottom: 0.6rem;
  flex: 1;
}

.feat-title a {
  color: inherit;
}

.feat-title a:hover {
  color: var(--accent);
  text-decoration: none;
}

.feat-excerpt {
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--ink-3);
  line-height: 1.55;
  margin-bottom: 0.75rem;
  flex: 1;
}

.feat-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--rule);
}

.feat-period {
  font-family: var(--sans);
  font-size: 0.62rem;
  color: var(--ink-4);
  letter-spacing: 0.06em;
}

.feat-link {
  font-family: var(--sans);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* ═══════════════════════════════════════════
   NOTICE BOX
 ═══════════════════════════════════════════ */
.notice {
  border-left: 3px solid var(--accent);
  background: var(--gold-light);
  padding: 0.9rem 1.1rem;
  margin: 1.5rem 0 0;
  font-family: var(--sans);
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--ink-2);
}

.notice strong {
  color: var(--ink);
  font-weight: 600;
}

.notice a {
  color: var(--accent);
  font-weight: 500;
}

/* ═══════════════════════════════════════════
   RESEARCH LOG
 ═══════════════════════════════════════════ */
.log-table {
  width: 100%;
  border-collapse: collapse;
  border-top: 2px solid var(--ink);
}

.log-table tr {
  border-bottom: 1px solid var(--rule);
}

.log-table tr:hover td {
  background: var(--paper-2);
}

.log-table td {
  padding: 0.75rem 0.5rem;
  vertical-align: top;
  transition: background var(--transition);
}

.log-date {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  width: 75px;
  padding-right: 1rem;
  font-variant-numeric: tabular-nums;
}

.log-type {
  font-family: var(--sans);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
  width: 90px;
  padding-right: 1rem;
}

.log-text {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--ink-2);
  line-height: 1.55;
}

/* ═══════════════════════════════════════════
   FOOTER
 ═══════════════════════════════════════════ */
.site-footer {
  background: #2e2e2e;
  color: #c8c4c0;
  border-top: 3px solid #7a2d3a;
  margin-top: 4rem;
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 2rem;
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 3rem;
}

.footer-logo-wrap {
  margin-bottom: 1.25rem;
}

.footer-logo-img {
  display: block;
  width: 100%;
  max-width: 260px;
  height: auto;
  filter: brightness(1.15) contrast(0.9);
  border-radius: 4px;
  opacity: 0.92;
}

.footer-col-label {
  font-family: var(--serif-sc);
  font-size: 0.58rem;
  letter-spacing: 0.24em;
  color: var(--accent);
  opacity: 0.8;
  margin-bottom: 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgba(122, 45, 58, 0.3);
}

.footer-desc {
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.7;
  color: rgb(215, 210, 207);
}

.footer-nav {
  list-style: none;
}

.footer-nav li {
  border-bottom: 1px solid rgba(220, 216, 212, 0.07);
}

.footer-nav a {
  display: block;
  font-family: var(--sans);
  font-size: 0.75rem;
  color: rgba(215, 210, 207, 0.55);
  padding: 0.4rem 0;
  transition: color 0.2s;
}

.footer-nav a:hover {
  color: var(--accent);
  text-decoration: none;
}

.footer-bottom {
  border-top: 1px solid rgba(220, 216, 212, 0.08);
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--sans);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: rgba(220, 216, 212, 0.25);
  gap: 1rem;
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════
   HERO SLIDER
 ═══════════════════════════════════════════ */
.hero-slider {
  position: relative;
  background: var(--ink);
  overflow: hidden;
  min-height: clamp(500px, 75vh, 820px);
  display: flex;
  flex-direction: column;
}

.hs-track {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  position: relative;
}

.hs-slide {
  grid-area: 1 / 1;
  display: grid;
  grid-template-columns: 1fr minmax(0, 320px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.85s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: inherit;
  position: relative;
}

.hs-slide.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 2;
}

.hs-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}

.hs-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: grayscale(30%) brightness(0.5) sepia(8%);
  transform: scale(1.05);
  transition: transform 8s linear;
}

.hs-slide.active .hs-bg img {
  transform: scale(1);
}

.hs-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(105deg, #000000f0 0%, rgba(0, 0, 0, 0.72) 48%, rgba(0, 0, 0, 0.28) 100%);
}

.hs-content {
  position: relative;
  z-index: 3;
  padding: clamp(2rem, 5vw, 4.5rem) clamp(1.5rem, 4vw, 4rem);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0;
  min-height: inherit;
}

.hs-eyebrow {
  font-family: var(--serif-sc);
  font-size: .62rem;
  font-weight: 500;
  letter-spacing: .28em;
  color: var(--accent);
  margin-bottom: .85rem;
  opacity: .9;
  display: flex;
  align-items: center;
  gap: .7rem;
}

.hs-eyebrow::before {
  content: '';
  display: inline-block;
  width: 28px;
  height: 1px;
  background: var(--accent);
  opacity: .55;
}

.hs-title {
  font-family: var(--serif-display);
  font-size: clamp(1.9rem, 4.8vw, 4rem);
  font-weight: 300;
  line-height: .95;
  letter-spacing: -.025em;
  color: #fff;
  margin-bottom: 1.1rem;
  max-width: 640px;
}

.hs-title em {
  font-style: italic;
  color: var(--accent);
}

.hs-excerpt {
  font-family: var(--serif-body);
  font-size: clamp(.85rem, 1.35vw, 1.05rem);
  font-style: italic;
  color: rgba(220, 216, 212, .62);
  line-height: 1.65;
  max-width: 520px;
  margin-bottom: 2rem;
}

.hs-cta {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--sans);
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid rgba(122, 45, 58, .45);
  padding: .6rem 1.25rem;
  width: fit-content;
  transition: background .25s, color .25s, border-color .25s;
}

.hs-cta::after {
  content: ' →';
}

.hs-cta:hover {
  background: var(--accent);
  color: var(--ink);
  border-color: var(--accent);
  text-decoration: none;
}

.hs-rail {
  position: relative;
  z-index: 3;
  border-left: 1px solid rgba(122, 45, 58, .15);
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.hs-rail-head {
  padding: .55rem 1.4rem .55rem .9rem;
  background: rgba(122, 45, 58, .10);
  border-bottom: 1px solid rgba(122, 45, 58, .18);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.hs-rail-label {
  font-family: var(--sans);
  font-size: .57rem;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: .8;
}

.hs-rail-counter {
  font-family: var(--sans);
  font-size: .6rem;
  color: rgba(220, 216, 212, .3);
  font-variant-numeric: tabular-nums;
}

.hs-rail-item {
  flex: 1;
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .75rem 1.4rem .75rem .9rem;
  border-bottom: 1px solid rgba(220, 216, 212, .06);
  text-decoration: none;
  transition: background .2s;
  min-height: 0;
}

.hs-rail-item:hover {
  background: rgba(220, 216, 212, .05);
  text-decoration: none;
}

.hs-rail-cat {
  font-family: var(--sans);
  font-size: .5rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: .75;
  margin-bottom: .2rem;
  display: block;
}

.hs-rail-title {
  font-family: var(--serif-display);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.25;
  color: rgba(220, 216, 212, .82);
}

.hs-rail-arrow {
  margin-left: auto;
  flex-shrink: 0;
  color: rgba(122, 45, 58, .45);
  font-size: 1rem;
  transition: color .2s, transform .2s;
}

.hs-rail-item:hover .hs-rail-arrow {
  color: var(--accent);
  transform: translateX(3px);
}

.hs-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .55rem 1.5rem;
  background: rgba(0, 0, 0, 0.96);
  border-top: 1px solid rgba(122, 45, 58, .18);
  flex-shrink: 0;
  z-index: 10;
}

.hs-dots {
  display: flex;
  gap: .45rem;
  align-items: center;
}

.hs-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(122, 45, 58, .22);
  border: none;
  padding: 0;
  transition: background .3s, transform .3s;
  cursor: pointer;
}

.hs-dot.active {
  background: var(--accent);
  transform: scale(1.45);
}

.hs-progress-wrap {
  flex: 1;
  height: 1px;
  background: rgba(122, 45, 58, .12);
  margin: 0 1.1rem;
  overflow: hidden;
}

.hs-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  opacity: .65;
  transition: width .1s linear;
}

.hs-nav {
  display: flex;
  align-items: center;
  gap: .55rem;
}

.hs-btn {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(122, 45, 58, .28);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(122, 45, 58, .55);
  font-size: .85rem;
  transition: background .2s, color .2s, border-color .2s;
}

.hs-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(122, 45, 58, .08);
}

.hs-nav-info {
  font-family: var(--serif-sc);
  font-size: .58rem;
  letter-spacing: .2em;
  color: rgba(220, 216, 212, .22);
  white-space: nowrap;
}

/* Slider responsive */
@media (max-width: 900px) {
  .hs-slide { grid-template-columns: 1fr; }
  .hs-rail { display: none; }
  .hero-slider { min-height: clamp(400px, 68vh, 600px); }
}

@media (max-width: 560px) {
  .hero-slider { min-height: clamp(360px, 70vh, 500px); }
  .hs-content { padding: 1.5rem 1.1rem 1.5rem; }
  .hs-title { font-size: clamp(1.6rem, 8vw, 2.5rem); }
}

/* ═══════════════════════════════════════════
   RESPONSIVE — TABLET
 ═══════════════════════════════════════════ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
  .featured-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 880px) {
  .page-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--rule-strong);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1.5rem;
    justify-content: center;
    padding: 1.25rem 1.5rem;
  }
  .sidebar-section { margin-bottom: 0; }
  .nav-links { display: none; }
  .nav-mobile-toggle { display: flex; }
  .article-hero, .article-body, .section-block { padding-left: 1.25rem; padding-right: 1.25rem; }
  .infobox { float: none; width: 100%; max-width: 100%; margin: 0 0 1.5rem; }
  .toc { float: none; width: 100%; max-width: 100%; margin: 0 0 1.25rem; }
  .heraldry-grid { grid-template-columns: 1fr 1fr; }
  .footer-inner { grid-template-columns: 1fr 1fr; gap: 2rem; }
}

@media (max-width: 600px) {
  .masthead { display: none; }
  .header-inner { padding: 2rem 1.25rem 1.75rem; }
  .site-title { font-size: clamp(2rem, 9vw, 3rem); }
  .featured-grid { grid-template-columns: 1fr; }
  .heraldry-grid { grid-template-columns: 1fr; }
  .footer-inner { grid-template-columns: 1fr; }
  .article-hero, .article-body, .section-block { padding-left: 1rem; padding-right: 1rem; }
  .log-type { display: none; }
}

/* ═══════════════════════════════════════════
   PRINT
 ═══════════════════════════════════════════ */
@media print {
  .nav-wrap, .masthead, .sidebar, .site-footer, .hero-slider { display: none; }
  .page-layout { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════
   PREFERS REDUCED MOTION
 ═══════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .hs-bg img { transition: none !important; }
}

/* ═══════════════════════════════════════════
   LEGAL MODAL
 ═══════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.active {
  display: flex;
}
.modal-box {
  background: var(--paper);
  max-width: 520px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  border-radius: 6px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18);
  padding: 2rem 2rem 1.5rem;
  position: relative;
}
.modal-box h2 {
  font-family: var(--serif-display);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 0.75rem;
}
.modal-box h2 em {
  color: var(--accent);
  font-style: italic;
}
.modal-box p {
  font-family: var(--sans);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--ink-2);
  margin-bottom: 0.75rem;
}
.modal-box .modal-alert {
  background: rgba(122,45,58,0.06);
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.82rem;
}
.modal-close {
  margin-top: 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.6rem 1.5rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.2s;
}
.modal-close:hover {
  background: var(--accent-2);
}
