/* ============================================================
   DIGITAL GALLERY — Main Stylesheet
   Light gallery / dark frames contrast design
   ============================================================ */

:root {
  /* Gallery surface */
  --gallery-bg: #F0EDE8;
  --gallery-bg2: #ECEAE5;

  /* Frame internals (always dark) */
  --bg:        #050510;
  --bg2:       #080820;
  --blue:      #00d4ff;
  --purple:    #7a5cff;
  --cyan:      #00ffe0;
  --glow-b:    rgba(0,212,255,0.35);
  --glow-p:    rgba(122,92,255,0.35);
  --glass-bg:  rgba(255,255,255,0.03);
  --glass-border: rgba(255,255,255,0.08);
  --text:      rgba(255,255,255,0.9);
  --text-dim:  rgba(255,255,255,0.4);
  --frame-glow: 0 0 30px rgba(0,212,255,0.12), 0 0 60px rgba(122,92,255,0.08);

  --ease-out:    cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

/* Theme overrides (affect frame internals and landing) */
[data-theme="light"] {
  --blue:      #0055ff;
  --purple:    #5533cc;
  --glass-bg:  rgba(255,255,255,0.06);
  --glass-border: rgba(255,255,255,0.1);
  --glow-b:    rgba(0,85,255,0.25);
  --glow-p:    rgba(85,51,204,0.25);
  --frame-glow: 0 4px 30px rgba(0,85,255,0.12);
}

[data-theme="neon"] {
  --blue:   #00ff88;
  --purple: #ff0088;
  --cyan:   #ffff00;
  --glow-b: rgba(0,255,136,0.4);
  --glow-p: rgba(255,0,136,0.4);
  --glass-bg: rgba(0,0,0,0.6);
  --glass-border: rgba(0,255,136,0.2);
  --frame-glow: 0 0 40px rgba(0,255,136,0.2), 0 0 80px rgba(255,0,136,0.1);
}

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

html { overflow: hidden; }

body {
  background: var(--gallery-bg);
  font-family: 'Inter', sans-serif;
  font-weight: 300;
  line-height: 1.6;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  user-select: none;
}

button, [data-title], canvas { cursor: pointer; }
.frame-desc { cursor: default; }

/* ============================================================ Landing */
#landing {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  overflow: hidden;
  background: #050510;
  transition: opacity 1.2s var(--ease-out), transform 1.2s var(--ease-out);
}

#landing.exit {
  opacity: 0;
  transform: scale(1.04);
  pointer-events: none;
}

#landing-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#landing-content {
  position: relative;
  z-index: 1;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.landing-eyebrow {
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  opacity: 0;
  transform: translateY(10px);
  animation: fadeUp 0.8s 0.3s var(--ease-out) forwards;
}

#landing-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(48px, 8vw, 96px);
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1;
  display: flex;
  gap: 0.25em;
}

.title-word {
  display: inline-block;
  opacity: 0;
  transform: translateY(30px);
  animation: fadeUp 1s var(--ease-out) forwards;
  background: linear-gradient(135deg, #fff 0%, var(--blue) 50%, var(--purple) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.title-word:nth-child(1) { animation-delay: 0.5s; }
.title-word:nth-child(2) { animation-delay: 0.7s; }

.landing-sub {
  font-size: 14px;
  color: rgba(255,255,255,0.3);
  letter-spacing: 0.05em;
  opacity: 0;
  animation: fadeUp 0.8s 1s var(--ease-out) forwards;
}

#enter-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 30px;
  background: rgba(0,212,255,0.05);
  border: 1px solid rgba(0,212,255,0.25);
  color: var(--blue);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 6px;
  opacity: 0;
  animation: fadeUp 0.8s 1.3s var(--ease-out) forwards;
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s, transform 0.3s var(--ease-out);
}

#enter-btn:hover {
  background: rgba(0,212,255,0.1);
  border-color: rgba(0,212,255,0.5);
  box-shadow: 0 0 30px var(--glow-b);
  transform: translateY(-2px);
}

.landing-scroll-hint {
  position: absolute;
  bottom: 32px;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.2);
  opacity: 0;
  animation: fadeUp 0.8s 1.8s var(--ease-out) forwards;
}

/* ============================================================ Gallery Space */
#gallery-space {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  opacity: 0;
  pointer-events: none;
  background: var(--gallery-bg);
  transition: opacity 1s var(--ease-out);
  -webkit-overflow-scrolling: touch;
}

#gallery-space.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Thin scroll bar */
#gallery-space::-webkit-scrollbar { width: 5px; }
#gallery-space::-webkit-scrollbar-track { background: transparent; }
#gallery-space::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.14); border-radius: 3px; }

/* ============================================================ Gallery Content */
#gallery-content {
  max-width: 1320px;
  margin: 0 auto;
  padding: 88px 40px 80px;
}

#gallery-header {
  margin-bottom: 52px;
  border-bottom: 1px solid rgba(0,0,0,0.07);
  padding-bottom: 40px;
}

.gallery-eyebrow {
  display: block;
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #999;
  margin-bottom: 14px;
}

#gallery-header h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 300;
  letter-spacing: -0.02em;
  color: #1a1a1a;
  line-height: 1.1;
  margin-bottom: 10px;
}

#gallery-header p {
  font-size: 14px;
  color: #888;
  font-weight: 300;
  max-width: 480px;
}

/* ============================================================ Gallery Grid */
#gallery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 52px 28px;
}

@media (max-width: 760px) {
  #gallery-grid { grid-template-columns: 1fr; }
  #gallery-content { padding: 80px 20px 60px; }
}

.gallery-item {
  display: flex;
  flex-direction: column;
}

.gallery-item--full {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gallery-item--full .frame {
  width: 680px;
  max-width: 100%;
}

/* ============================================================ Frame — dark art piece */
.frame {
  position: relative;
  height: 340px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #050510;
  box-shadow:
    0 2px 12px rgba(0,0,0,0.10),
    0 6px 30px rgba(0,0,0,0.08);
  transition:
    box-shadow 0.4s var(--ease-out),
    transform 0.4s var(--ease-out);
}

.frame:hover {
  box-shadow:
    0 4px 20px rgba(0,0,0,0.14),
    0 12px 50px rgba(0,0,0,0.12),
    0 0 0 1px rgba(0,212,255,0.12);
  transform: translateY(-3px);
  z-index: 2;
}

/* Frame glass — the dark canvas viewport */
.frame-glass {
  position: absolute;
  inset: 0 0 36px 0;
  background: #050510;
  overflow: hidden;
  contain: strict;
}

.frame-canvas, .frame-svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
}

.frame-inner {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* Frame footer bar */
.frame-footer {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: rgba(5,5,18,0.95);
  border-top: 1px solid rgba(255,255,255,0.05);
}

.frame-title {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  transition: color 0.3s;
}

.frame:hover .frame-title {
  color: var(--blue);
}

.frame-num {
  font-size: 10px;
  font-family: 'Space Grotesk', monospace;
  color: rgba(255,255,255,0.12);
}

.frame.visited .frame-num {
  color: rgba(122,92,255,0.4);
}

/* Description below frame */
.frame-desc {
  margin-top: 14px;
  font-size: 13px;
  color: #7a7a7a;
  line-height: 1.65;
  font-weight: 300;
  padding-right: 8px;
}

/* ============================================================ Explain Mode Overlay */
.frame-explain {
  position: absolute;
  inset: 0;
  background: rgba(5,5,16,0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s var(--ease-out);
  z-index: 20;
}

body.explain-mode .frame-explain {
  opacity: 1;
  pointer-events: auto;
}

.frame-explain h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 15px;
  font-weight: 500;
  color: var(--blue);
  margin-bottom: 10px;
}

.frame-explain p {
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  line-height: 1.7;
  margin-bottom: 16px;
}

.frame-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.frame-tags span {
  font-size: 9px;
  letter-spacing: 0.1em;
  padding: 4px 10px;
  border: 1px solid rgba(0,212,255,0.2);
  border-radius: 20px;
  color: var(--blue);
  text-transform: uppercase;
}

/* ============================================================ HUD */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  z-index: 500;
  pointer-events: none;
}

.hud-left, .hud-right { pointer-events: auto; }

.hud-logo {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  color: var(--blue);
  background: #0d0d1e;
  padding: 8px 14px;
  border-radius: 8px;
  box-shadow: 0 2px 14px rgba(0,0,0,0.2);
}

.hud-right {
  display: flex;
  align-items: center;
  background: #0d0d1e;
  border-radius: 10px;
  padding: 4px;
  gap: 1px;
  box-shadow: 0 2px 18px rgba(0,0,0,0.22);
}

.hud-status {
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.22);
  padding: 0 10px 0 8px;
  border-right: 1px solid rgba(255,255,255,0.07);
  margin-right: 3px;
  white-space: nowrap;
  line-height: 1;
}

.hud-sep {
  display: none; /* separator built into hud-status border */
}

.hud-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: rgba(255,255,255,0.35);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}

.hud-btn:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.85);
}

.hud-btn.active {
  background: rgba(0,212,255,0.14);
  color: var(--blue);
}

/* Theme Panel */
#theme-panel {
  position: fixed;
  top: 60px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 501;
  transition: opacity 0.25s, transform 0.25s var(--ease-out);
  transform-origin: top right;
}

#theme-panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
}

.theme-opt {
  padding: 9px 18px;
  background: #0d0d1e;
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 8px;
  color: rgba(255,255,255,0.4);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
  white-space: nowrap;
  text-align: left;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
}

.theme-opt:hover, .theme-opt.active {
  background: rgba(0,212,255,0.1);
  border-color: rgba(0,212,255,0.25);
  color: var(--blue);
}

/* ============================================================ Overlays */
#glitch-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 800;
  opacity: 0;
}

body.glitch-mode #glitch-overlay { opacity: 1; }

body.glitch-mode #gallery-grid {
  animation: glitchShift 0.1s infinite;
}

@keyframes glitchShift {
  0%   { transform: translate(0,0);      filter: none; }
  20%  { transform: translate(-3px, 1px); filter: hue-rotate(90deg); }
  40%  { transform: translate(3px, -1px); filter: hue-rotate(-90deg) saturate(2); }
  60%  { transform: translate(-1px, 3px); filter: contrast(1.5); }
  80%  { transform: translate(2px, -2px); filter: hue-rotate(180deg); }
  100% { transform: translate(0,0);      filter: none; }
}

body.glitch-mode .frame-glass::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    rgba(255,0,0,0.04) 0%, transparent 33%,
    rgba(0,255,0,0.04) 33%, transparent 66%,
    rgba(0,0,255,0.04) 66%, transparent 100%
  );
  animation: rgbSplit 0.15s infinite;
  z-index: 5;
  pointer-events: none;
}

@keyframes rgbSplit {
  0%   { transform: translate(0,0); }
  50%  { transform: translate(4px,-2px); }
  100% { transform: translate(-2px,3px); }
}

#glitch-jitter {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 900;
}

body.glitch-mode #glitch-jitter {
  animation: glitchFilter 0.12s infinite;
}

@keyframes glitchFilter {
  0%   { filter: none; }
  25%  { filter: hue-rotate(90deg) saturate(1.5); }
  50%  { filter: hue-rotate(-90deg) contrast(1.4); }
  75%  { filter: hue-rotate(180deg); }
  100% { filter: none; }
}

body.glitch-mode .frame-glass {
  animation: glitchJitter 0.1s infinite;
}

@keyframes glitchJitter {
  0%,100% { transform: translate(0,0); }
  20%  { transform: translate(-2px, 1px); }
  40%  { transform: translate(2px,-1px); }
  60%  { transform: translate(-1px, 2px); }
  80%  { transform: translate(1px,-2px); }
}

/* Presence (idle) */
#presence-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 600;
  background: rgba(240,237,232,0);
  transition: background 2.5s var(--ease-out);
}

body.idle #presence-overlay {
  background: rgba(240,237,232,0.55);
}

body.idle .frame-glass {
  filter: brightness(0.65) saturate(0.5);
  transition: filter 3s var(--ease-out);
}

/* Freeze mode */
body.frozen .frame-glass canvas,
body.frozen .frame-glass svg {
  filter: brightness(0.75) saturate(0.6);
}

/* ============================================================ Animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================ System-specific UI */

/* AI stage label */
.ai-stage-label {
  position: absolute;
  top: 10px; right: 10px;
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--blue);
  opacity: 0.7;
  z-index: 5;
  background: rgba(0,212,255,0.05);
  padding: 4px 8px;
  border: 1px solid rgba(0,212,255,0.12);
  border-radius: 3px;
  pointer-events: none;
}

/* Sound controls */
.sound-controls {
  position: absolute;
  bottom: 10px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 7px;
  z-index: 5;
}

.glass-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  background: rgba(8,8,24,0.75);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  color: rgba(255,255,255,0.4);
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.18s;
}

.glass-btn.active, .glass-btn:hover {
  background: rgba(0,212,255,0.08);
  border-color: rgba(0,212,255,0.25);
  color: var(--blue);
}

/* Hints & labels inside frames */
.cursor-hint, .memory-label, .zoom-hint {
  position: absolute;
  bottom: 10px; left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.2);
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
  transition: opacity 0.5s;
}

/* ============================================================ Depth Frame */
#depth-scene {
  perspective: 600px;
  transform-style: preserve-3d;
}

.depth-layer {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.1s linear;
}

.depth-card {
  position: absolute;
  width: 72px;
  height: 72px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.3s;
}

.bg-particle {
  position: absolute;
  border-radius: 50%;
  background: var(--blue);
  opacity: 0.3;
}

/* ============================================================ Micro Frame */
#micro-scene {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
}

.micro-text {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(16px, 2.2vw, 26px);
  font-weight: 300;
  color: rgba(255,255,255,0.85);
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
}

.micro-text.show { opacity: 1; transform: translateY(0); }

.micro-bar {
  width: 38px;
  height: 2px;
  background: var(--blue);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.6s var(--ease-out);
}

.micro-bar.show { transform: scaleX(1); }

.micro-shapes {
  display: flex;
  gap: 14px;
  align-items: center;
}

.micro-shape {
  opacity: 0;
  transform: scale(0.5) rotate(-20deg);
  transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out);
}

.micro-shape.show {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.micro-circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--blue);
}

.micro-sq {
  width: 26px;
  height: 26px;
  border: 1.5px solid var(--purple);
  transform: rotate(45deg);
}

.micro-sq.show { transform: rotate(45deg) scale(1); }

.micro-tri {
  width: 0;
  height: 0;
  border-left: 13px solid transparent;
  border-right: 13px solid transparent;
  border-bottom: 23px solid rgba(0,255,224,0.6);
}

.micro-words {
  display: flex;
  gap: 10px;
}

.micro-word {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out);
}

.micro-word.show {
  opacity: 1;
  transform: translateX(0);
}

/* ============================================================ Glass Panels (Frame 11) */
#glass-scene {
  position: relative;
  width: 100%; height: 100%;
  overflow: hidden;
}

#canvas-glass-bg {
  position: absolute;
  inset: 0; width: 100%; height: 100%;
}

.glass-panel {
  position: absolute;
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 10px;
  padding: 13px 15px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 8px 32px rgba(0,0,0,0.3);
  transition: transform 0.25s var(--ease-out), border-color 0.25s, box-shadow 0.25s;
}

.glass-panel:hover {
  border-color: rgba(0,212,255,0.2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1),
              0 8px 40px rgba(0,0,0,0.4),
              0 0 20px rgba(0,212,255,0.07);
}

.glass-panel-title {
  font-size: 8px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 10px;
  opacity: 0.75;
}

.glass-metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
}

.glass-metric-label {
  font-size: 9px;
  color: rgba(255,255,255,0.3);
  letter-spacing: 0.04em;
}

.glass-metric-bar {
  width: 55px;
  height: 2px;
  background: rgba(255,255,255,0.05);
  border-radius: 2px;
  overflow: hidden;
}

.glass-metric-fill {
  height: 100%;
  background: #00c8a0;
  border-radius: 2px;
  transition: width 1s var(--ease-out);
}

.glass-val {
  font-size: 9px;
  font-family: 'Space Grotesk', monospace;
  color: rgba(255,255,255,0.4);
  min-width: 28px;
  text-align: right;
}

/* ============================================================ Puzzle (Frame 15) */
.puzzle-message {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--blue);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s var(--ease-out);
  text-align: center;
}

.puzzle-message.show { opacity: 1; }

/* ============================================================ Signal echo / predicted */
.frame.signal-echo .frame-footer {
  border-top-color: rgba(0,212,255,0.4);
  box-shadow: 0 -4px 20px rgba(0,212,255,0.15);
}

.frame.visited {
  box-shadow:
    0 2px 12px rgba(0,0,0,0.10),
    0 6px 30px rgba(0,0,0,0.08),
    0 0 0 1px rgba(122,92,255,0.1);
}

/* ============================================================ Scrollbar global */
::selection {
  background: rgba(0,212,255,0.15);
  color: var(--blue);
}

::-webkit-scrollbar { display: none; }
