/* ===================================
   Main4 - Multi-stage Typography Motion
   =================================== */

/* --- Layout --- */
.typo-hero {
  position: relative;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-primary, #111111);
  overflow: hidden;
}

.typo-hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 25vh;
  background: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.1) 40%, rgba(0,0,0,0) 100%);
  z-index: 1;
  pointer-events: none;
}

.typo-hero-inner {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
}

/* --- Motion Stage Container --- */
.motion-stage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  opacity: 0;
  visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.motion-stage.is-active,
.motion-stage.is-exit {
  opacity: 1;
  visibility: visible;
}

/* --- Common Text Styling --- */
.typo-text {
  font-family: var(--font-primary);
  font-weight: 900;
  font-size: clamp(3rem, 11vw, 20rem);
  text-transform: uppercase;
  margin: 0;
  padding: 0;
  white-space: nowrap;
  line-height: 0.85;
}

.typo-red { color: #D32027; }
.typo-black { color: #ffffff; }

.fw-100 span:not(.typo-space) { font-weight: 100 !important; }
.fw-500 span:not(.typo-space) { font-weight: 500 !important; }
.fw-600 span:not(.typo-space) { font-weight: 600 !important; }
.fw-700 span:not(.typo-space) { font-weight: 700 !important; }
.fw-900 span:not(.typo-space) { font-weight: 900 !important; }

.typo-white span:not(.typo-space) { color: #ffffff !important; }
.typo-gray span:not(.typo-space) { color: #888888 !important; }
.typo-outline-white span:not(.typo-space) { color: transparent !important; -webkit-text-stroke: 0.15vw #ffffff; }
.typo-outline-red span:not(.typo-space) { color: transparent !important; -webkit-text-stroke: 0.15vw #ea1b2c; } 

.typo-justify {
  display: flex;
  justify-content: space-between;
  width: 100%;
}
.typo-space { width: 0.3em; }

/* Grid specific layout (Stage 1 & 3) */
.typo-grid {
  display: grid;
  width: 90vw;
  max-width: 1400px;
  grid-auto-rows: min-content;
  row-gap: 0;
}

.stage-1 .typo-grid {
  grid-template-columns: max-content auto;
}
.stage-1 .typo-item-pinup  { grid-column: 1; grid-row: 1; }
.stage-1 .typo-item-year   { grid-column: 2; grid-row: 1; justify-self: end; }
.stage-1 .typo-item-design { grid-column: 1; grid-row: 2; }
.stage-1 .typo-item-awards { grid-column: 1; grid-row: 3; }
.stage-1 .typo-item-pinimg { grid-column: 2; grid-row: 2 / 4; justify-self: end; display: flex; align-items: flex-end;}


/* --- Stage 2, 3, 4 Common Styling (main3-typo layout) --- */
.main3-typo {
  width: 90vw;
  max-width: 1400px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1vw;
  perspective: 1200px; /* For 3D transforms */
}

.typo-line {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding-bottom: 0.05em;
}

.typo-line span:not(.typo-space) {
  display: inline-block;
  font-family: var(--font-primary);
  font-weight: 100;
  font-size: clamp(4rem, 13vw, 20rem);
  text-transform: uppercase;
  color: #ffffff;
  line-height: 0.9;
}
.typo-line.typo-red span:not(.typo-space) { color: #ea1b2c !important; }

/* Stage 2 Animations */
.stage-2 .typo-line { opacity: 0; transform-origin: center center; }

/* Enter: slide from left/right */
.stage-2.is-active .typo-line-1 { animation: slideFromRight 2.0s cubic-bezier(0.25, 1, 0.5, 1) forwards; animation-delay: 0.1s; }
.stage-2.is-active .typo-line-2 { animation: slideFromLeft 2.0s cubic-bezier(0.25, 1, 0.5, 1) forwards; animation-delay: 0.3s; }
.stage-2.is-active .typo-line-3 { animation: slideFromRight 2.0s cubic-bezier(0.25, 1, 0.5, 1) forwards; animation-delay: 0.5s; }

@keyframes slideFromRight {
  0% { opacity: 0; transform: translateX(10vw) rotateX(0deg); }
  100% { opacity: 1; transform: translateX(0) rotateX(0deg); }
}
@keyframes slideFromLeft {
  0% { opacity: 0; transform: translateX(-10vw) rotateX(0deg); }
  100% { opacity: 1; transform: translateX(0) rotateX(0deg); }
}

/* Exit: Flip out (Y-axis) */
.stage-2.is-exit .typo-line-1 { animation: flipOutY 1.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; animation-delay: 0s; }
.stage-2.is-exit .typo-line-2 { animation: flipOutY 1.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; animation-delay: 0.2s; }
.stage-2.is-exit .typo-line-3 { animation: flipOutY 1.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; animation-delay: 0.4s; }

@keyframes flipOutY {
  0% { transform: rotateY(0deg); opacity: 1; }
  100% { transform: rotateY(90deg); opacity: 0; }
}

/* Stage 3 Animations */
.stage-3 .line-container { opacity: 0; transform-origin: center center; }

/* Enter: Flip in (Y-axis) */
.stage-3.is-active .typo-line-1 { animation: flipInY 1.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; animation-delay: 0s; }
.stage-3.is-active .typo-line-2 { animation: flipInY 1.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; animation-delay: 0.2s; }
.stage-3.is-active .typo-line-3 { animation: flipInY 1.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; animation-delay: 0.4s; }

@keyframes flipInY {
  0% { transform: rotateY(-90deg); opacity: 0; }
  100% { transform: rotateY(0deg); opacity: 1; }
}

/* Exit: Cube rotate out */
.stage-3.is-exit .typo-line-1 { animation: cubeOut 1.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; animation-delay: 0s; transform-origin: 50% 50% -10vw; }
.stage-3.is-exit .typo-line-2 { animation: cubeOut 1.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; animation-delay: 0.2s; transform-origin: 50% 50% -10vw; }
.stage-3.is-exit .typo-line-3 { animation: cubeOut 1.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; animation-delay: 0.4s; transform-origin: 50% 50% -10vw; }

@keyframes cubeOut {
  0% { transform: rotateX(0deg); opacity: 1; }
  100% { transform: rotateX(90deg); opacity: 0; }
}

/* Stage 4 Animations */
.stage-4 .line-container { opacity: 0; overflow: hidden; }

/* Enter: Cube rotate in */
.stage-4.is-active .typo-line-1 { animation: cubeIn 1.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; animation-delay: 0s; transform-origin: 50% 50% -10vw; }
.stage-4.is-active .typo-line-2 { animation: cubeIn 1.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; animation-delay: 0.2s; transform-origin: 50% 50% -10vw; }
.stage-4.is-active .typo-line-3 { animation: cubeIn 1.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; animation-delay: 0.4s; transform-origin: 50% 50% -10vw; }

@keyframes cubeIn {
  0% { transform: rotateX(-90deg); opacity: 0; }
  100% { transform: rotateX(0deg); opacity: 1; }
}

/* Exit: Slide down text spans without fading out */
.stage-4.is-exit .typo-line-1 { opacity: 1; }
.stage-4.is-exit .typo-line-2 { opacity: 1; }
.stage-4.is-exit .typo-line-3 { opacity: 1; }
.stage-4.is-exit .char { animation: slideDownOut 1.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.stage-4.is-exit .typo-line-1 .char { animation-delay: 0s; }
.stage-4.is-exit .typo-line-2 .char { animation-delay: 0.2s; }
.stage-4.is-exit .typo-line-3 .char { animation-delay: 0.4s; }

@keyframes slideDownOut {
  0% { transform: translateY(0); }
  100% { transform: translateY(110%); }
}


/* ==================================================
   Stage 1 & 3: Text Stroke Drawing Animations (CSS Mask)
   ================================================== */
.char {
  display: inline-block;
}

.stage-1 .char {
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: 0% 0%; 
}

/* Scoped to .is-active so it restarts when activated */
.is-active .char-I {
  -webkit-mask-image: linear-gradient(to bottom, #000 100%, transparent 0%);
  animation: draw-I 1s linear forwards; animation-delay: 0.2s;
}
@keyframes draw-I { to { -webkit-mask-size: 100% 100%; } }

.is-active .char-P, .is-active .char-D {
  -webkit-mask-image: 
    linear-gradient(to bottom, #000 100%, transparent 0%),
    linear-gradient(to right, #000 100%, transparent 0%);
  -webkit-mask-position: left top, right top;
  -webkit-mask-size: 45% 0%, 0% 100%;
  animation: draw-PD 1s linear forwards; animation-delay: 0.2s;
}
@keyframes draw-PD {
  0%   { -webkit-mask-size: 45% 0%, 0% 100%; }
  50%  { -webkit-mask-size: 45% 100%, 0% 100%; }
  100% { -webkit-mask-size: 45% 100%, 100% 100%; }
}

.is-active .char-N {
  -webkit-mask-image: 
    linear-gradient(to top, #000 100%, transparent 0%),
    linear-gradient(to bottom right, #000 100%, transparent 0%),
    linear-gradient(to top, #000 100%, transparent 0%);
  -webkit-mask-position: left bottom, center center, right bottom;
  -webkit-mask-size: 45% 0%, 0% 0%, 45% 0%;
  animation: draw-N 1.2s linear forwards; animation-delay: 0.2s;
}
@keyframes draw-N {
  0%   { -webkit-mask-size: 45% 0%, 0% 0%, 45% 0%; }
  33%  { -webkit-mask-size: 45% 100%, 0% 0%, 45% 0%; }
  66%  { -webkit-mask-size: 45% 100%, 100% 100%, 45% 0%; }
  100% { -webkit-mask-size: 45% 100%, 100% 100%, 45% 100%; }
}

.is-active .char-U {
  -webkit-mask-image: 
    linear-gradient(to bottom, #000 100%, transparent 0%),
    linear-gradient(to right, #000 100%, transparent 0%),
    linear-gradient(to top, #000 100%, transparent 0%);
  -webkit-mask-position: left top, center bottom, right bottom;
  -webkit-mask-size: 45% 0%, 0% 45%, 45% 0%;
  animation: draw-U 1s linear forwards; animation-delay: 0.2s;
}
@keyframes draw-U {
  0%   { -webkit-mask-size: 45% 0%, 0% 45%, 45% 0%; }
  33%  { -webkit-mask-size: 45% 100%, 0% 45%, 45% 0%; }
  66%  { -webkit-mask-size: 45% 100%, 100% 45%, 45% 0%; }
  100% { -webkit-mask-size: 45% 100%, 100% 45%, 45% 100%; }
}

.is-active .char-0 {
  -webkit-mask-image: 
    linear-gradient(to bottom, #000 100%, transparent 0%),
    linear-gradient(to top, #000 100%, transparent 0%);
  -webkit-mask-position: left top, right bottom;
  -webkit-mask-size: 55% 0%, 55% 0%;
  animation: draw-0 1s linear forwards; animation-delay: 0.2s;
}
@keyframes draw-0 {
  0%   { -webkit-mask-size: 55% 0%, 55% 0%; }
  50%  { -webkit-mask-size: 55% 100%, 55% 0%; }
  100% { -webkit-mask-size: 55% 100%, 55% 100%; }
}

.is-active .char-2 {
  -webkit-mask-image: 
    linear-gradient(to right, #000 100%, transparent 0%),
    linear-gradient(to bottom right, #000 100%, transparent 0%),
    linear-gradient(to right, #000 100%, transparent 0%);
  -webkit-mask-position: top left, center center, bottom left;
  -webkit-mask-size: 0% 40%, 0% 0%, 0% 40%;
  animation: draw-2 1.2s linear forwards; animation-delay: 0.2s;
}
@keyframes draw-2 {
  0%   { -webkit-mask-size: 0% 40%, 0% 0%, 0% 40%; }
  33%  { -webkit-mask-size: 100% 40%, 0% 0%, 0% 40%; }
  66%  { -webkit-mask-size: 100% 40%, 100% 100%, 0% 40%; }
  100% { -webkit-mask-size: 100% 40%, 100% 100%, 100% 40%; }
}

.is-active .char-diag {
  -webkit-mask-image: linear-gradient(135deg, #000 100%, transparent 0%);
  -webkit-mask-position: top left;
  -webkit-mask-size: 0% 0%;
  animation: draw-diag 1s linear forwards; animation-delay: 0.2s;
}
@keyframes draw-diag {
  0% { -webkit-mask-size: 0% 0%; }
  100% { -webkit-mask-size: 250% 250%; }
}

.is-active .char-E {
  -webkit-mask-image: 
    linear-gradient(to bottom, #000 100%, transparent 0%),
    linear-gradient(to right, #000 100%, transparent 0%),
    linear-gradient(to right, #000 100%, transparent 0%),
    linear-gradient(to right, #000 100%, transparent 0%);
  -webkit-mask-position: left top, right top, right center, right bottom;
  -webkit-mask-size: 45% 0%, 0% 40%, 0% 40%, 0% 40%;
  animation: draw-E 1s linear forwards; animation-delay: 0.2s;
}
@keyframes draw-E {
  0%  { -webkit-mask-size: 45% 0%, 0% 40%, 0% 40%, 0% 40%; }
  25% { -webkit-mask-size: 45% 100%, 0% 40%, 0% 40%, 0% 40%; }
  50% { -webkit-mask-size: 45% 100%, 100% 40%, 0% 40%, 0% 40%; }
  75% { -webkit-mask-size: 45% 100%, 100% 40%, 100% 40%, 0% 40%; }
  100%{ -webkit-mask-size: 45% 100%, 100% 40%, 100% 40%, 100% 40%; }
}

.is-active .char-A {
  -webkit-mask-image: 
    linear-gradient(to top right, #000 100%, transparent 0%),
    linear-gradient(to bottom right, #000 100%, transparent 0%),
    linear-gradient(to right, #000 100%, transparent 0%);
  -webkit-mask-position: left bottom, right top, center 65%;
  -webkit-mask-size: 0% 0%, 0% 0%, 0% 40%;
  animation: draw-A 1s linear forwards; animation-delay: 0.2s;
}
@keyframes draw-A {
  0%   { -webkit-mask-size: 0% 0%, 0% 0%, 0% 40%; }
  33%  { -webkit-mask-size: 60% 100%, 0% 0%, 0% 40%; }
  66%  { -webkit-mask-size: 60% 100%, 60% 100%, 0% 40%; }
  100% { -webkit-mask-size: 60% 100%, 60% 100%, 100% 40%; }
}

.is-active .char-W {
  -webkit-mask-image: 
    linear-gradient(to bottom right, #000 100%, transparent 0%),
    linear-gradient(to top right, #000 100%, transparent 0%),
    linear-gradient(to bottom right, #000 100%, transparent 0%),
    linear-gradient(to top right, #000 100%, transparent 0%);
  -webkit-mask-position: left top, center bottom, center top, right bottom;
  -webkit-mask-size: 0% 0%, 0% 0%, 0% 0%, 0% 0%;
  animation: draw-W 1.2s linear forwards; animation-delay: 0.2s;
}
@keyframes draw-W {
  0%   { -webkit-mask-size: 0% 0%, 0% 0%, 0% 0%, 0% 0%; }
  25%  { -webkit-mask-size: 50% 100%, 0% 0%, 0% 0%, 0% 0%; }
  50%  { -webkit-mask-size: 50% 100%, 50% 100%, 0% 0%, 0% 0%; }
  75%  { -webkit-mask-size: 50% 100%, 50% 100%, 50% 100%, 0% 0%; }
  100% { -webkit-mask-size: 50% 100%, 50% 100%, 50% 100%, 50% 100%; }
}

.is-active .char-R {
  -webkit-mask-image: 
    linear-gradient(to bottom, #000 100%, transparent 0%),
    linear-gradient(to right, #000 100%, transparent 0%),
    linear-gradient(to bottom right, #000 100%, transparent 0%);
  -webkit-mask-position: left top, right top, right bottom;
  -webkit-mask-size: 45% 0%, 0% 65%, 0% 0%;
  animation: draw-R 1s linear forwards; animation-delay: 0.2s;
}
@keyframes draw-R {
  0%   { -webkit-mask-size: 45% 0%, 0% 65%, 0% 0%; }
  33%  { -webkit-mask-size: 45% 100%, 0% 65%, 0% 0%; }
  66%  { -webkit-mask-size: 45% 100%, 100% 65%, 0% 0%; }
  100% { -webkit-mask-size: 45% 100%, 100% 65%, 100% 70%; }
}

.is-active .char-generic {
  -webkit-mask-image: linear-gradient(to right, #000 100%, transparent 0%);
  -webkit-mask-position: left top;
  -webkit-mask-size: 0% 100%;
  animation: draw-generic 1s linear forwards; animation-delay: 0.2s;
}
@keyframes draw-generic {
  0% { -webkit-mask-size: 0% 100%; }
  100% { -webkit-mask-size: 100% 100%; }
}

/* Stage 1 Exit Animation (Slide Left/Right and Fade Out) */
.stage-1.is-exit .typo-item-pinup,
.stage-1.is-exit .typo-item-design,
.stage-1.is-exit .typo-item-awards {
  animation: slideOutLeftStage1 1.7s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
.stage-1.is-exit .typo-item-year,
.stage-1.is-exit .typo-item-pinimg {
  animation: slideOutRightStage1 1.7s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes slideOutLeftStage1 {
  0% { transform: translateX(0); opacity: 1; }
  100% { transform: translateX(-15vw); opacity: 0; }
}
@keyframes slideOutRightStage1 {
  0% { transform: translateX(0); opacity: 1; }
  100% { transform: translateX(15vw); opacity: 0; }
}

/* Pin animation in Stage 1 */
.pin-svg-anim {
  height: 90%;
  width: auto;
  display: block;
  overflow: visible;
}

.pin-svg-anim path {
  stroke-dasharray: 1.1;
  stroke-dashoffset: 1.1;
  stroke-width: 1.5px;
  fill: transparent;
}

.is-active .pin-svg-anim .cls-1 {
  stroke: #ea1b2c;
  animation: pin-draw 1.5s ease-in-out forwards;
  animation-delay: 1.2s;
}

@keyframes pin-draw {
  0%   { stroke-dashoffset: 1.1; fill: transparent; }
  50%  { stroke-dashoffset: 0; fill: transparent; }
  100% { stroke-dashoffset: 0; fill: #ea1b2c; }
}

/* Responsive */
@media (max-width: 768px) {
  .typo-hero { height: 80vh; }

  .stage-1 .typo-grid { grid-template-columns: 1fr; }
  .stage-1 .typo-item-year   { grid-row: 1; grid-column: 1; justify-self: end; }
  .stage-1 .typo-item-pinup  { grid-row: 2; }
  .stage-1 .typo-item-design { grid-row: 3; }
  .stage-1 .typo-item-awards { grid-row: 4; }
  .stage-1 .typo-item-pinimg { grid-row: 5; grid-column: 1; justify-self: end; height: 36vw; margin-top: 2vw;}

  .typo-text { font-size: 18vw; }
  .typo-line span:not(.typo-space) { font-size: 14vw; }
}
