@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&display=swap');

/* ─── THEME VARIABLES ─────────────────────────────────────── */
:root,
[data-theme="light"] {
  --bg:           #f0ecff;
  --bg-2:         #e8e2ff;
  --surface:      #ffffff;
  --surface-2:    #f7f5ff;
  --border:       rgba(124, 58, 237, 0.15);
  --primary:      #7c3aed;
  --primary-dark: #5b21b6;
  --primary-glow: rgba(124, 58, 237, 0.18);
  --gold:         #d97706;
  --gold-light:   #fbbf24;
  --text:         #1e1b4b;
  --text-2:       #4c1d95;
  --text-muted:   #7c6fa0;
  --shadow:       0 4px 24px rgba(124, 58, 237, 0.10);
  --shadow-hover: 0 12px 40px rgba(124, 58, 237, 0.22);
  --star-opacity: 0.08;
  --toggle-track: #ddd6fe;
}

[data-theme="dark"] {
  --bg:           #080612;
  --bg-2:         #0f0a1e;
  --surface:      #1a1035;
  --surface-2:    #120d28;
  --border:       rgba(167, 139, 250, 0.15);
  --primary:      #a78bfa;
  --primary-dark: #7c3aed;
  --primary-glow: rgba(167, 139, 250, 0.20);
  --gold:         #fbbf24;
  --gold-light:   #fde68a;
  --text:         #ede9fe;
  --text-2:       #c4b5fd;
  --text-muted:   #7c6fa0;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
  --shadow-hover: 0 12px 40px rgba(167, 139, 250, 0.25);
  --star-opacity: 1;
  --toggle-track: #2e1f5e;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background-color 0.4s ease, color 0.4s ease;
  overflow-x: hidden;
}

/* ─── STAR FIELD ──────────────────────────────────────────── */
.stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: var(--star-opacity);
  transition: opacity 0.4s ease;
}

.star {
  position: absolute;
  border-radius: 50%;
  background: white;
  animation: twinkle var(--duration, 3s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

@keyframes twinkle {
  0%, 100% { opacity: 0.2; transform: scale(1); }
  50%       { opacity: 1;   transform: scale(1.4); }
}

/* ─── LAYOUT ──────────────────────────────────────────────── */
.site-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── HEADER ──────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 2.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background 0.4s, border-color 0.4s;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: inherit;
}

.logo-icon {
  font-size: 1.6rem;
  line-height: 1;
  filter: drop-shadow(0 0 8px var(--primary-glow));
}

.logo-text {
  font-family: 'Cinzel', serif;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.logo-text span {
  color: var(--gold);
}

/* ─── THEME TOGGLE ────────────────────────────────────────── */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
}

.theme-toggle .icon { font-size: 1rem; }

.toggle-track {
  width: 44px;
  height: 24px;
  background: var(--toggle-track);
  border-radius: 999px;
  position: relative;
  transition: background 0.3s;
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

[data-theme="dark"] .toggle-thumb {
  transform: translateX(20px);
  background: var(--gold);
}

/* ─── HERO ────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 4rem 2rem 2.5rem;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--primary-glow);
  color: var(--primary);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 1.2rem;
}

.hero h1 {
  font-family: 'Cinzel', serif;
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin-bottom: 0.75rem;
}

.hero h1 .accent { color: var(--gold); }

.hero p {
  font-size: 1.05rem;
  color: var(--text-muted);
  font-weight: 300;
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ─── TOOL GRID ───────────────────────────────────────────── */
.tools-section {
  padding: 2rem 2.5rem 4rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.section-label {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.2rem;
}

/* ─── TOOL CARD ───────────────────────────────────────────── */
.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.8rem 1.4rem 1.5rem;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  text-align: center;
  transition:
    transform      0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow     0.25s ease,
    border-color   0.25s ease,
    background     0.4s ease;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.tool-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, var(--primary-glow), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.tool-card:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: var(--shadow-hover);
  border-color: var(--primary);
}

.tool-card:hover::before { opacity: 1; }

.card-icon-wrap {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  background: var(--primary-glow);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s;
  position: relative;
  z-index: 1;
}

.tool-card:hover .card-icon-wrap {
  transform: scale(1.12) rotate(-4deg);
  background: var(--primary);
}

.card-label {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  position: relative;
  z-index: 1;
}

.card-title {
  font-family: 'Cinzel', serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
  line-height: 1.3;
  position: relative;
  z-index: 1;
}

.card-arrow {
  font-size: 0.8rem;
  color: var(--primary);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.2s, transform 0.2s;
  position: relative;
  z-index: 1;
}

.tool-card:hover .card-arrow {
  opacity: 1;
  transform: translateX(0);
}

/* ─── SPARKLE ANIMATION ON CARDS ─────────────────────────── */
.tool-card .sparkle {
  position: absolute;
  pointer-events: none;
  font-size: 0.7rem;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 2;
}

.tool-card:hover .sparkle { animation: sparkle-pop 0.6s ease forwards; }
.sparkle-1 { top: 10px; right: 14px; animation-delay: 0s !important; }
.sparkle-2 { top: 18px; right: 32px; animation-delay: 0.15s !important; }
.sparkle-3 { top: 8px;  right: 26px; animation-delay: 0.3s !important; }

@keyframes sparkle-pop {
  0%   { opacity: 0; transform: scale(0) rotate(0deg); }
  50%  { opacity: 1; transform: scale(1.3) rotate(20deg); }
  100% { opacity: 0; transform: scale(0.8) rotate(40deg) translateY(-8px); }
}

/* ─── FOOTER ──────────────────────────────────────────────── */
footer {
  margin-top: auto;
  text-align: center;
  padding: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ─── TOOL PAGE LAYOUT ────────────────────────────────────── */
.tool-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem 1.5rem 4rem;
}

.back-link {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  margin-bottom: 2.5rem;
  transition: color 0.2s;
  max-width: 1000px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}
.back-link:hover { color: var(--primary); }

.tool-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.tool-header .tool-icon-lg {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  display: block;
  filter: drop-shadow(0 0 12px var(--primary-glow));
}

.tool-header h1 {
  font-family: 'Cinzel', serif;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.tool-header h1 .accent { color: var(--gold); }

.tool-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 300;
}

/* ─── DROP ZONE ───────────────────────────────────────────── */
.drop-zone {
  width: 100%;
  max-width: 560px;
  border: 2px dashed var(--border);
  border-radius: 20px;
  background: var(--surface);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
  box-shadow: var(--shadow);
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--surface-2);
  transform: scale(1.01);
}

.drop-zone-icon {
  font-size: 2.5rem;
  margin-bottom: 0.8rem;
  display: block;
  opacity: 0.5;
}

.drop-zone p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.drop-zone p strong {
  color: var(--text);
  font-weight: 500;
}

.file-limit {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* ─── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1.5rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-success {
  background: #059669;
  color: white;
  box-shadow: 0 4px 14px rgba(5,150,105,0.25);
}
.btn-success:hover {
  background: #047857;
  transform: translateY(-1px);
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--primary-glow); border-color: var(--primary); }

/* ─── STATUS ──────────────────────────────────────────────── */
#status {
  margin-top: 1.2rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  min-height: 1.4em;
  text-align: center;
}
#status.error { color: #ef4444; }
#status.success { color: #10b981; }

/* ─── PROGRESS BAR ────────────────────────────────────────── */
.progress-wrap {
  width: 100%;
  max-width: 560px;
  margin-top: 1rem;
  display: none;
}
.progress-wrap.visible { display: block; }

.progress-bar-bg {
  background: var(--surface-2);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--gold));
  border-radius: 999px;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  text-align: right;
}

/* ─── PAGE RESULTS ────────────────────────────────────────── */
#pages {
  margin-top: 2rem;
  width: 100%;
  max-width: 860px;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.page-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: background 0.4s, border-color 0.4s;
}

.page-card canvas {
  display: block;
  width: 100%;
  height: auto;
}

.page-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1.2rem;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ─── DOWNLOAD ALL BAR ────────────────────────────────────── */
.download-all-bar {
  width: 100%;
  max-width: 860px;
  margin-top: 1rem;
  display: flex;
  justify-content: flex-end;
}

/* ─── RESULT PREVIEW (image tools) ──────────────────────────*/
#result-area {
  margin-top: 2rem;
  width: 100%;
  max-width: 560px;
  display: none;
}
#result-area.visible { display: block; }

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.result-card img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 360px;
  object-fit: contain;
  background: repeating-conic-gradient(#ccc 0% 25%, transparent 0% 50%) 0 0/16px 16px;
}

.result-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1.2rem;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ─── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 640px) {
  header { padding: 1rem 1.2rem; }
  .tools-section { padding: 1.5rem 1rem 3rem; }
  .tool-grid { grid-template-columns: repeat(2, 1fr); gap: 0.8rem; }
  .hero { padding: 2.5rem 1rem 1.5rem; }
  .logo-text { font-size: 1rem; }
}
