/* ============================================================
   ROOK — the CMS dashboard
   Same world as rookcms.com: the galley proof. Paper ground,
   press-blue proofing, red kept to hairlines and tags.
   ============================================================ */

:root {
  --paper: #fbfaf5;
  --sheet: #ffffff;
  --ink: #1c1712;
  --ink-2: #5a5244;
  --press: #1c2ec4;
  --press-deep: #14219b;
  --press-soft: #4d5fe0;
  --red: #c2361b;
  --graphite: #6b6455;
  --rule: #e2ddcd;
  --rule-dark: #c9c3ae;
  --tint-blue: #eef1fb;
  --nonphoto: #a9cadf;
  --f-display: "Besley", "Georgia", serif;
  --f-body: "Literata", "Georgia", serif;
  --f-mono: "Martian Mono", "Consolas", monospace;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* proofing-paper grain, same as the galley */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 90;
  pointer-events: none; opacity: 0.05; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='11'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, h3, h4 { font-family: var(--f-display); line-height: 1.12; margin: 0 0 0.5rem; }
a { color: var(--press); }
:focus-visible { outline: 2px solid var(--press); outline-offset: 3px; border-radius: 1px; }
::selection { background: var(--press); color: var(--paper); }
[hidden] { display: none !important; }

.mono { font-family: var(--f-mono); font-size: 0.82em; }
.smallnote { font-size: 0.85rem; color: var(--ink-2); }

/* same brand lockup as the marketing masthead: rook glyph + Besley 900, in ink */
.wordmark {
  display: flex; align-items: center; gap: 0.55rem;
  font-family: var(--f-display); font-weight: 900; font-size: 1.35rem;
  color: var(--ink); margin: 0; letter-spacing: 0.01em;
}
.wordmark svg { width: 22px; height: 26px; }

/* ---------- buttons & inputs ---------- */
button {
  font-family: var(--f-mono); font-size: 0.8rem; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--press); color: var(--paper);
  border: 2px solid var(--press); border-radius: 1px;
  padding: 0.55rem 1.1rem; cursor: pointer;
  transition: background 0.15s var(--ease-out), color 0.15s var(--ease-out);
}
button:hover { background: var(--press-deep); border-color: var(--press-deep); }
button.ghost { background: transparent; color: var(--press); }
button.ghost:hover { background: var(--tint-blue); }
button.linklike {
  background: none; border: none; color: var(--press); padding: 0;
  text-transform: none; letter-spacing: 0; font-family: var(--f-body);
  font-size: 0.85rem; text-decoration: underline; text-underline-offset: 3px;
}
button.linklike:hover { background: none; color: var(--press-deep); }
button.danger { background: transparent; color: var(--red); border-color: transparent; }
button.danger:hover { background: color-mix(in srgb, var(--red) 8%, var(--sheet)); border-color: transparent; }

input, select, textarea {
  font-family: var(--f-mono); font-size: 0.85rem;
  border: 1px solid var(--rule-dark); border-radius: 1px;
  background: var(--sheet); color: var(--ink);
  padding: 0.55rem 0.7rem;
}
input:focus, select:focus, textarea:focus { border-color: var(--press); outline: none; }
label { font-family: var(--f-mono); font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2); }

/* ---------- sign in ---------- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.signin__card {
  background: var(--sheet); border: 1px solid var(--rule);
  border-top: 4px solid var(--press);
  box-shadow: 0 2px 24px rgba(28, 23, 18, 0.07);
  max-width: 26rem; width: 100%; padding: 2.2rem 2.4rem 1.8rem;
}
.signin__card h1 { font-size: clamp(1.9rem, 3.4vw, 3rem); margin-top: 0.9rem; }
.signin .lede { color: var(--ink-2); font-size: 0.95rem; }
.signin form { display: grid; gap: 0.5rem; margin: 1.4rem 0 1rem; }
.signin__error { color: var(--red); font-size: 0.85rem; min-height: 1.2em; margin: 0; }

/* ---------- masthead (mirrors the marketing masthead exactly) ---------- */
.masthead {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 3px double var(--ink);
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
  padding: 0.65rem var(--gutter);
}
.masthead__site {
  margin: 0; font-family: var(--f-mono); font-size: 0.66rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-2);
  border-left: 1px solid var(--rule-dark); padding-left: 1.25rem;
  white-space: nowrap;
}
.masthead__who { margin: 0 0 0 auto; font-size: 0.85rem; color: var(--ink-2); }

.tabs { display: flex; align-items: center; gap: 1.5rem; }
.tabs button {
  background: transparent; color: var(--ink); border: none; border-bottom: 2px solid transparent;
  border-radius: 1px; padding: 0.35rem 0;
  font-size: 0.72rem; letter-spacing: 0.1em;
}
.tabs button:hover { color: var(--ink); background: transparent; border-bottom-color: var(--nonphoto); }
.tabs button.is-active { color: var(--press); border-bottom-color: var(--press); }

.flash {
  margin: 0; padding: 0.6rem clamp(1rem, 3vw, 2.2rem);
  background: var(--tint-blue); color: var(--press-deep);
  font-size: 0.9rem; border-bottom: 1px solid var(--rule);
}

/* ---------- screens ---------- */
.screen {
  display: grid; grid-template-columns: minmax(15rem, 21rem) 1fr;
  gap: clamp(1.2rem, 3vw, 2.4rem);
  padding: clamp(1.2rem, 3vw, 2.2rem);
  max-width: 90rem; margin: 0 auto;
  align-items: start;
}
.screen--single { grid-template-columns: 1fr; }
.screen-slug {
  font-family: var(--f-mono); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-2);
  border-bottom: 1px solid var(--rule-dark); padding-bottom: 0.5rem;
}

/* ---------- queue ---------- */
.queue__list { list-style: none; margin: 0.8rem 0; padding: 0; display: grid; gap: 0.4rem; }
.queue__list button {
  display: block; width: 100%; text-align: left;
  background: var(--sheet); color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 1px; padding: 0.6rem 0.75rem;
  font-family: var(--f-body); text-transform: none; letter-spacing: 0; font-size: 0.92rem;
}
.queue__list button:hover { border-color: var(--rule-dark); background: var(--sheet); }
.queue__list button.is-active { border-color: var(--press); background: var(--tint-blue); }
.queue__list .q-title { display: block; font-weight: 600; }
.queue__list .q-meta { display: block; font-family: var(--f-mono); font-size: 0.68rem; color: var(--ink-2); letter-spacing: 0.06em; margin-top: 0.2rem; }
.q-status { color: var(--press); }
.q-status--draft { color: var(--graphite); }

/* ---------- proof (review pane) ---------- */
.proof { background: var(--sheet); border: 1px solid var(--rule); padding: clamp(1.2rem, 3vw, 2rem); min-height: 24rem; }
.proof__hint { margin: 0; }
.proof__head { display: flex; align-items: start; gap: 1rem; flex-wrap: wrap; border-bottom: 1px solid var(--rule); padding-bottom: 0.9rem; }
.proof__head h3 { font-size: 1.2rem; margin: 0; }
.proof__meta { font-family: var(--f-mono); font-size: 0.72rem; color: var(--ink-2); letter-spacing: 0.06em; margin: 0.3rem 0 0; }
.proof__actions { margin-left: auto; display: flex; gap: 0.5rem; align-items: center; }

.checks { margin: 1rem 0; padding: 0.8rem 1rem; border: 1px solid var(--rule); background: var(--paper); }
/* heavy top rule, the ledger treatment — the verdict itself is the colored line of text */
.checks--pass { border-top: 3px solid var(--ink); }
.checks--fail { border-top: 3px solid var(--ink); }
.checks p { margin: 0; font-family: var(--f-mono); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; }
.checks--pass p { color: var(--press); }
.checks--fail p { color: var(--red); }
.checks ul { margin: 0.5rem 0 0; padding-left: 1.1rem; font-size: 0.88rem; }
.reviewnote { font-size: 0.88rem; background: color-mix(in srgb, var(--red) 4%, var(--paper)); border: 1px solid var(--rule-dark); padding: 0.6rem 0.9rem; margin: 0.8rem 0; }

.viewswitch { display: flex; gap: 0.25rem; margin: 1.1rem 0 0.8rem; }
.viewswitch button {
  background: transparent; color: var(--ink-2); border: 1px solid var(--rule-dark);
  padding: 0.3rem 0.8rem; font-size: 0.7rem;
}
.viewswitch button.is-active { background: var(--press); border-color: var(--press); color: var(--paper); }

/* rendered markdown proof */
.rendered { max-width: 62ch; }
.rendered h1 { font-size: 1.9rem; } .rendered h2 { font-size: 1.2rem; margin-top: 1.6rem; }
.rendered h3 { font-size: 1.0625rem; margin-top: 1.2rem; }
.rendered pre { background: var(--paper); border: 1px solid var(--rule); padding: 0.8rem 1rem; overflow-x: auto; font-size: 0.82rem; }
.rendered code { font-family: var(--f-mono); font-size: 0.85em; }
.rendered blockquote { border-left: 1px solid var(--rule-dark); margin-left: 0; padding-left: 1rem; color: var(--ink-2); }
.rendered img { max-width: 100%; }

/* diff */
.diff { font-family: var(--f-mono); font-size: 0.78rem; line-height: 1.55; overflow-x: auto; border: 1px solid var(--rule); }
.diff .dl { display: block; padding: 0.05rem 0.75rem; white-space: pre-wrap; word-break: break-word; }
.diff .dl--add { background: var(--tint-blue); color: var(--press-deep); }
.diff .dl--del { background: color-mix(in srgb, var(--red) 7%, var(--sheet)); color: var(--red); text-decoration: line-through; text-decoration-thickness: 1px; }
.diff .dl--ctx { color: var(--ink-2); }
.diff-note { font-size: 0.82rem; color: var(--ink-2); margin: 0.4rem 0 0; }

/* frontmatter table */
.fmtable { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.fmtable td { border-bottom: 1px solid var(--rule); padding: 0.35rem 0.6rem; vertical-align: top; }
.fmtable td:first-child { font-family: var(--f-mono); font-size: 0.72rem; color: var(--ink-2); width: 11rem; letter-spacing: 0.05em; }

/* reject form */
.rejectbox { margin-top: 1rem; display: grid; gap: 0.5rem; }
.rejectbox textarea { min-height: 4.5rem; resize: vertical; font-family: var(--f-body); }

/* ---------- directive editor ---------- */
.editor { background: var(--sheet); border: 1px solid var(--rule); padding: clamp(1rem, 2.5vw, 1.6rem); min-height: 24rem; }
.editor__head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.editor__head h3 { margin: 0; font-size: 0.9rem; color: var(--press-deep); }
.editor__actions { margin-left: auto; display: flex; gap: 0.5rem; }
#editor-text {
  width: 100%; min-height: 22rem; resize: vertical;
  line-height: 1.6; tab-size: 2;
  border-color: var(--rule-dark);
}
.enforce { margin-top: 1rem; border: 1px solid var(--rule); border-top: 3px solid var(--ink); background: var(--paper); padding: 0.8rem 1.1rem; }
.enforce h4 { font-family: var(--f-mono); font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--press); }
.enforce ul { margin: 0.4rem 0 0; padding-left: 1.1rem; font-size: 0.88rem; }
.enforce__diags { color: var(--red); font-size: 0.84rem; }
.enforce__diags:empty { display: none; }

/* ---------- team ---------- */
.team-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: clamp(1.2rem, 3vw, 2.4rem); margin-top: 1rem; }
.ledger { width: 100%; border-collapse: collapse; font-size: 0.88rem; background: var(--sheet); }
.ledger td, .ledger th { border: 1px solid var(--rule); padding: 0.5rem 0.7rem; text-align: left; vertical-align: top; }
.ledger .cap-count { font-family: var(--f-mono); font-size: 0.7rem; color: var(--ink-2); }
.tag {
  display: inline-block; font-family: var(--f-mono); font-size: 0.62rem; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  border: 1px solid currentColor; border-radius: 1px; padding: 0.08rem 0.35rem;
}
.tag--press { color: var(--press); }
.tag--graphite { color: var(--graphite); }

.issue { margin-top: 1.2rem; border-top: 1px dashed var(--rule-dark); padding-top: 1rem; }
.issue h4 { margin-bottom: 0.6rem; }
.issue__row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.issue__row input { flex: 1 1 10rem; }
.issued { margin-top: 1rem; border: 2px solid var(--press); background: var(--tint-blue); padding: 0.9rem 1.1rem; }
.issued p { margin: 0 0 0.5rem; font-size: 0.9rem; }
.issued pre {
  background: var(--sheet); border: 1px solid var(--rule-dark);
  padding: 0.7rem 0.9rem; font-size: 0.75rem; overflow-x: auto;
  white-space: pre-wrap; word-break: break-all; margin: 0 0 0.6rem;
}

/* ---------- colophon ---------- */
.colophon {
  margin-top: 2rem; padding: 1rem clamp(1rem, 3vw, 2.2rem);
  border-top: 1px solid var(--rule);
  font-size: 0.78rem; color: var(--ink-2);
}
.colophon p { margin: 0; }

/* ---------- stamp (verdicts only) ---------- */
.stamp {
  display: inline-block; font-family: var(--f-mono); font-weight: 700;
  font-size: 0.66rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--press); border: 2.5px solid var(--press);
  padding: 0.3rem 0.6rem 0.26rem 0.72rem; transform: rotate(-2.5deg);
  filter: url(#stamp-rough);
}
.stamp--red { color: var(--red); border-color: var(--red); transform: rotate(1.8deg); }

@media (max-width: 760px) {
  .screen { grid-template-columns: 1fr; }
  .masthead__who { margin-left: 0; }
}

/* ---------- media library (screen 04) ---------- */
.media-head { display: grid; gap: 0.9rem; margin: 0.6rem 0 1.2rem; max-width: 60rem; }
.media-upload { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.media-upload input[type="file"] { max-width: 18rem; font-family: var(--f-body); }
.media-upload #media-alt { flex: 1 1 16rem; }
#media-search { max-width: 22rem; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.9rem; }
.media-card {
  display: grid; gap: 0.35rem; text-align: left; padding: 0.55rem; cursor: pointer;
  background: var(--sheet); color: var(--ink); border: 1px solid var(--rule); border-radius: 1px;
  font-family: var(--f-body); font-size: 0.8rem; text-transform: none; letter-spacing: 0;
}
.media-card:hover { border-color: var(--press); background: var(--sheet); }
.media-card img, .media-card__blank {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block;
  background: var(--tint-blue); border: 1px solid var(--rule);
}
.media-card__blank { display: grid; place-items: center; color: var(--ink-2); font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase; }
.media-card__name { font-size: 0.72rem; word-break: break-all; }
.media-card__meta { font-size: 0.72rem; color: var(--ink-2); }
.media-card__warn { font-family: var(--f-mono); font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--red); }
.media-detail { margin-top: 1.4rem; background: var(--sheet); border: 1px solid var(--rule); border-top: 4px solid var(--press); padding: 1.2rem 1.4rem; }
.media-detail__inner { display: grid; grid-template-columns: minmax(0, 18rem) 1fr; gap: 1.4rem; align-items: start; }
.media-detail__inner img { width: 100%; border: 1px solid var(--rule); background: var(--tint-blue); }
.media-detail__fields { display: grid; gap: 0.5rem; }
.media-detail__fields h3 { font-size: 0.9rem; word-break: break-all; }
.media-detail__fields input { width: 100%; max-width: 32rem; }
.media-detail__fields pre { margin: 0.4rem 0 0; font-size: 0.78rem; background: var(--tint-blue); padding: 0.6rem 0.8rem; overflow-x: auto; }
@media (max-width: 760px) { .media-detail__inner { grid-template-columns: 1fr; } }
