:root {
  --ink: #f5ead2;
  --muted: #cbbd9f;
  --gold: #d7aa55;
  --deep: #090806;
  --panel: rgba(17, 13, 9, .82);
  --line: rgba(215, 170, 85, .34);
  --nav-h: 72px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 0%, rgba(116, 73, 27, .18), transparent 34rem),
    linear-gradient(180deg, #100c08 0%, #090806 60%, #060504 100%);
  font-family: Georgia, 'Times New Roman', serif;
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -3;
  opacity: .22;
  background-image:
    linear-gradient(90deg, transparent 49%, rgba(255,255,255,.025) 50%, transparent 51%),
    linear-gradient(0deg, transparent 49%, rgba(255,255,255,.018) 50%, transparent 51%);
  background-size: 48px 48px, 48px 48px;
}

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

.site-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  min-height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px clamp(16px, 4vw, 64px);
  background: linear-gradient(180deg, rgba(9,7,5,.96), rgba(9,7,5,.83));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.nav-mark {
  text-decoration: none;
  font-weight: 700;
  letter-spacing: .16em;
  color: #f2cf82;
  white-space: nowrap;
}
.nav-links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: clamp(16px, 3vw, 36px);
}
.nav-links a,
.house-nav a {
  position: relative;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: .13em;
  font-size: .82rem;
  color: #e8dcc4;
}
.nav-links a::after,
.house-nav a::after {
  content: '';
  position: absolute;
  left: 0;
  right: 100%;
  bottom: -6px;
  height: 1px;
  background: #e6b85c;
  transition: right .25s ease;
}
.nav-links a:hover::after,
.nav-links a:focus-visible::after,
.house-nav a:hover::after,
.house-nav a:focus-visible::after { right: 0; }

.hero {
  min-height: calc(100vh - var(--nav-h));
  display: grid;
  place-items: center;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(7,5,4,.28), rgba(7,5,4,.72)),
    url('../img/ibernia-portada.png') center/cover no-repeat;
}
.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(circle at center, transparent 0 28%, rgba(5,4,3,.48) 68%, rgba(5,4,3,.82) 100%);
}
.hero-card {
  width: min(760px, calc(100% - 36px));
  text-align: center;
  padding: clamp(26px, 5vw, 52px);
  background: linear-gradient(145deg, rgba(18,13,8,.76), rgba(7,5,4,.62));
  border: 1px solid rgba(236,193,103,.42);
  box-shadow: 0 24px 80px rgba(0,0,0,.55), inset 0 0 45px rgba(219,160,59,.06);
  backdrop-filter: blur(5px);
}
.hero-logo {
  width: clamp(150px, 22vw, 240px);
  aspect-ratio: 1;
  object-fit: cover;
  object-position: center;
  border-radius: 50%;
  margin: 0 auto 18px;
  filter: drop-shadow(0 0 24px rgba(238,178,60,.26));
}
.hero-kicker,
.section-kicker {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: .32em;
  font-size: .75rem;
  color: #ddb968;
}
h1, h2, h3 { line-height: 1.15; }
h1 {
  margin: 0;
  font-size: clamp(2.3rem, 6vw, 5rem);
  font-weight: 500;
  letter-spacing: .06em;
  text-shadow: 0 3px 18px rgba(0,0,0,.75);
}
.hero-subtitle {
  margin: 16px auto 28px;
  max-width: 44rem;
  color: #e7d7b7;
  font-size: clamp(1rem, 2vw, 1.22rem);
}
.actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 22px;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .78rem;
  border: 1px solid rgba(226,183,91,.62);
  background: linear-gradient(180deg, rgba(121,80,28,.34), rgba(38,27,15,.44));
  box-shadow: inset 0 0 20px rgba(222,166,66,.05), 0 7px 22px rgba(0,0,0,.2);
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}
.button:hover,
.button:focus-visible {
  transform: translateY(-2px);
  background: linear-gradient(180deg, rgba(162,106,31,.45), rgba(51,35,17,.58));
  box-shadow: inset 0 0 24px rgba(222,166,66,.09), 0 9px 28px rgba(0,0,0,.32);
}
.button.secondary { border-color: rgba(231,219,194,.34); color: #e8deca; }

.home-intro {
  padding: 72px 20px 90px;
  text-align: center;
  background: radial-gradient(circle at 50% 0%, rgba(177,115,34,.11), transparent 45rem);
}
.home-intro .inner { max-width: 880px; margin: auto; }
.home-intro h2 { font-size: clamp(1.8rem, 4vw, 3rem); margin: 0 0 18px; font-weight: 500; }
.home-intro p { color: #d7c8aa; font-size: 1.08rem; }

.house-nav-wrap {
  position: sticky;
  top: var(--nav-h);
  z-index: 900;
  background: rgba(11,9,7,.93);
  border-bottom: 1px solid rgba(215,170,85,.24);
  backdrop-filter: blur(8px);
}
.house-nav {
  max-width: 1280px;
  margin: auto;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 3vw, 38px);
  padding: 8px 18px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.house-nav a { white-space: nowrap; font-size: .72rem; }

.foundations-hero {
  position: relative;
  padding: clamp(62px, 8vw, 112px) 20px 80px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(191,127,39,.15), transparent 42rem),
    linear-gradient(180deg, #100c08 0%, #080706 100%);
  overflow: hidden;
}
.foundations-hero h1 { font-size: clamp(2.15rem, 5vw, 4.6rem); }
.foundations-hero .lead {
  margin: 16px auto 40px;
  max-width: 720px;
  color: #cfbea0;
}
.crest-grid {
  max-width: 1180px;
  margin: auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(15px, 2.4vw, 28px);
}
.crest-button {
  position: relative;
  min-width: 0;
  text-decoration: none;
  padding: 18px 14px 14px;
  background: rgba(19,14,10,.56);
  border: 1px solid rgba(215,170,85,.28);
  box-shadow: 0 18px 45px rgba(0,0,0,.24);
  transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
  overflow: hidden;
}
.crest-button::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(circle at 50% 35%, rgba(230,188,94,.14), transparent 58%);
  transition: opacity .25s ease;
}
.crest-button:hover,
.crest-button:focus-visible {
  transform: translateY(-5px);
  border-color: rgba(232,190,97,.62);
  box-shadow: 0 22px 55px rgba(0,0,0,.38);
}
.crest-button:hover::before,
.crest-button:focus-visible::before { opacity: 1; }
.crest-frame {
  width: min(100%, 235px);
  aspect-ratio: 1 / 1;
  margin: 0 auto 14px;
  position: relative;
  display: grid;
  place-items: center;
}
.crest-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 20px rgba(0,0,0,.42));
}
.crest-button strong {
  display: block;
  font-size: clamp(.92rem, 1.5vw, 1.14rem);
  font-weight: 500;
  letter-spacing: .055em;
}

/* Cubre la grafía antigua del escudo original y muestra la forma acordada: Pax Theobroma. */
.pax-fix {
  position: absolute;
  left: 20%;
  top: 37.5%;
  width: 61%;
  min-height: 13%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px 4px;
  color: #2a1b12;
  font-size: clamp(.62rem, 1.35vw, 1rem);
  font-style: italic;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255,255,255,.5);
  background:
    linear-gradient(180deg, #f5d79c, #dbae69 58%, #c78e4d),
    radial-gradient(circle at 20% 25%, rgba(255,255,255,.4), transparent 30%);
  border: 1px solid rgba(83,50,23,.6);
  border-radius: 55% 45% 52% 48% / 35% 34% 66% 65%;
  box-shadow: inset 0 1px 1px rgba(255,255,255,.55), 0 1px 2px rgba(0,0,0,.35);
  transform: rotate(-3deg);
  pointer-events: none;
}

.house-section {
  min-height: 100vh;
  position: relative;
  isolation: isolate;
  display: grid;
  align-items: center;
  padding: clamp(76px, 9vw, 126px) 20px;
  scroll-margin-top: calc(var(--nav-h) + 48px);
  overflow: hidden;
}
.house-section::before,
.house-section::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.house-section::before { z-index: -2; }
.house-section::after {
  z-index: -1;
  background: linear-gradient(90deg, rgba(5,4,3,.94) 0 12%, rgba(8,6,4,.60) 48%, rgba(5,4,3,.94) 88% 100%);
}
.house-inner {
  width: min(1080px, 100%);
  margin: auto;
  display: grid;
  grid-template-columns: minmax(220px, 330px) 1fr;
  gap: clamp(28px, 5vw, 70px);
  align-items: start;
}
.house-visual {
  position: sticky;
  top: calc(var(--nav-h) + 72px);
  text-align: center;
}
.house-visual .crest-frame { width: min(100%, 320px); }
.house-title {
  margin: 13px 0 4px;
  font-size: clamp(1.7rem, 3.2vw, 2.65rem);
  font-weight: 500;
  letter-spacing: .05em;
}
.house-motto {
  margin: 0;
  color: rgba(241,225,196,.72);
  font-style: italic;
}
.parchment {
  position: relative;
  padding: clamp(27px, 4.3vw, 54px);
  color: #e9dec8;
  background:
    linear-gradient(145deg, rgba(30,23,16,.94), rgba(16,13,10,.93)),
    repeating-linear-gradient(0deg, rgba(255,255,255,.015) 0 1px, transparent 1px 5px);
  border: 1px solid var(--house-border, rgba(215,170,85,.32));
  box-shadow: 0 28px 70px rgba(0,0,0,.42), inset 0 0 55px var(--house-glow, rgba(210,170,90,.045));
}
.parchment::before,
.parchment::after {
  content: '✦';
  position: absolute;
  color: var(--house-accent, #d6ab5c);
  opacity: .65;
  font-size: 1.1rem;
}
.parchment::before { left: 12px; top: 8px; }
.parchment::after { right: 12px; bottom: 8px; }
.parchment h3 {
  margin: 0 0 8px;
  font-size: clamp(1.35rem, 2.6vw, 2rem);
  color: var(--house-title, #f0d596);
  font-weight: 500;
}
.parchment .chapter {
  margin: 0 0 24px;
  color: var(--house-accent, #d7b66f);
  font-style: italic;
}
.parchment p { margin: 0 0 1.05em; }
.parchment p:last-child { margin-bottom: 0; }
.motto-box {
  margin-top: 26px;
  padding: 18px 20px;
  text-align: center;
  color: var(--house-title, #f0d596);
  border-top: 1px solid var(--house-border, rgba(215,170,85,.32));
  border-bottom: 1px solid var(--house-border, rgba(215,170,85,.32));
  font-size: 1.05rem;
  font-style: italic;
}
/* Pax Theobroma: sus textos destacados usan un rojo cálido y legible sobre el pergamino oscuro. */
.pax .motto-box {
  color: #e6847d;
  border-color: rgba(230,132,125,.48);
  text-shadow: 0 1px 0 rgba(0,0,0,.35), 0 0 12px rgba(230,132,125,.12);
}

.family-list {
  margin: 14px 0 20px;
  padding-left: 1.2rem;
}
.family-list li { margin: 8px 0; }

.simurg {
  --house-accent: #9dbfe0;
  --house-title: #d9ebff;
  --house-border: rgba(123,166,205,.42);
  --house-glow: rgba(65,133,202,.09);
}
.simurg::before {
  background:
    radial-gradient(circle at 20% 25%, rgba(87,135,188,.26), transparent 32rem),
    radial-gradient(circle at 80% 70%, rgba(160,192,220,.10), transparent 28rem),
    linear-gradient(135deg, #07101a, #10141a 45%, #06090c);
}
.pax {
  --house-accent: #f0c96d;
  --house-title: #f7e0a5;
  --house-border: rgba(217,174,67,.42);
  --house-glow: rgba(234,188,67,.08);
}
.pax::before {
  background:
    radial-gradient(circle at 18% 25%, rgba(76,157,207,.23), transparent 34rem),
    radial-gradient(circle at 78% 65%, rgba(182,156,53,.16), transparent 30rem),
    linear-gradient(135deg, #0e1921, #182016 48%, #0b0c08);
}
.liberium {
  --house-accent: #e1b34a;
  --house-title: #ffe09a;
  --house-border: rgba(225,179,74,.47);
  --house-glow: rgba(229,173,46,.10);
}
.liberium::before {
  background:
    radial-gradient(circle at 16% 30%, rgba(218,159,44,.22), transparent 32rem),
    radial-gradient(circle at 82% 65%, rgba(255,192,60,.10), transparent 26rem),
    linear-gradient(135deg, #161006, #050505 52%, #120d04);
}
.adalo {
  --house-accent: #96e1b3;
  --house-title: #c9ffd9;
  --house-border: rgba(92,198,126,.42);
  --house-glow: rgba(54,224,113,.09);
}
.adalo::before {
  background:
    radial-gradient(circle at 18% 24%, rgba(52,178,102,.22), transparent 33rem),
    radial-gradient(circle at 84% 64%, rgba(135,71,180,.18), transparent 28rem),
    linear-gradient(135deg, #06150c, #111018 50%, #06100a);
}

.spark-field,
.smoke-field {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.spark {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #f4d990;
  box-shadow: 0 0 8px 2px rgba(242,195,91,.6);
  opacity: 0;
  animation: twinkle var(--dur) ease-in-out var(--delay) infinite;
}
@keyframes twinkle {
  0%, 100% { opacity: 0; transform: translateY(8px) scale(.5); }
  45% { opacity: .85; transform: translateY(0) scale(1); }
  60% { opacity: .15; }
}
.smoke {
  position: absolute;
  width: 360px;
  height: 170px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(214,205,188,.11), rgba(176,163,143,.045) 45%, transparent 72%);
  filter: blur(24px);
  opacity: 0;
  animation: drift 18s linear infinite;
}
.smoke.s1 { left: -180px; bottom: 9%; animation-delay: -4s; }
.smoke.s2 { right: -220px; top: 24%; animation-delay: -11s; transform: scale(1.2); }
@keyframes drift {
  0% { opacity: 0; transform: translateX(-8vw) translateY(20px) scale(.85); }
  20% { opacity: .6; }
  70% { opacity: .28; }
  100% { opacity: 0; transform: translateX(28vw) translateY(-70px) scale(1.25); }
}

.candle {
  position: fixed;
  bottom: 20px;
  z-index: 850;
  width: 24px;
  height: 105px;
  border-radius: 7px 7px 3px 3px;
  background: linear-gradient(90deg, #9e815b, #e6d6b5 48%, #a7875b);
  box-shadow: 0 4px 15px rgba(0,0,0,.55);
  opacity: .72;
  pointer-events: none;
}
.candle.left { left: 26px; }
.candle.right { right: 26px; height: 82px; }
.candle::after {
  content: '';
  position: absolute;
  left: 50%;
  top: -31px;
  width: 17px;
  height: 31px;
  transform-origin: 50% 100%;
  transform: translateX(-50%);
  border-radius: 50% 50% 45% 45%;
  background: radial-gradient(ellipse at 50% 78%, #fff7c6 0 16%, #ffd36f 17% 42%, #ef8e2d 43% 64%, transparent 66%);
  filter: drop-shadow(0 0 9px rgba(255,183,64,.75));
  animation: flame 1.8s ease-in-out infinite;
}
@keyframes flame {
  0%,100% { transform: translateX(-50%) rotate(-2deg) scaleY(1); }
  50% { transform: translateX(-50%) rotate(3deg) scaleY(.9) scaleX(.94); }
}

.back-to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 920;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #f3d994;
  background: rgba(12,9,6,.78);
  border: 1px solid rgba(222,178,82,.38);
  text-decoration: none;
  opacity: 0;
  transform: translateY(8px);
  transition: .2s ease;
  pointer-events: none;
}
.back-to-top.visible { opacity: 1; transform: none; pointer-events: auto; }

.site-footer {
  padding: 30px 20px;
  text-align: center;
  color: #9f927d;
  background: #050403;
  border-top: 1px solid rgba(215,170,85,.15);
  font-size: .87rem;
}

@media (max-width: 900px) {
  :root { --nav-h: 64px; }
  .site-nav { padding-inline: 18px; gap: 14px; }
  .nav-mark { font-size: .9rem; }
  .nav-links { gap: 16px; }
  .nav-links a { font-size: .72rem; letter-spacing: .09em; }
  .crest-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 650px; }
  .house-inner { grid-template-columns: 1fr; }
  .house-visual { position: static; }
  .house-visual .crest-frame { width: min(66vw, 290px); }
  .house-motto { max-width: 560px; margin-inline: auto; }
  .candle { display: none; }
}

@media (max-width: 560px) {
  .site-nav { flex-wrap: wrap; min-height: auto; padding-block: 9px; }
  .nav-mark { width: 100%; text-align: center; }
  .nav-links { width: 100%; margin: 0; justify-content: center; }
  .nav-links a { font-size: .68rem; }
  .house-nav-wrap { position: static; }
  .house-nav { justify-content: flex-start; }
  .foundations-hero { padding-top: 44px; }
  .crest-grid { gap: 12px; }
  .crest-button { padding: 10px 8px 12px; }
  .crest-frame { margin-bottom: 8px; }
  .crest-button strong { font-size: .8rem; }
  .pax-fix { font-size: clamp(.48rem, 2.7vw, .76rem); }
  .house-section { min-height: auto; padding: 66px 14px; scroll-margin-top: 10px; }
  .parchment { padding: 25px 20px; }
  .hero-card { padding-inline: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
