/* =========================================================
   CircleCutterPro — style.css
   Design tokens, light/dark themes, layout, components
   ========================================================= */

/* ---------- Tokens ---------- */
:root {
  --primary: #2563EB;
  --accent: #3B82F6;
  --primary-soft: rgba(37, 99, 235, 0.12);

  --bg: #F8FAFC;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #FFFFFF;
  --border: rgba(15, 23, 42, 0.08);
  --text: #0F172A;
  --text-muted: #55637A;

  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 14px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 12px 40px rgba(37, 99, 235, 0.14);

  --radius: 18px;
  --radius-sm: 12px;

  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;

  --checker: repeating-conic-gradient(rgba(15,23,42,.07) 0% 25%, transparent 0% 50%) 0 0 / 18px 18px;
}

html[data-theme="dark"] {
  --bg: #0F172A;
  --surface: rgba(30, 41, 59, 0.62);
  --surface-solid: #1E293B;
  --border: rgba(148, 163, 184, 0.14);
  --text: #F1F5F9;
  --text-muted: #94A3B8;
  --primary-soft: rgba(59, 130, 246, 0.18);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.45);
  --checker: repeating-conic-gradient(rgba(241,245,249,.08) 0% 25%, transparent 0% 50%) 0 0 / 18px 18px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  transition: background-color .35s ease, color .35s ease;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0 0 .5em; }
p { margin: 0 0 1em; }
img, canvas { max-width: 100%; display: block; }
kbd {
  font: 600 .78em var(--font-body);
  padding: .1em .45em;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface-solid);
}

.container { width: min(1120px, 100% - 2.5rem); margin-inline: auto; }
.container--narrow { max-width: 720px; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: 600 .95rem var(--font-body);
  padding: .65rem 1.25rem;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease, color .18s ease;
}
.btn:active { transform: scale(.97); }

.btn--primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 6px 18px rgba(37, 99, 235, .35);
}
.btn--primary:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(37, 99, 235, .45); }

.btn--ghost {
  color: var(--text);
  background: transparent;
  border-color: var(--border);
}
.btn--ghost:hover { background: var(--primary-soft); border-color: var(--accent); color: var(--primary); }

.btn--sm { padding: .4rem .85rem; font-size: .85rem; }
.btn--lg { width: 100%; padding: .85rem 1.5rem; font-size: 1.05rem; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  cursor: pointer;
  transition: background-color .18s ease, color .18s ease, transform .18s ease, border-color .18s ease;
}
.icon-btn:hover:not(:disabled) { background: var(--primary-soft); color: var(--primary); border-color: var(--accent); transform: translateY(-1px); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Cards / glass ---------- */
.card {
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
}

/* ---------- Navbar ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav__inner { display: flex; align-items: center; gap: 1.5rem; padding: .8rem 0; }

.brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--text); }
.brand__mark { color: var(--primary); display: inline-flex; }
.brand__name { font: 700 1.15rem var(--font-display); letter-spacing: -.01em; }
.brand__name em { font-style: normal; color: var(--primary); }
.brand--sm .brand__name { font-size: 1rem; }

.nav__links { margin-left: auto; display: flex; gap: 1.25rem; }
.nav__links a {
  color: var(--text-muted); text-decoration: none; font-weight: 500; font-size: .95rem;
  transition: color .18s ease;
}
.nav__links a:hover { color: var(--primary); }

/* Theme toggle icons */
html[data-theme="light"] .icon-moon { display: none; }
html[data-theme="dark"] .icon-sun { display: none; }

/* ---------- Hero ---------- */
.hero { padding: clamp(3rem, 8vw, 5.5rem) 0 3.5rem; text-align: center; position: relative; overflow: hidden; }
.hero::before, .hero::after {
  content: ""; position: absolute; border-radius: 50%; filter: blur(90px); opacity: .35; pointer-events: none;
  background: var(--accent);
}
.hero::before { width: 380px; height: 380px; top: -140px; left: -120px; }
.hero::after { width: 320px; height: 320px; bottom: -160px; right: -100px; background: var(--primary); }

.hero__inner { position: relative; display: flex; flex-direction: column; align-items: center; }

.eyebrow {
  font: 600 .8rem var(--font-body);
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-soft);
  padding: .35rem .9rem; border-radius: 999px;
  margin-bottom: 1.1rem;
}

.hero h1 { font-size: clamp(2rem, 5.5vw, 3.4rem); letter-spacing: -.02em; max-width: 16ch; }
.grad {
  background: linear-gradient(120deg, var(--primary), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero__sub { color: var(--text-muted); max-width: 46ch; font-size: 1.06rem; margin-bottom: 2.2rem; }

/* ---------- Signature circular drop zone ---------- */
.dropzone {
  position: relative;
  width: min(340px, 78vw); aspect-ratio: 1;
  border-radius: 50%;
  display: grid; place-items: center;
  cursor: pointer;
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  transition: transform .25s ease, box-shadow .25s ease;
  animation: rise .6s ease both;
}
.dropzone:hover { transform: translateY(-4px) scale(1.015); }

.dropzone__ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 2.5px dashed var(--accent);
  animation: spin 40s linear infinite;
  transition: border-color .2s ease;
}
.dropzone.is-over { transform: scale(1.04); }
.dropzone.is-over .dropzone__ring { border-color: var(--primary); border-style: solid; box-shadow: 0 0 0 8px var(--primary-soft); }

.dropzone__content { display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: 2rem; color: var(--text-muted); }
.dropzone__content svg { color: var(--primary); margin-bottom: .4rem; }
.dropzone__content strong { font: 600 1.1rem var(--font-display); color: var(--text); }
.dropzone__content span { font-size: .85rem; }
.dropzone__formats { opacity: .75; font-size: .78rem !important; margin-top: .35rem; }

.upload-error {
  margin-top: 1.1rem;
  color: #DC2626; font-weight: 500; font-size: .92rem;
  background: rgba(220, 38, 38, .08);
  padding: .5rem 1rem; border-radius: var(--radius-sm);
}

/* ---------- Editor ---------- */
.editor { padding: 1rem 0 4rem; animation: rise .5s ease both; }
.editor__grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 920px) { .editor__grid { grid-template-columns: 1.6fr 1fr; align-items: start; } }

.stage__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.stage__head h2, .preview-card h2, .history-card h2 { font-size: 1.15rem; margin: 0; }

.stage__canvas-wrap {
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--checker), var(--surface-solid);
  border: 1px solid var(--border);
}
#editorCanvas { width: 100%; touch-action: none; cursor: grab; }
#editorCanvas.is-dragging { cursor: grabbing; }

.controls { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; margin-top: 1.1rem; align-items: center; }
.controls__group { display: flex; align-items: center; gap: .5rem; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: clamp(110px, 22vw, 190px); height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary) var(--fill, 0%), var(--border) var(--fill, 0%));
  outline-offset: 4px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 3px solid var(--primary);
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  cursor: pointer;
  transition: transform .15s ease;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 3px solid var(--primary);
  cursor: pointer;
}

.hint { color: var(--text-muted); font-size: .82rem; margin: 1rem 0 0; }

/* ---------- Preview panel ---------- */
.side { display: flex; flex-direction: column; gap: 1.5rem; }

.preview__circle-wrap {
  display: grid; place-items: center;
  padding: 1.25rem;
  border-radius: var(--radius-sm);
  background: var(--checker), var(--surface-solid);
  border: 1px solid var(--border);
  margin-bottom: 1.1rem;
}
#previewCanvas {
  width: min(240px, 60vw); height: auto;
  border-radius: 50%;
  box-shadow: var(--shadow-lg);
  animation: pop .35s ease;
}

.img-info {
  display: grid; grid-template-columns: 1fr 1fr; gap: .6rem .9rem;
  margin: 0 0 1.1rem; padding: 0;
}
.img-info div {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .55rem .8rem;
}
.img-info dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); }
.img-info dd { margin: 0; font: 600 .95rem var(--font-display); word-break: break-all; }

.field { display: block; margin-bottom: 1.1rem; }
.field span { display: block; font-size: .82rem; font-weight: 600; color: var(--text-muted); margin-bottom: .35rem; }
.field select {
  width: 100%; padding: .6rem .8rem;
  font: 500 .95rem var(--font-body);
  color: var(--text);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.preview__note { text-align: center; color: var(--text-muted); font-size: .8rem; margin: .8rem 0 0; }

/* ---------- History ---------- */
.history__empty { color: var(--text-muted); font-size: .88rem; margin: 0; }
.history__list { list-style: none; display: flex; flex-wrap: wrap; gap: .75rem; margin: 0; padding: 0; }
.history__list li { animation: pop .3s ease; }
.history__list button {
  border: 2px solid var(--border); background: var(--checker), var(--surface-solid);
  border-radius: 50%; padding: 3px; cursor: pointer;
  transition: border-color .18s ease, transform .18s ease;
}
.history__list button:hover { border-color: var(--accent); transform: scale(1.08); }
.history__list img { width: 56px; height: 56px; border-radius: 50%; }

/* ---------- Features ---------- */
.features { padding: 3.5rem 0; }
.section-title { text-align: center; font-size: clamp(1.5rem, 3.4vw, 2.1rem); margin-bottom: 2.2rem; letter-spacing: -.015em; }
.features__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.25rem; }
.feature { transition: transform .22s ease, box-shadow .22s ease; }
.feature:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.feature__icon { font-size: 1.7rem; margin-bottom: .6rem; }
.feature h3 { font-size: 1.05rem; }
.feature p { color: var(--text-muted); font-size: .92rem; margin: 0; }

/* ---------- FAQ ---------- */
.faq { padding: 1rem 0 4rem; }
.faq__item { padding: 0; margin-bottom: .8rem; overflow: hidden; }
.faq__item summary {
  list-style: none; cursor: pointer;
  padding: 1rem 1.25rem;
  font: 600 .98rem var(--font-display);
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}
.faq__item summary::-webkit-details-marker { display: none; }
.faq__item summary::after {
  content: "+"; font-size: 1.3rem; color: var(--primary);
  transition: transform .25s ease;
}
.faq__item[open] summary::after { transform: rotate(45deg); }
.faq__item p { padding: 0 1.25rem 1.1rem; color: var(--text-muted); font-size: .93rem; margin: 0; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); padding: 2.5rem 0; text-align: center; }
.footer__inner { display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.footer p { color: var(--text-muted); font-size: .9rem; margin: 0; }
.footer__copy { font-size: .82rem !important; opacity: .85; }
.footer__credit { font-size: .82rem !important; }
.footer__credit strong { color: var(--text); font-weight: 600; }
.footer__credit a { color: var(--primary); text-decoration: none; font-weight: 600; }
.footer__credit a:hover { text-decoration: underline; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem;
  transform: translate(-50%, 120%);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; font-weight: 600; font-size: .92rem;
  padding: .75rem 1.4rem; border-radius: 999px;
  box-shadow: 0 10px 30px rgba(37, 99, 235, .4);
  transition: transform .35s cubic-bezier(.2, .9, .3, 1.2);
  z-index: 100; pointer-events: none;
}
.toast.is-visible { transform: translate(-50%, 0); }

/* ---------- Animations ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Small screens ---------- */
@media (max-width: 480px) {
  .nav__links { display: none; }
  .controls { justify-content: center; }
  .card { padding: 1.1rem; }
}
