/* ==========================================================================
   idea2print — walkthrough UI
   Premium dark print-studio system. Ink, paper, cobalt, vermilion.
   Custom layer on top of Tailwind CDN utilities. No build step.
   ========================================================================== */

:root {
  --ink: #11100e;
  --ink-2: #171612;
  --ink-3: #1f1d17;
  --ink-line: #2c2921;
  --paper: #f3eee4;
  --paper-dim: #c8c1b0;
  --paper-faint: #857e6f;
  --cobalt: #2b4bf2;
  --cobalt-bright: #5d78ff;
  --cobalt-deep: #1b2fa6;
  --vermilion: #e04a26;
  --vermilion-soft: #f4764f;
  --ok: #3f9e6c;
  --warn: #d9a13f;
  --rail-w: 76px;
  --radius: 4px;
  --focus-ring: 0 0 0 2px var(--ink), 0 0 0 4.5px var(--cobalt-bright);
}

html {
  background: var(--ink);
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(43, 75, 242, 0.07), transparent 60%),
    var(--ink);
  color: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Paper-grain overlay: subtle repeating noise via layered gradients */
.grain::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.05;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 2px, rgba(243, 238, 228, 0.35) 2px 3px),
    repeating-linear-gradient(90deg, transparent 0 3px, rgba(17, 16, 14, 0.4) 3px 4px);
  mix-blend-mode: overlay;
}

::selection {
  background: var(--cobalt);
  color: var(--paper);
}

/* --------------------------------------------------------------------------
   Focus visibility — always visible, never removed
   -------------------------------------------------------------------------- */
:focus {
  outline: none;
}
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius);
}
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--cobalt);
  color: var(--paper);
  padding: 0.6rem 1rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
}
.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

/* --------------------------------------------------------------------------
   Registration rail — vertical 0→6 production strip with crop-mark geometry
   -------------------------------------------------------------------------- */
.reg-rail {
  width: var(--rail-w);
  border-right: 1px solid var(--ink-line);
  background:
    linear-gradient(180deg, rgba(43, 75, 242, 0.06), transparent 30%),
    var(--ink-2);
}

.reg-rail__track {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  min-height: 520px;
  padding: 1.25rem 0;
}

/* base spine */
.reg-rail__track::before {
  content: "";
  position: absolute;
  top: 2rem;
  bottom: 2rem;
  left: 50%;
  width: 1px;
  transform: translateX(-0.5px);
  background: var(--ink-line);
}

/* live progress fill on the spine */
.reg-rail__track::after {
  content: "";
  position: absolute;
  top: 2rem;
  left: 50%;
  width: 1px;
  transform: translateX(-0.5px);
  height: calc((100% - 4rem) * var(--rail-progress, 0) / 100);
  background: linear-gradient(180deg, var(--cobalt-bright), var(--cobalt));
  box-shadow: 0 0 12px rgba(93, 120, 255, 0.55);
  transition: height 600ms cubic-bezier(0.22, 1, 0.36, 1);
}

.reg-step {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  text-decoration: none;
  color: var(--paper-faint);
}

.reg-step__num {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
}

/* Registration mark: circle + crosshair, like press registration targets */
.reg-mark {
  position: relative;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--paper-faint);
  background: var(--ink-2);
  transition: border-color 200ms ease, box-shadow 200ms ease, background 200ms ease;
}
.reg-mark::before,
.reg-mark::after {
  content: "";
  position: absolute;
  background: currentColor;
  opacity: 0.85;
}
.reg-mark::before {
  left: 50%;
  top: -4px;
  bottom: -4px;
  width: 1px;
  transform: translateX(-0.5px);
}
.reg-mark::after {
  top: 50%;
  left: -4px;
  right: -4px;
  height: 1px;
  transform: translateY(-0.5px);
}
.reg-mark__dot {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: transparent;
  transition: background 200ms ease, transform 200ms ease;
}

/* states */
.reg-step[data-state="done"] {
  color: var(--paper-dim);
}
.reg-step[data-state="done"] .reg-mark {
  border-color: var(--paper-dim);
}
.reg-step[data-state="done"] .reg-mark__dot {
  background: var(--paper-dim);
  inset: 9px;
}
.reg-step[data-state="active"] {
  color: var(--cobalt-bright);
}
.reg-step[data-state="active"] .reg-mark {
  border-color: var(--cobalt-bright);
  box-shadow: 0 0 0 4px rgba(43, 75, 242, 0.18), 0 0 18px rgba(93, 120, 255, 0.35);
}
.reg-step[data-state="active"] .reg-mark__dot {
  background: var(--cobalt-bright);
  animation: reg-pulse 2.4s ease-in-out infinite;
}
.reg-step[data-state="todo"] .reg-mark {
  border-style: dashed;
  opacity: 0.55;
}
.reg-step:hover .reg-step__label,
.reg-step:focus-visible .reg-step__label {
  opacity: 1;
  transform: translateX(0);
}
.reg-step__label {
  position: absolute;
  left: calc(100% + 14px);
  top: 50%;
  transform: translate(-4px, -50%);
  translate: 0 0;
  white-space: nowrap;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: var(--ink-3);
  border: 1px solid var(--ink-line);
  color: var(--paper-dim);
  padding: 0.25rem 0.55rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 30;
}

@keyframes reg-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.55); opacity: 0.7; }
}

/* Mobile: rail flips horizontal along the top */
@media (max-width: 767px) {
  .reg-rail {
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--ink-line);
  }
  .reg-rail__track {
    flex-direction: row;
    min-height: 0;
    height: 64px;
    padding: 0 1rem;
    align-items: center;
  }
  .reg-rail__track::before {
    top: 50%;
    bottom: auto;
    left: 2rem;
    right: 2rem;
    width: auto;
    height: 1px;
    transform: translateY(-0.5px);
  }
  .reg-rail__track::after {
    top: 50%;
    left: 2rem;
    height: 1px;
    transform: translateY(-0.5px);
    width: calc((100% - 4rem) * var(--rail-progress, 0) / 100);
    transition: width 600ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  .reg-step__label { display: none; }
  .reg-rail__brand { display: none; }
}

/* --------------------------------------------------------------------------
   Crop-mark card corners — the studio card signature
   -------------------------------------------------------------------------- */
.crop-card {
  position: relative;
  background: var(--ink-2);
  border: 1px solid var(--ink-line);
}
.crop-card::before,
.crop-card::after,
.crop-card > .crop-ticks::before,
.crop-card > .crop-ticks::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  pointer-events: none;
  border-color: var(--paper-faint);
  border-style: solid;
  border-width: 0;
  opacity: 0.7;
  transition: border-color 180ms ease, opacity 180ms ease;
}
.crop-card::before { top: -1px; left: -1px; border-top-width: 1px; border-left-width: 1px; }
.crop-card::after { top: -1px; right: -1px; border-top-width: 1px; border-right-width: 1px; }
.crop-card > .crop-ticks::before { bottom: -1px; left: -1px; border-bottom-width: 1px; border-left-width: 1px; }
.crop-card > .crop-ticks::after { bottom: -1px; right: -1px; border-bottom-width: 1px; border-right-width: 1px; }

.crop-card:hover::before,
.crop-card:hover::after,
.crop-card:hover > .crop-ticks::before,
.crop-card:hover > .crop-ticks::after,
.crop-card.is-selected::before,
.crop-card.is-selected::after,
.crop-card.is-selected > .crop-ticks::before,
.crop-card.is-selected > .crop-ticks::after {
  border-color: var(--cobalt-bright);
  opacity: 1;
}
.crop-card.is-selected {
  border-color: var(--cobalt);
  box-shadow: 0 0 0 1px var(--cobalt), 0 8px 40px -18px rgba(43, 75, 242, 0.6);
}

/* --------------------------------------------------------------------------
   Typography helpers
   -------------------------------------------------------------------------- */
.display {
  font-family: "Zilla Slab", "Rockwell", serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.meta {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--paper-faint);
}
.meta--lit { color: var(--cobalt-bright); }
.rule {
  border: 0;
  height: 1px;
  background: var(--ink-line);
}

/* Kicker: vermilion proof-mark tick before section labels */
.kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}
.kicker::before {
  content: "";
  width: 18px;
  height: 8px;
  background:
    linear-gradient(90deg, var(--vermilion) 0 3px, transparent 3px 6px, var(--vermilion) 6px 9px, transparent 9px);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.7rem 1.25rem;
  border: 1px solid var(--ink-line);
  color: var(--paper);
  background: var(--ink-3);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 120ms ease, color 160ms ease;
  text-decoration: none;
}
.btn:hover { border-color: var(--paper-faint); background: #26231c; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.btn--primary {
  background: var(--cobalt);
  border-color: var(--cobalt);
  color: var(--paper);
}
.btn--primary:hover { background: var(--cobalt-bright); border-color: var(--cobalt-bright); }
.btn--proof {
  background: transparent;
  border-color: var(--vermilion);
  color: var(--vermilion-soft);
}
.btn--proof:hover { background: rgba(224, 74, 38, 0.12); border-color: var(--vermilion-soft); }
.btn--ghost {
  background: transparent;
}
.btn--sm { padding: 0.4rem 0.8rem; font-size: 0.66rem; }

/* --------------------------------------------------------------------------
   Form fields
   -------------------------------------------------------------------------- */
.field-label {
  display: block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--paper-dim);
  margin-bottom: 0.45rem;
}
.field-hint {
  font-size: 0.78rem;
  color: var(--paper-faint);
  margin-top: 0.35rem;
  line-height: 1.45;
}
.input, .textarea, .select {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--ink-line);
  color: var(--paper);
  padding: 0.65rem 0.85rem;
  font-size: 0.92rem;
  border-radius: var(--radius);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.input::placeholder, .textarea::placeholder { color: var(--paper-faint); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--paper-faint); }
.input:focus-visible, .textarea:focus-visible, .select:focus-visible {
  border-color: var(--cobalt-bright);
  box-shadow: 0 0 0 3px rgba(43, 75, 242, 0.25);
}
.textarea { min-height: 88px; resize: vertical; }

/* --------------------------------------------------------------------------
   Badges / chips
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.22rem 0.55rem;
  border: 1px solid var(--ink-line);
  color: var(--paper-dim);
  background: var(--ink-3);
  white-space: nowrap;
}
.badge--pass { border-color: rgba(63, 158, 108, 0.6); color: #7cc9a0; background: rgba(63, 158, 108, 0.1); }
.badge--fail { border-color: rgba(224, 74, 38, 0.6); color: var(--vermilion-soft); background: rgba(224, 74, 38, 0.1); }
.badge--warn { border-color: rgba(217, 161, 63, 0.55); color: #e6c076; background: rgba(217, 161, 63, 0.1); }
.badge--info { border-color: rgba(93, 120, 255, 0.55); color: var(--cobalt-bright); background: rgba(43, 75, 242, 0.12); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.74rem;
  padding: 0.28rem 0.65rem;
  border: 1px solid var(--ink-line);
  background: var(--ink-3);
  color: var(--paper-dim);
  border-radius: 999px;
}
.chip--danger { border-color: rgba(224, 74, 38, 0.5); color: var(--vermilion-soft); }

.swatch {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(243, 238, 228, 0.25);
  display: inline-block;
}

/* --------------------------------------------------------------------------
   Dropzone
   -------------------------------------------------------------------------- */
.dropzone {
  position: relative;
  border: 1.5px dashed var(--ink-line);
  background:
    repeating-linear-gradient(-45deg, transparent 0 14px, rgba(243, 238, 228, 0.015) 14px 28px),
    var(--ink-2);
  transition: border-color 180ms ease, background 180ms ease;
  cursor: pointer;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--paper-faint); }
.dropzone.is-dragover {
  border-color: var(--cobalt-bright);
  background: rgba(43, 75, 242, 0.07);
  box-shadow: inset 0 0 60px -20px rgba(43, 75, 242, 0.45);
}

/* --------------------------------------------------------------------------
   Masonry-ish reference board (CSS columns)
   -------------------------------------------------------------------------- */
.ref-board { column-count: 2; column-gap: 1rem; }
@media (min-width: 768px) { .ref-board { column-count: 3; } }
@media (min-width: 1280px) { .ref-board { column-count: 4; } }
.ref-board > * { break-inside: avoid; margin-bottom: 1rem; }

/* --------------------------------------------------------------------------
   Task console (SSE stream)
   -------------------------------------------------------------------------- */
.console {
  background: var(--ink);
  border: 1px solid var(--ink-line);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.74rem;
  line-height: 1.7;
  color: var(--paper-dim);
  max-height: 220px;
  overflow-y: auto;
  padding: 0.85rem 1rem;
}
.console__line { display: flex; gap: 0.75rem; }
.console__line .t { color: var(--paper-faint); flex: none; }
.console__line.err { color: var(--vermilion-soft); }

.progress-track {
  height: 4px;
  background: var(--ink-line);
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cobalt-deep), var(--cobalt-bright));
  transition: width 400ms ease;
  position: relative;
}
.progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(243, 238, 228, 0.35), transparent);
  animation: scan 1.6s linear infinite;
}
@keyframes scan {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */
.toast-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: min(380px, calc(100vw - 2rem));
}
.toast {
  border: 1px solid var(--ink-line);
  border-left: 3px solid var(--cobalt);
  background: var(--ink-3);
  color: var(--paper);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  box-shadow: 0 12px 40px -12px rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.toast--error { border-left-color: var(--vermilion); }
.toast--success { border-left-color: var(--ok); }
.toast__close {
  margin-left: auto;
  color: var(--paper-faint);
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.toast__close:hover { color: var(--paper); }

/* --------------------------------------------------------------------------
   JSON drawer
   -------------------------------------------------------------------------- */
.drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(17, 16, 14, 0.7);
  backdrop-filter: blur(2px);
  z-index: 60;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 94vw);
  background: var(--ink-2);
  border-left: 1px solid var(--ink-line);
  z-index: 70;
  display: flex;
  flex-direction: column;
  box-shadow: -24px 0 80px -20px rgba(0, 0, 0, 0.85);
}
.drawer__body {
  overflow: auto;
  flex: 1;
  padding: 1rem 1.25rem;
}
.drawer pre {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.74rem;
  line-height: 1.65;
  color: var(--paper-dim);
  white-space: pre-wrap;
  word-break: break-word;
}

/* --------------------------------------------------------------------------
   Split panel (Prompt Master)
   -------------------------------------------------------------------------- */
.split-divider {
  position: relative;
}
@media (min-width: 1024px) {
  .split-divider::before {
    content: "";
    position: absolute;
    left: -1px;
    top: 0;
    bottom: 0;
    width: 1px;
    background:
      repeating-linear-gradient(180deg, var(--ink-line) 0 8px, transparent 8px 16px);
  }
}

/* Proof stamp — rotated vermilion mark for approved/QA states */
.proof-stamp {
  display: inline-block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.6rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--vermilion-soft);
  border: 1.5px solid var(--vermilion-soft);
  padding: 0.2rem 0.5rem;
  transform: rotate(-4deg);
  opacity: 0.9;
}
.proof-stamp--ok { color: #7cc9a0; border-color: #7cc9a0; }

/* Checkerboard behind transparent PNGs */
.alpha-bed {
  background:
    conic-gradient(#211f19 0 25%, #191813 0 50%, #211f19 0 75%, #191813 0) 0 0 / 22px 22px;
}

/* Weight slider */
input[type="range"].weight {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  background: var(--ink-line);
  outline-offset: 6px;
}
input[type="range"].weight::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--cobalt-bright);
  border: 2px solid var(--ink);
  border-radius: 50%;
  cursor: pointer;
}
input[type="range"].weight::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--cobalt-bright);
  border: 2px solid var(--ink);
  border-radius: 50%;
  cursor: pointer;
}

/* Scrollbars in-theme */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--ink-line) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--ink-line); border-radius: 4px; }

/* --------------------------------------------------------------------------
   Motion preferences
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
  .progress-fill::after { animation: none; display: none; }
  .reg-step[data-state="active"] .reg-mark__dot { animation: none; }
}
