/* #introducao scene: a book's introduction as the app opens it
   (app/src/modules/library/presentation/screens/BookIntroductionScreen.tsx).
   An iPhone holds the real screen: Doré's engraving as the capa, torn along
   the app's own contour (FolhaSheet's TORN_SHEET_PATH, web/media/introducao/
   torn-mask.svg) with the paper lip and the picture's cast on the page, the
   the masthead and Tyndale's Genesis text baked
   by web/scripts/bake-introducao.mjs. Scrolling inside the phone collapses
   the capa to a band pinned at the top, as the app's CapaFolhaPage does.
   introducao.js only arms the folha's entrance; without it the page is shown
   as it stands. */

.l-intro {
  /* The app's light reading page, whatever the scene around it. */
  --i-paper: #f7f2e8;
  --i-ink: #1e150e;
  --i-ink-2: #3a2f28;
  --i-ink-3: #625952;
  --i-accent: #85362e;
  /* FolhaSheet's lip and the torn picture's cast (tokens folhaLip, tornCast). */
  --i-lip: #ece1cb;
  --i-cast: rgb(48 36 26 / 0.34);
  position: relative;
  background: var(--night-bg);
  color: var(--night-fg);
  padding: clamp(72px, 10vh, 120px) clamp(20px, 5vw, 64px);
}
.l-intro-in {
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: clamp(32px, 7vw, 96px);
  align-items: center;
}
.l-intro .l-eb {
  color: var(--night-rubric);
}
.l-intro .l-h2 {
  color: #f2e9d8;
}
.l-intro .l-lede {
  color: #b9ad9f;
}
.l-intro-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 26px 0 0;
  font-size: 18px;
  color: var(--night-fg-2);
}
.l-intro-hint .narrow {
  display: none;
}
.l-intro-hint .arrow {
  display: inline-block;
}
.l-intro.in .l-intro-hint .arrow {
  animation: l-intro-hint 1.8s ease-in-out infinite;
}
@keyframes l-intro-hint {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(6px);
  }
}

/* ── The phone ──────────────────────────────────────────────────────────── */
.l-intro-phone {
  /* Never taller than the window, so the whole screen reads at once. */
  height: min(820px, calc(var(--vh, 100vh) - 96px));
  aspect-ratio: 400 / 820;
  padding: 12px;
  box-sizing: border-box;
  border-radius: 56px;
  background: #0d0a08;
  box-shadow:
    0 0 0 2px #3a2f28,
    0 40px 60px -30px rgb(0 0 0 / 0.8);
}
.l-intro-glass {
  position: relative;
  height: 100%;
  overflow: hidden;
  border-radius: 46px;
  background: var(--i-paper);
  /* Capa sizes follow the screen's width. */
  container-type: inline-size;
  isolation: isolate;
}
.l-intro-glass .island {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 4;
  width: 110px;
  height: 32px;
  margin-left: -55px;
  border-radius: 16px;
  background: #0d0a08;
}

.l-intro-screen {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  /* Chains to the page at either end, so a thumb is never trapped in the phone. */
  overscroll-behavior-y: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.l-intro-screen::-webkit-scrollbar {
  display: none;
}
.l-intro-screen:focus-visible {
  outline: 3px solid var(--night-rubric);
  outline-offset: -3px;
  border-radius: 46px;
}

/* The capa: the engraving at full width, 5% larger about its centre
   (ENGRAVING_ZOOM). Scrolled, it stops as a band as tall as the status bar
   plus the torn tail (CapaFolhaPage COLLAPSED_TAIL) and the text runs under. */
.l-intro .capa {
  --capa-h: calc(100cqw * 955 / 760);
  --band: 112px;
  position: sticky;
  top: calc(var(--band) - var(--capa-h));
  z-index: 2;
  height: var(--capa-h);
  /* The picture casts its shadow down onto the page along the tear. */
  filter: drop-shadow(0 7px 9px var(--i-cast));
}
/* The tear cuts the picture's own box, never the zoomed engraving inside it:
   a mask on the scaled image would scale too and leave picture below the lip. */
.l-intro .capa .pic {
  height: 100%;
  overflow: hidden;
  /* Cut by the app's tear: solid above the strip, the contour across it. */
  -webkit-mask:
    linear-gradient(#000, #000) top / 100% calc(100% - 40px) no-repeat,
    url("/media/introducao/torn-mask.svg") bottom / 100% 40px no-repeat;
  mask:
    linear-gradient(#000, #000) top / 100% calc(100% - 40px) no-repeat,
    url("/media/introducao/torn-mask.svg") bottom / 100% 40px no-repeat;
}
.l-intro .capa img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.05);
}
/* The scrim the status bar reads on (useEngravingCapa SCRIM_TOP). */
.l-intro .capa::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  z-index: 1;
  height: 170px;
  background: linear-gradient(
    rgb(0 0 0 / 0.45) 0,
    rgb(0 0 0 / 0.3) 60px,
    rgb(0 0 0 / 0) 170px
  );
  pointer-events: none;
}
/* The thin lip of paper the picture tore along (between fibre and sheet). */
.l-intro .capa .lip {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 40px;
  fill: var(--i-lip);
}

.l-intro .folha {
  position: relative;
  z-index: 1;
  margin-top: -40px;
  padding: 52px 26px 40px;
  background: var(--i-paper);
  color: var(--i-ink);
}

/* Masthead (ReaderMasthead with BOOK_OPENING_MASTHEAD): the division's
   ornament each side of the blackletter name, then the subtitle in the
   accent and the source label. */
.l-intro .mast {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid #d9cfc0;
  text-align: center;
}
.l-intro .mast .row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.l-intro .mast .orn {
  width: 40px;
  height: 55px;
  fill: none;
  stroke: var(--i-accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.75;
}
.l-intro .mast .orn.flip {
  transform: scaleX(-1);
}
.l-intro .mast .title {
  margin: 0;
  font-family: var(--font-black);
  font-weight: 400;
  font-size: 54px;
  line-height: 1;
  color: var(--i-ink);
}
.l-intro .mast .sub {
  margin: 6px 0 0;
  font-family: var(--font-roman);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--i-accent);
}
.l-intro .mast .by {
  margin: 0;
  font-family: var(--font-roman);
  font-weight: 600;
  font-size: 20px;
  color: var(--i-ink);
}

.l-intro .text {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}
.l-intro .text p {
  margin: 0 0 14px;
}
.l-intro .text > p:first-of-type::first-letter {
  float: left;
  margin: 5px 8px 0 0;
  font-family: var(--font-black);
  font-size: 52px;
  line-height: 0.82;
  color: var(--i-accent);
}
.l-intro .text h4 {
  margin: 24px 0 10px;
  font-family: var(--font-roman);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  color: var(--i-accent);
}

/* The folha rises over the capa when the scene comes into view (the page
   settling as the app opens it). Armed by introducao.js only, so without
   scripts it simply stands in place. */
.l-intro.armed .folha {
  transform: translateY(70px);
  transition: transform 0.95s cubic-bezier(0.2, 0.8, 0.2, 1) 0.15s;
}
.l-intro.armed.risen .folha {
  transform: none;
}

@media (max-width: 820px) {
  .l-intro {
    padding: 64px 16px 72px 28px;
  }
  .l-intro-in {
    grid-template-columns: minmax(0, 1fr);
    gap: 36px;
  }
  .l-intro-hint .wide {
    display: none;
  }
  .l-intro-hint .narrow {
    display: inline;
  }
  .l-intro-phone {
    justify-self: center;
    width: min(100%, 340px);
    height: auto;
    padding: 10px;
    border-radius: 50px;
  }
  .l-intro-glass {
    border-radius: 41px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .l-intro.in .l-intro-hint .arrow {
    animation: none;
  }
  .l-intro.armed .folha {
    transform: none;
    transition: none;
  }
}
