/* admin.css: the VLM website editor's stylesheet (the editor, the sign-in page and the contact form's
   "sent" and "not sent" pages). Black like the site, the logo red for actions, Inter for text and Archivo
   for the mark. The editor: a top bar with the actions, the sections down the left, one view on the right.

   Strict BEM, the same rules as the site (src/styles/site.css): only .block, .block__element and
   .block--modifier; a block styles only its own elements; state is a modifier (or an aria-* attribute)
   set by script. Bare tags are styled only in the base layer below, as defaults any block overrides.
   The classes are set by client/*.js (built into assets/editor.js), public/*.html and routes/contact.mjs. */
@layer admin-base;

@font-face { font-family: Inter; font-weight: 100 900; font-display: swap; src: url(fonts/inter.woff2) format("woff2"); }
@font-face { font-family: Archivo; font-weight: 100 900; font-stretch: 62% 125%; font-display: swap; src: url(fonts/archivo.woff2) format("woff2"); }

/* ---------------------------------------------------------------- tokens, named by role */
:root {
  --admin-bg: #0a0a0a; --admin-surface: #141414; --admin-surface-raised: #1b1b1b;
  --admin-rule: #2a2a2a; --admin-border: #3a3a3a;
  --admin-text: #f4f4f2; --admin-text-muted: #a3a3a3;
  --admin-accent: #ea3346;                                      /* text, borders and focus (the site's red for text on black) */
  --admin-fill: #b90214; --admin-fill-hover: #9a0111; --admin-on-fill: #ffffff; /* the logo red, for filled buttons */
  --admin-ok: #5ccf8a; --admin-warn: #ffb347; --admin-bad: #ff7a6b;
  --admin-radius: 8px;
  color-scheme: dark;
}

/* ---------------------------------------------------------------- element defaults (form controls are
   plain elements in many views, so their look lives here, overridable by any block) */
@layer admin-base {
  * { box-sizing: border-box; }
  html, body { margin: 0; min-height: 100%; background: var(--admin-bg); color: var(--admin-text); }
  body { font: 400 15px/1.5 Inter, system-ui, sans-serif; }
  button, input, textarea, select { font: inherit; color: inherit; }
  a { color: var(--admin-accent); }
  :focus-visible { outline: 2px solid var(--admin-accent); outline-offset: 2px; }
  [hidden] { display: none !important; }
  h1, h2 { line-height: 1.2; }
  label { display: block; font-weight: 700; font-size: 13px; color: var(--admin-text); }
  input:is([type="text"], [type="password"], [type="number"], [type="date"], [type="email"], [type="search"]), textarea, select {
    width: 100%; background: var(--admin-bg); border: 1px solid var(--admin-border); border-radius: 8px; padding: .6em .75em;
  }
  input:focus, textarea:focus, select:focus { border-color: var(--admin-accent); outline: none; }
  textarea { resize: vertical; min-height: 4.5em; }
  input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--admin-accent); }
  button:disabled { opacity: .4; cursor: not-allowed; }
}

/* ---------------------------------------------------------------- brand: the VLM mark (--large on sign-in) */
.brand { margin: 0; font: 800 20px/1 Archivo, system-ui, sans-serif; font-stretch: 125%; letter-spacing: -.02em; color: var(--admin-fill); white-space: nowrap; }
.brand--large { justify-self: center; font-size: 34px; }

/* ---------------------------------------------------------------- btn: pill buttons
   --primary filled red · --ghost no fill · --small · --danger red on hover · --current the page you're on */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4em; border: 1px solid var(--admin-border); background: var(--admin-surface-raised);
  border-radius: 99px; padding: .5em 1.1em; cursor: pointer; font-weight: 700; font-size: 13px; letter-spacing: .02em; text-decoration: none; color: var(--admin-text); }
.btn:hover { border-color: var(--admin-accent); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn--primary { background: var(--admin-fill); border-color: var(--admin-fill); color: var(--admin-on-fill); }
.btn--primary:hover { background: var(--admin-fill-hover); border-color: var(--admin-fill-hover); }
.btn--ghost { background: none; }
.btn--small { padding: .3em .85em; font-size: 12px; }
.btn--large { padding: .8em; font-size: 14px; }
.btn--danger:hover { border-color: var(--admin-bad); color: var(--admin-bad); }
.btn--current, .btn--current:disabled { background: var(--admin-fill); color: var(--admin-on-fill); border-color: var(--admin-fill); opacity: 1; }

/* icon-btn: a small square button with a symbol (remove) */
.icon-btn { background: var(--admin-surface-raised); border: 1px solid var(--admin-rule); border-radius: 6px; width: 28px; height: 28px; cursor: pointer; }
.icon-btn:hover:not(:disabled) { border-color: var(--admin-accent); }
.icon-btn--danger:hover:not(:disabled) { border-color: var(--admin-bad); color: var(--admin-bad); }

/* btn-row: a row of buttons */
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- sign-in: the sign-in page (body) */
.sign-in { min-height: 100vh; display: grid; place-items: center; padding: 24px 20px; background: var(--admin-bg); }
.sign-in__form { width: min(380px, 100%); display: grid; gap: 12px; background: var(--admin-surface); padding: 30px 26px; border-radius: 16px; border: 1px solid var(--admin-rule); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.sign-in__title { margin: 0 0 6px; font-size: 18px; text-align: center; }
.sign-in__error { color: var(--admin-bad); font-size: 13px; min-height: 1.3em; margin: 0; }
.sign-in__hint { color: var(--admin-text-muted); font-size: 13px; text-align: center; margin: 4px 0 0; }

/* notice: a page with one message on it (the contact form's "sent" and "not sent" pages) */
.notice { min-height: 100vh; display: grid; place-items: center; padding: 24px 20px; background: var(--admin-bg); }
.notice__card { width: min(380px, 100%); display: grid; gap: 12px; background: var(--admin-surface); padding: 30px 26px; border-radius: 16px; border: 1px solid var(--admin-rule); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.notice__title { margin: 0; font-size: 20px; }
.notice__text { margin: 0; }

/* ---------------------------------------------------------------- app: the editor's frame (body)
   app__top the bar along the top · app__nav the sections · app__main the view (--wide for the library) */
.app__top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap;
  padding: 10px 20px; background: rgba(11,11,12,.94); border-bottom: 1px solid var(--admin-rule); backdrop-filter: blur(6px); }
.app__title { color: var(--admin-text-muted); font-size: 13px; }
.app__status { margin-right: auto; }
.app__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.app__me { color: var(--admin-text-muted); font-size: 13px; align-self: center; padding-left: 6px; }
.app__layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); min-height: calc(100vh - 58px); }
.app__nav { border-right: 1px solid var(--admin-rule); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; }
.app__nav-link { text-align: left; background: none; border: 0; padding: .6em .85em; border-radius: 8px; cursor: pointer; color: var(--admin-text-muted); font-weight: 700; font-size: 14px; }
.app__nav-link:hover { color: var(--admin-text); background: var(--admin-surface); }
.app__nav-link[aria-current="page"] { color: var(--admin-on-fill); background: var(--admin-fill); }
.app__main { padding: 24px 28px 80px; max-width: 980px; }
.app__main--wide { max-width: none; }
@media (max-width: 760px) {
  .app__top { padding: 10px 16px; }
  .app__layout { grid-template-columns: 1fr; }
  .app__nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--admin-rule); padding: 8px 12px; }
  .app__nav-link { white-space: nowrap; }
  .app__main { padding: 20px 16px 80px; }
}

/* status: the line in the top bar saying whether the draft is saved (--dirty unsaved, --ok up to date) */
.status { font-size: 12.5px; color: var(--admin-text-muted); }
.status--dirty { color: var(--admin-warn); }
.status--ok { color: var(--admin-ok); }

/* toast: a message at the bottom of the screen for a few seconds (--bad for errors) */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 30; max-width: min(560px, calc(100vw - 32px));
  background: var(--admin-surface-raised); border: 1px solid var(--admin-ok); border-radius: 10px; padding: 12px 18px; box-shadow: 0 10px 30px rgba(0,0,0,.5); font-size: 14px; }
.toast--bad { border-color: var(--admin-bad); }

/* ---------------------------------------------------------------- view: one section of the editor (mixed onto app__main) */
.view__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.view__title { margin: 0; font-size: 24px; }
.view__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.view__sub { font-size: 15px; margin: 32px 0 12px; color: var(--admin-accent); text-transform: uppercase; letter-spacing: .06em; }

/* hint: a line of help in muted type (--ok good news, --bad an error) */
.hint { color: var(--admin-text-muted); font-size: 13px; margin: 0 0 10px; }
.hint--ok { color: var(--admin-ok); }
.hint--bad { color: var(--admin-bad); }

/* narrow: a column for short forms */
.narrow { max-width: 420px; }

/* cards and card: the Dashboard's summary */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.card { background: var(--admin-surface); border: 1px solid var(--admin-rule); border-radius: var(--admin-radius); padding: 16px 18px; }
.card__title { margin: 0 0 6px; font-size: 13px; color: var(--admin-text-muted); text-transform: uppercase; letter-spacing: .06em; }
.card__text { margin: 0; }

/* problems: what to fix before publishing (--bad) and what's worth checking (--warn) */
.problems__box { border-radius: var(--admin-radius); padding: 12px 16px; margin-bottom: 14px; font-size: 13.5px; }
.problems__box--bad { background: rgba(255,122,107,.08); border: 1px solid rgba(255,122,107,.5); }
.problems__box--warn { background: rgba(255,179,71,.07); border: 1px solid rgba(255,179,71,.4); }
.problems__text { margin: 6px 0 0; }
.problems__list { margin: 6px 0 0; padding-left: 18px; }

/* badge: a small label in a row (Hidden, Featured, "2 to fix") */
.badge { font-size: 11.5px; font-weight: 700; border-radius: 99px; padding: .1em .6em; background: var(--admin-surface-raised); border: 1px solid var(--admin-border); color: var(--admin-text-muted); }
.badge--ok { color: var(--admin-ok); border-color: var(--admin-ok); background: none; }
.badge--bad { background: var(--admin-bad); border-color: var(--admin-bad); color: #1b0703; }

/* ---------------------------------------------------------------- rows: lists of pages, people, versions
   row: one line (--button a whole-row button, --wrap wraps on narrow screens, --off a disabled person) */
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; background: var(--admin-surface); border: 1px solid var(--admin-rule); border-radius: var(--admin-radius); padding: 10px 14px; text-align: left; color: inherit; }
.row--button { cursor: pointer; }
.row--button:hover { border-color: var(--admin-accent); }
.row--wrap { flex-wrap: wrap; }
.row--off { opacity: .6; }
.row__who { display: grid; margin-right: auto; }
.row__title { font-weight: 700; }
.row__meta { color: var(--admin-text-muted); font-size: 13px; margin-right: auto; }
.row__select { width: auto; padding: .3em .6em; font-size: 13px; }
.row__btns { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* log: the activity history */
.log { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.log__item { padding: 6px 0; border-bottom: 1px solid var(--admin-rule); display: flex; gap: 8px; }
.log__when { color: var(--admin-text-muted); min-width: 150px; }
.log__who { color: var(--admin-text); font-weight: 700; min-width: 110px; }
.log__ip { margin-left: auto; color: var(--admin-text-muted); font-size: 12px; }

/* temp-pw: a new one-time password, shown once */
.temp-pw { border: 1px solid var(--admin-accent); background: rgba(234,51,70,.07); border-radius: var(--admin-radius); padding: 14px 18px; margin-bottom: 18px; }
.temp-pw__title { margin: 0 0 6px; }
.temp-pw__value { margin: 0 0 6px; font: 700 22px/1.3 ui-monospace, Consolas, monospace; letter-spacing: .04em; user-select: all; }

/* ---------------------------------------------------------------- forms built from the content model
   field: a label, a hint and a control (--check a checkbox with its label beside it)
   group: a fieldset for an object's fields (--readonly for someone who can only look) */
.field { margin-bottom: 18px; }
.field--check { display: flex; align-items: center; gap: 10px; }
.field--flush { margin: 0; }
.field__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.field__label { display: block; font-weight: 700; font-size: 13px; color: var(--admin-text); }
.field--check .field__label { margin: 0; font-weight: 600; }
.field__count { font-size: 12px; color: var(--admin-text-muted); font-variant-numeric: tabular-nums; }
.field__count--warn { color: var(--admin-warn); }
.field__count--bad { color: var(--admin-bad); font-weight: 700; }
.group { border: 1px solid var(--admin-rule); border-radius: var(--admin-radius); padding: 14px 16px 2px; margin: 0 0 20px; }
.group--readonly { border: 0; padding: 0; margin: 0; opacity: .75; }
.group__legend { padding: 0 8px; font-weight: 700; color: var(--admin-accent); font-size: 13px; letter-spacing: .04em; text-transform: uppercase; }

/* rich: the rich-text editor (TipTap). The extensions are configured to class what they render, so the
   document's headings, quotes and links are rich__ elements (client/fields.js). */
.rich { border: 1px solid var(--admin-border); border-radius: 8px; background: var(--admin-bg); }
.rich:focus-within { border-color: var(--admin-accent); }
.rich__toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border-bottom: 1px solid var(--admin-rule); }
.rich__btn { background: var(--admin-surface-raised); border: 1px solid transparent; border-radius: 6px; padding: .2em .6em; font-size: 12.5px; font-weight: 700; cursor: pointer; color: var(--admin-text-muted); }
.rich__btn:hover { color: var(--admin-text); }
.rich__btn[aria-pressed="true"] { color: var(--admin-on-fill); background: var(--admin-fill); }
.rich__sep { width: 1px; background: var(--admin-rule); margin: 2px 4px; }
.rich__doc { min-height: 7em; padding: 10px 12px; outline: none; }
.rich__paragraph { margin: 0 0 1em; }
.rich__heading { margin: 1em 0 .5em; font-size: 1.25em; }
.rich__heading:first-child, .rich__paragraph:first-child { margin-top: 0; }
.rich__quote { border-left: 3px solid var(--admin-accent); margin: 0 0 1em; padding-left: 12px; color: var(--admin-text-muted); }
.rich__list { margin: 0 0 1em; padding-left: 1.4em; }

/* list: a list field (items, an Add button; long lists get a search and an Add at the top) */
.list__items { display: grid; gap: 10px; margin-bottom: 8px; }
.list__top { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.list__search { flex: 1; }
.list__add { margin-bottom: 18px; }
.list__add--top { margin-bottom: 0; white-space: nowrap; }

/* drag-handle: the ⠿ on each list item; drag it (or use the arrow keys on it) to reorder. While dragging, the
   item lifts (list-item--dragging) and the list stops reacting to hovers (list__items--dragging). */
.drag-handle { flex: none; width: 26px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 6px; background: none; color: var(--admin-text-muted); font-size: 18px; line-height: 1; cursor: grab; touch-action: none; }
.drag-handle:hover, .drag-handle:focus-visible { color: var(--admin-text); background: var(--admin-surface-raised); }
.list__items--dragging { cursor: grabbing; user-select: none; }
.list__items--dragging .drag-handle { cursor: grabbing; }
.list-item--dragging { position: relative; z-index: 2; border-color: var(--admin-accent); box-shadow: 0 10px 28px rgb(0 0 0 / 0.45); opacity: 0.95; }
.badge--home { color: var(--admin-accent); border-color: var(--admin-accent); background: none; }
.badge--warn { color: var(--admin-warn, #e0a800); border-color: var(--admin-warn, #e0a800); background: none; }
/* list__tools: the filter buttons and Sort, under the search; list__group: a heading inside the items (On Home,
   then the others) */
.list__tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.list__filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip { font: inherit; font-size: 12.5px; font-weight: 700; padding: .3em .9em; border-radius: 99px; border: 1px solid var(--admin-rule); background: var(--admin-surface); color: var(--admin-text-muted); cursor: pointer; }
.filter-chip:hover { border-color: var(--admin-accent); color: var(--admin-text); }
.filter-chip[aria-pressed="true"] { background: var(--admin-accent); border-color: var(--admin-accent); color: #fff; }
.list__group { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; padding: 8px 2px 2px; }
.list__group:not(:first-child) { margin-top: 14px; padding-top: 16px; border-top: 1px solid var(--admin-rule); }
.list__group-title { font-size: 14px; }
.list__group-note { color: var(--admin-text-muted); font-size: 12.5px; }

/* list-item: one item in a list (--simple a single value; --fold an object that folds to one line) */
.list-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; background: var(--admin-surface); border: 1px solid var(--admin-rule); border-radius: var(--admin-radius); padding: 14px 12px 0 14px; }
.list-item--simple { grid-template-columns: auto minmax(0, 1fr) auto; padding: 8px 8px 8px 6px; align-items: center; }
.list-item--fold { display: block; padding: 0; }
.list-item__summary { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; list-style: none; }
.list-item__summary::-webkit-details-marker { display: none; }
.list-item__summary::after { content: "+"; margin-left: auto; color: var(--admin-text-muted); font-weight: 700; }
.list-item--fold[open] .list-item__summary { border-bottom: 1px solid var(--admin-rule); }
.list-item--fold[open] .list-item__summary::after { content: "–"; }
.list-item__title { font-weight: 700; }
.list-item__inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 14px 12px 0 14px; }
.list-item__controls { display: flex; gap: 4px; align-items: flex-start; }

/* ---------------------------------------------------------------- images
   thumb: a preview (--empty no image yet, --mini a list item's tiny one) */
.thumb { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 6px; border: 1px solid var(--admin-rule); background: var(--admin-surface-raised); display: block; }
.thumb--empty { display: grid; place-items: center; font-size: 12px; color: var(--admin-text-muted); }
.thumb--mini { width: 64px; height: 40px; aspect-ratio: auto; border-radius: 4px; flex: none; }
.thumb--mini.thumb--empty { display: none; }

/* image-pick: choosing an image for a field, with its alt text (--needs-alt when it has none) */
.image-pick { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 12px; align-items: start; }
.image-pick__side { display: grid; gap: 8px; justify-items: start; }
.image-pick__alt { display: grid; gap: 6px; width: 100%; padding: 8px 10px; border: 1px solid transparent; border-radius: 6px; }
.image-pick__alt--needs-alt { border-color: var(--admin-bad); }
.image-pick__label { font-size: 13px; font-weight: 600; }
.image-pick__alt--needs-alt .image-pick__label { color: var(--admin-bad); }
@media (max-width: 760px) { .image-pick { grid-template-columns: 1fr; } }

/* media-card: one image in the library (--needs-alt when it has no alt text) */
.media-card { background: var(--admin-surface); border: 1px solid var(--admin-rule); border-radius: var(--admin-radius); overflow: hidden; }
.media-card--needs-alt { border-color: var(--admin-warn); }
.media-card__thumb { border: 0; border-radius: 0; }
.media-card__body { padding: 12px 14px; }
.media-card__id { margin: 0 0 10px; font-weight: 700; font-size: 13px; color: var(--admin-accent); word-break: break-all; }

/* media-browser: the library's search, filters, pages and grid (client/media-browser.js) */
.media-browser__bar { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: end; margin: 6px 0 12px; padding: 12px 14px; background: var(--admin-surface); border: 1px solid var(--admin-rule); border-radius: var(--admin-radius); }
.media-browser__field { display: grid; gap: 4px; font-size: 12.5px; color: var(--admin-text-muted); font-weight: 700; }
.media-browser__field--search { flex: 1 1 320px; }
.media-browser__control { min-height: 38px; }
.media-browser__count { margin: 0 0 10px; color: var(--admin-text-muted); font-size: 13px; }
.media-browser__pager { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 14px; }
.media-browser__pager:last-child { margin: 16px 0 0; }
.media-browser__gap { color: var(--admin-text-muted); padding: 0 4px; }
.media-browser__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
