/* =====================================================
   Explain Geometry — student-friendly UI
   Palette: warm cream + violet/coral accents, generous
   whitespace, rounded geometry. Tuned for HS / undergrad.
   ===================================================== */

:root {
  --bg: #fbf9f4;
  --panel: #ffffff;
  --ink: #0b0a14;
  --ink-soft: #1f1d2e;
  --muted: #6b6478;
  --border: #ebe6dd;
  --border-strong: #d8d2c4;
  --brand: #6d28d9;          /* deep violet */
  --brand-2: #c026d3;         /* fuchsia */
  --brand-soft: #f5f1ff;
  --accent: #f97316;          /* coral */
  --accent-soft: #fff3e8;
  --ok: #059669;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --shadow-sm: 0 1px 2px rgba(15, 12, 30, 0.04), 0 1px 1px rgba(15, 12, 30, 0.03);
  --shadow-md: 0 6px 24px -8px rgba(57, 25, 97, 0.18), 0 2px 6px rgba(15, 12, 30, 0.06);
  --shadow-lg: 0 24px 60px -20px rgba(57, 25, 97, 0.25), 0 8px 16px rgba(15, 12, 30, 0.06);
  --radius: 14px;
  --radius-lg: 22px;
}

* { box-sizing: border-box; }
html, body { padding: 0; margin: 0; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-feature-settings: "cv11", "ss01";
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Soft background blobs for warmth */
.bg-blob {
  position: fixed;
  pointer-events: none;
  z-index: -1;
  filter: blur(80px);
  opacity: 0.6;
  border-radius: 50%;
}
.bg-blob-1 {
  width: 480px; height: 480px;
  top: -120px; right: -160px;
  background: radial-gradient(circle, rgba(192, 38, 211, 0.32), rgba(192, 38, 211, 0) 70%);
}
.bg-blob-2 {
  width: 520px; height: 520px;
  bottom: -200px; left: -160px;
  background: radial-gradient(circle, rgba(249, 115, 22, 0.22), rgba(249, 115, 22, 0) 70%);
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 56px 24px 80px;
}

/* ====== HERO ====== */
.hero { margin-bottom: 32px; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  font-size: 14px;
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: white;
  border-radius: 9px;
  font-weight: 700;
  font-size: 18px;
  box-shadow: var(--shadow-md);
}
.brand-name { font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
.brand-pill {
  background: var(--brand-soft);
  color: var(--brand);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.hero h1 {
  font-family: "Fraunces", "Inter", serif;
  font-weight: 700;
  font-size: clamp(34px, 5.4vw, 56px);
  line-height: 1.06;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
  color: var(--ink);
}
.hero h1 .hi {
  background: linear-gradient(120deg, var(--brand), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-style: italic;
}
.hero .lede {
  font-size: clamp(16px, 1.7vw, 18px);
  color: var(--muted);
  max-width: 700px;
  margin: 0;
}

/* ====== FORM CARD ====== */
.form-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px 32px 26px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

.field-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 10px;
}
.field-num {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px;
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
}
.optional { color: var(--muted); font-weight: 500; margin-left: 4px; }

textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: #fdfcfa;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  resize: vertical;
  transition: border 0.15s, background 0.15s, box-shadow 0.15s;
  min-height: 110px;
}
textarea::placeholder { color: #a8a2b3; }
textarea:focus {
  outline: none;
  border-color: var(--brand);
  background: white;
  box-shadow: 0 0 0 4px var(--brand-soft);
}

/* Example chips */
.examples {
  display: flex; flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}
.examples-label { font-size: 12px; color: var(--muted); margin-right: 4px; }
.chip {
  background: white;
  border: 1px solid var(--border);
  color: var(--ink-soft);
  padding: 7px 14px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
  transform: translateY(-1px);
}

/* Dropzone */
.dropzone {
  position: relative;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: #fdfcfa;
  transition: border 0.15s, background 0.15s, transform 0.15s;
  margin-bottom: 22px;
}
.dropzone.is-over {
  border-color: var(--brand);
  background: var(--brand-soft);
  transform: scale(1.005);
}
.dropzone-inner {
  display: flex; align-items: center; gap: 18px;
  padding: 22px 24px;
}
.dropzone-icon { font-size: 32px; line-height: 1; flex-shrink: 0; }
.dropzone-text strong {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
}
.dropzone-text .hint {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}
.linklike {
  background: none; border: none; padding: 0;
  font: inherit; color: var(--brand);
  text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}
.linklike:hover { color: var(--brand-2); }

.dropzone-preview {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
}
.dropzone-preview img {
  width: 56px; height: 56px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.preview-meta { flex: 1; min-width: 0; }
.preview-meta strong {
  display: block;
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.preview-meta span {
  font-size: 12px; color: var(--muted);
}
.ghost-btn {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 32px; height: 32px;
  font-size: 14px;
  cursor: pointer;
  color: var(--muted);
}
.ghost-btn:hover { color: var(--danger); border-color: var(--danger); }

/* Big primary button */
button.primary, .primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: white;
  border: none;
  padding: 14px 22px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center; justify-content: center;
  gap: 10px;
  width: 100%;
  box-shadow: var(--shadow-md);
  transition: transform 0.12s, box-shadow 0.12s;
}
button.primary:hover, .primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}
button.primary:disabled {
  opacity: 0.6; cursor: not-allowed;
  transform: none;
}
.primary-icon { font-size: 16px; }
.big-button { margin-top: 4px; }
.micro {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: 10px 0 0;
}

/* ====== STATUS / PROGRESS ====== */
.status-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
}
.status-card h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 18px;
  font-family: "Fraunces", "Inter", serif;
  letter-spacing: -0.01em;
}
.progress {
  list-style: none;
  margin: 0; padding: 0;
}
.progress li {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 0;
  font-size: 14px;
  color: var(--muted);
  transition: color 0.3s;
}
.progress li .dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: white;
  flex-shrink: 0;
  transition: all 0.3s;
}
.progress li.is-active {
  color: var(--ink);
  font-weight: 600;
}
.progress li.is-active .dot {
  border-color: var(--brand);
  background: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
  animation: pulseDot 1.4s ease-in-out infinite;
}
.progress li.is-done { color: var(--ink-soft); }
.progress li.is-done .dot {
  border-color: var(--ok);
  background: var(--ok);
}
.progress li.is-done .dot::after {
  content: "";
  display: block;
  width: 100%; height: 100%;
  background: radial-gradient(circle, white 30%, transparent 32%);
  border-radius: 50%;
}
@keyframes pulseDot {
  0%, 100% { box-shadow: 0 0 0 4px var(--brand-soft); }
  50%      { box-shadow: 0 0 0 8px rgba(109, 40, 217, 0.10); }
}
.status-foot {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* ====== RESULT ====== */
.result-section { margin-bottom: 24px; }
.result-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 18px 24px;
  border-bottom: none;
}
.result-header h2 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
  font-family: "Fraunces", "Inter", serif;
}
.result-header .meta {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-soft, .btn-ghost {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  font-family: inherit;
  cursor: pointer;
}
.btn-soft {
  background: var(--brand-soft);
  color: var(--brand);
}
.btn-soft:hover { background: #ebe2ff; }
.btn-ghost {
  background: white;
  color: var(--ink);
  border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--ink); }

#tutorFrame {
  display: block;
  width: 100%;
  height: 800px; /* JS resizes to content height on load; this is just a fallback. */
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: white;
}

/* ====== ERROR ====== */
.error-card {
  background: var(--danger-soft);
  border: 1px solid #fecaca;
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 24px;
}
.error-card h2 {
  margin: 0 0 10px;
  font-size: 16px;
  color: var(--danger);
}
.error-card pre {
  background: white;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 12px;
  margin: 0 0 14px;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* ====== HOW IT WORKS ====== */
.how-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 32px;
  margin-bottom: 24px;
}
.how-card h3 {
  margin: 0 0 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.how-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}
.how-grid > div { position: relative; }
.how-num {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: white;
  border-radius: 8px;
  font-size: 12px; font-weight: 700;
  margin-bottom: 8px;
}
.how-grid strong { display: block; font-size: 14px; margin-bottom: 4px; }
.how-grid p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.55; }

footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 20px 0 0;
}
footer code {
  background: white;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 11px;
}

/* ====== MOBILE ====== */
@media (max-width: 720px) {
  main { padding: 32px 16px 56px; }
  .form-card { padding: 22px 18px; border-radius: 18px; }
  .status-card, .how-card { padding: 22px 18px; border-radius: 18px; }
  .result-header { padding: 16px 18px; flex-direction: column; align-items: stretch; }
  .result-actions { width: 100%; }
  .result-actions a, .result-actions button { flex: 1; text-align: center; }
  #tutorFrame { height: 700px; }
  .dropzone-inner { padding: 18px; gap: 14px; flex-direction: column; text-align: center; }
  .dropzone-icon { font-size: 28px; }
  .how-grid { grid-template-columns: 1fr; gap: 16px; }
  .hero h1 { font-size: 34px; }
}

@media (max-width: 420px) {
  .hero h1 { font-size: 30px; }
  .brand-name { font-size: 13px; }
  textarea { font-size: 14px; }
}
