/* ============================================================
   Scale Nearshoring — CV Builder app + CV document styles
   (brand tokens come from brand.css)
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sn-font);
  color: var(--sn-ink);
  background: #e9eef5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: minmax(420px, 560px) 1fr;
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}
.pane-form {
  background: var(--sn-white);
  border-right: 1px solid var(--sn-gray-cool);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.pane-preview {
  background: #dde4ee;
  overflow: auto;
  min-width: 0;
  position: relative;
}

/* ---------- Form header / progress ---------- */
.form-top {
  padding: 20px 28px 0;
  border-bottom: 1px solid var(--sn-gray-cool);
  background: var(--sn-white);
}
.brandbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.brandbar img { height: 30px; }
.brandbar .tagline { font-size: 12px; color: var(--sn-ink-70); font-weight: 600; }

.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 2px;
  padding-bottom: 14px;
}
.step-chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--sn-ink-70);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.step-chip:hover { background: var(--sn-offwhite); }
.step-chip .num {
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--sn-gray-cool); color: var(--sn-white);
  font-size: 11px; font-weight: 800;
}
.step-chip.active { color: var(--sn-blue); background: var(--sn-offwhite); }
.step-chip.active .num { background: var(--sn-blue); }
.step-chip.done .num { background: var(--sn-green); }
.step-chip.error .num { background: #d64545; }

.progress-track { height: 4px; background: var(--sn-gray-cool); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--sn-green); transition: width .3s ease; }

/* ---------- Form body ---------- */
.form-body { flex: 1; min-height: 0; overflow-y: auto; padding: 26px 28px 28px; }
.step-head { margin-bottom: 22px; }
.step-eyebrow { font-size: 13px; font-weight: 700; color: var(--sn-green); margin: 0 0 4px; }
.step-title { font-size: 26px; font-weight: 800; color: var(--sn-blue); margin: 0 0 6px; line-height: 1.15; }
.step-sub { font-size: 14px; color: var(--sn-ink-70); margin: 0; line-height: 1.5; }

/* ---------- Fields ---------- */
.field { margin-bottom: 18px; }
.field-label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.field-label .lbl { font-size: 13px; font-weight: 700; color: var(--sn-ink); }
.field-label .req { color: #d64545; margin-left: 2px; }
.field-label .opt { font-size: 11px; font-weight: 600; color: var(--sn-ink-70); }
.counter { font-size: 11px; font-weight: 600; color: var(--sn-ink-70); font-variant-numeric: tabular-nums; }
.counter.over { color: #d64545; }

.input, .textarea, .select {
  width: 100%;
  font-family: var(--sn-font);
  font-size: 14px;
  color: var(--sn-ink);
  background: var(--sn-white);
  border: 1px solid var(--sn-border);
  border-radius: var(--sn-radius-sm);
  padding: 10px 12px;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { resize: vertical; min-height: 88px; line-height: 1.5; }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--sn-blue-light);
  box-shadow: 0 0 0 3px rgba(66,143,218,.18);
}
.input.invalid, .textarea.invalid, .select.invalid { border-color: #d64545; }
.input.at-limit, .textarea.at-limit {
  border-color: #d64545;
  background: #fdf0f0;
  box-shadow: 0 0 0 3px rgba(214,69,69,.12);
}
.field-error { font-size: 12px; color: #d64545; margin-top: 5px; font-weight: 600; }
.field-hint { font-size: 12px; color: var(--sn-ink-70); margin-top: 5px; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ---------- Repeatable item cards ---------- */
.repeat-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.repeat-count { font-size: 12px; font-weight: 700; color: var(--sn-ink-70); }
.repeat-count b { color: var(--sn-blue); }
.item-card {
  border: 1px solid var(--sn-gray-cool);
  border-radius: var(--sn-radius-lg);
  padding: 16px 16px 4px;
  margin-bottom: 14px;
  background: var(--sn-white);
  position: relative;
}
.item-card .item-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin: -4px -4px 12px; padding-bottom: 10px;
  border-bottom: 1px dashed var(--sn-gray-cool);
}
.item-card .item-idx { font-size: 12px; font-weight: 800; color: var(--sn-blue); display: flex; align-items: center; gap: 8px; }
.item-card .item-idx .dot { width: 18px; height: 18px; border-radius: 4px; background: var(--sn-green); display:grid; place-items:center; color:#fff; font-size:11px; }
.icon-btn {
  border: none; background: transparent; cursor: pointer; color: var(--sn-ink-70);
  padding: 5px; border-radius: 5px; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 5px;
}
.icon-btn:hover { background: #fbe9e9; color: #d64545; }
.add-btn {
  width: 100%; padding: 12px; border: 1.5px dashed var(--sn-blue-light);
  background: rgba(66,143,218,.05); color: var(--sn-blue);
  border-radius: var(--sn-radius); font-weight: 700; font-size: 13.5px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px; transition: background .15s;
}
.add-btn:hover { background: rgba(66,143,218,.12); }
.add-btn:disabled { opacity: .45; cursor: not-allowed; border-style: solid; }

/* slider */
.slider-row { display: flex; align-items: center; gap: 12px; }
.slider-row input[type=range] { flex: 1; accent-color: var(--sn-blue-light); }
.slider-val { font-size: 13px; font-weight: 800; color: var(--sn-blue); min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }

/* bullet list editor */
.bullet-list { display: flex; flex-direction: column; gap: 8px; }
.bullet-row { display: flex; align-items: center; gap: 8px; }
.bullet-row .bullet-dot { flex: 0 0 auto; width: 8px; height: 8px; background: var(--sn-blue-light); clip-path: polygon(0 0, 100% 50%, 0 100%); }
.bullet-row .input { flex: 1; min-width: 0; padding: 8px 11px; }
.bullet-add {
  margin-top: 8px; font-family: var(--sn-font); font-size: 12.5px; font-weight: 700;
  color: var(--sn-blue); background: rgba(66,143,218,.06);
  border: 1px dashed var(--sn-blue-light); border-radius: var(--sn-radius-sm);
  padding: 7px 12px; cursor: pointer;
}
.bullet-add:hover { background: rgba(66,143,218,.12); }
.bullet-add:disabled { opacity: .45; cursor: not-allowed; border-style: solid; }

/* ---------- Footer nav ---------- */
.form-nav {
  flex: 0 0 auto;
  display: flex; gap: 12px; padding: 14px 28px;
  background: var(--sn-white);
  border-top: 1px solid var(--sn-gray-cool);
  box-shadow: 0 -4px 12px rgba(0,0,0,.04);
}
.pane-form { position: relative; }
.btn {
  font-family: var(--sn-font); font-size: 14px; font-weight: 700; cursor: pointer;
  border-radius: var(--sn-radius); padding: 12px 22px; border: 1px solid transparent;
  transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--sn-green); color: #2b3a0c; }
.btn-primary:hover { background: #9fbf45; }
.btn-blue { background: var(--sn-blue-deep); color: #fff; }
.btn-blue:hover { background: #055a91; }
.btn-ghost { background: var(--sn-white); color: var(--sn-blue); border-color: var(--sn-gray-cool); }
.btn-ghost:hover { background: var(--sn-offwhite); }
.btn-ghost:disabled { opacity: .4; cursor: not-allowed; }
.flex-grow { flex: 1; }

/* ---------- Photo cropper ---------- */
.photo-block { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.drop-zone {
  width: 170px; height: 170px; flex: 0 0 auto;
  border: 2px dashed var(--sn-blue-light); border-radius: var(--sn-radius-lg);
  background: var(--sn-offwhite); display: grid; place-items: center; text-align: center;
  cursor: pointer; color: var(--sn-blue); padding: 12px; transition: background .15s;
}
.drop-zone:hover, .drop-zone.drag { background: rgba(66,143,218,.12); }
.drop-zone .dz-ico { font-size: 30px; margin-bottom: 8px; }
.drop-zone .dz-t { font-size: 12.5px; font-weight: 700; line-height: 1.4; }
.drop-zone .dz-s { font-size: 11px; color: var(--sn-ink-70); margin-top: 4px; }

.crop-stage {
  width: 240px; height: 240px; border-radius: var(--sn-radius-lg); overflow: hidden;
  position: relative; background: #1d2733; cursor: grab; touch-action: none; flex: 0 0 auto;
  box-shadow: var(--sn-shadow-soft);
}
.crop-stage.dragging { cursor: grabbing; }
.crop-stage canvas { display: block; width: 100%; height: 100%; }
.crop-grid { position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.25) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.25) 1px, transparent 1px);
  background-size: 33.33% 33.33%; }
.crop-controls { flex: 1; min-width: 200px; }
.crop-controls .zoom-lab { font-size: 12px; font-weight: 700; color: var(--sn-ink); margin-bottom: 6px; display:flex; justify-content: space-between; }
.crop-controls input[type=range] { width: 100%; accent-color: var(--sn-blue-light); }
.crop-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.mini-btn { font-size: 12px; font-weight: 700; padding: 8px 12px; border-radius: var(--sn-radius-sm); border: 1px solid var(--sn-gray-cool); background: #fff; cursor: pointer; color: var(--sn-blue); }
.mini-btn:hover { background: var(--sn-offwhite); }
.photo-preview-sq { width: 78px; height: 78px; border-radius: 6px; overflow: hidden; border: 2px solid var(--sn-gray-cool); }
.photo-preview-sq img { width: 100%; height: 100%; object-fit: cover; display:block; }

/* ---------- Tweak variants ---------- */
/* Focus mode: distraction-free form, preview hidden (still on Review step) */
.app.layout-focus { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr); }
.app.layout-focus .pane-preview { display: none; }
.app.layout-focus .form-body > div { max-width: 720px; margin: 0 auto; }
.app.layout-focus .form-top { padding-left: 0; padding-right: 0; }
.app.layout-focus .form-top > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.app.layout-focus .form-nav { justify-content: center; }
.app.layout-focus .form-nav > .btn { min-width: 150px; }

/* Compact density */
.app.density-compact .form-body { padding: 18px 22px 110px; }
.app.density-compact .field { margin-bottom: 12px; }
.app.density-compact .item-card { padding: 12px 12px 2px; margin-bottom: 10px; }
.app.density-compact .step-title { font-size: 22px; }
.app.density-compact .input, .app.density-compact .textarea, .app.density-compact .select { padding: 8px 10px; }
.app.density-compact .step-head { margin-bottom: 16px; }

/* CTA color */
.app.cta-blue .btn-primary { background: var(--sn-blue-deep); color: #fff; }
.app.cta-blue .btn-primary:hover { background: #055a91; }

/* ============================================================
   CV DOCUMENT
   ============================================================ */
.cv-scaler { display: flex; flex-direction: column; align-items: center; gap: 26px; padding: 32px; }
.cv-toolbar {
  position: sticky; top: 0; z-index: 20; width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px; background: rgba(255,255,255,.92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--sn-gray-cool);
}
.cv-toolbar .ttl { font-size: 13px; font-weight: 800; color: var(--sn-blue); }
.cv-toolbar .meta { font-size: 12px; color: var(--sn-ink-70); }
.cv-toolbar .acts { display: flex; gap: 10px; }

.cv-doc {
  width: 816px; background: #fff; position: relative;
  box-shadow: 0 10px 40px rgba(0,0,0,.18); flex: 0 0 auto;
  font-size: 12px; color: var(--sn-ink);
}

/* running header — repeats at the top of every printed page */
.cv-table { width: 100%; border-collapse: collapse; }
.cv-table > thead > tr > td { padding: 0 0 12px; }
.cv-table > tbody > tr > td { padding: 0; }
.cv-runhead { position: relative; height: 46px; background: var(--sn-blue); }
.cv-runhead .runlogo { position: absolute; right: 34px; top: 12px; height: 22px; }

/* hero (page 1 only) — negative top margin cancels the band's bottom gap so the
   band + hero read as one solid blue block on page 1 (no white line). */
.cv-hero { position: relative; height: 240px; background: var(--sn-blue); margin-top: -12px; }
.cv-photo {
  position: absolute; top: 34px; left: 34px; width: 168px; height: 168px;
  background: var(--sn-white); border: 4px solid #fff; border-radius: var(--cv-photo-radius, 6px); overflow: hidden;
  box-shadow: 0 4px 14px rgba(0,0,0,.25); display: grid; place-items: center;
}
.cv-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cv-photo .ph-ico { color: #c6d4e6; font-size: 46px; }
.cv-id { position: absolute; left: 230px; right: 30px; top: 34px; height: 168px;
  display: flex; flex-direction: column; justify-content: center; }
.cv-id .name { font-size: 34px; font-weight: 900; color: var(--sn-green); line-height: 1.04; letter-spacing: -.5px; }
.cv-id .title { font-size: 17px; font-weight: 600; color: #fff; margin-top: 8px; letter-spacing: .3px; }

/* body columns — sidebar has its own page-1 height and never stretches with the
   main column, so the blue panel can't fragment/orphan onto page 2. */
.cv-cols { display: grid; grid-template-columns: 300px 1fr; align-items: start; }
.cv-side { background: var(--sn-blue-light); color: #fff; padding: 8px 24px 26px; min-height: 720px; }
.cv-main { background: #fff; padding: 14px 30px 26px; min-width: 0; }

/* section header (green pennant tab) */
.sec { margin-top: 18px; }
.sec:first-child { margin-top: 6px; }
.sec-tab {
  display: inline-block; position: relative; background: var(--sn-green); color: #fff;
  font-weight: 800; font-size: 13px; letter-spacing: .3px; padding: 7px 16px;
  margin-bottom: 11px;
  box-shadow: 4px 4px 0 rgba(0,0,0,.16); text-transform: none;
}
.cv-side .sec-tab { box-shadow: 4px 4px 0 rgba(0,0,0,.18); }

/* sidebar content */
.cv-side .edu-item { margin-bottom: 12px; }
.cv-side .edu-deg { font-weight: 800; font-size: 12.5px; line-height: 1.25; }
.cv-side .edu-uni { font-size: 11.5px; opacity: .92; margin-top: 2px; line-height: 1.3; }
.cv-side ul { list-style: none; margin: 0; padding: 0; }
.cv-side .blist li { position: relative; padding-left: 16px; margin-bottom: 7px; font-size: 12px; line-height: 1.35; }
.cv-side .blist li::before { content: ""; position: absolute; left: 0; top: 5px;
  width: 8px; height: 8px; background: var(--sn-green);
  clip-path: polygon(0 0, 100% 50%, 0 100%); }
.cv-side .lang-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.cv-side .lang-item .lname { font-size: 12.5px; font-weight: 700; }
.cv-side .lang-item .llvl { font-size: 10.5px; font-weight: 700; background: rgba(255,255,255,.2); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }

/* main content */
.cv-main .summary { font-size: 12px; line-height: 1.55; color: var(--sn-ink); white-space: pre-wrap; }
.cv-main .cert-item { margin-bottom: 9px; padding-left: 16px; position: relative; }
.cv-main .cert-item::before { content: ""; position: absolute; left: 0; top: 5px;
  width: 8px; height: 8px; background: var(--sn-blue-light); clip-path: polygon(0 0, 100% 50%, 0 100%); }
.cv-main .cert-name { font-weight: 800; font-size: 12px; color: var(--sn-blue); line-height: 1.25; }
.cv-main .cert-meta { font-size: 11px; color: var(--sn-ink-70); margin-top: 1px; }
.cv-main .cert-meta a { color: var(--sn-blue-light); }

.skill-item { margin-bottom: 9px; }
.skill-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.skill-name { font-weight: 800; font-size: 12px; color: var(--sn-ink-strong); }
.skill-right { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.skill-yrs { font-size: 10.5px; color: var(--sn-ink-70); font-weight: 600; }
.skill-level {
  font-size: 10px; font-weight: 800; letter-spacing: .3px; text-transform: uppercase;
  padding: 2px 9px; border-radius: 999px; color: #fff; background: var(--sn-blue-light);
}
.skill-level[data-lvl="Basic"]  { background: #9bb0c4; }
.skill-level[data-lvl="Medium"] { background: var(--sn-blue-light); }
.skill-level[data-lvl="Full"]   { background: var(--sn-blue); }
.skill-level[data-lvl="Expert"] { background: var(--sn-green); color: #2b3a0c; }
.skill-desc { font-size: 10.5px; color: var(--sn-ink-70); margin-top: 3px; line-height: 1.35; }

/* full-width area below the two columns (Technical Knowledge, Experience, Projects) */
.cv-wide { padding: 20px 34px 34px; }
.exp-item { margin-bottom: 16px; padding-left: 16px; position: relative; }
.exp-item::before { content: ""; position: absolute; left: 0; top: 4px; bottom: 4px; width: 3px; background: var(--sn-green); border-radius: 3px; }
.exp-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.exp-co { font-weight: 900; font-size: 14px; color: var(--sn-blue); }
.exp-dates { font-size: 11px; font-weight: 700; color: var(--sn-ink-70); white-space: nowrap; }
.exp-role { font-size: 12.5px; font-weight: 700; color: var(--sn-blue-light); margin-top: 1px; }
.exp-scope { font-size: 11.5px; font-style: italic; color: var(--sn-ink-70); margin-top: 3px; }
.exp-meta { font-size: 11.5px; line-height: 1.45; margin-top: 5px; }
.exp-meta .k { font-weight: 800; color: var(--sn-ink-strong); }
.exp-block { margin-top: 6px; }
.exp-sub { font-size: 11px; font-weight: 800; color: var(--sn-ink-strong); text-transform: uppercase; letter-spacing: .3px; }
.exp-bullets { list-style: none; margin: 3px 0 0; padding: 0; }
.exp-bullets li { position: relative; padding-left: 14px; font-size: 11.5px; line-height: 1.45; margin-bottom: 2px; }
.exp-bullets li::before { content: ""; position: absolute; left: 0; top: 5px; width: 7px; height: 7px; background: var(--sn-green); clip-path: polygon(0 0, 100% 50%, 0 100%); }
.proj-item { margin-bottom: 16px; background: var(--sn-offwhite); border-radius: 8px; padding: 14px 16px; border-left: 4px solid var(--sn-green); }
.proj-title { font-weight: 900; font-size: 14px; color: var(--sn-blue); }
.proj-intro { font-size: 11.5px; line-height: 1.45; margin-top: 4px; }
.proj-row { font-size: 11.5px; line-height: 1.5; margin-top: 4px; }
.proj-row .k { font-weight: 800; color: var(--sn-ink-strong); }

.cv-empty-hint { font-size: 11px; color: var(--sn-ink-70); font-style: italic; opacity: .8; }
.cv-placeholder { opacity: .5; }

/* ---------- saved-link modal ---------- */
.save-overlay {
  position: fixed; inset: 0; background: rgba(15,30,50,.5); z-index: 90;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.save-modal {
  background: var(--sn-white); border-radius: var(--sn-radius-lg); max-width: 520px; width: 100%;
  padding: 28px; box-shadow: var(--sn-shadow-panel);
}
.save-modal h3 { margin: 0 0 6px; color: var(--sn-blue); font-size: 20px; }
.save-modal .sm-check {
  width: 44px; height: 44px; border-radius: 50%; background: var(--sn-green);
  display: grid; place-items: center; color: #2b3a0c; font-size: 22px; font-weight: 900; margin-bottom: 14px;
}
.save-modal p { margin: 0 0 16px; font-size: 13.5px; color: var(--sn-ink-70); line-height: 1.55; }
.save-modal .sm-url { display: flex; gap: 8px; margin-bottom: 16px; }
.save-modal .sm-url input {
  flex: 1; min-width: 0; font-family: ui-monospace, monospace; font-size: 12px;
  border: 1px solid var(--sn-gray-cool); border-radius: var(--sn-radius-sm);
  padding: 10px 12px; background: var(--sn-offwhite); color: var(--sn-ink);
}
.save-modal .sm-acts { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- print ---------- */
@media print {
  @page { size: letter; margin: 0.16in 0; }
  @page :first { margin-top: 0; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  html, body { background: #fff; }
  .app { display: block; height: auto; }
  .pane-form, .cv-toolbar, .form-nav, #tweaks-root, .save-overlay { display: none !important; }
  .pane-preview { overflow: visible; background: #fff; }
  .cv-scaler { padding: 0; gap: 0; transform: none !important; zoom: 1 !important; }
  .cv-doc { box-shadow: none; transform: none !important; width: 100%; }
  /* The <thead> band repeats as a running header on pages 2, 3, 4… */
  thead { display: table-header-group; }
  /* Keep atomic blocks from splitting awkwardly across sheets. */
  .exp-item, .proj-item, .skill-item, .cert-item, .edu-item, .lang-item, .exp-block {
    break-inside: avoid; page-break-inside: avoid;
  }
  /* Section titles (green tabs) stay glued to their first element. */
  .sec-tab { break-after: avoid !important; page-break-after: avoid !important; }
  .sec > .sec-tab + * { break-before: avoid !important; page-break-before: avoid !important; }
  .cv-side { break-inside: avoid; page-break-inside: avoid; }
}
