/* Qbit styles. Cube size is 200px; faces are pushed out by 100px (half) in 3D. */

:root {
  --bg-canvas: #e6ebf2;
  --bg-grid: #b4bfce;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --danger: #ef4444;
  --primary: #2563eb;
  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: var(--font-main); }

html, body {
  width: 100vw; height: 100vh; overflow: hidden;
  background: var(--bg-canvas); color: var(--text-main);
}

.canvas {
  width: 100vw; height: 100vh; position: relative;
  background-image: radial-gradient(var(--bg-grid) 1.2px, transparent 1.2px);
  background-size: 24px 24px;
}

.btn { padding: 6px 12px; font-size: 12px; font-weight: 600; border-radius: 8px; border: none; cursor: pointer; }
.btn-primary { background: #0f172a; color: #fff; }
.btn-primary:hover { background: #1e293b; }
.btn-danger { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }

/* Cube */
.qbit-viewport { position: absolute; width: 200px; height: 200px; perspective: 1200px; z-index: 10; }
.qbit-viewport.is-focused { z-index: 5000; }
/* The glow goes on the OUTER wrapper. Putting a filter on .qbit-cube would flatten the 3D cube. */
.qbit-viewport.is-focused { filter: drop-shadow(0 20px 25px rgba(15,23,42,0.18)); }

.qbit-cube {
  width: 100%; height: 100%; position: relative; transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.qbit-cube.is-rotating { transition: none; }

.cube-face {
  position: absolute; width: 200px; height: 200px; padding: 10px;
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: 14px; border: 1px solid #7c8da3;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.cube-face.front  { transform: rotateY(0deg)   translateZ(100px); background: #d3dce8; }
.cube-face.right  { transform: rotateY(90deg)  translateZ(100px); background: #c6d1e0; }
.cube-face.back   { transform: rotateY(180deg) translateZ(100px); background: #d3dce8; }
.cube-face.left   { transform: rotateY(-90deg) translateZ(100px); background: #c6d1e0; }
.cube-face.top    { transform: rotateX(90deg)  translateZ(100px); background: #dbe3ed; }
.cube-face.bottom { transform: rotateX(-90deg) translateZ(100px); background: #b9c5d6; }
.cube-face.active-face { background: #fff; border: 1px solid var(--primary); }

/* Grey outer edge: grab it and drag to turn the cube */
.qbit-grab-frame {
  position: absolute; inset: 0; z-index: 20;
  border: 12px solid transparent; border-radius: 14px;
  cursor: grab;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}
.qbit-grab-frame:hover { border-color: rgba(148,163,184,0.25); background-color: rgba(148,163,184,0.08); }
.qbit-cube.is-rotating .qbit-grab-frame {
  cursor: grabbing; border-color: rgba(100,116,139,0.4); background-color: rgba(100,116,139,0.12);
}

/* Everything inside a face sits above the grab frame */
.qbit-face-content { position: relative; z-index: 40; width: 100%; height: 100%; display: flex; flex-direction: column; }

/* Text on faces you are not looking at is hidden, so cube edges stay crisp.
   It is shown again while you turn the cube. */
.cube-face:not(.active-face) .qbit-face-content { opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
.cube-face.active-face .qbit-face-content { transition: opacity 0.3s ease 0.1s; }
.qbit-cube.is-rotating .cube-face .qbit-face-content { opacity: 1; transition: none; }

/* Face header: drag it to move the cube */
.qbit-header {
  display: flex; align-items: center; gap: 2px; padding: 2px 4px; min-height: 22px;
  background: rgba(255,255,255,0.75); border-bottom: 1px solid rgba(203,213,225,0.6);
  border-radius: 12px 12px 0 0; cursor: move; user-select: none;
}
.qbit-face-title { font-size: 11px; font-weight: 600; color: var(--text-muted); margin-right: auto; }
.qbit-btn {
  background: transparent; border: none; cursor: pointer; font-size: 10px;
  min-width: 16px; height: 16px; border-radius: 4px; color: var(--text-muted);
}
.qbit-btn:hover { color: var(--text-main); background: rgba(15,23,42,0.08); }
.qbit-btn.delete:hover { color: var(--danger); background: #fef2f2; }

.qbit-body { flex: 1; display: flex; flex-direction: column; padding: 6px; min-height: 0; }
.qbit-textarea {
  flex: 1; width: 100%; border: none; resize: none; outline: none;
  font-size: 13px; line-height: 1.45; color: var(--text-main); background: transparent; border-radius: 8px;
}
.qbit-textarea:focus { background: rgba(255,255,255,0.95); box-shadow: inset 0 0 0 1px var(--primary); }
.qbit-footer { display: flex; align-items: center; justify-content: space-between; padding-top: 4px; font-size: 10px; color: #94a3b8; pointer-events: none; }
.qbit-dot { width: 6px; height: 6px; border-radius: 50%; background: #cbd5e1; }
.qbit-dot.has-content { background: var(--primary); }

/* Cursors while orbiting (right-click drag, or hold Space and drag) */
body.space-held, body.space-held .qbit-viewport *, body.is-orbiting, body.is-orbiting * { cursor: grab !important; }
body.is-orbiting, body.is-orbiting * { cursor: grabbing !important; }

/* ---- State links ---- */
.link-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; overflow: visible; }
.link-layer line { stroke: #64748b; stroke-width: 2; stroke-linecap: round; }
.qbit-viewport.is-link-source { filter: drop-shadow(0 0 12px rgba(37,99,235,0.7)); }
.link-hint {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 10000;
  max-width: 80vw; padding: 10px 18px; font-size: 13px; line-height: 1.4; text-align: center;
  color: #fff; background: #0f172a; border-radius: 12px; box-shadow: 0 10px 25px -5px rgba(0,0,0,0.25);
}
.link-hint:empty { display: none; }

/* ---- Sidebar ---- */
:root { --sidebar-w: 230px; }
.canvas { margin-left: var(--sidebar-w); width: calc(100vw - var(--sidebar-w)); }
.link-hint { left: calc(50% + var(--sidebar-w) / 2); }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w); z-index: 10000;
  display: flex; flex-direction: column; gap: 24px; padding: 24px 16px;
  background: #ffffff; border-right: 1px solid #cbd5e1;
  box-shadow: 4px 0 20px -8px rgba(15,23,42,0.12);
}
.sidebar-brand h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.sidebar-brand p { margin-top: 2px; font-size: 12px; color: var(--text-muted); }
.sidebar h2 { margin-bottom: 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
.sidebar .btn { display: block; width: 100%; margin-bottom: 8px; padding: 10px 12px; font-size: 13px; }
.face-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.face-btn {
  padding: 9px 0; font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--text-main); background: #fff; border: 1px solid #cbd5e1; border-radius: 8px;
}
.face-btn:hover { background: #f1f5f9; }
.face-btn.is-active { color: #fff; background: var(--primary); border-color: var(--primary); }
.sidebar-note { margin-top: 8px; font-size: 11px; line-height: 1.4; color: var(--text-muted); }

/* Cube footer: face name on the left, role (Main / Dependent) in the middle */
.qbit-footer-left { display: flex; align-items: center; gap: 6px; }
.qbit-role { font-size: 9px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--primary); }

.btn-accent { background: var(--primary); color: #fff; }
.btn-accent:hover { background: #1d4ed8; }
