/* ==========================================================================
 * GARDUNIA — SWISS ARCHIVAL EDITORIAL DESIGN SYSTEM (v2.0)
 * Gardunia — Plataforma de Humanidades Digitais & Património Documental
 * Charte Municipale Torres Novas :
 *   - Pantone 378 (Olive Web #60672B · RGB 46/102/10 #2E660A · Deep #464C1E)
 *   - Pantone 397 (Citrine Web #D7D218 · RGB 215/209/27 #D7D11B)
 * Accessibility: WCAG 2.1 AA/AAA verified contrast ratios & full keyboard nav
 * ========================================================================== */

:root,
:root[data-theme='light'] {
  /* Core Swiss Editorial Palette — Torres Novas Municipal Harmony */
  --ed-paper: #FAF9F4;
  --ed-paper-elev: #FFFFFF;
  --ed-vellum: #F3F1E8;
  --ed-vellum-deep: #E8E5D6;
  --ed-ink: #1B1C16;
  --ed-ink-secondary: #383B2E;
  --ed-ink-muted: #585C49;
  --ed-accent: #60672B;
  --ed-accent-hover: #464C1E;
  --ed-accent-soft: rgba(96, 103, 43, 0.08);
  --ed-accent-border: rgba(96, 103, 43, 0.30);
  --ed-citron: #D7D218;
  --ed-citron-rgb: #D7D11B;
  --ed-citron-soft: rgba(215, 210, 24, 0.16);
  --ed-gall: #68650A;
  --ed-gall-soft: rgba(215, 210, 24, 0.15);
  --ed-rule: #D7D5C6;
  --ed-rule-strong: #464C1E;
  --ed-focus: #2E660A;

  /* Typography Trio */
  --font-ed-serif: 'Newsreader', 'Cormorant Garamond', 'Lora', Georgia, 'Times New Roman', serif;
  --font-ed-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --font-ed-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;

  /* Harmonize existing portal & widget tokens with Torres Novas palette */
  --q2-bg: #FAF9F4;
  --q2-bg-elev: #FFFFFF;
  --q2-bg-soft: #F3F1E8;
  --q2-text: #1B1C16;
  --q2-muted: #585C49;
  --q2-border: #D7D5C6;
  --q2-accent: #60672B;
  --q2-accent-contrast: #FFFFFF;
  --q2-link: #60672B;
  --tnv-olive: #60672B;
  --tnv-olive-deep: #464C1E;
  --tnv-green: #2E660A;
  --tnv-citron: #D7D218;
  --tnv-citron-ink: #68650A;
  --font-display: var(--font-ed-serif);
  --font-serif: var(--font-ed-serif);
}

:root[data-theme='dark'] {
  --ed-paper: #151711;
  --ed-paper-elev: #1C1F17;
  --ed-vellum: #22261C;
  --ed-vellum-deep: #2B3023;
  --ed-ink: #F2F1E8;
  --ed-ink-secondary: #D7D6C8;
  --ed-ink-muted: #A6A595;
  --ed-accent: #D7D218;
  --ed-accent-hover: #E5E14B;
  --ed-accent-soft: rgba(215, 210, 24, 0.12);
  --ed-accent-border: rgba(215, 210, 24, 0.36);
  --ed-citron: #D7D218;
  --ed-citron-rgb: #D7D11B;
  --ed-citron-soft: rgba(215, 210, 24, 0.15);
  --ed-gall: #C5CA30;
  --ed-gall-soft: rgba(197, 202, 48, 0.14);
  --ed-rule: #2E3326;
  --ed-rule-strong: #8F9650;
  --ed-focus: #D7D218;

  --q2-bg: #151711;
  --q2-bg-elev: #1C1F17;
  --q2-bg-soft: #22261C;
  --q2-text: #F2F1E8;
  --q2-muted: #A6A595;
  --q2-border: #2E3326;
  --q2-accent: #D7D218;
  --q2-accent-contrast: #151711;
  --q2-link: #D7D218;
  --tnv-olive: #C5CA30;
  --tnv-olive-deep: #D7D218;
  --tnv-green: #8CC63F;
  --tnv-citron: #D7D218;
  --tnv-citron-ink: #E5E14B;
}

/* Base Document Reset & Rhythm */
html {
  background-color: var(--ed-paper) !important;
  color: var(--ed-ink) !important;
  font-family: var(--font-ed-sans);
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background-color: var(--ed-paper) !important;
  color: var(--ed-ink) !important;
  font-family: var(--font-ed-sans);
  line-height: 1.62;
  letter-spacing: -0.005em;
}

/* Accessible Skip Link */
.ed-skip-link {
  position: fixed;
  top: -100px;
  left: 1rem;
  z-index: 9999;
  background: var(--ed-accent);
  color: var(--q2-accent-contrast, #FFFFFF) !important;
  padding: 0.6rem 1rem;
  font-family: var(--font-ed-mono);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--ed-ink);
  transition: top 0.15s ease;
}
.ed-skip-link:focus {
  top: 0.75rem;
}

/* Global Keyboard Focus Ring (WCAG 2.1 AA) */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--ed-focus) !important;
  outline-offset: 2px !important;
}

/* Container Width — Generous Swiss Editorial Grid */
.container {
  max-width: 1280px !important;
  padding-left: 1.75rem !important;
  padding-right: 1.75rem !important;
}

/* ==========================================================================
 * 1. SWISS MASTHEAD & NAVIGATION (#header)
 * ========================================================================== */
#header {
  background: var(--ed-paper) !important;
  border-top: 4px solid #60672B !important;
  border-bottom: 1px solid var(--ed-rule) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  padding: 0 !important;
  height: auto !important;
  position: relative;
}

#header::before {
  display: block !important;
  content: '' !important;
  position: absolute;
  top: -4px;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #2E660A 0%, #60672B 62%, #D7D218 62%, #D7D218 100%) !important;
  z-index: 95;
  pointer-events: none;
}

#header::after {
  display: none !important;
}

#header .navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 66px;
  gap: 1.25rem;
  padding: 0.45rem 0;
}

.ed-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none !important;
  color: var(--ed-ink) !important;
}

.ed-brand-emblem {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid #60672B;
  box-shadow: 0 0 0 2px rgba(215, 210, 24, 0.38);
  flex-shrink: 0;
}

.ed-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.ed-brand-title {
  font-family: var(--font-ed-serif);
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ed-ink) !important;
}

.ed-brand-sub {
  font-family: var(--font-ed-mono);
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ed-accent);
  margin-top: 0.12rem;
}

/* Primary Navigation */
#header .dropmenu ul.navigation {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

#header .dropmenu ul.navigation > li {
  position: relative;
}

#header .dropmenu ul.navigation > li > a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.72rem;
  font-family: var(--font-ed-sans);
  font-size: 0.84rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--ed-ink-secondary) !important;
  text-decoration: none !important;
  border-bottom: 2px solid transparent;
  border-radius: 0 !important;
  background: transparent !important;
  transition: color 0.15s ease, border-color 0.15s ease;
}

#header .dropmenu ul.navigation > li > a:hover,
#header .dropmenu ul.navigation > li > a.active {
  color: var(--ed-ink) !important;
  border-bottom-color: #D7D218;
  box-shadow: inset 0 -1px 0 #60672B;
  font-weight: 600;
}

/* Accessible Dropdown Submenu */
#header .dropmenu ul.navigation > li.has-children > ul {
  position: absolute;
  top: calc(100% + 1px);
  left: 0;
  min-width: 310px;
  background: var(--ed-paper-elev) !important;
  border: 1px solid var(--ed-ink) !important;
  border-radius: 0 !important;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.09) !important;
  padding: 0.35rem 0 !important;
  z-index: 1000;
}

#header .dropmenu ul.navigation > li.has-children > ul > li > a {
  display: block;
  padding: 0.52rem 1rem !important;
  font-size: 0.82rem !important;
  color: var(--ed-ink-secondary) !important;
  border-left: 2px solid transparent;
  text-decoration: none !important;
  line-height: 1.35;
}

#header .dropmenu ul.navigation > li.has-children > ul > li > a:hover,
#header .dropmenu ul.navigation > li.has-children > ul > li > a.active {
  background: var(--ed-vellum) !important;
  color: var(--ed-ink) !important;
  border-left-color: var(--ed-accent);
}

/* Header Right Actions: Search Shortcut, PT/FR/EN Switcher, Theme Toggle */
.ed-header-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.ed-quick-search-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.32rem 0.62rem;
  background: var(--ed-vellum);
  color: var(--ed-ink-secondary) !important;
  border: 1px solid var(--ed-rule);
  border-radius: 0;
  font-family: var(--font-ed-sans);
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none !important;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.ed-quick-search-btn:hover {
  border-color: var(--ed-ink);
  background: var(--ed-paper-elev);
  color: var(--ed-ink) !important;
}

.ed-quick-search-btn kbd {
  font-family: var(--font-ed-mono);
  font-size: 0.68rem;
  padding: 0.05rem 0.32rem;
  border: 1px solid var(--ed-rule);
  background: var(--ed-paper);
  color: var(--ed-ink-muted);
}

.ed-langswitcher {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--ed-rule);
  background: var(--ed-paper-elev);
}

.ed-lang-btn {
  padding: 0.28rem 0.48rem;
  font-family: var(--font-ed-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ed-ink-muted) !important;
  text-decoration: none !important;
  border-right: 1px solid var(--ed-rule);
  transition: background 0.15s ease, color 0.15s ease;
}

.ed-lang-btn:last-child {
  border-right: none;
}

.ed-lang-btn:hover {
  color: var(--ed-ink) !important;
  background: var(--ed-vellum);
}

.ed-lang-btn.active {
  background: var(--ed-accent) !important;
  color: var(--q2-accent-contrast, #FFFFFF) !important;
}

#header .theme-toggle {
  border: 1px solid var(--ed-rule) !important;
  border-radius: 0 !important;
  background: var(--ed-paper-elev) !important;
  color: var(--ed-ink-secondary) !important;
  width: 32px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body.header-fixed #page-wrapper {
  padding-top: 70px !important;
}

#body-wrapper {
  padding-top: 1.35rem !important;
  padding-bottom: 3.5rem !important;
}

/* ==========================================================================
 * 2. ABOVE THE FOLD — EDITORIAL HERO, KPI STRIP & DUAL-TRACK GATEWAY
 * ========================================================================== */
.ed-home-shell {
  color: var(--ed-ink);
}

/* Top Metadata Eyebrow Bar */
.ed-eyebrow-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.65rem;
  padding: 0.48rem 0;
  border-top: 1px solid var(--ed-rule-strong);
  border-bottom: 1px solid var(--ed-rule);
  font-family: var(--font-ed-mono);
  font-size: 0.71rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ed-ink-muted);
}

.ed-eyebrow-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--ed-gall);
  font-weight: 600;
}

.ed-status-dot {
  width: 7px;
  height: 7px;
  background: var(--ed-accent);
  display: inline-block;
}

/* Hero Lead Grid (8 / 4 Asymmetric Columns) */
.ed-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.15fr) minmax(280px, 1fr);
  gap: 2.25rem;
  padding: 1.65rem 0 1.5rem;
  border-bottom: 1px solid var(--ed-rule);
  align-items: end;
}

.ed-hero-kicker {
  font-family: var(--font-ed-mono);
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ed-accent);
  margin-bottom: 0.55rem;
}

.ed-hero-title {
  font-family: var(--font-ed-serif) !important;
  font-size: clamp(1.95rem, 3.3vw, 2.85rem) !important;
  font-weight: 600 !important;
  line-height: 1.12 !important;
  letter-spacing: -0.018em !important;
  color: var(--ed-ink) !important;
  margin: 0 0 0.85rem 0 !important;
  border: none !important;
  padding: 0 !important;
}

.ed-hero-title em {
  font-style: italic;
  font-weight: 500;
  color: var(--ed-accent);
}

.ed-hero-lead {
  font-family: var(--font-ed-serif);
  font-size: 1.12rem;
  line-height: 1.56;
  color: var(--ed-ink-secondary);
  margin: 0;
  max-width: 68ch;
}

.ed-hero-colophon {
  border-left: 1px solid var(--ed-rule);
  padding-left: 1.35rem;
  font-size: 0.81rem;
  line-height: 1.55;
  color: var(--ed-ink-muted);
}

.ed-colophon-row {
  padding: 0.38rem 0;
  border-bottom: 1px solid var(--ed-rule);
}

.ed-colophon-row:first-child {
  padding-top: 0;
}

.ed-colophon-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.ed-colophon-lbl {
  display: block;
  font-family: var(--font-ed-mono);
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ed-ink-muted);
  margin-bottom: 0.1rem;
}

.ed-colophon-val {
  color: var(--ed-ink);
  font-weight: 500;
}

.ed-colophon-val code {
  font-family: var(--font-ed-mono);
  font-size: 0.74rem;
  background: var(--ed-vellum);
  padding: 0.08rem 0.3rem;
  color: var(--ed-gall);
}

/* Proof by Figures — 6-Cell Swiss Tabular Strip */
.ed-metrics-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border-bottom: 2px solid var(--ed-rule-strong);
  background: var(--ed-paper-elev);
}

.ed-metric-cell {
  padding: 0.9rem 0.95rem;
  border-right: 1px solid var(--ed-rule);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.ed-metric-cell:last-child {
  border-right: none;
}

.ed-metric-num {
  font-family: var(--font-ed-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.32rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ed-ink);
  line-height: 1.15;
}

.ed-metric-num.is-accent {
  color: var(--ed-accent);
}

.ed-metric-label {
  font-family: var(--font-ed-sans);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ed-ink);
  margin-top: 0.28rem;
  line-height: 1.25;
}

.ed-metric-sub {
  font-family: var(--font-ed-mono);
  font-size: 0.67rem;
  color: var(--ed-ink-muted);
  margin-top: 0.18rem;
  line-height: 1.3;
}

/* ==========================================================================
 * 3. DUAL-TRACK GATEWAY (VOIE A : PUBLIC & FAMILLES / VOIE B : CHERCHEURS)
 * ========================================================================== */
.ed-gateway-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-bottom: 2px solid var(--ed-rule-strong);
  background: var(--ed-paper);
}

.ed-track {
  padding: 1.5rem 1.75rem 1.6rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.ed-track-a {
  border-right: 1px solid var(--ed-rule-strong);
  background: var(--ed-paper);
}

.ed-track-b {
  background: var(--ed-vellum);
}

.ed-track-header {
  margin-bottom: 1rem;
}

.ed-track-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-ed-mono);
  font-size: 0.69rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.5rem;
  margin-bottom: 0.6rem;
}

.ed-track-a .ed-track-tag {
  background: var(--ed-accent);
  color: var(--q2-accent-contrast, #FFFFFF);
  border-left: 3px solid #D7D218;
}

.ed-track-b .ed-track-tag {
  background: #464C1E;
  color: #FFFFFF;
  border-left: 3px solid #D7D218;
}

.ed-track-title {
  font-family: var(--font-ed-serif) !important;
  font-size: 1.48rem !important;
  font-weight: 600 !important;
  line-height: 1.2 !important;
  color: var(--ed-ink) !important;
  margin: 0 0 0.45rem 0 !important;
  border: none !important;
  padding: 0 !important;
}

.ed-track-desc {
  font-size: 0.89rem;
  color: var(--ed-ink-secondary);
  margin: 0;
  line-height: 1.5;
}

.ed-track-links {
  list-style: none !important;
  margin: 0.85rem 0 0 0 !important;
  padding: 0 !important;
  border-top: 1px solid var(--ed-rule);
}

.ed-track-links li {
  margin: 0 !important;
  padding: 0 !important;
  border-bottom: 1px solid var(--ed-rule);
}

.ed-track-link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.62rem 0.25rem;
  text-decoration: none !important;
  color: var(--ed-ink) !important;
  transition: padding-left 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.ed-track-link:hover {
  padding-left: 0.55rem;
  color: var(--ed-accent) !important;
  background: var(--ed-accent-soft);
}

.ed-track-link-main {
  display: flex;
  flex-direction: column;
}

.ed-track-link-title {
  font-size: 0.89rem;
  font-weight: 600;
  color: inherit;
}

.ed-track-link-meta {
  font-family: var(--font-ed-mono);
  font-size: 0.7rem;
  color: var(--ed-ink-muted);
  margin-top: 0.08rem;
}

.ed-track-arrow {
  font-family: var(--font-ed-mono);
  font-size: 0.88rem;
  color: var(--ed-accent);
  flex-shrink: 0;
}

/* ==========================================================================
 * 4. UNIFIED INSTANT SEARCH ENGINE (#recherche-unifiee)
 * ========================================================================== */
.ed-search-section {
  padding: 2rem 0 1.85rem;
  border-bottom: 2px solid var(--ed-rule-strong);
}

.ed-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.ed-rubric {
  font-family: var(--font-ed-mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ed-accent);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.25rem;
}

.ed-rubric::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #D7D218;
  border: 1.5px solid #60672B;
  flex-shrink: 0;
}

.ed-section-title {
  font-family: var(--font-ed-serif) !important;
  font-size: 1.55rem !important;
  font-weight: 600 !important;
  color: var(--ed-ink) !important;
  margin: 0 !important;
  border: none !important;
  padding: 0 !important;
}

.ed-search-panel {
  background: var(--ed-paper-elev);
  border: 1px solid var(--ed-ink);
  padding: 1.2rem 1.35rem;
}

.ed-search-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--ed-rule);
}

.ed-mode-tab {
  font-family: var(--font-ed-mono);
  font-size: 0.73rem;
  font-weight: 600;
  padding: 0.32rem 0.7rem;
  border: 1px solid var(--ed-rule);
  background: var(--ed-paper);
  color: var(--ed-ink-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.ed-mode-tab:hover {
  border-color: var(--ed-ink);
  color: var(--ed-ink);
}

.ed-mode-tab.active {
  background: var(--ed-accent);
  border-color: var(--ed-accent);
  color: var(--q2-accent-contrast, #FFFFFF);
}

.ed-search-bar {
  display: grid;
  grid-template-columns: minmax(0, 2.5fr) minmax(150px, 0.95fr) minmax(130px, 0.7fr) auto;
  gap: 0.65rem;
  align-items: stretch;
}

.ed-input,
.ed-select {
  width: 100%;
  height: 42px;
  padding: 0 0.85rem;
  font-family: var(--font-ed-sans);
  font-size: 0.9rem;
  color: var(--ed-ink) !important;
  background: var(--ed-paper) !important;
  border: 1px solid var(--ed-rule) !important;
  border-radius: 0 !important;
  margin: 0 !important;
}

.ed-input:focus,
.ed-select:focus {
  border-color: var(--ed-ink) !important;
  background: var(--ed-paper-elev) !important;
}

.ed-btn-primary {
  height: 42px;
  padding: 0 1.25rem;
  background: var(--ed-accent) !important;
  color: var(--q2-accent-contrast, #FFFFFF) !important;
  border: 1px solid var(--ed-accent) !important;
  border-radius: 0 !important;
  font-family: var(--font-ed-mono);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.ed-btn-primary:hover {
  background: var(--ed-accent-hover) !important;
}

.ed-search-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
  font-family: var(--font-ed-mono);
  font-size: 0.71rem;
  color: var(--ed-ink-muted);
}

.ed-chip {
  font-family: var(--font-ed-mono);
  font-size: 0.7rem;
  padding: 0.16rem 0.5rem;
  background: var(--ed-vellum);
  border: 1px solid var(--ed-rule);
  color: var(--ed-ink-secondary);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.ed-chip:hover {
  border-color: var(--ed-accent);
  color: var(--ed-accent);
}

.ed-search-status {
  margin-top: 0.75rem;
  font-family: var(--font-ed-mono);
  font-size: 0.76rem;
  color: var(--ed-ink-muted);
  min-height: 1.2rem;
}

.ed-results-container {
  margin-top: 0.75rem;
  border-top: 1px solid var(--ed-rule-strong);
  display: none;
}

.ed-results-container.is-open {
  display: block;
}

.ed-results-group-title {
  font-family: var(--font-ed-mono);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ed-gall);
  background: var(--ed-vellum);
  padding: 0.42rem 0.75rem;
  border-bottom: 1px solid var(--ed-rule);
}

.ed-results-scroll {
  max-height: 410px;
  overflow-y: auto;
}

.ed-results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  margin: 0 !important;
}

.ed-results-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--ed-paper-elev);
  border-bottom: 1px solid var(--ed-rule-strong);
  padding: 0.48rem 0.65rem;
  text-align: left;
  font-family: var(--font-ed-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ed-ink-muted);
}

.ed-results-table td {
  padding: 0.52rem 0.65rem;
  border-bottom: 1px solid var(--ed-rule);
  vertical-align: middle;
}

.ed-results-table tr:hover td {
  background: var(--ed-accent-soft);
}

.ed-mono-tag {
  font-family: var(--font-ed-mono);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  color: var(--ed-gall);
  background: var(--ed-gall-soft);
  padding: 0.1rem 0.38rem;
  border: 1px solid var(--ed-rule);
  white-space: nowrap;
}

.ed-action-mini {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--font-ed-mono);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.18rem 0.45rem;
  border: 1px solid var(--ed-accent-border);
  color: var(--ed-accent) !important;
  text-decoration: none !important;
  background: var(--ed-paper);
  white-space: nowrap;
}

.ed-action-mini:hover {
  background: var(--ed-accent);
  color: var(--q2-accent-contrast, #FFFFFF) !important;
}

/* ==========================================================================
 * 5. ASYMMETRIC SWISS EDITORIAL GRID (BRIDGES + RIGOR & METHODOLOGY)
 * ========================================================================== */
.ed-magazine-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.05fr) minmax(300px, 1fr);
  gap: 2.25rem;
  padding: 2.2rem 0;
  border-bottom: 2px solid var(--ed-rule-strong);
  align-items: start;
}

.ed-bridges-col {
  display: flex;
  flex-direction: column;
  gap: 1.85rem;
}

/* Featured Bridge 01 — 17th-Century Facsimile & Critical Apparatus */
.ed-bridge-lead {
  border-top: 2px solid var(--ed-rule-strong);
  padding-top: 1.15rem;
}

.ed-bridge-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-family: var(--font-ed-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ed-gall);
  margin-bottom: 0.45rem;
}

.ed-bridge-title {
  font-family: var(--font-ed-serif) !important;
  font-size: 1.52rem !important;
  font-weight: 600 !important;
  line-height: 1.22 !important;
  color: var(--ed-ink) !important;
  margin: 0 0 0.55rem 0 !important;
  border: none !important;
  padding: 0 !important;
}

.ed-bridge-summary {
  font-size: 0.93rem;
  color: var(--ed-ink-secondary);
  margin: 0 0 1rem 0;
  line-height: 1.58;
}

.ed-facsimile-card {
  border: 1px solid var(--ed-rule-strong);
  background: var(--ed-paper-elev);
}

.ed-facsimile-img-wrap {
  position: relative;
  background: #E7E3D8;
  border-bottom: 1px solid var(--ed-rule);
  padding: 0.65rem;
  text-align: center;
}

.ed-facsimile-img-wrap img {
  width: 100%;
  max-height: 215px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  filter: contrast(1.06);
}

.ed-facsimile-zoom-btn {
  position: absolute;
  right: 0.75rem;
  bottom: 0.75rem;
  background: rgba(26, 26, 26, 0.86);
  color: #FAF9F6 !important;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 0.28rem 0.62rem;
  font-family: var(--font-ed-mono);
  font-size: 0.69rem;
  cursor: pointer;
}

.ed-facsimile-zoom-btn:hover {
  background: var(--ed-accent);
  color: var(--q2-accent-contrast, #FFFFFF) !important;
}

.ed-apparatus-tabs {
  display: flex;
  border-bottom: 1px solid var(--ed-rule);
  background: var(--ed-vellum);
  flex-wrap: wrap;
}

.ed-app-tab {
  padding: 0.48rem 0.85rem;
  font-family: var(--font-ed-mono);
  font-size: 0.71rem;
  font-weight: 600;
  border: none;
  border-right: 1px solid var(--ed-rule);
  background: transparent;
  color: var(--ed-ink-muted);
  cursor: pointer;
}

.ed-app-tab.active {
  background: var(--ed-paper-elev);
  color: var(--ed-ink);
  box-shadow: inset 0 2px 0 var(--ed-accent);
}

.ed-app-pane {
  display: none;
  padding: 1rem 1.15rem;
  font-size: 0.88rem;
}

.ed-app-pane.active {
  display: block;
}

.ed-verbatim-quote {
  font-family: var(--font-ed-serif);
  font-size: 1.08rem;
  font-style: italic;
  line-height: 1.62;
  color: var(--ed-ink);
  border-left: 2px solid var(--ed-accent);
  padding-left: 0.95rem;
  margin: 0 0 0.7rem 0;
}

.ed-diplomatic-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin: 0 !important;
}

.ed-diplomatic-grid th,
.ed-diplomatic-grid td {
  padding: 0.36rem 0.5rem;
  border-bottom: 1px solid var(--ed-rule);
  text-align: left;
}

.ed-diplomatic-grid th {
  font-family: var(--font-ed-mono);
  font-size: 0.67rem;
  text-transform: uppercase;
  color: var(--ed-ink-muted);
}

/* Secondary Thematic Bridges Grid (3 Dossiers) */
.ed-bridges-subgrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.35rem;
}

.ed-bridge-card {
  border-top: 1.5px solid var(--ed-ink);
  padding-top: 0.85rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.ed-bridge-card h4 {
  font-family: var(--font-ed-serif) !important;
  font-size: 1.15rem !important;
  font-weight: 600 !important;
  line-height: 1.28 !important;
  color: var(--ed-ink) !important;
  margin: 0.25rem 0 0.5rem 0 !important;
}

.ed-bridge-card p {
  font-size: 0.85rem;
  color: var(--ed-ink-secondary);
  line-height: 1.54;
  margin: 0 0 0.8rem 0;
}

/* Mini Swiss Century Bar Chart inside Bridge 02 */
.ed-century-bars {
  margin: 0.45rem 0 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  font-family: var(--font-ed-mono);
  font-size: 0.69rem;
}

.ed-century-row {
  display: grid;
  grid-template-columns: 56px 1fr 52px;
  align-items: center;
  gap: 0.45rem;
}

.ed-century-track {
  height: 7px;
  background: var(--ed-vellum-deep);
  position: relative;
}

.ed-century-fill {
  height: 100%;
  background: var(--ed-accent);
}

.ed-bridge-cta {
  font-family: var(--font-ed-mono);
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--ed-accent) !important;
  text-decoration: none !important;
  padding-top: 0.55rem;
  border-top: 1px solid var(--ed-rule);
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
}

.ed-bridge-cta:hover {
  text-decoration: underline !important;
}

/* Right Column — Permanent "Rigueur & Méthodologie" Box */
.ed-rigor-aside {
  background: var(--ed-vellum);
  border: 1px solid var(--ed-rule);
  border-top: 3px solid var(--ed-accent);
  padding: 1.35rem 1.4rem;
}

.ed-rigor-title {
  font-family: var(--font-ed-serif) !important;
  font-size: 1.28rem !important;
  font-weight: 600 !important;
  color: var(--ed-ink) !important;
  margin: 0.2rem 0 0.65rem 0 !important;
  border: none !important;
  padding: 0 !important;
}

.ed-rigor-intro {
  font-size: 0.84rem;
  color: var(--ed-ink-secondary);
  margin: 0 0 0.95rem 0;
  line-height: 1.52;
}

.ed-regime-meter {
  margin-bottom: 1rem;
  padding: 0.7rem 0.8rem;
  background: var(--ed-paper-elev);
  border: 1px solid var(--ed-rule);
}

.ed-regime-bar {
  display: flex;
  height: 8px;
  width: 100%;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.ed-reg-v { background: #60672B; width: 32.4%; }
.ed-reg-f { background: #D7D218; width: 29.1%; }
.ed-reg-r { background: #464C1E; width: 38.5%; }

.ed-regime-legend {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  font-family: var(--font-ed-mono);
  font-size: 0.68rem;
  color: var(--ed-ink-secondary);
}

.ed-rigor-list {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.ed-rigor-list li {
  padding: 0.6rem 0;
  border-top: 1px solid var(--ed-rule);
  font-size: 0.82rem;
  line-height: 1.48;
  color: var(--ed-ink-secondary);
}

.ed-rigor-list li strong {
  display: block;
  color: var(--ed-ink);
  font-weight: 600;
  margin-bottom: 0.1rem;
}

.ed-rigor-actions {
  margin-top: 0.95rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--ed-rule-strong);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

/* ==========================================================================
 * 6. HISTORICAL MONOGRAPH SYNTHESIS & DIRECTORY STRIP (BELOW BRIDGES)
 * ========================================================================== */
.ed-monograph-section {
  padding: 2.1rem 0 1rem;
}

.ed-chapters-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.75rem;
  margin-top: 1.1rem;
}

.ed-chapter-col {
  border-top: 1px solid var(--ed-rule-strong);
  padding-top: 0.85rem;
}

.ed-chapter-num {
  font-family: var(--font-ed-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ed-gall);
  letter-spacing: 0.06em;
}

.ed-chapter-col h3 {
  font-family: var(--font-ed-serif) !important;
  font-size: 1.14rem !important;
  font-weight: 600 !important;
  margin: 0.25rem 0 0.55rem 0 !important;
  color: var(--ed-ink) !important;
  border: none !important;
  padding: 0 !important;
}

.ed-chapter-col p {
  font-size: 0.87rem;
  color: var(--ed-ink-secondary);
  line-height: 1.58;
  margin: 0;
}

/* Full-Folio Inspection Lightbox Dialog */
.ed-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: rgba(15, 17, 16, 0.84);
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.ed-modal-backdrop.is-open {
  display: flex;
}

.ed-modal-dialog {
  background: var(--ed-paper-elev);
  border: 1px solid var(--ed-ink);
  max-width: 940px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.ed-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--ed-rule);
  font-family: var(--font-ed-mono);
  font-size: 0.76rem;
}

.ed-modal-body {
  overflow: auto;
  padding: 1rem;
  text-align: center;
  background: #1A1A1A;
}

.ed-modal-body img {
  max-width: 100%;
  height: auto;
}

/* ==========================================================================
 * 7. INNER PAGES PROSE, TABLES, BREADCRUMBS & FOOTER HARMONIZATION
 * ========================================================================== */
.ed-inner-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.45rem 0 0.75rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--ed-rule);
}

.ed-inner-topbar .breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--font-ed-mono);
  font-size: 0.72rem;
  color: var(--ed-ink-muted);
}

.ed-inner-topbar .breadcrumbs li + li::before {
  content: "/";
  margin-right: 0.35rem;
  color: var(--ed-rule);
}

.ed-fallback-banner {
  background: var(--ed-vellum);
  border: 1px solid var(--ed-rule);
  border-left: 3px solid var(--ed-accent);
  padding: 0.6rem 0.95rem;
  margin-bottom: 1.2rem;
  font-size: 0.83rem;
  color: var(--ed-ink-secondary);
}

.ed-prose h1 {
  font-family: var(--font-ed-serif) !important;
  font-weight: 600 !important;
  letter-spacing: -0.015em !important;
  color: var(--ed-ink) !important;
  border-bottom: 2px solid var(--ed-rule-strong) !important;
  padding-bottom: 0.65rem !important;
  margin-bottom: 1.25rem !important;
}

.ed-prose h2 {
  font-family: var(--font-ed-serif) !important;
  font-weight: 600 !important;
  color: var(--ed-ink) !important;
  border-top: 1px solid var(--ed-rule) !important;
  border-bottom: none !important;
  padding-top: 1.2rem !important;
  margin-top: 2rem !important;
}

.ed-prose code {
  font-family: var(--font-ed-mono) !important;
  font-size: 0.82em !important;
}

.ed-prose table {
  border-collapse: collapse !important;
  border-top: 1.5px solid var(--ed-rule-strong) !important;
  border-bottom: 1.5px solid var(--ed-rule-strong) !important;
}

.ed-prose table thead th {
  background: var(--ed-vellum) !important;
  color: var(--ed-ink) !important;
  font-family: var(--font-ed-mono) !important;
  font-size: 0.73rem !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--ed-rule-strong) !important;
}

.verif-badge {
  font-family: var(--font-ed-mono) !important;
  font-size: 0.68rem !important;
  border-radius: 0 !important;
  background: var(--ed-gall-soft) !important;
  color: var(--ed-gall) !important;
  border: 1px solid var(--ed-rule) !important;
}

/* Gardunia Soalheira-style Footer — Torres Novas Municipal Palette (Light & Dark) */
#footer {
  background: var(--ed-vellum) !important;
  border-top: 3px solid #60672B !important;
  box-shadow: inset 0 2px 0 0 rgba(215, 210, 24, 0.55);
  color: var(--ed-ink-secondary) !important;
}

.gardunia-footer-license {
  max-width: 920px;
  margin: 0.75rem auto 1rem;
  padding: 1rem 1.3rem;
  border-radius: 8px;
  border: 1px solid rgba(96, 103, 43, 0.28);
  border-left: 4px solid #60672B;
  background: rgba(96, 103, 43, 0.045);
  font-size: 0.82rem;
  line-height: 1.56;
  text-align: left;
  color: var(--ed-ink-secondary);
}

.gardunia-footer-heading,
.gardunia-footer-domain {
  font-weight: 700;
  color: #464C1E;
}

.gardunia-footer-heading {
  margin-bottom: 0.18rem;
}

.gardunia-footer-divider {
  border-top: 1px solid rgba(96, 103, 43, 0.18);
}

.gardunia-footer-warning {
  font-size: 0.79rem;
  color: #8b1e2a;
  font-weight: 600;
}

.gardunia-footer-cite {
  flex: 1 1 560px;
  font-family: var(--font-ed-mono, monospace);
  font-size: 0.77rem;
  padding: 0.35rem 0.6rem;
  border-radius: 5px;
  background: rgba(96, 103, 43, 0.07);
  color: var(--ed-ink);
  user-select: all;
  white-space: normal;
  word-break: break-word;
}

.gardunia-footer-copy-btn {
  background: #60672B;
  color: #ffffff !important;
  border: none;
  border-bottom: 2px solid #D7D218;
  border-radius: 5px;
  padding: 0.32rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.gardunia-footer-copy-btn:hover {
  background: #464C1E;
}

html[data-theme="dark"] .gardunia-footer-license {
  border-color: rgba(215, 210, 24, 0.30);
  border-left-color: #D7D218;
  background: rgba(96, 103, 43, 0.16);
}

html[data-theme="dark"] .gardunia-footer-heading,
html[data-theme="dark"] .gardunia-footer-domain {
  color: #D7D218;
}

html[data-theme="dark"] .gardunia-footer-divider {
  border-top-color: rgba(215, 210, 24, 0.18);
}

html[data-theme="dark"] .gardunia-footer-warning {
  color: #fca5a5;
}

html[data-theme="dark"] .gardunia-footer-cite {
  background: rgba(255, 255, 255, 0.07);
}

html[data-theme="dark"] .gardunia-footer-copy-btn {
  background: #60672B;
  border: 1px solid #D7D218;
}

/* ==========================================================================
 * 8. RESPONSIVE BREAKPOINTS (TABLET & MOBILE)
 * ========================================================================== */
@media (max-width: 1080px) {
  .ed-metrics-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .ed-metric-cell:nth-child(3) {
    border-right: none;
  }
  .ed-metric-cell:nth-child(-n+3) {
    border-bottom: 1px solid var(--ed-rule);
  }
  .ed-magazine-grid {
    grid-template-columns: 1fr;
  }
  .ed-bridges-subgrid,
  .ed-chapters-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .ed-hero-grid,
  .ed-gateway-grid,
  .ed-footer-grid {
    grid-template-columns: 1fr;
  }
  .ed-hero-colophon {
    border-left: none;
    border-top: 1px solid var(--ed-rule);
    padding-left: 0;
    padding-top: 1rem;
  }
  .ed-track-a {
    border-right: none;
    border-bottom: 1px solid var(--ed-rule-strong);
  }
  .ed-search-bar {
    grid-template-columns: 1fr;
  }
  .ed-quick-search-btn span,
  .ed-quick-search-btn kbd {
    display: none;
  }
}

@media (max-width: 560px) {
  .container {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
  .ed-metrics-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ed-metric-cell {
    border-bottom: 1px solid var(--ed-rule);
  }
  .ed-track {
    padding: 1.15rem 1rem;
  }
}
