/* ============================================================
   Emily Berst — Gallery   ·   interface styles
   ============================================================ */

:root {
  --ink: #0b0a09;
  --paper: #f5f2ea;
  --gold: #c9a96a;
  --gold-soft: rgba(201, 169, 106, 0.55);
  --glass: rgba(16, 14, 12, 0.78);
  --serif: "Cormorant Garamond", "Didot", Georgia, serif;
  --sans: "Inter", -apple-system, "Helvetica Neue", Arial, sans-serif;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}
#stage.dragging { cursor: grabbing; }
#stage.pointing { cursor: pointer; }

/* ---------- cinematic overlays ---------- */

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 52%, rgba(0, 0, 0, 0.38) 100%),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.18), transparent 14%);
  z-index: 2;
}

.grain {
  position: fixed;
  inset: -50%;
  pointer-events: none;
  z-index: 2;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 1.4s steps(4) infinite;
}
@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 1%); }
  50% { transform: translate(1%, -1.5%); }
  75% { transform: translate(-1%, 2%); }
  100% { transform: translate(2%, 0); }
}

/* ---------- entrance overlay ---------- */

#overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  transition: opacity 1.6s ease, visibility 1.6s;
}
#overlay.hidden { opacity: 0; visibility: hidden; }

.overlay-inner { text-align: center; padding: 0 24px; max-width: 560px; }

.overlay-kicker {
  font-family: var(--sans);
  font-weight: 300;
  font-size: 12px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: rgba(245, 242, 234, 0.45);
  margin-bottom: 18px;
  animation: rise 1.2s ease both;
}

.overlay-title {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(52px, 10vw, 96px);
  line-height: 1.02;
  color: var(--paper);
  letter-spacing: 0.02em;
  animation: rise 1.2s 0.15s ease both;
}

.overlay-rule {
  width: 72px;
  height: 1px;
  margin: 28px auto;
  background: linear-gradient(to right, transparent, var(--gold), transparent);
  animation: rise 1.2s 0.3s ease both;
}

.overlay-sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: 19px;
  color: rgba(245, 242, 234, 0.66);
  margin-bottom: 44px;
  animation: rise 1.2s 0.4s ease both;
}

.progress {
  width: 180px;
  height: 1px;
  margin: 0 auto 34px;
  background: rgba(245, 242, 234, 0.14);
  overflow: hidden;
}
.progress-bar {
  width: 0%;
  height: 100%;
  background: var(--gold);
  transition: width 0.4s ease;
}

#enter-btn {
  font-family: var(--sans);
  font-weight: 400;
  font-size: 12px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: rgba(245, 242, 234, 0.4);
  background: transparent;
  border: 1px solid rgba(245, 242, 234, 0.18);
  padding: 15px 42px 15px 46px;
  cursor: default;
  transition: all 0.45s ease;
}
#enter-btn:not([disabled]) {
  color: var(--paper);
  border-color: var(--gold-soft);
  cursor: pointer;
}
#enter-btn:not([disabled]):hover {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--ink);
  letter-spacing: 0.4em;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- wordmark ---------- */

#wordmark {
  position: fixed;
  top: 26px;
  left: 30px;
  z-index: 10;
  color: var(--paper);
  cursor: pointer;
  user-select: none;
  opacity: 0;
  transition: opacity 1.2s ease 0.6s;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.5);
}
body.entered #wordmark { opacity: 1; }
.wm-name {
  display: block;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 21px;
  letter-spacing: 0.06em;
}
.wm-sub {
  display: block;
  font-size: 9px;
  font-weight: 300;
  letter-spacing: 0.44em;
  text-transform: uppercase;
  color: rgba(245, 242, 234, 0.55);
  margin-top: 3px;
}

/* ---------- tour button ---------- */

#tour-btn {
  position: fixed;
  top: 30px;
  right: 30px;
  z-index: 10;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(245, 242, 234, 0.75);
  background: rgba(16, 14, 12, 0.35);
  border: 1px solid rgba(245, 242, 234, 0.22);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 10px 18px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 1.2s ease 0.9s, background 0.3s, color 0.3s, border-color 0.3s;
}
body.entered #tour-btn { opacity: 1; }
#tour-btn:hover { border-color: var(--gold-soft); color: var(--paper); }
#tour-btn.active {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--ink);
}

/* ---------- hint ---------- */

#hint {
  position: fixed;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  font-size: 11px;
  font-weight: 300;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(245, 242, 234, 0.55);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 1s ease;
  pointer-events: none;
}
#hint.show { opacity: 1; }

/* ---------- focus navigation arrows ---------- */

.nav-arrow {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 12;
  width: 52px;
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: var(--serif);
  font-size: 44px;
  font-weight: 300;
  line-height: 0;
  color: rgba(245, 242, 234, 0.7);
  background: rgba(16, 14, 12, 0.3);
  border: 1px solid rgba(245, 242, 234, 0.14);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0.5s, background 0.3s, color 0.3s;
}
.nav-arrow span { display: block; transform: translateY(-6%); }
.nav-arrow:hover { background: rgba(201, 169, 106, 0.25); color: var(--paper); }
#nav-prev { left: 22px; border-radius: 42px 8px 8px 42px; }
#nav-next { right: 22px; border-radius: 8px 42px 42px 8px; }
body.focus .nav-arrow, body.mobile.entered .nav-arrow { opacity: 1; visibility: visible; }
body.focus.panel-open #nav-next { right: min(422px, calc(38vw + 22px)); }

/* ---------- info panel ---------- */

#panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(400px, 92vw);
  z-index: 14;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(1.1);
  -webkit-backdrop-filter: blur(22px) saturate(1.1);
  border-left: 1px solid rgba(201, 169, 106, 0.25);
  padding: 64px 44px 40px;
  transform: translateX(102%);
  transition: transform 0.9s cubic-bezier(0.22, 1, 0.3, 1);
  overflow-y: auto;
}
body.panel-open #panel { transform: translateX(0); }

/* while editing, drop the read-only description + Edit button and pin content
   to the top so the form's Save/Cancel are always reachable (scroll if tall) */
#panel.editing { justify-content: flex-start; }
#panel.editing .panel-desc,
#panel.editing #edit-btn { display: none; }

#panel-close {
  position: absolute;
  top: 20px;
  right: 24px;
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 300;
  line-height: 1;
  color: rgba(245, 242, 234, 0.55);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.3s, transform 0.3s;
}
#panel-close:hover { color: var(--paper); transform: rotate(90deg); }

.panel-body { opacity: 1; transition: opacity 0.35s ease; }
#panel.swapping .panel-body { opacity: 0; }

.panel-counter {
  font-size: 10px;
  font-weight: 300;
  letter-spacing: 0.4em;
  color: var(--gold);
  margin-bottom: 18px;
}

.panel-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(30px, 3vw, 40px);
  line-height: 1.12;
  color: var(--paper);
  margin-bottom: 12px;
}

.panel-meta {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: rgba(245, 242, 234, 0.55);
}

.panel-rule {
  width: 46px;
  height: 1px;
  background: var(--gold-soft);
  margin: 26px 0;
}

.panel-desc {
  font-size: 14.5px;
  font-weight: 300;
  line-height: 1.85;
  color: rgba(245, 242, 234, 0.82);
  max-height: 44vh;
  overflow-y: auto;
  padding-right: 6px;
}
.panel-desc::-webkit-scrollbar { width: 3px; }
.panel-desc::-webkit-scrollbar-thumb { background: rgba(201, 169, 106, 0.4); }

.panel-foot {
  position: absolute;
  bottom: 26px;
  left: 44px;
  right: 44px;
  font-size: 10px;
  font-weight: 300;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(245, 242, 234, 0.3);
}

/* ---------- entrance links ---------- */

.overlay-links {
  margin-top: 30px;
  animation: rise 1.2s 0.55s ease both;
}
.overlay-links a {
  font-size: 10px;
  font-weight: 300;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(245, 242, 234, 0.45);
  text-decoration: none;
  margin: 0 14px;
  transition: color 0.3s;
}
.overlay-links a:hover { color: var(--gold); }

/* ---------- admin ---------- */

#admin-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 10, 9, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
#admin-gate[hidden] { display: none; }

.gate-box {
  width: min(360px, 90vw);
  background: var(--glass);
  border: 1px solid rgba(201, 169, 106, 0.35);
  padding: 34px 34px 26px;
  text-align: center;
}
.gate-box h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 26px;
  color: var(--paper);
  margin-bottom: 8px;
}
.gate-box p {
  font-size: 12px;
  font-weight: 300;
  color: rgba(245, 242, 234, 0.55);
  margin-bottom: 20px;
}
.gate-box input {
  width: 100%;
  background: rgba(245, 242, 234, 0.07);
  border: 1px solid rgba(245, 242, 234, 0.2);
  color: var(--paper);
  font-size: 15px;
  padding: 11px 14px;
  outline: none;
  text-align: center;
  letter-spacing: 0.1em;
}
.gate-box input:focus { border-color: var(--gold-soft); }

.gate-error {
  color: #e08b7a;
  font-size: 11.5px;
  min-height: 16px;
  margin: 10px 0 4px !important;
}

.gate-actions { display: flex; gap: 10px; justify-content: center; margin-top: 8px; }
.gate-actions button, .edit-actions button {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 10px 20px;
  cursor: pointer;
  border: 1px solid rgba(245, 242, 234, 0.25);
  background: transparent;
  color: rgba(245, 242, 234, 0.75);
  transition: all 0.3s;
}
#gate-submit, #edit-save {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--ink);
}
.gate-actions button:hover, .edit-actions button:hover { filter: brightness(1.15); }

#admin-chip {
  position: fixed;
  top: 78px;
  left: 30px;
  z-index: 10;
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(16, 14, 12, 0.5);
  border: 1px solid rgba(201, 169, 106, 0.4);
  padding: 6px 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
#admin-chip[hidden] { display: none; }
#admin-chip button {
  background: none;
  border: none;
  color: rgba(245, 242, 234, 0.55);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0;
}
#admin-chip button:hover { color: var(--paper); }

#edit-btn {
  margin-top: 26px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 10px 18px;
  cursor: pointer;
  border: 1px solid rgba(201, 169, 106, 0.5);
  background: transparent;
  color: var(--gold);
  transition: all 0.3s;
}
#edit-btn:hover { background: var(--gold); color: var(--ink); }
#edit-btn[hidden] { display: none; }

.panel-edit { display: flex; flex-direction: column; gap: 12px; }
.panel-edit[hidden] { display: none; }
.panel-edit label {
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(245, 242, 234, 0.5);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.panel-edit input, .panel-edit textarea {
  width: 100%;
  background: rgba(245, 242, 234, 0.07);
  border: 1px solid rgba(245, 242, 234, 0.18);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 300;
  line-height: 1.6;
  padding: 9px 12px;
  outline: none;
  resize: vertical;
}
.panel-edit input:focus, .panel-edit textarea:focus { border-color: var(--gold-soft); }
.edit-row { display: flex; align-items: center; gap: 12px; }
.edit-row button {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 8px 14px;
  cursor: pointer;
  border: 1px solid rgba(245, 242, 234, 0.25);
  background: transparent;
  color: rgba(245, 242, 234, 0.8);
}
.edit-row button:hover { border-color: var(--gold-soft); color: var(--paper); }
#edit-rot-state { font-size: 11px; color: rgba(245, 242, 234, 0.45); }
.edit-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 2px; }

body.saving #edit-save { opacity: 0.5; pointer-events: none; }

/* ---------- webgl fallback ---------- */

#webgl-fail[hidden] { display: none; }

#webgl-fail {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--ink);
  color: var(--paper);
  padding: 24px;
}
#webgl-fail h1 { font-family: var(--serif); font-weight: 300; font-size: 44px; margin-bottom: 16px; }
#webgl-fail p { font-weight: 300; line-height: 1.8; color: rgba(245, 242, 234, 0.6); }

/* ---------- mobile ---------- */

@media (max-width: 700px) {
  #wordmark { top: 18px; left: 20px; }
  #tour-btn { top: 20px; right: 20px; padding: 8px 14px; }
  #hint { bottom: 24px; font-size: 10px; letter-spacing: 0.16em; }

  .nav-arrow { width: 44px; height: 66px; font-size: 34px; }
  #nav-prev { left: 12px; }
  #nav-next { right: 12px; }
  body.focus.panel-open #nav-next { right: 12px; }

  #panel {
    top: auto;
    left: 0;
    width: 100%;
    max-height: 52vh;
    justify-content: flex-start;
    border-left: none;
    border-top: 1px solid rgba(201, 169, 106, 0.3);
    padding: 30px 26px 22px;
    transform: translateY(104%);
  }
  body.panel-open #panel { transform: translateY(0); }
  .panel-title { font-size: 26px; }
  .panel-desc { max-height: 22vh; font-size: 13.5px; }
  .panel-rule { margin: 16px 0; }
  .panel-foot { display: none; }
  #panel-close { top: 12px; right: 16px; }
}
