/* ==========================================================================
   CV builder. Layered on the tokens in styles.css — no colour is invented
   here, so both themes follow the rest of the site for free.
   ========================================================================== */

main { padding-block: 44px 72px; }

.cv-head { max-width: 760px; margin-inline: auto; text-align: center; }
.cv-head .eyebrow { justify-content: center; }
.cv-head h1 { margin: 16px 0 12px; font-size: clamp(1.9rem, 4.4vw, 3rem); line-height: 1.22; font-weight: 800; }
.cv-head h1 em { font-style: normal; color: var(--teal); }
.cv-head p { margin: 0; color: var(--muted); font-size: .95rem; line-height: 1.85; }

/* ------------------------------------------------------------- progress -- */

.cv-progress {
  display: flex;
  justify-content: center;
  gap: clamp(6px, 3vw, 34px);
  margin: 36px auto 26px;
  padding: 0;
  list-style: none;
  counter-reset: none;
}
.cv-progress li {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
  transition: color .2s;
}
.cv-progress b {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  font-family: Inter, sans-serif;
  font-size: .8rem;
  transition: background .2s, color .2s, border-color .2s;
}
.cv-progress .is-current { color: var(--ink); }
.cv-progress .is-current b { border-color: var(--teal); background: var(--teal); color: #fff; }
.cv-progress .is-done b { border-color: var(--teal); color: var(--teal); }
.cv-progress .is-done b::before { content: "✓"; }
.cv-progress .is-done b { font-size: .9rem; }
/* The number is replaced by a tick once the step is behind you. */
.cv-progress .is-done b > * { display: none; }

@media (max-width: 720px) {
  .cv-progress li span { display: none; }
  .cv-progress { gap: 10px; }
}

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

.cv-form {
  max-width: 860px;
  margin-inline: auto;
  padding: clamp(20px, 4vw, 38px);
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.cv-step { min-width: 0; margin: 0; padding: 0; border: 0; }
/* A fieldset with display:grid needs to opt back in to [hidden]. */
.cv-step[hidden] { display: none; }

.cv-step legend {
  padding: 0;
  margin-bottom: 6px;
  font-size: 1.15rem;
  font-weight: 800;
}
.legend-mid { display: block; margin-top: 34px; }
.step-intro { margin: 0 0 22px; color: var(--muted); font-size: .84rem; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
  margin-top: 20px;
}

.field { display: grid; gap: 7px; align-content: start; min-width: 0; }
.field.is-wide { margin-top: 18px; }
.field > span { font-size: .8rem; font-weight: 600; }
.field > span i { font-style: normal; font-weight: 500; color: var(--muted); }
.field.is-required > span::after {
  content: "*";
  margin-inline-start: 4px;
  color: var(--gold);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: .88rem;
  transition: border-color .18s, box-shadow .18s;
}
.field textarea { resize: vertical; min-height: 96px; line-height: 1.7; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--teal) 16%, transparent);
}
.field select {
  appearance: none;
  /* Chevron drawn in the box's own text colour so it survives dark mode. */
  background-image: linear-gradient(45deg, transparent 49%, currentColor 50%, currentColor 56%, transparent 57%),
                    linear-gradient(-45deg, transparent 49%, currentColor 50%, currentColor 56%, transparent 57%);
  background-size: 6px 6px, 6px 6px;
  background-position: left 18px top 55%, left 13px top 55%;
  background-repeat: no-repeat;
  padding-inline-start: 34px;
}
html[dir="ltr"] .field select {
  background-position: right 13px top 55%, right 18px top 55%;
  padding-inline-start: 14px;
  padding-inline-end: 34px;
}

.field-hint { color: var(--muted); font-size: .74rem; line-height: 1.6; }

.field-error {
  display: none;
  color: #b3261e;
  font-style: normal;
  font-size: .74rem;
  font-weight: 600;
}
:root[data-theme="dark"] .field-error { color: #ff9d94; }
.field.has-error input,
.field.has-error select,
.field.has-error textarea { border-color: #b3261e; }
.field.has-error .field-error { display: block; }

/* --------------------------------------------------------- repeat rows -- */

.repeat-list { display: grid; gap: 16px; margin-top: 18px; }

.repeat-row {
  position: relative;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
}
.repeat-row .field-grid { margin-top: 0; }

.row-remove {
  position: absolute;
  inset-inline-end: 12px;
  top: 12px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: color .18s, border-color .18s;
}
.row-remove:hover { color: #b3261e; border-color: #b3261e; }
.row-remove svg { width: 14px; }

.field-until { display: grid; gap: 7px; align-content: start; }
.field-until > label { display: grid; gap: 7px; }
.tick {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  color: var(--muted);
  font-size: .74rem;
  font-weight: 600;
  cursor: pointer;
}
.tick input { width: 15px; height: 15px; flex: 0 0 auto; accent-color: var(--teal); }

.add-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 11px 20px;
  border: 1.5px dashed var(--line);
  border-radius: 13px;
  background: none;
  color: var(--teal);
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .18s, background .18s;
}
.add-row:hover { border-color: var(--teal); background: var(--teal-light); }
.add-row svg { width: 15px; }

/* -------------------------------------------------------------- chips ---- */

.chip-input {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 18px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: var(--paper);
}
.chip-input:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--teal) 16%, transparent);
}
.chip-input input {
  flex: 1 1 160px;
  min-width: 120px;
  padding: 5px 2px;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: .86rem;
}
.chip-input input:focus { outline: none; }

.chip-list { display: contents; margin: 0; padding: 0; list-style: none; }
.chip-list li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--teal-light);
  color: var(--teal);
  font-size: .78rem;
  font-weight: 600;
}
.chip-list button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  line-height: 1;
  cursor: pointer;
  opacity: .6;
}
.chip-list button:hover { opacity: 1; }

.chip-suggest { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }
.chip-suggest button {
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: .75rem;
  cursor: pointer;
  transition: color .18s, border-color .18s;
}
.chip-suggest button:hover { color: var(--teal); border-color: var(--teal); }

/* ---------------------------------------------------------- languages --- */

.language-grid { display: grid; gap: 12px; margin-top: 18px; }
.language-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--paper);
}
.language-row > span { font-size: .85rem; font-weight: 600; }
.language-row select {
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: .8rem;
}

/* ------------------------------------------------------------- review --- */

.review-card {
  display: grid;
  gap: 2px;
  margin-top: 20px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  font-size: .85rem;
}
.review-card dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.review-card dt { color: var(--muted); font-size: .78rem; }
.review-card dd { margin: 0; font-weight: 600; }
.review-card .review-missing { color: var(--muted); font-weight: 400; }

/* ------------------------------------------------------------ captcha --- */

.captcha-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-start;
  margin-top: 24px;
}
.captcha-image { position: relative; flex: 0 0 auto; }
.captcha-image img {
  display: block;
  width: 240px;
  height: 80px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--paper);
}
.captcha-refresh {
  position: absolute;
  inset-inline-end: 8px;
  bottom: 8px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, .9);
  color: #0a5664;
  cursor: pointer;
}
.captcha-refresh svg { width: 14px; }
.captcha-row .field { flex: 1 1 220px; }

/* Off-screen rather than display:none — a bot that only skips hidden inputs
   still fills this one in. */
.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.consent { margin: 22px 0 0; color: var(--muted); font-size: .75rem; line-height: 1.7; }

/* ---------------------------------------------------------- navigation -- */

.form-error {
  display: flex;
  gap: 8px;
  margin: 22px 0 0;
  padding: 13px 16px;
  border: 1px solid rgba(179, 38, 30, .3);
  border-radius: 13px;
  background: rgba(179, 38, 30, .07);
  color: #b3261e;
  font-size: .82rem;
  font-weight: 600;
  line-height: 1.6;
}
.form-error[hidden] { display: none; }
:root[data-theme="dark"] .form-error { color: #ff9d94; }

.cv-nav { display: flex; gap: 12px; margin-top: 30px; }

.btn-primary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 13px 28px;
  border-radius: 13px;
  font: inherit;
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s, background .18s;
}
.btn-primary {
  border: 0;
  background: var(--teal);
  color: #fff;
  box-shadow: 0 12px 30px color-mix(in srgb, var(--teal) 28%, transparent);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); }
.btn-primary:disabled { opacity: .6; cursor: progress; transform: none; }
.btn-ghost {
  border: 1.5px solid var(--line);
  background: none;
  color: var(--ink);
}
.btn-ghost:hover { border-color: var(--teal); color: var(--teal); }
.btn-primary[hidden], .btn-ghost[hidden] { display: none; }

#btn-next, #btn-submit { margin-inline-start: auto; }

.btn-spinner {
  display: none;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.is-working .btn-spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn-spinner { animation-duration: 2s; }
  .btn-primary:hover:not(:disabled) { transform: none; }
}

/* ------------------------------------------------------------- result --- */

.cv-result {
  max-width: 860px;
  margin: 28px auto 0;
  padding: clamp(22px, 4vw, 38px);
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.cv-result[hidden] { display: none; }

.result-head { display: flex; align-items: center; gap: 12px; }
.result-head svg {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  padding: 7px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  stroke-width: 2.6;
}
.result-head h2 { margin: 0; font-size: 1.3rem; font-weight: 800; }

.credentials { margin-top: 22px; }
.credentials p { margin: 0 0 14px; color: var(--muted); font-size: .82rem; line-height: 1.7; }
.cred-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 30px;
  align-items: center;
  padding: 18px 22px;
  border: 1px dashed var(--teal);
  border-radius: 16px;
  background: var(--teal-light);
}
.cred-grid > div { display: grid; gap: 3px; }
.cred-grid small { color: var(--muted); font-size: .72rem; }
.cred-grid b {
  font-family: "DejaVu Sans Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 1.05rem;
  letter-spacing: .04em;
  /* Credentials are Latin whatever the page direction. */
  unicode-bidi: isolate;
}
.cred-grid .btn-ghost { margin-inline-start: auto; padding: 9px 18px; }

.result-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.result-note { margin: 18px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.7; }

@media (max-width: 560px) {
  .cv-nav { flex-direction: column-reverse; }
  #btn-next, #btn-submit { margin-inline-start: 0; }
  .cv-nav button { width: 100%; }
  .cred-grid .btn-ghost { margin-inline-start: 0; width: 100%; }
}

/* ---------------------------------------------------------------- photo -- */

.avatar-field {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  margin-top: 20px;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: var(--paper);
}

.avatar-preview {
  position: relative;
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--card);
  overflow: hidden;
  color: var(--muted);
}
.avatar-preview svg { width: 38px; stroke-width: 1.5; }
.avatar-preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar-preview img[hidden] { display: none; }
.avatar-preview.has-photo { border-color: var(--gold); }

.avatar-copy { display: grid; gap: 5px; min-width: 0; }
.avatar-copy b { font-size: .82rem; font-weight: 600; }
.avatar-copy b i { font-style: normal; font-weight: 500; color: var(--muted); }
.avatar-copy small { color: var(--muted); font-size: .74rem; line-height: 1.6; }

.avatar-buttons { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 7px; }

.avatar-pick, .avatar-clear {
  display: inline-flex;
  align-items: center;
  padding: 9px 18px;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .18s, color .18s;
}
.avatar-pick:hover, .avatar-clear:hover { border-color: var(--teal); color: var(--teal); }
.avatar-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.avatar-pick:focus-within { border-color: var(--teal); box-shadow: 0 0 0 4px color-mix(in srgb, var(--teal) 16%, transparent); }
.avatar-clear[hidden] { display: none; }

/* Not inside a .field, so it needs its own visibility switch. */
#avatar-error { display: none; margin-top: 4px; }
.avatar-field.has-error #avatar-error { display: block; }
.avatar-field.has-error { border-color: #b3261e; }

@media (max-width: 520px) {
  .avatar-field { flex-direction: column; align-items: center; text-align: center; }
  .avatar-buttons { justify-content: center; }
}
