/* Editor-only styles. Loaded on editor.html only. */

.editor { width: 100%; max-width: none; }
.editor-intro h1 { margin-bottom: 0.5rem; }

/* ---------- Toolbar ---------- */

.editor-toolbar {
  position: sticky;
  top: var(--topbar);
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0;
  margin-bottom: 1.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.toolbar-spacer { flex: 1 1 auto; }

.save-status {
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.save-status[data-tone="ok"] { color: var(--accent); }
.save-status[data-tone="error"] { color: var(--bad); font-weight: 600; }

.btn {
  font: inherit;
  font-size: 0.875rem;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-small { font-size: 0.8rem; padding: 0.25rem 0.6rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); }

[data-message] { margin-bottom: 1.25rem; }
[data-message][data-tone="ok"] { border-left-color: var(--accent); color: var(--text); }
[data-message][data-tone="error"] { border-left-color: var(--bad); color: var(--bad); }

/* ---------- Form ---------- */

.editor-form fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 0 0 1.5rem;
  background: var(--surface);
}

.editor-form legend {
  font-weight: 600;
  padding: 0 0.5rem;
  font-size: 1rem;
}

/* ---------- Collapsing ----------
   Sections and entry rows both collapse the same way: a heading that is a
   button, a chevron that turns, and a body hidden with [hidden] rather than
   display:none in CSS, so the state lives in one place the script owns. */

/* The browser's own `[hidden] { display: none }` is a user-agent rule, so any
   author rule that sets `display` beats it — `.field-grid { display: grid }` did
   exactly that, and collapsing an entry row set the attribute while the fields
   stayed on screen. This puts `hidden` back in charge for the whole editor. */
.editor [hidden] { display: none !important; }

.section-toggle,
.entry-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.15rem 0;
  font: inherit;
  color: inherit;
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
}

.section-toggle:hover,
.entry-toggle:hover { color: var(--accent); }

.section-toggle:focus-visible,
.entry-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius);
}

.chevron {
  flex: none;
  width: 0.9em;
  height: 0.9em;
  color: var(--muted);
  transition: transform 0.15s ease;
}

[aria-expanded="true"] > .chevron { transform: rotate(90deg); }

/* A collapsed section keeps its frame but stops reserving a body's worth of
   padding, so eight closed sections read as a list rather than eight boxes. */
.editor-form fieldset[data-open="false"] { padding-bottom: 0.35rem; }

.entry-editor[data-open="false"] { padding-bottom: 0.6rem; }
.entry-editor[data-open="false"] .entry-editor-head {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.editor-form label,
.field-grid label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.editor-form input,
.editor-form textarea,
.editor-form select {
  border-color: var(--border-strong);
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.5rem 0.65rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.editor-form select {
  /* Native arrow, but the light/dark token colours rather than the OS default. */
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 1.1rem) 55%, calc(100% - 0.75rem) 55%;
  background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
  background-repeat: no-repeat;
  padding-right: 2rem;
  cursor: pointer;
}

.editor-form input:focus,
.editor-form textarea:focus,
.editor-form select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 12%, transparent); }

.editor-form textarea { resize: vertical; line-height: 1.55; }
.editor-form input[type="file"] { padding: 0.4rem; font-size: 0.85rem; }

.editor-form small {
  display: block;
  margin-top: 0.3rem;
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--muted);
}

.optional { font-weight: 400; text-transform: none; opacity: 0.7; }

.required {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.05rem 0.3rem;
  vertical-align: 0.05em;
}

.grid-2,
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1rem;
}

.grid-2 > label,
.field-grid > label.full { grid-column: auto; }
.field-grid > label.full { grid-column: 1 / -1; }

@media (max-width: 38rem) {
  .grid-2,
  .field-grid { grid-template-columns: 1fr; }
}

/* ---------- Repeatable entries ---------- */

.entry-editor-list { display: grid; gap: 1rem; margin-bottom: 1rem; }

.entry-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--bg);
}

.entry-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.entry-editor-head h3 {
  margin: 0;
  min-width: 0;
  flex: 1 1 auto;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

/* The row title can be long — a pasted job title, a full certificate name.
   Truncate it rather than letting it push Remove off the row. */
.entry-toggle > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Reordering ---------- */

.entry-grip {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: var(--radius);
  cursor: grab;
}
.entry-grip svg { width: 1.1rem; height: 1.1rem; }
.entry-grip:hover { color: var(--accent); background: color-mix(in srgb, var(--primary) 12%, transparent); }
.entry-grip:active { cursor: grabbing; }
.entry-grip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.entry-editor.is-dragging { opacity: 0.4; }

/* Where the row will land. A 2px rule rather than a gap, so nothing reflows
   mid-drag and the pointer keeps hitting the row it is over. */
.entry-editor.drop-before,
.entry-editor.drop-after { position: relative; }
.entry-editor.drop-before::before,
.entry-editor.drop-after::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}
.entry-editor.drop-before::before { top: -0.55rem; }
.entry-editor.drop-after::after { bottom: -0.55rem; }

/* Touch devices get no HTML5 drag events; the grip is still a focusable button
   with arrow keys, so it stays useful rather than becoming dead weight. */
@media (hover: none) {
  .entry-grip { cursor: default; }
}

/* ---------- Counts and list tools ---------- */

.section-count {
  flex: none;
  min-width: 1.35rem;
  margin-left: 0.15rem;
  padding: 0.05rem 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.section-toggle:hover .section-count { color: var(--accent); border-color: var(--accent); }

.list-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.list-count { margin: 0; font-size: 0.8rem; }

/* A second heading inside a fieldset — Languages under Basics. Sits below the
   legend in weight, so the section still reads as one thing. */
.editor-form .subhead {
  margin: 1.5rem 0 0.4rem;
  padding-top: 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  border-top: 1px solid var(--border);
}

.grip-inline { letter-spacing: -0.1em; }

.empty { font-style: italic; }

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

.skills-editor {
  margin-top: 0.3rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.chips:not(:empty) { margin-bottom: 0.5rem; }

.chips li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 0.1rem 0.3rem 0.1rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text);
}

.chip-remove {
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.2rem;
}
.chip-remove:hover { color: var(--bad); }

.skills-editor input[type="text"] { border: 0 !important; background: none !important; padding: 0.2rem 0 !important; }
.skills-editor input[type="text"]:focus { box-shadow: none !important; }

/* The text box takes the room; the library button sits at the end of the line. */
.skills-entry {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.skills-entry input[type="text"] { flex: 1 1 auto; min-width: 6rem; }

.btn-small {
  flex: none;
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
}

/* ---------- Skill library picker ---------- */

.swal-filter {
  width: 100%;
  margin: 0 0 0.75rem;
  padding: 0.45rem 0.6rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.swal-library {
  max-height: 48vh;
  overflow-y: auto;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
}

.swal-library section + section { margin-top: 0.9rem; }

.swal-library h4 {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.swal-library ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.15rem 0.75rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.swal-library label {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.15rem 0;
  font-size: 0.88rem;
  cursor: pointer;
}

.swal-library input[type="checkbox"] { accent-color: var(--accent); flex: none; }
.swal-library li.on label,
.swal-library input:disabled + span { color: var(--muted); cursor: default; }

/* The note after a skill: which field it came from, or its German label. */
.swal-library em {
  font-style: normal;
  font-size: 0.76rem;
  color: var(--muted);
  margin-left: auto;
  padding-left: 0.5rem;
  text-align: right;
}

.swal-textarea {
  width: 100%;
  font: inherit;
  font-size: 0.88rem;
  line-height: 1.5;
  padding: 0.6rem 0.7rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
}

.swal-check {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}

.swal-check input { accent-color: var(--accent); margin-top: 0.15rem; }

/* ---------- Image upload ---------- */

.image-editor {
  margin-top: 0.3rem;
  padding: 0.75rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.image-preview img {
  display: block;
  max-width: 100%;
  max-height: 14rem;
  width: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.6rem;
}

.image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

/* ---------- Help ---------- */

.editor-help {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--muted);
}

.editor-help h2 { font-size: 1rem; }

/* ---------- SweetAlert2 ---------- */
/* The library ships its own light palette; these rules put it on the site's
   tokens so dialogs follow light/dark with everything else. Buttons come from
   .btn via buttonsStyling:false in editor.js. */

.swal2-popup.editor-swal {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
}

.editor-swal .swal2-title {
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 600;
}

.editor-swal .swal2-html-container {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: left;
  margin-top: 0.75rem;
}

.editor-swal .swal2-actions { gap: 0.5rem; margin-top: 1.25rem; }
.editor-swal .swal2-validation-message {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--warn);
}

.editor-swal .swal2-input {
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: none;
}
.editor-swal .swal2-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 12%, transparent); }

.swal-list {
  margin: 0;
  padding-left: 1.15rem;
  text-align: left;
}
.swal-list li { margin-bottom: 0.4rem; }

.swal-note { margin: 0.8rem 0 0; font-size: 0.85rem; }
.swal-note:first-child { margin-top: 0; }

.swal-code {
  margin: 0.5rem 0;
  padding: 0.6rem 0.8rem;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: var(--text);
  overflow-x: auto;
  white-space: pre;
}

/* Toasts are narrow — keep the title on one line and the text readable. */
.swal2-toast.editor-swal { border: 1px solid var(--border); }
.swal2-toast.editor-swal .swal2-title { font-size: 0.9rem; margin: 0; }

/* Drag and Drop Zones */
.icon-ok { color: var(--ok); }

/* One line of counts for everything loaded. */
.data-summary { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.data-summary li { padding: .3rem .75rem; border: 1px solid var(--border-default, #d0d7de); border-radius: 99px; font-size: .85rem; background: var(--bg-surface, transparent); }
.data-summary li[data-empty="true"] { opacity: .55; }
.data-summary strong { font-variant-numeric: tabular-nums; }

/* Skills radar */
.skills-radar { min-height: 120px; max-width: 640px; margin: 0 auto 1rem; }
.radar-notes p { margin: .3rem 0; }

/* Reuse the guide's typography, colours and header. */
.editor-page { padding-top: 2.5rem; padding-bottom: 3rem; }
.editor-intro { margin-bottom: 1.5rem; }
.editor-intro h1 { font-size: clamp(2rem, 4vw, 3rem); }
.editor p { margin-bottom: .75rem; max-width: 75ch; }
.editor .lede { font-size: 1.15rem; }
.editor .muted { color: var(--muted); }
.editor-intro-help summary { cursor: pointer; color: var(--primary); }
.editor-intro-help[open] summary { margin-bottom: .75rem; }
.editor .subhead { margin: 1.5rem 0 .75rem; }
.editor-form legend { max-width: 100%; }
.editor-form input, .editor-form select, .editor-form textarea { min-width: 0; }
.editor-form label { min-width: 0; }
.skills-entry { flex-wrap: wrap; }
.editor .btn { min-height: 44px; }
.btn-icon-spacing { margin-right: .35rem; }
.editor .visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.editor-swal { max-width: calc(100vw - 2rem); }
@media (max-width: 38rem) {
  .editor-toolbar { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor-toolbar .save-status { grid-column: 1 / -1; }
  .editor-toolbar .toolbar-spacer { display: none; }
  .editor-form fieldset { padding: .85rem; min-width: 0; }
  .entry-editor { min-width: 0; }
  .field-grid, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .skills-entry input[type="text"] { flex-basis: 100%; }
}
