/* =============================================================================
 * premium-cover-whiteboard-final.css
 * -----------------------------------------------------------------------------
 * Final overrides loaded AFTER polish-final.css. This file does two things:
 *   1. Hard-fix the page cover so reposition mode is stable, the action
 *      buttons stay clickable, and tilt/spotlight don't fight the position.
 *   2. Make the Whiteboard visibly premium: floating glass topbar, glass
 *      toolbar pills, polished subbar, dark canvas with depth gradients,
 *      premium textareas for inline text + equations.
 *
 * Reduced motion and mobile are honoured at the bottom of the file.
 * =============================================================================
 */

/* ── Cover hardfix ─────────────────────────────────────────────────────── */
.page-cover.has-cover.cover-repositioning,
.page-cover.has-cover.cover-repositioning:hover {
  transform: none !important;
  animation: none !important;
}
.page-cover.has-cover.cover-repositioning img,
.page-cover.has-cover.cover-repositioning:hover img {
  transform: none !important;
  transition: object-position 80ms linear !important;
  cursor: ns-resize !important;
}
.page-cover.has-cover.cover-repositioning::after,
.page-cover.has-cover.cover-repositioning::before {
  opacity: 0 !important;
  background: transparent !important;
}

/* Cover actions stay reachable, especially during reposition. */
.page-cover.has-cover.cover-repositioning .page-cover-actions,
.page-cover.has-cover:hover .page-cover-actions,
.page-cover.has-cover .page-cover-actions:hover,
.page-cover.has-cover:focus-within .page-cover-actions {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: translateY(0) !important;
}

.page-cover-actions {
  z-index: 20 !important;
  pointer-events: auto !important;
}
.cover-action-btn {
  z-index: 21 !important;
  pointer-events: auto !important;
}

/* ── Whiteboard premium look ─────────────────────────────────────────────
 * Visible difference vs. the previous flat look:
 *   - Layered radial gradients + soft dot grid as canvas background.
 *   - Floating glass topbar + toolbar with rounded corners, blur, shadow.
 *   - Active tool clearly inverted (white pill on dark, black pill on light).
 *   - Hover lift + soft glow.
 *   - Polished sub-toolbar (palette, brush size, snap/grid).
 *   - Glassy text + equation inline editors with proper focus ring.
 */

/* ----- Editor root: depth canvas ----- */
.wb-editor-root {
  position: relative;
}
.wb-editor-root::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 600px at 12% -10%, rgba(120, 140, 200, 0.10), transparent 60%),
    radial-gradient(900px 600px at 92% 110%, rgba(180, 130, 220, 0.07), transparent 60%),
    radial-gradient(circle at center, transparent 0, rgba(0, 0, 0, 0.18) 100%);
  z-index: 0;
}

/* The actual SVG canvas keeps a faint dot pattern AND a top vignette. */
:root[data-theme="dark"] .wb-canvas {
  background:
    radial-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px) 0 0 / 18px 18px,
    radial-gradient(900px 600px at 50% -10%, rgba(255, 255, 255, 0.04), transparent 60%),
    linear-gradient(180deg, #0c0d11 0%, #08090c 100%);
}
:root[data-theme="light"] .wb-canvas {
  background:
    radial-gradient(rgba(15, 18, 28, 0.06) 1px, transparent 1px) 0 0 / 18px 18px,
    radial-gradient(900px 600px at 50% -10%, rgba(15, 18, 28, 0.03), transparent 60%),
    linear-gradient(180deg, #f9fafc 0%, #eef0f6 100%);
}

/* ----- Topbar: floating glass header ----- */
.wb-top {
  position: relative;
  z-index: 4;
  margin: 10px 12px 0 !important;
  padding: 10px 14px !important;
  border-radius: 14px !important;
  background: rgba(20, 22, 28, 0.55) !important;
  border: 1px solid rgba(255, 255, 255, 0.10) !important;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 -1px 0 rgba(0, 0, 0, 0.30) inset,
    0 14px 32px rgba(0, 0, 0, 0.32) !important;
  backdrop-filter: blur(22px) saturate(1.5) !important;
  -webkit-backdrop-filter: blur(22px) saturate(1.5) !important;
  animation: wbFadeUp 320ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
:root[data-theme="light"] .wb-top {
  background: rgba(255, 255, 255, 0.78) !important;
  border-color: rgba(15, 18, 28, 0.10) !important;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 12px 28px rgba(15, 18, 28, 0.10) !important;
}

/* ----- Toolbar pill ----- */
.wb-toolbar {
  position: relative;
  z-index: 3;
  margin: 10px 12px 0 !important;
  padding: 6px !important;
  display: inline-flex !important;
  flex-wrap: wrap;
  gap: 4px !important;
  border-radius: 14px !important;
  background: rgba(20, 22, 28, 0.55) !important;
  border: 1px solid rgba(255, 255, 255, 0.10) !important;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 -1px 0 rgba(0, 0, 0, 0.30) inset,
    0 12px 28px rgba(0, 0, 0, 0.32) !important;
  backdrop-filter: blur(22px) saturate(1.5) !important;
  -webkit-backdrop-filter: blur(22px) saturate(1.5) !important;
  animation: wbFadeUp 360ms cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 60ms;
}
:root[data-theme="light"] .wb-toolbar {
  background: rgba(255, 255, 255, 0.85) !important;
  border-color: rgba(15, 18, 28, 0.10) !important;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 10px 24px rgba(15, 18, 28, 0.10) !important;
}

/* ----- Toolbar buttons ----- */
.wb-toolbar .wb-tool,
.wb-toolbar .wb-btn,
.wb-toolbar > button {
  position: relative;
  width: 32px;
  height: 32px;
  display: inline-grid !important;
  place-items: center !important;
  border-radius: 10px !important;
  border: 1px solid transparent !important;
  background: transparent !important;
  color: rgba(245, 245, 247, 0.85) !important;
  cursor: pointer;
  transition:
    background 140ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color 140ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 140ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 220ms cubic-bezier(0.22, 1, 0.36, 1) !important;
}
.wb-toolbar .wb-tool:hover,
.wb-toolbar .wb-btn:hover,
.wb-toolbar > button:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.14) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28) !important;
}
.wb-toolbar .wb-tool.active,
.wb-toolbar > button.active {
  background: #ffffff !important;
  color: #0a0a0a !important;
  border-color: #ffffff !important;
  box-shadow:
    0 8px 22px rgba(0, 0, 0, 0.42),
    0 0 0 2px rgba(255, 255, 255, 0.08) !important;
  animation: wbToolPop 240ms cubic-bezier(0.16, 1, 0.3, 1);
}
.wb-toolbar .wb-tool:active,
.wb-toolbar > button:active { transform: translateY(0) scale(0.96) !important; }
.wb-toolbar .wb-tool svg { width: 16px; height: 16px; }

:root[data-theme="light"] .wb-toolbar .wb-tool,
:root[data-theme="light"] .wb-toolbar > button {
  color: rgba(15, 18, 28, 0.78) !important;
}
:root[data-theme="light"] .wb-toolbar .wb-tool.active,
:root[data-theme="light"] .wb-toolbar > button.active {
  background: #0a0a0a !important;
  color: #ffffff !important;
  border-color: #0a0a0a !important;
}

.wb-toolbar .wb-sep {
  width: 1px !important;
  height: 18px !important;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.18), transparent) !important;
  margin: 0 4px !important;
}
:root[data-theme="light"] .wb-toolbar .wb-sep {
  background: linear-gradient(180deg, transparent, rgba(15, 18, 28, 0.18), transparent) !important;
}

/* ----- Sub-toolbar (palette + brush + grid) ----- */
.wb-subbar {
  position: relative;
  z-index: 3;
  margin: 8px 12px 0 !important;
  padding: 8px 12px !important;
  border-radius: 12px !important;
  background: rgba(20, 22, 28, 0.45) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28) !important;
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  animation: wbFadeUp 380ms cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 100ms;
}
:root[data-theme="light"] .wb-subbar {
  background: rgba(255, 255, 255, 0.78) !important;
  border-color: rgba(15, 18, 28, 0.08) !important;
}

.wb-subbar .wb-color {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.18);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 220ms ease;
}
.wb-subbar .wb-color:hover {
  transform: scale(1.18);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.42);
}
.wb-subbar .wb-color.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.28);
}

.wb-subbar input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  height: 4px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0.10));
  border-radius: 999px;
  outline: none;
}
.wb-subbar input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.65);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: transform 140ms ease;
}
.wb-subbar input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.1); }

/* ----- Inline text + equation editors ----- */
.wb-text-edit,
.wb-eq-edit {
  background: rgba(20, 22, 28, 0.92) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.20) !important;
  border-radius: 10px !important;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.15) inset,
    0 14px 36px rgba(0, 0, 0, 0.55) !important;
  padding: 8px 10px !important;
  outline: none !important;
}
.wb-text-edit:focus,
.wb-eq-edit:focus {
  border-color: rgba(255, 255, 255, 0.55) !important;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.20) inset,
    0 0 0 3px rgba(255, 255, 255, 0.12),
    0 18px 42px rgba(0, 0, 0, 0.65) !important;
}

/* ----- Whiteboard list cards (when shown as page block) ----- */
.wb-card-list .wb-card,
.wb-block-card {
  position: relative;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(20, 22, 28, 0.55);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 12px 28px rgba(0, 0, 0, 0.30);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  transition:
    transform 180ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 220ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color 180ms cubic-bezier(0.22, 1, 0.36, 1);
}
.wb-card-list .wb-card:hover,
.wb-block-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.10) inset,
    0 22px 48px rgba(0, 0, 0, 0.45);
}

/* ----- Animations ----- */
@keyframes wbFadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes wbToolPop {
  from { transform: scale(0.94); }
  60%  { transform: scale(1.05); }
  to   { transform: scale(1); }
}
@keyframes wbGlowSweep {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ── Reduced motion ───────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .wb-top,
  .wb-toolbar,
  .wb-subbar { animation: none !important; }
  .wb-toolbar .wb-tool:hover,
  .wb-toolbar > button:hover { transform: none !important; }
  .wb-toolbar .wb-tool.active,
  .wb-toolbar > button.active { animation: none !important; }
  .wb-card-list .wb-card:hover,
  .wb-block-card:hover { transform: none !important; }
}

/* ── Mobile ───────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .wb-top,
  .wb-toolbar,
  .wb-subbar { margin-left: 8px !important; margin-right: 8px !important; }
  .wb-toolbar .wb-tool:hover,
  .wb-toolbar > button:hover { transform: none !important; }
}


/* =============================================================================
 * Cover flat hardfix — final wins.
 * No more 3D tilt/scale; only a soft pointer-following light. Buttons stay
 * clickable at any zoom. Works whether or not .has-cover is present.
 * ============================================================================= */
.page-cover::before,
.page-cover::after { pointer-events: none !important; }

.page-cover,
.page-cover:hover,
.page-cover.has-cover,
.page-cover.has-cover:hover {
  transform: none !important;
}
.page-cover img,
.page-cover:hover img,
.page-cover.has-cover:hover img {
  transform: none !important;
}

/* Pointer-following light, present even without .has-cover. */
.page-cover {
  position: relative;
}
.page-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none !important;
  background: radial-gradient(
    420px 260px at var(--gs-mx, 50%) var(--gs-my, 50%),
    rgba(255, 255, 255, 0.28),
    rgba(255, 255, 255, 0.08) 38%,
    transparent 72%
  ) !important;
  opacity: 0.55;
  transition: opacity 160ms ease;
}
.page-cover:hover::after { opacity: 0.85; }

/* Action buttons must stay reachable. */
.page-cover-actions {
  position: absolute !important;
  right: max(14px, env(safe-area-inset-right)) !important;
  bottom: 14px !important;
  z-index: 100 !important;
  pointer-events: auto !important;
  display: flex !important;
  gap: 8px !important;
  opacity: 0;
  visibility: visible !important;
  transform: translateY(4px);
  transition: opacity 160ms ease, transform 160ms ease;
}
.page-cover:hover .page-cover-actions,
.page-cover:focus-within .page-cover-actions,
.page-cover .page-cover-actions:hover,
.page-cover.cover-repositioning .page-cover-actions {
  opacity: 1 !important;
  transform: translateY(0) !important;
  pointer-events: auto !important;
}
.cover-action-btn {
  position: relative !important;
  z-index: 101 !important;
  pointer-events: auto !important;
}
/* Invisible hover bridge so the cursor never falls into a dead gap
 * between the cover and the buttons. */
.page-cover-actions::before {
  content: "";
  position: absolute;
  inset: -12px;
  pointer-events: auto;
  z-index: -1;
}

/* When repositioning, kill the moving light too — we want a stable surface. */
.page-cover.cover-repositioning::after,
.page-cover.cover-repositioning::before {
  opacity: 0 !important;
  background: transparent !important;
}


/* ── AI key prompt modal ─────────────────────────────────────────────── */
.ai-key-prompt-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.ai-key-prompt-modal .modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.ai-key-prompt-card {
  position: relative;
  width: min(440px, 100%);
  padding: 22px 22px 18px;
  border-radius: 16px;
  background: rgba(20, 22, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f5f5f7;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  animation: aiKeyModalIn 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.ai-key-prompt-card h2 {
  margin: 0 0 8px;
  font-size: 19px;
  letter-spacing: -0.01em;
}
.ai-key-prompt-card p {
  margin: 0 0 16px;
  color: rgba(245, 245, 247, 0.78);
  line-height: 1.5;
  font-size: 14px;
}
.ai-key-prompt-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.ai-key-prompt-actions .btn {
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}
.ai-key-prompt-actions .btn-primary {
  background: #fff;
  color: #0a0a0a;
  border-color: #fff;
}
.ai-key-prompt-actions .btn-ghost {
  background: transparent;
  color: rgba(245, 245, 247, 0.86);
  border-color: rgba(255, 255, 255, 0.22);
}
.ai-key-prompt-actions .btn-primary:hover { background: rgba(255, 255, 255, 0.92); }
.ai-key-prompt-actions .btn-ghost:hover { background: rgba(255, 255, 255, 0.06); }
@keyframes aiKeyModalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.96); filter: blur(4px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}
@media (prefers-reduced-motion: reduce) {
  .ai-key-prompt-card { animation: none !important; }
}
