/* ==========================================================================
   Gautavaris DigiSoft HUB — Gothic Cathedral Sigil & Twin Gates Preloader
   ========================================================================== */

html.gothic-preloading,
body.gothic-preloading {
  overflow: hidden !important;
}

.gothic-preloader {
  --gp-abyss: #050408;
  --gp-obsidian: #0c0812;
  --gp-gold: #d4af37;
  --gp-gold-bright: #f2d58a;
  --gp-gold-dim: #7a5e2b;
  --gp-crimson: #8f1d2c;
  --gp-crimson-bright: #c91a2b;
  --gp-parchment: #ece4d9;
  --gp-ash: #9e918a;

  position: fixed;
  inset: 0;
  z-index: 999999;
  display: grid;
  place-items: center;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  background: transparent;
}

/* Twin Obsidian Cathedral Gates */
.gp-gate {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  z-index: 1;
  background-color: var(--gp-abyss);
  background-image:
    radial-gradient(ellipse 90% 60% at 50% 45%, rgba(143, 29, 44, 0.16), transparent 72%),
    linear-gradient(180deg, rgba(12, 8, 18, 0.96) 0%, rgba(5, 4, 8, 0.99) 52%, rgba(10, 5, 10, 0.98) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cg fill='none' stroke='%23d4af37' stroke-opacity='0.055' stroke-width='1'%3E%3Cpath d='M48 0 L96 48 L48 96 L0 48 Z'/%3E%3Cpath d='M48 16 L80 48 L48 80 L16 48 Z'/%3E%3Ccircle cx='48' cy='48' r='6'/%3E%3C/g%3E%3C/svg%3E");
  transition: transform 0.85s cubic-bezier(0.76, 0, 0.24, 1);
  will-change: transform;
}

.gp-gate-left {
  left: 0;
  border-right: 1px solid rgba(212, 175, 55, 0.34);
  box-shadow: inset -24px 0 60px rgba(0, 0, 0, 0.85);
}

.gp-gate-right {
  right: 0;
  border-left: 1px solid rgba(212, 175, 55, 0.34);
  box-shadow: inset 24px 0 60px rgba(0, 0, 0, 0.85);
}

/* Center seam gilded filigree & diamond clasp */
.gp-gate-left::before,
.gp-gate-right::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(212, 175, 55, 0.14) 18%,
    rgba(242, 213, 138, 0.42) 50%,
    rgba(212, 175, 55, 0.14) 82%,
    transparent 100%
  );
  pointer-events: none;
}

.gp-gate-left::before {
  right: 5px;
}

.gp-gate-right::before {
  left: 5px;
}

.gp-gate-left::after,
.gp-gate-right::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border: 1px solid rgba(212, 175, 55, 0.6);
  background: var(--gp-crimson);
  box-shadow: 0 0 12px rgba(201, 26, 43, 0.6);
  transform: translateY(-50%) rotate(45deg);
  pointer-events: none;
}

.gp-gate-left::after {
  right: -6px;
}

.gp-gate-right::after {
  left: -6px;
}

.gothic-preloader.is-opening .gp-gate-left {
  transform: translate3d(-102%, 0, 0);
}

.gothic-preloader.is-opening .gp-gate-right {
  transform: translate3d(102%, 0, 0);
}

/* Vignette */
.gp-vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(
    circle at 50% 48%,
    transparent 24%,
    rgba(5, 4, 8, 0.55) 70%,
    rgba(2, 1, 4, 0.92) 100%
  );
  transition: opacity 0.45s ease;
}

/* Four Gold Filigree Viewport Corners */
.gp-corners {
  position: absolute;
  inset: 18px;
  z-index: 3;
  pointer-events: none;
  transition: opacity 0.38s ease;
}

.gp-corner {
  position: absolute;
  width: 46px;
  height: 46px;
  border-color: rgba(212, 175, 55, 0.55);
  border-style: solid;
  border-width: 0;
}

.gp-corner::before {
  content: "";
  position: absolute;
  width: 26px;
  height: 26px;
  border-color: rgba(212, 175, 55, 0.24);
  border-style: solid;
  border-width: 0;
}

.gp-corner::after {
  content: "✦";
  position: absolute;
  font-size: 0.72rem;
  line-height: 1;
  color: var(--gp-gold-bright);
  text-shadow: 0 0 8px rgba(212, 175, 55, 0.65);
}

.gp-tl {
  top: 0;
  left: 0;
  border-top-width: 1px;
  border-left-width: 1px;
}
.gp-tl::before {
  top: 6px;
  left: 6px;
  border-top-width: 1px;
  border-left-width: 1px;
}
.gp-tl::after {
  top: 9px;
  left: 9px;
}

.gp-tr {
  top: 0;
  right: 0;
  border-top-width: 1px;
  border-right-width: 1px;
}
.gp-tr::before {
  top: 6px;
  right: 6px;
  border-top-width: 1px;
  border-right-width: 1px;
}
.gp-tr::after {
  top: 9px;
  right: 9px;
}

.gp-bl {
  bottom: 0;
  left: 0;
  border-bottom-width: 1px;
  border-left-width: 1px;
}
.gp-bl::before {
  bottom: 6px;
  left: 6px;
  border-bottom-width: 1px;
  border-left-width: 1px;
}
.gp-bl::after {
  bottom: 9px;
  left: 9px;
}

.gp-br {
  bottom: 0;
  right: 0;
  border-bottom-width: 1px;
  border-right-width: 1px;
}
.gp-br::before {
  bottom: 6px;
  right: 6px;
  border-bottom-width: 1px;
  border-right-width: 1px;
}
.gp-br::after {
  bottom: 9px;
  right: 9px;
}

/* Rising Gold & Crimson Ember Motes */
.gp-embers {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
  transition: opacity 0.38s ease;
}

.gp-ember {
  position: absolute;
  bottom: -18px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  opacity: 0;
  background: radial-gradient(circle, #fff3cc 0%, var(--gp-gold) 55%, transparent 100%);
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.75);
  animation: gpEmberRise 5.4s linear infinite;
}

.gp-ember:nth-child(even) {
  width: 3px;
  height: 3px;
  background: radial-gradient(circle, #ffb3bd 0%, var(--gp-crimson-bright) 60%, transparent 100%);
  box-shadow: 0 0 9px rgba(201, 26, 43, 0.85);
}

.gp-ember:nth-child(1) { left: 14%; animation-duration: 5.2s; animation-delay: 0.1s; }
.gp-ember:nth-child(2) { left: 26%; animation-duration: 6.1s; animation-delay: 1.4s; }
.gp-ember:nth-child(3) { left: 37%; animation-duration: 4.8s; animation-delay: 0.6s; }
.gp-ember:nth-child(4) { left: 46%; animation-duration: 5.8s; animation-delay: 2.1s; }
.gp-ember:nth-child(5) { left: 55%; animation-duration: 4.9s; animation-delay: 0.9s; }
.gp-ember:nth-child(6) { left: 64%; animation-duration: 6.4s; animation-delay: 1.8s; }
.gp-ember:nth-child(7) { left: 76%; animation-duration: 5.1s; animation-delay: 0.3s; }
.gp-ember:nth-child(8) { left: 87%; animation-duration: 5.9s; animation-delay: 1.1s; }

/* Centerpiece Stage */
.gp-stage {
  position: relative;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  max-width: 440px;
  padding: 1.5rem;
  transition: opacity 0.42s ease, transform 0.48s cubic-bezier(0.22, 1, 0.36, 1);
}

.gp-sigil-wrap {
  position: relative;
  width: 184px;
  height: 184px;
  display: grid;
  place-items: center;
  margin-bottom: 1.45rem;
}

.gp-aura {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(201, 26, 43, 0.28) 0%,
    rgba(212, 175, 55, 0.14) 44%,
    transparent 72%
  );
  animation: gpAuraPulse 3.2s ease-in-out infinite;
  pointer-events: none;
}

.gp-sigil-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.gp-ring-outer {
  transform-origin: 110px 110px;
  animation: gpSpinCW 26s linear infinite;
}

.gp-ring-inner {
  transform-origin: 110px 110px;
  animation: gpSpinCCW 16s linear infinite;
}

.gp-progress-track {
  fill: none;
  stroke: rgba(212, 175, 55, 0.16);
  stroke-width: 2.2;
}

.gp-progress-arc {
  fill: none;
  stroke: var(--gp-gold-bright);
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-dasharray: 540.35;
  stroke-dashoffset: 540.35;
  transform: rotate(-90deg);
  transform-origin: 110px 110px;
  filter: drop-shadow(0 0 6px rgba(242, 213, 138, 0.65));
  transition: stroke-dashoffset 0.12s linear;
}

/* Central Medallion */
.gp-medallion {
  position: relative;
  width: 102px;
  height: 102px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(circle at 35% 30%, rgba(143, 29, 44, 0.45), rgba(12, 8, 18, 0.96) 72%);
  border: 1.5px solid var(--gp-gold);
  box-shadow:
    0 0 0 4px rgba(12, 8, 18, 0.9),
    0 0 0 5px rgba(212, 175, 55, 0.35),
    0 0 28px rgba(201, 26, 43, 0.38),
    inset 0 0 18px rgba(212, 175, 55, 0.16);
  animation: gpMedallionFloat 3.8s ease-in-out infinite;
  transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
}

.gp-medallion::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -120%;
  width: 65%;
  height: 200%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 244, 210, 0.24),
    transparent
  );
  transform: rotate(24deg);
  animation: gpSheenSweep 3.4s ease-in-out infinite;
  pointer-events: none;
}

.gp-crest-img {
  width: 66px;
  height: 66px;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(242, 213, 138, 0.45));
  position: relative;
  z-index: 1;
}

.gp-crest-fallback {
  display: none;
  font-size: 2.2rem;
  line-height: 1;
  color: var(--gp-gold-bright);
  text-shadow: 0 0 14px rgba(212, 175, 55, 0.7), 0 0 24px rgba(201, 26, 43, 0.6);
  position: relative;
  z-index: 1;
}

/* Typography & Divider */
.gp-title {
  font-family: "Cinzel Decorative", "Cinzel", Georgia, serif;
  font-size: clamp(1.75rem, 4.8vw, 2.55rem);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: 0.08em;
  margin: 0 0 0.35rem;
  background: linear-gradient(180deg, #fff6de 0%, var(--gp-gold-bright) 52%, var(--gp-gold-dim) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 16px rgba(143, 29, 44, 0.55));
  animation: gpCandleGlow 3.2s ease-in-out infinite alternate;
}

.gp-title--blackletter {
  font-family: "UnifrakturMaguntia", "Cinzel", serif;
  font-weight: 400;
  letter-spacing: 0.05em;
  font-size: clamp(2.15rem, 5.4vw, 3rem);
}

.gp-subtitle {
  font-family: "Cinzel", Georgia, serif;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gp-ash);
  margin: 0;
}

.gp-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  width: min(240px, 72vw);
  margin: 0.95rem auto 0;
}

.gp-divider::before,
.gp-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.75), transparent);
}

.gp-divider span {
  font-size: 0.85rem;
  line-height: 1;
  color: var(--gp-gold);
  text-shadow: 0 0 10px rgba(212, 175, 55, 0.55);
}

/* Progress Bar & Status Inscription */
.gp-progress-box {
  width: min(290px, 82vw);
  margin: 0.9rem auto 0;
}

.gp-progress-track-bar {
  position: relative;
  height: 4px;
  background: rgba(212, 175, 55, 0.14);
  border: 1px solid rgba(212, 175, 55, 0.3);
  overflow: visible;
}

.gp-progress-track-bar::before,
.gp-progress-track-bar::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 6px;
  height: 6px;
  background: var(--gp-gold);
  border: 1px solid var(--gp-abyss);
  transform: translateY(-50%) rotate(45deg);
}

.gp-progress-track-bar::before {
  left: -4px;
}

.gp-progress-track-bar::after {
  right: -4px;
}

.gp-progress-fill {
  position: relative;
  height: 100%;
  width: 0%;
  background: linear-gradient(
    90deg,
    var(--gp-crimson) 0%,
    var(--gp-crimson-bright) 38%,
    var(--gp-gold) 82%,
    #fff2c6 100%
  );
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.55);
  transition: width 0.1s linear;
}

.gp-progress-fill::after {
  content: "";
  position: absolute;
  right: -2px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff8de;
  box-shadow: 0 0 10px var(--gp-gold-bright), 0 0 16px rgba(201, 26, 43, 0.8);
  transform: translateY(-50%);
}

.gp-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.65rem;
}

.gp-status-text {
  font-family: "Fira Code", "JetBrains Mono", Consolas, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gp-ash);
  text-align: left;
  transition: color 0.25s ease;
}

.gp-percent {
  font-family: "Fira Code", "JetBrains Mono", Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--gp-gold-bright);
  flex-shrink: 0;
}

/* Completion, Opening & Done States */
.gothic-preloader.is-complete .gp-medallion {
  transform: scale(1.04);
  border-color: #fff2c6;
  box-shadow:
    0 0 0 4px rgba(32, 8, 14, 0.95),
    0 0 0 6px rgba(242, 213, 138, 0.78),
    0 0 38px rgba(201, 26, 43, 0.75),
    0 0 54px rgba(212, 175, 55, 0.45);
}

.gothic-preloader.is-complete .gp-status-text {
  color: var(--gp-gold-bright);
}

.gothic-preloader.is-opening {
  pointer-events: none;
}

.gothic-preloader.is-opening .gp-stage {
  opacity: 0;
  transform: scale(0.95);
}

.gothic-preloader.is-opening .gp-corners,
.gothic-preloader.is-opening .gp-embers,
.gothic-preloader.is-opening .gp-vignette {
  opacity: 0;
}

.gothic-preloader.is-done {
  display: none !important;
  visibility: hidden;
}

/* Keyframes */
@keyframes gpSpinCW {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes gpSpinCCW {
  from { transform: rotate(360deg); }
  to { transform: rotate(0deg); }
}

@keyframes gpMedallionFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes gpAuraPulse {
  0%, 100% {
    opacity: 0.65;
    transform: scale(0.96);
  }
  50% {
    opacity: 1;
    transform: scale(1.06);
  }
}

@keyframes gpCandleGlow {
  0% { filter: drop-shadow(0 4px 14px rgba(143, 29, 44, 0.48)); }
  100% { filter: drop-shadow(0 4px 22px rgba(212, 175, 55, 0.42)); }
}

@keyframes gpSheenSweep {
  0%, 20% { left: -120%; }
  55%, 100% { left: 165%; }
}

@keyframes gpEmberRise {
  0% {
    transform: translate3d(0, 0, 0) scale(0.8);
    opacity: 0;
  }
  15% {
    opacity: 0.78;
  }
  75% {
    opacity: 0.45;
  }
  100% {
    transform: translate3d(14px, -105vh, 0) scale(0.25);
    opacity: 0;
  }
}

/* Mobile Adjustments */
@media (max-width: 520px) {
  .gp-corners {
    inset: 12px;
  }
  .gp-corner {
    width: 28px;
    height: 28px;
  }
  .gp-corner::before {
    width: 16px;
    height: 16px;
  }
  .gp-corner::after {
    font-size: 0.58rem;
  }
  .gp-sigil-wrap {
    width: 156px;
    height: 156px;
    margin-bottom: 1.15rem;
  }
  .gp-medallion {
    width: 86px;
    height: 86px;
  }
  .gp-crest-img {
    width: 54px;
    height: 54px;
  }
  .gp-subtitle {
    letter-spacing: 0.18em;
    font-size: 0.62rem;
  }
  .gp-status-text {
    font-size: 0.62rem;
    letter-spacing: 0.1em;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .gp-ring-outer,
  .gp-ring-inner,
  .gp-medallion,
  .gp-medallion::after,
  .gp-aura,
  .gp-title,
  .gp-ember {
    animation: none !important;
  }
  .gp-embers {
    display: none;
  }
  .gp-gate {
    transition-duration: 0.25s;
  }
  .gp-stage,
  .gp-corners,
  .gp-vignette {
    transition-duration: 0.2s;
  }
}
