/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-start: #0f0c29;
  --bg-mid:   #302b63;
  --bg-end:   #24243e;
  --panel-bg: rgba(255,255,255,0.07);
  --panel-border: rgba(255,255,255,0.15);
  --text-primary: #f0f0f0;
  --text-muted: #a0a0b8;
  --accent: #7c6bff;
  --accent-hover: #9a8dff;
  --slider-track: rgba(255,255,255,0.15);
  --slider-thumb: #7c6bff;
  --code-bg: rgba(0,0,0,0.35);
  --radius-panel: 20px;
  --radius-card: 16px;
  --transition: 0.18s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, var(--bg-start), var(--bg-mid), var(--bg-end));
  min-height: 100vh;
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

/* ── Site Nav ─────────────────────────────────────────────── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 12, 41, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--accent);
}

.nav-links { display: flex; gap: 6px; }

.nav-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid transparent;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.nav-link:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.07);
}

.nav-link.active {
  color: var(--text-primary);
  background: rgba(124,107,255,0.2);
  border-color: rgba(124,107,255,0.4);
}

/* ── Hero ─────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 64px 24px 44px;
}

.hero-title {
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 30%, #b8adff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 14px;
}

.hero-sub {
  color: var(--text-primary);
  font-size: 1.1rem;
  max-width: 540px;
  margin: 0 auto 8px;
}

.hero-hint {
  color: var(--text-muted);
  font-size: 0.92rem;
  max-width: 480px;
  margin: 0 auto 28px;
}

.hero-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  padding: 12px 28px;
  border-radius: 99px;
  font-size: 0.9rem;
  font-weight: 700;
  transition: background var(--transition), transform var(--transition);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--text-primary);
  text-decoration: none;
  padding: 12px 28px;
  border-radius: 99px;
  font-size: 0.9rem;
  font-weight: 700;
  transition: background var(--transition), transform var(--transition);
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.14);
  transform: translateY(-1px);
}

/* ── Glass Panel ──────────────────────────────────────────── */
.glass-panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 28px;
}

/* ── Panel Title ──────────────────────────────────────────── */
.panel-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}

/* ── Controls Stack ───────────────────────────────────────── */
.controls-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 500;
}

.control-label span:first-child { color: var(--text-primary); }

.control-value {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 42px;
  text-align: right;
}

.control-value small {
  font-size: 0.7em;
  font-weight: 400;
  color: var(--text-muted);
}

/* ── Sliders ──────────────────────────────────────────────── */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 99px;
  background: var(--slider-track);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--slider-thumb);
  box-shadow: 0 0 0 3px rgba(124,107,255,0.3);
  transition: transform var(--transition), box-shadow var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 0 5px rgba(124,107,255,0.4);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: var(--slider-thumb);
  box-shadow: 0 0 0 3px rgba(124,107,255,0.3);
  cursor: pointer;
}

/* ── Toggle Switch ────────────────────────────────────────── */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 99px;
  transition: background var(--transition), border-color var(--transition);
}

.toggle-thumb {
  position: absolute;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: left var(--transition);
}

.toggle input:checked + .toggle-track {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle input:checked + .toggle-track .toggle-thumb {
  left: calc(100% - 19px);
}

/* ── Copy Button ──────────────────────────────────────────── */
.copy-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 9px 18px;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  letter-spacing: 0.3px;
}

.copy-btn:hover { background: var(--accent-hover); transform: translateY(-1px); }
.copy-btn:active { transform: translateY(0); }
.copy-btn.copied { background: #22c55e; }
.copy-btn svg { flex-shrink: 0; }

/* ── Output Header ────────────────────────────────────────── */
.output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 99px; }

/* ── Footer ───────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.8rem;
  opacity: 0.6;
}

/* ═══════════════════════════════════════════════════════════
   CLIP PATH SPECIFIC STYLES
   ═══════════════════════════════════════════════════════════ */

/* ── 3-Panel App Shell ────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: 270px 1fr 270px;
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 60px;
}

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 270px 1fr; }
  .output-col { grid-column: 1 / -1; }
}

@media (max-width: 700px) {
  .app-shell { grid-template-columns: 1fr; }
}

/* ── Controls Column ──────────────────────────────────────── */
.controls-col {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Shape Type Selector ──────────────────────────────────── */
.shape-types {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.shape-type-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 8px 10px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  font-family: inherit;
}

.shape-type-btn:hover {
  background: rgba(124,107,255,0.15);
  border-color: rgba(124,107,255,0.4);
  color: var(--text-primary);
}

.shape-type-btn.active {
  background: rgba(124,107,255,0.35);
  border-color: var(--accent);
  color: var(--text-primary);
}

/* ── Polygon Action Buttons ───────────────────────────────── */
.poly-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 4px;
}

.ctrl-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 7px 8px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  font-family: inherit;
  text-align: center;
}

.ctrl-btn:hover {
  background: rgba(124,107,255,0.2);
  border-color: rgba(124,107,255,0.4);
  color: var(--text-primary);
}

.ctrl-btn:active {
  background: rgba(124,107,255,0.35);
}

/* ── Snap Row ─────────────────────────────────────────────── */
.snap-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 4px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ── Points List ──────────────────────────────────────────── */
.points-list {
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.point-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.06);
  font-size: 0.74rem;
  font-family: monospace;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.point-item:hover { background: rgba(124,107,255,0.15); }
.point-item.selected { background: rgba(124,107,255,0.25); border-color: var(--accent); }

.point-idx {
  font-size: 0.62rem;
  color: var(--accent);
  font-weight: 700;
  min-width: 18px;
}

.point-coords { color: var(--text-primary); }

/* ── Controls stack spacing within shape panels ───────────── */
#controls-polygon,
#controls-circle,
#controls-ellipse,
#controls-inset {
  margin-top: 18px;
}

/* ── Editor Column ────────────────────────────────────────── */
.editor-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* ── Preview Tabs ─────────────────────────────────────────── */
.preview-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tab-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 7px 16px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  font-family: inherit;
}

.tab-btn:hover {
  background: rgba(124,107,255,0.15);
  border-color: rgba(124,107,255,0.35);
  color: var(--text-primary);
}

.tab-btn.active {
  background: rgba(124,107,255,0.28);
  border-color: var(--accent);
  color: var(--text-primary);
}

/* ── Editor Canvas (square) ───────────────────────────────── */
.editor-canvas {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 16px;
  cursor: crosshair;
  user-select: none;
  overflow: hidden;
}

/* ── Clip Preview Element ─────────────────────────────────── */
.clip-preview {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  transition: clip-path 0.15s ease;
}

.clip-preview.gradient-mode {
  background: linear-gradient(135deg, #7c6bff 0%, #f093fb 50%, #4facfe 100%);
}

.clip-preview.image-mode {
  background-image:
    radial-gradient(circle at 25% 60%, rgba(124,107,255,0.7) 0%, transparent 45%),
    radial-gradient(circle at 75% 30%, rgba(240,147,251,0.6) 0%, transparent 40%),
    radial-gradient(circle at 50% 90%, rgba(79,172,254,0.5) 0%, transparent 40%),
    linear-gradient(160deg, #1a1a2e, #302b63);
}

.clip-preview.card-mode {
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.clip-card-content {
  text-align: center;
  padding: 20px;
  color: #1a1a2e;
}

.cpc-tag {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #7c6bff;
  margin-bottom: 8px;
}

.cpc-title {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: #1a1a2e;
}

.cpc-body {
  font-size: 0.82rem;
  color: #666;
}

/* ── SVG Overlay ──────────────────────────────────────────── */
.editor-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

#svg-path {
  fill: rgba(124,107,255,0.12);
  stroke: #7c6bff;
  stroke-width: 0.5;
  stroke-dasharray: 2 1;
  vector-effect: non-scaling-stroke;
}

#svg-circle,
#svg-ellipse {
  fill: rgba(124,107,255,0.12);
  stroke: #7c6bff;
  stroke-width: 0.5;
  stroke-dasharray: 2 1;
  vector-effect: non-scaling-stroke;
}

#svg-rect {
  fill: none;
  stroke: #7c6bff;
  stroke-width: 0.5;
  stroke-dasharray: 2 1;
  vector-effect: non-scaling-stroke;
}

/* ── Point Handles ────────────────────────────────────────── */
#points-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.point-handle {
  position: absolute;
  width: 13px;
  height: 13px;
  background: #fff;
  border: 2.5px solid #7c6bff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  cursor: grab;
  z-index: 20;
  transition: transform 0.1s, background 0.1s;
  touch-action: none;
  pointer-events: all;
}

.point-handle:hover {
  transform: translate(-50%, -50%) scale(1.35);
  background: #b8adff;
}

.point-handle.dragging {
  cursor: grabbing;
  background: #7c6bff;
  transform: translate(-50%, -50%) scale(1.3);
}

.point-handle.selected {
  background: #7c6bff;
  border-color: #fff;
}

.point-handle.center-handle {
  background: rgba(124,107,255,0.6);
  border-color: #fff;
  width: 15px;
  height: 15px;
}

.point-handle.radius-handle {
  border-color: #f093fb;
  border-style: dashed;
}

/* ── Editor Hint ──────────────────────────────────────────── */
.editor-hint {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.editor-hint strong { color: var(--text-primary); }

/* ── Output Column ────────────────────────────────────────── */
.output-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

pre#clip-css-output {
  background: var(--code-bg);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 18px 20px;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.78rem;
  line-height: 1.75;
  color: #c9d1d9;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Syntax highlight tokens */
.tok-prop  { color: #79c0ff; }
.tok-num   { color: #d2a8ff; }
.tok-unit  { color: #7ee787; }
.tok-paren { color: #ffa657; }

/* ── Compat List ──────────────────────────────────────────── */
.compat-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0;
}

.compat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.compat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.compat-dot.green { background: #22c55e; }

.webkit-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 10px;
  padding: 8px 10px;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  line-height: 1.5;
}

.webkit-note code {
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
  color: #b8adff;
}

/* ── Presets Section (white bg) ───────────────────────────── */
.presets-section {
  background: #ffffff;
  padding: 60px 0 80px;
  width: 100%;
  overflow-x: hidden;
}

.presets-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 40px;
}

.section-header {
  text-align: center;
  margin-bottom: 44px;
}

.section-title {
  font-size: clamp(1.4rem, 4vw, 2.1rem);
  font-weight: 800;
  color: #1a1a2e;
  margin-bottom: 10px;
}

.section-sub {
  color: #666;
  font-size: 0.95rem;
}

.presets-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  padding: 16px 4px;
}

.preset-card {
  flex: 0 0 calc((100% - 80px) / 5);
  min-width: 0;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  border: 2px solid transparent;
}

.preset-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.14);
}

.preset-card.active {
  border-color: #7c6bff;
  box-shadow: 0 4px 16px rgba(124,107,255,0.3);
}

.preset-preview {
  width: 100%;
  aspect-ratio: 1;
  background: linear-gradient(135deg, #7c6bff 0%, #f093fb 50%, #4facfe 100%);
}

.preset-name {
  font-size: 0.72rem;
  font-weight: 700;
  color: #1a1a2e;
  text-align: center;
  padding: 8px 6px;
}

@media (max-width: 900px) {
  .preset-card { flex: 0 0 calc((100% - 60px) / 4); }
}

@media (max-width: 650px) {
  .preset-card { flex: 0 0 calc((100% - 40px) / 3); }
}

@media (max-width: 420px) {
  .preset-card { flex: 0 0 calc((100% - 20px) / 2); }
}
