:root {
  --ink: #070b14;
  --ink-soft: #0c1220;
  --indigo: #121a2e;
  --crimson: #8b1e2d;
  --crimson-glow: rgba(139, 30, 45, 0.35);
  --gold: #c4a35a;
  --gold-soft: rgba(196, 163, 90, 0.55);
  --ivory: #f3ebe0;
  --ivory-muted: rgba(243, 235, 224, 0.72);
  --ivory-faint: rgba(243, 235, 224, 0.45);
  --font-display: "Cormorant Garamond", "Times New Roman", serif;
  --font-body: "Source Serif 4", Georgia, serif;
  --font-fa: "Vazirmatn", "Cormorant Garamond", sans-serif;
  --brand-tracking: 0.18em;
  --brand-tracking-start: 0.32em;
}

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

html,
body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--ink);
  color: var(--ivory);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  position: relative;
  min-height: 100svh;
  min-height: 100dvh;
  max-height: 100svh;
  max-height: 100dvh;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* —— Atmosphere —— */
.stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 60% at 70% 45%, var(--crimson-glow), transparent 55%),
    radial-gradient(ellipse 70% 50% at 25% 70%, rgba(18, 40, 70, 0.5), transparent 50%),
    linear-gradient(160deg, var(--ink) 0%, var(--indigo) 45%, var(--ink-soft) 100%);
}

.stage__glow {
  position: absolute;
  inset: -10%;
  background:
    radial-gradient(circle at 62% 42%, rgba(196, 163, 90, 0.12), transparent 28%),
    radial-gradient(circle at 55% 55%, rgba(139, 30, 45, 0.18), transparent 40%);
  animation: glowPulse 12s ease-in-out infinite alternate;
}

.stage__carpet {
  display: none;
}

.stage__wolf {
  position: absolute;
  z-index: 1;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(7, 11, 20, 0.88) 0%, rgba(7, 11, 20, 0.35) 38%, rgba(7, 11, 20, 0.15) 55%, rgba(7, 11, 20, 0.55) 100%),
    linear-gradient(180deg, rgba(7, 11, 20, 0.45) 0%, transparent 25%, transparent 70%, rgba(7, 11, 20, 0.75) 100%),
    url("/art/wolf.jpg") 72% 42% / cover no-repeat;
  transform: scale(1.06) translate3d(1.5%, 0, 0);
  filter: saturate(0.92) contrast(1.05) brightness(0.88);
  animation: wolfDrift 22s ease-in-out infinite alternate;
  will-change: transform;
}

.stage__vignette {
  position: absolute;
  z-index: 3;
  inset: 0;
  background:
    radial-gradient(ellipse 75% 70% at 50% 45%, transparent 30%, rgba(7, 11, 20, 0.55) 75%, rgba(7, 11, 20, 0.92) 100%);
  box-shadow: inset 0 0 120px rgba(7, 11, 20, 0.85);
}

.stage__grain {
  position: absolute;
  z-index: 4;
  inset: 0;
  opacity: 0.07;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

/* —— Crest content —— */
.crest {
  position: relative;
  z-index: 1;
  height: 100svh;
  height: 100dvh;
  max-height: 100svh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding:
    max(1.25rem, env(safe-area-inset-top))
    max(1.5rem, env(safe-area-inset-right))
    max(1.25rem, env(safe-area-inset-bottom))
    max(1.5rem, env(safe-area-inset-left));
  max-width: 42rem;
  gap: clamp(0.65rem, 1.8vh, 1.15rem);
}

.crest__origin {
  font-family: var(--font-body);
  font-size: clamp(0.68rem, 1.5vw, 0.8rem);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold-soft);
  opacity: 0;
  animation: fadeUp 1.1s ease-out 0.2s forwards;
}

.crest__brand {
  display: flex;
  flex-direction: column;
  gap: 0.15em;
  line-height: 0.95;
}

.crest__latin {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.6rem, 9.5vw, 5.6rem);
  letter-spacing: var(--brand-tracking);
  text-transform: uppercase;
  color: var(--ivory);
  text-shadow:
    0 0 40px rgba(196, 163, 90, 0.15),
    0 2px 24px rgba(0, 0, 0, 0.55);
  opacity: 0;
  animation: brandSettle 1.6s cubic-bezier(0.22, 1, 0.36, 1) 0.35s forwards;
  max-width: 100%;
}

.crest__persian {
  font-family: var(--font-fa);
  font-weight: 500;
  font-size: clamp(1.55rem, 5.2vw, 2.75rem);
  letter-spacing: 0.04em;
  color: var(--gold);
  opacity: 0;
  animation: fadeUp 1.2s ease-out 0.7s forwards;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.5);
}

.crest__rule {
  width: min(12rem, 40vw);
  height: 1px;
  background: linear-gradient(90deg, var(--gold), rgba(196, 163, 90, 0.15), transparent);
  opacity: 0;
  transform-origin: left center;
  animation: ruleDraw 1.4s ease-out 0.9s forwards;
}

.crest__line {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1rem, 2.6vw, 1.35rem);
  line-height: 1.45;
  color: var(--ivory-muted);
  max-width: 28rem;
  opacity: 0;
  animation: fadeUp 1.2s ease-out 1.05s forwards;
}

.crest__names {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  margin-top: clamp(0.25rem, 1vh, 0.6rem);
  opacity: 0;
  animation: fadeUp 1.2s ease-out 1.25s forwards;
}

.crest__names li {
  font-size: clamp(0.72rem, 1.6vw, 0.85rem);
  color: var(--ivory-faint);
  letter-spacing: 0.02em;
  display: flex;
  align-items: baseline;
  gap: 0.4em;
}

.crest__lang {
  font-family: var(--font-body);
  font-size: 0.65em;
  letter-spacing: 0.16em;
  color: var(--gold);
  opacity: 0.75;
}

[lang="fa"],
[lang="ar"] {
  font-family: var(--font-fa);
}

/* —— Motion —— */
@keyframes wolfDrift {
  from {
    transform: scale(1.06) translate3d(1.5%, 0.4%, 0);
  }
  to {
    transform: scale(1.09) translate3d(-0.8%, -0.6%, 0);
  }
}

@keyframes glowPulse {
  from {
    opacity: 0.75;
  }
  to {
    opacity: 1;
  }
}

@keyframes brandSettle {
  from {
    opacity: 0;
    letter-spacing: var(--brand-tracking-start);
    transform: translateY(0.4em);
  }
  to {
    opacity: 1;
    letter-spacing: var(--brand-tracking);
    transform: translateY(0);
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(0.6em);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ruleDraw {
  from {
    opacity: 0;
    transform: scaleX(0);
  }
  to {
    opacity: 1;
    transform: scaleX(1);
  }
}

/* —— Responsive: keep one viewport, tighten on small screens —— */
@media (max-width: 640px) {
  :root {
    --brand-tracking: 0.045em;
    --brand-tracking-start: 0.1em;
  }

  .crest {
    width: 100%;
    max-width: 100%;
    padding-top: max(1.1rem, env(safe-area-inset-top));
    padding-bottom: max(1.1rem, env(safe-area-inset-bottom));
    padding-left: max(1.25rem, env(safe-area-inset-left));
    padding-right: max(1.25rem, env(safe-area-inset-right));
    gap: clamp(0.45rem, 1.4vh, 0.85rem);
    /* Soft left scrim so type stays readable over fur */
    background: linear-gradient(
      90deg,
      rgba(7, 11, 20, 0.72) 0%,
      rgba(7, 11, 20, 0.42) 55%,
      rgba(7, 11, 20, 0) 100%
    );
  }

  .crest__brand {
    width: 100%;
    max-width: 100%;
  }

  .crest__origin {
    letter-spacing: 0.16em;
    font-size: clamp(0.62rem, 2.8vw, 0.72rem);
    max-width: 100%;
  }

  .crest__latin {
    /* Fit 12-letter brand + tracking inside phone width */
    font-size: clamp(1.55rem, 7.4vw, 2.05rem);
    letter-spacing: var(--brand-tracking);
    line-height: 1.05;
    width: 100%;
  }

  .crest__persian {
    font-size: clamp(1.15rem, 5.5vw, 1.55rem);
    max-width: 100%;
  }

  .crest__line {
    font-size: clamp(0.95rem, 4.2vw, 1.1rem);
    max-width: 100%;
    padding-right: 0.25rem;
  }

  .crest__names {
    gap: 0.35rem 0.75rem;
    width: 100%;
  }

  .crest__names li {
    font-size: clamp(0.68rem, 3.2vw, 0.78rem);
  }

  /* Center the wolf face on phones */
  .stage__wolf {
    background:
      linear-gradient(180deg, rgba(7, 11, 20, 0.5) 0%, transparent 22%, transparent 68%, rgba(7, 11, 20, 0.78) 100%),
      linear-gradient(90deg, rgba(7, 11, 20, 0.55) 0%, rgba(7, 11, 20, 0.2) 40%, rgba(7, 11, 20, 0.25) 100%),
      url("/art/wolf.jpg") 50% 38% / cover no-repeat;
    transform: scale(1.08) translate3d(0, 0, 0);
    animation: wolfDriftMobile 26s ease-in-out infinite alternate;
  }

  .stage__glow {
    background:
      radial-gradient(circle at 50% 40%, rgba(196, 163, 90, 0.16), transparent 32%),
      radial-gradient(circle at 50% 55%, rgba(139, 30, 45, 0.22), transparent 42%);
  }
}

/* Extra-narrow phones (e.g. SE / tight portrait) */
@media (max-width: 390px) {
  :root {
    --brand-tracking: 0.03em;
    --brand-tracking-start: 0.08em;
  }

  .crest__latin {
    font-size: clamp(1.4rem, 7vw, 1.75rem);
  }

  .crest__persian {
    font-size: clamp(1.05rem, 5vw, 1.3rem);
  }

  .stage__wolf {
    background-position: 50% 36%;
  }
}

/* Tablets */
@media (min-width: 641px) and (max-width: 1099px) {
  .stage__wolf {
    background-position: 58% 40%;
  }
}

@media (min-width: 1100px) {
  .crest {
    padding-left: clamp(3rem, 8vw, 7rem);
    max-width: 46rem;
  }

  .stage__wolf {
    background-position: 72% 40%;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .crest {
    gap: 0.4rem;
    padding-block: 0.75rem;
  }

  .crest__latin {
    font-size: clamp(1.8rem, 7vh, 3rem);
  }

  .crest__persian {
    font-size: clamp(1.1rem, 4.5vh, 1.6rem);
  }

  .crest__line {
    font-size: clamp(0.9rem, 3.2vh, 1.1rem);
  }

  .crest__names {
    margin-top: 0.15rem;
  }

  .stage__wolf {
    background-position: 50% 42%;
  }
}

@keyframes wolfDriftMobile {
  from {
    transform: scale(1.08) translate3d(0, 0.3%, 0);
  }
  to {
    transform: scale(1.11) translate3d(0, -0.5%, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage__wolf,
  .stage__glow,
  .crest__latin,
  .crest__persian,
  .crest__origin,
  .crest__line,
  .crest__names,
  .crest__rule {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .crest__latin {
    letter-spacing: var(--brand-tracking);
  }

  @media (max-width: 640px) {
    .stage__wolf {
      transform: scale(1.08);
    }
  }
}
