@font-face {
  font-family: "Marck Script";
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url("assets/fonts/marck-script-cyrillic-400-normal.woff2") format("woff2");
  unicode-range: U+0400-052F, U+2116;
}

@font-face {
  font-family: "Marck Script";
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url("assets/fonts/marck-script-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC;
}

:root {
  color-scheme: dark;
  --paper-w: min(92vw, 97.1vh);
  --paper-h: 100vh;
  --side: calc((100vw - var(--paper-w)) / 2);
  --paper-margin-y: calc((100vh - var(--paper-h)) / 2);
  --calligraphy-font: "Marck Script", "Horus Calligraphy", "Monotype Corsiva", "Segoe Script", "URW Chancery L", "Apple Chancery", cursive;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #1a0b04;
}

body {
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

button {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}

.lyric-page {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  isolation: isolate;
  background: #1a0b04;
}

.tabletop {
  position: absolute;
  z-index: 0;
  top: 0;
  left: min(0px, calc(var(--side) - (100vw - var(--side)) * .3762));
  display: block;
  width: max(100vw, calc((100vw - var(--side)) / .7266));
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.paper-stage {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: calc(50% + var(--paper-w) * .0135);
  width: var(--paper-w);
  height: var(--paper-h);
  transform: translate(-50%, -50%);
  filter: drop-shadow(1.1vh .7vh 1.2vh rgba(0, 0, 0, .28));
}

.paper {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.paper-content {
  position: absolute;
  z-index: 3;
  top: 7.6%;
  right: 12%;
  bottom: 22%;
  left: 12%;
  min-height: 0;
  overflow: hidden;
  color: #140b05;
  font-family: var(--calligraphy-font);
  font-synthesis: weight;
  font-size: clamp(1rem, calc(var(--paper-w) * .034), 1.85rem);
  font-weight: 600;
  line-height: 1.28;
  text-shadow: 0 1px rgba(255, 248, 226, .2);
  user-select: text;
  -webkit-user-select: text;
}

.content-inner {
  width: 100%;
  min-height: 0;
}

.contents-view {
  display: flex;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2% 1% 7%;
}

.section-kicker,
.contents-title,
.contents-list,
.contents-meta,
.poem-title,
.poem-author,
.poem-stanza {
  margin-top: 0;
}

.section-kicker {
  margin-bottom: .42em;
  font-size: .7em;
  font-weight: 700;
  letter-spacing: .08em;
  opacity: .74;
}

.contents-title {
  margin-bottom: 1em;
  font-size: 1.5em;
  line-height: 1.06;
  font-weight: 700;
  letter-spacing: .02em;
  text-align: center;
}

.contents-list {
  display: grid;
  width: min(100%, 28em);
  margin-bottom: 0;
  padding-left: 0;
  gap: .9em;
  list-style: none;
  counter-reset: lyric-contents;
}

.contents-list li { counter-increment: lyric-contents; }

.contents-link {
  position: relative;
  display: grid;
  width: 100%;
  grid-template-columns: 2em minmax(0, 1fr);
  grid-template-areas:
    "number name"
    "number meta";
  column-gap: .5em;
  align-items: center;
  color: #140b05;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.contents-link::before {
  content: counter(lyric-contents, decimal-leading-zero);
  grid-area: number;
  align-self: stretch;
  padding-top: .12em;
  border-right: 1px solid rgba(52, 28, 12, .38);
  font-size: .72em;
  font-variant-numeric: tabular-nums;
  opacity: .68;
}

.contents-name {
  grid-area: name;
  font-size: 1.08em;
  font-weight: 700;
  letter-spacing: .012em;
}

.contents-meta {
  grid-area: meta;
  margin-bottom: 0;
  font-size: .68em;
  font-style: italic;
  font-weight: 600;
  letter-spacing: .018em;
  opacity: .72;
}

.contents-link:hover .contents-name,
.contents-link:focus-visible .contents-name {
  color: #74260e;
  text-decoration: underline;
  text-decoration-color: rgba(116, 38, 14, .58);
  text-underline-offset: .16em;
}

.contents-link:focus-visible {
  outline: 1px solid rgba(77, 38, 15, .56);
  outline-offset: .3em;
}

.poem-view {
  display: flex;
  height: 100%;
  min-height: 0;
  flex-direction: column;
}

.poem-header {
  flex: 0 0 auto;
  padding: 0 2% .62em;
  text-align: center;
}

.poem-title {
  margin-bottom: .14em;
  font-size: 1.5em;
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: .012em;
}

.poem-author {
  margin-bottom: 0;
  font-size: .72em;
  font-style: italic;
  font-weight: 600;
  letter-spacing: .035em;
  opacity: .72;
}

.poem-body {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  margin: 0;
  padding: .28em 0 1em;
  overflow-x: hidden;
  overflow-y: auto;
  color: #140b05;
  font-size: var(--poem-font-size, 1em);
  font-weight: 700;
  line-height: 1.28;
  letter-spacing: .006em;
  scrollbar-width: thin;
  scrollbar-color: #8a4f20 rgba(62, 29, 10, .2);
  touch-action: pan-y;
  overscroll-behavior: contain;
}

.poem-body::-webkit-scrollbar {
  width: clamp(8px, .48em, 12px);
  height: 0;
}

.poem-body::-webkit-scrollbar-track {
  border-left: 1px solid rgba(80, 42, 16, .24);
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(58, 26, 8, .08),
    rgba(58, 26, 8, .24),
    rgba(58, 26, 8, .08)
  );
  box-shadow: inset 0 0 .18em rgba(36, 14, 3, .24);
}

.poem-body::-webkit-scrollbar-thumb {
  min-height: 34px;
  border: 2px solid rgba(240, 201, 116, .34);
  border-radius: 999px;
  background: linear-gradient(90deg, #4f2810 0%, #a5652c 48%, #51280f 100%);
  box-shadow:
    inset 0 0 .16em rgba(255, 224, 151, .55),
    0 0 .12em rgba(46, 18, 4, .42);
}

.poem-body::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(90deg, #613015 0%, #c4833c 48%, #633116 100%);
}

.poem-body::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

.poem-body:focus-visible {
  outline: 1px solid rgba(77, 38, 15, .34);
  outline-offset: -.2em;
}

.poem-axis {
  position: relative;
  left: var(--poem-axis-shift, 0px);
  width: var(--poem-axis-width, max-content);
  max-width: none;
  margin-inline: auto;
}

.poem-stanza {
  width: 100%;
  margin-bottom: .78em;
  text-align: left;
}

.poem-stanza:last-child { margin-bottom: 0; }

.poem-line {
  display: block;
  white-space: nowrap;
}

.visual-object {
  position: absolute;
  z-index: 4;
  overflow: visible;
}

.object-state {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.object-hot,
.object-animation { opacity: 0; }

.visual-object.is-active .object-idle { opacity: 1; }
.visual-object.is-active .object-hot { opacity: 0; transform: none; }
.visual-object.is-active.animation-ready .object-idle { opacity: 0; }
.visual-object.is-active.animation-ready .object-hot { opacity: 0; }
.visual-object.is-active.animation-ready .object-animation { opacity: 1; }
.visual-object.animation-failed.is-active .object-animation { opacity: 0; }
.visual-object.animation-failed.is-active .object-idle { opacity: 0; }
.visual-object.animation-failed.is-active .object-hot { opacity: 1; }

.object-idle,
.object-hot {
  transform: none;
  transition: none;
}

.object-animation {
  position: absolute;
  z-index: 2;
  left: var(--animation-left, 0);
  top: var(--animation-top, 0);
  display: block;
  width: var(--animation-width, 100%);
  height: var(--animation-height, 100%);
  object-fit: fill;
  pointer-events: none;
  transform: none;
  transform-origin: 50% 50%;
  transition: none;
}

.object-hit {
  position: absolute;
  z-index: 20;
  cursor: pointer;
  background: transparent;
}

.candle {
  z-index: 7;
  --animation-left: -11.44%;
  --animation-top: -10.97%;
  --animation-width: 122.65%;
  --animation-height: 120.61%;
  left: 1.5vw;
  top: 1.2vh;
  width: min(32vh, calc(var(--side) - 1.5vw));
  aspect-ratio: 400 / 450;
}

.candle .object-animation,
.candle .object-hot { transform-origin: 0 0; }

.candle-hit {
  left: 6%;
  top: 5%;
  width: 88%;
  height: 88%;
  border-radius: 50%;
}

.feather {
  z-index: 8;
  --feather-w: min(51.5vw, 111vh);
  --animation-left: -4.23%;
  --animation-top: -17.93%;
  --animation-width: 107.78%;
  --animation-height: 138.89%;
  left: 1vw;
  bottom: calc(var(--paper-margin-y) + 2.5vh);
  width: var(--feather-w);
  height: calc(var(--feather-w) * .216667);
  transform: rotate(1.8deg);
  transform-origin: 82% 52%;
}

.feather::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: max(28%, calc(var(--side) - 1vw));
  right: -1%;
  top: 54%;
  height: 17%;
  border-radius: 50%;
  background: radial-gradient(
    ellipse at 58% 50%,
    rgba(24, 10, 3, .68) 0%,
    rgba(24, 10, 3, .62) 38%,
    rgba(24, 10, 3, .28) 64%,
    rgba(24, 10, 3, 0) 82%
  );
  filter: blur(calc(var(--feather-w) * .011));
  transform: translate(
    calc(var(--feather-w) * .018),
    calc(var(--feather-w) * .052)
  ) skewX(16deg);
  pointer-events: none;
  transition: opacity 80ms linear;
}

.feather.is-active::before { opacity: 1; }

.feather .object-animation,
.feather .object-hot { transform-origin: 0 100%; }

.feather .object-state {
  filter: drop-shadow(
    calc(var(--feather-w) * .004)
    calc(var(--feather-w) * .009)
    calc(var(--feather-w) * .006)
    rgba(18, 7, 2, .42)
  );
}

.feather-hit {
  inset: 4% 1% 4% 0;
  clip-path: polygon(0 18%, 52% 4%, 100% 32%, 100% 73%, 48% 91%, 0 98%);
}

.medallion {
  z-index: 5;
  --animation-left: -8.44%;
  --animation-top: -5.69%;
  --animation-width: 117.72%;
  --animation-height: 112.27%;
  left: calc(50% + var(--paper-w) / 2 + .6vw);
  top: 1.2vh;
  width: min(42vh, calc(var(--side) - 1.2vw));
  aspect-ratio: 716 / 1005;
}

.medallion-hit {
  left: 0;
  top: 17%;
  width: 62%;
  height: 70%;
  border-radius: 44%;
}

.medallion .object-animation {
  right: auto;
  transform-origin: 100% 0;
}

.medallion .object-hot { transform-origin: 100% 0; }

.seal {
  z-index: 9;
  left: calc(50% + var(--paper-w) / 2 - 6vh);
  bottom: var(--paper-margin-y);
  width: min(26vh, 18vw);
  aspect-ratio: 620 / 650;
  transform: translateX(-50%);
}

.seal.is-active .object-hot {
  opacity: 1;
  transform: none;
  animation: seal-hover-glow 900ms ease-in-out infinite alternate;
}

.seal.is-active .object-idle { opacity: 0; }

@keyframes seal-hover-glow {
  from { filter: brightness(1); }
  to { filter: brightness(1.18) drop-shadow(0 0 .5vh rgba(255, 190, 72, .7)); }
}

.page-transition {
  position: fixed;
  z-index: 30;
  left: calc(50% + var(--paper-w) * .0135);
  top: calc(50% - var(--paper-h) * 3 / 708);
  display: none;
  /* The full 1248x720 source is scaled from its 545px-wide source sheet.
     This makes the animated sheet exactly coincide with the static sheet,
     while the fog continues beyond it and covers the surrounding objects. */
  width: calc(var(--paper-w) * 1248 / 546);
  height: calc(var(--paper-h) * 720 / 708);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.page-transition-video {
  position: absolute;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.page-transition-video.is-active { display: block; }

body.is-page-transitioning .page-transition { display: block; }
body.is-page-transitioning .paper-content { visibility: hidden; }
body.is-page-transitioning.transition-content-ready .paper-content { visibility: visible; }
body.is-page-transitioning .object-hit { pointer-events: none; }
body.is-page-transitioning .feather { z-index: 31; }

.seal-hit {
  left: 15%;
  top: 3%;
  width: 65%;
  height: 59%;
  border-radius: 50%;
}

.blotter {
  z-index: 6;
  --animation-left: -7.46%;
  --animation-top: -8.99%;
  --animation-width: 114.92%;
  --animation-height: 117.63%;
  right: 1.2vw;
  bottom: calc(var(--paper-margin-y) + 2vh);
  width: min(43vh, calc(var(--side) - 3vw));
  aspect-ratio: 1020 / 832;
}

.blotter-hit {
  inset: 0;
  clip-path: polygon(2% 43%, 68% 0, 100% 26%, 86% 100%, 58% 91%, 41% 65%, 0 63%);
}

.blotter .object-animation,
.blotter .object-hot { transform-origin: 100% 100%; }

.blotter .object-animation {
  right: auto;
}

.visual-object.is-disabled .object-hit,
.object-hit:disabled {
  cursor: default;
}

.site-animations-off .object-animation { display: none; }
.site-animations-off .visual-object.is-active .object-hot,
.site-animations-off .visual-object.is-active.animation-ready .object-hot {
  opacity: 1;
  transform: none;
  animation: none;
}

@media (max-aspect-ratio: 4 / 5) {
  .paper-content {
    top: 7.5%;
    right: 7%;
    bottom: 21%;
    left: 7%;
  }

  .contents-view { padding-inline: 0; }
  .contents-list { gap: .68em; }
  .poem-header { padding-inline: 1%; }

  .candle {
    left: 1vw;
    top: 1vw;
    width: 20vw;
  }

  .medallion {
    left: auto;
    right: 1vw;
    top: 1vw;
    width: 22vw;
  }

  .blotter {
    right: 1vw;
    bottom: 17vh;
    width: 25vw;
  }

  .seal {
    left: auto;
    right: 0;
    bottom: var(--paper-margin-y);
    width: min(16vh, 20vw);
    transform: none;
  }

  .feather {
    --feather-w: 63vw;
    left: 1vw;
    bottom: calc(var(--paper-margin-y) + 2.5vh);
  }
}

@media (max-height: 480px) {
  .candle { width: min(31vh, calc(var(--side) - 5vw)); }
  .medallion { width: min(39vh, calc(var(--side) - 6vw)); }
  .blotter { width: min(39vh, calc(var(--side) - 5vw)); }
  .paper-content { font-size: clamp(.9rem, calc(var(--paper-w) * .05), 1.22rem); }
  .contents-title { margin-bottom: .55em; }
  .contents-list { gap: .4em; }
  .poem-header { padding-bottom: .3em; }
  .poem-stanza { margin-bottom: .54em; }
}

@media (prefers-reduced-motion: reduce) {
  .object-animation { display: none; }
  .visual-object.is-active .object-hot,
  .visual-object.is-active.animation-ready .object-hot {
    opacity: 1;
    transform: none;
    animation: none;
  }
  .feather.is-active::before { opacity: 1; }
}


/* PERFORMANCE LYRIC R1: on touch screens avoid compositing an expensive paper
   shadow continuously. The geometry and artwork stay unchanged. */
@media (pointer: coarse), (max-width: 900px) {
  .paper-stage { filter: none; }
  .object-animation { will-change: auto; }
}
