/* =====================================================
   AsciiForge — Stylesheet
   ===================================================== */

/* ---------- Theme tokens ---------- */
:root {
  --bg: #F8FAFC;
  --bg-elev: #FFFFFF;
  --bg-soft: #F1F5F9;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --text: #0F172A;
  --text-muted: #475569;
  --text-subtle: #64748B;
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-soft: #EFF6FF;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 20px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.08);
  --shadow-xl: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(226, 232, 240, 0.9);
  --ascii-bg: #020617;
  --ascii-text: #C7D2FE;
  --success: #059669;
}

html.dark {
  --bg: #020617;
  --bg-elev: #0F172A;
  --bg-soft: #0B1220;
  --border: #1E293B;
  --border-strong: #334155;
  --text: #F8FAFC;
  --text-muted: #CBD5E1;
  --text-subtle: #94A3B8;
  --accent: #3B82F6;
  --accent-hover: #60A5FA;
  --accent-soft: #1E3A8A;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  --glass-bg: rgba(15, 23, 42, 0.7);
  --glass-border: rgba(51, 65, 85, 0.6);
  --ascii-bg: #020617;
  --ascii-text: #A5B4FC;
  --success: #10B981;
}

* { -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

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

/* Subtle grid pattern for background depth (no gradients) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
}

html.dark body::before { opacity: 0.2; }

/* ---------- Glass card ---------- */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--glass-border);
}

/* ---------- Navbar ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 40;
  transition: background-color 0.4s ease, border-color 0.4s ease;
}

.nav-icon-btn {
  position: relative;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--text);
  border: 1px solid transparent;
  transition: all 0.25s ease;
}
.nav-icon-btn:hover {
  background: var(--bg-soft);
  border-color: var(--border);
  color: var(--accent);
  transform: translateY(-1px);
}
.nav-icon-btn i { font-size: 18px; }

/* Tooltip */
.tooltip {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
}
.tooltip::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-bottom-color: var(--text);
}
.nav-icon-btn:hover .tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Hero ---------- */
.hero-heading {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
.eyebrow .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

/* ---------- Upload dropzone ---------- */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: 16px;
  background: var(--bg-elev);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
}
.dropzone:hover,
.dropzone.drag {
  border-color: var(--accent);
  background: var(--bg-soft);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.dropzone .icon-wrap {
  width: 64px; height: 64px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  transition: transform 0.3s ease;
}
.dropzone:hover .icon-wrap { transform: scale(1.08) rotate(-4deg); }
.dropzone .icon-wrap i { font-size: 28px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  user-select: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-elev);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-soft);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

/* Ripple */
.btn .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  transform: scale(0);
  animation: ripple 0.6s linear;
  pointer-events: none;
}
.btn-secondary .ripple { background: rgba(37,99,235,0.2); }
@keyframes ripple {
  to { transform: scale(4); opacity: 0; }
}

/* ---------- Preview image ---------- */
.preview-wrap {
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}
.preview-wrap img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 480px;
  object-fit: contain;
  background: var(--bg-soft);
}

/* ---------- ASCII output ---------- */
.ascii-output {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0;
  white-space: pre;
  color: var(--ascii-text);
  background: var(--ascii-bg);
  padding: 1.25rem;
  border-radius: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  min-height: 140px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  tab-size: 4;
}
@media (min-width: 768px) {
  .ascii-output { font-size: 12px; }
}
.ascii-output::-webkit-scrollbar { height: 8px; }
.ascii-output::-webkit-scrollbar-track { background: transparent; }
.ascii-output::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

/* ---------- Reveal animation ---------- */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Spinner ---------- */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--text);
  color: var(--bg);
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast i { color: var(--success); font-size: 18px; }

/* ---------- Footer ---------- */
.footer a {
  width: 38px; height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  transition: all 0.25s ease;
}
.footer a:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.footer a i { font-size: 16px; }

/* ---------- Animations ---------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInFromBottom {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in { animation-fill-mode: both; }
.fade-in { animation: fadeIn 0.7s cubic-bezier(0.16, 1, 0.3, 1); }
.slide-in-from-bottom-2 { animation: slideInFromBottom 0.5s cubic-bezier(0.16, 1, 0.3, 1); }
.slide-in-from-bottom-4 { animation: slideInFromBottom 0.8s cubic-bezier(0.16, 1, 0.3, 1); }
.duration-700 { animation-duration: 0.7s; }
.duration-1000 { animation-duration: 1s; }
.delay-150 { animation-delay: 150ms; }
.delay-300 { animation-delay: 300ms; }

.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

/* Custom range slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 999px;
  outline: none;
  transition: all 0.2s;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: var(--border);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3), 0 1px 3px rgba(0,0,0,0.1);
  cursor: pointer;
  margin-top: -6px;
  transition: all 0.15s ease;
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4), 0 2px 6px rgba(0,0,0,0.15);
}
input[type="range"]::-webkit-slider-thumb:active {
  transform: scale(1.05);
}
input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  border: none;
}
input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
  cursor: pointer;
  transition: all 0.15s ease;
}

/* Hide default file input */
.hidden-input { display: none; }

/* Canvas hidden */
#workCanvas { display: none; }

/* Stat chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
}

/* Controls row */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.control-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}
