@import url('https://fonts.googleapis.com/css2?family=MedievalSharp&family=IM+Fell+English:ital@0;1&family=Fira+Code:wght@300;400&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --parchment-deep: #1a1408;
  --scroll-surface: #d4c5a0;
  --faded-ink: #2c2416;
  --gold-leaf: #c9a84c;
  --dried-blood: #6b2020;
  --ember-glow: #d4943a;
  --charcoal-ash: #0d0b07;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--charcoal-ash);
  color: var(--faded-ink);
  font-family: 'IM Fell English', serif;
  overflow-x: hidden;
  min-height: 100vh;
}

/* dark void background */
.void {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(26, 20, 8, 0.6) 0%, transparent 70%),
    var(--charcoal-ash);
  z-index: 0;
}

/* dust motes */
.dust {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.dust-mote {
  position: absolute;
  width: 3px;
  height: 3px;
  background: radial-gradient(circle, rgba(201, 168, 76, 0.4) 0%, transparent 70%);
  border-radius: 50%;
  animation: drift linear infinite;
}

@keyframes drift {
  0% { transform: translateY(100vh) translateX(0); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(-10vh) translateX(40px); opacity: 0; }
}

/* the scroll container */
.scroll-container {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
}

/* scroll body */
.scroll-body {
  position: relative;
  width: min(88vw, 660px);
  margin: 0 auto;
  background:
    url('../assets/parchment-texture.png') repeat,
    linear-gradient(180deg, #d4c5a0 0%, #c8b88e 50%, #d4c5a0 100%);
  background-blend-mode: multiply;
  padding: 60px 40px 80px;
  clip-path: inset(0 0 0 0);
  opacity: 0;
  transform: scaleY(0);
  transform-origin: top center;
  animation: unroll 2.2s cubic-bezier(0.22, 0.61, 0.36, 1) 0.8s forwards;
}

@keyframes unroll {
  0% {
    opacity: 1;
    transform: scaleY(0);
    clip-path: inset(0 0 100% 0);
  }
  30% {
    opacity: 1;
    transform: scaleY(1);
    clip-path: inset(0 0 70% 0);
  }
  100% {
    opacity: 1;
    transform: scaleY(1);
    clip-path: inset(0 0 0 0);
  }
}

/* scroll top roll */
.scroll-top {
  position: relative;
  width: min(94vw, 720px);
  margin: 0 auto;
  height: 50px;
  z-index: 3;
  opacity: 0;
  animation: fadeIn 0.6s ease 0.4s forwards;
}

.scroll-top-inner {
  width: 100%;
  height: 50px;
  background:
    linear-gradient(180deg,
      #8b7748 0%,
      #c8b88e 15%,
      #d4c5a0 30%,
      #b8a87a 50%,
      #a08c60 70%,
      #8b7748 85%,
      #6b5a38 100%
    );
  border-radius: 25px 25px 4px 4px;
  box-shadow:
    0 8px 30px rgba(0, 0, 0, 0.7),
    inset 0 -3px 6px rgba(0, 0, 0, 0.3),
    inset 0 3px 6px rgba(255, 255, 255, 0.15);
}

/* scroll bottom curl */
.scroll-bottom {
  position: relative;
  width: min(94vw, 720px);
  margin: 0 auto;
  height: 60px;
  z-index: 3;
  opacity: 0;
  animation: fadeIn 0.6s ease 2.8s forwards;
}

.scroll-bottom-inner {
  width: 100%;
  height: 60px;
  background:
    linear-gradient(0deg,
      #6b5a38 0%,
      #8b7748 20%,
      #a08c60 40%,
      #c8b88e 60%,
      #d4c5a0 75%,
      #b8a87a 90%,
      #a08c60 100%
    );
  border-radius: 4px 4px 30px 30px;
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.8),
    inset 0 3px 6px rgba(0, 0, 0, 0.2),
    inset 0 -4px 8px rgba(255, 255, 255, 0.1);
  transform: perspective(400px) rotateX(-8deg);
  transform-origin: top center;
}

/* scroll edge shadows */
.scroll-body::before,
.scroll-body::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 30px;
  z-index: 2;
  pointer-events: none;
}

.scroll-body::before {
  left: 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.15) 0%, transparent 100%);
}

.scroll-body::after {
  right: 0;
  background: linear-gradient(-90deg, rgba(0, 0, 0, 0.15) 0%, transparent 100%);
}

/* content elements */
.incantation {
  text-align: center;
  font-family: 'MedievalSharp', cursive;
  font-size: clamp(1.6rem, 5vw, 2.8rem);
  color: var(--faded-ink);
  line-height: 1.4;
  margin-bottom: 50px;
  opacity: 0;
  animation: inkBleed 1.8s ease 2.4s forwards;
  text-shadow: 1px 1px 2px rgba(44, 36, 22, 0.3);
}

@keyframes inkBleed {
  0% {
    opacity: 0;
    filter: blur(4px);
    letter-spacing: 0.3em;
  }
  40% {
    opacity: 0.6;
    filter: blur(2px);
    letter-spacing: 0.1em;
  }
  100% {
    opacity: 1;
    filter: blur(0);
    letter-spacing: 0.04em;
  }
}

/* QR seal */
.qr-seal {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 10px auto 40px;
  opacity: 0;
  animation: brandBurn 2s ease 3.2s forwards;
}

@keyframes brandBurn {
  0% {
    opacity: 0;
    filter: brightness(3) blur(8px);
    transform: scale(0.7);
  }
  30% {
    opacity: 0.8;
    filter: brightness(2) blur(3px);
    transform: scale(1.05);
  }
  60% {
    filter: brightness(1.3) blur(1px);
    transform: scale(0.98);
  }
  100% {
    opacity: 1;
    filter: brightness(1) blur(0);
    transform: scale(1);
  }
}

.qr-frame {
  position: relative;
  padding: 18px;
  border-radius: 16px;
  background:
    radial-gradient(circle, var(--dried-blood) 0%, #4a1515 100%);
  box-shadow:
    0 0 40px rgba(201, 168, 76, 0.15),
    0 0 80px rgba(107, 32, 32, 0.2),
    inset 0 0 20px rgba(0, 0, 0, 0.4);
  border: 3px solid var(--gold-leaf);
  transition: box-shadow 0.4s ease;
}

.qr-frame:hover {
  box-shadow:
    0 0 60px rgba(212, 148, 58, 0.3),
    0 0 120px rgba(107, 32, 32, 0.3),
    inset 0 0 20px rgba(0, 0, 0, 0.4);
}

.qr-frame img {
  display: block;
  width: clamp(180px, 45vw, 280px);
  height: clamp(180px, 45vw, 280px);
  border-radius: 4px;
  object-fit: contain;
  filter: sepia(0.2) contrast(1.1);
}

/* inscription link */
.inscription {
  text-align: center;
  margin: 30px auto 50px;
  opacity: 0;
  animation: fadeIn 1.2s ease 4.4s forwards;
}

.inscription a {
  font-family: 'Fira Code', monospace;
  font-size: clamp(0.65rem, 2vw, 0.85rem);
  font-weight: 300;
  color: var(--faded-ink);
  text-decoration: none;
  letter-spacing: 0.05em;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(44, 36, 22, 0.3);
  transition: color 0.5s ease, border-color 0.5s ease, text-shadow 0.5s ease;
  word-break: break-all;
}

.inscription a:hover {
  color: var(--ember-glow);
  border-color: var(--ember-glow);
  text-shadow: 0 0 20px rgba(212, 148, 58, 0.4);
}

/* closing text */
.closing {
  text-align: center;
  font-family: 'IM Fell English', serif;
  font-style: italic;
  font-size: clamp(1rem, 3vw, 1.4rem);
  color: var(--faded-ink);
  opacity: 0;
  animation: fadeIn 1.5s ease 5s forwards;
  letter-spacing: 0.08em;
  margin-top: 20px;
}

/* ornament dividers */
.ornament {
  text-align: center;
  font-size: 1.4rem;
  color: var(--gold-leaf);
  opacity: 0;
  animation: fadeIn 1s ease 4s forwards;
  margin: 20px 0;
  letter-spacing: 0.5em;
}

@keyframes fadeIn {
  to { opacity: 1; }
}

/* subtle grain overlay on scroll */
.scroll-body .grain {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 1;
  mix-blend-mode: multiply;
}

/* responsive */
@media (max-width: 480px) {
  .scroll-body {
    padding: 40px 24px 60px;
  }

  .qr-frame {
    padding: 12px;
    border-width: 2px;
  }
}
