/* ============================================================
   TERRA MAGICA — Design tokens & base styles
   ============================================================ */

:root {
  /* Parchment palette */
  --parchment-50: #faf3e0;
  --parchment-100: #f4ead5;
  --parchment-200: #ecdfbf;
  --parchment-300: #e1cea2;
  --parchment-400: #c9b585;

  /* Ink */
  --ink-900: #1f1812;
  --ink-800: #2d251c;
  --ink-700: #4a3d2e;
  --ink-500: #6b5a44;
  --ink-400: #8a7a62;

  /* Accents */
  --leather: #5a3a22;
  --leather-dark: #3e2614;
  --forest: #2d4a32;
  --forest-dark: #1c3220;
  --bordeaux: #7a2e2a;
  --bordeaux-dark: #5a1f1c;
  --gold: #a87d3a;
  --gold-light: #c9a458;

  /* Semantic */
  --bg: var(--parchment-100);
  --surface: var(--parchment-200);
  --surface-raised: var(--parchment-50);
  --text: var(--ink-900);
  --text-muted: var(--ink-500);
  --border: rgba(90, 58, 34, 0.25);
  --border-strong: rgba(90, 58, 34, 0.5);
  --accent: var(--leather);
  --accent-2: var(--forest);
  --accent-3: var(--bordeaux);

  /* Type */
  --font-display: 'Cormorant Garamond', 'Garamond', serif;
  --font-eyebrow: 'IM Fell English SC', 'Cormorant Garamond', serif;
  --font-body: 'EB Garamond', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --font-ui: 'Inter', -apple-system, sans-serif;

  --texture-strength: 0.55;
}

/* Palette swap: rotate which hue is "primary" by remapping --leather (used everywhere as primary accent) */
[data-palette="forest"] {
  --leather: #2d4a32;
  --leather-dark: #1c3220;
  --forest: #5a3a22;
  --forest-dark: #3e2614;
  --bordeaux: #7a2e2a;
  --bordeaux-dark: #5a1f1c;
  --accent: var(--leather);
  --accent-2: var(--forest);
  --accent-3: var(--bordeaux);
}

[data-palette="bordeaux"] {
  --leather: #7a2e2a;
  --leather-dark: #5a1f1c;
  --forest: #5a3a22;
  --forest-dark: #3e2614;
  --bordeaux: #2d4a32;
  --bordeaux-dark: #1c3220;
  --accent: var(--leather);
  --accent-2: var(--forest);
  --accent-3: var(--bordeaux);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Parchment texture using layered gradients — aged, mottled, stained */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: var(--texture-strength);
  background:
    /* mottled age stains */
    radial-gradient(ellipse 35% 28% at 12% 18%, rgba(120, 82, 38, 0.16) 0%, transparent 60%),
    radial-gradient(ellipse 30% 22% at 78% 12%, rgba(90, 58, 34, 0.13) 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 88% 72%, rgba(120, 82, 38, 0.15) 0%, transparent 62%),
    radial-gradient(ellipse 28% 24% at 22% 82%, rgba(90, 58, 34, 0.12) 0%, transparent 60%),
    radial-gradient(circle at 55% 45%, rgba(168, 125, 58, 0.10) 0%, transparent 40%),
    /* warm glow corners */
    radial-gradient(ellipse at 15% 10%, rgba(168, 125, 58, 0.16) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 80%, rgba(90, 58, 34, 0.14) 0%, transparent 55%),
    /* edge darkening vignette — the burnt parchment border */
    radial-gradient(ellipse 120% 120% at 50% 50%, transparent 55%, rgba(90, 58, 34, 0.10) 80%, rgba(62, 38, 20, 0.22) 100%),
    /* fine fibre weave */
    repeating-linear-gradient(
      127deg,
      transparent 0, transparent 2px,
      rgba(90, 58, 34, 0.018) 2px, rgba(90, 58, 34, 0.018) 4px
    ),
    repeating-linear-gradient(
      37deg,
      transparent 0, transparent 3px,
      rgba(168, 125, 58, 0.022) 3px, rgba(168, 125, 58, 0.022) 5px
    );
}

/* Subtle paper noise via SVG data URI */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: calc(var(--texture-strength) * 0.7);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.35  0 0 0 0 0.22  0 0 0 0 0.13  0 0 0 0.4 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.5'/></svg>");
  mix-blend-mode: multiply;
}

main, header, footer, nav { position: relative; z-index: 1; }

/* Typography */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink-900);
  letter-spacing: -0.01em;
  margin: 0 0 0.4em 0;
  text-wrap: balance;
}

h1 { font-size: clamp(2.5rem, 5vw, 4.5rem); line-height: 1.05; font-weight: 500; }
h2 { font-size: clamp(1.8rem, 3vw, 2.75rem); line-height: 1.15; }
h3 { font-size: 1.5rem; line-height: 1.25; }
h4 { font-size: 1.15rem; line-height: 1.3; font-family: var(--font-body); font-weight: 700; }

p { margin: 0 0 1em 0; text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

a { color: var(--leather-dark); text-decoration: none; }
a:hover { color: var(--bordeaux); }

.eyebrow {
  font-family: var(--font-eyebrow);
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--leather);
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
}

.eyebrow::before, .eyebrow::after {
  content: "";
  width: 24px;
  height: 1px;
  background: currentColor;
  opacity: 0.6;
}

.eyebrow.no-rules::before, .eyebrow.no-rules::after { display: none; }

.script {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-500);
}

/* Container */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 32px;
}

.container-narrow { max-width: 900px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 26px;
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 600;
  border-radius: 2px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  background: transparent;
  color: var(--ink-900);
  position: relative;
  letter-spacing: 0.01em;
}

.btn-primary {
  background: var(--ink-900);
  color: var(--parchment-50);
  border-color: var(--ink-900);
}
.btn-primary:hover {
  background: var(--bordeaux);
  border-color: var(--bordeaux);
  color: var(--parchment-50);
  transform: translateY(-1px);
}

.btn-secondary {
  background: transparent;
  color: var(--ink-900);
  border-color: var(--ink-900);
}
.btn-secondary:hover {
  background: var(--ink-900);
  color: var(--parchment-50);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-900);
  border-color: transparent;
  padding: 14px 0;
}
.btn-ghost::after {
  content: "→";
  transition: transform 0.18s ease;
}
.btn-ghost:hover::after { transform: translateX(4px); }

.btn-sm { padding: 8px 16px; font-size: 0.9rem; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 32px;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-raised {
  background: var(--surface-raised);
  box-shadow:
    0 1px 0 rgba(90, 58, 34, 0.08),
    0 8px 24px rgba(31, 24, 18, 0.08);
}

.card:hover.card-hoverable {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(31, 24, 18, 0.12);
}

/* Ornaments — richer medieval-flourish divider */
.ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: var(--gold);
  font-size: 1rem;
  margin: 3.5em auto;
  max-width: 720px;
  position: relative;
}

/* Outer flourish caps */
.ornament::before, .ornament::after {
  content: "";
  flex: 1;
  height: 14px;
  max-width: 240px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
}

.ornament::before {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 14' preserveAspectRatio='none'><g fill='none' stroke='%23a87d3a' stroke-width='1' stroke-linecap='round'><path d='M0 7 L200 7'/><path d='M0 4 L180 4'/><path d='M200 7 C 210 7, 215 3, 222 4 C 228 5, 230 9, 226 11 C 222 12, 218 10, 220 7'/><circle cx='234' cy='7' r='2.2' fill='%23a87d3a'/></g></svg>");
}

.ornament::after {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 14' preserveAspectRatio='none'><g fill='none' stroke='%23a87d3a' stroke-width='1' stroke-linecap='round'><path d='M40 7 L240 7'/><path d='M60 4 L240 4'/><path d='M40 7 C 30 7, 25 3, 18 4 C 12 5, 10 9, 14 11 C 18 12, 22 10, 20 7'/><circle cx='6' cy='7' r='2.2' fill='%23a87d3a'/></g></svg>");
}

/* Center glyph wrapped in diamond frame */
.ornament > span,
.ornament .glyph {
  position: relative;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: var(--leather);
  z-index: 1;
}

.ornament > span::before,
.ornament .glyph::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid var(--gold);
  transform: rotate(45deg);
  background: var(--parchment-50);
}

.ornament > span::after,
.ornament .glyph::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid var(--gold);
  opacity: 0.5;
  transform: rotate(45deg);
}

/* Glyph itself sits above the diamond frame */
.ornament > span > *,
.ornament .glyph > * {
  position: relative;
  z-index: 2;
}

/* When glyph is plain text (default ❦) */
.ornament > span:not(:has(*))::before {
  /* fallback already handled by ::before pseudo */
}

/* Variant: dark backgrounds (e.g. wrapped in dark sections) */
.night-bg .ornament,
.dark .ornament {
  color: var(--gold-light);
}
.night-bg .ornament > span::before,
.dark .ornament > span::before {
  background: transparent;
}

/* Placeholder image */
.placeholder-img {
  background:
    repeating-linear-gradient(
      45deg,
      var(--parchment-300) 0,
      var(--parchment-300) 8px,
      var(--parchment-200) 8px,
      var(--parchment-200) 16px
    );
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-500);
  text-align: center;
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.placeholder-img::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px dashed var(--border-strong);
  pointer-events: none;
}

.placeholder-img span {
  background: var(--parchment-100);
  padding: 6px 10px;
  position: relative;
  z-index: 1;
  border: 1px solid var(--border);
}

/* Tag/chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-family: var(--font-body);
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--parchment-50);
  color: var(--ink-700);
  border-radius: 2px;
  letter-spacing: 0.02em;
}
.chip-filled { background: var(--ink-900); color: var(--parchment-50); border-color: var(--ink-900); }
.chip-leather { background: var(--leather); color: var(--parchment-50); border-color: var(--leather); }
.chip-forest { background: var(--forest); color: var(--parchment-50); border-color: var(--forest); }
.chip-bordeaux { background: var(--bordeaux); color: var(--parchment-50); border-color: var(--bordeaux); }
.chip-gold { background: var(--gold); color: var(--ink-900); border-color: var(--gold); }

/* Forms */
input, textarea, select {
  width: 100%;
  padding: 12px 14px;
  background: var(--parchment-50);
  border: 1px solid var(--border-strong);
  color: var(--ink-900);
  font-family: var(--font-body);
  font-size: 1rem;
  border-radius: 2px;
  outline: none;
  transition: border-color 0.15s ease;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--leather);
  background: var(--parchment-50);
  box-shadow: 0 0 0 3px rgba(90, 58, 34, 0.1);
}
label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink-700);
  letter-spacing: 0.02em;
}

/* Wax seal */
.wax-seal {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--bordeaux), var(--bordeaux-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--parchment-50);
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  box-shadow:
    inset 0 -4px 8px rgba(0,0,0,0.3),
    inset 0 4px 8px rgba(255,255,255,0.1),
    0 4px 12px rgba(122, 46, 42, 0.3);
  position: relative;
  flex-shrink: 0;
}
.wax-seal::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px dashed rgba(255,255,255,0.3);
  border-radius: 50%;
}

/* Navigation */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(244, 234, 213, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  max-width: 1400px;
  margin: 0 auto;
}
.nav-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--ink-900);
  cursor: pointer;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.nav-logo-mark {
  width: 38px;
  height: 38px;
  border: 1.5px solid var(--ink-900);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  background: var(--ink-900);
  color: var(--parchment-50);
}
.nav-links {
  display: flex;
  gap: 4px;
  align-items: center;
}
.nav-link {
  padding: 8px 14px;
  font-size: 0.95rem;
  color: var(--ink-700);
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.15s ease;
  font-weight: 500;
}
.nav-link:hover { color: var(--ink-900); background: rgba(90, 58, 34, 0.08); }
.nav-link.active { color: var(--ink-900); background: rgba(90, 58, 34, 0.12); }

/* Nav dropdown */
.nav-dropdown { position: relative; }
.nav-dropdown .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nav-caret {
  font-size: 0.7rem;
  transition: transform 0.18s ease;
  display: inline-block;
}
.nav-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 280px;
  background: var(--parchment-50);
  border: 1px solid var(--border-strong);
  box-shadow: 0 12px 32px rgba(31, 24, 18, 0.18);
  padding: 8px;
  z-index: 200;
  animation: fadeUp 0.16s ease-out both;
}
.nav-menu::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 24px;
  width: 11px;
  height: 11px;
  background: var(--parchment-50);
  border-left: 1px solid var(--border-strong);
  border-top: 1px solid var(--border-strong);
  transform: rotate(45deg);
}
.nav-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  cursor: pointer;
  color: var(--ink-700);
  font-size: 0.98rem;
  transition: background 0.14s ease, color 0.14s ease;
}
.nav-menu-item:hover { background: rgba(90, 58, 34, 0.08); color: var(--ink-900); }
.nav-menu-item.active { background: rgba(90, 58, 34, 0.12); color: var(--ink-900); }
.nav-menu-glyph {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  font-size: 0.95rem;
  background: var(--surface);
  flex-shrink: 0;
}

/* Bibliothèque tab bar */
.biblio-tabbar {
  position: sticky;
  top: 71px;
  z-index: 90;
  background: rgba(244, 234, 213, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.biblio-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.biblio-tabs::-webkit-scrollbar { display: none; }
.biblio-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 16px 18px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink-500);
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.biblio-tab:hover { color: var(--ink-900); }
.biblio-tab.active { color: var(--ink-900); border-bottom-color: var(--leather); }
.biblio-tab-glyph { font-size: 1.05rem; }

/* Chronicle timeline */
.chronicle-timeline {
  position: relative;
  padding-left: 8px;
}
.chronicle-entry {
  position: relative;
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 24px;
  padding-bottom: 28px;
}
.chronicle-entry:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 27px;
  top: 56px;
  bottom: -4px;
  width: 1px;
  background: linear-gradient(180deg, var(--gold), transparent);
}
.chronicle-node {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--ink-900);
  color: var(--gold-light);
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--gold);
  flex-shrink: 0;
}

/* Price tables */
.price-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.98rem;
}
.price-table tr { border-bottom: 1px solid var(--border); }
.price-table tr:last-child { border-bottom: none; }
.price-table tr:nth-child(odd) { background: rgba(90, 58, 34, 0.03); }
.price-table td { padding: 13px 18px; vertical-align: middle; }
.pt-name { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; color: var(--ink-900); }
.pt-desc { color: var(--ink-500); font-size: 0.9rem; }
.pt-price {
  text-align: right;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--leather);
  white-space: nowrap;
}

@media (max-width: 600px) {
  .pt-desc { display: none; }
}

/* Footer */
/* Reusable wood panel — dark stained planks */
.wood-panel {
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0, transparent 158px,
      rgba(0,0,0,0.30) 158px, rgba(0,0,0,0.30) 160px,
      rgba(120, 78, 40, 0.12) 161px, rgba(120, 78, 40, 0.12) 163px,
      transparent 164px, transparent 180px
    ),
    repeating-linear-gradient(
      88deg,
      rgba(40, 24, 12, 0.0) 0, rgba(40, 24, 12, 0.0) 3px,
      rgba(30, 18, 9, 0.22) 3px, rgba(30, 18, 9, 0.22) 4px,
      rgba(60, 38, 18, 0.10) 5px, rgba(60, 38, 18, 0.10) 9px
    ),
    radial-gradient(ellipse 30% 60% at 20% 35%, rgba(95, 60, 30, 0.40) 0%, transparent 60%),
    radial-gradient(ellipse 26% 50% at 75% 70%, rgba(70, 44, 22, 0.32) 0%, transparent 60%),
    linear-gradient(180deg, #32230f 0%, #20150a 100%);
  position: relative;
}
.wood-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='w2'><feTurbulence type='fractalNoise' baseFrequency='0.012 0.18' numOctaves='4' seed='3'/><feColorMatrix values='0 0 0 0 0.12  0 0 0 0 0.07  0 0 0 0 0.03  0 0 0 0.5 0'/></filter><rect width='100%' height='100%' filter='url(%23w2)'/></svg>");
  opacity: 0.5;
  mix-blend-mode: overlay;
}
.wood-panel > * { position: relative; z-index: 1; }

/* Footer — dark stained wood planks */
.footer {
  background:
    /* plank seams (vertical shadow lines) */
    repeating-linear-gradient(
      90deg,
      transparent 0, transparent 218px,
      rgba(0,0,0,0.32) 218px, rgba(0,0,0,0.32) 220px,
      rgba(120, 78, 40, 0.12) 221px, rgba(120, 78, 40, 0.12) 223px,
      transparent 224px, transparent 240px
    ),
    /* wood grain streaks */
    repeating-linear-gradient(
      88deg,
      rgba(40, 24, 12, 0.0) 0, rgba(40, 24, 12, 0.0) 3px,
      rgba(30, 18, 9, 0.25) 3px, rgba(30, 18, 9, 0.25) 4px,
      rgba(60, 38, 18, 0.10) 5px, rgba(60, 38, 18, 0.10) 9px
    ),
    /* warm knots / lighting */
    radial-gradient(ellipse 30% 60% at 18% 40%, rgba(90, 56, 28, 0.35) 0%, transparent 60%),
    radial-gradient(ellipse 26% 50% at 72% 65%, rgba(70, 44, 22, 0.30) 0%, transparent 60%),
    linear-gradient(180deg, #2a1c10 0%, #1d130a 100%);
  color: var(--parchment-200);
  padding: 64px 0 32px;
  margin-top: 80px;
  position: relative;
  z-index: 2;
  border-top: 3px solid var(--leather-dark);
  box-shadow: inset 0 6px 16px rgba(0,0,0,0.4);
}
.footer::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='w'><feTurbulence type='fractalNoise' baseFrequency='0.012 0.18' numOctaves='4' seed='7'/><feColorMatrix values='0 0 0 0 0.12  0 0 0 0 0.07  0 0 0 0 0.03  0 0 0 0.55 0'/></filter><rect width='100%' height='100%' filter='url(%23w)'/></svg>");
  opacity: 0.5;
  mix-blend-mode: overlay;
}
.footer > * { position: relative; z-index: 1; }
.footer h4 {
  font-family: var(--font-eyebrow);
  font-size: 0.9rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold-light);
  margin-bottom: 1em;
}
.footer a { color: var(--parchment-200); display: block; padding: 4px 0; }
.footer a:hover { color: var(--gold-light); }

/* ===== Bibliothèque ===== */
.library-grid { }

/* Featured tome (book) */
.tome {
  position: relative;
  aspect-ratio: 3 / 4;
  display: flex;
  filter: drop-shadow(0 16px 32px rgba(31, 24, 18, 0.28));
  transition: transform 0.25s ease;
}
.card-hoverable:hover .tome { transform: translateY(-4px) rotate(-0.4deg); }

.tome-spine {
  width: 26px;
  flex-shrink: 0;
  background:
    linear-gradient(90deg, var(--leather-dark), var(--leather) 45%, var(--leather-dark));
  border-right: 1px solid rgba(0,0,0,0.35);
  box-shadow: inset -4px 0 8px rgba(0,0,0,0.4), inset 3px 0 4px rgba(255,255,255,0.06);
  border-radius: 3px 0 0 3px;
}
.tome-cover {
  flex: 1;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(120, 78, 40, 0.5), transparent 60%),
    linear-gradient(160deg, var(--leather) 0%, var(--leather-dark) 100%);
  border: 1px solid rgba(0,0,0,0.3);
  border-radius: 2px 6px 6px 2px;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.35);
  display: flex;
  padding: 22px;
}
.tome-frame {
  flex: 1;
  border: 1px solid var(--gold);
  outline: 1px solid var(--gold);
  outline-offset: -5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
}
.tome-rule {
  width: 70%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-light) 50%, transparent);
  margin: 16px 0;
}

/* Shelf category label */
.shelf-label {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-eyebrow);
  font-size: 0.92rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--leather);
}
.shelf-glyph {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--gold);
  border-radius: 50%;
  font-size: 1rem;
  background: var(--parchment-50);
  flex-shrink: 0;
}
.shelf-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--gold) 0%, transparent 100%);
  opacity: 0.5;
}

/* Document row */
.doc-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 20px;
  align-items: center;
  padding: 18px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.doc-row:hover {
  transform: translateX(4px);
  border-color: var(--gold);
  box-shadow: 0 6px 18px rgba(31, 24, 18, 0.1);
}
.doc-icon {
  width: 48px;
  height: 62px;
  background: var(--parchment-50);
  border: 1px solid var(--border-strong);
  position: relative;
  flex-shrink: 0;
}
.doc-fold {
  position: absolute;
  top: 0; right: 0;
  width: 0; height: 0;
  border-top: 12px solid var(--parchment-200);
  border-left: 12px solid transparent;
}
.doc-lines {
  position: absolute;
  bottom: 8px; left: 7px; right: 7px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.doc-lines span {
  height: 1px;
  background: var(--ink-500);
  opacity: 0.4;
}
.doc-dl {
  font-size: 1.4rem;
  color: var(--leather);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 50%;
  transition: all 0.18s ease;
  flex-shrink: 0;
}
.doc-row:hover .doc-dl {
  border-color: var(--gold);
  background: var(--parchment-50);
}

@media (max-width: 900px) {
  .library-grid { grid-template-columns: 1fr !important; }
  .library-grid > div:first-child { position: static !important; max-width: 340px; margin: 0 auto; }
}

/* Masonry gallery */
.masonry {
  column-count: 4;
  column-gap: 14px;
}
.masonry-item {
  margin: 0 0 14px;
  break-inside: avoid;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.masonry-item .placeholder-img {
  transition: transform 0.4s ease, filter 0.3s ease;
}
.masonry-item:hover .placeholder-img {
  transform: scale(1.04);
  filter: brightness(0.92);
}
.masonry-item figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 28px 16px 12px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--parchment-50);
  background: linear-gradient(180deg, transparent, rgba(31, 24, 18, 0.82));
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.masonry-item:hover figcaption {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1024px) { .masonry { column-count: 3; } }
@media (max-width: 720px) { .masonry { column-count: 2; } }
@media (max-width: 460px) { .masonry { column-count: 1; } }

/* Animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fadeUp 0.5s ease-out both; }

/* Responsive */
@media (max-width: 1100px) {
  .nav-links { display: none; }
  .nav-mobile-toggle { display: flex; }
}

@media (max-width: 768px) {
  body { font-size: 16px; }
  .container { padding: 0 20px; }
  h1 { font-size: 2.4rem; }
  h2 { font-size: 1.8rem; }
}

.nav-mobile-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-strong);
  cursor: pointer;
}
