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

:root {
  --bg:           #0d0b09;
  --bg-card:      #121008;
  --bg-inset:     #090706;
  --bg-studio:    #100e0b;
  --border:       #2c2418;
  --border-hi:    #c8a96e35;
  --gold:         #c8a96e;
  --gold-dim:     #c8a96e14;
  --gold-bright:  #e0c080;
  --cream:        #ede5d4;
  --text-body:    #b8a898;
  --text-muted:   #6a5e50;
  --text-dim:     #3a3028;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'Crimson Pro', Georgia, serif;
  --font-mono:    'DM Mono', 'Courier New', monospace;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  overflow-x: hidden;
}

/* ── Grain ── */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 200;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── Scroll Progress ── */
#scroll-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px;
  background: var(--border); z-index: 300;
}
#scroll-bar {
  height: 100%; width: 0; background: var(--gold);
  transition: width 0.1s linear;
}

/* ── Search Overlay ── */
#search-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(10, 8, 6, 0.97);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 80px 40px 40px;
  overflow-y: auto;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 1; transition: opacity 0.3s ease;
}
#search-overlay.hidden { opacity: 0; pointer-events: none; }

.search-inner { width: 100%; max-width: 760px; }

.search-close {
  display: block; margin-bottom: 48px;
  background: none; border: 1px solid var(--border);
  color: var(--text-muted); font-family: var(--font-mono);
  font-size: 0.7rem; letter-spacing: 2px; padding: 6px 16px;
  cursor: pointer; transition: all 0.2s;
}
.search-close:hover { border-color: var(--gold); color: var(--gold); }

.search-eyebrow {
  font-family: var(--font-mono); font-size: 0.65rem; letter-spacing: 4px;
  color: var(--gold); margin-bottom: 12px; opacity: 0.8;
}
.search-heading {
  font-family: var(--font-display); font-size: 2.8rem; font-weight: 700;
  color: var(--cream); margin-bottom: 36px; line-height: 1.1;
}
.search-field-wrap {
  border-bottom: 1px solid var(--border); margin-bottom: 48px;
  transition: border-color 0.3s;
}
.search-field-wrap:focus-within { border-color: var(--gold); }

#search-input {
  width: 100%; background: none; border: none; outline: none;
  font-family: var(--font-display); font-size: 1.6rem; color: var(--cream);
  padding: 12px 0; caret-color: var(--gold);
}
#search-input::placeholder { color: var(--text-dim); }

#search-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }

.search-result-card {
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 20px; cursor: pointer; transition: all 0.2s;
}
.search-result-card:hover { border-color: var(--gold); background: var(--gold-dim); }
.search-result-num {
  font-family: var(--font-mono); font-size: 0.6rem; color: var(--text-muted);
  letter-spacing: 2px; margin-bottom: 8px;
}
.search-result-title {
  font-family: var(--font-display); font-size: 1rem; font-weight: 700;
  color: var(--cream); margin-bottom: 4px;
}
.search-result-artist {
  font-family: var(--font-body); font-style: italic; font-size: 0.85rem;
  color: var(--gold);
}
.search-no-results {
  font-family: var(--font-body); font-style: italic; color: var(--text-muted);
  font-size: 1.1rem; grid-column: 1 / -1;
}

/* ── Fullscreen Overlay ── */
#fullscreen-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: #000; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  opacity: 1; transition: opacity 0.3s;
}
#fullscreen-overlay.hidden { opacity: 0; pointer-events: none; }

#fullscreen-close {
  position: absolute; top: 24px; right: 32px;
  background: none; border: 1px solid #333; color: #888;
  font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 2px;
  padding: 6px 16px; cursor: pointer; z-index: 1; transition: all 0.2s;
}
#fullscreen-close:hover { border-color: var(--gold); color: var(--gold); }

#fullscreen-meta {
  position: absolute; bottom: 28px; left: 40px;
  font-family: var(--font-display); font-style: italic; font-size: 1rem;
  color: #555;
}

#fullscreen-frame {
  width: min(90vw, 90vh); height: min(90vw, 90vh);
  border: none; background: #000;
}

/* ── Top Nav ── */
#top-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 40px;
  background: linear-gradient(180deg, rgba(13,11,9,0.95) 0%, rgba(13,11,9,0) 100%);
  pointer-events: none;
}
#top-nav > * { pointer-events: all; }

.nav-logo {
  font-family: var(--font-mono); font-size: 0.65rem; letter-spacing: 4px;
  color: var(--text-muted);
}

.nav-right { display: flex; align-items: center; gap: 28px; }

.nav-link {
  background: none; border: none;
  font-family: var(--font-mono); font-size: 0.65rem; letter-spacing: 2px;
  color: var(--text-muted); cursor: pointer; text-decoration: none;
  transition: color 0.2s;
}
.nav-link:hover { color: var(--gold); }

/* ── Side Nav ── */
#side-nav {
  position: fixed; right: 28px; top: 50%; transform: translateY(-50%);
  z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
#side-track {
  width: 2px; height: 160px; background: var(--border);
  position: relative; border-radius: 2px;
}
#side-thumb {
  position: absolute; left: -2px; top: 0; width: 6px; height: 20px;
  background: var(--gold); border-radius: 3px;
  transition: top 0.3s ease;
}
#side-counter {
  font-family: var(--font-mono); font-size: 0.6rem; color: var(--text-muted);
  letter-spacing: 1px; display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.side-sep { color: var(--text-dim); font-size: 0.5rem; }
#side-current { color: var(--gold); }

/* ── Hero ── */
#hero {
  position: relative; min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}

#hero-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0.6;
}

.hero-inner {
  position: relative; z-index: 2;
  text-align: center; padding: 100px 40px 80px;
  display: flex; flex-direction: column; align-items: center; gap: 24px;
}

.hero-eyebrow {
  font-family: var(--font-mono); font-size: 0.65rem; letter-spacing: 4px;
  color: var(--text-muted);
}

.hero-title {
  font-family: var(--font-display); font-weight: 900;
  font-size: clamp(4.5rem, 14vw, 11rem); line-height: 0.92;
  color: var(--cream);
}
.hero-title em { font-style: italic; font-weight: 400; color: var(--gold); font-size: 0.7em; }
.hero-outline {
  -webkit-text-stroke: 1px var(--cream);
  color: transparent;
}

.hero-sub {
  font-family: var(--font-body); font-style: italic; font-size: 1.1rem;
  color: var(--text-body); max-width: 440px; line-height: 1.8;
}

.hero-scroll {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 3px;
  color: var(--text-muted); margin-top: 20px;
}
.hero-scroll-line {
  width: 1px; height: 50px; background: linear-gradient(180deg, var(--gold), transparent);
  animation: scrollpulse 2s ease-in-out infinite;
}
@keyframes scrollpulse {
  0%, 100% { opacity: 0.4; transform: scaleY(1); }
  50%       { opacity: 1;   transform: scaleY(1.1); }
}

/* ── Section Commons ── */
.section-eyebrow {
  font-family: var(--font-mono); font-size: 0.65rem; letter-spacing: 4px;
  color: var(--gold); opacity: 0.8; margin-bottom: 10px;
}
.section-title {
  font-family: var(--font-display); font-weight: 700; font-size: 2.4rem;
  color: var(--cream); line-height: 1.15;
}
.section-sub {
  font-family: var(--font-body); font-style: italic; color: var(--text-body);
  font-size: 1rem; margin-top: 8px;
}

/* ── Studio ── */
#studio {
  padding: 100px 60px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-studio);
}
.studio-header { margin-bottom: 48px; }

.studio-body {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px;
  border: 1px solid var(--border);
  min-height: 500px;
}

.studio-editor-panel, .studio-output-panel {
  background: var(--bg-inset);
  display: flex; flex-direction: column;
}
.studio-editor-panel { border-right: 1px solid var(--border); }

.studio-panel-label {
  font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 3px;
  color: var(--text-muted); padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.studio-editor-wrap { flex: 1; overflow: hidden; }

.CodeMirror {
  height: 100% !important; font-family: var(--font-mono) !important;
  font-size: 13px !important; line-height: 1.7 !important;
  background: #0a0806 !important;
}
.CodeMirror-gutters { background: #080604 !important; border-right: 1px solid #1a1410 !important; }
.CodeMirror-linenumber { color: #3a3028 !important; }
.CodeMirror-scroll { background: #0a0806 !important; }

.studio-toolbar {
  display: flex; border-top: 1px solid var(--border);
  background: var(--bg-card);
}
.studio-toolbar button {
  flex: 1; padding: 12px; border: none; border-right: 1px solid var(--border);
  background: transparent; font-family: var(--font-mono); font-size: 0.7rem;
  letter-spacing: 2px; cursor: pointer; transition: all 0.2s;
}
.studio-toolbar button:last-child { border-right: none; }
#studio-run { color: var(--gold); }
#studio-run:hover { background: var(--gold); color: #000; }
#studio-clear { color: var(--text-muted); }
#studio-clear:hover { color: var(--cream); background: var(--border); }

.studio-canvas-wrap {
  flex: 1; position: relative; background: #000;
  min-height: 400px;
  display: flex; align-items: center; justify-content: center;
}
.studio-idle {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #000; z-index: 2;
}
.studio-idle p {
  font-family: var(--font-body); font-style: italic;
  color: #333; font-size: 0.95rem;
}
.studio-idle.hidden { display: none; }

.studio-frame {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border: none; background: #000;
}

/* ── Gallery Section ── */
#gallery-section { padding: 80px 0 0; }
.gallery-header { padding: 0 60px 48px; }

#gallery {
  display: grid; grid-template-columns: repeat(2, 1fr);
  border-top: 1px solid var(--border);
}

/* ── Artwork Card ── */
.artwork-card {
  background: var(--bg-card);
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  opacity: 0; transform: translateY(24px);
  transition: opacity 0.8s ease, transform 0.8s ease, box-shadow 0.4s ease;
  position: relative;
  overflow: hidden;
}
.artwork-card:nth-child(even) { border-right: none; }
.artwork-card.revealed { opacity: 1; transform: translateY(0); }

/* Subtle glow on hover */
.artwork-card:hover {
  box-shadow: inset 0 0 80px rgba(200, 169, 110, 0.04);
  z-index: 1;
}

/* Faint number watermark */
.piece-number {
  position: absolute; bottom: 200px; right: 16px;
  font-family: var(--font-display); font-weight: 900; font-size: 6rem;
  color: var(--gold); opacity: 0.04; line-height: 1;
  pointer-events: none; z-index: 0;
  -webkit-user-select: none;
  user-select: none;
}

/* ── Canvas Area ── */
.canvas-area {
  position: relative; width: 100%;
  height: clamp(280px, 42vw, 560px);
  background: #000; border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.idle-state {
  position: absolute; inset: 0; z-index: 4;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  background: #000; transition: opacity 0.4s ease;
}
.idle-state.hidden { opacity: 0; pointer-events: none; }

.idle-icon { width: 40px; height: 40px; opacity: 0.15; }
.idle-label {
  font-family: var(--font-mono); font-size: 0.6rem;
  letter-spacing: 3px; color: #333;
}

.art-frame {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border: none; background: #000;
}

/* Fullscreen button */
.fullscreen-btn {
  position: absolute; top: 12px; right: 12px; z-index: 5;
  background: rgba(13,11,9,0.85); border: 1px solid var(--border);
  color: var(--text-muted); font-family: var(--font-mono);
  font-size: 0.6rem; letter-spacing: 2px; padding: 5px 10px;
  cursor: pointer; opacity: 0; transition: all 0.2s;
}
.canvas-area:hover .fullscreen-btn { opacity: 1; }
.fullscreen-btn:hover { border-color: var(--gold); color: var(--gold); }

/* ── Info Panel ── */
.info-panel {
  padding: 28px 32px 32px;
  flex: 1; display: flex; flex-direction: column; gap: 0;
  position: relative; z-index: 2;
}

.piece-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}

.piece-title {
  font-family: var(--font-display); font-weight: 700; font-size: 1.25rem;
  color: var(--cream); line-height: 1.2;
}

.rerun-btn {
  flex-shrink: 0; background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); font-family: var(--font-mono);
  font-size: 0.6rem; letter-spacing: 2px; padding: 5px 12px;
  cursor: pointer; transition: all 0.2s; white-space: nowrap; margin-top: 4px;
}
.rerun-btn:hover { border-color: var(--gold); color: var(--gold); }

.piece-description {
  font-family: var(--font-body); font-style: italic; font-size: 0.95rem;
  color: var(--text-body); line-height: 1.85; margin-bottom: 20px; flex: 1;
}

/* Artist line */
.piece-artist-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.piece-artist-label {
  font-family: var(--font-mono); font-size: 0.6rem;
  letter-spacing: 2px; color: var(--text-muted);
}
.piece-artist-name {
  font-family: var(--font-display); font-style: italic; font-size: 0.9rem;
  color: var(--gold);
}
.piece-artist-search {
  background: none; border: none; color: var(--text-muted);
  font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 1px;
  cursor: pointer; padding: 0; transition: color 0.2s;
  text-decoration: underline; text-underline-offset: 3px;
}
.piece-artist-search:hover { color: var(--gold); }


/* Code reveal toggle */
.code-toggle-btn {
  background: none; border: none; color: var(--text-muted);
  font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 2px;
  cursor: pointer; padding: 0; transition: color 0.2s;
  text-decoration: underline; text-underline-offset: 3px;
  align-self: flex-start;
}
.code-toggle-btn:hover { color: var(--gold); }

.code-reveal {
  display: none; margin-top: 16px;
  background: #080604; border: 1px solid var(--border);
  padding: 16px; overflow-x: auto;
}
.code-reveal.open { display: block; }
.code-reveal pre {
  font-family: var(--font-mono); font-size: 0.72rem;
  color: #a0d0b0; line-height: 1.7; white-space: pre; tab-size: 4;
}

/* ── Footer ── */
footer {
  padding: 32px 60px;
  border-top: 1px solid var(--border);
  background: var(--bg-inset);
}
.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.footer-logo {
  font-family: var(--font-mono); font-size: 0.65rem; letter-spacing: 3px; color: var(--text-muted);
}
.footer-note {
  font-family: var(--font-body); font-style: italic; color: var(--text-dim); font-size: 0.82rem;
  line-height: 1.7; max-width: 700px;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ── Responsive ── */
@media (max-width: 900px) {
  #gallery { grid-template-columns: 1fr; }
  .artwork-card:nth-child(even) { border-right: 1px solid var(--border); }
  .studio-body { grid-template-columns: 1fr; }
  .studio-editor-panel { border-right: none; border-bottom: 1px solid var(--border); }
  .studio-canvas-wrap { min-height: 340px; }
  #studio { padding: 60px 24px; }
  #gallery-section { padding: 60px 0 0; }
  .gallery-header { padding: 0 24px 36px; }
  #top-nav { padding: 14px 24px; }
  footer { padding: 24px; }
  #side-nav { display: none; }
}