/* ============================================================
   DAVE BALLAM — IMMERSIVE 3D GALLERY
   styles.css
   ============================================================ */

:root {
  --bg:        #05060e;
  --bg-2:      #0b0e1f;
  --ink:       #e8ebf5;
  --ink-dim:   rgba(232, 235, 245, 0.55);
  --accent:    #7f9bff;
  --accent-2:  #b48fff;
  --hairline:  rgba(232, 235, 245, 0.14);
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body:    "Outfit", system-ui, sans-serif;
}

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

[hidden] { display: none !important; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: radial-gradient(120% 90% at 50% 0%, var(--bg-2) 0%, var(--bg) 60%, #020309 100%);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- 3D stage ---------- */
#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  outline: none;
}
body.dragging #stage { cursor: grabbing; }
body.hovering #stage { cursor: pointer; }

/* ============================================================
   LOADING SCREEN
   ============================================================ */
#loader {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(110% 90% at 50% 30%, #0d1128 0%, var(--bg) 65%, #010208 100%);
  transition: opacity 1.4s ease, visibility 1.4s;
}
#loader.done { opacity: 0; visibility: hidden; pointer-events: none; }

.loader-stars {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1px 1px at 12% 22%, rgba(255,255,255,.7) 50%, transparent 51%),
    radial-gradient(1px 1px at 78% 14%, rgba(255,255,255,.5) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 32% 74%, rgba(180,200,255,.6) 50%, transparent 51%),
    radial-gradient(1px 1px at 64% 58%, rgba(255,255,255,.45) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 88% 82%, rgba(200,180,255,.5) 50%, transparent 51%),
    radial-gradient(1px 1px at 44% 38%, rgba(255,255,255,.4) 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 88%, rgba(255,255,255,.5) 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 92% 40%, rgba(160,190,255,.55) 50%, transparent 51%);
  animation: starDrift 40s linear infinite alternate;
  opacity: .8;
}
@keyframes starDrift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(-2%, -3%, 0) scale(1.06); }
}

.loader-inner {
  position: relative;
  text-align: center;
  padding: 0 24px;
  animation: loaderRise 1.2s cubic-bezier(.2,.9,.25,1) both;
}
@keyframes loaderRise {
  from { opacity: 0; transform: translateY(26px); }
  to   { opacity: 1; transform: none; }
}

.loader-orb {
  position: relative;
  width: 84px; height: 84px;
  margin: 0 auto 34px;
}
.loader-orb span {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(127,155,255,.55);
  animation: orbPulse 2.6s ease-in-out infinite;
}
.loader-orb span:nth-child(2) { animation-delay: .55s; border-color: rgba(180,143,255,.4); }
.loader-orb span:nth-child(3) { animation-delay: 1.1s; border-color: rgba(127,155,255,.25); }
.loader-orb::after {
  content: "";
  position: absolute; inset: 32px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #cfd9ff, #7f9bff 55%, #3a4fb0);
  box-shadow: 0 0 30px 6px rgba(127,155,255,.55);
  animation: orbGlow 2.6s ease-in-out infinite;
}
@keyframes orbPulse {
  0%   { transform: scale(.55); opacity: .9; }
  70%  { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}
@keyframes orbGlow {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.14); }
}

.loader-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(26px, 5vw, 44px);
  letter-spacing: .42em;
  margin-left: .42em; /* optically recenter */
}
.loader-sub {
  margin-top: 10px;
  font-size: 11px;
  letter-spacing: .34em;
  color: var(--ink-dim);
}

.progress {
  width: min(320px, 70vw);
  height: 2px;
  margin: 40px auto 0;
  background: rgba(232,235,245,.12);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px rgba(127,155,255,.8);
  transition: width .35s ease;
}
.loader-status {
  margin-top: 16px;
  font-size: 12px;
  letter-spacing: .16em;
  color: var(--ink-dim);
  min-height: 1.4em;
}

.enter-btn {
  margin-top: 34px;
  padding: 15px 44px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .32em;
  text-indent: .32em;
  color: var(--ink);
  background: transparent;
  border: 1px solid rgba(127,155,255,.5);
  border-radius: 999px;
  cursor: pointer;
  transition: background .35s, box-shadow .35s, transform .35s;
  animation: loaderRise .9s cubic-bezier(.2,.9,.25,1) both;
}
.enter-btn:hover, .enter-btn:focus-visible {
  background: rgba(127,155,255,.14);
  box-shadow: 0 0 34px rgba(127,155,255,.35), inset 0 0 18px rgba(127,155,255,.12);
  transform: translateY(-2px);
}

/* ============================================================
   HUD (top bar, bottom hint)
   ============================================================ */
.hud {
  position: fixed;
  left: 0; right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px clamp(18px, 4vw, 44px);
  pointer-events: none;
  transition: opacity 1s ease;
}
#hud-top    { top: 0; justify-content: space-between; }
#hud-bottom { bottom: 0; justify-content: center; padding-bottom: max(18px, env(safe-area-inset-bottom)); }

body.ui-idle .hud { opacity: 0; }
body.lb-open .hud { opacity: 0; }

.hud > * { pointer-events: auto; }
body.ui-idle .hud > *, body.lb-open .hud > * { pointer-events: none; }

.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .3em;
  white-space: nowrap;
  text-shadow: 0 2px 18px rgba(0,0,0,.6);
}
.brand span {
  margin-left: .9em;
  font-weight: 300;
  color: var(--ink-dim);
  letter-spacing: .22em;
}

.modes {
  display: flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: rgba(6, 8, 18, .45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.mode-btn {
  padding: 9px 18px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .22em;
  text-indent: .22em;
  color: var(--ink-dim);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: color .3s, background .3s, box-shadow .3s;
}
.mode-btn:hover { color: var(--ink); }
.mode-btn.active {
  color: #fff;
  background: rgba(127,155,255,.18);
  box-shadow: 0 0 18px rgba(127,155,255,.25), inset 0 0 0 1px rgba(127,155,255,.35);
}

.icon-btn {
  padding: 10px 18px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .22em;
  color: var(--ink-dim);
  background: rgba(6, 8, 18, .45);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: color .3s, border-color .3s;
}
.icon-btn i { font-style: normal; color: var(--accent); }
.icon-btn:hover { color: var(--ink); border-color: rgba(127,155,255,.5); }

/* ---------- search ---------- */
.hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.search {
  position: relative;
  display: flex;
  align-items: center;
}
#search-input {
  width: 140px;
  padding: 10px 58px 10px 16px;   /* room for result count + clear button */
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .14em;
  color: var(--ink);
  background: rgba(6, 8, 18, .45);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  outline: none;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: width .35s ease, border-color .3s, box-shadow .3s;
  -webkit-appearance: none;
  appearance: none;
}
#search-input::-webkit-search-cancel-button { display: none; }
#search-input::placeholder { color: var(--ink-dim); }
#search-input:focus {
  width: 220px;
  border-color: rgba(127,155,255,.55);
  box-shadow: 0 0 18px rgba(127,155,255,.22);
}
.search-clear {
  position: absolute;
  right: 13px;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--ink-dim);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color .3s;
}
.search-clear:hover { color: var(--ink); }
.search-count {
  position: absolute;
  right: 36px;   /* sits left of the clear (X) button */
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: .1em;
  color: var(--accent);
  pointer-events: none;
}
.search-count.none { color: #ff8f8f; }

/* ---------- filter panel ---------- */
.filter-panel {
  position: fixed;
  top: 70px;
  right: clamp(18px, 4vw, 44px);
  z-index: 29;
  max-width: 320px;
  background: rgba(6, 8, 18, .92);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  animation: slideDown .3s cubic-bezier(.2, .9, .25, 1);
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: none; }
}

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--hairline);
}
.filter-header h3 {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .18em;
  color: var(--ink);
  margin: 0;
}
.filter-close {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--ink-dim);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color .3s;
}
.filter-close:hover { color: var(--ink); }

.filter-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.filter-group label {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .15em;
  color: var(--ink-dim);
  text-transform: uppercase;
}
.filter-select {
  padding: 8px 12px;
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--ink);
  background: rgba(127, 155, 255, .08);
  border: 1px solid rgba(127, 155, 255, .25);
  border-radius: 4px;
  outline: none;
  transition: border-color .3s, background .3s;
}
.filter-select:hover { border-color: rgba(127, 155, 255, .4); }
.filter-select:focus {
  background: rgba(127, 155, 255, .12);
  border-color: rgba(127, 155, 255, .55);
  box-shadow: 0 0 12px rgba(127, 155, 255, .15);
}
.filter-select option {
  background: #0b0e1f;
  color: var(--ink);
}

.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 130px;
  overflow-y: auto;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--ink-dim);
  background: rgba(127, 155, 255, .08);
  border: 1px solid rgba(127, 155, 255, .25);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .3s, background .3s, color .3s;
}
.tag-chip i {
  font-style: normal;
  font-size: 9px;
  color: rgba(232, 235, 245, 0.35);
}
.tag-chip:hover { border-color: rgba(127, 155, 255, .4); color: var(--ink); }
.tag-chip.active {
  color: var(--ink);
  background: rgba(127, 155, 255, .28);
  border-color: rgba(127, 155, 255, .65);
  box-shadow: 0 0 12px rgba(127, 155, 255, .2);
}
.tag-chip.active i { color: var(--accent); }

.filter-reset {
  margin-top: 6px;
  padding: 8px 12px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .15em;
  color: var(--ink-dim);
  background: rgba(255, 143, 143, .08);
  border: 1px solid rgba(255, 143, 143, .25);
  border-radius: 4px;
  cursor: pointer;
  transition: background .3s, border-color .3s, color .3s;
}
.filter-reset:hover {
  color: #ff8f8f;
  background: rgba(255, 143, 143, .14);
  border-color: rgba(255, 143, 143, .4);
}

@media (max-width: 720px) {
  .filter-panel {
    max-width: calc(100vw - 40px);
    right: 20px;
  }
}

/* ---------- hover tooltip ---------- */
.tooltip {
  position: fixed;
  top: 0; left: 0;
  z-index: 40;
  padding: 7px 15px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink);
  background: rgba(6, 8, 18, .72);
  border: 1px solid rgba(127,155,255,.35);
  border-radius: 999px;
  pointer-events: none;
  white-space: nowrap;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 24px rgba(0,0,0,.45);
}

.hint {
  font-size: 11px;
  letter-spacing: .18em;
  color: var(--ink-dim);
  text-align: center;
  text-shadow: 0 2px 14px rgba(0,0,0,.7);
}
.hint b { color: var(--ink); font-weight: 500; }

@media (max-width: 720px) {
  .brand span { display: none; }
  .hint { font-size: 10px; letter-spacing: .1em; }
  .mode-btn { padding: 8px 12px; font-size: 10px; }
  .icon-btn { padding: 8px 12px; font-size: 10px; }
  #search-input { width: 104px; padding: 8px 48px 8px 13px; font-size: 10px; }
  #search-input:focus { width: 150px; }
  .tooltip { display: none; }
}
@media (max-width: 460px) {
  #hud-top { flex-wrap: wrap; justify-content: center; gap: 10px; }
  .brand { width: 100%; text-align: center; font-size: 12px; }
}

/* ============================================================
   LIGHTBOX
   ============================================================ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .5s ease;
}
.lightbox.open { opacity: 1; }

.lb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 4, 12, .62);
  backdrop-filter: blur(22px) saturate(.85);
  -webkit-backdrop-filter: blur(22px) saturate(.85);
}

.lb-frame {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: min(1100px, 92vw);
  max-height: 88vh;
  transform: scale(.9) translateY(18px);
  opacity: 0;
  transition: transform .6s cubic-bezier(.2,.9,.25,1), opacity .6s ease;
}
.lightbox.open .lb-frame { transform: none; opacity: 1; }
.lb-frame.swap { transition: opacity .18s ease; opacity: 0 !important; }

.lb-imgwrap {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  box-shadow:
    0 40px 90px rgba(0,0,0,.75),
    0 0 0 1px rgba(232,235,245,.1),
    0 0 80px rgba(127,155,255,.14);
}
#lb-img {
  display: block;
  max-width: min(1100px, 92vw);
  max-height: 62vh;
  object-fit: contain;
}

.lb-meta {
  margin-top: 22px;
  text-align: center;
  max-width: 640px;
  padding: 0 12px;
}
#lb-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(16px, 2.4vw, 22px);
  letter-spacing: .18em;
  text-transform: uppercase;
}
#lb-caption {
  margin-top: 8px;
  font-weight: 300;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-dim);
}
.lb-exif {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  list-style: none;
}
.lb-exif li {
  padding: 6px 13px;
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--ink-dim);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: rgba(10, 13, 26, .5);
}
.lb-exif li b {
  font-weight: 500;
  color: var(--accent);
  margin-right: 6px;
}

.lb-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  list-style: none;
}
.lb-tags li {
  padding: 5px 12px;
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--accent);
  border: 1px solid rgba(127, 155, 255, .3);
  border-radius: 999px;
  background: rgba(127, 155, 255, .08);
}
.lb-tags li::before { content: '#'; opacity: .55; margin-right: 3px; }

.lb-btn {
  position: absolute;
  z-index: 5;
  width: 52px; height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--ink);
  background: rgba(10, 13, 26, .55);
  border: 1px solid var(--hairline);
  border-radius: 50%;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background .3s, border-color .3s, transform .3s;
}
.lb-btn:hover {
  background: rgba(127,155,255,.2);
  border-color: rgba(127,155,255,.55);
  transform: scale(1.08);
}
.lb-close { top: max(20px, env(safe-area-inset-top)); right: 22px; }
.lb-share { top: max(20px, env(safe-area-inset-top)); left: 22px; }
.lb-share svg { display: block; }
.lb-prev  { left: 22px;  top: 50%; margin-top: -26px; }
.lb-next  { right: 22px; top: 50%; margin-top: -26px; }

.lb-counter {
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .3em;
  color: var(--ink-dim);
}

@media (max-width: 720px) {
  #lb-img { max-height: 52vh; }
  .lb-prev { left: 10px; }
  .lb-next { right: 10px; }
  .lb-btn { width: 44px; height: 44px; font-size: 15px; }
  .lb-exif li { padding: 5px 10px; font-size: 10px; }
}

/* ---------- toast (link copied etc.) ---------- */
.toast {
  position: fixed;
  bottom: max(70px, calc(env(safe-area-inset-bottom) + 52px));
  left: 50%;
  z-index: 55;                 /* above the lightbox */
  padding: 10px 22px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .22em;
  text-indent: .22em;
  color: var(--ink);
  background: rgba(6, 8, 18, .8);
  border: 1px solid rgba(127, 155, 255, .45);
  border-radius: 999px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, .5), 0 0 24px rgba(127, 155, 255, .18);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity .35s ease, transform .35s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============================================================
   WEBGL FALLBACK
   ============================================================ */
#webgl-fallback {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  padding: 24px;
  background: var(--bg);
}
#webgl-fallback h1 {
  font-family: var(--font-display);
  letter-spacing: .4em;
  font-size: 22px;
}
#webgl-fallback p { color: var(--ink-dim); line-height: 1.7; }
