/*
  Admin styles, written by hand.

  Deliberately not Tailwind: the public site's Tailwind pipeline exists because that page
  is a pixel-faithful rebuild of a design reference. The admin has no reference, is seen by
  a handful of people, and is better served by a few hundred lines of plain CSS than by a
  second build step. The brand tokens below are copied from the site's @theme block so the
  two stay recognisably the same product.
*/

:root {
  --navy: #2b6398;
  --navy-deep: #255580;
  --navy-abyss: #06164d;
  --cyan: #0eacdf;
  --teal: #29ba9c;

  --success: #22a45a;
  --danger: #e8262c;
  --warn: #b26b00;

  --ink: #0a0a0a;
  --ink-muted: #364153;
  --ink-subtle: #666d79;

  --surface: #ffffff;
  --surface-gray: #f5f5f5;
  --surface-blue: #f7fafc;
  --hairline: #e3e8ee;

  --radius: 10px;
  --shadow-card: 0 1px 2px rgb(16 24 40 / 0.04), 0 8px 24px rgb(16 24 40 / 0.05);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface-gray);
}

h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .25rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; margin: 2rem 0 .5rem; }
h3 { font-size: .95rem; margin: 1.25rem 0 .35rem; color: var(--ink-muted); }

a { color: var(--navy-deep); }

.lede { color: var(--ink-subtle); margin: 0 0 1.5rem; max-inline-size: 60ch; }
.muted { color: var(--ink-subtle); }

.sr-only {
  position: absolute; inline-size: 1px; block-size: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* Every interactive control keeps a visible focus ring - this is an admin people
   drive from the keyboard all day. */
:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---- shell -------------------------------------------------------------------------- */

.admin-shell { min-block-size: 100dvh; }

.admin-bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
  block-size: 60px;
  background: var(--navy-abyss);
  color: #fff;
  position: sticky;
  inset-block-start: 0;
  z-index: 10;
}

.admin-brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  color: #fff;
  text-decoration: none;
  font-size: .95rem;
  white-space: nowrap;
}

.admin-brand img { object-fit: contain; }
.admin-brand strong { font-weight: 600; color: var(--cyan); }

.admin-nav { display: flex; gap: .35rem; margin-inline-end: auto; }

.admin-nav a {
  color: rgb(255 255 255 / 0.78);
  text-decoration: none;
  padding: .4rem .7rem;
  border-radius: 6px;
  font-size: .9rem;
}

.admin-nav a:hover { color: #fff; background: rgb(255 255 255 / 0.08); }
.admin-nav a.active { color: #fff; background: rgb(255 255 255 / 0.16); }

.admin-account { display: flex; align-items: center; gap: .75rem; margin: 0; }
.admin-who { font-size: .85rem; color: rgb(255 255 255 / 0.72); }
.admin-bar .btn-quiet { color: #fff; border-color: rgb(255 255 255 / 0.28); background: transparent; }
.admin-bar .btn-quiet:hover { background: rgb(255 255 255 / 0.12); }

.admin-main {
  max-inline-size: 1180px;
  margin-inline: auto;
  padding: 2rem 1.5rem 4rem;
}

/* ---- login -------------------------------------------------------------------------- */

.bare-shell {
  min-block-size: 100dvh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(1200px 600px at 50% -20%, #144178 0%, transparent 60%),
    var(--navy-abyss);
}

.login-card {
  inline-size: min(100%, 400px);
  background: var(--surface);
  border-radius: 14px;
  padding: 2rem;
  box-shadow: 0 12px 32px rgb(4 20 60 / 0.32);
}

.login-logo { display: block; margin-block-end: 1.5rem; block-size: auto; max-inline-size: 100%; }
.login-sub { color: var(--ink-subtle); margin: 0 0 1.5rem; font-size: .9rem; }

.login-card label { display: block; font-size: .85rem; font-weight: 500; margin-block-end: .3rem; }
.login-card .checkline { display: flex; align-items: center; gap: .5rem; font-weight: 400; margin-block: 1rem; }
.login-card .checkline input { inline-size: auto; margin: 0; }

/* ---- forms -------------------------------------------------------------------------- */

input[type="text"], input[type="email"], input[type="password"],
input[type="url"], input[type="number"], select, textarea {
  inline-size: 100%;
  padding: .5rem .65rem;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  margin-block-end: .9rem;
}

textarea { resize: vertical; min-block-size: 4.5rem; line-height: 1.45; }

input:disabled, textarea:disabled { background: var(--surface-gray); color: var(--ink-subtle); }

label { font-size: .85rem; }

/* ---- buttons ------------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .45rem .85rem;
  font: inherit;
  font-size: .875rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { background: var(--surface-blue); }

.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-deep); }

.btn-publish { background: var(--success); border-color: var(--success); color: #fff; }
.btn-publish:hover { filter: brightness(.94); }

.btn-quiet { background: transparent; }

.btn-block { inline-size: 100%; padding-block: .6rem; }

.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---- table -------------------------------------------------------------------------- */

.grid {
  inline-size: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.grid th, .grid td {
  padding: .75rem 1rem;
  text-align: start;
  border-block-end: 1px solid var(--hairline);
  vertical-align: middle;
}

.grid thead th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-subtle);
  background: var(--surface-blue);
}

.grid tbody tr:last-child th, .grid tbody tr:last-child td { border-block-end: 0; }

.grid .actions { text-align: end; white-space: nowrap; }
.grid .actions .btn + .btn { margin-inline-start: .4rem; }

.culture {
  display: inline-block;
  min-inline-size: 2rem;
  font-variant: all-small-caps;
  font-weight: 600;
  letter-spacing: .04em;
}

/* ---- pills and notices -------------------------------------------------------------- */

.pill {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 500;
  background: var(--surface-gray);
  color: var(--ink-muted);
}

.pill-live { background: #e6f6ec; color: #14663a; }
.pill-draft { background: #fff3e0; color: #8a4b00; }
.pill-none { background: var(--surface-gray); color: var(--ink-subtle); }

.notice {
  padding: .7rem .9rem;
  border-radius: 8px;
  margin-block: 1rem;
  font-size: .9rem;
  border: 1px solid transparent;
}

.notice-error { background: #fdecec; border-color: #f5c2c2; color: #8c1114; }
.notice-ok { background: #e6f6ec; border-color: #b9e3c8; color: #14663a; }
.notice-warn { background: #fff6e5; border-color: #f0d9a8; color: #7a4a00; }

/* ---- editor ------------------------------------------------------------------------- */

.edit-head {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: start;
  justify-content: space-between;
  margin-block-end: 1rem;
}

.edit-head .culture {
  font-size: .75em;
  color: var(--ink-subtle);
  margin-inline-start: .4rem;
}

.edit-actions { display: flex; gap: .5rem; align-items: center; }

/* A sticky action bar would fight the collapsible groups; instead the head is short
   enough that Save and Publish stay one scroll away. */

.node-root { display: grid; gap: .75rem; }

.node-group {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
}

.node-group > summary {
  padding: .7rem 1rem;
  cursor: pointer;
  font-weight: 600;
  font-size: .95rem;
  background: var(--surface-blue);
  display: flex;
  align-items: center;
  gap: .5rem;
  list-style: none;
}

.node-group > summary::-webkit-details-marker { display: none; }

.node-group > summary::before {
  content: "▸";
  color: var(--ink-subtle);
  font-size: .8em;
  transition: transform .12s ease;
}

.node-group[open] > summary::before { transform: rotate(90deg); }

.node-count {
  margin-inline-start: auto;
  font-weight: 400;
  font-size: .78rem;
  color: var(--ink-subtle);
  background: var(--surface-gray);
  border-radius: 999px;
  padding: .05rem .5rem;
}

/* Nested groups sit inside their parent's padding rather than stacking shadows. */
.node-group > .node-object,
.node-group > .node-array { padding: 1rem; display: grid; gap: .5rem; }

.node-group .node-group { box-shadow: none; }

.node-item {
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--surface-blue);
  margin-block-end: .5rem;
}

.node-item-bar {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .6rem;
  border-block-end: 1px solid var(--hairline);
}

.node-item-no {
  inline-size: 1.4rem;
  block-size: 1.4rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font-size: .72rem;
  font-weight: 600;
  flex: none;
}

.node-item-title {
  margin-inline-end: auto;
  font-size: .85rem;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-item > .node-object { padding: .75rem; background: var(--surface); }

.btn-tiny { padding: .2rem .5rem; font-size: .78rem; }
.btn-danger { color: var(--danger); border-color: transparent; }
.btn-danger:hover { background: #fdecec; }

.field { margin-block-end: .25rem; }
.field label { display: block; color: var(--ink-muted); margin-block-end: .2rem; }
.field input[type="checkbox"] { inline-size: auto; margin-block-end: .9rem; }

.field-ref {
  margin: -.6rem 0 .9rem;
  padding: .35rem .55rem;
  background: var(--surface-gray);
  border-inline-start: 3px solid var(--cyan);
  border-radius: 0 6px 6px 0;
  font-size: .82rem;
  color: var(--ink-muted);
}

.field-ref span {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--ink-subtle);
  margin-inline-end: .4rem;
}

/* ---- image upload -------------------------------------------------------------------- */

.image-field__row { display: flex; gap: .75rem; align-items: flex-start; }

.image-field__thumb {
  inline-size: 72px;
  block-size: 72px;
  flex: none;
  object-fit: contain;
  background: var(--surface-gray);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 4px;
}

/* A path this application cannot serve - a file under the site's wwwroot, say - is marked
   rather than left as a broken-image glyph. */
.image-field__thumb.is-missing {
  background:
    repeating-linear-gradient(45deg, var(--surface-gray) 0 6px, #e9edf2 6px 12px);
}

.image-field__controls { flex: 1; min-inline-size: 0; }

.image-field__actions { display: flex; align-items: center; gap: .6rem; margin-block-start: -.5rem; }

/* The file input is hidden inside its label, so the label is the button. */
.image-field__actions label.btn { cursor: pointer; }
.image-field__actions input[type="file"] { display: none; }

.image-field__meta { font-size: .78rem; }
.image-field__error { margin-block: .5rem 0; }
