/* ==========================================================================
   main.css — Core design system for LaunchKit (light doodle theme)
   Inter + Caveat fonts, CSS custom properties, base reset, layout, buttons,
   form elements, doodle utilities, SVG decorations, shared components.
   ========================================================================== */

/* --- Global hidden override --- */
[hidden] {
  display: none !important;
}

/* --- Custom Properties --- */
:root {
  --bg: #fafafa;
  --bg-card: #ffffff;
  --bg-input: #fafafa;
  --bg-muted: #f5f5f5;
  --accent: #635bff;
  --accent-soft: rgba(99,91,255,0.08);
  --accent-border: rgba(99,91,255,0.2);
  --accent-hover: #5046e5;
  --text: #3f3f46;
  --text-strong: #09090b;
  --text-muted: #71717a;
  --text-dim: #a1a1aa;
  --border: #d4d4d8;
  --border-dashed: #b4b4bc;
  --green: #16a34a;
  --green-soft: rgba(22,163,74,0.08);
  --green-border: rgba(22,163,74,0.2);
  --orange: #ea580c;
  --orange-soft: rgba(234,88,12,0.08);
  --purple: #7c3aed;
  --purple-soft: rgba(124,58,237,0.06);
  --red: #ef4444;
  --red-soft: rgba(239,68,68,0.06);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-pill: 20px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-doodle: 'Caveat', cursive;
  --transition: 0.15s ease;
}

/* --- Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-hover);
}

ul, ol {
  padding-left: 1.5rem;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-strong);
  line-height: 1.3;
}

h1 { font-size: 2.25rem; font-weight: 800; }
h2 { font-size: 1.5rem; font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 600; }

/* --- Layout --- */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* --- Navigation --- */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 720px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px dashed var(--border-dashed);
  position: relative;
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text-strong);
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.logo span { color: var(--accent); }

.logo-upvote path {
  transition: opacity 0.3s ease;
}
.logo:hover .logo-upvote path {
  opacity: 0.85;
}

.logo:hover {
  color: var(--text-strong);
}

.nav-link {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  transition: color var(--transition);
}

.nav-link:hover {
  color: var(--text);
}

/* --- Doodle Utilities --- */
.doodle-img {
  mix-blend-mode: multiply;
  pointer-events: none;
  user-select: none;
}

.doodle-note {
  font-family: var(--font-doodle);
  color: var(--text-muted);
  pointer-events: none;
  user-select: none;
}

@keyframes doodle-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-4px) rotate(2deg); }
}

@keyframes doodle-float-alt {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-3px) rotate(-2deg); }
}

.doodle-float { animation: doodle-float 4s ease-in-out infinite; }
.doodle-float-alt { animation: doodle-float-alt 5s ease-in-out infinite; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* --- SVG Wavy Underline --- */
.wavy-underline {
  position: relative;
  display: inline;
}

.wavy-underline::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -6px;
  height: 8px;
  background: url("data:image/svg+xml,%3Csvg width='100' height='8' viewBox='0 0 100 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 4C10 0 15 8 25 4C35 0 40 8 50 4C60 0 65 8 75 4C85 0 90 8 100 4' stroke='%23635bff' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") repeat-x;
  background-size: 50px 8px;
}

/* --- SVG Squiggly Divider --- */
.squiggly-divider {
  display: block;
  width: 100%;
  height: 12px;
  margin: 2rem 0;
  background: url("data:image/svg+xml,%3Csvg width='200' height='12' viewBox='0 0 200 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 6Q10 0 20 6T40 6T60 6T80 6T100 6T120 6T140 6T160 6T180 6T200 6' stroke='%23b4b4bc' stroke-width='1' stroke-linecap='round'/%3E%3C/svg%3E") repeat-x center;
  background-size: 100px 12px;
  border: none;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--text-strong);
  color: #fff;
  border-color: var(--text-strong);
}

.btn-primary:hover:not(:disabled) {
  background: #27272a;
}

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-sm {
  font-size: 0.78rem;
  padding: 0.35rem 0.8rem;
}

.btn-xl {
  font-size: 1rem;
  padding: 0.7rem 1.5rem;
  font-weight: 700;
}

.btn-block {
  display: flex;
  width: 100%;
  justify-content: center;
}

/* Sketchy button style */
.btn-sketchy {
  position: relative;
  background: var(--text-strong);
  color: #fff;
  border: none;
  padding: 0.7rem 1.5rem;
  border-radius: 2px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  font-family: var(--font);
  transition: transform 0.15s;
  box-shadow: 3px 3px 0 0 var(--border);
}

.btn-sketchy:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 0 var(--border); }
.btn-sketchy:active { transform: translate(1px, 1px); box-shadow: 2px 2px 0 0 var(--border); }

/* Rocket rumble + smoke on hover for the generate button */
@keyframes rocket-rumble {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-0.5px, -0.8px); }
  50% { transform: translate(0.5px, -0.3px); }
  75% { transform: translate(-0.3px, -0.6px); }
}

@keyframes smoke-rise {
  0% {
    opacity: 0.5;
    transform: translateX(var(--sx)) translateY(0) scale(0.4);
  }
  50% {
    opacity: 0.3;
  }
  100% {
    opacity: 0;
    transform: translateX(calc(var(--sx) + var(--dx))) translateY(-38px) scale(1.2);
  }
}

.form-submit {
  overflow: visible;
}

.form-submit:hover {
  animation: rocket-rumble 0.3s ease-in-out infinite;
  box-shadow: 4px 4px 0 0 var(--border);
}
.form-submit:active {
  animation: none;
}

/* Smoke particles — only visible on hover */
.form-submit::before,
.form-submit::after,
.form-submit-wrap::before,
.form-submit-wrap::after {
  content: '';
  position: absolute;
  bottom: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-dashed);
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

.form-submit::before { --sx: -30px; --dx: -12px; left: 50%; }
.form-submit::after { --sx: 10px; --dx: 16px; left: 50%; }
.form-submit-wrap::before { --sx: -55px; --dx: -8px; left: 50%; width: 8px; height: 8px; }
.form-submit-wrap::after { --sx: 35px; --dx: 10px; left: 50%; width: 7px; height: 7px; }

.form-submit:hover::before,
.form-submit:hover::after {
  animation: smoke-rise 1.2s ease-out infinite;
}
.form-submit:hover .form-submit-wrap::before {
  animation: smoke-rise 1.4s ease-out 0.3s infinite;
}
.form-submit:hover .form-submit-wrap::after {
  animation: smoke-rise 1.1s ease-out 0.6s infinite;
}

.form-submit:active::before,
.form-submit:active::after,
.form-submit:active .form-submit-wrap::before,
.form-submit:active .form-submit-wrap::after {
  animation: none;
  opacity: 0;
}

/* --- Form Elements --- */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.form-input,
.form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-strong);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  font-family: var(--font);
  font-size: 0.88rem;
  outline: none;
  transition: all 0.15s;
}

.form-input:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-dim);
}

.form-input-lg {
  padding: 0.75rem 0.85rem;
  font-size: 0.92rem;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-textarea-lg {
  padding: 0.75rem 0.85rem;
  font-size: 0.92rem;
  min-height: 100px;
}

.form-error {
  color: var(--red);
  font-size: 0.82rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--red-soft);
  border-radius: var(--radius-sm);
}

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

/* --- Badges / Pills --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.68rem;
  font-weight: 600;
}

.badge-green {
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid var(--green-border);
}

.badge-muted {
  color: var(--text-muted);
  background: rgba(113,113,122,0.08);
  border: 1px solid var(--border);
}

.badge-accent {
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
}

/* --- Progress Bar --- */
.progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
  position: relative;
}

.progress::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 12px;
  background: url("data:image/svg+xml,%3Csvg width='200' height='12' viewBox='0 0 200 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 6Q10 0 20 6T40 6T60 6T80 6T100 6T120 6T140 6T160 6T180 6T200 6' stroke='%23b4b4bc' stroke-width='1' stroke-linecap='round'/%3E%3C/svg%3E") repeat-x center;
  background-size: 100px 12px;
}

.progress-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.progress-bar-track {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.progress-doodle-note {
  font-family: var(--font-doodle);
  font-size: 0.96rem;
  color: var(--green);
  opacity: 0.7;
  white-space: nowrap;
}

/* --- Loading Spinner --- */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner[hidden] {
  display: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Loading State --- */
.loading-state {
  display: flex;
  justify-content: center;
  padding: 3rem 1rem 4rem;
}

.loading-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem 2rem;
  max-width: 440px;
  width: 100%;
  text-align: center;
  position: relative;
  overflow: visible;
}

.loading-hero-doodle {
  position: absolute;
  top: -32px;
  right: -28px;
  width: 72px;
  height: 72px;
  opacity: 0.6;
}

.loading-sparkle-doodle {
  position: absolute;
  top: -18px;
  left: -22px;
  width: 52px;
  height: 52px;
  opacity: 0.5;
}

.loading-spinner-lg {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1.25rem;
}

.loading-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-strong);
  margin-bottom: 0.25rem;
}

.loading-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

.loading-steps {
  display: flex;
  flex-direction: column;
  gap: 0;
  text-align: left;
}

.loading-step {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  transition: background 0.3s ease, color 0.3s ease;
  color: var(--text-dim);
  position: relative;
}

.loading-step-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-muted);
  flex-shrink: 0;
  transition: background 0.3s, color 0.3s;
  color: var(--text-dim);
}

.loading-step-text {
  font-size: 0.84rem;
  font-weight: 500;
  flex: 1;
}

.loading-step-check {
  opacity: 0;
  color: var(--green);
  transition: opacity 0.3s;
  flex-shrink: 0;
}

/* Active step: currently processing */
.loading-step.active {
  color: var(--text-strong);
  background: var(--accent-soft);
}

.loading-step.active .loading-step-icon {
  background: var(--accent);
  color: #fff;
}

.loading-step.active .loading-step-text {
  font-weight: 600;
}

/* Completed step: already done */
.loading-step.done {
  color: var(--text);
}

.loading-step.done .loading-step-icon {
  background: rgba(34, 197, 94, 0.1);
  color: var(--green);
}

.loading-step.done .loading-step-check {
  opacity: 1;
}

/* Progress bar under the steps */
.loading-progress-bar {
  margin-top: 1.25rem;
  height: 4px;
  background: var(--bg-muted);
  border-radius: 2px;
  overflow: hidden;
}

.loading-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.6s ease;
}

/* Handwritten note at bottom */
.loading-doodle-note {
  margin-top: 1.25rem;
  font-family: var(--font-doodle);
  font-size: 1rem;
  color: var(--accent);
  opacity: 0.7;
  transform: rotate(-1.5deg);
}

@media (max-width: 480px) {
  .loading-card {
    padding: 2rem 1.25rem 1.5rem;
  }
  .loading-hero-doodle,
  .loading-sparkle-doodle {
    display: none;
  }
}

/* --- Error State --- */
.error-state {
  text-align: center;
  padding: 4rem 1rem;
}

.error-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: var(--red-soft);
  color: var(--red);
  border-radius: 50%;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.error-title {
  color: var(--text-strong);
  margin-bottom: 0.5rem;
}

.error-desc {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* --- Plan Container --- */
.plan-container {
  padding-top: 2rem;
  padding-bottom: 6rem;
}

/* --- Step Connector (between subreddit cards) --- */
.step-connector {
  display: flex;
  justify-content: center;
  padding: 0.15rem 0;
}

.step-line {
  width: 2px;
  height: 28px;
  background: var(--border-dashed);
  border-radius: 1px;
  position: relative;
}

.step-line::before,
.step-line::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-dashed);
}

.step-line::before {
  top: -3px;
}

.step-line::after {
  bottom: -3px;
}

/* --- Utility Classes --- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

.gap-xs { gap: 0.25rem; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 0.75rem; }
.gap-lg { gap: 1rem; }
.gap-xl { gap: 1.5rem; }

.mt-xs { margin-top: 0.25rem; }
.mt-sm { margin-top: 0.5rem; }
.mt-md { margin-top: 1rem; }
.mt-lg { margin-top: 1.5rem; }
.mt-xl { margin-top: 2rem; }

.mb-xs { margin-bottom: 0.25rem; }
.mb-sm { margin-bottom: 0.5rem; }
.mb-md { margin-bottom: 1rem; }
.mb-lg { margin-bottom: 1.5rem; }
.mb-xl { margin-bottom: 2rem; }

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.8rem; }

.hidden { display: none !important; }

/* --- Responsive --- */
@media (max-width: 768px) {
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.25rem; }

  .container {
    padding: 0 1rem;
  }

  .btn-xl {
    font-size: 0.95rem;
    padding: 0.65rem 1.25rem;
  }
}

@media (max-width: 480px) {
  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.1rem; }

  .navbar {
    padding: 0.75rem 1rem;
  }

  .progress {
    padding-bottom: 1rem;
    margin-bottom: 1rem;
  }
}
