/* Reset and Variables */
:root {
  --blue-bg: #dbeafe;
  --blue-text: #2563eb;
  --brand-bg: #dedcff;
  --brand-text: #6c5cff;
  --bg-color: transparent;
  --border-color: #e4e4e7;
  --text-primary: #18181b;
  --text-secondary: #71717a;
  --tooltip-bg: #18181b;
  --zinc-100: #f4f4f5;
  --font-family-sans:
    "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-family-mono: "Inter", monospace;
}

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

html {
  background: transparent;
}

body {
  font-family: var(--font-family-sans);
  background-color: var(--bg-color);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* Canvas Container */
.canvas-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Demo Info */
.demo-info {
  position: absolute;
  bottom: 48px;
  text-align: center;
  max-width: 500px;
  z-index: 10;
  padding: 0 20px;
  display: none; /* temporarily hidden */
}

.demo-info h1 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

.demo-info p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

kbd {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.8rem;
  font-family: var(--font-family-mono);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}

#status-panel {
  margin-top: 16px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: white;
  padding: 6px 12px;
  border-radius: 9999px;
  border: 1px solid var(--border-color);
  display: inline-block;
}

#current-tool {
  color: var(--brand-text);
  font-weight: 600;
}

/* Toolbar System (Centered) */
.toolbar-system {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

/* Toolbar Floating Wrapper */
.toolbar-wrapper {
  position: relative;
  pointer-events: none;
}

.toolbar-container {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow:
    0 10px 25px -10px rgba(0, 0, 0, 0.05),
    0 1px 3px rgba(0, 0, 0, 0.01);
  pointer-events: auto;
  overflow: visible; /* CRITICAL: let shared pill hop outside boundary */
}

/* Shared Hover Pill Background */
.hover-pill {
  position: absolute;
  top: 6px;
  bottom: 6px;
  border-radius: 8px;
  z-index: 0;
  pointer-events: none;
  background-color: var(--zinc-100);
  opacity: 0;
  /* stiffness: 350, damping: 30 spring equivalent */
  transition:
    left 0.35s cubic-bezier(0.2, 0.9, 0.4, 1),
    width 0.35s cubic-bezier(0.2, 0.9, 0.4, 1),
    opacity 0.2s ease;
}

/* Shared Active Pill Background */
.active-pill {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 8px;
  width: 40px;
  border-radius: 8px;
  z-index: 1;
  pointer-events: none;
  transition: background-color 0.25s ease;
  transform-origin: center center;
  will-change: transform, width;
}

.active-pill.blue-bg {
  background-color: var(--blue-bg);
}

.active-pill.brand-bg {
  background-color: var(--brand-bg);
}

/* Tool Buttons */
.tool-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: color 0.2s ease;
  z-index: 2; /* Sits above active pill */
}

.tool-btn:hover {
  color: var(--text-primary);
}

.tool-btn.active {
  color: var(--blue-text);
}

.tool-btn.active.brand {
  color: var(--brand-text);
}

/* Icon Wrappers */
.icon-wrapper {
  position: relative;
  z-index: 2;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.icon-svg {
  width: 20px;
  height: 20px;
  stroke-width: 2px;
}

/* Divider styling */
.divider {
  width: 1px;
  height: 20px;
  background-color: var(--border-color);
  margin: 0 4px;
  z-index: 2;
}

/* Custom Sticky outline icon */
.sticky-outline {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 2px;
  transition: border-color 0.2s ease;
}

/* Micro-animations on Hover */
.tool-btn:not(.active):hover .select-icon {
  transform: scale(1.1) rotate(-15deg) translate(-1px, -1px);
}

.tool-btn:not(.active):hover .pan-icon {
  animation: wiggle 0.4s ease-in-out;
}

.tool-btn:not(.active):hover .frame-icon {
  transform: scale(1.1);
}

.tool-btn:not(.active):hover .sticky-icon {
  transform: scale(1.15) rotate(10deg) translateY(-1px);
}

.tool-btn:not(.active):hover .text-icon {
  transform: scale(1.1) translateY(-2px);
}

.tool-btn:not(.active):hover .marker-icon {
  transform: scale(1.1) rotate(-20deg) translate(2px, -2px);
}

.tool-btn:not(.active):hover .shape-icon {
  transform: scale(1.15);
}

.tool-btn:not(.active):hover .link-icon {
  transform: scale(1.1);
}

/* Wiggle animation keyframes */
@keyframes wiggle {
  0%,
  100% {
    transform: scale(1.1) rotate(0deg);
  }
  20% {
    transform: scale(1.1) rotate(-15deg);
  }
  40% {
    transform: scale(1.1) rotate(15deg);
  }
  60% {
    transform: scale(1.1) rotate(-10deg);
  }
  80% {
    transform: scale(1.1) rotate(5deg);
  }
}

/* Active Icon Pop Animation */
.tool-btn.active .icon-wrapper {
  animation: icon-pop 0.45s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes icon-pop {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(0.8);
  }
  70% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* Tooltip */
.tooltip-wrapper {
  position: relative;
  display: inline-block;
  z-index: 3;
}

.tooltip {
  position: absolute;
  top: 50px;
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background-color: var(--tooltip-bg);
  color: white;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition:
    opacity 0.15s ease 0s,
    transform 0.15s cubic-bezier(0.22, 1, 0.36, 1) 0s;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
}

.tooltip .shortcut {
  color: #a1a1aa;
  margin-left: 4px;
  font-family: var(--font-family-mono);
  font-size: 0.7rem;
}

.tooltip-wrapper:hover .tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  transition-delay: 1s, 1s;
}

/* --- Secondary Properties Toolbar Styles --- */

.properties-toolbar-wrapper {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translate(-50%, 20px) scale(0.9);
  width: 380px;
  height: 52px;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  box-shadow: 0 10px 25px -10px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  opacity: 0;
  pointer-events: none;
  z-index: 99;
  /* Exit transition: fast pop down */
  transition:
    opacity 0.15s ease-in,
    transform 0.2s ease-in;
  overflow: visible; /* CRITICAL: let custom slider swatch thumbs pop outside menu boundary */
}

/* Dynamic Widths based on active panel */
.properties-toolbar-wrapper.panel-sticky {
  width: 280px;
}

.properties-toolbar-wrapper.panel-marker {
  width: 220px;
}

.properties-toolbar-wrapper.panel-marker .thickness-wrapper {
  width: 180px;
}

.properties-toolbar-wrapper.panel-text {
  width: 160px;
}

.properties-toolbar-wrapper.panel-link {
  width: 380px;
}

.properties-toolbar-wrapper.panel-shape {
  width: 200px;
}

.properties-toolbar-wrapper.active {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  pointer-events: auto;
  /* Entrance transition: bouncy pop up */
  transition:
    opacity 0.15s ease-out,
    transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.property-panel {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible; /* Let sliders bulge and thumbs morph outward */
}

.hidden {
  display: none !important;
}

.panel-divider {
  width: 1px;
  height: 20px;
  background-color: var(--border-color);
  margin: 0 12px;
  flex-shrink: 0;
}

/* Panel Buttons */
.panel-icon-btn {
  position: relative;
  background: transparent;
  border: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color 0.2s;
  outline: none;
}

.panel-icon-btn:hover {
  color: var(--text-primary);
}

.panel-icon-btn.active {
  color: var(--text-primary);
}

.btn-hover-shim {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background-color: var(--zinc-100);
  opacity: 0;
  transform: scale(0.96);
  transition:
    opacity 0.15s,
    transform 0.15s;
  z-index: -1;
}

.panel-icon-btn:hover .btn-hover-shim,
.panel-icon-btn.active .btn-hover-shim {
  opacity: 1;
  transform: scale(1);
}

.panel-icon {
  width: 16px;
  height: 16px;
  position: relative;
  z-index: 2;
  transition: transform 0.25s cubic-bezier(0.2, 1, 0.2, 1);
}

/* Micro-animations */
.panel-icon-btn:hover .marker-pencil,
.panel-icon-btn:hover .marker-highlighter {
  transform: scale(1.1) rotate(-15deg);
}

.panel-icon-btn:hover .marker-eraser {
  transform: scale(1.15) rotate(15deg);
}

/* Shape Micro-animations */
.panel-icon-btn:hover [data-lucide="square"],
.panel-icon-btn:hover [data-lucide="circle"],
.panel-icon-btn:hover [data-lucide="triangle"],
.panel-icon-btn:hover [data-lucide="diamond"],
.panel-icon-btn:hover [data-lucide="hexagon"] {
  transform: scale(1.1);
}

/* Sticky Colors list */
.sticky-colors-list {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.sticky-color-btn {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.05);
  cursor: pointer;
  outline: none;
  transition: transform 0.2s cubic-bezier(0.2, 1, 0.2, 1);
}

.sticky-color-btn:hover {
  transform: scale(1.15);
}

.sticky-color-btn.active {
  transform: scale(1.1);
  box-shadow:
    0 0 0 2px var(--text-secondary),
    0 0 0 4px white;
}

/* Slider wrappers */
.slider-wrapper {
  position: relative;
  height: 32px;
  display: flex;
  align-items: center;
  overflow: visible;
  touch-action: none;
}

.thickness-wrapper {
  width: 90px;
}

.color-wrapper {
  width: 140px;
}

/* Custom sliders */
.custom-slider {
  position: relative;
  width: 100%;
  height: 32px;
  cursor: pointer;
  overflow: visible;
}

.slider-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.slider-track-path {
  transition:
    stroke 0.15s ease,
    fill 0.15s ease;
}

.slider-thumb {
  position: absolute;
  pointer-events: none;
  z-index: 1000;
  transform: translate(-50%, -50%);
  top: 16px;
  left: 0;
  transition: left 0.05s linear;
}

/* Thickness Slider Thumb */
.thickness-thumb {
  width: 20px;
  height: 20px;
  background: white;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.3s cubic-bezier(0.2, 1, 0.2, 1),
    width 0.3s cubic-bezier(0.2, 1, 0.2, 1),
    height 0.3s cubic-bezier(0.2, 1, 0.2, 1);
}

.thumb-inner-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition:
    background-color 0.15s ease,
    width 0.15s ease,
    height 0.15s ease;
}

.thickness-thumb.dragging {
  transform: translate(-50%, -50%) translateY(-28px);
  width: 32px;
  height: 32px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: none !important;
}

/* Color Slider Swatch */
.color-thumb {
  width: 32px;
  height: 50px;
  margin-top: -25px;
}

.color-swatch-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.12));
}

.color-swatch-svg path {
  transition:
    d 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    fill 0.15s ease,
    transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Text size controls */
.text-size-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.shape-selector {
  display: flex;
  align-items: center;
  gap: 4px;
}

.font-size-indicator {
  font-family: var(--font-family-mono);
  font-size: 0.8rem;
  font-weight: 500;
  width: 44px;
  text-align: center;
  color: var(--text-secondary);
}

/* Link Submit form */
.link-submit-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

#link-input {
  flex: 1;
  background-color: var(--zinc-100);
  border: 1px solid rgba(228, 228, 231, 0.5);
  border-radius: 9999px;
  padding: 6px 12px;
  height: 32px;
  font-size: 0.85rem;
  font-family: var(--font-family-sans);
  color: var(--text-primary);
  outline: none;
  transition:
    background 0.15s,
    border-color 0.15s;
}

#link-input:focus {
  background-color: white;
  border-color: var(--brand-text);
  box-shadow: 0 0 0 3px rgba(108, 92, 255, 0.15);
}

.submit-btn {
  background-color: var(--brand-text);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(108, 92, 255, 0.25);
  flex-shrink: 0;
  transition:
    background 0.2s,
    transform 0.2s;
}

.submit-btn:hover {
  background-color: #5a4be8;
  transform: scale(1.05);
}

.submit-btn:active {
  transform: scale(0.95);
}

.file-upload-label {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition:
    background 0.2s,
    color 0.2s;
}

.file-upload-label:hover {
  background-color: var(--zinc-100);
  color: var(--text-primary);
}
