/* ═══════════════════════════════════════════════════════════════════
   Magnus Board — Presenter CSS
   Dark theme, 16:9 letterbox, canvas layers, minimal chrome
   ═══════════════════════════════════════════════════════════════════ */

/* ── Base ──────────────────────────────────────────────────────── */
body.presenter-body {
  background: #000;
  color: var(--board-text);
  font-family: var(--font-sans);
  overflow: hidden;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Viewport (full screen, centers the 16:9 container) ─────── */
#board-viewport {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  position: relative;
}

/* ── Board Wrapper (holds slide + footer, centered) ─────────── */
#board-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: calc((100vh - 48px) * (16 / 9));
}

/* ── Slide Container (16:9 fixed aspect ratio) ─────────────── */
#slide-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--board-bg);
  overflow: hidden;
}

/* ── Triple Frame: Yellow → Black → Yellow (always visible) ── */
#slide-container::after {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow:
    inset 0 0 0 5px #FFD700,
    inset 0 0 0 11px #000000,
    inset 0 0 0 17px #FFD700;
  pointer-events: none;
  z-index: 200;
}

/* ── Transition color flash overlay ───────────────────────── */
.transition-flash {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
}

/* ── Slide Layers ──────────────────────────────────────────────── */
#slide-current,
#slide-next {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  will-change: transform, opacity;
  backface-visibility: hidden;
}

#slide-next {
  visibility: hidden;
  pointer-events: none;
}

/* ── Canvas Layers ─────────────────────────────────────────────── */
/* NOTE: width/height are set by JS (canvas-engine._resize) to match
   container at device-pixel-ratio resolution.  Do NOT set width/height
   here — CSS percentage dimensions cause sub-pixel rounding mismatches
   against the integer backing-buffer size, producing blurry strokes. */
#canvas-committed,
#canvas-active {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 10;
  transition: opacity 150ms ease-out;
}

#canvas-active {
  z-index: 11;
}

/* When pen mode is active (P key), show crosshair cursor on container */
#slide-container.pen-active {
  cursor: crosshair;
}

/* Disable all browser touch/pen gestures on the slide container.
   JS handles pen/mouse/touch discrimination in CanvasEngine._onPointerDown.
   Must be unconditional — @media(pointer:fine) misses secondary pen devices. */
#slide-container { touch-action: none; }

/* ── Board Footer (attached to bottom frame) ─────────────────── */
#board-footer {
  position: relative;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: #0a0a0f;
  border-top: 5px solid #FFD700;
  font-family: var(--font-sans);
  color: rgba(255, 255, 255, 0.9);
  flex-shrink: 0;
}

.footer-progress {
  position: absolute;
  top: 5px;
  left: 0;
  height: 2px;
  background: #FFD700;
  opacity: 0.6;
  transition: width 400ms var(--ease-out);
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.footer-logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: contain;
  filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.3));
}

.footer-brand {
  font-family: var(--font-display, var(--font-sans));
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  color: #FFD700;
}

.footer-counter {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 0.05em;
}

.footer-right {
  display: flex;
  align-items: center;
}

#footer-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Pen Toolbar ───────────────────────────────────────────────── */
#pen-toolbar {
  position: fixed;
  bottom: 50px;
  right: 20px;
  background: rgba(20, 20, 35, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: 12px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity var(--transition-normal), transform var(--transition-normal);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

#pen-toolbar.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.toolbar-section {
  display: flex;
  gap: 6px;
  align-items: center;
}

.toolbar-section.tools {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 10px;
}

.tool-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--board-text-dim);
  font-size: 1.1rem;
  transition: all var(--transition-fast);
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--board-text);
}

.tool-btn.active {
  background: rgba(99, 102, 241, 0.3);
  color: #818cf8;
}

.color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.color-swatch:hover {
  transform: scale(1.2);
}

.color-swatch.active {
  border-color: var(--board-text);
  transform: scale(1.15);
}

.width-btn {
  width: 36px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.width-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.width-btn.active {
  background: rgba(99, 102, 241, 0.2);
}

.width-btn .line {
  background: var(--board-text);
  border-radius: 2px;
  width: 20px;
}

/* ── Blackout Screen ───────────────────────────────────────────── */
#black-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 200;
  display: none;
  cursor: pointer;
}

#black-screen.active {
  display: block;
}

/* ── Class Listing (shown when no slug) ────────────────────────── */
#class-listing {
  max-width: 800px;
  margin: 0 auto;
  padding: 60px 40px;
  font-family: var(--font-sans);
}

.listing-header {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 40px;
}

.listing-logo {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(255, 215, 0, 0.3));
}

#class-listing h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 4px;
  background: linear-gradient(135deg, var(--board-accent), #FFA500);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

#class-listing .subtitle {
  color: var(--board-text-dim);
  font-size: 1.1rem;
  margin-bottom: 0;
}

/* ── Volume Indicator ─────────────────────────────────────────── */
#volume-indicator {
  position: fixed;
  bottom: 50px;
  left: 20px;
  background: rgba(20, 20, 35, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 200ms, transform 200ms;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--board-text);
}

#volume-indicator.visible {
  opacity: 1;
  transform: translateY(0);
}

#volume-indicator .vol-bar {
  width: 80px;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  overflow: hidden;
}

#volume-indicator .vol-fill {
  height: 100%;
  background: var(--board-accent);
  border-radius: 2px;
  transition: width 150ms;
}

.class-card {
  display: block;
  padding: 20px 24px;
  background: var(--board-surface);
  border: 1px solid var(--board-border);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.class-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--board-accent);
  transform: translateX(4px);
}

.class-card .card-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.class-card .card-meta {
  font-size: 0.85rem;
  color: var(--board-text-dim);
}

/* ── KaTeX overrides for dark theme ────────────────────────────── */
.katex { color: var(--board-text); }
.katex-display { margin: 1em 0; }
.katex-display > .katex { font-size: 1.1em; }

/* ── Slide content defaults ────────────────────────────────────── */
#slide-current .slide-content,
#slide-next .slide-content {
  width: 100%;
  height: 100%;
  color: var(--board-text);
  font-family: var(--font-sans);
  font-size: 1.15rem;
  line-height: 1.6;
}

/* Scale font-size relative to viewport width for responsive text */
@media (min-width: 1200px) {
  #slide-current .slide-content,
  #slide-next .slide-content {
    font-size: clamp(18px, 1.6vw, 28px);
  }
}

/* ── Fragment hidden state ─────────────────────────────────────── */
[data-fragment] {
  visibility: hidden;
  opacity: 0;
}

[data-fragment].revealed {
  visibility: visible;
  opacity: 1;
}

/* ── Loading state ─────────────────────────────────────────────── */
#board-viewport .loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  color: var(--board-text-dim);
}

#board-viewport .loading .spinner {
  width: 48px;
  height: 48px;
}

/* ── Tool Hint (brief popup for shortcut feedback) ─────────────── */
#tool-hint {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(20, 20, 35, 0.92);
  backdrop-filter: blur(8px);
  color: var(--board-text);
  padding: 8px 20px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  border-left: 3px solid var(--board-accent);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms, transform 200ms;
}

#tool-hint.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Canvas Text Input (overlay input for text tool) ──────────── */
.canvas-text-input {
  font-family: 'Inter', sans-serif;
  caret-color: var(--board-accent);
  transition: none;
}

/* ── Font Scaling (I/O keys) ─────────────────────────────────── */
/* Transform-origin top-left so scale() grows rightward & downward,
   keeping the top-left corner anchored. Canvas is a sibling, so
   its bounding rect is unaffected by this transform. */
#slide-current {
  transform-origin: top left;
}

/* ── Scroll Mode (V key) ────────────────────────────────────── */
#slide-current.scroll-mode {
  overflow-y: auto;
  overflow-x: hidden;
}

/* Gold-themed scrollbar to match the presenter frame */
#slide-current.scroll-mode::-webkit-scrollbar {
  width: 8px;
}

#slide-current.scroll-mode::-webkit-scrollbar-track {
  background: rgba(255, 215, 0, 0.05);
}

#slide-current.scroll-mode::-webkit-scrollbar-thumb {
  background: rgba(255, 215, 0, 0.3);
  border-radius: 4px;
}

#slide-current.scroll-mode::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 215, 0, 0.5);
}

/* ── Area Zoom (G key) ──────────────────────────────────────── */
/* Zoom-pick: cursor changes to zoom-in while selecting a center point */
#slide-container.zoom-pick {
  cursor: zoom-in;
}

/* Zoom-active: move cursor while panning the zoomed view */
#slide-container.zoom-active {
  cursor: move;
}
