/* The Jainik admin's base stylesheet (R5 contract 8.4). Tokens first: their values are ADMIN_TOKENS in src/admin/kit.tsx
   (a test keeps the two equal). Then the layout and the kit's components. Screens add their own files under /admin/
   (staff.css, website.css, builder.css) and use these tokens. Every target is at least 44px; nothing scrolls the page
   sideways at 320px wide; no web fonts. */

:root {
  --red: #d60000;
  --red-dark: #b00000;
  --maroon: #8f0026;
  --deep: #5a0019;
  --paper: #fbf7f2;
  --white: #ffffff;
  --ink: #2a1d1d;
  --muted: #6b5a55;
  --line: #ecdcd2;
  --ok: #1d6b3a;
  --ok-bg: #e7f4ec;
  --warn: #8a5a00;
  --warn-bg: #fff4dc;
  --error: #b00000;
  --error-bg: #fdecec;
  --focus: #8f0026;
  --radius: 10px;
  --gap: 16px;
  --target: 44px;
  --body: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--body); font-size: 1rem; line-height: 1.5; color: var(--ink); background: var(--paper);
  display: grid; grid-template-columns: 1fr; grid-template-areas: "top" "side" "main"; grid-template-rows: auto auto 1fr; min-height: 100vh; }
/* Only main grows on a short page; the top bar keeps its own height. */
@media (min-width: 900px) { body { grid-template-columns: 240px minmax(0, 1fr); grid-template-areas: "top top" "side main"; grid-template-rows: auto 1fr; } }
a { color: var(--maroon); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
/* The focus colour is the top bar's own colour: there the ring is white. */
.top :focus-visible { outline-color: var(--white); }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; z-index: 10; background: var(--white); padding: 10px 14px; border-radius: var(--radius); }

/* Top bar and navigation */
.top { grid-area: top; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px var(--gap);
  padding: 8px var(--gap); background: var(--maroon); color: var(--white); }
.top .brand { color: var(--white); font-weight: 700; text-decoration: none; min-height: var(--target); display: inline-flex; align-items: center; }
.signout { display: flex; align-items: center; gap: 12px; margin: 0; }
.signout .who { overflow-wrap: anywhere; }
.side { grid-area: side; background: var(--white); border-bottom: 1px solid var(--line); padding: 8px var(--gap); }
@media (min-width: 900px) { .side { border-bottom: 0; border-right: 1px solid var(--line); } }
.nav-heading { margin: 12px 0 4px; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.side ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 8px; }
@media (min-width: 900px) { .side ul { display: block; } }
.side a { display: flex; align-items: center; min-height: var(--target); padding: 0 10px; border-radius: 8px; text-decoration: none; color: var(--ink); }
.side a[aria-current="page"] { background: var(--maroon); color: var(--white); }
/* On a phone the navigation folds into "Menu" (public/admin/js/nav.js); on a wide screen it is always open. */
.nav-menu { margin: 0; }
.nav-menu > summary { display: flex; align-items: center; min-height: var(--target); cursor: pointer; font-weight: 700; color: var(--maroon); }
@media (min-width: 900px) { .nav-menu > summary { display: none; } }

main { grid-area: main; padding: var(--gap); max-width: 920px; width: 100%; min-width: 0; }
main.wide { max-width: none; }
main:focus { outline: none; }
h1 { font-size: 1.6rem; margin: 8px 0 16px; overflow-wrap: anywhere; }
h2 { font-size: 1.25rem; margin: 24px 0 8px; }

/* Messages */
.flash { padding: 12px 16px; border-radius: var(--radius); margin: 0 0 16px; }
.flash.success { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--error-bg); color: var(--error); }
.flash.info { background: var(--warn-bg); color: var(--warn); }
.error-summary { border: 2px solid var(--error); background: var(--error-bg); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px; }
.error-summary h2 { margin: 0 0 8px; font-size: 1.1rem; color: var(--error); }
.error-summary ul { margin: 0; padding-left: 20px; }

/* The session note (public/admin/js/keep.js): at the foot of the screen, above everything, until the person acts. */
.session-note { position: fixed; left: var(--gap); right: var(--gap); bottom: var(--gap); z-index: 20; max-width: 640px; margin: 0 auto;
  background: var(--warn-bg); color: var(--ink); border: 2px solid var(--warn); border-radius: var(--radius); padding: 12px 16px; box-shadow: 0 4px 16px rgba(42, 29, 29, 0.25); }
.session-note[hidden] { display: none; }
.session-note p { margin: 0; }
.session-note .actions { margin: 8px 0 0; }

/* Fields */
.field { margin: 0 0 var(--gap); }
.field label, .field legend { display: block; font-weight: 700; margin-bottom: 4px; }
.field .req { font-weight: 400; color: var(--muted); }
.field .help { margin: 0 0 6px; color: var(--muted); font-size: 0.95rem; }
.field .error { margin: 0 0 6px; color: var(--error); font-weight: 700; }
.field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea {
  width: 100%; min-height: var(--target); font: inherit; padding: 8px 12px; border: 1px solid #b9aaa5; border-radius: 8px; background: var(--white); color: var(--ink); }
.field textarea { min-height: 96px; resize: vertical; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border: 2px solid var(--error); }
.field.check { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.field.check input { width: 24px; height: 24px; }
.field.check label { margin: 0; font-weight: 400; min-height: var(--target); display: inline-flex; align-items: center; }
fieldset.field { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--white); }
.field.media .thumb { display: block; margin-top: 8px; max-width: 160px; max-height: 120px; border-radius: 6px; }

/* Rich text (the kit's RichInput, wherever it is drawn): the vendored editor in place of the textarea. */
.rich .ql-toolbar.ql-snow, .rich .ql-container.ql-snow { border-color: var(--muted); background: var(--white); }
.rich .ql-toolbar.ql-snow { border-radius: 8px 8px 0 0; }
.rich .ql-container.ql-snow { border-radius: 0 0 8px 8px; font: inherit; }
.rich .ql-editor { min-height: 120px; font-size: 1rem; }
.rich .ql-toolbar button { min-width: var(--target); min-height: var(--target); }
.rich .ql-editor:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
.rich.has-error .ql-container.ql-snow { border: 2px solid var(--error); }

/* Buttons */
.button { display: inline-flex; align-items: center; justify-content: center; min-height: var(--target); padding: 8px 18px; border-radius: 999px;
  border: 2px solid var(--maroon); background: var(--maroon); color: var(--white); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
.button.secondary { background: var(--white); color: var(--maroon); }
.button.danger { background: var(--error); border-color: var(--error); color: var(--white); }
.top .button.secondary { border-color: var(--white); }
.actions { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: var(--gap) 0; }
/* Every target is at least 44px (R-8.4): a link on its own line ("Back to ...", "All forms"), a plain link among the
   actions, and a table's links. */
main > p > a:only-child, .actions > a:not(.button), td a { display: inline-flex; align-items: center; min-height: var(--target); }
.pager { margin: var(--gap) 0; }

/* Lists and tables: a table scrolls inside its own box, never the page. Words stay whole (break-word, not anywhere,
   which let a column shrink to one letter); a table is at least 36rem wide, so on a phone it scrolls in its box. */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); }
table { border-collapse: collapse; width: 100%; }
.table-wrap table { min-width: 36rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: break-word; }
th { font-size: 0.9rem; color: var(--muted); }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.muted { color: var(--muted); }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--line); font-size: 0.85rem; font-weight: 700; }
.badge.live { background: var(--ok-bg); color: var(--ok); }
.badge.draft { background: var(--warn-bg); color: var(--warn); }
.mono { font-family: var(--mono); overflow-wrap: anywhere; }
/* In a table an address or email stays whole too: the table scrolls in its box instead. */
.table-wrap .mono { overflow-wrap: break-word; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
