/* ============================================================
   CvKit builder app shell: toolbar, form panel, live preview.
   The rendered CV itself is styled by templates.css.
   ============================================================ */

.cvb { padding: 1.4rem; }

/* ---------- toolbar ---------- */

.cvb-toolbar {
  display: flex; flex-wrap: wrap; gap: 0.9rem 1.4rem;
  align-items: flex-end;
  padding-bottom: 1.1rem; margin-bottom: 1.2rem;
  border-bottom: 2px solid var(--ink);
}
.cvb-ctl { display: flex; flex-direction: column; gap: 0.3rem; }
.cvb-ctl > label { font-size: 0.85rem; color: var(--ink-faint); letter-spacing: 0.04em; }
.cvb-ctl select, .cvb-ctl input[type="color"] {
  font: inherit; color: var(--ink);
  background: var(--paper-bright);
  border: 1.5px solid var(--ink); border-radius: 8px;
  padding: 0.35rem 0.55rem; min-height: 2.3rem;
}
.cvb-ctl input[type="color"] { width: 3.2rem; padding: 0.15rem; cursor: pointer; }
.cvb-swatches { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.cvb-swatch {
  width: 1.55rem; height: 1.55rem; border-radius: 50%;
  border: 2px solid var(--paper-bright);
  outline: 1.5px solid var(--line);
  cursor: pointer; padding: 0;
}
.cvb-swatch[aria-pressed="true"] { outline: 2.5px solid var(--ink); }
/* the swatch outline doubles as its border, so the focus ring must win */
.cvb-swatch:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.cvb-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-inline-start: auto; align-items: flex-end; }

/* template picker: category chips + expand toggle over the thumbnail strip */
.cvb-tplhead {
  display: flex; flex-wrap: wrap; gap: 0.5rem 0.8rem;
  align-items: center; justify-content: space-between;
  margin-bottom: 0.3rem;
}
.cvb-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.cvb-chip {
  font: inherit; font-size: 0.82rem; font-weight: 600;
  color: var(--ink-soft); background: var(--paper-bright);
  border: 1.5px solid var(--line); border-radius: 999px;
  padding: 0.28rem 0.75rem; cursor: pointer;
  line-height: 1.2; white-space: nowrap;
}
.cvb-chip small { font-weight: 500; opacity: 0.85; margin-inline-start: 0.15rem; }
.cvb-chip:hover { border-color: var(--ink-soft); color: var(--ink); }
.cvb-chip[aria-pressed="true"] {
  background: var(--ink); color: var(--paper-bright); border-color: var(--ink);
}
.cvb-chip[aria-pressed="true"] small { opacity: 0.85; }
.cvb-chip--toggle { margin-inline-start: auto; }
.cvb-chip--toggle::after { content: "\25BE"; display: inline-block; margin-inline-start: 0.35em; }
.cvb-chip--toggle[aria-expanded="true"]::after { content: "\25B4"; }

.cvb-tpls {
  display: flex; gap: 0.7rem; overflow-x: auto;
  padding: 0.4rem 0.2rem 0.7rem;
  scrollbar-width: thin;
}
/* expanded: wrap into a grid so the whole collection is on screen */
.cvb-tpls--grid { flex-wrap: wrap; overflow: visible; }
.cvb-tpl[hidden] { display: none; }
.cvb-tpl {
  flex: none; width: 92px;
  background: var(--paper-bright);
  border: 1.5px solid var(--line); border-radius: 10px;
  padding: 0.35rem; cursor: pointer;
  font: inherit; color: var(--ink-soft); font-size: 0.8rem;
  display: flex; flex-direction: column; gap: 0.25rem; align-items: center;
}
.cvb-tpl img {
  width: 100%; height: auto; aspect-ratio: 0.707; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--line);
  background: #fff; display: block;
}
.cvb-tpl[aria-pressed="true"] {
  border-color: var(--ink);
  box-shadow: 0 2px 0 rgba(47, 42, 36, 0.9);
  color: var(--ink); font-weight: 600;
}

/* ---------- two-pane layout ---------- */

.cvb-layout {
  display: grid; grid-template-columns: minmax(340px, 5fr) 7fr;
  gap: 1.6rem; align-items: start;
}
@media (max-width: 980px) { .cvb-layout { grid-template-columns: 1fr; } }

/* ---------- form panel ---------- */

.cvb-form { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }

/* a panel is a wrapper holding the <details> and, for CV sections, a
   toolbar that sits on the header row but outside the <summary> */
.cvb-sec {
  position: relative;
  border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--paper-bright);
}
.cvb-sec > details > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  font-family: var(--font-display); font-weight: 600; font-size: 1.05rem;
}
.cvb-sec > details > summary::-webkit-details-marker { display: none; }
.cvb-sec > details > summary::before { content: "▸"; color: var(--ink-faint); transition: transform 0.15s; }
.cvb-sec > details[open] > summary::before { transform: rotate(90deg); }
[dir="rtl"] .cvb-sec > details > summary::before { content: "◂"; }
[dir="rtl"] .cvb-sec > details[open] > summary::before { transform: rotate(-90deg); }
.cvb-sec--tools > details > summary { padding-inline-end: 8.5rem; }
.cvb-sec-tag { color: var(--ink-faint); font-weight: 500; font-size: 0.85em; }
.cvb-sec-body { padding: 0.2rem 0.9rem 0.9rem; display: flex; flex-direction: column; gap: 0.7rem; }

.cvb-sec-tools {
  position: absolute; top: 0.5rem; inset-inline-end: 0.6rem;
  display: flex; gap: 0.25rem; align-items: center;
}
.cvb-iconbtn {
  font: inherit; line-height: 1;
  background: none; border: 1.5px solid transparent; border-radius: 7px;
  color: var(--ink-faint); cursor: pointer; padding: 0.25rem 0.45rem;
}
.cvb-iconbtn:hover { border-color: var(--line); color: var(--ink); background: var(--paper-dim); }
.cvb-iconbtn:disabled { opacity: 0.3; cursor: default; }
.cvb-iconbtn--danger:hover { color: var(--danger); }

.cvb-field { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; min-width: 0; }
.cvb-field > label { font-size: 0.82rem; color: var(--ink-faint); }
.cvb-field input[type="text"], .cvb-field input[type="email"], .cvb-field input[type="tel"],
.cvb-field input[type="url"], .cvb-field textarea, .cvb-field select {
  font: inherit; color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line); border-radius: 8px;
  padding: 0.45rem 0.6rem;
  width: 100%;
}
.cvb-field textarea { resize: vertical; min-height: 4.2rem; }
.cvb-hint { font-size: 0.8rem; color: var(--ink-faint); }
/* text controls show focus with their border; file and checkbox inputs
   have no border of their own and keep the site's focus ring */
.cvb-field input:not([type="file"]):not([type="checkbox"]):focus, .cvb-field textarea:focus, .cvb-field select:focus {
  outline: none; border-color: var(--ink);
}
.cvb-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.cvb-row .cvb-field { flex: 1 1 42%; }
.cvb-row .cvb-field--narrow { flex: 0 1 30%; }
.cvb-check { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; color: var(--ink-soft); }

.cvb-entry {
  border: 1.5px dashed var(--line); border-radius: 10px;
  padding: 0.7rem;
  display: flex; flex-direction: column; gap: 0.55rem;
}
/* the entry toolbar is a normal row above the fields so it never overlaps
   the first field's label on narrow panels */
.cvb-entry-tools {
  display: flex; justify-content: flex-end; gap: 0.15rem;
  margin-block: -0.3rem -0.35rem; margin-inline: 0 -0.3rem;
}
.cvb-add { align-self: flex-start; }

.cvb-photo-row { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.cvb-photo-thumb {
  width: 56px; height: 56px; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--line); display: none;
}
.cvb-photo-thumb.has-photo { display: block; }
.cvb-title-input input { font-weight: 600; }

/* ---------- preview panel ---------- */

/* the preview sticks beside the form; a multi-page CV is taller than the
   viewport, so the panel scrolls on its own instead of hiding its bottom
   until the form has been scrolled to the end */
.cvb-preview-wrap {
  position: sticky; top: 1rem; min-width: 0;
  max-height: calc(100vh - 2rem); overflow-y: auto; scrollbar-gutter: stable;
  padding-bottom: 0.5rem;
}
@media (max-width: 980px) { .cvb-preview-wrap { position: static; max-height: none; overflow: visible; } }
.cvb-preview-bar {
  display: flex; align-items: center; gap: 0.8rem;
  margin-bottom: 0.6rem; flex-wrap: wrap;
}
.cvb-preview-bar .small-note { margin: 0; flex: 1; min-width: 200px; }
.cvb-preview-frame {
  border: 2px solid var(--ink); border-radius: 6px;
  background: var(--paper-dim);
  padding: 14px; overflow: hidden;
  box-shadow: var(--shadow-soft);
}
.cvb-preview-scale { transform-origin: top left; }
.cvb-preview-scale .cv-page { box-shadow: 0 4px 18px rgba(47, 42, 36, 0.22); }
[dir="rtl"] .cvb-preview-scale { transform-origin: top right; }

/* ---------- print: only the CV ---------- */

#print-root { display: none; }

@media print {
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; }
  html, body { background: #fff !important; margin: 0 !important; padding: 0 !important; }
}
