/* =========================================================
   WHOI — Ruimte PRO v5.0 Elite Edition
   Met Immersive Mode, Verhaal & Telescoop
   ========================================================= */

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

html, body {
  width:100%; 
  height:100%;
  overscroll-behavior:none;
  background:#001427; 
  color:#fff;
  font-family:system-ui,-apple-system,"Segoe UI",Roboto,Ubuntu,"Helvetica Neue",Arial,sans-serif;
  overflow:hidden;
}

/* Topbalk */
.topbar {
  --h:70px; 
  height:var(--h);
  background:linear-gradient(90deg,#033062,#054087);
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 20px; 
  color:#fff;
  box-shadow:0 4px 12px rgba(0,0,0,.4);
  z-index:100;
}

.topbar-left h1 {
  font-size:1.4rem;
  font-weight:800;
  background: linear-gradient(90deg, #fff, #a8d8f0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
}

.topbar-left .slogan {
  font-size:.95rem;
  opacity:.9;
  margin: 3px 0 0 0;
}

.topbar-right {
  display:flex;
  gap:10px;
}

.header-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: 10px;
  background: rgba(255,255,255,0.15);
  color: white;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
  backdrop-filter: blur(10px);
}

.header-btn:hover {
  background: rgba(255,255,255,0.25);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.header-btn .btn-icon {
  font-size: 18px;
}

.easter {
  display:flex;
  gap:6px;
  margin-left: 10px;
}

.easter button {
  width:30px;
  height:30px;
  border:0;
  border-radius:8px;
  background:#2662c8;
  color:#fff;
  font-weight:800;
  font-size:14px;
  cursor:pointer;
  box-shadow:0 2px 6px rgba(0,0,0,.4);
  transition: all 0.2s;
}

.easter button:hover {
  background:#3a7be0;
  transform:scale(1.1);
}

/* Layout */
.wrapper {
  display:grid;
  grid-template-columns:240px 1fr;
  height:calc(100vh - 70px - 64px); /* topbar + footer */
}

/* Sidebar */
#sidebar {
  background:#082a53;
  border-right:3px solid #0a3f80;
  display:flex;
  flex-direction:column;
  min-height:0;
  overflow:hidden;
}

.sidebar-header {
  padding: 12px 16px;
  background: rgba(14, 88, 181, 0.3);
  border-bottom: 2px solid #0a3f80;
}

.sidebar-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}

/* Icon tabs */
.tabs {
  display:grid;
  grid-template-columns:repeat(5,1fr);
  gap:8px;
  padding:8px;
}

.tab {
  background:#0a3a7a;
  border:0;
  border-radius:10px;
  height:52px;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  transition: all 0.2s;
  position: relative;
}

.tab img {
  width:28px;
  height:28px;
  opacity:.95;
}

.tab.active {
  background:#0e58b5;
  box-shadow: 0 0 12px rgba(14, 88, 181, 0.6);
}

.tab:hover {
  background:#0e58b5;
  transform: translateY(-2px);
}

/* Tray */
#tray {
  flex:1;
  overflow-y:auto;
  overflow-x:hidden;
  -webkit-overflow-scrolling:touch;
  padding:8px;
  display:grid;
  grid-template-columns:repeat(auto-fill,68px);
  gap:8px;
}

#tray img {
  width:68px;
  height:68px;
  object-fit:contain;
  background:#0f2a4e;
  border-radius:10px;
  cursor:pointer;
  box-shadow:0 1px 2px rgba(0,0,0,.25);
  transition: all 0.2s;
}

#tray img:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
}

.sidebar-footer {
  padding: 12px;
  background: rgba(14, 88, 181, 0.2);
  border-top: 2px solid #0a3f80;
}

.sidebar-footer .tip {
  font-size: 12px;
  opacity: 0.85;
  text-align: center;
  margin: 0;
}

/* Canvas */
#canvas {
  position:relative;
  overflow:hidden;
  background:url("assets/backgrounds/ruimte01.png") center/cover no-repeat;
  height:100%;
  min-height:400px;
  z-index:1;
}

.canvas-item {
  position:absolute;
  user-select:none;
  pointer-events:auto;
  transform-origin:center;
  cursor:grab;
  transition:none;
}

.canvas-item:active {
  cursor:grabbing;
}

#liveOverlay {
  position:absolute;
  inset:0;
  background:rgba(0,0,30,.18);
  display:none;
  pointer-events:none;
  z-index:0;
}

/* Canvas Counter */
.canvas-counter {
  position: absolute;
  top: 15px;
  left: 15px;
  background: rgba(10, 25, 55, 0.85);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  backdrop-filter: blur(5px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  z-index: 50;
}

.canvas-counter span {
  color: #4fc3f7;
  font-weight: 800;
  font-size: 16px;
}

/* Footer - Met alle knoppen altijd zichtbaar */
#footerBar {
  height:64px;
  background:#072a52;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:12px;
  border-top:3px solid #0a3f80;
  position:fixed;
  bottom:0;
  left:0;
  width:100%;
  z-index:2000;
  padding: 0 20px;
}

#btnLive {
  background:#ff7a00;
  border:none;
  color:#fff;
  border-radius:12px;
  padding:10px 18px;
  font-weight:800;
  font-size: 14px;
  cursor:pointer;
  transition: all 0.2s;
  box-shadow: 0 3px 10px rgba(255, 122, 0, 0.4);
}

#btnLive:hover {
  background:#ff9933;
  transform: scale(1.05);
}

/* Footer knoppen */
.footer-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

.footer-btn:hover {
  background: rgba(255,255,255,0.2);
  transform: translateY(-2px);
}

.footer-divider {
  width: 2px;
  height: 35px;
  background: rgba(255,255,255,0.15);
  margin: 0 8px;
}

.bg-choice {
  display:flex;
  gap:8px;
}

.bg-choice img {
  width:52px;
  height:34px;
  border-radius:8px;
  opacity:.85;
  cursor:pointer;
  border:2px solid rgba(255,255,255,.15);
  background:#0b2346;
  transition: all 0.2s;
}

.bg-choice img.active {
  border-color: #ff7a00;
  opacity: 1;
  box-shadow: 0 0 12px rgba(255, 122, 0, 0.6);
}

.bg-choice img:hover {
  opacity: 1;
  transform: scale(1.1);
}

/* Mini-menu */
.mini-menu {
  position:fixed;
  right:18px;
  bottom:84px;
  z-index:60;
  display:none;
  flex-direction:column;
  gap:8px;
  background:rgba(10,25,55,.9);
  backdrop-filter:blur(5px);
  padding:10px;
  border-radius:14px;
  box-shadow:0 4px 16px rgba(0,0,0,.5);
}

.mini-menu button {
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 48px;
}

.mini-menu button:hover {
  background: rgba(255,255,255,0.2);
  transform: scale(1.1);
}

.mini-menu img {
  width:32px;
  height:32px;
  opacity:.95;
}

/* WHOI logo */
.whoi-logo {
  position:fixed;
  right:100px;
  bottom:84px;
  width:80px;
  opacity:.95;
  z-index:45;
}

/* Story Overlay */
.story-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(5px);
}

.story-overlay.hidden {
  display: none;
}

.story-box {
  background: linear-gradient(135deg, #0a2855, #0e3f7a);
  border-radius: 16px;
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
}

.story-header {
  background: linear-gradient(90deg, #0e58b5, #2b8bd6);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid #054087;
}

.story-header h2 {
  margin: 0;
  font-size: 1.5rem;
  color: white;
}

.close-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  font-size: 24px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  background: rgba(255,255,255,0.3);
  transform: rotate(90deg);
}

.story-content {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.story-input-section,
.story-display-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.story-content label {
  font-weight: 600;
  color: #4fc3f7;
  font-size: 14px;
}

.story-content input,
.story-content textarea {
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 12px;
  color: white;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}

.story-content input:focus,
.story-content textarea:focus {
  outline: none;
  border-color: #4fc3f7;
  background: rgba(255,255,255,0.15);
}

.story-preview {
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  padding: 16px;
  min-height: 200px;
  line-height: 1.6;
}

.story-preview h4 {
  color: #4fc3f7;
  margin-bottom: 12px;
}

.placeholder-text {
  color: rgba(255,255,255,0.5);
  font-style: italic;
}

.story-footer {
  padding: 20px 24px;
  background: rgba(0,0,0,0.3);
  border-top: 2px solid rgba(255,255,255,0.1);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.btn-primary {
  background: linear-gradient(135deg, #0e58b5, #2b8bd6);
  border: none;
  color: white;
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(14, 88, 181, 0.5);
}

.btn-secondary {
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.3);
  color: white;
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.2);
}

/* Help Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(5px);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: linear-gradient(135deg, #0a2855, #0e3f7a);
  border-radius: 16px;
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.modal-header {
  background: linear-gradient(90deg, #0e58b5, #2b8bd6);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid #054087;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.4rem;
  color: white;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(85vh - 100px);
}

.help-section {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.help-section:last-child {
  border-bottom: none;
}

.help-section h3 {
  color: #4fc3f7;
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.help-section p {
  line-height: 1.6;
  opacity: 0.9;
}

.help-section kbd {
  background: rgba(255,255,255,0.2);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
  border: 1px solid rgba(255,255,255,0.3);
}

/* ========================================
   IMMERSIVE MODE 
   ======================================== */
body.immersive .topbar {
  display: none;
}

body.immersive #sidebar {
  display: none;
}

body.immersive #footerBar {
  display: none;
}

body.immersive .wrapper {
  height: 100vh;
  grid-template-columns: 1fr;
}

body.immersive #canvas {
  width: 100%;
  height: 100vh;
}

body.immersive .mini-menu {
  opacity: 0.3;
  transition: opacity 0.3s;
}

body.immersive .mini-menu:hover {
  opacity: 1;
}

body.immersive .whoi-logo {
  opacity: 0.3;
}

body.immersive .canvas-counter {
  display: none;
}

/* Immersive exit hint */
body.immersive::after {
  content: "Druk ESC om Immersive Mode te verlaten";
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 10000;
  opacity: 1;
  animation: fadeOut 4s forwards;
  pointer-events: none;
}

@keyframes fadeOut {
  0%, 50% { opacity: 1; }
  100% { opacity: 0; }
}

/* Responsive */
@media (max-width: 768px) {
  .topbar {
    flex-wrap: wrap;
    height: auto;
  }
  
  .topbar-left h1 {
    font-size: 1.1rem;
  }
  
  .header-btn .btn-text {
    display: none;
  }
  
  .story-content {
    grid-template-columns: 1fr;
  }
  
  #sidebar {
    width: 180px;
  }
  
  .wrapper {
    grid-template-columns: 180px 1fr;
  }
}

/* Schalen voor kleinere hoogtes */
@media (max-height:820px) { 
  body:not(.immersive) {
    transform:scale(.92);
    transform-origin:top left;
  } 
}

@media (max-height:700px) { 
  body:not(.immersive) {
    transform:scale(.85);
    transform-origin:top left;
  } 
}

/* Viewport height variable */
canvas {
  display: block;
  width: 100%;
  height: calc(var(--vh, 1vh) * 100);
}
