/* ==========================================================================
   Questfarer: under construction page
   Loaded after main.css and reuses its tokens.
   ========================================================================== */

.construction {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1000px 560px at 50% 22%, rgba(57, 122, 150, 0.28), transparent 70%),
    radial-gradient(700px 420px at 50% 100%, rgba(231, 101, 50, 0.14), transparent 70%),
    var(--navy);
}

.construction__main {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(2rem, 6vh, 4rem) var(--gutter) 2rem;
  text-align: center;
  overflow: hidden;
  isolation: isolate;
}

/* Slowly drifting contour field */
.construction__sky {
  position: absolute;
  inset: -20%;
  z-index: -1;
  background:
    repeating-radial-gradient(ellipse 55% 42% at 30% 35%, transparent 0 30px, rgba(242, 235, 221, 0.045) 30px 31px),
    repeating-radial-gradient(ellipse 48% 56% at 78% 70%, transparent 0 38px, rgba(215, 163, 61, 0.04) 38px 39px);
  -webkit-mask-image: radial-gradient(closest-side, #000 35%, transparent);
  mask-image: radial-gradient(closest-side, #000 35%, transparent);
  animation: contour-drift 40s ease-in-out infinite alternate;
}

@keyframes contour-drift {
  from {
    transform: translate3d(-3%, -2%, 0) scale(1) rotate(0deg);
  }
  to {
    transform: translate3d(3%, 2%, 0) scale(1.12) rotate(4deg);
  }
}

/* Title artwork: resolves into place, then floats, with a light sweep */
.construction__title {
  width: min(880px, 100%);
  margin: 0 0 clamp(2.5rem, 6vh, 4.5rem);
  font-size: 1rem;
  animation: title-arrive 1.4s cubic-bezier(0.16, 0.84, 0.3, 1) both;
}

.construction__title-frame {
  position: relative;
  display: block;
  animation: title-float 8s ease-in-out 1.4s infinite;
}

.construction__title img {
  width: 100%;
  filter: drop-shadow(0 30px 44px rgba(0, 0, 0, 0.6));
}

.construction__sheen {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 42%, rgba(255, 244, 214, 0.75) 50%, transparent 58%) no-repeat;
  background-size: 300% 100%;
  background-position: 150% 0;
  -webkit-mask: url("../img/title-construction.webp") center / 100% 100% no-repeat;
  mask: url("../img/title-construction.webp") center / 100% 100% no-repeat;
  mix-blend-mode: soft-light;
  animation: sheen 6s ease-in-out 1.6s infinite;
}

@keyframes title-arrive {
  from {
    opacity: 0;
    transform: translateY(26px) scale(0.92);
    filter: blur(14px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }
}

@keyframes title-float {
  0%,
  100% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  50% {
    transform: translate3d(0, -12px, 0) rotate(-0.6deg);
  }
}

@keyframes sheen {
  0%,
  55% {
    background-position: 150% 0;
  }
  100% {
    background-position: -50% 0;
  }
}

.construction .label,
.construction__lede,
.trail,
.construction__status {
  animation: rise 0.9s ease both;
}

.construction .label {
  animation-delay: 0.7s;
}

.construction__lede {
  max-width: 46ch;
  margin: 0 0 clamp(1.5rem, 4vh, 2.75rem);
  font-size: clamp(1.1rem, 2.2vw, 1.35rem);
  color: var(--paper);
  text-wrap: balance;
  animation-delay: 0.9s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   Trail: the Questfarer progress indicator.
   An orange route is charted through four waypoints (the Adventure
   lifecycle) and a marker travels it toward the gold final objective.
   -------------------------------------------------------------------------- */

.trail {
  --lap: 9s;
  width: min(640px, 100%);
  animation-delay: 1.1s;
}

.trail__map {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

/* Expedition map drawn behind the route: water, forest, a ridge, the summit */
.trail__terrain {
  fill: none;
  stroke: rgba(242, 235, 221, 0.5);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trail__terrain--sea {
  stroke: var(--blue);
}

.trail__terrain--forest {
  fill: rgba(85, 120, 100, 0.22);
  stroke: var(--green);
}

.trail__terrain--rock {
  fill: rgba(57, 122, 150, 0.12);
}

.trail__terrain--snow {
  stroke: rgba(242, 235, 221, 0.7);
}

.trail__compass {
  stroke: rgba(215, 163, 61, 0.55);
}

.trail__compass-needle {
  fill: rgba(215, 163, 61, 0.8);
  stroke: none;
  transform-box: fill-box;
  transform-origin: center;
  animation: needle-seek 5s ease-in-out infinite;
}

/* Each stretch of terrain sits dim until the marker reaches it, then stays lit */
.trail__zone {
  animation: var(--lap) linear infinite;
}

.trail__zone--1 {
  animation-name: zone-1;
}

.trail__zone--2 {
  animation-name: zone-2;
}

.trail__zone--3 {
  animation-name: zone-3;
}

.trail__zone--4 {
  animation-name: zone-4;
}

/* Ambient motion: drifting swell, wind in the trees */
.trail__terrain--sea path {
  animation: swell 3.6s ease-in-out infinite alternate;
}

.trail__terrain--sea path:nth-child(even) {
  animation-direction: alternate-reverse;
  animation-duration: 4.4s;
}

.trail__terrain--forest {
  transform-box: fill-box;
  transform-origin: 50% 100%;
}

.trail__zone--2.trail__terrain--forest {
  animation-name: zone-2, sway;
  animation-duration: var(--lap), 4.8s;
  animation-timing-function: linear, ease-in-out;
  animation-direction: normal, alternate;
}

/* Burst of light as each quest token is reached */
.trail__flash {
  fill: none;
  stroke: var(--orange-bright);
  stroke-width: 2.5;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: var(--lap) ease-out infinite;
}

.trail__flash--1 {
  animation-name: flash-1;
}

.trail__flash--2 {
  animation-name: flash-2;
}

.trail__flash--3 {
  animation-name: flash-3;
}

.trail__base,
.trail__path {
  fill: none;
  stroke-linecap: round;
}

.trail__base {
  stroke: rgba(154, 151, 142, 0.5);
  stroke-width: 2;
  stroke-dasharray: 0.6 1.6;
}

.trail__path {
  stroke: var(--orange);
  stroke-width: 3.5;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  filter: drop-shadow(0 0 6px rgba(231, 101, 50, 0.7));
  animation: trail-draw var(--lap) linear infinite;
}

.trail__marker {
  fill: var(--paper);
  stroke: var(--orange);
  stroke-width: 2.5;
  offset-path: path("M80 78 C130 10 190 110 240 52 S350 20 400 70 S510 112 560 36");
  offset-rotate: auto 45deg;
  offset-distance: 0%;
  animation: trail-travel var(--lap) linear infinite;
}

.trail__stop circle {
  fill: var(--navy);
  stroke: var(--stone);
  stroke-width: 3;
}

/* Quest emblem inside each waypoint token */
.trail__icon {
  fill: none;
  stroke: var(--paper);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Flag planted on the summit once the route gets there */
.trail__flag {
  fill: none;
  stroke: var(--paper);
  stroke-width: 2;
  stroke-linecap: round;
  transform-box: fill-box;
  transform-origin: 0 100%;
  animation: flag-raise var(--lap) ease-out infinite;
}

.trail__flag-cloth {
  fill: var(--orange);
  stroke: var(--orange);
  stroke-width: 1;
  stroke-linejoin: round;
  transform-box: fill-box;
  transform-origin: 0 50%;
  animation: flag-wave 1.1s ease-in-out infinite alternate;
}

/* Tokens punch outward on arrival */
.trail__stop--1,
.trail__stop--2,
.trail__stop--3 {
  transform-box: fill-box;
  transform-origin: center;
  animation: var(--lap) ease-out infinite;
}

.trail__stop--1 {
  animation-name: pop-1;
}

.trail__stop--2 {
  animation-name: pop-2;
}

.trail__stop--3 {
  animation-name: pop-3;
}

.trail__stop--1 circle {
  fill: var(--orange);
  stroke: var(--orange);
}

.trail__stop--2 circle {
  animation: stop-2 var(--lap) linear infinite;
}

.trail__stop--3 circle {
  animation: stop-3 var(--lap) linear infinite;
}

.trail__stop--4 circle {
  stroke: var(--gold);
  animation: stop-4 var(--lap) linear infinite;
}

.trail__stop--4 .trail__ring {
  fill: none;
  stroke: var(--gold);
  stroke-width: 2;
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0;
  animation: stop-ring var(--lap) ease-out infinite;
}

@keyframes trail-draw {
  0% {
    stroke-dashoffset: 100;
    opacity: 1;
  }
  70%,
  92% {
    stroke-dashoffset: 0;
    opacity: 1;
  }
  100% {
    stroke-dashoffset: 0;
    opacity: 0;
  }
}

@keyframes trail-travel {
  0% {
    offset-distance: 0%;
    opacity: 1;
  }
  70%,
  92% {
    offset-distance: 100%;
    opacity: 1;
  }
  100% {
    offset-distance: 100%;
    opacity: 0;
  }
}

@keyframes stop-2 {
  0%,
  23% {
    fill: var(--navy);
    stroke: var(--stone);
  }
  25%,
  92% {
    fill: var(--orange);
    stroke: var(--orange);
  }
  100% {
    fill: var(--navy);
    stroke: var(--stone);
  }
}

@keyframes stop-3 {
  0%,
  45% {
    fill: var(--navy);
    stroke: var(--stone);
  }
  47%,
  92% {
    fill: var(--orange);
    stroke: var(--orange);
  }
  100% {
    fill: var(--navy);
    stroke: var(--stone);
  }
}

@keyframes stop-4 {
  0%,
  69% {
    fill: var(--navy);
  }
  71%,
  92% {
    fill: var(--gold);
  }
  100% {
    fill: var(--navy);
  }
}

@keyframes zone-1 {
  0% {
    opacity: 0.4;
  }
  5%,
  92% {
    opacity: 1;
  }
  100% {
    opacity: 0.4;
  }
}

@keyframes zone-2 {
  0%,
  17% {
    opacity: 0.4;
  }
  25%,
  92% {
    opacity: 1;
  }
  100% {
    opacity: 0.4;
  }
}

@keyframes zone-3 {
  0%,
  39% {
    opacity: 0.4;
  }
  47%,
  92% {
    opacity: 1;
  }
  100% {
    opacity: 0.4;
  }
}

@keyframes zone-4 {
  0%,
  60% {
    opacity: 0.4;
  }
  71%,
  92% {
    opacity: 1;
  }
  100% {
    opacity: 0.4;
  }
}

@keyframes pop-1 {
  0% {
    transform: scale(1);
  }
  3% {
    transform: scale(1.4);
  }
  9%,
  100% {
    transform: scale(1);
  }
}

@keyframes pop-2 {
  0%,
  23% {
    transform: scale(1);
  }
  26% {
    transform: scale(1.4);
  }
  32%,
  100% {
    transform: scale(1);
  }
}

@keyframes pop-3 {
  0%,
  45% {
    transform: scale(1);
  }
  48% {
    transform: scale(1.4);
  }
  54%,
  100% {
    transform: scale(1);
  }
}

@keyframes flash-1 {
  0% {
    opacity: 0;
    transform: scale(1);
  }
  2% {
    opacity: 1;
    transform: scale(1.1);
  }
  16%,
  100% {
    opacity: 0;
    transform: scale(3);
  }
}

@keyframes flash-2 {
  0%,
  23% {
    opacity: 0;
    transform: scale(1);
  }
  25% {
    opacity: 1;
    transform: scale(1.1);
  }
  39%,
  100% {
    opacity: 0;
    transform: scale(3);
  }
}

@keyframes flash-3 {
  0%,
  45% {
    opacity: 0;
    transform: scale(1);
  }
  47% {
    opacity: 1;
    transform: scale(1.1);
  }
  61%,
  100% {
    opacity: 0;
    transform: scale(3);
  }
}

@keyframes swell {
  from {
    transform: translateX(-4px);
  }
  to {
    transform: translateX(4px);
  }
}

@keyframes sway {
  from {
    transform: skewX(-3deg);
  }
  to {
    transform: skewX(3deg);
  }
}

@keyframes needle-seek {
  0%,
  100% {
    transform: rotate(-14deg);
  }
  35% {
    transform: rotate(22deg);
  }
  60% {
    transform: rotate(-6deg);
  }
  80% {
    transform: rotate(10deg);
  }
}

@keyframes flag-wave {
  from {
    transform: skewY(-7deg) scaleX(1);
  }
  to {
    transform: skewY(7deg) scaleX(0.92);
  }
}

@keyframes flag-raise {
  0%,
  70% {
    opacity: 0;
    transform: scaleY(0.2);
  }
  74%,
  92% {
    opacity: 1;
    transform: scaleY(1);
  }
  100% {
    opacity: 0;
    transform: scaleY(1);
  }
}

@keyframes stop-ring {
  0%,
  70% {
    opacity: 0;
    transform: scale(1);
  }
  72% {
    opacity: 0.9;
    transform: scale(1);
  }
  92%,
  100% {
    opacity: 0;
    transform: scale(3.2);
  }
}

.trail__labels {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--orange-bright);
}

.trail__labels li:last-child {
  color: var(--gold);
}

.trail__labels span {
  display: block;
  font-size: clamp(0.8rem, 2.6vw, 1.05rem);
  text-transform: uppercase;
  color: var(--paper);
}

.construction__status {
  margin: clamp(1.5rem, 4vh, 2.5rem) 0 0;
  font-size: 0.95rem;
  color: var(--text-muted);
  animation-delay: 1.3s;
}

.construction__footer {
  flex-shrink: 0;
  padding: 1.25rem var(--gutter) calc(1.25rem + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  border-top: 1px solid var(--line);
}

.construction__footer p {
  margin: 0;
}

.construction__footer a {
  color: var(--paper);
  font-weight: 600;
}

.construction__footer a:hover,
.construction__footer a:focus-visible {
  color: var(--orange-bright);
}

/* Reduced motion: show the finished route, no travel or float */
@media (prefers-reduced-motion: reduce) {
  .construction__sheen,
  .trail__marker,
  .trail__ring {
    display: none;
  }

  .trail__path {
    stroke-dashoffset: 0;
    animation: none;
  }

  .trail__flash {
    display: none;
  }

  .trail__flag,
  .trail__flag-cloth,
  .trail__zone,
  .trail__terrain--sea path,
  .trail__compass-needle,
  .trail__stop {
    animation: none;
  }

  .trail__stop circle {
    fill: var(--orange);
    stroke: var(--orange);
    animation: none;
  }

  .trail__stop--4 circle {
    fill: var(--gold);
    stroke: var(--gold);
  }
}
