/* ============================================================
   CASTLE GATE — STYLESHEET
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700;900&family=Uncial+Antiqua&display=swap');

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

:root {
  --wood-dark:    #3b2210;
  --wood-mid:     #5c3317;
  --wood-light:   #8B5E3C;
  --wood-grain:   #6b3f1e;
  --wood-edge:    #2a1608;
  --gold:         #c9a84c;
  --gold-light:   #f5d98b;
  --gold-dark:    #7a5c1a;
  --parchment:    #f2e8c9;
  --parchment2:   #e8d9a8;
  --ink:          #1a0f05;
  --ink-light:    #3a2010;
  --stone:        #4a4a52;
  --stone-light:  #6a6a74;
  --iron:         #2d2d30;
  --torch-orange: #ff7700;
  --torch-yellow: #ffdd00;
  --mist:         rgba(180, 200, 220, 0.15);
  --shadow-deep:  rgba(0,0,0,0.85);
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #0a0a0f;
  font-family: 'Cinzel', serif;
  cursor: default;
  user-select: none;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 40%, rgba(0, 0, 0, 0.7) 120%);
  z-index: 9999;
}

/* ── Canvas ──────────────────────────────────────────────── */
#castle-canvas {
  position: fixed;
  inset: 0;
  width: 100%; height: 100%;
  display: block;
  cursor: pointer;
}

/* ── Fog overlay ──────────────────────────────────────────── */
#fog-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 120% 40% at 50% 100%, rgba(100,120,150,0.35) 0%, transparent 70%),
    radial-gradient(ellipse 80% 30% at 20% 100%, rgba(80,100,130,0.2) 0%, transparent 60%),
    radial-gradient(ellipse 80% 30% at 80% 100%, rgba(80,100,130,0.2) 0%, transparent 60%);
  animation: fogDrift 12s ease-in-out infinite alternate;
  z-index: 5;
}

@keyframes fogDrift {
  0%   { opacity: 0.6; transform: scaleX(1) translateY(0); }
  100% { opacity: 1;   transform: scaleX(1.05) translateY(-8px); }
}

/* ── Torch lights ─────────────────────────────────────────── */
.torch-light {
  position: fixed;
  bottom: 22%;
  width: 220px; height: 320px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 6;
  animation: torchFlicker 0.12s ease-in-out infinite alternate;
}
.left-torch  { left: 14%;  background: radial-gradient(ellipse at center, rgba(255,140,0,0.22) 0%, transparent 70%); }
.right-torch { right: 14%; background: radial-gradient(ellipse at center, rgba(255,140,0,0.22) 0%, transparent 70%); animation-delay: 0.06s; }

@keyframes torchFlicker {
  0%   { opacity: 0.7; transform: scale(1); }
  100% { opacity: 1;   transform: scale(1.08); }
}

/* ── Particles ────────────────────────────────────────────── */
#particles-overlay {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 7;
  overflow: hidden;
}
.particle {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,200,80,0.6);
  animation: particleFloat linear infinite;
}
@keyframes particleFloat {
  0%   { transform: translateY(0) scale(1);   opacity: 0.8; }
  80%  { opacity: 0.4; }
  100% { transform: translateY(-100vh) scale(0.3); opacity: 0; }
}

/* ── Click prompt ─────────────────────────────────────────── */
#click-prompt {
  position: fixed;
  bottom: 5%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  text-align: center;
  animation: promptPulse 2.4s ease-in-out infinite;
}
.prompt-inner {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: rgba(10,6,2,0.7);
  border: 1px solid rgba(201,168,76,0.4);
  border-radius: 12px;
  padding: 14px 28px;
  backdrop-filter: blur(6px);
  box-shadow: 0 0 24px rgba(201,168,76,0.15), inset 0 1px 0 rgba(255,255,255,0.05);
}
.prompt-icon { font-size: 1.6rem; }
.prompt-inner p { color: var(--parchment); font-size: 0.85rem; letter-spacing: 0.1em; }
.prompt-inner strong { color: var(--gold-light); }
.prompt-chevrons { display: flex; gap: 4px; margin-top: 2px; }
.prompt-chevrons span {
  display: block; width: 8px; height: 8px;
  border-right: 2px solid var(--gold); border-bottom: 2px solid var(--gold);
  transform: rotate(45deg);
  animation: chevronBounce 1.2s ease-in-out infinite;
}
.prompt-chevrons span:nth-child(2) { animation-delay: 0.15s; }
.prompt-chevrons span:nth-child(3) { animation-delay: 0.30s; }

@keyframes chevronBounce {
  0%,100% { transform: rotate(45deg) translateY(0); opacity: 0.4; }
  50%      { transform: rotate(45deg) translateY(3px); opacity: 1; }
}
@keyframes promptPulse {
  0%,100% { transform: translateX(-50%) translateY(0);   opacity: 0.85; }
  50%      { transform: translateX(-50%) translateY(-5px); opacity: 1; }
}



/* ── Wooden Sign ──────────────────────────────────────────── */
.wooden-sign {
  position: absolute;
  width: 520px;
  height: 380px;
  border-radius: 0px;
  overflow: visible;
  pointer-events: auto; /* Allow interaction over 3D canvas */
  transform-origin: center center;
  background: rgba(15, 8, 3, 0.45); /* Dark translucent tint for contrast */
  border: 1px solid rgba(0,0,0,0.6);
  box-shadow: inset 0 0 50px rgba(0,0,0,0.7);
}

/* Wood planks effect */
.wooden-sign::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: 0px;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 58px,
    rgba(0,0,0,0.18) 58px,
    rgba(0,0,0,0.18) 62px
  );
  pointer-events: none;
}
/* Worn edge highlight */
.wooden-sign::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: 0px;
  background: linear-gradient(135deg, rgba(255,200,120,0.12) 0%, transparent 50%, rgba(0,0,0,0.2) 100%);
  pointer-events: none;
}

.sign-face {
  position: relative; z-index: 2;
  padding: 28px 32px 32px;
  display: flex; flex-direction: column; gap: 14px;
}

.sign-header {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; flex-wrap: wrap;
}
.sign-header h2 {
  font-family: 'Cinzel', serif;
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--gold-light);
  text-shadow: 0 2px 6px rgba(0,0,0,1), 0 0 16px rgba(201,168,76,0.8);
  letter-spacing: 0.05em;
  text-align: center;
}
.scroll-icon { font-size: 1.2rem; flex-shrink: 0; }

.sign-divider {
  height: 2px;
  background: linear-gradient(to right, transparent, var(--gold-dark), var(--gold), var(--gold-dark), transparent);
  border-radius: 1px;
}

.sign-subtitle {
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff6e0;
  text-align: center;
  line-height: 1.6;
  text-shadow: 0 2px 5px rgba(0,0,0,0.9);
  opacity: 0.95;
}

/* Sign nails */
.sign-nail {
  position: absolute;
  width: 14px; height: 14px;
  background: radial-gradient(circle at 35% 35%, #aaa, #444);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5), inset 0 1px 1px rgba(255,255,255,0.2);
  z-index: 10;
}
.sign-nail.tl { top: 10px;  left: 12px;  }
.sign-nail.tr { top: 10px;  right: 12px; }
.sign-nail.bl { bottom: 10px; left: 12px;  }
.sign-nail.br { bottom: 10px; right: 12px; }

/* ── Forms ────────────────────────────────────────────────── */
.sign-form { display: flex; flex-direction: column; gap: 16px; }

.input-row {
  display: flex; gap: 10px; align-items: flex-end;
}
.input-group {
  display: flex; flex-direction: column; gap: 5px;
  flex: 1;
}
.input-group.wide { flex: 1.6; }
.input-group.centered { width: 100%; }

label {
  font-family: 'Cinzel', serif;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-shadow: 0 2px 4px rgba(0,0,0,0.9);
}

input[type="number"],
input[type="password"],
input[type="text"] {
  background: rgba(10,5,2,0.65);
  border: 1.5px solid var(--gold-dark);
  border-radius: 5px;
  color: var(--parchment);
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  padding: 9px 11px;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
  width: 100%;
  -moz-appearance: textfield;
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button { -webkit-appearance: none; }
input:focus {
  border-color: var(--gold);
  background: rgba(15,8,3,0.85);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.2), 0 0 12px rgba(201,168,76,0.15);
}
input::placeholder { color: rgba(210,190,140,0.35); }

.password-wrapper {
  position: relative; display: flex; align-items: center;
}
.password-wrapper input { padding-right: 40px; }
.eye-btn {
  position: absolute; right: 8px;
  background: none; border: none;
  font-size: 1rem; cursor: pointer;
  opacity: 0.6; transition: opacity 0.2s;
  padding: 0;
}
.eye-btn:hover { opacity: 1; }

/* Error */
.sign-error {
  font-size: 0.75rem;
  color: #ff8866;
  text-align: center;
  text-shadow: 0 0 8px rgba(255,100,50,0.5);
  animation: errorShake 0.4s ease;
}
.sign-error.hidden { display: none; }
@keyframes errorShake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

/* ── Buttons ──────────────────────────────────────────────── */
.sign-btn {
  position: relative;
  background: linear-gradient(135deg, #5c3a0a 0%, #8b5e20 50%, #5c3a0a 100%);
  border: 2px solid var(--gold-dark);
  border-radius: 6px;
  color: var(--gold-light);
  font-family: 'Cinzel', serif;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 12px 24px;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.2s, border-color 0.2s;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,220,100,0.2);
  align-self: center;
  min-width: 180px;
}
.sign-btn:hover {
  transform: translateY(-2px);
  border-color: var(--gold);
  box-shadow: 0 6px 24px rgba(0,0,0,0.6), 0 0 20px rgba(201,168,76,0.25), inset 0 1px 0 rgba(255,220,100,0.3);
}
.sign-btn:active { transform: translateY(0); }
.sign-btn.gold {
  background: linear-gradient(135deg, var(--gold-dark) 0%, var(--gold) 50%, var(--gold-dark) 100%);
  color: var(--ink);
  text-shadow: none;
}
.sign-btn.gold:hover { box-shadow: 0 6px 24px rgba(0,0,0,0.6), 0 0 30px rgba(201,168,76,0.5); }

.btn-glow {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,220,100,0.15) 50%, transparent 100%);
  transform: translateX(-100%);
  transition: transform 0.4s;
}
.sign-btn:hover .btn-glow { transform: translateX(100%); }
.btn-text { position: relative; z-index: 1; }


/* ── Success overlay ──────────────────────────────────────── */
#success-overlay {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at center, rgba(30,20,5,0.95) 0%, rgba(0,0,0,0.98) 100%);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
#success-overlay.hidden { display: none; }

.success-content {
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  animation: successReveal 1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes successReveal {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.success-crest {
  font-size: 4rem;
  animation: crestPulse 1.5s ease-in-out infinite alternate;
}
@keyframes crestPulse {
  0%   { filter: drop-shadow(0 0 8px rgba(201,168,76,0.4)); }
  100% { filter: drop-shadow(0 0 24px rgba(201,168,76,0.9)); }
}

.success-content h1 {
  font-family: 'Cinzel', serif;
  font-size: clamp(1.5rem, 5vw, 2.8rem);
  font-weight: 900;
  color: var(--gold-light);
  text-shadow: 0 0 30px rgba(201,168,76,0.6);
  letter-spacing: 0.08em;
}
.success-content p {
  font-family: 'Cinzel', serif;
  font-size: clamp(0.8rem, 2.5vw, 1rem);
  color: var(--parchment2);
  letter-spacing: 0.1em;
  opacity: 0.8;
}

/* Gate opening animation */
.success-gate-anim {
  display: flex;
  width: 200px; height: 120px;
  margin-top: 10px;
  position: relative;
  overflow: hidden;
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
}
.gate-half {
  width: 50%; height: 100%;
  background: linear-gradient(
    to right,
    #3b2210, #5c3317 40%, #3b2210
  );
  border: 1px solid #222;
}
.gate-half.left  { transform-origin: left center;  animation: gateOpenLeft  1.2s 0.5s cubic-bezier(0.4,0,0.2,1) forwards; }
.gate-half.right { transform-origin: right center; animation: gateOpenRight 1.2s 0.5s cubic-bezier(0.4,0,0.2,1) forwards; }

@keyframes gateOpenLeft  {
  from { transform: rotateY(0deg);    }
  to   { transform: rotateY(-80deg); }
}
@keyframes gateOpenRight {
  from { transform: rotateY(0deg);   }
  to   { transform: rotateY(80deg);  }
}

/* ── Utility ──────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Background scene vignette ────────────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0;
  background: radial-gradient(ellipse 100% 100% at 50% 50%, transparent 40%, rgba(0,0,0,0.6) 100%);
  pointer-events: none;
  z-index: 4;
}

/* ── Responsive tweaks ── */
/* Removed @media query since CSS3DObject handles 3D scaling for the fixed 520x380 board */

/* ── Loading Screen ───────────────────────────────────────── */
#loading-screen {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: #06080f;
  z-index: 999999;
  display: flex; justify-content: center; align-items: center;
  color: var(--gold);
  font-family: 'Cinzel', serif;
  transition: opacity 1.2s ease, visibility 1.2s ease;
}
#loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
}
.loader-content { text-align: center; }
.loader-spinner {
  width: 60px; height: 60px;
  margin: 0 auto 24px;
  border: 3px solid rgba(229, 204, 143, 0.1);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1s infinite cubic-bezier(0.6, 0.1, 0.4, 0.9);
}
@keyframes spin { 
  to { transform: rotate(360deg); } 
}

/* ── Intro Title Overlay ────────────────────────────────────── */
#intro-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 10000;
}

#intro-svg {
  position: absolute;
  width: 100%;
  max-width: 1200px;
  height: 100%;
  max-height: 800px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

#intro-text-container {
  font-family: 'Great Vibes', cursive;
  font-size: clamp(4rem, 12vw, 14rem);
  color: #fff;
  text-shadow: 0 0 20px rgba(255, 200, 100, 0.8), 0 0 40px rgba(255, 150, 50, 0.6);
  display: flex;
  gap: 2px;
  position: relative;
  z-index: 10001;
}

.intro-letter {
  opacity: 0;
  transform: translateY(20px) scale(0.8);
  will-change: opacity, transform;
  display: inline-block;
}

#intro-firefly {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 15px 5px #fff, 0 0 35px 15px #ffaa00;
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  z-index: 10002;
}
