/* Qlon — "typesetter's desk" theme.
   Tailwind (Play CDN) handles layout utilities; this file defines the design's
   signature components: the ink rail, the paper-sheet document preview, panels,
   buttons, and the serif document typography. Brand primary = #005db5. */

/* ---------------- Canvas texture ---------------- */
/* Faint dot grid so large empty areas read as intentional, not barren. */
.canvas-bg {
  background-image: radial-gradient(rgba(15, 30, 60, 0.045) 1px, transparent 1px);
  background-size: 24px 24px;
  background-attachment: fixed;
}
.dark.canvas-bg { background-image: radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px); }

/* ---------------- Wizard steppers (forward/reverse, responsive + mode-gated) ----
   Each wizard has a desktop stepper and a mobile progress bar in the header. The
   .stepper-desktop/.stepper-mobile classes own the breakpoint (desktop-only vs
   mobile-only); the body.mode-reverse class then hides whichever wizard is inactive.
   Kept in CSS (not Tailwind responsive utilities) so the mode gate and the media
   query don't fight over `display`. */
.stepper-desktop { display: none; }
.stepper-mobile { display: block; }
@media (min-width: 768px) {
  .stepper-desktop { display: block; }
  .stepper-mobile { display: none; }
}
body:not(.mode-reverse) [data-reverse-only] { display: none !important; }
body.mode-reverse [data-forward-only] { display: none !important; }

/* ---------------- Top horizontal stepper ---------------- */
.hstep { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.hstep .badge {
  display: flex; align-items: center; justify-content: center;
  height: 1.9rem; width: 1.9rem; flex-shrink: 0; border-radius: 9999px;
  border: 2px solid #d1d5db; background: #fff; font-size: 0.8rem; font-weight: 600; color: #9ca3af;
  transition: all 0.15s ease;
}
.dark .hstep .badge { border-color: #28395c; background: #0b1220; color: #94a3b8; }
.hstep-label { font-size: 0.85rem; font-weight: 500; color: #9ca3af; white-space: nowrap; transition: color 0.15s ease; }
.dark .hstep-label { color: #94a3b8; }
.hstep.step-active .badge { border-color: #005db5; color: #005db5; box-shadow: 0 0 0 4px rgba(0, 93, 181, 0.18); }
.dark .hstep.step-active .badge { color: #5aa1e6; }
.hstep.step-active .hstep-label { color: #005db5; }
.dark .hstep.step-active .hstep-label { color: #5aa1e6; }
.hstep.step-done .badge { background: #005db5; border-color: #005db5; color: #fff; animation: badgePop 0.35s ease; }
.hstep.step-done .hstep-label { color: #1f2937; }
.dark .hstep.step-done .hstep-label { color: #e5e7eb; }
.hstep.step-clickable { cursor: pointer; }
@keyframes badgePop { 0% { transform: scale(1); } 45% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* Connector: gray track with a primary fill that wipes left→right when reached. */
.connector { position: relative; flex: none; width: 2.25rem; height: 2px; margin: 0 0.5rem; overflow: hidden; background: #e5e7eb; border-radius: 9999px; }
@media (min-width: 1024px) { .connector { width: 3rem; } }
.dark .connector { background: #28395c; }
.connector::after { content: ""; position: absolute; inset: 0; width: 0; background: #005db5; transition: width 0.45s ease; }
.connector-active::after { width: 100%; }

/* ---------------- Loading overlay ---------------- */
.indeterminate { position: relative; height: 4px; width: 100%; overflow: hidden; border-radius: 9999px; background: #e5e7eb; }
.dark .indeterminate { background: #28395c; }
.indeterminate-bar { position: absolute; height: 100%; width: 40%; border-radius: 9999px; background: #005db5; animation: indeterminate 1.2s ease-in-out infinite; }
@keyframes indeterminate { 0% { left: -40%; } 100% { left: 100%; } }

/* ---------------- Success ---------------- */
.success-check {
  display: flex; align-items: center; justify-content: center;
  height: 4.5rem; width: 4.5rem; border-radius: 9999px; background: #dcfce7; color: #16a34a;
}
.dark .success-check { background: rgba(22, 163, 74, 0.16); color: #4ade80; }
.step-panel[data-step="4"]:not(.hidden) .success-check { animation: successPop 0.5s cubic-bezier(0.2, 0.7, 0.3, 1.3) both; }
.step-panel[data-step="4"]:not(.hidden) .success-check svg path { stroke-dasharray: 26; stroke-dashoffset: 26; animation: drawCheck 0.4s 0.28s ease forwards; }
@keyframes successPop { 0% { transform: scale(0.4); opacity: 0; } 60% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }
@keyframes drawCheck { to { stroke-dashoffset: 0; } }

/* ---------------- Overlay/modal entrance ---------------- */
.fade-in { animation: fadeIn 0.2s ease both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.pop-in { animation: popIn 0.24s cubic-bezier(0.2, 0.7, 0.3, 1.2) both; }
@keyframes popIn { from { opacity: 0; transform: scale(0.96) translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------- Surface headings ---------------- */
.eyebrow { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: #005db5; }
.dark .eyebrow { color: #5aa1e6; }
.surface-title { font-family: "Bricolage Grotesque", system-ui, sans-serif; font-size: clamp(1.55rem, 3vw, 2rem); font-weight: 700; letter-spacing: -0.02em; margin-top: 0.35rem; line-height: 1.1; }
.surface-sub { margin-top: 0.5rem; color: #5b6472; }
.dark .surface-sub { color: #9aa4b2; }
.surface-footer { margin-top: 2.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.pane-label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #9ca3af; }

/* ---------------- Panels (cards) ---------------- */
.panel { background: #fff; border: 1px solid #e5e7eb; border-radius: 1rem; padding: 1.25rem 1.25rem 1.35rem; }
.dark .panel { background: #0f1a2e; border-color: #1f3050; }
.legend { padding: 0 0.35rem; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: #9ca3af; }

/* ---------------- Preview document typography (clean, theme-aware) ---------------- */
.doc-prose { font-family: "Source Serif 4", Georgia, serif; line-height: 1.65; font-size: 0.95rem; color: #1f2937; }
.dark .doc-prose { color: #e5e7eb; }
.doc-prose .doc-empty { font-family: "Inter", system-ui, sans-serif; color: #9ca3af; font-style: italic; }
.doc-prose > :first-child { margin-top: 0; }
.doc-prose h1, .doc-prose h2, .doc-prose h3, .doc-prose h4 { font-weight: 600; line-height: 1.25; margin: 1.3em 0 0.5em; }
.doc-prose h1 { font-size: 1.7em; }
.doc-prose h2 { font-size: 1.35em; border-bottom: 1px solid #e5e7eb; padding-bottom: 0.2em; }
.doc-prose h3 { font-size: 1.12em; }
.dark .doc-prose h2 { border-color: #28395c; }
.doc-prose p { margin: 0.65em 0; }
.doc-prose a { color: #005db5; text-decoration: underline; }
.dark .doc-prose a { color: #5aa1e6; }
.doc-prose ul { list-style: disc; padding-left: 1.4em; margin: 0.65em 0; }
.doc-prose ol { list-style: decimal; padding-left: 1.4em; margin: 0.65em 0; }
.doc-prose li { margin: 0.25em 0; }
.doc-prose blockquote { border-left: 3px solid #d4d4d4; padding-left: 1em; color: #6b7280; font-style: italic; margin: 0.8em 0; }
.dark .doc-prose blockquote { border-color: #28395c; color: #9ca3af; }
.doc-prose code { font-family: "JetBrains Mono", monospace; background: #f0f0f0; padding: 0.1em 0.35em; border-radius: 4px; font-size: 0.85em; }
.dark .doc-prose code { background: #15223a; }
.doc-prose pre { font-family: "JetBrains Mono", monospace; background: #1f2430; color: #f4f4f5; padding: 0.9em; border-radius: 8px; overflow-x: auto; margin: 0.8em 0; }
.doc-prose pre code { background: transparent; padding: 0; color: inherit; }
.doc-prose table { border-collapse: collapse; margin: 0.9em 0; width: 100%; font-size: 0.9em; }
.doc-prose th, .doc-prose td { border: 1px solid #e3e3e3; padding: 0.4em 0.65em; text-align: left; }
.dark .doc-prose th, .dark .doc-prose td { border-color: #28395c; }
.doc-prose th { background: #f7f7f5; font-weight: 600; }
.dark .doc-prose th { background: #15223a; }
.doc-prose img { max-width: 100%; height: auto; }
.doc-prose hr { border: 0; border-top: 1px solid #e5e7eb; margin: 1.3em 0; }
.dark .doc-prose hr { border-color: #28395c; }

/* ---------------- Step entrance (staggered cascade) ---------------- */
/* Direct children of the active step fade + rise in sequence, replaying on each
   step change (the panel goes display:none → block, restarting child animations). */
.step-panel:not(.hidden) > * { animation: stepIn 0.5s cubic-bezier(0.22, 0.61, 0.36, 1) both; }
.step-panel:not(.hidden) > *:nth-child(1) { animation-delay: 0.04s; }
.step-panel:not(.hidden) > *:nth-child(2) { animation-delay: 0.10s; }
.step-panel:not(.hidden) > *:nth-child(3) { animation-delay: 0.16s; }
.step-panel:not(.hidden) > *:nth-child(4) { animation-delay: 0.22s; }
.step-panel:not(.hidden) > *:nth-child(5) { animation-delay: 0.28s; }
.step-panel:not(.hidden) > *:nth-child(n + 6) { animation-delay: 0.34s; }
/* Stagger the grouped panels on the Details step too. */
.step-panel:not(.hidden) .space-y-5 > * { animation: stepIn 0.5s cubic-bezier(0.22, 0.61, 0.36, 1) both; }
.step-panel:not(.hidden) .space-y-5 > *:nth-child(1) { animation-delay: 0.20s; }
.step-panel:not(.hidden) .space-y-5 > *:nth-child(2) { animation-delay: 0.28s; }
.step-panel:not(.hidden) .space-y-5 > *:nth-child(3) { animation-delay: 0.36s; }
@keyframes stepIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------------- Buttons ---------------- */
.btn-primary {
  border-radius: 0.625rem; background: #005db5; padding: 0.65rem 1.35rem;
  font-size: 0.9rem; font-weight: 600; color: #fff;
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.btn-primary:hover { background: #004a91; }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }

.btn-ghost {
  border-radius: 0.625rem; border: 1px solid #d1d5db; background: transparent;
  padding: 0.65rem 1.35rem; font-size: 0.9rem; font-weight: 500; color: #374151;
  transition: background-color 0.15s ease;
}
.btn-ghost:hover { background: #fff; }
.dark .btn-ghost { border-color: #2b3b59; color: #cbd5e1; }
.dark .btn-ghost:hover { background: #0f1a2e; }

.btn-soft {
  display: inline-flex; align-items: center; gap: 0.375rem; border-radius: 0.5rem;
  border: 1px solid #d1d5db; background: #fff; padding: 0.375rem 0.75rem;
  font-size: 0.8rem; font-weight: 500; color: #374151;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.btn-soft:hover { background: #f3f4f6; border-color: #9ca3af; }
.btn-soft:active { transform: translateY(1px); }
.dark .btn-soft { border-color: #2b3b59; background: #0f1a2e; color: #cbd5e1; }
.dark .btn-soft:hover { background: #15223a; border-color: #3a4f73; }

/* ---------------- Form fields ---------------- */
.field-label { display: block; margin-bottom: 0.375rem; font-weight: 500; color: #374151; }
.dark .field-label { color: #cbd5e1; }
.field-input {
  display: block; width: 100%; border-radius: 0.625rem; border: 1px solid #d1d5db;
  background: #fff; padding: 0.625rem 0.7rem; font-size: 0.9rem; color: #111827;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field-input:focus { outline: none; border-color: #005db5; box-shadow: 0 0 0 3px rgba(0, 93, 181, 0.22); }
.dark .field-input { border-color: #2b3b59; background: #0b1220; color: #f3f4f6; }
.field-invalid { border-color: #dc2626 !important; box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2) !important; }

/* Dropzone drag-over state */
.dropzone-active { border-color: #005db5 !important; background: rgba(0, 93, 181, 0.06) !important; }

/* ---------------- Language toggle ---------------- */
.lang-btn { color: #6b7280; transition: background-color 0.15s ease, color 0.15s ease; }
.lang-btn:hover { background: #f3f4f6; }
.dark .lang-btn { color: #9ca3af; }
.dark .lang-btn:hover { background: #15223a; }
.lang-btn-dark { color: rgba(255, 255, 255, 0.6); }
.lang-btn-dark:hover { background: rgba(255, 255, 255, 0.08); }
.lang-active, .dark .lang-active, .lang-btn-dark.lang-active { background: #005db5; color: #fff; }
.lang-active:hover, .lang-btn-dark.lang-active:hover { background: #005db5; }

/* ---------------- Content mode tabs ---------------- */
.mode-tab { color: #6b7280; }
.dark .mode-tab { color: #9ca3af; }
.mode-tab-active { background: #fff; color: #005db5; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }
.dark .mode-tab-active { background: #0b1220; color: #5aa1e6; }

/* ---------------- Help modal provider tabs ---------------- */
.help-tab {
  flex-shrink: 0; border-radius: 0.5rem; padding: 0.375rem 0.875rem;
  font-size: 0.8125rem; font-weight: 500; color: #6b7280;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.help-tab:hover { background: #f3f4f6; }
.dark .help-tab { color: #9ca3af; }
.dark .help-tab:hover { background: #15223a; }
.help-tab-active { background: #005db5; color: #fff; }
.help-tab-active:hover { background: #005db5; }

/* ---------------- Keyboard focus ---------------- */
button:focus-visible, a:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid #005db5; outline-offset: 2px; border-radius: 0.5rem;
}
.dark button:focus-visible, .dark a:focus-visible, .dark select:focus-visible, .dark [tabindex]:focus-visible {
  outline-color: #5aa1e6;
}

/* ---------------- Reduced motion ---------------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
