/* ==========================================================================
   NeuroNight SF — iPad Photo Booth & WebRTC AR Studio Stylesheet
   Matches neuronightsf.org Design System (#090E1C, #4FE3C1, #8C7CFF, Sora/Manrope)
   ========================================================================== */

:root {
  --bg: #090E1C;
  --deep: #0C1328;
  --surface: #111933;
  --surface-raise: #16204A;
  --ink: #E8EEF9;
  --muted: #98A5C6;
  --line: #223057;
  --line-bright: #2E3E70;
  --accent: #4FE3C1;
  --accent-ink: #06121A;
  --violet: #8C7CFF;
  --rose: #FF6FB5;
  --amber: #FFB36B;
  --blue: #6FB7FF;
  --display: "Sora", system-ui, -apple-system, sans-serif;
  --body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background ambient glow matching neuronightsf.org */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(85% 60% at 88% 8%, rgba(79, 227, 193, 0.11) 0%, transparent 60%),
    radial-gradient(65% 50% at 10% 85%, rgba(140, 124, 255, 0.12) 0%, transparent 65%);
  z-index: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1540px;
  margin: 0 auto;
  padding: 12px 18px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ==========================================================================
   TOP HEADER BAR
   ========================================================================== */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(19, 28, 58, 0.92), rgba(12, 19, 40, 0.92));
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-decoration: none;
}

.brand-logo svg {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}

.brand-logo .glow-word {
  color: var(--accent);
  text-shadow: 0 0 22px rgba(79, 227, 193, 0.45);
}

.event-pill {
  font: 600 11.5px/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(79, 227, 193, 0.1);
  border: 1px solid rgba(79, 227, 193, 0.35);
  padding: 6px 11px;
  border-radius: 999px;
}

.header-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.styled-dropdown-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1.5px solid var(--line-bright);
  border-radius: 999px;
  padding: 5px 12px 5px 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}

.styled-dropdown-pill:hover,
.styled-dropdown-pill:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(79, 227, 193, 0.22);
}

.dropdown-prefix {
  font: 700 12.5px/1 var(--display);
  color: var(--muted);
  white-space: nowrap;
  user-select: none;
}

.styled-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234FE3C1' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  background-size: 12px 12px;
  border: 0;
  color: var(--ink);
  font: 800 13.5px/1.2 var(--display);
  padding: 5px 22px 5px 2px;
  cursor: pointer;
}

.styled-select:focus {
  outline: none;
  color: var(--accent);
}

.styled-select option {
  background: var(--deep);
  color: var(--ink);
  font-family: var(--body);
  font-weight: 600;
}

/* ==========================================================================
   MAIN TWO-COLUMN IPAD STUDIO LAYOUT
   ========================================================================== */
.studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.38fr) minmax(390px, 0.92fr);
  gap: 16px;
  align-items: start;
}

@media (max-width: 1120px) {
  .studio-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   LEFT COLUMN: PHOTO BOOTH VIEWFINDER & MAGIC SHOWCASE
   ========================================================================== */
.booth-stage-card {
  background: radial-gradient(120% 90% at 85% 20%, #12204A 0%, #0C1328 65%);
  border: 1px solid var(--line-bright);
  border-radius: 22px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.48);
}

/* Magic Preview Banner ("Showcase WHAT will be magically added before") */
.magic-showcase-banner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 16px;
  background: linear-gradient(90deg, rgba(79, 227, 193, 0.14), rgba(140, 124, 255, 0.14));
  border: 1.5px solid rgba(79, 227, 193, 0.48);
}

.magic-icon-badge {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--deep);
  border: 1.5px solid var(--accent);
  display: grid;
  place-items: center;
  font-size: 27px;
  box-shadow: 0 0 20px rgba(79, 227, 193, 0.25);
}

.magic-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.magic-eyebrow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font: 700 11px/1.2 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.anchor-pill {
  background: rgba(140, 124, 255, 0.22);
  border: 1px solid var(--violet);
  color: #DBD4FF;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 700;
}

.magic-title {
  font: 800 18px/1.2 var(--display);
  color: var(--ink);
  margin: 0;
}

.magic-desc {
  font-size: 13.5px;
  color: #C7D2EC;
  margin: 0;
}

.pose-instruction-box {
  background: rgba(9, 14, 28, 0.85);
  border: 1.5px dashed var(--amber);
  border-radius: 12px;
  padding: 8px 12px;
  max-width: 255px;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--amber);
  font-weight: 700;
}

@media (max-width: 720px) {
  .magic-showcase-banner {
    grid-template-columns: 1fr;
  }
  .pose-instruction-box {
    max-width: 100%;
  }
}

/* Main Viewfinder Canvas Wrapper */
.viewfinder-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #060A14;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid var(--line-bright);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.7);
}

#arCanvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* Hidden source video element for webcam ingestion */
#webcamVideo {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Floating HUD badges on the viewfinder */
.hud-top-left {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: none;
}

.hud-badge {
  background: rgba(9, 14, 28, 0.82);
  border: 1px solid rgba(79, 227, 193, 0.45);
  backdrop-filter: blur(8px);
  padding: 6px 11px;
  border-radius: 999px;
  font: 700 11.5px/1 var(--mono);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Simplified "X of 3" Countdown Overlay */
.countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(9, 14, 28, 0.08) 0%, rgba(9, 14, 28, 0.38) 100%);
  z-index: 15;
}

.countdown-overlay[hidden] {
  display: none !important;
}

.countdown-center-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
}

.countdown-center-stack[hidden] {
  display: none !important;
}

.countdown-number {
  font: 800 clamp(84px, 14vw, 152px)/0.95 var(--display);
  color: var(--accent);
  text-shadow:
    0 0 36px rgba(79, 227, 193, 0.85),
    0 6px 20px rgba(0, 0, 0, 0.9);
  letter-spacing: -0.05em;
  animation: pulseTick 0.7s ease-out infinite;
}

@keyframes pulseTick {
  0% { transform: scale(1.18); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.88; }
}

.countdown-phase-title {
  font: 800 24px/1.2 var(--display);
  color: #fff;
  background: rgba(9, 14, 28, 0.88);
  border: 1.5px solid var(--accent);
  padding: 8px 24px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}

/* Between-Photo "Choose Next Overlay" Prompt Card */
.choose-next-overlay-card {
  pointer-events: auto;
  margin-top: auto;
  margin-bottom: 8px;
  background: rgba(9, 14, 28, 0.92);
  border: 2px solid var(--accent);
  border-radius: 18px;
  padding: 16px 24px;
  max-width: 560px;
  text-align: center;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.choose-next-overlay-card[hidden] {
  display: none !important;
}

.choose-next-title {
  font: 800 20px/1.2 var(--display);
  color: var(--accent);
}

.choose-next-desc {
  margin: 0;
  font-size: 14px;
  color: var(--ink);
}

/* Camera shutter flash */
.shutter-flash {
  position: absolute;
  inset: 0;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  z-index: 25;
  transition: opacity 0.25s ease-out;
}

.shutter-flash.firing {
  opacity: 0.95;
  transition: none;
}

/* Action Bar below Viewfinder */
.booth-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-cta-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px 20px;
  border-radius: 999px;
  border: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: 14.5px;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s ease, border-color 0.15s ease;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-BoothSnap {
  background: linear-gradient(120deg, var(--accent), #6BF5D6);
  color: var(--accent-ink);
  box-shadow: 0 0 24px rgba(79, 227, 193, 0.38);
  font-size: 15px;
  padding: 13px 22px;
}

.btn-BoothSnap:hover {
  filter: brightness(1.07);
}

.btn-BoothRandom {
  background: linear-gradient(120deg, var(--violet), #FF6FB5);
  color: #FFFFFF;
  box-shadow: 0 0 24px rgba(140, 124, 255, 0.42);
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--line-bright);
  font-size: 14px;
  padding: 11px 16px;
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-secondary.active {
  background: rgba(79, 227, 193, 0.16);
  border-color: var(--accent);
  color: var(--accent);
}

/* WebRTC Loopback & Captured Strip Drawer */
.bottom-monitors-row {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 12px;
}

@media (max-width: 760px) {
  .bottom-monitors-row {
    grid-template-columns: 1fr;
  }
}

.monitor-card {
  background: linear-gradient(180deg, #131C3A, #0F1630);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.monitor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.monitor-title {
  font: 700 11.5px/1 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.webrtc-video-box {
  position: relative;
  aspect-ratio: 16 / 10;
  background: #050811;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line-bright);
}

#webrtcLoopbackVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.webrtc-stats-overlay {
  position: absolute;
  bottom: 6px;
  left: 6px;
  right: 6px;
  background: rgba(9, 14, 28, 0.84);
  padding: 4px 8px;
  border-radius: 6px;
  font: 500 10.5px/1.3 var(--mono);
  color: var(--accent);
  display: flex;
  justify-content: space-between;
}

/* Mini Gallery / Recent Snaps */
.gallery-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  min-height: 112px;
  align-items: center;
}

.gallery-thumb {
  position: relative;
  flex: 0 0 132px;
  height: 100px;
  border-radius: 10px;
  overflow: hidden;
  border: 1.5px solid var(--line-bright);
  cursor: pointer;
  background: #060A14;
}

.gallery-thumb:hover {
  border-color: var(--accent);
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-thumb span {
  position: absolute;
  bottom: 4px;
  left: 4px;
  right: 4px;
  background: rgba(9, 14, 28, 0.85);
  font: 700 9.5px/1.2 var(--mono);
  color: var(--accent);
  padding: 3px 5px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   RIGHT COLUMN: 50-ITEM INTERACTIVE CONTROL PANEL & TOP 10 CURATOR
   ========================================================================== */
.control-panel-card {
  background: linear-gradient(180deg, #131C3A, #0C1328);
  border: 1px solid var(--line-bright);
  border-radius: 22px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 96px);
  position: sticky;
  top: 12px;
}

@media (max-width: 1120px) {
  .control-panel-card {
    max-height: none;
    position: static;
  }
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.panel-header h2 {
  font: 800 20px/1.15 var(--display);
  margin: 3px 0 0;
}

.eyebrow {
  font: 700 11px/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.top10-counter-pill {
  background: rgba(255, 179, 107, 0.14);
  border: 1px solid var(--amber);
  color: var(--amber);
  padding: 6px 11px;
  border-radius: 999px;
  font: 700 11.5px/1 var(--mono);
  cursor: pointer;
  white-space: nowrap;
}

/* Active Body Anchor Detail Box inside Control Panel */
.anchor-inspector-box {
  background: rgba(9, 14, 28, 0.72);
  border: 1px solid var(--line-bright);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.anchor-inspector-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
}

.anchor-inspector-row strong {
  color: var(--accent);
  font-family: var(--mono);
}

/* Search & Randomize Bar */
.search-row {
  display: flex;
  gap: 8px;
}

.search-input {
  flex: 1;
  background: var(--deep);
  border: 1px solid var(--line-bright);
  border-radius: 11px;
  padding: 9px 12px;
  color: var(--ink);
  font-size: 13.5px;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Category Tabs */
.category-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.cat-tab {
  flex: 0 0 auto;
  background: var(--deep);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 7px 11px;
  border-radius: 999px;
  font: 700 12px/1 var(--body);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.cat-tab:hover {
  color: var(--ink);
  border-color: var(--line-bright);
}

.cat-tab.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 800;
}

/* Scrollable 50-Item Grid */
.preset-list-container {
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding-right: 4px;
  max-height: 520px;
}

.preset-item-card {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(12, 19, 40, 0.85);
  border: 1.5px solid var(--line);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.preset-item-card:hover {
  border-color: var(--line-bright);
  background: rgba(22, 32, 74, 0.75);
}

.preset-item-card.selected {
  border-color: var(--accent);
  background: linear-gradient(90deg, rgba(79, 227, 193, 0.16), rgba(140, 124, 255, 0.12));
  box-shadow: 0 0 20px rgba(79, 227, 193, 0.18);
}

.preset-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--line-bright);
  display: grid;
  place-items: center;
  font-size: 21px;
}

.preset-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.preset-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.preset-code {
  font: 700 11px/1 var(--mono);
  color: var(--accent);
}

.preset-name {
  font: 700 14px/1.2 var(--display);
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preset-anchor-tag {
  font: 600 11px/1.2 var(--mono);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.star-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 16px;
  cursor: pointer;
}

.star-btn.starred {
  color: var(--amber);
  border-color: var(--amber);
  background: rgba(255, 179, 107, 0.14);
}

/* ==========================================================================
   PHOTO BOOTH RESULT MODAL
   ========================================================================== */
dialog.photo-modal {
  width: min(880px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  background: linear-gradient(180deg, #131C3A, #090E1C);
  color: var(--ink);
  border: 1.5px solid var(--accent);
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.8);
}

dialog.photo-modal::backdrop {
  background: rgba(5, 8, 18, 0.82);
  backdrop-filter: blur(6px);
}

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

.modal-preview-grid {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 720px) {
  .modal-preview-grid {
    grid-template-columns: 1fr;
  }
}

.modal-preview-box {
  background: #050811;
  border: 1px solid var(--line-bright);
  border-radius: 14px;
  padding: 10px;
  text-align: center;
}

.modal-preview-box img {
  max-width: 100%;
  max-height: 460px;
  border-radius: 10px;
  display: inline-block;
}
