/* ================================================================
   NO PERRY — Foundation Standard 26B
   Scroll-unfurling guild banner inside #living-chronicle.
   Progress driven by Environmental World RAF (--foundation-progress).
   ================================================================ */

.np-foundation-standard {
  --foundation-progress: 0;
  --foundation-idle: 0;
  position: relative;
  width: min(52vw, 420px);
  margin: 2.5rem auto 2rem;
  perspective: 900px;
}

.np-foundation-standard__stage {
  position: relative;
  width: 100%;
  min-height: min(58vh, 520px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.np-foundation-standard__pole {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.np-foundation-standard__finial {
  display: block;
  width: 28px;
  height: 28px;
  margin: 0 auto 0.15rem;
  margin-left: -7px;
  border-radius: 50% 50% 40% 40%;
  background:
    radial-gradient(circle at 35% 30%, #f0d78a, #b8892a 55%, #5a3c10 100%);
  box-shadow:
    0 0 12px rgba(200, 160, 60, 0.35),
    inset 0 -2px 4px rgba(0, 0, 0, 0.35);
  position: relative;
  z-index: 4;
}

.np-foundation-standard__rod {
  display: block;
  width: 10px;
  height: calc(100% - 36px);
  margin: 0 auto;
  border-radius: 3px;
  background:
    linear-gradient(90deg, #3a2a18, #8a6a3a 40%, #c9a24a 50%, #6a4a22 70%, #2a1c0e);
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.45);
}

.np-foundation-standard__banner {
  position: relative;
  z-index: 2;
  width: 100%;
  margin-top: 1.6rem;
  /* clear the finial so fabric hangs from the rod, not through the pole */
  padding-top: 0;
  transform-origin: top center;
  /* unfurl: clip from top; start ~8% visible */
  clip-path: inset(
    0 0 calc(100% - (8% + var(--foundation-progress) * 92%)) 0
  );
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.55));
}

.np-foundation-standard__fabric {
  position: relative;
  min-height: min(48vh, 440px);
  padding: 2.4rem 1.4rem 2.8rem;
  border-radius: 0 0 18px 18px / 0 0 28px 28px;
  background:
    linear-gradient(165deg, rgba(48, 28, 18, 0.96), rgba(18, 12, 10, 0.98) 55%, rgba(12, 8, 8, 0.99)),
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 3px,
      rgba(255, 220, 140, 0.015) 3px,
      rgba(255, 220, 140, 0.015) 4px
    );
  border: 1px solid rgba(180, 140, 70, 0.28);
  border-top: 3px solid rgba(201, 162, 74, 0.55);
  box-shadow:
    inset 0 0 40px rgba(0, 0, 0, 0.45),
    inset 0 -30px 40px rgba(80, 40, 10, 0.12);
  overflow: hidden;
  will-change: transform;
}

.np-foundation-standard.is-complete:not(.np-foundation-reduced) .np-foundation-standard__fabric {
  animation: np-foundation-sway 9s ease-in-out infinite;
}

@keyframes np-foundation-sway {
  0%, 100% { transform: translate3d(0, 0, 0) skewX(0deg); }
  50% { transform: translate3d(0, 2px, 0) skewX(0.4deg); }
}

.np-foundation-standard__weave {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background:
    radial-gradient(ellipse 70% 40% at 50% 0%, rgba(201, 162, 74, 0.18), transparent 70%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 5px,
      rgba(255, 230, 170, 0.02) 5px,
      rgba(255, 230, 170, 0.02) 6px
    );
  mix-blend-mode: soft-light;
}

.np-foundation-standard__inscription {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  text-align: center;
  opacity: calc(0.15 + var(--foundation-progress) * 0.85);
  transform: translateY(calc((1 - var(--foundation-progress)) * 18px));
}

.np-foundation-standard__brand {
  margin: 0.4rem 0 0.2rem;
  font-family: 'Cinzel', 'Times New Roman', serif;
  font-size: clamp(1.6rem, 3.2vw, 2.35rem);
  font-weight: 700;
  letter-spacing: 0.28em;
  color: #f0d78a;
  text-shadow:
    0 0 18px rgba(200, 160, 60, 0.35),
    0 2px 0 rgba(40, 24, 8, 0.8);
  opacity: calc(clamp((var(--foundation-progress) - 0.35) / 0.25, 0, 1));
}

.np-foundation-standard__kicker {
  margin: 0;
  font-family: 'Cinzel', 'Times New Roman', serif;
  font-size: 0.72rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: rgba(210, 180, 120, 0.7);
  opacity: calc(clamp((var(--foundation-progress) - 0.45) / 0.2, 0, 1));
}

.np-foundation-standard__founder {
  margin: 0.35rem 0 0;
  font-family: 'Cinzel', 'Times New Roman', serif;
  font-size: clamp(1.15rem, 2.2vw, 1.55rem);
  letter-spacing: 0.22em;
  color: #ffe9b0;
  opacity: calc(clamp((var(--foundation-progress) - 0.62) / 0.15, 0, 1));
}

.np-foundation-standard__date {
  margin: 0;
  font-family: var(--font-mono, 'Courier New', monospace);
  font-size: 0.95rem;
  letter-spacing: 0.28em;
  color: rgba(232, 200, 120, 0.9);
  opacity: calc(clamp((var(--foundation-progress) - 0.7) / 0.12, 0, 1));
}

.np-foundation-standard__server,
.np-foundation-standard__alliance {
  margin: 0;
  font-family: 'Cinzel', 'Times New Roman', serif;
  font-size: 0.78rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(200, 175, 130, 0.78);
  opacity: calc(clamp((var(--foundation-progress) - 0.82) / 0.12, 0, 1));
}

.np-foundation-standard__edge {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 10px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #c9a24a, transparent);
  transform: scaleX(0);
  transform-origin: left center;
  opacity: 0;
  pointer-events: none;
}

.np-foundation-standard.is-complete .np-foundation-standard__edge {
  animation: np-foundation-edge 600ms ease-out 1 forwards;
}

@keyframes np-foundation-edge {
  0% { transform: scaleX(0); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: scaleX(1); opacity: 0.85; }
}

.np-foundation-standard__torch {
  position: absolute;
  top: 18%;
  width: 70px;
  height: 140px;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(
    ellipse 50% 55% at 50% 40%,
    rgba(255, 170, 60, calc(0.08 + var(--foundation-progress) * 0.12)),
    transparent 70%
  );
  filter: blur(8px);
  opacity: calc(0.35 + var(--foundation-progress) * 0.55);
}

.np-foundation-standard__torch--l { left: -8%; }
.np-foundation-standard__torch--r { right: -8%; }

.np-foundation-standard__source {
  margin: 1rem auto 0;
  max-width: 36rem;
  text-align: center;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: rgba(160, 140, 110, 0.55);
  opacity: calc(clamp((var(--foundation-progress) - 0.88) / 0.12, 0, 1));
}

/* Mobile — simpler vertical reveal, wider banner */
@media (max-width: 767px) {
  .np-foundation-standard {
    width: min(90vw, 360px);
    perspective: none;
    margin: 1.75rem auto 1.5rem;
  }
  .np-foundation-standard__stage {
    min-height: 420px;
  }
  .np-foundation-standard__fabric {
    min-height: 380px;
    padding: 2rem 1rem 2.4rem;
  }
  .np-foundation-standard.is-complete .np-foundation-standard__fabric {
    animation: np-foundation-sway-mobile 11s ease-in-out infinite;
  }
  @keyframes np-foundation-sway-mobile {
    0%, 100% { transform: translate3d(0, 0, 0); }
    50% { transform: translate3d(0, 1px, 0); }
  }
  .np-foundation-standard__brand {
    letter-spacing: 0.18em;
    font-size: 1.45rem;
  }
  .np-foundation-standard__torch {
    width: 48px;
    height: 100px;
    opacity: calc(0.25 + var(--foundation-progress) * 0.4);
  }
  .np-foundation-standard__torch--l { left: -4%; }
  .np-foundation-standard__torch--r { right: -4%; }
}

@media (prefers-reduced-motion: reduce) {
  .np-foundation-standard {
    --foundation-progress: 1 !important;
    --foundation-idle: 0 !important;
  }
  .np-foundation-standard__banner {
    clip-path: none;
  }
  .np-foundation-standard__inscription,
  .np-foundation-standard__brand,
  .np-foundation-standard__kicker,
  .np-foundation-standard__founder,
  .np-foundation-standard__date,
  .np-foundation-standard__server,
  .np-foundation-standard__alliance,
  .np-foundation-standard__source {
    opacity: 1 !important;
    transform: none !important;
  }
  .np-foundation-standard__fabric {
    transform: none;
    animation: none !important;
  }
  .np-foundation-standard__edge {
    animation: none;
    transform: scaleX(1);
    opacity: 0.7;
  }
}
