/* =========================================================
   LIVRO DO PATRIMÓNIO — V7 DINÂMICO
   ========================================================= */

.heritage-book-section {
  --book-paper: #fffdf8;
  --book-paper-warm: #faf5eb;
  --book-ink: #4f6a83;
  --book-navy: #173d61;
  --book-blue: #1684c5;
  --book-green: #39a263;
  --book-gold: #c8aa64;
  --book-gold-light: #e2ca8c;
  --book-cover: #113a61;
  --book-cover-deep: #082741;

  width: 100%;
  margin-top: clamp(42px, 5vw, 72px);
  scroll-margin-top: 145px;
}

/* Alinhado exatamente com o início do contentor do mapa. */
.heritage-book-heading {
  width: 100%;
  margin: 0 0 20px;
  padding: 0;
}

.heritage-book-heading .section-kicker {
  display: block;
  margin-bottom: 7px;
}

.heritage-book-heading p {
  max-width: 900px;
  margin: 0;
  color: #617791;
  font-size: 1rem;
  line-height: 1.62;
}


/* =========================================================
   PALCO / LIVRO ABERTO
   ========================================================= */

.heritage-book-stage {
  position: relative;

  width: 100%;
  min-height: 754px;

  margin: 0 auto;
  padding: 23px 13px 31px;

  perspective: 2400px;
}

/*
 * Base física do livro.
 * Não é um cartão exterior: fica apenas imediatamente por baixo
 * das folhas, funcionando como capa traseira / lombada.
 */
.heritage-book-base {
  position: absolute;
  z-index: 0;

  inset: 14px 4px 19px;

  border-radius: 28px 28px 36px 36px;

  background:
    repeating-linear-gradient(
      90deg,
      rgba(255,255,255,.018) 0 1px,
      rgba(0,0,0,.018) 1px 3px
    ),
    linear-gradient(
      135deg,
      #1b4d7b 0%,
      #123d66 42%,
      #0a2946 100%
    );

  box-shadow:
    0 26px 48px rgba(5, 38, 63, .23),
    inset 0 -10px 18px rgba(0,0,0,.18),
    inset 0 1px 0 rgba(255,255,255,.10);

  pointer-events: none;
}

.heritage-book-base::before {
  content: "";

  position: absolute;
  inset: 10px;

  border: 1px solid rgba(222, 234, 242, .13);
  border-radius: 20px 20px 28px 28px;
}

.heritage-book-base::after {
  content: "";

  position: absolute;

  top: 14px;
  bottom: 14px;
  left: 50%;

  width: 32px;

  transform: translateX(-50%);

  background:
    radial-gradient(
      ellipse at center,
      rgba(1,18,30,.32),
      rgba(1,18,30,.08) 45%,
      transparent 72%
    );

  pointer-events: none;
}

.heritage-flip-book {
  position: relative;
  z-index: 3;

  width: 100%;
  min-height: 700px;

  margin: 0 auto;

  filter:
    drop-shadow(
      0 18px 19px
      rgba(31, 58, 78, .16)
    );
}

.heritage-flip-book .stf__parent,
.heritage-flip-book .stf__wrapper,
.heritage-flip-book .stf__block {
  overflow: visible !important;
}


/* =========================================================
   CAPA FRONTAL — LIVRO FECHADO
   ========================================================= */

.heritage-book-cover-page {
  position: relative;
  overflow: hidden;

  color: #f7f2e6;

  background:
    radial-gradient(
      ellipse at 50% 26%,
      rgba(255,255,255,.055),
      transparent 34%
    ),
    repeating-linear-gradient(
      0deg,
      rgba(255,255,255,.016) 0 1px,
      rgba(0,0,0,.018) 1px 3px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(255,255,255,.012) 0 1px,
      transparent 1px 4px
    ),
    linear-gradient(
      145deg,
      #174d7a 0%,
      var(--book-cover) 36%,
      var(--book-cover-deep) 100%
    );

  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.08),
    inset 0 -18px 36px rgba(0,0,0,.16);
}

.heritage-book-cover-page::before {
  content: "";

  position: absolute;
  z-index: 1;

  inset: 18px;

  border: 1px solid rgba(210, 180, 109, .72);
  border-radius: 9px;

  box-shadow:
    0 0 0 5px rgba(200, 170, 100, .07),
    inset 0 0 0 1px rgba(236, 215, 158, .12);

  pointer-events: none;
}

.heritage-book-cover-page::after {
  content: "";

  position: absolute;
  z-index: 1;

  inset: 28px;

  border:
    1px solid
    rgba(217, 190, 127, .23);

  border-radius: 5px;

  pointer-events: none;
}

.heritage-cover-inner {
  position: relative;
  z-index: 2;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  height: 100%;

  padding: 72px 68px 62px;

  text-align: center;
}

.heritage-cover-kicker {
  margin-bottom: 25px;

  color: rgba(232, 213, 166, .87);

  font-family: "Montserrat", sans-serif;
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .20em;
  text-transform: uppercase;
}

.heritage-cover-ornament {
  position: relative;

  width: 190px;
  height: 13px;

  margin-bottom: 27px;
}

.heritage-cover-ornament::before,
.heritage-cover-ornament::after {
  content: "";

  position: absolute;
  top: 6px;

  width: 76px;
  height: 1px;

  background:
    linear-gradient(
      90deg,
      transparent,
      var(--book-gold-light)
    );
}

.heritage-cover-ornament::before {
  left: 0;
}

.heritage-cover-ornament::after {
  right: 0;
  transform: scaleX(-1);
}

.heritage-cover-ornament i {
  position: absolute;

  top: 2px;
  left: 50%;

  width: 9px;
  height: 9px;

  border: 1px solid var(--book-gold-light);

  transform:
    translateX(-50%)
    rotate(45deg);
}

.heritage-cover-title {
  max-width: 470px;

  margin: 0 0 32px;

  color: #fbf7ec;

  font-family:
    "Libre Baskerville",
    serif;

  font-size:
    clamp(
      2rem,
      3vw,
      3.05rem
    );

  font-weight: 700;
  line-height: 1.10;
  letter-spacing: -.035em;

  text-shadow:
    0 1px 0 rgba(255,255,255,.12),
    0 2px 14px rgba(0,0,0,.20);
}

/* Medalhão do brasão */
.heritage-cover-crest-medallion {
  display: grid;
  place-items: center;

  width: 126px;
  height: 138px;

  margin-bottom: 29px;

  border: 1px solid rgba(225, 202, 144, .68);
  border-radius: 50% 50% 46% 46% / 42% 42% 58% 58%;

  background:
    radial-gradient(
      circle at 50% 36%,
      rgba(255,255,255,.10),
      rgba(255,255,255,.025) 50%,
      rgba(0,0,0,.055)
    );

  box-shadow:
    0 0 0 5px rgba(200,170,100,.055),
    inset 0 0 22px rgba(0,0,0,.12);
}

.heritage-cover-crest-window {
  display: grid;
  place-items: center;

  width: 96px;
  height: 112px;

  overflow: hidden;
}

.heritage-cover-crest {
  display: block;

  max-width: 88px;
  max-height: 106px;

  object-fit: contain;
}

/*
 * Se ainda não existir assets/img/brasao.png,
 * o JS usa logo.png. Esta classe recorta a zona esquerda
 * do logótipo, onde normalmente se encontra o brasão.
 */
.heritage-cover-crest.is-logo-fallback {
  width: auto;
  max-width: none;
  height: 108px;
  max-height: none;

  justify-self: start;
}

.heritage-cover-junta {
  margin: 0;

  color: rgba(241, 232, 210, .88);

  font-family:
    "Libre Baskerville",
    serif;

  font-size: .78rem;
  line-height: 1.55;
}

.heritage-cover-junta strong {
  display: block;

  margin-bottom: 3px;

  color: #f3e4be;

  font-size: .72rem;
  font-weight: 400;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.heritage-cover-footer-line {
  width: 104px;
  height: 1px;

  margin: 28px auto 0;

  background:
    linear-gradient(
      90deg,
      transparent,
      rgba(226,202,140,.95),
      transparent
    );
}


/* Capa traseira */
.heritage-book-back-cover {
  position: relative;

  background:
    repeating-linear-gradient(
      0deg,
      rgba(255,255,255,.013) 0 1px,
      rgba(0,0,0,.015) 1px 3px
    ),
    linear-gradient(
      145deg,
      #143f69,
      #092944
    );

  box-shadow:
    inset 0 0 0 1px
    rgba(255,255,255,.07);
}


/* =========================================================
   FOLHAS
   ========================================================= */

.heritage-history-page {
  position: relative;
  overflow: hidden;

  color: var(--book-ink);

  background:
    radial-gradient(
      ellipse at 18% 13%,
      rgba(255,255,255,.98),
      transparent 29%
    ),
    radial-gradient(
      circle at 82% 78%,
      rgba(197,165,119,.045),
      transparent 36%
    ),
    linear-gradient(
      90deg,
      var(--book-paper-warm),
      var(--book-paper)
    );

  box-shadow:
    inset 0 0 0 1px
    rgba(177,157,123,.19);
}

.heritage-history-page::before {
  content: "";

  position: absolute;
  inset: 0;

  opacity: .10;
  pointer-events: none;

  background-image:
    radial-gradient(
      circle,
      rgba(89,70,43,.20)
      0 .48px,
      transparent .8px
    );

  background-size: 7px 7px;
  mix-blend-mode: multiply;
}

.heritage-history-page::after {
  content: "";

  position: absolute;
  inset: 0;

  pointer-events: none;

  background:
    linear-gradient(
      90deg,
      rgba(102,76,44,.025),
      transparent 5% 95%,
      rgba(102,76,44,.027)
    );
}

.heritage-history-page-content {
  position: relative;
  z-index: 2;

  height: 100%;

  padding: 64px 48px 57px;
}

.heritage-history-running-head {
  position: absolute;
  z-index: 4;

  top: 17px;
  left: 39px;
  right: 39px;

  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 14px;

  padding-bottom: 9px;

  border-bottom:
    1px solid
    rgba(135,112,78,.18);

  color: #887965;

  font-family:
    "Libre Baskerville",
    serif;

  font-size: .57rem;
  font-style: italic;
}

.heritage-history-page-footer {
  position: absolute;
  z-index: 4;

  left: 39px;
  right: 39px;
  bottom: 17px;

  display: flex;
  align-items: center;

  gap: 10px;

  color: #887b68;

  font-family:
    "Libre Baskerville",
    serif;

  font-size: .60rem;
}

.heritage-history-page-footer i {
  flex: 1;

  height: 1px;

  background:
    rgba(138,125,105,.23);
}


/* =========================================================
   ABERTURA — PÁGINA 01
   ========================================================= */

.heritage-book-opening {
  height: 100%;
}

.heritage-book-place-name {
  max-width: 600px;

  margin: 1px 0 24px;

  color: var(--book-navy);

  font-family:
    "Libre Baskerville",
    serif;

  font-size:
    clamp(
      2.15rem,
      2.8vw,
      3.05rem
    );

  font-weight: 700;
  line-height: 1.06;
  letter-spacing: -.043em;
}

.heritage-book-opening-photo {
  position: relative;
  overflow: hidden;

  height: 482px;

  padding: 7px;

  border:
    1px solid
    rgba(151,126,91,.22);

  border-radius: 3px;

  background: #f4eee3;

  box-shadow:
    0 11px 25px
    rgba(73,59,39,.13);

  transform:
    rotate(-.07deg);
}

.heritage-book-opening-photo img,
.heritage-book-visual-grid img,
.heritage-book-gallery-grid img {
  display: block;

  width: 100%;
  height: 100%;

  object-fit: cover;
}

.heritage-book-image-fallback {
  display: none;

  position: absolute;
  inset: 7px;

  place-items: center;

  background:
    linear-gradient(
      135deg,
      #daeaf1,
      #cbdfe8
    );

  color: #7892a2;

  font-family:
    "Libre Baskerville",
    serif;

  font-size: .72rem;
  font-style: italic;
}

.heritage-book-is-missing > img {
  display: none !important;
}

.heritage-book-is-missing >
.heritage-book-image-fallback {
  display: grid;
}


/* =========================================================
   CAPÍTULOS
   ----- CAPÍTULO I -----
   ========================================================= */

.heritage-book-chapter-rule {
  display: flex;
  align-items: center;
  justify-content: center;

  gap: 13px;

  margin: 4px 0 18px;

  color: #8b7557;

  font-family:
    "Libre Baskerville",
    serif;

  font-size: .69rem;
  font-weight: 700;
  letter-spacing: .14em;
}

.heritage-book-chapter-rule::before,
.heritage-book-chapter-rule::after {
  content: "";

  width: 72px;
  height: 1px;

  background:
    linear-gradient(
      90deg,
      transparent,
      #bba886
    );
}

.heritage-book-chapter-rule::after {
  transform: scaleX(-1);
}

.heritage-book-editorial-title {
  margin: 0 0 19px;
  padding-bottom: 13px;

  border-bottom:
    1px solid
    rgba(139,113,77,.24);

  color: var(--book-navy);

  font-family:
    "Libre Baskerville",
    serif;

  font-size:
    clamp(
      2.05rem,
      2.65vw,
      2.95rem
    );

  line-height: 1.06;
  font-weight: 700;
  letter-spacing: -.04em;
}

.heritage-book-long-copy {
  max-height: 505px;

  overflow-y: auto;

  padding-right: 12px;

  color: #536e88;

  font-family:
    "Libre Baskerville",
    serif;

  font-size: .91rem;
  line-height: 1.82;

  scrollbar-width: thin;
  scrollbar-color:
    #d2c4ad transparent;
}

.heritage-book-long-copy p {
  margin: 0 0 18px;
}

.heritage-book-long-copy p:first-child::first-letter {
  float: left;

  margin:
    7px 9px 0 0;

  color: #315a78;

  font-size: 3.75rem;
  line-height: .76;
  font-weight: 700;
}


/* Página visual que acompanha capítulos depois do primeiro. */
.heritage-book-visual-grid {
  display: grid;

  grid-template-columns:
    1.08fr .92fr;

  grid-template-rows:
    1fr 1fr;

  gap: 16px;

  height: 100%;
}

.heritage-book-visual-grid figure {
  position: relative;
  overflow: hidden;

  margin: 0;
  padding: 6px;

  border:
    1px solid
    #d6c7b2;

  border-radius: 3px;

  background: #fffaf2;

  box-shadow:
    0 7px 15px
    rgba(73,57,36,.10);
}

.heritage-book-visual-grid figure:first-child {
  grid-row: 1 / 3;

  transform:
    rotate(-.13deg);
}

.heritage-book-visual-grid figure:nth-child(2) {
  transform:
    rotate(.15deg);
}

.heritage-book-visual-grid figure:nth-child(3) {
  transform:
    rotate(-.15deg);
}

.heritage-book-visual-single {
  position: relative;
  overflow: hidden;

  height: 100%;

  margin: 0;
  padding: 7px;

  border:
    1px solid
    #d3c4ad;

  border-radius: 3px;

  background: #fffaf1;

  box-shadow:
    0 8px 18px
    rgba(73,58,37,.11);

  transform:
    rotate(-.09deg);
}


/* =========================================================
   LINHA CRONOLÓGICA — ONDA CONTÍNUA NO SPREAD
   ========================================================= */

.heritage-book-timeline-page {
  position: relative;

  height: 100%;
}

.heritage-book-timeline-title {
  margin: 1px 0 7px;

  color: var(--book-navy);

  font-family:
    "Libre Baskerville",
    serif;

  font-size:
    clamp(
      1.75rem,
      2.2vw,
      2.35rem
    );

  font-weight: 700;
  letter-spacing: -.035em;
}

.heritage-book-timeline-subtitle {
  margin: 0;

  color: #6b8093;

  font-family:
    "Libre Baskerville",
    serif;

  font-size: .75rem;
  line-height: 1.5;
}

.heritage-book-timeline-canvas {
  position: relative;

  height: 475px;

  margin-top: 15px;
}

.heritage-book-timeline-canvas svg {
  position: absolute;
  inset: 0;

  width: 100%;
  height: 100%;

  overflow: visible;
}

.heritage-book-timeline-wave-shadow {
  fill: none;

  stroke: rgba(25,118,174,.09);
  stroke-width: 14;
  stroke-linecap: round;
}

.heritage-book-timeline-wave-line {
  fill: none;

  stroke-width: 6;
  stroke-linecap: round;
}

.heritage-book-timeline-event {
  position: absolute;

  width: 168px;

  transform:
    translateX(-50%);

  text-align: center;

  font-family:
    "Libre Baskerville",
    serif;
}

.heritage-book-timeline-event::before {
  content: "";

  position: absolute;

  top: var(--dot-y);
  left: 50%;

  width: 16px;
  height: 16px;

  border: 4px solid #fffdfa;
  border-radius: 50%;

  background: var(--book-blue);

  box-shadow:
    0 0 0 2px
    rgba(22,132,197,.20);

  transform:
    translate(-50%, -50%);
}

.heritage-book-timeline-event.is-current::before {
  background: var(--book-green);

  box-shadow:
    0 0 0 2px
    rgba(57,162,99,.20);
}

.heritage-book-timeline-event-copy {
  position: absolute;

  left: 50%;

  width: 168px;

  transform:
    translateX(-50%);
}

.heritage-book-timeline-event.is-above
.heritage-book-timeline-event-copy {
  bottom:
    calc(
      475px -
      var(--dot-y) +
      18px
    );
}

.heritage-book-timeline-event.is-below
.heritage-book-timeline-event-copy {
  top:
    calc(
      var(--dot-y) +
      19px
    );
}

.heritage-book-timeline-event strong {
  display: block;

  margin-bottom: 4px;

  color: #176da8;

  font-size: .71rem;
}

.heritage-book-timeline-event.is-current strong {
  color: #2f9457;
}

.heritage-book-timeline-event span {
  display: block;

  margin-bottom: 4px;

  color: #344e66;

  font-size: .65rem;
  font-weight: 700;
}

.heritage-book-timeline-event p {
  margin: 0;

  color: #738291;

  font-size: .58rem;
  line-height: 1.42;
}


/* =========================================================
   GALERIA FINAL
   ========================================================= */

.heritage-book-gallery-intro {
  margin:
    -4px 0 17px;

  color: #667d92;

  font-family:
    "Libre Baskerville",
    serif;

  font-size: .78rem;
  line-height: 1.55;
}

.heritage-book-gallery-grid {
  display: grid;

  grid-template-columns:
    1.16fr .84fr;

  grid-template-rows:
    repeat(2, 1fr);

  gap: 12px;

  height: 470px;
}

.heritage-book-gallery-grid figure {
  position: relative;
  overflow: hidden;

  margin: 0;
  padding: 5px;

  border:
    1px solid
    #d6c7b2;

  border-radius: 3px;

  background: #fffaf2;

  box-shadow:
    0 6px 13px
    rgba(73,57,36,.09);
}

.heritage-book-gallery-grid figure:first-child {
  grid-row:
    1 / 3;
}

.heritage-book-endpaper {
  display: grid;
  place-items: center;

  height: 100%;

  color: #a99980;

  font-family:
    "Libre Baskerville",
    serif;

  font-size: .72rem;
  font-style: italic;
}


/* =========================================================
   TRANSIÇÃO ENTRE PATRIMÓNIOS
   ========================================================= */

.heritage-book-stage.is-changing
.heritage-flip-book {
  filter:
    drop-shadow(
      0 22px 24px
      rgba(21,44,61,.19)
    );
}

.heritage-book-stage.is-changing::after {
  content: "";

  position: absolute;
  z-index: 5;

  left: 50%;
  bottom: 5px;

  width: min(76%, 980px);
  height: 34px;

  border-radius: 50%;

  background:
    radial-gradient(
      ellipse at center,
      rgba(21,42,57,.18),
      transparent 68%
    );

  transform:
    translateX(-50%);

  pointer-events: none;
}


/* =========================================================
   FALLBACK / DETALHE ANTIGO
   ========================================================= */

.heritage-flip-book.no-pageflip {
  display: grid;

  grid-template-columns:
    repeat(
      2,
      minmax(0, 1fr)
    );

  gap: 1px;

  max-height: 700px;
  overflow-y: auto;
}

.heritage-detail--legacy-book-replaced {
  display: none !important;
}


/* =========================================================
   RESPONSIVO
   ========================================================= */

@media (max-width: 1100px) {
  .heritage-book-stage {
    min-height: 730px;
  }
}

@media (max-width: 820px) {
  .heritage-book-stage {
    min-height: 720px;

    padding:
      14px 2px 22px;
  }

  .heritage-history-page-content {
    padding:
      59px 28px 54px;
  }

  .heritage-history-running-head {
    left: 26px;
    right: 26px;
  }

  .heritage-book-opening-photo {
    height: 435px;
  }

  .heritage-cover-inner {
    padding:
      58px 38px 48px;
  }
}

@media (max-width: 540px) {
  .heritage-book-place-name {
    font-size: 1.85rem;
  }

  .heritage-book-opening-photo {
    height: 390px;
  }

  .heritage-book-visual-grid {
    grid-template-columns:
      1fr 1fr;

    grid-template-rows:
      285px 175px;
  }

  .heritage-book-visual-grid figure:first-child {
    grid-column:
      1 / -1;

    grid-row:
      auto;
  }

  .heritage-book-gallery-grid {
    height: 430px;
  }

  .heritage-cover-title {
    font-size: 1.8rem;
  }
}

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


/* =========================================================
   V8 — LARGURA, LIVRO FECHADO CENTRADO E ABERTURA
   ========================================================= */

/*
 * Um pouco mais de largura sem alterar a linguagem visual
 * da capa nem das folhas.
 */
.heritage-book-stage {
  min-height: 770px;
  padding-inline: 4px;
}

/*
 * O próprio PageFlip desloca-se suavemente.
 * Quando está fechado, a página de capa (que o StPageFlip
 * coloca na metade direita do spread) é trazida para o centro.
 */
.heritage-flip-book {
  min-height: 720px;

  transform: translateX(0);

  transition:
    transform 1050ms
    cubic-bezier(.22,.61,.36,1);
}

.heritage-book-stage.is-closed
.heritage-flip-book {
  transform: translateX(-25%);
}

/*
 * O fundo azul que representa a capa traseira / base do livro
 * desaparece completamente quando o livro está fechado.
 * Assim não existe "uma capa do lado esquerdo".
 */
.heritage-book-base {
  opacity: 1;

  transform:
    scaleX(1);

  transform-origin:
    center center;

  transition:
    opacity 320ms ease 210ms,
    transform 1050ms
    cubic-bezier(.22,.61,.36,1);
}

.heritage-book-stage.is-closed
.heritage-book-base {
  opacity: 0;

  transform:
    scaleX(.50);

  transition:
    opacity 180ms ease,
    transform 1050ms
    cubic-bezier(.22,.61,.36,1);
}

/* Sombra de um livro fechado, apenas debaixo da capa central. */
.heritage-book-stage.is-closed::after {
  content: "";

  position: absolute;
  z-index: 1;

  left: 50%;
  bottom: 18px;

  width: min(44%, 620px);
  height: 38px;

  border-radius: 50%;

  background:
    radial-gradient(
      ellipse at center,
      rgba(13, 39, 58, .24),
      rgba(13, 39, 58, .08) 46%,
      transparent 72%
    );

  transform:
    translateX(-50%);

  pointer-events: none;
}

/* Cursor que comunica que a capa pode ser aberta. */
.heritage-book-stage.is-closed
.heritage-book-cover-page {
  cursor: pointer;
}


/* =========================================================
   V8 — BRASÃO REAL
   ========================================================= */

.heritage-cover-crest-medallion {
  width: 142px;
  height: 154px;

  background:
    radial-gradient(
      circle at 50% 38%,
      rgba(255,255,255,.085),
      rgba(255,255,255,.018) 52%,
      rgba(0,0,0,.055)
    );
}

.heritage-cover-crest-window {
  width: 116px;
  height: 128px;

  overflow: visible;
}

.heritage-cover-crest {
  max-width: 112px;
  max-height: 124px;

  filter:
    drop-shadow(
      0 5px 6px
      rgba(0,0,0,.14)
    );
}


/* =========================================================
   V8 — LINHA HISTÓRICA MAIS PRÓXIMA DA REFERÊNCIA
   ========================================================= */

.heritage-book-timeline-page {
  position: relative;

  height: 100%;
}

.heritage-book-timeline-heading {
  height: 72px;
}

.heritage-book-timeline-title {
  margin: 0 0 3px;

  color: #122d55;

  font-family:
    "Libre Baskerville",
    serif;

  font-size:
    clamp(
      1.85rem,
      2.45vw,
      2.65rem
    );

  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -.04em;
}

.heritage-book-timeline-subtitle {
  margin: 0;

  color: #61789c;

  font-family:
    "Montserrat",
    sans-serif;

  font-size: .72rem;
  line-height: 1.45;
}

.heritage-book-timeline-canvas {
  position: relative;

  height: 475px;

  margin-top: 2px;

  overflow: hidden;
}

.heritage-book-timeline-canvas svg {
  position: absolute;
  inset: 0;

  width: 100%;
  height: 100%;

  overflow: hidden;
}

/* Ondas suaves de fundo */
.heritage-book-timeline-bg-wave {
  pointer-events: none;
}

.heritage-book-timeline-bg-wave--1 {
  fill: rgba(208, 233, 249, .43);
}

.heritage-book-timeline-bg-wave--2 {
  fill: rgba(220, 240, 252, .53);
}

.heritage-book-timeline-bg-wave--3 {
  fill: rgba(232, 245, 253, .72);
}

/* Pequena silhueta paisagística no fundo, sobretudo no lado direito */
.heritage-book-timeline-silhouette {
  fill: rgba(144, 196, 231, .20);
}

/* Linha principal — azul para verde como na referência. */
.heritage-book-timeline-wave-shadow {
  fill: none;

  stroke:
    rgba(28, 143, 203, .09);

  stroke-width: 13;
  stroke-linecap: round;
}

.heritage-book-timeline-wave-line {
  fill: none;

  stroke-width: 5.5;
  stroke-linecap: round;
}

.heritage-book-timeline-event {
  position: absolute;

  top: 0;
  bottom: 0;

  width: 176px;

  transform:
    translateX(-50%);

  text-align: center;

  font-family:
    "Montserrat",
    sans-serif;
}

.heritage-book-timeline-event::before {
  content: "";

  position: absolute;

  top: var(--dot-y);
  left: 50%;

  width: 17px;
  height: 17px;

  border:
    4px solid
    #fffdfa;

  border-radius: 50%;

  background:
    #1684c5;

  box-shadow:
    0 0 0 2px
    rgba(22,132,197,.25),
    0 5px 11px
    rgba(17,95,145,.13);

  transform:
    translate(-50%, -50%);
}

.heritage-book-timeline-event::after {
  content: "";

  position: absolute;

  left: 50%;

  width: 1px;
  height: 22px;

  border-left:
    1px dashed
    rgba(22,132,197,.52);

  transform:
    translateX(-50%);
}

.heritage-book-timeline-event.is-above::after {
  top:
    calc(
      var(--dot-y) -
      27px
    );
}

.heritage-book-timeline-event.is-below::after {
  top:
    calc(
      var(--dot-y) +
      6px
    );
}

.heritage-book-timeline-event.is-current::before {
  background:
    #00ad67;

  box-shadow:
    0 0 0 2px
    rgba(0,173,103,.24),
    0 5px 11px
    rgba(0,110,70,.13);
}

.heritage-book-timeline-event.is-current::after {
  border-left-color:
    rgba(0,173,103,.52);
}

.heritage-book-timeline-event-copy {
  position: absolute;

  top: var(--copy-y);
  left: 50%;

  width: 176px;

  transform:
    translateX(-50%);
}

.heritage-book-timeline-event strong {
  display: block;

  margin-bottom: 4px;

  color: #0874dd;

  font-size: .80rem;
  font-weight: 800;
}

.heritage-book-timeline-event.is-current strong {
  color: #04a75f;
}

.heritage-book-timeline-event span {
  display: block;

  margin-bottom: 4px;

  color: #101c61;

  font-size: .68rem;
  font-weight: 800;
}

.heritage-book-timeline-event p {
  margin: 0;

  color: #5d70a0;

  font-size: .61rem;
  line-height: 1.42;
}


/* =========================================================
   V8 — MOBILE
   O PageFlip já muda para portrait; neste modo não precisamos
   de deslocar meia página para centrar a capa.
   ========================================================= */

@media (max-width: 820px) {
  .heritage-book-stage.is-closed
  .heritage-flip-book {
    transform: none;
  }

  .heritage-book-stage {
    min-height: 735px;
  }

  .heritage-flip-book {
    min-height: 700px;
  }

  .heritage-book-stage.is-closed::after {
    width: min(72%, 520px);
  }

  .heritage-book-timeline-event {
    width: 142px;
  }

  .heritage-book-timeline-event-copy {
    width: 142px;
  }
}


/* =========================================================
   V9 — AJUSTES APROVADOS
   ========================================================= */

/* ---------------------------------------------------------
   CAPA: cantos rectangulares
   --------------------------------------------------------- */

.heritage-book-cover-page,
.heritage-book-back-cover {
  border-radius: 0 !important;
}

.heritage-book-cover-page::before,
.heritage-book-cover-page::after {
  border-radius: 0 !important;
}

/*
 * Quando o livro está aberto, a base azul acompanha
 * praticamente o tamanho exato do spread.
 * Como o livro tem 720 x 700 por folha, o spread é 1440:700.
 */
.heritage-book-base {
  top: 23px;
  right: auto;
  bottom: auto;
  left: 50%;

  width: calc(100% - 18px);
  max-width: 1450px;
  height: auto;
  aspect-ratio: 1440 / 700;

  border-radius: 0 !important;

  transform:
    translateX(-50%);

  transform-origin:
    center center;
}

.heritage-book-base::before {
  inset: 7px;

  border-radius: 0 !important;
}

/*
 * A lombada continua subtil, mas já não cria
 * um bloco excessivo por baixo das folhas.
 */
.heritage-book-base::after {
  top: 8px;
  bottom: 8px;

  width: 24px;
}

/*
 * No estado fechado a base continua totalmente escondida.
 * Mantemos apenas a capa frontal centrada.
 */
.heritage-book-stage.is-closed
.heritage-book-base {
  opacity: 0;

  transform:
    translateX(-50%)
    scaleX(.50);
}


/* ---------------------------------------------------------
   CAPA: distribuição vertical + brasão maior e sem medalhão
   --------------------------------------------------------- */

.heritage-cover-inner {
  justify-content: flex-start;

  padding:
    62px 72px 54px;
}

.heritage-cover-kicker {
  margin-bottom: 20px;
}

.heritage-cover-ornament {
  margin-bottom: 31px;
}

.heritage-cover-title {
  max-width: 520px;

  margin:
    0 auto 38px;
}

/* Remove completamente a moldura/círculo em torno do brasão. */
.heritage-cover-crest-medallion {
  display: grid;
  place-items: center;

  width: 205px;
  height: 210px;

  margin:
    0 auto 31px;

  border: 0 !important;
  border-radius: 0 !important;

  background: none !important;

  box-shadow: none !important;
}

.heritage-cover-crest-window {
  width: 195px;
  height: 205px;

  overflow: visible;
}

.heritage-cover-crest {
  width: auto;
  height: auto;

  max-width: 190px;
  max-height: 202px;

  object-fit: contain;

  filter:
    drop-shadow(
      0 7px 8px
      rgba(0,0,0,.15)
    );
}

.heritage-cover-junta {
  margin-top: auto;
}

.heritage-cover-footer-line {
  margin-top: 23px;
}


/* ---------------------------------------------------------
   LIVRO: um pouco mais largo
   --------------------------------------------------------- */

.heritage-book-stage {
  min-height: 770px;
}

.heritage-flip-book {
  min-height: 700px;
}


/* ---------------------------------------------------------
   LINHA HISTÓRICA
   - nunca coloca texto junto à dobra central
   - até 6 acontecimentos por spread
   - spreads adicionais quando necessário
   --------------------------------------------------------- */

.heritage-book-timeline-canvas {
  overflow: hidden;
}

.heritage-book-timeline-event {
  width: 166px;
}

.heritage-book-timeline-event-copy {
  width: 166px;
}

/* Etiquetas ligeiramente mais compactas para respirarem melhor. */
.heritage-book-timeline-event strong {
  font-size: .78rem;
}

.heritage-book-timeline-event span {
  font-size: .66rem;
}

.heritage-book-timeline-event p {
  font-size: .59rem;
}


/* ---------------------------------------------------------
   MOBILE
   --------------------------------------------------------- */

@media (max-width: 820px) {
  .heritage-book-base {
    width: calc(100% - 8px);
    max-width: 720px;

    aspect-ratio: 720 / 700;
  }

  .heritage-cover-inner {
    padding:
      50px 34px 45px;
  }

  .heritage-cover-crest-medallion {
    width: 170px;
    height: 177px;

    margin-bottom: 25px;
  }

  .heritage-cover-crest-window {
    width: 162px;
    height: 172px;
  }

  .heritage-cover-crest {
    max-width: 158px;
    max-height: 168px;
  }
}


/* =========================================================
   V10 — ENQUADRAMENTO FINAL DA CAPA
   ========================================================= */

/*
 * O movimento centro <-> spread passa para um wrapper próprio.
 * Assim não entra em conflito com transforms internos do PageFlip.
 */
.heritage-book-motion {
  position: relative;

  width: 100%;
  min-height: 720px;

  margin: 0 auto;

  transform: translateX(0);

  transition:
    transform 1050ms
    cubic-bezier(.22,.61,.36,1);
}

/*
 * No desktop, a capa frontal ocupa a metade direita do spread
 * quando o PageFlip está fechado. Deslocamos o conjunto 25%
 * para a esquerda para essa única capa ficar exatamente ao centro.
 */
.heritage-book-stage.is-closed
.heritage-book-motion {
  transform: translateX(-25%);
}

/*
 * O PageFlip deixa de receber o translate diretamente.
 * Isto corrige o caso em que o transform interno da biblioteca
 * anulava o nosso centramento.
 */
.heritage-flip-book,
.heritage-book-stage.is-closed
.heritage-flip-book {
  transform: none !important;

  transition: none !important;
}


/* ---------------------------------------------------------
   CAPA AZUL VISÍVEL POR BAIXO DO LIVRO ABERTO
   --------------------------------------------------------- */

/*
 * A base fica ligeiramente maior que as folhas:
 * ~11px de cada lado e ~8px em cima/baixo.
 *
 * É suficiente para se perceber a capa sem voltar a criar
 * aquele rectângulo azul demasiado grande.
 */
.heritage-book-base {
  top: -8px;
  right: auto;
  bottom: auto;
  left: 50%;

  width: calc(100% + 22px);
  max-width: 1462px;

  height: 716px;

  opacity: 1;
  visibility: visible;

  transform:
    translateX(-50%)
    scaleX(1);

  border-radius: 0 !important;

  transition:
    opacity 210ms ease 170ms,
    visibility 0s linear 0s;
}

/*
 * Filete interior da capa aberta.
 */
.heritage-book-base::before {
  inset: 8px;

  border-radius: 0 !important;
}

/*
 * Lombada discreta.
 */
.heritage-book-base::after {
  top: 8px;
  bottom: 8px;

  width: 24px;
}


/* ---------------------------------------------------------
   LIVRO FECHADO = UMA ÚNICA CAPA
   --------------------------------------------------------- */

/*
 * A base aberta é removida por completo assim que iniciamos
 * o fecho. Não fica qualquer rectângulo azul à esquerda.
 */
.heritage-book-stage.is-closed
.heritage-book-base {
  opacity: 0 !important;
  visibility: hidden !important;

  transform:
    translateX(-50%)
    scaleX(.50);

  transition:
    opacity 100ms ease,
    visibility 0s linear 110ms;
}

/*
 * Também durante a animação programática de fecho,
 * a base desaparece para o utilizador ver apenas a capa
 * que está fisicamente a rodar.
 */
.heritage-book-stage.is-closing
.heritage-book-base {
  opacity: 0 !important;
  visibility: hidden !important;
}

/*
 * A sombra do livro fechado acompanha a capa central,
 * não o spread completo.
 */
.heritage-book-stage.is-closed::after {
  left: 50%;

  width: min(45%, 650px);

  transform:
    translateX(-50%);
}


/* ---------------------------------------------------------
   MOBILE
   Portrait já é uma única página, portanto não deslocamos.
   --------------------------------------------------------- */

@media (max-width: 820px) {
  .heritage-book-stage.is-closed
  .heritage-book-motion {
    transform: none;
  }

  .heritage-book-base {
    width: calc(100% + 12px);
    max-width: 732px;

    height: 708px;
  }
}


/* =========================================================
   V14 — CORREÇÃO PRECISA A PARTIR DA V10
   ========================================================= */

/* ---------------------------------------------------------
   MOVIMENTO DO LIVRO
   --------------------------------------------------------- */

/*
 * O valor --book-shift-x é calculado em JavaScript usando
 * a posição REAL da capa visível.
 * Nada de -25%, nada de adivinhar esquerda/direita.
 */
.heritage-book-motion {
  transform:
    translateX(
      var(--book-shift-x, 0px)
    ) !important;

  transition:
    transform 1050ms
    cubic-bezier(.22,.61,.36,1) !important;
}

/*
 * Neutraliza os antigos deslocamentos percentuais da V10.
 * Quem manda agora é sempre --book-shift-x.
 */
.heritage-book-stage.is-closed
.heritage-book-motion,
.heritage-book-stage.is-closing
.heritage-book-motion,
.heritage-book-stage.is-open
.heritage-book-motion {
  transform:
    translateX(
      var(--book-shift-x, 0px)
    ) !important;
}

.heritage-flip-book,
.heritage-book-stage.is-closed
.heritage-flip-book {
  transform: none !important;
  transition: none !important;
}


/* ---------------------------------------------------------
   CAPA AZUL POR BAIXO DAS PÁGINAS
   --------------------------------------------------------- */

/*
 * Estas variáveis são obtidas a partir do rectângulo combinado
 * das páginas REALMENTE visíveis no momento.
 * Assim a capa fica 9px maior em todos os lados — nem mais,
 * nem menos — mesmo no último spread.
 */
.heritage-book-base {
  position: absolute !important;
  z-index: 0 !important;

  top:
    var(--book-base-top, 0px) !important;

  left:
    var(--book-base-left, 0px) !important;

  right: auto !important;
  bottom: auto !important;

  width:
    var(--book-base-width, 0px) !important;

  height:
    var(--book-base-height, 0px) !important;

  max-width: none !important;
  aspect-ratio: auto !important;

  transform: none !important;

  border-radius: 0 !important;

  opacity: 0;
  visibility: hidden;

  transition:
    opacity 150ms ease;
}

.heritage-book-base::before {
  inset: 7px !important;
  border-radius: 0 !important;
}

.heritage-book-base::after {
  top: 7px !important;
  bottom: 7px !important;
  width: 22px !important;
}

/* Apenas quando o spread está aberto. */
.heritage-book-stage.is-open
.heritage-book-base {
  opacity: 1 !important;
  visibility: visible !important;
}

/* Fechado ou a fechar: fica apenas a capa frontal real. */
.heritage-book-stage.is-closed
.heritage-book-base,
.heritage-book-stage.is-closing
.heritage-book-base {
  opacity: 0 !important;
  visibility: hidden !important;
}

/*
 * A sombra artificial antiga deixa de ser necessária;
 * a própria capa real do PageFlip já tem profundidade.
 */
.heritage-book-stage.is-closed::after {
  display: none !important;
}


/* ---------------------------------------------------------
   MOBILE
   --------------------------------------------------------- */

@media (max-width: 820px) {
  /*
   * Em portrait o próprio PageFlip já apresenta uma única página.
   * O JS deteta essa situação e usa shift 0.
   */
  .heritage-book-motion {
    transition:
      transform 850ms
      cubic-bezier(.22,.61,.36,1) !important;
  }
}


/* =========================================================
   V16 — AJUSTES SOBRE A V14
   ========================================================= */

/* Primeira página: a imagem usa apenas a altura restante. */
.heritage-book-opening {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.heritage-book-place-name { flex: 0 0 auto; }
.heritage-book-opening-photo {
  flex: 1 1 auto;
  min-height: 0;
  height: auto !important;
  margin-bottom: 0;
}

/* Evitar scrollbars temporárias da curvatura 3D. */
.heritage-book-section,
.heritage-book-stage {
  overflow: clip;
  overflow-clip-margin: 64px;
}

/* Contracapa com o mesmo acabamento da capa frontal, mas sem conteúdo. */
.heritage-book-back-cover {
  position: relative;
  overflow: hidden;
  border-radius: 0 !important;
  background:
    radial-gradient(ellipse at 50% 26%, rgba(255,255,255,.055), transparent 34%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.016) 0 1px, rgba(0,0,0,.018) 1px 3px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.012) 0 1px, transparent 1px 4px),
    linear-gradient(145deg, #174d7a 0%, var(--book-cover) 36%, var(--book-cover-deep) 100%) !important;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.08),
    inset 0 -18px 36px rgba(0,0,0,.16),
    0 24px 34px rgba(18,44,63,.18) !important;
}
.heritage-book-back-cover::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 18px;
  border: 1px solid rgba(210,180,109,.72);
  box-shadow: 0 0 0 5px rgba(200,170,100,.07), inset 0 0 0 1px rgba(236,215,158,.12);
  pointer-events: none;
}
.heritage-book-back-cover::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 28px;
  border: 1px solid rgba(217,190,127,.23);
  pointer-events: none;
}

/* No último estado fica apenas a contracapa, sem base azul por trás. */
.heritage-book-stage.is-back-cover .heritage-book-base {
  opacity: 0 !important;
  visibility: hidden !important;
}
.heritage-book-stage.is-back-cover .heritage-book-back-cover {
  filter: drop-shadow(0 22px 25px rgba(21,45,63,.22));
}
.heritage-book-stage.is-back-cover::after { display: none !important; }


/* =========================================================
   V17 — AJUSTES FINAIS
   ========================================================= */

/* A base azul não aparece durante a rotação da capa. */
.heritage-book-stage.is-opening .heritage-book-base,
.heritage-book-stage.is-closing .heritage-book-base {
  opacity: 0 !important;
  visibility: hidden !important;
}

/* Só aparece depois de o spread assentar. */
.heritage-book-stage.is-open:not(.is-opening):not(.is-closing):not(.is-back-cover)
.heritage-book-base {
  opacity: 1 !important;
  visibility: visible !important;
}

/* Galeria: ocupar apenas a altura disponível na folha. */
.heritage-book-gallery-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.heritage-book-gallery-page .heritage-book-editorial-title,
.heritage-book-gallery-page .heritage-book-gallery-intro {
  flex: 0 0 auto;
}

.heritage-book-gallery-grid {
  flex: 1 1 auto;
  min-height: 0;
  height: auto !important;
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
}

.heritage-book-gallery-grid figure {
  min-width: 0;
  min-height: 0;
}

.heritage-book-gallery-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}


/* =========================================================
   V18 — FECHO ESPELHA A ABERTURA
   ========================================================= */

/*
 * Durante o fecho o livro continua a ser tratado como ABERTO.
 * Só passa a .is-closed depois de a capa acabar de rodar.
 * Isto impede estilos de capa fechada de aparecerem a meio da animação.
 */
.heritage-book-stage.is-closing::after {
  display: none !important;
}

.heritage-book-stage.is-closing
.heritage-book-base {
  opacity: 0 !important;
  visibility: hidden !important;
}


/* =========================================================
   V22 — FECHO LIMPO + TÍTULOS CENTRADOS
   Base direta: V18
   ========================================================= */

/*
 * Caso que faltava:
 * quando o utilizador fecha manualmente com seta/clique/swipe,
 * closeBook() não é chamado.
 *
 * Durante qualquer transição junto à capa frontal escondemos
 * APENAS a base azul traseira. Não escondemos páginas, capas,
 * nem criamos uma segunda capa.
 */
.heritage-book-stage.is-front-edge-transition
.heritage-book-base {
  opacity: 0 !important;
  visibility: hidden !important;
}

/*
 * Também não mostramos a sombra larga do spread durante essa
 * transição, para não parecer existir outra capa por baixo.
 */
.heritage-book-stage.is-front-edge-transition::after {
  display: none !important;
}


/* ---------------------------------------------------------
   TÍTULOS CENTRADOS
   --------------------------------------------------------- */

.heritage-book-place-name,
.heritage-book-editorial-title,
.heritage-book-timeline-title {
  text-align: center !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

.heritage-book-timeline-subtitle,
.heritage-book-gallery-intro {
  text-align: center !important;
}

/*
 * Retira a linha horizontal imediatamente por baixo do título.
 * Mantemos as restantes linhas editoriais do livro.
 */
.heritage-book-editorial-title {
  border-bottom: 0 !important;
  padding-bottom: 0 !important;
}


/* =========================================================
   V24 — FECHO DA CAPA FRONTAL
   ========================================================= */

/*
 * Classe apenas de diagnóstico/estado.
 * O esconder efetivo da base é feito por inline style !important
 * em JavaScript, para não depender da especificidade do CSS.
 */
.heritage-book-stage.is-exact-front-closing::after {
  display: none !important;
}

/*
 * Mantemos títulos centrados e sem a linha inferior,
 * como já estava aprovado na V22.
 */
.heritage-book-place-name,
.heritage-book-editorial-title,
.heritage-book-timeline-title {
  text-align: center !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

.heritage-book-timeline-subtitle,
.heritage-book-gallery-intro {
  text-align: center !important;
}

.heritage-book-editorial-title {
  border-bottom: 0 !important;
  padding-bottom: 0 !important;
}


/* =========================================================
   V25 — MESMA CORREÇÃO DA CAPA, AGORA NA CONTRACAPA
   ========================================================= */

/*
 * Estado usado apenas enquanto a contracapa está a fechar.
 * A base azul é escondida por inline style !important no JS;
 * aqui removemos apenas a sombra larga do spread.
 */
.heritage-book-stage.is-exact-back-closing::after {
  display: none !important;
}


/* =========================================================
   V26 — ESTABILIZAÇÃO DO FECHO DAS CAPAS
   ========================================================= */

/*
 * A base fica bloqueada como invisível durante TODO o fecho
 * e permanece assim no estado final fechado.
 * O JS só liberta este bloqueio quando o utilizador volta a abrir.
 */
.heritage-book-stage.is-hard-cover-locked
.heritage-book-base {
  opacity: 0 !important;
  visibility: hidden !important;
}

.heritage-book-stage.is-hard-cover-locked::after {
  display: none !important;
}


/* V27 — a contracapa mantém o estado até o spread interior assentar. */


/* =========================================================
   V28 — POSIÇÃO FIXA DO BRASÃO NA CAPA
   ========================================================= */

/*
 * O nome do património passa a ter uma área vertical reservada.
 * Assim, tenha uma, duas ou três linhas, o brasão começa sempre
 * exatamente na mesma posição da capa.
 */
.heritage-cover-title {
  display: flex !important;
  align-items: center;
  justify-content: center;

  width: 100%;
  max-width: 520px;

  height: 138px;
  min-height: 138px;
  max-height: 138px;

  margin: 0 auto 24px !important;

  overflow: hidden;

  text-align: center;
}

/*
 * O brasão e tudo o que vem abaixo deixam de depender da altura
 * real ocupada pelo título.
 */
.heritage-cover-crest-medallion {
  flex: 0 0 205px;

  width: 205px;
  height: 205px;

  margin: 0 auto 31px;
}

.heritage-cover-junta {
  flex: 0 0 auto;
  margin-top: auto;
}

/*
 * Nomes um pouco maiores continuam a caber melhor dentro do espaço
 * reservado sem deslocar o brasão.
 */
.heritage-cover-title {
  line-height: 1.08;
}

@media (max-width: 820px) {
  .heritage-cover-title {
    height: 118px;
    min-height: 118px;
    max-height: 118px;

    margin-bottom: 20px !important;
  }

  .heritage-cover-crest-medallion {
    flex-basis: 170px;

    width: 170px;
    height: 170px;
  }
}


/* =========================================================
   V29 — IMAGENS INTELIGENTES + GALERIA AUTOMÁTICA
   ========================================================= */

/*
 * Quando uma fotografia tem uma proporção muito diferente da moldura,
 * o JS muda automaticamente de cover para contain.
 */
.heritage-book-smart-image.is-contain {
  object-fit: contain !important;
}

.heritage-book-smart-image.is-cover {
  object-fit: cover !important;
}

/* Fundo discreto quando usamos contain. */
figure:has(.heritage-book-smart-image.is-contain),
.heritage-book-opening-photo:has(.heritage-book-smart-image.is-contain) {
  background:
    linear-gradient(
      135deg,
      #fbf7ef,
      #f3ecdf
    );
}

/*
 * Galeria final:
 * cada página recebe até três fotografias,
 * mantendo a composição 1 grande + 2 pequenas.
 */
.heritage-book-gallery-page {
  display: flex;
  flex-direction: column;

  height: 100%;
  min-height: 0;
}

.heritage-book-gallery-grid {
  flex: 1 1 auto;

  min-height: 0;
  height: auto !important;
}

.heritage-book-gallery-count {
  margin:
    -8px 0 12px;

  color: #9a8a73;

  font-family:
    "Libre Baskerville",
    serif;

  font-size: .58rem;
  font-style: italic;

  text-align: center;
}

/* Uma única fotografia na página da galeria ocupa a área disponível. */
.heritage-book-gallery-grid.has-one {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

.heritage-book-gallery-grid.has-one figure:first-child {
  grid-column: 1;
  grid-row: 1;
}

/* Duas fotografias dividem a página de forma equilibrada. */
.heritage-book-gallery-grid.has-two {
  grid-template-columns:
    repeat(2, minmax(0, 1fr));

  grid-template-rows: 1fr;
}

.heritage-book-gallery-grid.has-two figure:first-child,
.heritage-book-gallery-grid.has-two figure:nth-child(2) {
  grid-row: 1;
}


/* =========================================================
   V30 — VOLTAR AO ENQUADRAMENTO ORIGINAL DAS FOTOGRAFIAS
   ========================================================= */

/*
 * Voltamos ao comportamento visual anterior:
 * as fotografias preenchem totalmente a moldura.
 */
.heritage-book-opening-photo img,
.heritage-book-visual-grid img,
.heritage-book-gallery-grid img,
.heritage-book-smart-image,
.heritage-book-smart-image.is-cover,
.heritage-book-smart-image.is-contain {
  width: 100%;
  height: 100%;

  object-fit: cover !important;
}

/*
 * Mesmo que uma fotografia falhe ou ainda não exista,
 * a moldura mantém-se no mesmo sítio e mostra o placeholder.
 */
.heritage-book-visual-grid figure {
  min-width: 0;
  min-height: 0;
}

.heritage-book-visual-grid figure.heritage-book-is-missing,
.heritage-book-visual-grid figure.is-empty-image-slot {
  display: block;
}

.heritage-book-visual-grid figure.is-empty-image-slot
.heritage-book-image-fallback {
  display: grid;
}

/* Neutraliza o fundo especial introduzido para o modo contain da V29. */
figure:has(.heritage-book-smart-image.is-contain),
.heritage-book-opening-photo:has(.heritage-book-smart-image.is-contain) {
  background: #fffaf2;
}


/* =========================================================
   GALERIA — SEM DESCRIÇÃO NEM CONTADOR
   ========================================================= */

/*
 * Mantém apenas o título "Galeria fotográfica" na primeira página.
 * A descrição e o contador (Galeria 1/2, 2/2, ...) deixam de aparecer
 * em todas as páginas da galeria, libertando esse espaço para as imagens.
 */
.heritage-book-gallery-intro,
.heritage-book-gallery-count {
  display: none !important;
}


/* =========================================================
   V34 — MODO MOBILE REAL
   Desktop mantém-se inalterado.
   ========================================================= */

@media (max-width: 900px) {

  /* -------------------------------------------------------
     SECÇÃO / PALCO
     ------------------------------------------------------- */

  .heritage-book-section {
    margin-top: 30px;
    scroll-margin-top: 90px;
  }

  .heritage-book-heading {
    margin-bottom: 12px;
  }

  .heritage-book-heading .section-kicker {
    margin-bottom: 5px;
    font-size: .72rem;
  }

  .heritage-book-heading p {
    font-size: .88rem;
    line-height: 1.48;
  }

  .heritage-book-stage {
    width: calc(100vw - 18px);
    max-width: 450px;

    min-height:
      min(
        690px,
        calc((100vw - 18px) * 1.48 + 24px)
      );

    margin-inline: auto;

    padding: 10px 4px 16px;

    perspective: 1750px;

    overflow: clip;
    overflow-clip-margin: 38px;
  }

  .heritage-book-motion {
    width: 100%;
    min-height: 0 !important;
  }

  .heritage-flip-book {
    width: 100%;
    min-height: 0 !important;

    filter:
      drop-shadow(
        0 12px 14px
        rgba(31,58,78,.14)
      );
  }

  /*
   * Em portrait não existe meia página vazia para compensar.
   * O centramento da capa é tratado pelo PageFlip.
   */
  .heritage-book-stage.is-closed
  .heritage-book-motion,
  .heritage-book-stage.is-closing
  .heritage-book-motion,
  .heritage-book-stage.is-open
  .heritage-book-motion {
    transform:
      translateX(0) !important;
  }


  /* -------------------------------------------------------
     FOLHA
     ------------------------------------------------------- */

  .heritage-history-page-content {
    padding:
      43px 20px 43px;
  }

  .heritage-history-running-head {
    top: 11px;
    left: 18px;
    right: 18px;

    gap: 8px;

    padding-bottom: 6px;

    font-size: .48rem;
  }

  .heritage-history-running-head span {
    min-width: 0;

    overflow: hidden;

    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .heritage-history-page-footer {
    left: 18px;
    right: 18px;
    bottom: 11px;

    gap: 7px;

    font-size: .52rem;
  }


  /* -------------------------------------------------------
     CAPA
     ------------------------------------------------------- */

  .heritage-cover-inner {
    justify-content: flex-start;

    padding:
      34px 24px 26px !important;
  }

  .heritage-cover-kicker {
    margin-bottom: 11px;

    font-size: .52rem;
    letter-spacing: .16em;
  }

  .heritage-cover-ornament {
    width: 132px;
    height: 10px;

    margin-bottom: 13px;
  }

  .heritage-cover-ornament::before,
  .heritage-cover-ornament::after {
    width: 52px;
  }

  .heritage-cover-title {
    width: 100%;
    max-width: 330px;

    height: 92px;
    min-height: 92px;
    max-height: 92px;

    margin:
      0 auto 13px !important;

    font-size:
      clamp(
        1.35rem,
        6.4vw,
        1.85rem
      );

    line-height: 1.06;
  }

  .heritage-cover-crest-medallion {
    flex-basis: 136px;

    width: 136px;
    height: 136px;

    margin:
      0 auto 14px;
  }

  .heritage-cover-crest-window {
    width: 132px;
    height: 134px;
  }

  .heritage-cover-crest {
    max-width: 128px;
    max-height: 132px;
  }

  .heritage-cover-junta {
    margin-top: auto;

    font-size: .64rem;
    line-height: 1.42;
  }

  .heritage-cover-junta strong {
    font-size: .59rem;
  }

  .heritage-cover-footer-line {
    width: 84px;

    margin-top: 14px;
  }


  /* -------------------------------------------------------
     PRIMEIRA PÁGINA
     ------------------------------------------------------- */

  .heritage-book-opening {
    display: flex;
    flex-direction: column;

    height: 100%;
    min-height: 0;
  }

  .heritage-book-place-name {
    max-width: 100%;

    margin:
      0 0 13px;

    font-size:
      clamp(
        1.45rem,
        7vw,
        1.95rem
      );

    line-height: 1.02;
  }

  .heritage-book-opening-photo {
    flex: 1 1 auto;

    height: auto !important;
    min-height: 0;

    padding: 5px;
  }


  /* -------------------------------------------------------
     CAPÍTULOS / TEXTO
     ------------------------------------------------------- */

  .heritage-book-chapter-rule {
    gap: 8px;

    margin:
      0 0 11px;

    font-size: .54rem;
    letter-spacing: .11em;
  }

  .heritage-book-chapter-rule::before,
  .heritage-book-chapter-rule::after {
    width: 44px;
  }

  .heritage-book-editorial-title {
    margin:
      0 0 12px;

    font-size:
      clamp(
        1.42rem,
        7vw,
        1.78rem
      );

    line-height: 1.04;
  }

  .heritage-book-long-copy {
    max-height:
      calc(100% - 80px);

    padding-right: 5px;

    font-size: .77rem;
    line-height: 1.62;
  }

  .heritage-book-long-copy p {
    margin-bottom: 12px;
  }

  .heritage-book-long-copy p:first-child::first-letter {
    margin:
      5px 7px 0 0;

    font-size: 2.65rem;
  }


  /* -------------------------------------------------------
     IMAGENS DOS CAPÍTULOS
     1 grande em cima + 2 pequenas em baixo
     ------------------------------------------------------- */

  .heritage-book-visual-grid {
    grid-template-columns:
      repeat(
        2,
        minmax(0, 1fr)
      );

    grid-template-rows:
      minmax(0, 1.45fr)
      minmax(0, .72fr);

    gap: 9px;

    height: 100%;
  }

  .heritage-book-visual-grid figure {
    padding: 4px;
  }

  .heritage-book-visual-grid figure:first-child {
    grid-column:
      1 / -1;

    grid-row:
      1;
  }

  .heritage-book-visual-grid figure:nth-child(2) {
    grid-column:
      1;

    grid-row:
      2;
  }

  .heritage-book-visual-grid figure:nth-child(3) {
    grid-column:
      2;

    grid-row:
      2;
  }


  /* -------------------------------------------------------
     GALERIA
     ------------------------------------------------------- */

  .heritage-book-gallery-page {
    height: 100%;
  }

  .heritage-book-gallery-grid {
    grid-template-columns:
      repeat(
        2,
        minmax(0, 1fr)
      ) !important;

    grid-template-rows:
      minmax(0, 1.45fr)
      minmax(0, .72fr) !important;

    gap: 8px;

    height: auto !important;
    min-height: 0;

    flex: 1 1 auto;
  }

  .heritage-book-gallery-grid figure {
    padding: 4px;
  }

  .heritage-book-gallery-grid figure:first-child {
    grid-column:
      1 / -1 !important;

    grid-row:
      1 !important;
  }

  .heritage-book-gallery-grid figure:nth-child(2) {
    grid-column:
      1 !important;

    grid-row:
      2 !important;
  }

  .heritage-book-gallery-grid figure:nth-child(3) {
    grid-column:
      2 !important;

    grid-row:
      2 !important;
  }

  .heritage-book-gallery-grid.has-one {
    grid-template-columns:
      1fr !important;

    grid-template-rows:
      1fr !important;
  }

  .heritage-book-gallery-grid.has-one
  figure:first-child {
    grid-column:
      1 !important;

    grid-row:
      1 !important;
  }

  .heritage-book-gallery-grid.has-two {
    grid-template-columns:
      1fr !important;

    grid-template-rows:
      repeat(
        2,
        minmax(0, 1fr)
      ) !important;
  }

  .heritage-book-gallery-grid.has-two
  figure:first-child,
  .heritage-book-gallery-grid.has-two
  figure:nth-child(2) {
    grid-column:
      1 !important;

    grid-row:
      auto !important;
  }


  /* -------------------------------------------------------
     LINHA HISTÓRICA
     Em portrait cada folha mostra uma metade do spread,
     portanto os acontecimentos já ficam naturalmente divididos.
     ------------------------------------------------------- */

  .heritage-book-timeline-title {
    font-size: 1.42rem;
  }

  .heritage-book-timeline-subtitle {
    font-size: .64rem;
    line-height: 1.38;
  }

  .heritage-book-timeline-canvas {
    margin-top: 9px;
  }

  .heritage-book-timeline-event,
  .heritage-book-timeline-event-copy {
    width: 112px;
  }

  .heritage-book-timeline-event strong {
    font-size: .61rem;
  }

  .heritage-book-timeline-event span {
    font-size: .55rem;
  }

  .heritage-book-timeline-event p {
    font-size: .50rem;
    line-height: 1.30;
  }


  /* -------------------------------------------------------
     TOQUE
     ------------------------------------------------------- */

  .heritage-book-cover-page,
  .heritage-history-page,
  .heritage-book-back-cover {
    touch-action:
      pan-y pinch-zoom;
  }
}


@media (max-width: 390px) {

  .heritage-book-stage {
    width:
      calc(100vw - 10px);

    padding-inline: 2px;
  }

  .heritage-history-page-content {
    padding:
      40px 17px 40px;
  }

  .heritage-cover-inner {
    padding:
      30px 20px 23px !important;
  }

  .heritage-cover-title {
    height: 86px;
    min-height: 86px;
    max-height: 86px;
  }

  .heritage-book-long-copy {
    font-size: .74rem;
  }
}


/* =========================================================
   V35 — FINALIZAÇÃO: TEXTO, LANDSCAPE, A11Y E PERFORMANCE
   ========================================================= */

/* ---------------------------------------------------------
   Paginação automática dos capítulos
   --------------------------------------------------------- */

/*
 * O texto já chega dividido pelo JavaScript.
 * Por isso deixa de existir scroll interno dentro da folha.
 */
.heritage-book-long-copy {
  max-height: none !important;
  overflow: hidden !important;
  padding-right: 0 !important;
  scrollbar-width: none;
}

.heritage-book-long-copy::-webkit-scrollbar {
  display: none;
}

.heritage-book-continuation-label {
  margin:
    4px 0 12px;

  color: #9b805a;

  font-family:
    "Libre Baskerville",
    serif;

  font-size: .68rem;
  font-weight: 700;

  letter-spacing: .12em;
  text-align: center;
}

.heritage-book-editorial-title.is-continuation-title {
  margin-bottom: 18px;
}

.heritage-book-editorial-title.is-continuation-title span {
  display: block;

  margin-top: 6px;

  color: #9b805a;

  font-family:
    "Libre Baskerville",
    serif;

  font-size: .67rem;
  font-weight: 400;
  letter-spacing: .04em;
}


/* ---------------------------------------------------------
   Acessibilidade
   --------------------------------------------------------- */

.heritage-book-sr-only {
  position: absolute !important;

  width: 1px !important;
  height: 1px !important;

  padding: 0 !important;
  margin: -1px !important;

  overflow: hidden !important;

  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;

  white-space: nowrap !important;

  border: 0 !important;
}

.heritage-flip-book:focus-visible {
  outline:
    3px solid
    rgba(20, 132, 205, .72);

  outline-offset: 6px;
}


/* ---------------------------------------------------------
   Mobile landscape
   --------------------------------------------------------- */

@media
  (max-width: 900px)
  and (orientation: landscape) {

  .heritage-book-section {
    margin-top: 20px;
  }

  .heritage-book-heading {
    max-width: 580px;
    margin-inline: auto;
    margin-bottom: 8px;
  }

  .heritage-book-heading p {
    margin-bottom: 0;

    font-size: .78rem;
  }

  .heritage-book-stage {
    width:
      min(
        calc(100vw - 20px),
        580px
      );

    max-width: 580px;

    min-height:
      min(
        450px,
        calc(100svh - 30px)
      );

    padding:
      6px 3px 10px;
  }

  .heritage-history-page-content {
    padding:
      31px 18px 31px;
  }

  .heritage-history-running-head {
    top: 8px;
    left: 15px;
    right: 15px;

    padding-bottom: 4px;

    font-size: .42rem;
  }

  .heritage-history-page-footer {
    left: 15px;
    right: 15px;
    bottom: 8px;

    font-size: .44rem;
  }

  .heritage-cover-inner {
    padding:
      23px 24px 18px !important;
  }

  .heritage-cover-kicker {
    margin-bottom: 6px;

    font-size: .42rem;
  }

  .heritage-cover-ornament {
    margin-bottom: 5px;
  }

  .heritage-cover-title {
    max-width: 390px;

    height: 60px;
    min-height: 60px;
    max-height: 60px;

    margin-bottom: 6px !important;

    font-size:
      clamp(
        1.05rem,
        4vw,
        1.38rem
      );
  }

  .heritage-cover-crest-medallion {
    flex-basis: 92px;

    width: 92px;
    height: 92px;

    margin-bottom: 7px;
  }

  .heritage-cover-crest-window {
    width: 90px;
    height: 90px;
  }

  .heritage-cover-crest {
    max-width: 88px;
    max-height: 88px;
  }

  .heritage-cover-junta {
    font-size: .47rem;
  }

  .heritage-cover-junta strong {
    font-size: .45rem;
  }

  .heritage-cover-footer-line {
    width: 62px;

    margin-top: 6px;
  }

  .heritage-book-place-name {
    margin-bottom: 8px;

    font-size:
      clamp(
        1.15rem,
        4.6vw,
        1.5rem
      );
  }

  .heritage-book-editorial-title {
    margin-bottom: 8px;

    font-size:
      clamp(
        1.12rem,
        4.5vw,
        1.45rem
      );
  }

  .heritage-book-chapter-rule {
    margin-bottom: 6px;

    font-size: .45rem;
  }

  .heritage-book-continuation-label {
    margin:
      2px 0 7px;

    font-size: .45rem;
  }

  .heritage-book-long-copy {
    font-size: .66rem;
    line-height: 1.48;
  }

  .heritage-book-long-copy p {
    margin-bottom: 8px;
  }

  .heritage-book-long-copy p:first-child::first-letter {
    margin:
      4px 6px 0 0;

    font-size: 2.15rem;
  }

  .heritage-book-visual-grid,
  .heritage-book-gallery-grid {
    gap: 6px;
  }

  .heritage-book-timeline-title {
    font-size: 1.05rem;
  }

  .heritage-book-timeline-subtitle {
    font-size: .50rem;
  }

  .heritage-book-timeline-event,
  .heritage-book-timeline-event-copy {
    width: 92px;
  }

  .heritage-book-timeline-event strong {
    font-size: .50rem;
  }

  .heritage-book-timeline-event span {
    font-size: .46rem;
  }

  .heritage-book-timeline-event p {
    font-size: .42rem;
  }
}


/* ---------------------------------------------------------
   Movimento reduzido
   --------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {

  .heritage-flip-book,
  .heritage-book-motion,
  .heritage-book-base {
    transition-duration: .01ms !important;
  }
}


/* =========================================================
   V36 — CORREÇÃO DO ENQUADRAMENTO MOBILE
   ========================================================= */

/*
 * A V35 ainda deixava a folha demasiado alta em ecrãs baixos.
 * O JS passa a calcular a dimensão da folha pelo viewport.
 * Aqui retiramos alturas mínimas que podiam forçar o corte.
 */
@media
  (max-width: 900px)
  and (orientation: portrait) {

  .heritage-book-stage {
    min-height: 0 !important;

    padding:
      8px 3px 14px !important;
  }

  .heritage-book-motion,
  .heritage-flip-book {
    min-height: 0 !important;
  }


  /* -------------------------------------------------------
     Folha
     ------------------------------------------------------- */

  .heritage-history-page-content {
    padding:
      38px 15px 37px !important;
  }

  .heritage-history-running-head {
    top: 9px !important;
    left: 15px !important;
    right: 15px !important;

    padding-bottom: 5px !important;

    font-size: .44rem !important;
  }

  .heritage-history-page-footer {
    left: 15px !important;
    right: 15px !important;
    bottom: 9px !important;

    font-size: .46rem !important;
  }


  /* -------------------------------------------------------
     Capa
     O brasão deixa de poder descer para fora da capa.
     ------------------------------------------------------- */

  .heritage-cover-inner {
    justify-content:
      space-between !important;

    min-height: 0;

    padding:
      22px 18px 18px !important;
  }

  .heritage-cover-kicker {
    flex: 0 0 auto;

    margin-bottom: 4px !important;

    font-size: .48rem !important;
  }

  .heritage-cover-ornament {
    flex: 0 0 auto;

    width: 118px !important;
    height: 8px !important;

    margin-bottom: 5px !important;
  }

  .heritage-cover-ornament::before,
  .heritage-cover-ornament::after {
    top: 4px !important;

    width: 46px !important;
  }

  .heritage-cover-ornament i {
    top: 0 !important;

    width: 8px !important;
    height: 8px !important;
  }

  .heritage-cover-title {
    flex: 0 0 64px;

    display: flex !important;
    align-items: center;
    justify-content: center;

    width: 100% !important;
    max-width: 310px !important;

    height: 64px !important;
    min-height: 64px !important;
    max-height: 64px !important;

    margin:
      0 auto 4px !important;

    font-size:
      clamp(
        1.18rem,
        5.8vw,
        1.56rem
      ) !important;

    line-height: 1.04 !important;
  }

  .heritage-cover-crest-medallion {
    flex:
      0 0 104px !important;

    width: 104px !important;
    height: 104px !important;

    margin:
      0 auto 5px !important;
  }

  .heritage-cover-crest-window {
    width: 100px !important;
    height: 100px !important;
  }

  .heritage-cover-crest {
    max-width: 98px !important;
    max-height: 100px !important;
  }

  .heritage-cover-junta {
    flex: 0 0 auto;

    margin-top: 0 !important;

    font-size: .52rem !important;
    line-height: 1.35 !important;
  }

  .heritage-cover-junta strong {
    font-size: .49rem !important;
  }

  .heritage-cover-footer-line {
    width: 68px !important;

    margin-top: 6px !important;
  }


  /* -------------------------------------------------------
     Página visual dos capítulos
     Nunca ultrapassa o rodapé.
     ------------------------------------------------------- */

  .heritage-book-visual-grid {
    height: 100% !important;
    max-height: 100% !important;

    grid-template-columns:
      repeat(
        2,
        minmax(0, 1fr)
      ) !important;

    grid-template-rows:
      minmax(0, 1fr)
      82px !important;

    gap: 7px !important;
  }

  .heritage-book-visual-grid figure {
    min-height: 0 !important;

    padding: 4px !important;
  }

  .heritage-book-visual-grid figure:first-child {
    grid-column:
      1 / -1 !important;

    grid-row:
      1 !important;
  }

  .heritage-book-visual-grid figure:nth-child(2) {
    grid-column:
      1 !important;

    grid-row:
      2 !important;
  }

  .heritage-book-visual-grid figure:nth-child(3) {
    grid-column:
      2 !important;

    grid-row:
      2 !important;
  }


  /* -------------------------------------------------------
     Galeria
     ------------------------------------------------------- */

  .heritage-book-gallery-grid {
    height: 100% !important;
    max-height: 100% !important;

    grid-template-rows:
      minmax(0, 1fr)
      82px !important;
  }


  /* -------------------------------------------------------
     Texto
     ------------------------------------------------------- */

  .heritage-book-editorial-title {
    margin-bottom: 9px !important;

    font-size:
      clamp(
        1.20rem,
        6vw,
        1.52rem
      ) !important;
  }

  .heritage-book-chapter-rule {
    margin-bottom: 7px !important;
  }

  .heritage-book-long-copy {
    font-size: .70rem !important;
    line-height: 1.48 !important;
  }

  .heritage-book-long-copy p {
    margin-bottom: 9px !important;
  }

  .heritage-book-continuation-label {
    margin:
      2px 0 7px !important;

    font-size: .48rem !important;
  }
}


/*
 * Ecrãs particularmente baixos:
 * compactamos mais a segunda linha de fotografias e a capa.
 */
@media
  (max-width: 900px)
  and (orientation: portrait)
  and (max-height: 680px) {

  .heritage-book-heading p {
    font-size: .78rem !important;
    line-height: 1.38 !important;
  }

  .heritage-cover-inner {
    padding:
      17px 16px 14px !important;
  }

  .heritage-cover-title {
    flex-basis: 54px !important;

    height: 54px !important;
    min-height: 54px !important;
    max-height: 54px !important;

    font-size:
      clamp(
        1.02rem,
        5.2vw,
        1.34rem
      ) !important;
  }

  .heritage-cover-crest-medallion {
    flex-basis: 86px !important;

    width: 86px !important;
    height: 86px !important;
  }

  .heritage-cover-crest-window {
    width: 82px !important;
    height: 82px !important;
  }

  .heritage-cover-crest {
    max-width: 80px !important;
    max-height: 82px !important;
  }

  .heritage-book-visual-grid,
  .heritage-book-gallery-grid {
    grid-template-rows:
      minmax(0, 1fr)
      68px !important;
  }
}


/* =========================================================
   V37 — ROTAÇÃO MOBILE / CAPA AZUL SINCRONIZADA
   ========================================================= */

/*
 * Durante a reconstrução portrait <-> landscape,
 * a base antiga nunca pode ficar visível.
 */
.heritage-book-stage.is-reflowing
.heritage-book-base {
  opacity: 0 !important;
  visibility: hidden !important;
  transition: none !important;
}


/*
 * No mobile a base deve seguir exclusivamente as medidas
 * calculadas pelo JS a partir do .stf__parent atual.
 * Neutraliza dimensões antigas herdadas das versões desktop.
 */
@media (max-width: 900px) {

  .heritage-book-base {
    top:
      var(--book-base-top, 0px) !important;

    left:
      var(--book-base-left, 0px) !important;

    right: auto !important;
    bottom: auto !important;

    width:
      var(--book-base-width, 0px) !important;

    height:
      var(--book-base-height, 0px) !important;

    max-width: none !important;
    aspect-ratio: auto !important;

    transform: none !important;
  }


  /*
   * A "lombada" central só faz sentido no spread desktop.
   * Em mobile existe uma única folha, por isso retiramo-la.
   */
  .heritage-book-base::after {
    display: none !important;
  }
}


/* =========================================================
   V38 — CAPA MOBILE + CAPA FÍSICA POR BAIXO DAS FOLHAS
   ========================================================= */

@media
  (max-width: 900px)
  and (orientation: portrait) {

  /* -------------------------------------------------------
     CAPA
     Retiramos o space-between que estava a espalhar demasiado
     os elementos na vertical.
     ------------------------------------------------------- */

  .heritage-cover-inner {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;

    padding:
      24px 18px 18px !important;
  }

  .heritage-cover-kicker {
    flex: 0 0 auto !important;

    margin:
      0 0 14px !important;
  }

  .heritage-cover-ornament {
    flex: 0 0 auto !important;

    margin:
      0 0 24px !important;
  }

  /*
   * Área fixa do nome:
   * nomes curtos ou longos não deslocam o brasão.
   */
  .heritage-cover-title {
    flex:
      0 0 72px !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    width: 100% !important;
    max-width: 315px !important;

    height: 72px !important;
    min-height: 72px !important;
    max-height: 72px !important;

    margin:
      0 auto 22px !important;

    overflow: hidden !important;

    font-size:
      clamp(
        1.18rem,
        5.8vw,
        1.58rem
      ) !important;

    line-height: 1.05 !important;
  }

  .heritage-cover-crest-medallion {
    flex:
      0 0 106px !important;

    width: 106px !important;
    height: 106px !important;

    margin:
      0 auto 24px !important;
  }

  .heritage-cover-crest-window {
    width: 102px !important;
    height: 102px !important;
  }

  .heritage-cover-crest {
    max-width: 100px !important;
    max-height: 102px !important;
  }

  .heritage-cover-junta {
    flex: 0 0 auto !important;

    margin:
      0 auto !important;
  }

  .heritage-cover-footer-line {
    flex: 0 0 auto !important;

    margin:
      15px auto 0 !important;
  }


  /* -------------------------------------------------------
     CAPA AZUL SOB AS FOLHAS
     ------------------------------------------------------- */

  /*
   * Quando o livro está aberto, a capa/base deve ser sempre
   * perceptível em redor da folha.
   */
  .heritage-book-stage.is-open:not(.is-opening):not(.is-closing):not(.is-back-cover):not(.is-reflowing)
  .heritage-book-base {
    opacity: 1 !important;
    visibility: visible !important;

    box-shadow:
      0 16px 27px rgba(5,38,63,.18),
      inset 0 -8px 14px rgba(0,0,0,.16),
      inset 0 1px 0 rgba(255,255,255,.09) !important;
  }

  .heritage-book-base::before {
    inset: 6px !important;

    border:
      1px solid
      rgba(222,234,242,.12) !important;
  }
}


/*
 * Nos ecrãs muito baixos mantemos o mesmo alinhamento,
 * apenas compactamos ligeiramente as distâncias.
 */
@media
  (max-width: 900px)
  and (orientation: portrait)
  and (max-height: 680px) {

  .heritage-cover-inner {
    padding:
      18px 16px 14px !important;
  }

  .heritage-cover-kicker {
    margin-bottom: 9px !important;
  }

  .heritage-cover-ornament {
    margin-bottom: 15px !important;
  }

  .heritage-cover-title {
    flex-basis: 58px !important;

    height: 58px !important;
    min-height: 58px !important;
    max-height: 58px !important;

    margin-bottom: 14px !important;

    font-size:
      clamp(
        1.02rem,
        5.1vw,
        1.34rem
      ) !important;
  }

  .heritage-cover-crest-medallion {
    flex-basis: 88px !important;

    width: 88px !important;
    height: 88px !important;

    margin-bottom: 14px !important;
  }

  .heritage-cover-crest-window {
    width: 84px !important;
    height: 84px !important;
  }

  .heritage-cover-crest {
    max-width: 82px !important;
    max-height: 84px !important;
  }

  .heritage-cover-footer-line {
    margin-top: 8px !important;
  }
}


/* =========================================================
   V39 — CAPA MOBILE REENQUADRADA + CAPA FÍSICA GARANTIDA
   ========================================================= */

/*
 * No mobile, a capa física sob as folhas passa a ser desenhada
 * diretamente em volta da caixa estável do StPageFlip.
 * Assim acompanha sempre a folha e não depende do cálculo da base
 * azul independente, que podia ficar invisível/desalinhada.
 */
@media (max-width: 900px) {

  /* Não usamos a base azul independente como efeito visual no mobile. */
  .heritage-book-stage.is-open:not(.is-opening):not(.is-closing):not(.is-back-cover)
  .heritage-book-base {
    opacity: 0 !important;
    visibility: hidden !important;
  }

  /* Capa azul visível por baixo das folhas. */
  .heritage-book-stage.is-open:not(.is-opening):not(.is-closing):not(.is-back-cover):not(.is-reflowing)
  .heritage-flip-book
  .stf__parent {
    box-shadow:
      0 0 0 8px #123e67,
      0 0 0 9px rgba(229,239,246,.14),
      0 0 0 12px #082d4d,
      0 15px 27px rgba(5,38,63,.22) !important;
  }
}


/* ---------------------------------------------------------
   CAPA FRONTAL — PORTRAIT
   --------------------------------------------------------- */

@media
  (max-width: 900px)
  and (orientation: portrait) {

  /*
   * Grelha fixa:
   * kicker / ornamento / nome / brasão / junta / linha.
   * O nome tem sempre a mesma zona e deixa de empurrar o brasão.
   */
  .heritage-cover-inner {
    display: grid !important;

    grid-template-columns:
      minmax(0, 1fr) !important;

    grid-template-rows:
      auto
      14px
      82px
      116px
      auto
      10px !important;

    align-content: center !important;
    align-items: center !important;
    justify-items: center !important;

    row-gap: 14px !important;

    height: 100% !important;
    min-height: 0 !important;

    padding:
      30px 24px 28px !important;

    box-sizing: border-box !important;
  }

  .heritage-cover-kicker {
    grid-row: 1 !important;

    margin: 0 !important;

    font-size: .50rem !important;
    line-height: 1.2 !important;
    letter-spacing: .17em !important;
  }

  .heritage-cover-ornament {
    grid-row: 2 !important;

    width: 122px !important;
    height: 14px !important;

    margin: 0 !important;
  }

  .heritage-cover-ornament::before,
  .heritage-cover-ornament::after {
    top: 7px !important;

    width: 48px !important;
  }

  .heritage-cover-ornament i {
    top: 3px !important;

    width: 8px !important;
    height: 8px !important;
  }

  .heritage-cover-title {
    grid-row: 3 !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    width: 100% !important;
    max-width: 320px !important;

    height: 82px !important;
    min-height: 82px !important;
    max-height: 82px !important;

    margin: 0 !important;
    padding: 0 4px !important;

    overflow: hidden !important;

    font-size:
      clamp(
        1.22rem,
        5.8vw,
        1.58rem
      ) !important;

    line-height: 1.05 !important;
    text-align: center !important;
  }

  .heritage-cover-crest-medallion {
    grid-row: 4 !important;

    align-self: center !important;

    width: 112px !important;
    height: 116px !important;

    margin: 0 !important;

    flex: none !important;
  }

  .heritage-cover-crest-window {
    width: 108px !important;
    height: 112px !important;
  }

  .heritage-cover-crest {
    max-width: 106px !important;
    max-height: 110px !important;
  }

  .heritage-cover-junta {
    grid-row: 5 !important;

    align-self: center !important;

    margin: 0 !important;

    font-size: .54rem !important;
    line-height: 1.45 !important;
    text-align: center !important;
  }

  .heritage-cover-junta strong {
    margin-bottom: 2px !important;

    font-size: .51rem !important;
  }

  .heritage-cover-footer-line {
    grid-row: 6 !important;

    width: 72px !important;

    margin: 0 !important;
  }
}


/*
 * Em ecrãs mais baixos preservamos as mesmas posições,
 * apenas compactamos a grelha.
 */
@media
  (max-width: 900px)
  and (orientation: portrait)
  and (max-height: 680px) {

  .heritage-cover-inner {
    grid-template-rows:
      auto
      12px
      64px
      92px
      auto
      8px !important;

    row-gap: 10px !important;

    padding:
      20px 20px 18px !important;
  }

  .heritage-cover-title {
    height: 64px !important;
    min-height: 64px !important;
    max-height: 64px !important;

    font-size:
      clamp(
        1.04rem,
        5.1vw,
        1.34rem
      ) !important;
  }

  .heritage-cover-crest-medallion {
    width: 90px !important;
    height: 92px !important;
  }

  .heritage-cover-crest-window {
    width: 86px !important;
    height: 88px !important;
  }

  .heritage-cover-crest {
    max-width: 84px !important;
    max-height: 86px !important;
  }
}


/* ---------------------------------------------------------
   LANDSCAPE
   --------------------------------------------------------- */

@media
  (max-width: 900px)
  and (orientation: landscape) {

  .heritage-book-stage.is-open:not(.is-opening):not(.is-closing):not(.is-back-cover):not(.is-reflowing)
  .heritage-flip-book
  .stf__parent {
    box-shadow:
      0 0 0 6px #123e67,
      0 0 0 7px rgba(229,239,246,.14),
      0 0 0 9px #082d4d,
      0 12px 22px rgba(5,38,63,.20) !important;
  }
}


/* =========================================================
   V40 — RESTAURO DA CAPA FÍSICA POR BAIXO DAS FOLHAS
   ========================================================= */

/*
 * A V37 passou a medir a base através de .stf__parent.
 * Em algumas estruturas do StPageFlip esse elemento não está
 * dentro de #heritageFlipBook, logo a medição falhava e as
 * variáveis ficavam a 0px.
 *
 * A V40 volta a usar a própria .heritage-book-base medida
 * pelas folhas visíveis — o método que já estava estável.
 */

/* Livro aberto: a capa física real fica visível. */
.heritage-book-stage.is-open:not(.is-opening):not(.is-closing):not(.is-back-cover):not(.is-reflowing)
.heritage-book-base {
  opacity: 1 !important;
  visibility: visible !important;

  box-shadow:
    0 18px 30px rgba(5,38,63,.20),
    inset 0 -8px 14px rgba(0,0,0,.16),
    inset 0 1px 0 rgba(255,255,255,.09) !important;
}

/* Fechado / animações / contracapa: mantém a lógica já estabilizada. */
.heritage-book-stage.is-closed
.heritage-book-base,
.heritage-book-stage.is-opening
.heritage-book-base,
.heritage-book-stage.is-closing
.heritage-book-base,
.heritage-book-stage.is-back-cover
.heritage-book-base,
.heritage-book-stage.is-reflowing
.heritage-book-base {
  opacity: 0 !important;
  visibility: hidden !important;
}

/*
 * Desativamos apenas a moldura artificial adicionada na V39
 * ao .stf__parent. Agora a capa azul volta a ser um elemento real.
 */
@media (max-width: 900px) {

  .heritage-book-stage.is-open
  .heritage-flip-book
  .stf__parent {
    box-shadow: none !important;
  }

  .heritage-book-base {
    top:
      var(--book-base-top, 0px) !important;

    left:
      var(--book-base-left, 0px) !important;

    right: auto !important;
    bottom: auto !important;

    width:
      var(--book-base-width, 0px) !important;

    height:
      var(--book-base-height, 0px) !important;

    max-width: none !important;
    aspect-ratio: auto !important;

    transform: none !important;

    border-radius: 0 !important;
  }

  /* Em página única não existe lombada central. */
  .heritage-book-base::after {
    display: none !important;
  }

  .heritage-book-base::before {
    inset: 6px !important;
  }
}


/* =========================================================
   V42 — CAPA MOBILE COM POSIÇÕES FIXAS
   ========================================================= */

/*
 * Em vez de flex/grid, os elementos principais da capa passam
 * a ocupar posições percentuais fixas.
 *
 * Assim:
 * - o nome pode ter 1, 2 ou 3 linhas;
 * - o brasão NUNCA se desloca;
 * - a Junta NUNCA se desloca;
 * - o conjunto mantém sempre a mesma composição.
 */
@media
  (max-width: 900px)
  and (orientation: portrait) {

  .heritage-cover-inner {
    position: relative !important;

    display: block !important;

    width: 100% !important;
    height: 100% !important;

    padding: 0 !important;

    box-sizing: border-box !important;
  }


  /* Património da Freguesia */
  .heritage-cover-kicker {
    position: absolute !important;

    top: 7.5% !important;
    left: 50% !important;

    width: 82% !important;

    margin: 0 !important;

    transform:
      translateX(-50%) !important;

    font-size: .50rem !important;
    line-height: 1.2 !important;
    letter-spacing: .17em !important;

    text-align: center !important;
  }


  /* Filete + losango */
  .heritage-cover-ornament {
    position: absolute !important;

    top: 15.5% !important;
    left: 50% !important;

    width: 122px !important;
    height: 14px !important;

    margin: 0 !important;

    transform:
      translateX(-50%) !important;
  }

  .heritage-cover-ornament::before,
  .heritage-cover-ornament::after {
    top: 7px !important;

    width: 48px !important;
  }

  .heritage-cover-ornament i {
    top: 3px !important;

    width: 8px !important;
    height: 8px !important;
  }


  /*
   * Zona FIXA do nome.
   * O centro desta área é sempre o mesmo, independentemente
   * do número de linhas.
   */
  .heritage-cover-title {
    position: absolute !important;

    top: 23% !important;
    left: 50% !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    width: 72% !important;
    max-width: 290px !important;

    height: 19% !important;
    min-height: 78px !important;
    max-height: 112px !important;

    margin: 0 !important;
    padding: 0 5px !important;

    overflow: hidden !important;

    transform:
      translateX(-50%) !important;

    font-size:
      clamp(
        1.20rem,
        5.7vw,
        1.58rem
      ) !important;

    line-height: 1.06 !important;
    letter-spacing: -.025em !important;

    text-align: center !important;
    text-wrap: balance;
  }

  .heritage-cover-title.is-long-title {
    font-size:
      clamp(
        1.08rem,
        5.1vw,
        1.40rem
      ) !important;
  }

  .heritage-cover-title.is-very-long-title {
    font-size:
      clamp(
        .94rem,
        4.6vw,
        1.22rem
      ) !important;

    line-height: 1.04 !important;
  }


  /*
   * Brasão em posição fixa.
   * Já não depende da altura ocupada pelo nome.
   */
  .heritage-cover-crest-medallion {
    position: absolute !important;

    top: 48% !important;
    left: 50% !important;

    display: grid !important;
    place-items: center !important;

    width: 116px !important;
    height: 122px !important;

    margin: 0 !important;

    transform:
      translateX(-50%) !important;

    flex: none !important;
  }

  .heritage-cover-crest-window {
    width: 112px !important;
    height: 118px !important;
  }

  .heritage-cover-crest {
    max-width: 110px !important;
    max-height: 116px !important;
  }


  /* Identificação da Junta */
  .heritage-cover-junta {
    position: absolute !important;

    top: 76.5% !important;
    left: 50% !important;

    width: 78% !important;
    max-width: 270px !important;

    margin: 0 !important;

    transform:
      translateX(-50%) !important;

    font-size: .56rem !important;
    line-height: 1.48 !important;

    text-align: center !important;
  }

  .heritage-cover-junta strong {
    margin-bottom: 3px !important;

    font-size: .53rem !important;
    letter-spacing: .085em !important;
  }


  /* Linha decorativa inferior */
  .heritage-cover-footer-line {
    position: absolute !important;

    top: 87% !important;
    left: 50% !important;

    width: 74px !important;

    margin: 0 !important;

    transform:
      translateX(-50%) !important;
  }
}


/*
 * Em ecrãs baixos mantemos as MESMAS posições percentuais.
 * Só reduzimos dimensões, nunca deslocamos os blocos.
 */
@media
  (max-width: 900px)
  and (orientation: portrait)
  and (max-height: 680px) {

  .heritage-cover-title {
    min-height: 60px !important;
    max-height: 82px !important;

    font-size:
      clamp(
        1.00rem,
        5vw,
        1.32rem
      ) !important;
  }

  .heritage-cover-title.is-long-title {
    font-size:
      clamp(
        .92rem,
        4.6vw,
        1.18rem
      ) !important;
  }

  .heritage-cover-title.is-very-long-title {
    font-size:
      clamp(
        .82rem,
        4.1vw,
        1.06rem
      ) !important;
  }

  .heritage-cover-crest-medallion {
    width: 92px !important;
    height: 96px !important;
  }

  .heritage-cover-crest-window {
    width: 88px !important;
    height: 92px !important;
  }

  .heritage-cover-crest {
    max-width: 86px !important;
    max-height: 90px !important;
  }

  .heritage-cover-junta {
    font-size: .49rem !important;
  }

  .heritage-cover-junta strong {
    font-size: .47rem !important;
  }
}


/* =========================================================
   V43 — CAPA MOBILE LANDSCAPE COM POSIÇÕES FIXAS
   ========================================================= */

/*
 * A V42 já resolveu o portrait usando posições absolutas.
 * No landscape ainda sobreviviam as regras flex antigas.
 *
 * Agora o landscape usa exatamente o mesmo princípio:
 * cada bloco ocupa uma posição fixa na capa e o tamanho do nome
 * só altera a fonte — nunca empurra o brasão ou a Junta.
 */
@media
  (max-width: 900px)
  and (orientation: landscape) {

  .heritage-cover-inner {
    position: relative !important;

    display: block !important;

    width: 100% !important;
    height: 100% !important;

    padding: 0 !important;

    box-sizing: border-box !important;
  }


  /* Património da Freguesia */
  .heritage-cover-kicker {
    position: absolute !important;

    top: 6.5% !important;
    left: 50% !important;

    width: 82% !important;

    margin: 0 !important;

    transform:
      translateX(-50%) !important;

    font-size: .40rem !important;
    line-height: 1.15 !important;
    letter-spacing: .16em !important;

    text-align: center !important;
  }


  /* Ornamento */
  .heritage-cover-ornament {
    position: absolute !important;

    top: 15% !important;
    left: 50% !important;

    width: 108px !important;
    height: 12px !important;

    margin: 0 !important;

    transform:
      translateX(-50%) !important;
  }

  .heritage-cover-ornament::before,
  .heritage-cover-ornament::after {
    top: 6px !important;

    width: 42px !important;
  }

  .heritage-cover-ornament i {
    top: 2px !important;

    width: 8px !important;
    height: 8px !important;
  }


  /*
   * Zona fixa do título.
   * O centro do nome fica sempre no mesmo local.
   */
  .heritage-cover-title {
    position: absolute !important;

    top: 23% !important;
    left: 50% !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    width: 68% !important;
    max-width: 340px !important;

    height: 18% !important;
    min-height: 54px !important;
    max-height: 78px !important;

    margin: 0 !important;
    padding: 0 5px !important;

    overflow: hidden !important;

    transform:
      translateX(-50%) !important;

    font-size:
      clamp(
        1.02rem,
        3.4vw,
        1.34rem
      ) !important;

    line-height: 1.04 !important;
    letter-spacing: -.02em !important;

    text-align: center !important;
    text-wrap: balance;
  }

  .heritage-cover-title.is-long-title {
    font-size:
      clamp(
        .92rem,
        3vw,
        1.18rem
      ) !important;
  }

  .heritage-cover-title.is-very-long-title {
    font-size:
      clamp(
        .80rem,
        2.6vw,
        1.02rem
      ) !important;

    line-height: 1.02 !important;
  }


  /* Brasão fixo */
  .heritage-cover-crest-medallion {
    position: absolute !important;

    top: 48% !important;
    left: 50% !important;

    display: grid !important;
    place-items: center !important;

    width: 82px !important;
    height: 86px !important;

    margin: 0 !important;

    transform:
      translateX(-50%) !important;

    flex: none !important;
  }

  .heritage-cover-crest-window {
    width: 78px !important;
    height: 82px !important;
  }

  .heritage-cover-crest {
    max-width: 76px !important;
    max-height: 80px !important;
  }


  /* Junta */
  .heritage-cover-junta {
    position: absolute !important;

    top: 76% !important;
    left: 50% !important;

    width: 74% !important;
    max-width: 330px !important;

    margin: 0 !important;

    transform:
      translateX(-50%) !important;

    font-size: .43rem !important;
    line-height: 1.35 !important;

    text-align: center !important;
  }

  .heritage-cover-junta strong {
    margin-bottom: 2px !important;

    font-size: .42rem !important;
    letter-spacing: .08em !important;
  }


  /* Linha final */
  .heritage-cover-footer-line {
    position: absolute !important;

    top: 88% !important;
    left: 50% !important;

    width: 58px !important;

    margin: 0 !important;

    transform:
      translateX(-50%) !important;
  }
}


/*
 * Landscape particularmente baixo:
 * as posições mantêm-se, apenas compactamos tamanhos.
 */
@media
  (max-width: 900px)
  and (orientation: landscape)
  and (max-height: 380px) {

  .heritage-cover-title {
    min-height: 46px !important;
    max-height: 62px !important;

    font-size:
      clamp(
        .88rem,
        2.9vw,
        1.14rem
      ) !important;
  }

  .heritage-cover-title.is-long-title {
    font-size:
      clamp(
        .80rem,
        2.55vw,
        1.00rem
      ) !important;
  }

  .heritage-cover-title.is-very-long-title {
    font-size:
      clamp(
        .72rem,
        2.3vw,
        .90rem
      ) !important;
  }

  .heritage-cover-crest-medallion {
    width: 68px !important;
    height: 72px !important;
  }

  .heritage-cover-crest-window {
    width: 64px !important;
    height: 68px !important;
  }

  .heritage-cover-crest {
    max-width: 62px !important;
    max-height: 66px !important;
  }

  .heritage-cover-junta {
    font-size: .38rem !important;
  }

  .heritage-cover-junta strong {
    font-size: .37rem !important;
  }
}


/* =========================================================
   V44 — CAPA FÍSICA ESTÁVEL DURANTE VIRAGENS
   ========================================================= */

/*
 * A base já não deve animar width/height/posição entre medições.
 * Apenas a visibilidade pode fazer fade.
 */
.heritage-book-base {
  transition:
    opacity 180ms ease,
    visibility 180ms ease !important;
}


/* =========================================================
   V45 — CAPA FÍSICA SEMPRE VISÍVEL QUANDO O LIVRO ESTÁ ABERTO
   ========================================================= */

/*
 * Regra final para vencer qualquer regra antiga das versões mobile.
 */
.heritage-book-stage.is-open:not(.is-opening):not(.is-closing):not(.is-back-cover):not(.is-reflowing)
.heritage-book-base {
  display: block !important;

  opacity: 1 !important;
  visibility: visible !important;

  z-index: 0 !important;
}


/*
 * O livro/páginas ficam sempre acima da capa física.
 */
.heritage-book-motion,
.heritage-flip-book {
  position: relative;
  z-index: 1;
}


/*
 * A base usa exclusivamente as variáveis calculadas pelo JS.
 */
.heritage-book-base {
  top:
    var(--book-base-top, 0px) !important;

  left:
    var(--book-base-left, 0px) !important;

  right: auto !important;
  bottom: auto !important;

  width:
    var(--book-base-width, 0px) !important;

  height:
    var(--book-base-height, 0px) !important;

  transform: none !important;

  transition:
    opacity 160ms ease,
    visibility 160ms ease !important;
}


/* =========================================================
   V47 — CAPA PORTRAIT MAIS JUSTA À FOLHA
   ========================================================= */

@media
  (max-width: 900px)
  and (orientation: portrait) {

  .heritage-book-base::before {
    inset: 3px !important;
  }

  .heritage-book-stage.is-open:not(.is-opening):not(.is-closing):not(.is-back-cover):not(.is-reflowing)
  .heritage-book-base {
    box-shadow:
      0 10px 18px rgba(5,38,63,.14),
      inset 0 -4px 8px rgba(0,0,0,.12),
      inset 0 1px 0 rgba(255,255,255,.06) !important;
  }
}


/* =========================================================
   V48 — CAPA LANDSCAPE MAIS JUSTA À FOLHA
   ========================================================= */

@media
  (max-width: 900px)
  and (orientation: landscape) {

  /*
   * A capa física fica visível, mas com um rebordo fino.
   * Evita aquele efeito de "placa azul" demasiado grande
   * por baixo da folha no modo horizontal.
   */
  .heritage-book-base::before {
    inset: 3px !important;
  }

  .heritage-book-stage.is-open:not(.is-opening):not(.is-closing):not(.is-back-cover):not(.is-reflowing)
  .heritage-book-base {
    box-shadow:
      0 9px 16px rgba(5,38,63,.14),
      inset 0 -4px 7px rgba(0,0,0,.11),
      inset 0 1px 0 rgba(255,255,255,.06) !important;
  }
}
