/* ============================================================================
   Wellpaged — Builder UI Kit chrome
   DESIGN.md §6.3: theme → profile → links → stage → publish, with a live
   device-framed preview and a persistent top bar (status sticker + Preview +
   Publish). The theme picker is the hero of step 1.
   ============================================================================ */
@import url('../assets/css/colors_and_type.css');

* , *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font-body);
  font-size: 15px; -webkit-font-smoothing: antialiased; }
button { font: inherit; background: none; border: 0; cursor: pointer; color: inherit; }
input { font: inherit; }

.builder { display: grid; grid-template-columns: 1fr 460px; height: 100vh; overflow: hidden; }

/* ---- Top bar (persistent, spans the editor column) ---- */
.editor { display: flex; flex-direction: column; min-width: 0; height: 100vh; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 16px 28px; border-bottom: 1px solid rgba(11,11,18,.12);
  position: sticky; top: 0; background: var(--paper); z-index: 30; }
.topbar .wm { font-family: var(--font-display); font-size: 20px; font-weight: 500; font-variation-settings:'opsz' 144,'SOFT' 50; letter-spacing: -.028em; }
.topbar-kicker { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; color: var(--text-dim); text-transform: uppercase; }
.topbar .spacer { flex: 1; }
.st { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: var(--r-pill);
  font-family: var(--font-mono); font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  border: 1.2px solid var(--ink); }
.st .dot { width: 7px; height: 7px; border-radius: 50%; }
.st.draft { background: var(--paper); } .st.draft .dot { background: var(--ink); }
.st.staged { background: var(--blue); color: var(--paper); } .st.staged .dot { background: var(--paper); }
.st.building { background: var(--sunshine); } .st.building .dot { background: var(--ink); animation: pulse 1.1s infinite; }
.st.live { background: var(--mint); } .st.live .dot { background: var(--ink); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.25} }
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 18px; border-radius: var(--r-pill);
  border: 1.5px solid var(--ink); font-size: 13px; font-weight: 500; transition: background 160ms, color 160ms; }
.btn.primary { background: var(--ink); color: var(--paper); } .btn.primary:hover { background: var(--paper); color: var(--ink); }
.btn.ghost { background: var(--paper); color: var(--ink); } .btn.ghost:hover { background: var(--ink); color: var(--paper); }

/* ---- Stepper ---- */
.stepper { display: flex; gap: 6px; padding: 18px 28px; border-bottom: 1px solid rgba(11,11,18,.1); }
.step { display: flex; align-items: center; gap: 9px; padding: 7px 14px 7px 9px; border-radius: var(--r-pill);
  font-size: 13px; color: var(--text-dim); cursor: default; transition: background 140ms, color 140ms; }
.step.reachable { cursor: pointer; }
.step.reachable:hover:not(.active) { background: var(--paper-soft); }
.step .n { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid currentColor; display: flex;
  align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 11px; }
.step.active { background: var(--paper-sink); color: var(--ink); font-weight: 500; }
.step.done { color: var(--blue-deep); }
.step.done .n { background: var(--blue); border-color: var(--blue); color: var(--paper); }

/* ---- Step body ---- */
.stepbody { padding: 28px 28px 26px; overflow-y: auto; flex: 1; scrollbar-width: none; }
.stepbody::-webkit-scrollbar { width: 0; height: 0; display: none; }
.step-head { margin-bottom: 20px; }
.step-head .eyebrow { font-size: 12px; }
.step-intro { color: var(--text-muted); font-size: 14.5px; line-height: 1.55; max-width: 46ch; margin: 0 0 20px; }
.field-hint { font-size: 12px; color: var(--text-dim); margin-top: 7px; line-height: 1.4; }

/* ---- Footer step navigation (the primary flow control) ---- */
.step-nav { display: flex; align-items: center; gap: 14px; padding: 16px 28px;
  border-top: 1px solid rgba(11,11,18,.12); background: var(--paper); }
.step-nav .spacer { flex: 1; }
.step-nav .progress { font-family: var(--font-mono); font-size: 11px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-dim); }
.btn[disabled] { opacity: .4; pointer-events: none; }
.step-head h2 { font-family: var(--font-display); font-weight: 400; font-variation-settings:'opsz' 120,'SOFT' 40;
  font-size: 38px; letter-spacing: -.022em; margin: 8px 0 0; }
.step-head h2 em { font-style: italic; color: var(--violet-deep); }

/* ---- Theme picker (hero of step 1) ---- */
.theme-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; grid-auto-rows: 1fr; }
.theme-card { border: 1.5px solid var(--ink); border-radius: var(--r-lg); overflow: hidden; cursor: pointer;
  background: var(--paper); box-shadow: var(--shadow-hard); transition: transform 200ms var(--ease-spring), box-shadow 200ms;
  position: relative; display: flex; flex-direction: column; }
.theme-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.theme-card.sel { outline: 3px solid var(--blue); outline-offset: 2px; }
.theme-card.sel .pick-badge { display: inline-flex; }
.pick-badge { display: none; position: absolute; top: 10px; right: 10px; z-index: 3; padding: 4px 10px;
  background: var(--blue); color: var(--paper); font-family: var(--font-mono); font-size: 9px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; border: 1.5px solid var(--ink); border-radius: var(--r-pill);
  box-shadow: 2px 3px 0 var(--ink); transform: rotate(-3deg); }
.theme-thumb { height: 116px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.theme-thumb .mini-name { font-size: 22px; }
.theme-meta { padding: 12px 14px; border-top: 1.5px solid var(--ink); flex: 1; display: flex; flex-direction: column; justify-content: center; }
.theme-meta .tn { font-family: var(--font-display); font-weight: 500; font-size: 17px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.theme-meta .tc { font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-dim); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Form ---- */
.field { margin-bottom: 18px; }
.field label { display: block; font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 7px; }
.field .inp, .field textarea { width: 100%; border: 1.5px solid var(--ink); border-radius: var(--r-md);
  background: var(--paper); padding: 11px 13px; font-size: 15px; color: var(--ink); outline: none; }
.field textarea { resize: vertical; min-height: 70px; font-family: var(--font-body); line-height: 1.5; }
.field .inp:focus, .field textarea:focus { box-shadow: 0 0 0 2px var(--blue); border-color: var(--blue); }
.handle-row { display: flex; align-items: center; border: 1.5px solid var(--ink); border-radius: var(--r-md); overflow: hidden; }
.handle-row:focus-within { box-shadow: 0 0 0 2px var(--blue); border-color: var(--blue); }
.handle-row .pre { padding: 11px 4px 11px 13px; font-family: var(--font-mono); font-size: 13px; color: var(--text-dim); white-space: nowrap; }
.handle-row input { border: 0; background: none; outline: none; padding: 11px 13px 11px 4px; font-size: 15px; flex: 1; color: var(--ink); }
.avail { font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; margin-top: 7px; }
.avail.ok { color: var(--blue-deep); } .avail.taken { color: var(--coral); }

/* ---- Links editor ---- */
.link-edit-list { display: flex; flex-direction: column; gap: 10px; }
.link-edit { display: flex; align-items: center; gap: 10px; background: var(--paper-soft); border: 1.5px solid var(--ink);
  border-radius: var(--r-md); padding: 10px 12px; box-shadow: var(--shadow-hard); }
.link-edit.drag { transform: rotate(-2deg); box-shadow: var(--shadow-big); }
.link-edit .grip { font-family: var(--font-mono); color: var(--text-dim); cursor: grab; letter-spacing: .1em; }
.link-edit .le-body { flex: 1; min-width: 0; }
.link-edit .le-ic { width: 20px; height: 20px; flex-shrink: 0; display: flex; }
.link-edit .le-ic svg { width: 20px; height: 20px; fill: var(--ink); }
.link-edit .le-label { font-weight: 700; font-size: 14px; }
.link-edit .le-url { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-edit .le-del { color: var(--text-dim); font-size: 16px; padding: 4px; border-radius: 6px; }
.link-edit .le-del:hover { background: var(--coral); color: var(--ink); }
.add-link { display: flex; align-items: center; gap: 8px; padding: 12px; border: 1.5px dashed rgba(11,11,18,.4);
  border-radius: var(--r-md); color: var(--text-muted); font-size: 14px; width: 100%; justify-content: center; }
.add-link:hover { border-color: var(--ink); color: var(--ink); background: var(--paper-soft); }
.link-edit .le-feat { color: var(--text-dim); font-size: 13px; padding: 4px 6px; border-radius: 6px; border: 1.5px solid transparent; }
.link-edit .le-feat.on { color: var(--violet-deep); border-color: var(--violet-deep); background: color-mix(in srgb, var(--violet) 12%, transparent); }
.link-edit .le-feat:hover { color: var(--violet-deep); }

/* ---- Category chips (brand step) ---- */
.cat-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-chip { padding: 8px 14px; border-radius: var(--r-pill); border: 1.5px solid var(--ink);
  background: var(--paper); font-size: 13px; font-weight: 500; cursor: pointer; transition: background 140ms, color 140ms; }
.cat-chip:hover { background: var(--paper-soft); }
.cat-chip.on { background: var(--ink); color: var(--paper); }

/* ---- Socials intake rows ---- */
.social-edit-list { display: flex; flex-direction: column; gap: 10px; }
.social-edit { display: flex; align-items: center; gap: 13px; padding: 11px 14px; border: 1.5px solid var(--ink);
  border-radius: var(--r-md); background: var(--paper); transition: opacity 160ms; }
.social-edit.off { opacity: .5; }
.social-edit .si { width: 22px; height: 22px; flex-shrink: 0; display: flex; }
.social-edit .si svg { width: 22px; height: 22px; fill: var(--ink); }
.social-edit .sname { width: 76px; font-size: 14px; font-weight: 500; flex-shrink: 0; }
.social-edit input { flex: 1; min-width: 0; border: 0; background: none; outline: none;
  font-family: var(--font-mono); font-size: 13px; color: var(--ink); }
.social-edit .s-toggle { flex-shrink: 0; padding: 6px 14px; border-radius: var(--r-pill); border: 1.5px solid var(--ink);
  background: var(--paper); font-size: 12px; font-weight: 600; transition: background 140ms, color 140ms; }
.social-edit .s-toggle.on { background: var(--mint); color: var(--ink); }
.social-edit .s-toggle:hover { background: var(--ink); color: var(--paper); }
.social-edit .s-toggle.on:hover { background: var(--mint); color: var(--ink); }

/* ---- Review card ---- */
.review-card { border: 1.5px solid var(--ink); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-hard); }
.review-row { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 18px; border-bottom: 1px solid rgba(11,11,18,.1); }
.review-row:last-child { border-bottom: 0; }
.review-row .rk { font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-dim); }
.review-row .rv { font-size: 15px; font-weight: 500; text-align: right; }

/* ---- Preview pane (device frame) ---- */
.preview-pane { background: var(--paper-sink); border-left: 1px solid rgba(11,11,18,.12);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 28px 0 0;
  position: sticky; top: 0; height: 100vh; overflow: hidden; }
.preview-tag { font-family: var(--font-mono); font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--text-dim); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.preview-tag .url { color: var(--blue-deep); }
.phone { width: 320px; height: 660px; border-radius: 44px; background: var(--ink); padding: 11px;
  box-shadow: 0 30px 60px -20px rgba(11,11,18,.5); position: relative; flex-shrink: 0; }
.phone::before { content:''; position: absolute; top: 22px; left: 50%; transform: translateX(-50%);
  width: 96px; height: 26px; background: var(--ink); border-radius: 999px; z-index: 10; }
.phone-screen { width: 100%; height: 100%; border-radius: 34px; overflow: hidden; background: #fff; position: relative; }
.phone-scroll { position: absolute; inset: 0; overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none; }
.phone-scroll::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* ---- Publish dialog ---- */
.scrim { position: fixed; inset: 0; background: rgba(11,11,18,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.dialog { width: 440px; max-width: calc(100vw - 40px); background: var(--paper); border: 1.5px solid var(--ink);
  border-radius: var(--r-xl); box-shadow: var(--shadow-big); padding: 28px; }
.dialog h3 { font-family: var(--font-display); font-weight: 500; font-size: 26px; letter-spacing: -.015em; margin: 10px 0 10px; }
.dialog p { color: var(--text-muted); line-height: 1.55; margin: 0 0 8px; }
.dialog .url-line { font-family: var(--font-mono); font-size: 13px; color: var(--blue-deep); }
.dialog-actions { display: flex; gap: 10px; margin-top: 22px; }
.dialog-actions .btn { flex: 1; justify-content: center; }

/* ---- Toast ---- */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--mint); color: var(--ink);
  border: 1.5px solid var(--ink); border-radius: var(--r-md); padding: 13px 18px; box-shadow: var(--shadow-hard);
  font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 10px; z-index: 120;
  animation: rise-in 320ms var(--ease-spring); }
.toast .s { font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
@keyframes rise-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* ---- Builder additions: theme search/groups, link inputs, preview note, toasts ---- */
.theme-search { width: 100%; margin-bottom: 12px; }
.theme-group { font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-dim); margin: 22px 0 12px; display: flex; align-items: center; gap: 8px; }
.theme-group:first-of-type { margin-top: 6px; }
.theme-group-n { background: var(--paper-sink); border-radius: var(--r-pill); padding: 2px 8px; font-size: 9px; color: var(--text-muted); }
.link-edit { align-items: flex-start; }
.link-edit .grip, .link-edit .le-ic, .link-edit .le-feat, .link-edit .le-del { align-self: center; }
.le-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.le-in { width: 100%; border: 1.5px solid var(--ink); border-radius: var(--r-sm); background: var(--paper);
  padding: 7px 10px; font-size: 13.5px; color: var(--ink); outline: none; }
.le-in:focus { box-shadow: 0 0 0 2px var(--blue); border-color: var(--blue); }
.le-in.mono { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); }
.preview-note { margin-top: 14px; max-width: 300px; text-align: center; font-size: 11px; line-height: 1.5; color: var(--text-dim); padding: 0 12px; }
.preview-note strong { color: var(--text-muted); text-transform: capitalize; }
.toast.error { background: var(--coral); }
.toast.info { background: var(--blue); color: var(--paper); }
/* real template screenshots (TypeUI registry) in the picker + device preview */
.theme-thumb.img { padding: 0; }
.theme-thumb.img img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.tpl-preview { width: 100%; max-width: 380px; border: 1.5px solid var(--ink); border-radius: var(--r-lg);
  overflow: hidden; box-shadow: var(--shadow-hard); background: var(--paper); }
.tpl-preview img { width: 100%; display: block; }

/* ---- Mobile: stack editor over preview, un-trap the fixed-height layout ---- */
@media (max-width: 900px) {
  .builder { grid-template-columns: 1fr; height: auto; min-height: 100vh; overflow: visible; }
  .editor { height: auto; overflow: visible; }
  .stepbody { overflow: visible; }
  .stepper { flex-wrap: wrap; }
  .step-nav { position: sticky; bottom: 0; z-index: 20; }
  .preview-pane { position: static; height: auto; border-left: 0; border-top: 1.5px solid rgba(11,11,18,.14);
    padding: 28px 16px 44px; }
  .tpl-preview { max-width: 100%; }
}
@media (max-width: 480px) {
  .theme-grid { grid-template-columns: 1fr; }
  .step-head h2 { font-size: 30px; }
}

@media (prefers-reduced-motion: reduce) { *,*::before,*::after { animation-duration:.01ms !important; transition-duration:.01ms !important; } }
