/* Fonts are loaded via <link> in story.html (no render-blocking @import). */

/* Base styles for story page */
* {
  margin: 0;
  padding: 0;
  color: #ffffff;
}

body {
  background: #000000;
  font-family: "Lato", sans-serif;
  width: 100%;
  margin: 0;
  padding: 0;
  color: #ffffff;
  min-height: 100vh;
}

/* Story Container */
.story-container {
  transition: opacity 1s ease;
}

.story-container--hidden {
  opacity: 0;
}

/* Hero Introduction */
.hero-intro {
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  width: 100%;
}

/* Spider Tag Styles */
.spider-tag-large {
  padding: 1.6rem 6.5rem 12.5rem;
  border-radius: 44px;
  font-size: 2rem;
  color: #fff;
  background: #ee2737; /* classic "HELLO my name is" sticker red, flat like the film */
  text-align: center;
  font-family: "Lato", sans-serif;
  font-weight: 900;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.45),
    0 18px 48px rgba(238, 39, 55, 0.22);
  position: relative;
  line-height: normal;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  animation: heroAppear 2s ease-out forwards;
}

.spider-tag-large br {
  display: none; /* keep HELLO / my name is tight, like the sticker */
}

.spider-tag-large strong {
  display: block;
  text-transform: uppercase;
  font-size: 4.2rem;
  line-height: 1;
  letter-spacing: 0.01em;
}

.spider-tag-large p {
  font-size: 1.9rem;
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: 0.01em;
}

/* ambient Spider-Verse glitch — starts after the intro settles */
.spider-tag-large.loaded {
  animation: spiderGlitch 3s infinite;
}

@keyframes spiderGlitch {
  0%, 38%, 46%, 86%, 97%, 100% {
    filter: none;
  }
  /* first burst — quick stutter */
  40% {
    filter: drop-shadow(-8px 0 0 rgba(0, 255, 255, 0.9)) drop-shadow(8px 0 0 rgba(255, 0, 90, 0.9));
  }
  42% {
    filter: drop-shadow(6px 0 0 rgba(0, 255, 255, 0.9)) drop-shadow(-6px 0 0 rgba(255, 0, 90, 0.9)) saturate(2) contrast(1.2) hue-rotate(-12deg);
  }
  44% {
    filter: drop-shadow(-3px 0 0 rgba(0, 255, 255, 0.7)) drop-shadow(3px 0 0 rgba(255, 0, 90, 0.7));
  }
  /* second burst — the big one */
  88% {
    filter: drop-shadow(10px 0 0 rgba(0, 255, 255, 0.95)) drop-shadow(-10px 0 0 rgba(255, 0, 90, 0.95)) saturate(1.8);
  }
  90% {
    filter: drop-shadow(-7px 2px 0 rgba(0, 255, 255, 0.9)) drop-shadow(7px -2px 0 rgba(255, 0, 90, 0.9)) contrast(1.35) hue-rotate(10deg);
  }
  93% {
    filter: drop-shadow(4px -1px 0 rgba(0, 255, 255, 0.75)) drop-shadow(-4px 1px 0 rgba(255, 0, 90, 0.75));
  }
  95% {
    filter: drop-shadow(-2px 0 0 rgba(0, 255, 255, 0.5)) drop-shadow(2px 0 0 rgba(255, 0, 90, 0.5));
  }
}

/* the tag's own lettering physically jolts (children, so the 3D hover on the card is untouched) */
.spider-tag-large.loaded strong,
.spider-tag-large.loaded p {
  animation: textJolt 3s infinite;
}

.spider-tag-large.loaded p {
  animation-delay: 0.05s; /* slightly out of sync — more broken-signal */
}

@keyframes textJolt {
  0%, 38%, 46%, 86%, 97%, 100% {
    transform: none;
  }
  40% { transform: translateX(-4px) skewX(-3deg); }
  42% { transform: translateX(5px); }
  44% { transform: translateX(-2px); }
  88% { transform: translateX(6px) skewX(4deg); }
  91% { transform: translateX(-5px); }
  94% { transform: translateX(2px); }
}

/* the signature splits too, on the same clock */
.spider-tag-large.loaded:after {
  animation: nameGlitch 3s infinite;
}

@keyframes nameGlitch {
  0%, 38%, 46%, 86%, 97%, 100% {
    text-shadow: none;
    transform: rotate(-1deg);
  }
  40% {
    text-shadow: -6px 0 0 rgba(0, 255, 255, 0.9), 6px 0 0 rgba(255, 0, 90, 0.9);
    transform: rotate(-1deg) translateX(5px);
  }
  42% {
    text-shadow: 5px 0 0 rgba(0, 255, 255, 0.9), -5px 0 0 rgba(255, 0, 90, 0.9);
    transform: rotate(-1deg) translateX(-6px) skewX(-6deg);
  }
  44% {
    text-shadow: -3px 0 0 rgba(0, 255, 255, 0.7), 3px 0 0 rgba(255, 0, 90, 0.7);
    transform: rotate(-1deg) translateX(2px);
  }
  88% {
    text-shadow: -7px 0 0 rgba(0, 255, 255, 0.95), 7px 0 0 rgba(255, 0, 90, 0.95);
    transform: rotate(-1deg) translateX(-7px) skewX(5deg) scaleY(1.04);
  }
  91% {
    text-shadow: 6px 0 0 rgba(0, 255, 255, 0.9), -6px 0 0 rgba(255, 0, 90, 0.9);
    transform: rotate(-1deg) translateX(6px);
  }
  94% {
    text-shadow: -3px 1px 0 rgba(0, 255, 255, 0.7), 3px -1px 0 rgba(255, 0, 90, 0.7);
    transform: rotate(-1deg) translateX(-2px);
  }
}

.spider-tag-large:before {
  content: "";
  position: absolute;
  top: 8.6rem;
  left: 0.9rem;
  right: 0.9rem;
  bottom: 0.9rem;
  background: #fff;
  border-radius: 26px 26px 34px 34px;
}

.spider-tag-large:after {
  content: "Priyam Raj";
  position: absolute;
  top: 11.6rem;
  left: 0;
  width: 100%;
  text-align: center;
  font-family: "Rock Salt", cursive;
  font-size: 2.5rem;
  letter-spacing: 0.2rem;
  font-weight: bold;
  color: #000;
  transform: rotate(-1deg);
}

@keyframes heroAppear {
  0% {
    transform: scale(0.3) rotateY(360deg);
    opacity: 0;
    filter: hue-rotate(180deg) blur(5px);
  }
  30% {
    transform: scale(0.8) rotateY(180deg);
    opacity: 0.5;
    filter: hue-rotate(90deg) blur(2px);
  }
  60% {
    transform: scale(1.2) rotateY(0deg);
    opacity: 0.8;
    filter: hue-rotate(45deg) blur(1px);
  }
  80% {
    transform: scale(0.9) rotateY(-10deg);
    opacity: 0.9;
    filter: hue-rotate(0deg) blur(0px);
  }
  100% {
    transform: scale(1) rotateY(0deg);
    opacity: 1;
    filter: hue-rotate(0deg) blur(0px);
  }
}

/* Alive ticker — a quiet reminder that the clock is running */
.alive-note {
  margin-top: 3rem;
  font-family: "Permanent Marker", cursive;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  opacity: 0;
  animation: aliveFade 1.2s ease 2.4s forwards;
}

.alive-note span {
  font-family: "Lato", sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  color: #eb1d36;
  text-shadow: -1px 0 rgba(0, 255, 255, 0.5), 1px 0 rgba(255, 0, 90, 0.4);
}

@keyframes aliveFade {
  to { opacity: 0.6; }
}

/* Scroll Indicator */
.scroll-indicator {
  position: absolute;
  bottom: 2rem;
  text-align: center;
  animation: bounce 2s infinite;
}

.scroll-arrow {
  font-size: 2rem;
  animation: pulse 1.5s infinite;
  text-shadow: -2px 0 rgba(0, 255, 255, 0.6), 2px 0 rgba(255, 0, 90, 0.6);
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

/* Story Chapters */
.story-chapter {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
}

.chapter-content {
  max-width: 800px;
  text-align: center;
}

/* Comic Title */
.comic-title {
  display: inline-block;
  margin: 2rem auto;
  padding: 1rem 2.5rem;
  position: relative;
  font-family: "Bangers", cursive;
  font-size: 2.1rem;
  font-weight: normal;
  text-transform: uppercase;
  letter-spacing: 0.2rem;
  color: #000;
  text-align: center;
  background: 
    radial-gradient(circle, #000 1px, transparent 1px),
    #ffffff;
  background-size: 8px 8px;
  background-position: 0 0, 4px 4px;
  border: 3px solid #000;
  border-radius: 8px;
  box-shadow: 4px 4px 0px #000;
  transition: transform 0.2s ease;
}

.comic-title:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0px #000;
}

/* chapter titles catch multiverse interference on staggered clocks */
.comic-title--chapter {
  animation: titleGlitch 5s infinite;
}

.early-chapter .comic-title--chapter { animation-delay: 1.2s; }
.creative-chapter .comic-title--chapter { animation-delay: 2.5s; }
.timeline-intro-chapter .comic-title--chapter { animation-delay: 3.7s; }

@keyframes titleGlitch {
  0%, 88%, 95.5%, 100% {
    filter: none;
  }
  89.5% {
    filter: drop-shadow(-5px 0 0 rgba(0, 255, 255, 0.8)) drop-shadow(5px 0 0 rgba(255, 0, 90, 0.8));
  }
  91.5% {
    filter: drop-shadow(4px 0 0 rgba(0, 255, 255, 0.7)) drop-shadow(-4px 0 0 rgba(255, 0, 90, 0.7)) contrast(1.2);
  }
  93.5% {
    filter: drop-shadow(-2px 0 0 rgba(0, 255, 255, 0.5)) drop-shadow(2px 0 0 rgba(255, 0, 90, 0.5));
  }
}

.comic-title--chapter {
  background: 
    radial-gradient(circle, #333 1px, transparent 1px),
    #f9f9f9;
  background-size: 6px 6px;
}

/* Story Text — comic-book body lettering */
.story-text {
  font-size: 1.3rem;
  line-height: 1.65;
  margin-bottom: 2rem;
  text-align: left;
  max-width: 600px;
  margin-left: 0;
  margin-right: auto;
  opacity: 0.95;
  font-family: "Comic Neue", "Lato", sans-serif;
  font-weight: 700;
  text-transform: none;
}

/* Story Overlay Effects */
.story-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 1000;
  opacity: 1;
  transition: opacity 1s ease;
}

/* Portal Effect */
.portal-effect {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0;
  height: 0;
  border-radius: 50%;
  background: radial-gradient(circle, #eb1d36, #000);
  z-index: 998;
  opacity: 0;
}

.portal-expand {
  animation: portalExpand 2s ease-out forwards;
}

@keyframes portalExpand {
  0% {
    width: 0;
    height: 0;
    opacity: 1;
  }
  50% {
    width: 200vw;
    height: 200vw;
    opacity: 0.8;
  }
  100% {
    width: 300vw;
    height: 300vw;
    opacity: 0;
  }
}

/* Web Lines */
.web-lines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 997;
  opacity: 0;
}

.web-lines::before,
.web-lines::after {
  content: "";
  position: absolute;
  background: linear-gradient(45deg, transparent 48%, #fff 49%, #fff 51%, transparent 52%);
  background-size: 50px 50px;
  animation: webMove 3s linear infinite;
}

.web-lines::before {
  width: 200%;
  height: 200%;
  top: -50%;
  left: -50%;
}

.web-lines::after {
  width: 200%;
  height: 200%;
  top: -50%;
  left: -50%;
  background: linear-gradient(-45deg, transparent 48%, #fff 49%, #fff 51%, transparent 52%);
  background-size: 50px 50px;
  animation-direction: reverse;
}

@keyframes webMove {
  0% {
    transform: translate(0, 0);
  }
  100% {
    transform: translate(50px, 50px);
  }
}

/* Comic Dots */
.comic-dots {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: radial-gradient(circle, #eb1d36 1px, transparent 1px);
  background-size: 20px 20px;
  opacity: 0;
  z-index: 996;
  pointer-events: none;
  animation: comicFade 0.5s ease-out forwards;
}

@keyframes comicFade {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 0.2;
  }
  100% {
    opacity: 0;
  }
}

/* Speed Lines */
.speed-lines {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 200%;
  height: 200%;
  transform: translate(-50%, -50%);
  background: radial-gradient(ellipse at center, transparent 0%, transparent 40%, rgba(255,255,255,0.1) 40%, transparent 42%);
  background-size: 100% 100%;
  z-index: 995;
  opacity: 0;
  pointer-events: none;
}

.speed-burst {
  animation: speedBurst 0.8s ease-out forwards;
}

@keyframes speedBurst {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(3);
    opacity: 0;
  }
}

/* Polaroids */
.story-polaroids {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 3rem;
  flex-wrap: wrap;
}

.story-polaroid {
  width: 300px;
  height: 350px;
  background-color: #fff;
  padding: 1rem;
  box-shadow: 0 0.2rem 1.2rem rgba(0, 0, 0, 0.2);
  filter: grayscale(80%);
  transition: filter 0.3s ease, transform 0.3s ease;
  transform: rotate(var(--rotation, 0deg));
  position: relative;
  overflow: visible;
}

.story-polaroid:nth-child(1) { --rotation: -3deg; }
.story-polaroid:nth-child(2) { --rotation: 2deg; }
.story-polaroid:nth-child(3) { --rotation: -1deg; }

.story-polaroid:hover {
  filter: grayscale(0%);
  transform: rotate(0deg) scale(1.05);
  z-index: 10;
}

/* occasional random interference — JS picks one visible polaroid at a time */
.story-polaroid.glitch-hit {
  animation: polaroidGlitch 0.3s steps(2) 1;
}

@keyframes polaroidGlitch {
  0% {
    filter: grayscale(80%) drop-shadow(-5px 0 0 rgba(0, 255, 255, 0.75)) drop-shadow(5px 0 0 rgba(255, 0, 90, 0.75));
  }
  60% {
    filter: grayscale(80%) drop-shadow(4px 0 0 rgba(0, 255, 255, 0.55)) drop-shadow(-4px 0 0 rgba(255, 0, 90, 0.55));
  }
  100% {
    filter: grayscale(80%);
  }
}

.story-polaroid-image {
  height: 250px;
  width: 100%;
  overflow: hidden;
  padding-bottom: 5px;
}

.story-polaroid-image img {
  height: 100%;
  width: 100%;
  display: block;
  object-fit: cover;
}

.story-polaroid-caption {
  font-family: "Permanent Marker";
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 14px;
  padding-top: 10px;
  color: #000;
  text-align: center;
  line-height: 1.2;
  text-transform: lowercase;
}

.story-polaroid-date {
  font-family: "Permanent Marker";
  font-size: 11px;
  color: #6b6b6b;
  text-align: center;
  padding-top: 4px;
  text-transform: lowercase;
}

/* Duct tape effects for polaroids */
.story-polaroid::before,
.story-polaroid::after {
  content: '';
  position: absolute;
  background: linear-gradient(135deg, rgba(196, 196, 196, 0.7) 0%, rgba(168, 168, 168, 0.8) 50%, rgba(154, 154, 154, 0.9) 100%);
  border: 1px solid rgba(136, 136, 136, 0.6);
  border-radius: 2px;
  box-shadow: 
    inset 0 1px 0 rgba(255,255,255,0.4),
    0 3px 6px rgba(0,0,0,0.2);
  z-index: 10;
  opacity: 0.85;
}

/* Random tape patterns */
.story-polaroid:nth-child(1)::before {
  top: -15px;
  right: 10px;
  width: 80px;
  height: 30px;
  transform: rotate(18deg);
}
.story-polaroid:nth-child(1)::after {
  bottom: -12px;
  left: 5px;
  width: 65px;
  height: 25px;
  transform: rotate(-15deg);
}

.story-polaroid:nth-child(2)::before {
  top: 25px;
  left: -18px;
  width: 35px;
  height: 90px;
  transform: rotate(-5deg);
}
.story-polaroid:nth-child(2)::after {
  top: 35px;
  right: -15px;
  width: 30px;
  height: 80px;
  transform: rotate(8deg);
}

.story-polaroid:nth-child(3)::before {
  top: -12px;
  left: 50%;
  transform: translateX(-50%) rotate(-8deg);
  width: 80px;
  height: 30px;
}
.story-polaroid:nth-child(3)::after {
  bottom: -10px;
  right: 30px;
  width: 60px;
  height: 25px;
  transform: rotate(22deg);
}

/* Closing — comic sign-off */
.tbc-title {
  font-family: "Bangers", cursive;
  font-size: 2.4rem;
  letter-spacing: 0.12em;
  margin-bottom: 0.2rem;
  text-shadow: -2px 0 rgba(0, 255, 255, 0.5), 2px 0 rgba(255, 0, 90, 0.5);
}

.tbc-note {
  font-family: "Permanent Marker", cursive;
  font-size: 0.95rem;
  opacity: 0.7;
  margin-bottom: 2.2rem;
  text-transform: lowercase;
}

/* Closing links */
.closing-links {
  display: flex;
  gap: 2rem;
  justify-content: center;
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.closing-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.1rem 2.4rem;
  background: #000000;
  border: 3px solid #ffffff;
  border-radius: 10px;
  color: #ffffff;
  text-decoration: none;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
  box-shadow: 5px 5px 0px #ffffff;
  position: relative;
  transform: rotate(-1.5deg);
}

.closing-link:nth-child(2) {
  transform: rotate(1.5deg);
}

.closing-link:hover {
  background: #eb1d36;
  transform: rotate(0deg) translate(-2px, -2px);
  box-shadow: 7px 7px 0px #ffffff, 0 14px 34px rgba(235, 29, 54, 0.35);
}

.closing-link:hover .link-title {
  text-shadow: -2px 0 rgba(0, 255, 255, 0.8), 2px 0 rgba(255, 0, 90, 0.8);
}

.link-title {
  font-family: "Bangers", cursive;
  font-size: 1.4rem;
  font-weight: normal;
  line-height: 1.2;
  letter-spacing: 0.1em;
}

.link-subtitle {
  font-family: "Lato", sans-serif;
  font-size: 0.8rem;
  opacity: 0.7;
  margin-top: 0.25rem;
  font-style: italic;
  text-transform: lowercase;
}

/* Reflection — a quiet memo to my future self */
.story-reflection-section {
  position: relative;
  display: flex;
  justify-content: center;
  padding: 4rem 2rem 2rem;
}

.story-reflection-section::before {
  content: "✳";
  position: absolute;
  transform: translateY(-2.5rem);
  font-size: 1rem;
  opacity: 0.4;
}

.story-reflection-section .story-text {
  max-width: 34rem;
  margin: 0 auto;
  text-align: center;
  font-family: "Permanent Marker", cursive;
  font-size: 0.95rem;
  line-height: 2.1;
  opacity: 0.65;
}

/* Back to main */
.back-to-main {
  text-align: center;
  margin: 2rem 0 2rem 0;
}

.back-link {
  color: #ffffff;
  text-decoration: none;
  font-family: "Permanent Marker", cursive;
  font-size: 0.95rem;
  opacity: 0.6;
  transition: opacity 0.3s ease;
  text-transform: lowercase;
}

.back-link:hover {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .spider-tag-large.loaded,
  .spider-tag-large.loaded:after,
  .spider-tag-large.loaded strong,
  .spider-tag-large.loaded p,
  .comic-title--chapter,
  .story-polaroid.glitch-hit {
    animation: none;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .spider-tag-large {
    padding: 1.2rem 3.5rem 9rem;
    border-radius: 34px;
  }

  .spider-tag-large strong {
    font-size: 3rem;
  }

  .spider-tag-large p {
    font-size: 1.4rem;
  }

  .spider-tag-large:before {
    top: 6.2rem;
    left: 0.7rem;
    right: 0.7rem;
    bottom: 0.7rem;
    border-radius: 20px 20px 26px 26px;
  }

  .spider-tag-large:after {
    font-size: 1.5rem;
    top: 8.2rem;
    letter-spacing: 0.1rem;
  }
  
  .story-text {
    font-size: 1.2rem;
  }
  
  .story-polaroids {
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
  }
  
  .story-polaroid {
    width: 280px;
    height: 330px;
  }
  
  .story-polaroid-image {
    height: 220px;
  }
}