/* #traducoes scene: closed scrolls stacked on the left, one open on the right.
   With WebGL (`.tr-in.is-3d`) the rolls, rods and sheet are drawn by
   traducoes.js on the canvas under this markup; the tags and the text stay
   DOM, laid over the 3D. Without it, the baked sprites (rod.webp, roll.webp)
   and the parchment texture draw the same objects flat. Phones (`.v`): the
   rolls go two by two above the sheet, which unrolls downwards. */

.l-trans {
  position: relative;
  background: var(--bg);
  padding: clamp(80px, 11vh, 128px) 0;
  overflow: hidden;
}
.tr-in {
  position: relative;
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 clamp(32px, 5vw, 80px) 0 clamp(96px, 9vw, 130px);
  display: grid;
  grid-template-columns: minmax(0, 440px) minmax(0, 1fr);
  gap: 56px;
  align-items: center;
}
/* The canvas overhangs the grid so shadows and lifted rolls are not cut at
   its edge; traducoes.js maps the DOM rects relative to the canvas itself. */
.tr-gl {
  position: absolute;
  top: -64px;
  left: -48px;
  width: calc(100% + 96px);
  height: calc(100% + 128px);
  z-index: 1;
  pointer-events: none;
}
.tr-head,
.tr-open {
  position: relative;
  z-index: 2;
}
.tr-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- the stack */

.tr-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 30px;
}
.tr-roll {
  --tilt: 0deg;
  position: relative;
  display: block;
  width: 330px;
  max-width: 100%;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 23px;
  background: none;
  cursor: pointer;
  transform: rotate(var(--tilt));
  -webkit-tap-highlight-color: transparent;
}
.tr-roll:nth-child(3n + 2) {
  width: 352px;
}
.tr-roll:nth-child(3n) {
  width: 374px;
}
/* Each roll leans a little; traducoes.js reads --tilt for its 3D roll. */
.tr-roll:nth-child(4n + 1) {
  --tilt: -1.8deg;
}
.tr-roll:nth-child(4n + 2) {
  --tilt: -0.6deg;
}
.tr-roll:nth-child(4n + 3) {
  --tilt: 0.6deg;
}
.tr-roll:nth-child(4n) {
  --tilt: 1.8deg;
}
.tr-roll:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
/* The flat roll, while there is no WebGL roll over it. */
.tr-roll::before {
  content: "";
  position: absolute;
  inset: -12px 0 -14px;
  background: url("/media/traducoes/roll.webp") center / 100% 100% no-repeat;
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.tr-in.is-3d .tr-roll::before {
  display: none;
}
/* A card tag lying on the roll: the baked card, nine-sliced around the hole. */
.tr-roll .tag {
  position: absolute;
  top: 50%;
  left: 36%;
  height: 30px;
  box-sizing: border-box;
  border-style: solid;
  border-width: 0 10px 0 26px;
  border-image: url("/media/traducoes/tag.webp") 0 24 0 62 fill stretch;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 30px;
  letter-spacing: 0.08em;
  color: var(--ink);
  filter: drop-shadow(0 1px 1px rgba(40, 26, 14, 0.35));
  transform: translate(var(--dx, 0px), -50%);
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.tr-in.is-3d .tr-roll .tag {
  transition: none; /* traducoes.js moves it with its roll */
}
.tr-in:not(.is-3d) .tr-roll:hover::before,
.tr-in:not(.is-3d) .tr-roll:focus-visible::before {
  transform: translateX(14px);
}
.tr-in:not(.is-3d) .tr-roll:hover .tag,
.tr-in:not(.is-3d) .tr-roll:focus-visible .tag {
  --dx: 14px;
}
.tr-in:not(.is-3d) .tr-roll[aria-pressed="true"]::before {
  transform: translateX(40px);
}
.tr-in:not(.is-3d) .tr-roll[aria-pressed="true"] .tag {
  --dx: 40px;
}
/* The open translation's tag is inked in rubric. */
.tr-roll[aria-pressed="true"] .tag {
  color: var(--accent);
}

/* Without scripts the rolls cannot open: the other translations are listed. */
.tr-names {
  display: none;
  margin: 26px 0 0;
  padding: 0;
  list-style: none;
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink-2);
}
.tr-names b {
  display: inline-block;
  min-width: 4.6em;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--accent);
}
:root:not([data-theme-choice]) .tr-stack {
  display: none;
}
:root:not([data-theme-choice]) .tr-names {
  display: block;
}

/* ---- the open scroll */

.tr-open {
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 52px 0;
}
.tr-rod {
  position: relative;
  z-index: 1;
  width: 34px;
  height: auto;
  margin: -44px -14px;
  filter: drop-shadow(4px 8px 6px rgba(40, 26, 14, 0.3));
}
.tr-sheet {
  display: grid;
  width: 640px;
  max-width: 100%;
  background: url("/media/traducoes/parchment.webp") center / 100% 100% no-repeat;
  filter: drop-shadow(4px 10px 10px rgba(40, 26, 14, 0.22));
}
.tr-in.is-3d .tr-sheet {
  background: none;
  filter: none;
}
.tr-in.is-3d .tr-rod {
  visibility: hidden;
}

.tr-p {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 52px 58px 44px;
  color: var(--ink);
  transition:
    opacity 0.45s ease,
    visibility 0.45s;
}
.tr-p:not(.on) {
  visibility: hidden;
  opacity: 0;
}
/* While a sheet unwinds, its ink is clipped to the flat part and comes up. */
.tr-in.is-3d .tr-p.on {
  opacity: var(--ink, 1);
  filter: blur(calc((1 - var(--ink, 1)) * 2.4px));
  clip-path: inset(0 var(--cl, 0px));
}
/* The unroll drives the ink frame by frame; a CSS fade would trail it.
   Under reduced motion the sheet stays open and the fade is the change. */
@media (prefers-reduced-motion: no-preference) {
  .tr-in.is-3d .tr-p {
    transition: none;
  }
}
.tr-in.is-3d.v .tr-p.on {
  clip-path: inset(var(--cl, 0px) 0);
}
/* The app's book-opening masthead (ReaderMasthead, BOOK_OPENING_MASTHEAD):
   ornament, blackletter name, subtitle in rubric caps, chapter label. */
.tr-p .mast {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.tr-p .mast .row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.tr-p .mast .orn {
  width: 40px;
  height: 55px;
}
.tr-p .mast .orn.flip {
  transform: scaleX(-1);
}
.tr-p .ttl {
  margin: 0;
  font-family: var(--font-black);
  font-weight: 400;
  font-size: clamp(52px, 5vw, 68px);
  line-height: 1;
  color: var(--ink);
}
.tr-p .mast .sub {
  margin: 4px 0 0;
  font-family: var(--font-roman);
  font-size: 19px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.tr-p .mast .cap {
  margin: 0;
  font-family: var(--font-roman);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
}
.tr-p .vv {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: var(--font-body);
  font-size: 22px;
  line-height: 1.6;
  /* Ink sits in the parchment rather than on it. */
  mix-blend-mode: multiply;
}
.tr-p .vv p {
  margin: 0;
  text-wrap: pretty;
}
.tr-p sup {
  margin-right: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
}
.tr-p .cr {
  margin: auto 0 0;
  padding-top: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.55;
  color: var(--ink-3);
}

@media (max-width: 1100px) {
  .tr-in {
    padding: 0 32px;
    grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
    gap: 32px;
  }
  .tr-roll,
  .tr-roll:nth-child(3n + 2),
  .tr-roll:nth-child(3n) {
    width: calc(100% - 46px);
  }
  .tr-p {
    padding: 44px 40px 36px;
  }
}

/* Phones: two columns of rolls, then the sheet across the width, its rods
   above and below. */
@media (max-width: 699px) {
  .l-trans {
    padding: 72px 0 64px;
  }
  .tr-in {
    grid-template-columns: minmax(0, 1fr);
    padding: 0 16px;
    gap: 8px;
  }
  .tr-stack {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 14px;
    margin-top: 24px;
  }
  .tr-roll,
  .tr-roll:nth-child(3n + 2),
  .tr-roll:nth-child(3n) {
    width: 100%;
    height: 44px;
    --tilt: 0deg;
  }
  .tr-roll .tag {
    left: 38%;
    height: 26px;
    line-height: 26px;
    font-size: 12px;
  }
  /* Two rolls a row: the open one is not pulled sideways into its neighbour. */
  .tr-in:not(.is-3d) .tr-roll[aria-pressed="true"]::before {
    transform: none;
  }
  .tr-in:not(.is-3d) .tr-roll[aria-pressed="true"] .tag {
    --dx: 0px;
  }
  .tr-open {
    padding: 34px 22px;
  }
  .tr-rod {
    display: none;
  }
  .tr-sheet {
    width: 100%;
  }
  .tr-p {
    gap: 12px;
    padding: 30px 22px 26px;
  }
  .tr-p .ttl {
    font-size: 44px;
  }
  .tr-p .mast .orn {
    width: 30px;
    height: 41px;
  }
  .tr-p .mast .sub {
    font-size: 15px;
  }
  .tr-p .mast .cap {
    font-size: 21px;
  }
  .tr-p .vv {
    font-size: 18px;
    line-height: 1.6;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tr-roll::before,
  .tr-roll .tag {
    transition: none;
  }
}
