/* ArchKit — Sakura x Lavender x IKEA x K-pop Aesthetic */

@keyframes blob-drift-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.05); }
  66% { transform: translate(-20px, 15px) scale(0.95); }
}
@keyframes blob-drift-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(-25px, 25px) scale(0.97); }
  66% { transform: translate(20px, -10px) scale(1.03); }
}
@keyframes blob-drift-3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(15px, 20px) scale(1.04); }
  66% { transform: translate(-30px, -15px) scale(0.96); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 157, 0.3); }
  50% { box-shadow: 0 0 0 6px rgba(255, 107, 157, 0); }
}

:root {
  /* Colors */
  --primary: #FF6B9D;
  --secondary: #C084FC;
  --accent-hot: #FF2D78;
  --accent-violet: #8B5CF6;
  --accent-mint: #34D399;
  --accent-peach: #FFBE98;
  --bg-base: #F8F7FF;
  --bg-card: #FFFFFF;
  --bg-input: #F8F7FF;
  --bg-blush: #FFD1DC;
  --bg-powder: #E8DAEF;
  --bg-cloud: #F0EAFF;
  --border: #E8DAEF;
  --border-focus: #C084FC;
  --text: #2D2640;
  --text-secondary: #6B5E7B;
  --text-muted: #B8A9C9;

  /* Typography */
  --font-display: "Quicksand", "Nunito", sans-serif;
  --font-body: "Nunito", "Segoe UI", sans-serif;
  --font-mono: "DM Mono", monospace;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(45, 38, 64, 0.05);
  --shadow-md: 0 4px 16px rgba(45, 38, 64, 0.08);
  --shadow-lg: 0 8px 32px rgba(192, 132, 252, 0.12);
  --shadow-glow: 0 4px 14px rgba(255, 107, 157, 0.35);

  /* Easing */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);

  /* Layout */
  --toolbar-h: 56px;
  --palette-w: 210px;
  --legend-w: 272px;
}

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

html, body {
  height: 100%;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text);
  background: var(--bg-base);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Ambient Background Blobs ──────────────────────────────── */

.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.07;
}

.blob-1 {
  width: 500px; height: 500px;
  background: var(--primary);
  top: -100px; left: -100px;
  animation: blob-drift-1 40s ease-in-out infinite;
}

.blob-2 {
  width: 400px; height: 400px;
  background: var(--secondary);
  bottom: -80px; right: -80px;
  animation: blob-drift-2 35s ease-in-out infinite;
}

.blob-3 {
  width: 350px; height: 350px;
  background: #BFBFFF;
  top: 40%; left: 50%;
  animation: blob-drift-3 45s ease-in-out infinite;
}

/* ── Toolbar ───────────────────────────────────────────────── */

#toolbar {
  position: relative;
  z-index: 100;
  height: var(--toolbar-h);
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid rgba(232, 218, 239, 0.6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  gap: 12px;
}

.toolbar-left, .toolbar-center, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-mint);
  margin-left: 2px;
  animation: pulseGlow 2s ease-in-out infinite;
}

.tool-btn {
  height: 36px;
  min-width: 36px;
  padding: 0 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s var(--ease-out);
}

.tool-btn:hover {
  background: rgba(192, 132, 252, 0.1);
  color: var(--text);
  transform: scale(1.03);
}

.tool-btn:active {
  transform: scale(0.97);
}

.tool-btn.active {
  background: rgba(255, 107, 157, 0.12);
  color: var(--primary);
}

.tool-btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}

.pill-btn {
  background: rgba(192, 132, 252, 0.08);
  border-radius: var(--radius-full);
  padding: 0 14px;
}

.pill-btn:hover {
  background: rgba(192, 132, 252, 0.18);
}

.btn-label {
  font-size: 12px;
}

.separator {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
  opacity: 0.6;
}

/* ── App Layout ────────────────────────────────────────────── */

#app {
  position: relative;
  z-index: 1;
  display: flex;
  height: calc(100% - var(--toolbar-h));
}

/* ── Palette (Left) ────────────────────────────────────────── */

#palette {
  width: var(--palette-w);
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  border-right: 1px solid rgba(232, 218, 239, 0.5);
  overflow-y: auto;
  padding: 16px 12px;
  flex-shrink: 0;
}

.palette-section {
  margin-bottom: 20px;
  animation: fadeInUp 0.35s var(--ease-out) both;
}

.palette-section:nth-child(2) { animation-delay: 50ms; }

.palette-section-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding: 0 8px;
  text-transform: uppercase;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  user-select: none;
}

.palette-item:hover {
  background: rgba(192, 132, 252, 0.08);
  transform: translateX(3px);
}

.palette-item:active {
  transform: scale(0.97);
  background: rgba(255, 107, 157, 0.12);
}

.palette-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.25s var(--ease-bounce);
}

.palette-item:hover .palette-icon {
  transform: scale(1.08);
}

.palette-icon svg {
  width: 20px;
  height: 20px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.palette-label {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.palette-dims {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* ── Viewport ──────────────────────────────────────────────── */

#viewport {
  flex: 1;
  position: relative;
  background: transparent;
  overflow: hidden;
}

#viewport canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.viewport-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 18px;
  background: rgba(45, 38, 64, 0.65);
  backdrop-filter: blur(12px);
  color: white;
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s var(--ease-out);
  letter-spacing: 0.01em;
}

.viewport-hint.visible { opacity: 1; }

/* ── Legend (Right) ────────────────────────────────────────── */

#legend {
  width: var(--legend-w);
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  border-left: 1px solid rgba(232, 218, 239, 0.5);
  overflow-y: auto;
  padding: 16px;
  flex-shrink: 0;
}

.legend-section {
  margin-bottom: 20px;
  animation: fadeInUp 0.35s var(--ease-out) both;
}

.legend-section:nth-child(2) { animation-delay: 60ms; }
.legend-section:nth-child(3) { animation-delay: 120ms; }

.legend-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-transform: uppercase;
}

/* ── Units Toggle ──────────────────────────────────────────── */

.units-toggle {
  display: flex;
  background: var(--bg-cloud);
  border-radius: var(--radius-full);
  padding: 3px;
  margin-bottom: 16px;
}

.units-toggle button {
  flex: 1;
  padding: 7px 14px;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.25s var(--ease-bounce);
}

.units-toggle button.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.units-toggle button:not(.active):hover {
  color: var(--text-secondary);
}

/* ── Stats Grid ────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 12px;
  border: 1px solid rgba(232, 218, 239, 0.5);
  box-shadow: var(--shadow-sm);
  transition: all 0.25s var(--ease-out);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(192, 132, 252, 0.3);
}

.stat-label {
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.stat-unit {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

/* ── Properties Panel ──────────────────────────────────────── */

.prop-group {
  margin-bottom: 16px;
}

.prop-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.prop-label {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  width: 64px;
  flex-shrink: 0;
}

.prop-input {
  flex: 1;
  height: 34px;
  padding: 0 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  background: var(--bg-input);
  outline: none;
  transition: all 0.2s var(--ease-out);
}

.prop-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(192, 132, 252, 0.15);
  background: var(--bg-card);
}

.prop-input:hover:not(:focus) {
  border-color: var(--text-muted);
}

.prop-input::-webkit-inner-spin-button { opacity: 0; }
.prop-input:hover::-webkit-inner-spin-button { opacity: 1; }

/* ── Link Badge ────────────────────────────────────────────── */

.link-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: linear-gradient(135deg, rgba(255, 107, 157, 0.1), rgba(192, 132, 252, 0.1));
  color: var(--accent-violet);
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid rgba(192, 132, 252, 0.2);
}

/* ── Element Count ─────────────────────────────────────────── */

.element-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
}

/* ── Empty State ───────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-muted);
}

.empty-state-icon {
  margin-bottom: 10px;
  opacity: 0.5;
}

.empty-state-icon svg {
  stroke: var(--secondary);
}

.empty-state-text {
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ── Template Modal ────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(45, 38, 64, 0.4);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeInUp 0.3s var(--ease-out);
}

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 520px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(45, 38, 64, 0.2), 0 8px 32px rgba(192, 132, 252, 0.1);
  border: 1px solid rgba(232, 218, 239, 0.6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-cloud);
  border-radius: 50%;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease-out);
}

.modal-close:hover {
  background: rgba(255, 107, 157, 0.12);
  color: var(--primary);
  transform: scale(1.1);
}

.modal-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.template-card {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  cursor: pointer;
  transition: all 0.25s var(--ease-out);
  text-align: center;
}

.template-card:hover {
  border-color: var(--secondary);
  background: var(--bg-card);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.template-card:active {
  transform: scale(0.97);
}

.template-icon {
  font-size: 32px;
  margin-bottom: 8px;
  display: block;
}

.template-name {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.template-desc {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── Scrollbar ─────────────────────────────────────────────── */

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Selection / focus ring utility ────────────────────────── */

*:focus-visible {
  outline: 2px solid var(--secondary);
  outline-offset: 2px;
}
