/* ===== Web fonts (vendored — works offline + on the static host) =====
 * Latin-only subset; ~74 KB total. The site referenced Cinzel + Inter
 * everywhere but never declared @font-face, so headlines silently fell back
 * to Times. (REVIEW_visual.md V-001.) The woff2 files live in
 * www/vendor/fonts/ so they ship with the rsync deploy artifact. */
@font-face {
  font-family: 'Cinzel';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('../vendor/fonts/cinzel-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../vendor/fonts/inter-latin.woff2') format('woff2');
}

/* ===== Reset & base ===== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; background: #000; color: #eee; font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; }

a { color: inherit; }

/* ===== Brightness top bar ===== */
#brightness-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 36px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.85), rgba(0,0,0,0.65));
  border-bottom: 1px solid rgba(255,255,255,0.08);
  color: #f0f0f0;
  font-size: 13px;
  z-index: 1000;
  user-select: none;
  backdrop-filter: blur(6px);
}
#brightness-bar .bb-label { opacity: 0.85; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; font-size: 11px; }
#brightness-bar input[type="range"] {
  width: 200px; accent-color: #d4af37;
  cursor: pointer;
}
#brightness-bar .bb-readout { font-variant-numeric: tabular-nums; min-width: 50px; opacity: 0.95; }
#brightness-bar .bb-keys, #brightness-bar .bb-hint { opacity: 0.55; font-size: 12px; }
#brightness-bar .bb-spacer { flex: 1; }
#brightness-bar kbd {
  background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.2);
  padding: 1px 6px; border-radius: 4px; font-size: 11px; font-family: ui-monospace, monospace;
}

/* ===== Stage (CSS3D + WebGL) ===== */
#stage {
  position: fixed; top: 36px; left: 0; right: 0; bottom: 0;
}
#css3d {
  position: absolute; top: 0; left: 0;
  pointer-events: none;
  z-index: 0;
}
#webgl {
  position: absolute; top: 0; left: 0;
  z-index: 1;
  background: transparent;
  cursor: crosshair;
  display: block;
}
.theme-classical #webgl { cursor: crosshair; }
.theme-surreal #webgl { cursor: crosshair; }
.theme-castle #webgl { cursor: crosshair; image-rendering: pixelated; }

/* CSS3D iframe wrapper. Pointer events disabled by default. */
.art-wrap { position: relative; overflow: hidden; }
.art-wrap iframe { display: block; }

/* Fallback card shown if the iframe is blocked by X-Frame-Options or fails
   to load. Themed to match the surrounding scene. */
.art-fallback {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 60px;
  font-family: 'Inter', -apple-system, sans-serif;
  pointer-events: auto;
}
.theme-classical .art-fallback {
  background: linear-gradient(180deg, #2a1f12 0%, #14100a 100%);
  color: #f0e6d0;
}
.theme-surreal .art-fallback {
  background: radial-gradient(ellipse at center, #1a0e2a 0%, #050310 100%);
  color: #dffcff;
}
.theme-castle .art-fallback {
  background: linear-gradient(180deg, #1a2848 0%, #06102a 100%);
  color: #fff2c8;
  font-family: 'Cinzel', 'Times New Roman', serif;
  image-rendering: pixelated;
}
.theme-castle .art-fallback .af-title {
  font-family: 'Cinzel', 'Times New Roman', serif;
  color: #ffd66e;
  text-shadow: 0 2px 0 #6a4a10;
}
.art-fallback .af-eyebrow {
  font-size: 14px; letter-spacing: 0.4em; text-transform: uppercase; opacity: 0.55;
  margin-bottom: 18px; font-family: ui-monospace, monospace;
}
.art-fallback .af-title {
  font-size: 64px; line-height: 1; margin-bottom: 20px;
}
.theme-classical .art-fallback .af-title {
  font-family: 'Cinzel', serif; color: #d4af37;
}
.theme-surreal .art-fallback .af-title {
  font-family: 'Inter', sans-serif; font-weight: 200; letter-spacing: 0.05em;
  background: linear-gradient(90deg, #7af0ff, #ff6ad5);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.art-fallback .af-desc {
  font-size: 22px; max-width: 80%; line-height: 1.5; opacity: 0.7;
  margin-bottom: 28px;
}
.art-fallback .af-link {
  font-family: ui-monospace, monospace; font-size: 16px; opacity: 0.75;
  text-decoration: none; padding: 10px 18px;
  border: 1px solid currentColor; border-radius: 4px;
}
.art-fallback .af-link:hover { opacity: 1; }

/* ===== HUD ===== */
#hud {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  font-size: 13px;
  z-index: 100;
  pointer-events: none;
  backdrop-filter: blur(8px);
}
#hud.locked #hud-instructions strong { color: #9ee08a; }
#hud-instructions strong { color: #ffd66e; margin-right: 10px; }
#hud-instructions .kb { opacity: 0.8; }
#hud kbd {
  background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.2);
  padding: 1px 6px; border-radius: 4px; font-size: 11px; font-family: ui-monospace, monospace; margin: 0 2px;
}
#hud-back { pointer-events: auto; opacity: 0.85; text-decoration: none; padding-left: 12px; border-left: 1px solid rgba(255,255,255,0.15); }
#hud-back:hover { opacity: 1; }
#load-counter { opacity: 0.65; font-size: 12px; font-variant-numeric: tabular-nums; }

/* ===== Loading screen ===== */
#loading {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at center, #1a1410 0%, #050302 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
  transition: opacity 0.55s ease;
}
.theme-surreal #loading {
  background: radial-gradient(ellipse at center, #0a0820 0%, #000 100%);
}
.theme-castle #loading {
  background: radial-gradient(ellipse at 50% 70%, #1a2240 0%, #050714 65%, #000 100%);
}
.theme-castle .loading-title {
  font-family: 'Cinzel', 'Times New Roman', serif;
  color: #ffd66e;
  text-shadow: 0 2px 0 #6a4a10, 0 0 18px rgba(255,200,80,0.35);
  font-size: 38px;
}
.theme-castle .spinner { border-top-color: #ffd66e; }
#loading.done { opacity: 0; }
.loading-inner { text-align: center; }
.loading-title {
  font-family: 'Cinzel', 'Times New Roman', serif;
  font-size: 36px; letter-spacing: 0.15em;
  color: #d4af37; margin-bottom: 8px;
}
.theme-surreal .loading-title { color: #7af0ff; font-family: 'Inter', sans-serif; letter-spacing: 0.25em; text-transform: uppercase; font-weight: 200; }
.loading-sub { font-size: 13px; opacity: 0.65; margin-bottom: 22px; }
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: #d4af37;
  margin: 0 auto;
  animation: spin 1s linear infinite;
}
.theme-surreal .spinner { border-top-color: #7af0ff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Focus mode overlay ===== */
#focus-overlay {
  position: fixed; top: 36px; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 200;
}
.focus-mode #css3d { pointer-events: auto; }
.focus-mode #webgl { pointer-events: none; opacity: 0.55; transition: opacity 0.3s; }
#focus-overlay .fo-hint {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.78); padding: 10px 18px; border-radius: 999px;
  font-size: 13px; pointer-events: auto;
  border: 1px solid rgba(255,255,255,0.15);
}
#focus-overlay kbd {
  background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.2);
  padding: 1px 6px; border-radius: 4px; font-size: 11px; font-family: ui-monospace, monospace; margin: 0 2px;
}
#focus-overlay a { color: #ffd66e; text-decoration: none; margin-left: 8px; }
#focus-overlay a:hover { text-decoration: underline; }

/* ===== Debug overlay ===== */
#debug-overlay {
  position: fixed; top: 48px; right: 12px;
  background: rgba(0,0,0,0.75); color: #9ef0ff;
  padding: 8px 12px; border-radius: 6px;
  font-family: ui-monospace, monospace; font-size: 12px;
  z-index: 999;
  pointer-events: none;
  border: 1px solid rgba(158,240,255,0.25);
}
#debug-overlay strong { color: #fff; }
#debug-overlay div { line-height: 1.5; }

/* ===== Touch / mobile fallback ===== */
#touch-fallback {
  position: fixed; inset: 0; z-index: 3000;
  display: none;
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #1a1410 0%, #050302 100%);
  color: #f0e6d0;
  padding: 28px 22px;
  font-family: 'Inter', -apple-system, sans-serif;
  text-align: center;
}
.theme-surreal #touch-fallback { background: radial-gradient(ellipse at center, #0a0820 0%, #000 100%); color: #dffcff; }
.theme-castle    #touch-fallback { background: radial-gradient(ellipse at 50% 70%, #1a2240 0%, #050714 100%); color: #fff2c8; }
html.touch #touch-fallback { display: flex; }
html.touch #stage { filter: brightness(0.55); pointer-events: none; }
#touch-fallback .tf-inner { max-width: 460px; }
#touch-fallback h2 {
  font-family: 'Cinzel', serif;
  font-size: 26px; letter-spacing: 0.08em;
  color: #ffd66e; margin: 0 0 12px;
}
.theme-surreal #touch-fallback h2 { color: #7af0ff; font-family: 'Inter', sans-serif; text-transform: uppercase; font-weight: 300; letter-spacing: 0.22em; }
#touch-fallback p { font-size: 14px; line-height: 1.55; opacity: 0.78; margin: 0 0 18px; }
#touch-fallback a.tf-back {
  display: inline-block; padding: 10px 22px;
  border: 1px solid currentColor; border-radius: 999px;
  text-decoration: none; color: inherit; opacity: 0.85;
  font-size: 13px; letter-spacing: 0.08em;
}
#touch-fallback a.tf-back:hover { opacity: 1; }
#touch-fallback ul.tf-members {
  list-style: none; padding: 0; margin: 22px 0 26px;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 12px;
}
#touch-fallback ul.tf-members a {
  display: inline-block; padding: 6px 12px;
  border: 1px solid currentColor; border-radius: 6px;
  text-decoration: none; color: inherit; opacity: 0.75;
  font-size: 12px; font-family: ui-monospace, monospace;
}
#touch-fallback ul.tf-members a:hover { opacity: 1; }

/* ===== Warp overlay (castle "jump into painting") ===== */
#warp-overlay {
  position: fixed; inset: 0;
  background: #fff;
  opacity: 0;
  z-index: 5000;
  pointer-events: none;
  /* Driven by JS each frame; no CSS transition so the fade tracks the camera dolly exactly. */
}
