/* Portfolio editor — same ink, paper and one red as the site. */
@font-face { font-family: "Dela Gothic One"; src: url("../fonts/dela-gothic-one-latin.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url("../fonts/space-grotesk-latin.woff2") format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/jetbrains-mono-latin.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }

:root {
  --paper: #f2ede3; --paper-2: #e8e1d3; --card: #faf7f1; --ink: #141312; --ink-2: #3a3834; --muted: #6c685f;
  --line: rgba(20, 19, 18, .18); --accent: #e0402f; --accent-ink: #fff8f0; --ok: #2f7a4a;
  --f-display: "Dela Gothic One", "Arial Black", sans-serif; --f-body: "Space Grotesk", system-ui, sans-serif; --f-mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --paper: #0e0e0d; --paper-2: #1a1917; --card: #141312; --ink: #efe9dc; --ink-2: #bdb6a8; --muted: #8e897f; --line: rgba(239, 233, 220, .16); --accent: #ff5b45; --ok: #6fc28e; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.45; display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code { font-family: var(--f-mono); font-size: .85em; }

/* ---- top bar */
.ed-top { display: flex; align-items: center; gap: 14px; padding: 12px 18px; padding-top: calc(12px + env(safe-area-inset-top)); border-bottom: 2px solid var(--ink); background: var(--paper); flex-wrap: wrap; }
.ed-stamp { display: grid; place-items: center; width: 40px; height: 40px; background: var(--accent); color: var(--accent-ink); text-decoration: none; font-family: var(--f-display); border-radius: 4px; transform: rotate(-5deg); box-shadow: inset 0 0 0 2px var(--accent), inset 0 0 0 4px var(--accent-ink); }
.ed-kicker { margin: 0; font-family: var(--f-mono); font-size: .62rem; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.ed-brand h1 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 1.35rem; line-height: 1; text-transform: uppercase; }
.ed-status { display: flex; align-items: center; gap: 8px; margin: 0 0 0 8px; font-family: var(--f-mono); font-size: .7rem; letter-spacing: .06em; color: var(--muted); }
.ed-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.ed-status.is-dirty i { background: var(--accent); animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .3; } }
.ed-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.ed-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 14px; border: 2px solid var(--ink); background: var(--card); font-weight: 700; font-size: .88rem; box-shadow: 3px 3px 0 var(--ink); transition: transform .15s var(--ease), box-shadow .15s var(--ease); white-space: nowrap; }
.ed-btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.ed-btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.ed-btn--primary { background: var(--accent); color: var(--accent-ink); }
.ed-btn--ghost { box-shadow: none; border-color: var(--line); background: transparent; }
.ed-btn--ghost:hover { box-shadow: none; border-color: var(--ink); }
.ed-btn--sm { min-height: 32px; padding: 0 10px; font-size: .78rem; box-shadow: 2px 2px 0 var(--ink); }

/* ---- layout */
.ed-tabs { display: none; }
.ed-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 190px minmax(360px, 560px) 1fr; }
.ed-nav { border-right: 2px solid var(--ink); padding: 14px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.ed-nav button { display: flex; align-items: baseline; gap: 10px; width: 100%; text-align: left; padding: 9px 10px; border: 0; background: none; border-left: 3px solid transparent; font-weight: 600; }
.ed-nav button span { font-family: var(--f-mono); font-size: .64rem; color: var(--muted); }
.ed-nav button:hover { background: var(--paper-2); }
.ed-nav button[aria-current="true"] { border-left-color: var(--accent); background: var(--card); }
.ed-form { overflow-y: auto; padding: 22px 22px 120px; border-right: 2px solid var(--ink); scroll-behavior: smooth; }
.ed-sec { margin-bottom: 44px; scroll-margin-top: 16px; }
.ed-sec__head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.ed-sec__num { font-family: var(--f-display); font-size: 1.6rem; color: transparent; -webkit-text-stroke: 1.5px var(--ink); }
.ed-sec h2 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 1.3rem; text-transform: uppercase; }
.ed-sec__help { margin: 0 0 16px; color: var(--muted); font-size: .9rem; }

/* ---- fields */
.ed-field { display: grid; gap: 5px; margin-bottom: 14px; }
.ed-field > span, .ed-label { font-family: var(--f-mono); font-size: .64rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ed-field small { color: var(--muted); font-size: .78rem; }
.ed-field small a { color: var(--accent); }
.ed-field input, .ed-field textarea, .ed-field select, .ed-row input, .ed-row textarea {
  width: 100%; padding: 9px 11px; border: 1.5px solid var(--line); background: var(--card); border-radius: 0; transition: border-color .15s, box-shadow .15s;
}
.ed-field textarea, .ed-row textarea { min-height: 76px; resize: vertical; line-height: 1.45; }
.ed-field input:focus, .ed-field textarea:focus, .ed-field select:focus, .ed-row input:focus, .ed-row textarea:focus { outline: none; border-color: var(--ink); box-shadow: 3px 3px 0 var(--accent); }
.ed-field input[type="number"] { max-width: 140px; }
.ed-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.ed-check { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-weight: 600; }
.ed-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.ed-group { border: 1.5px solid var(--line); padding: 14px 14px 2px; margin-bottom: 14px; }
.ed-group > legend { padding: 0 6px; font-family: var(--f-mono); font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink); }

/* list of strings */
.ed-list { display: grid; gap: 6px; margin-bottom: 14px; }
.ed-row { display: flex; gap: 6px; align-items: flex-start; }
.ed-row > :first-child { flex: 1; }
.ed-icon { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border: 1.5px solid var(--line); background: var(--card); color: var(--muted); font-size: .9rem; line-height: 1; }
.ed-icon:hover { border-color: var(--ink); color: var(--ink); }
.ed-icon--del:hover { border-color: var(--accent); color: var(--accent); }
.ed-add { justify-self: start; border: 1.5px dashed var(--line); background: none; padding: 7px 12px; font-weight: 600; font-size: .84rem; color: var(--ink-2); }
.ed-add:hover { border-color: var(--accent); color: var(--accent); }

/* list of objects = cards */
.ed-cards { display: grid; gap: 10px; margin-bottom: 14px; }
.ed-card { border: 2px solid var(--ink); background: var(--card); }
.ed-card__head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; cursor: pointer; user-select: none; }
.ed-card__idx { font-family: var(--f-mono); font-size: .66rem; color: var(--accent); }
.ed-card__title { flex: 1; min-width: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-card__chev { width: 10px; height: 10px; border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); rotate: -45deg; transition: rotate .2s var(--ease); margin: 0 6px; }
.ed-card.is-open .ed-card__chev { rotate: 45deg; }
.ed-card__body { display: none; padding: 12px 12px 2px; border-top: 1.5px solid var(--line); }
.ed-card.is-open .ed-card__body { display: block; animation: open .25s var(--ease); }
@keyframes open { from { opacity: 0; transform: translateY(-4px); } }
.ed-card__tools { display: flex; gap: 4px; }
.ed-card__tools .ed-icon { width: 30px; height: 30px; }

/* photo upload */
.ed-upload { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.ed-thumb img { display: block; height: 46px; width: 64px; object-fit: cover; border: 1.5px solid var(--ink); }
.ed-drop { display: grid; gap: 6px; justify-items: start; padding: 16px; border: 2px dashed var(--accent); margin-bottom: 4px; }
.ed-drop small { color: var(--muted); }

/* photo manager */
.ed-drop--big { padding: 22px; justify-items: center; text-align: center; background: color-mix(in srgb, var(--accent) 6%, transparent); transition: background-color .2s, border-color .2s; margin-bottom: 14px; }
.ed-drop--big b { font-family: var(--f-display); font-weight: 400; font-size: 1.05rem; text-transform: uppercase; }
.ed-drop.is-over { background: color-mix(in srgb, var(--accent) 22%, transparent); border-style: solid; }
.ed-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.ed-photo { border: 2px solid var(--ink); background: var(--card); padding: 8px 8px 0; }
.ed-photo.needs-label { border-color: var(--accent); }
.ed-photo__thumb { position: relative; aspect-ratio: 4 / 3; background: var(--paper-2); border: 1.5px solid var(--ink); overflow: hidden; display: grid; place-items: center; }
.ed-photo__thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ed-photo__none { font-family: var(--f-mono); font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ed-photo__bar { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 8px; }
.ed-photo__tools { display: flex; gap: 4px; }
.ed-photo__tools .ed-icon { width: 30px; height: 30px; }
.ed-photo .ed-field { margin-bottom: 10px; }
.ed-photo .ed-grid2 { grid-template-columns: 1.4fr 1fr; gap: 0 8px; }
.ed-photo.needs-label .ed-field:first-of-type input { border-color: var(--accent); }

/* chips (skill evidence) */
.ed-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.ed-chip { padding: 6px 10px; border: 1.5px solid var(--line); background: var(--card); font-size: .8rem; font-weight: 600; border-radius: 999px; }
.ed-chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* changed-field marker */
.is-changed > input, .is-changed > textarea, .is-changed > select { border-left: 4px solid var(--accent); }

/* ---- preview */
.ed-preview { display: flex; flex-direction: column; min-width: 0; background: var(--paper-2); }
.ed-preview__bar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1.5px solid var(--line); }
.ed-live { display: flex; align-items: center; gap: 8px; font-family: var(--f-mono); font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ed-live i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.ed-live.is-busy i { animation: blink .6s ease-in-out infinite; }
.ed-seg { display: flex; border: 1.5px solid var(--ink); margin-left: auto; }
.ed-seg button { border: 0; background: none; padding: 5px 10px; font-size: .78rem; font-weight: 600; }
.ed-seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.ed-link { border: 0; background: none; text-decoration: underline; text-underline-offset: 3px; font-size: .82rem; }
.ed-frame { flex: 1; min-height: 0; display: flex; justify-content: center; padding: 14px; }
.ed-frame iframe { width: 100%; height: 100%; border: 2px solid var(--ink); background: #fff; box-shadow: 6px 6px 0 var(--ink); transition: width .35s var(--ease); }
.ed-frame[data-size="phone"] iframe { width: 390px; max-width: 100%; border-radius: 22px; }

/* ---- dialog */
.ed-dialog { border: 2px solid var(--ink); background: var(--paper); color: var(--ink); padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 10px 10px 0 var(--accent); }
.ed-dialog::backdrop { background: rgba(14, 14, 13, .6); backdrop-filter: blur(3px); }
.ed-dialog__in { padding: 22px; }
.ed-dialog h2 { margin: 0 0 6px; font-family: var(--f-display); font-weight: 400; font-size: 1.3rem; text-transform: uppercase; }
.ed-help { color: var(--muted); margin: 0 0 16px; font-size: .9rem; }
.ed-dialog__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.ed-result { min-height: 1.4em; margin: 4px 0; font-size: .88rem; }
.ed-result.ok { color: var(--ok); }
.ed-result.err { color: var(--accent); }
.ed-result a { color: inherit; }

.ed-toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); translate: -50% 0; z-index: 50; padding: 10px 16px; background: var(--ink); color: var(--paper); font-weight: 600; font-size: .88rem; box-shadow: 4px 4px 0 var(--accent); opacity: 0; transform: translateY(10px); transition: opacity .2s, transform .3s var(--ease); pointer-events: none; }
.ed-toast.is-on { opacity: 1; transform: none; }

/* ---- smaller screens: form and preview become tabs */
@media (max-width: 1100px) {
  .ed-main { grid-template-columns: 170px 1fr; }
  .ed-tabs { display: flex; border-bottom: 2px solid var(--ink); }
  .ed-tabs button { flex: 1; padding: 10px; border: 0; background: none; font-weight: 700; border-bottom: 3px solid transparent; }
  .ed-tabs button[aria-selected="true"] { border-bottom-color: var(--accent); }
  .ed-main[data-view="form"] .ed-preview { display: none; }
  .ed-main[data-view="preview"] .ed-nav, .ed-main[data-view="preview"] .ed-form { display: none; }
  .ed-main[data-view="preview"] { grid-template-columns: 1fr; }
  .ed-form { border-right: 0; }
}
@media (max-width: 720px) {
  .ed-top { gap: 10px; padding: 10px 12px; }
  .ed-status { order: 3; width: 100%; margin: 0; }
  .ed-actions { order: 2; margin-left: auto; }
  .ed-actions .ed-btn--ghost { display: none; }
  .ed-actions .ed-btn { min-height: 36px; padding: 0 10px; font-size: .8rem; }
  .ed-main { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .ed-main[data-view="preview"] { grid-template-rows: 1fr; }
  .ed-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1.5px solid var(--line); padding: 8px; scrollbar-width: none; }
  .ed-nav button { flex: none; width: auto; border-left: 0; border-bottom: 3px solid transparent; }
  .ed-nav button[aria-current="true"] { border-bottom-color: var(--accent); }
  .ed-form { padding: 16px 14px 100px; }
  .ed-grid2 { grid-template-columns: 1fr; }
  .ed-frame { padding: 8px; }
  .ed-frame iframe { box-shadow: none; }
  .ed-seg { display: none; }
  .ed-field input, .ed-field textarea, .ed-field select, .ed-row input, .ed-row textarea { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
