/* ==========================================================================
   TABLET STYLUS & INKING ENGINE STYLESHEET
   Apple Pencil • Samsung S-Pen • USI Stylus • Palm Rejection Support
   ========================================================================== */

/* Inking Canvas Overlay */
#stylus-inking-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
  touch-action: pan-y pinch-zoom;
  transition: opacity 0.15s ease;
}

#stylus-inking-canvas.active-inking {
  pointer-events: auto;
}

/* Custom Inking Cursor */
.inking-pen-cursor {
  cursor: crosshair !important;
}

/* Floating Stylus HUD Toolbar */
.stylus-floating-hud {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1002;
  background: var(--bg-hud, rgba(252, 252, 251, 0.94));
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-hud, rgba(0, 0, 0, 0.12));
  border-radius: 9999px;
  box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.15), 0 4px 12px -2px rgba(0, 0, 0, 0.08);
  padding: 0.35rem 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
  user-select: none;
  -webkit-user-select: none;
}

[data-theme="dark"] .stylus-floating-hud {
  background: rgba(15, 23, 42, 0.94);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.5);
}

[data-theme="sepia"] .stylus-floating-hud {
  background: rgba(247, 239, 225, 0.96);
  border-color: rgba(184, 163, 130, 0.6);
}

.stylus-hud-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  position: relative;
}

.stylus-hud-btn:hover {
  background: var(--accent-light, rgba(37, 99, 235, 0.12));
  color: var(--accent-color, #2563eb);
  transform: translateY(-1px);
}

.stylus-hud-btn.active {
  background: var(--accent-color, #2563eb) !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.stylus-divider {
  width: 1px;
  height: 1.5rem;
  background: var(--border-hud, rgba(0, 0, 0, 0.12));
  margin: 0 0.15rem;
}

/* Color Swatches Popover / Row */
.stylus-color-palette {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0 0.2rem;
}

.stylus-color-dot {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

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

.stylus-color-dot.selected {
  border-color: var(--text-primary);
  transform: scale(1.15);
  box-shadow: 0 0 0 2px var(--bg-hud);
}

/* Thickness Indicator Pill */
.stylus-thickness-indicator {
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
  border-radius: 9999px;
  background: var(--code-bg, rgba(0, 0, 0, 0.05));
  border: 1px solid var(--border-hud, rgba(0, 0, 0, 0.1));
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
}

/* Star / IMP Badge on Canvas */
.canvas-imp-badge {
  position: absolute;
  transform: translate(-50%, -50%);
  background: #fef08a;
  color: #854d0e;
  border: 1.5px solid #eab308;
  font-family: var(--font-sans, sans-serif);
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.15rem 0.55rem;
  border-radius: 9999px;
  box-shadow: 0 2px 6px rgba(234, 179, 8, 0.3);
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  z-index: 52;
  user-select: none;
}

.canvas-imp-badge:hover {
  background: #fde047;
  transform: translate(-50%, -50%) scale(1.05);
}

/* Tablet Optimizations */
@media (max-width: 768px) {
  .stylus-floating-hud {
    bottom: 0.75rem;
    right: 50%;
    transform: translateX(50%);
    max-width: calc(100vw - 1.5rem);
    padding: 0.25rem 0.4rem;
    gap: 0.2rem;
  }
  .stylus-hud-btn {
    width: 2.1rem;
    height: 2.1rem;
  }
  .stylus-color-palette {
    gap: 0.2rem;
  }
  .stylus-color-dot {
    width: 1.1rem;
    height: 1.1rem;
  }
  .hud-hide-tablet-sm {
    display: none;
  }
}
