@import url('chrome.css?v=0.16.0');

/* GateIron house style for a whole page: chrome.css (tokens, faces, bar, account menu, buttons,
   footer) and the element rules below. A page with its own layout loads chrome.css alone.

   Colour never carries meaning alone: badges state their value in words and
   the priority ramp is ordered by weight. */

:root { color-scheme: light; }
:root.gi-dark-auto { color-scheme: light dark; }

/* ---------------- page ---------------- */
* { box-sizing: border-box; }

body {
  margin: 0;
  /* The footer ends the page even when the content does not fill the window,
     and is pushed below the fold as soon as it does. */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: 'Hanken Grotesk', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

main {
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 2rem 28px 4rem;
  flex: 1 0 auto;
}
main:focus { outline: none; }
main.narrow { max-width: var(--gi-measure); }
/* Running text keeps a reading measure on a page as wide as the window allows. */
.prose { max-width: var(--gi-measure); }

h1, h2, h3 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin: 0 0 0.6rem;
}
h1 { font-size: 2rem; }
.subtitle {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--text-muted);
  margin: -0.35rem 0 1.5rem;
}
h2 { font-size: 1.3rem; margin-top: 2rem; }
h3 { font-size: 1.05rem; margin-top: 1.5rem; }

a { color: var(--accent); text-underline-offset: 0.18em; }
a:hover { color: var(--accent-hover); }

p { margin: 0 0 0.9rem; }
.muted { color: var(--text-muted); font-size: 0.9rem; }
.stale { font-weight: 700; }

/* Keyboard focus only. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}

/* Bare <button> in the page body is the solid pill, as .btn-primary. :where() keeps these at zero
   specificity, so any rule of the page's own wins. Scoped to main, so the account menu's items are
   untouched; .btn and .linkish opt out. */
:where(main button:not(.btn, .linkish)) {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.45em 1.1em;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--accent);
  background: var(--accent);
  color: var(--accent-on);
  cursor: pointer;
}
:where(main button:not(.btn, .linkish)):hover { background: var(--accent-hover); }
:where(main button:not(.btn, .linkish)):active:not(:disabled) { transform: translateY(1px) scale(0.97); filter: brightness(0.88); }
@media (prefers-reduced-motion: reduce) { :where(main button:not(.btn, .linkish)):active:not(:disabled) { transform: none; } }
/* Sent and waiting (forms.js data-busy), as .btn in chrome.css: readable, with chrome.css's spinner. */
:where(main button:not(.btn, .linkish))[aria-busy="true"]:disabled { opacity: 0.85; cursor: progress; }
:where(main button:not(.btn, .linkish))[aria-busy="true"]::before {
  content: ""; width: 0.9em; height: 0.9em; flex: none; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: gi-spin 0.7s linear infinite;
}
@media (prefers-reduced-motion: reduce) { :where(main button:not(.btn, .linkish))[aria-busy="true"]::before { animation-duration: 2.5s; } }

:where(main button:not(.btn, .linkish)):disabled { opacity: 0.45; cursor: not-allowed; }
:where(main button:not(.btn, .linkish)):disabled:hover { background: var(--accent); }

/* A button that is really a link, kept for in-sentence actions. */
.linkish {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

/* ---------------- forms ---------------- */
label {
  display: block;
  margin: 1.1rem 0 0.3rem;
  font-weight: 600;
  font-size: 0.93rem;
}
input, textarea, select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--field-border);
  border-radius: var(--radius);
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { min-height: 8rem; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; }
select {
  padding-right: 2rem;   /* room for the native arrow */
}
.field-hint { color: var(--text-muted); font-size: 0.85rem; margin: 0.25rem 0 0; }
label .field-hint { display: block; font-weight: 400; margin: 0; }
/* The form rules (README, Forms; assets/forms.js). */
.required-mark { color: var(--urgent); font-weight: 700; }
.required-note { margin: 0 0 0.1rem; font-size: 0.88rem; color: var(--text-muted); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--urgent); }
.field-error { margin: 0.1rem 0 0.4rem; font-size: 0.86rem; color: var(--urgent); }
.field-error:empty { margin: 0; }

/* A column, not the page's full width. Tables still get the whole page. */
form { max-width: var(--gi-form-width); }
/* Except the little ones in a table row, which are controls, not forms. */
td form, .row-actions form { max-width: none; display: inline; }
td form > button, .row-actions form > button { margin-top: 0; }

:where(form > button[type="submit"]) { margin-top: 1.4rem; }

.field-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0 1rem;
}
.field-pair > div > label:first-child { margin-top: 1.1rem; }

/* ---------------- cards, notices, dialogs ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.2rem;
}

.notice {
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--quiet);
  background: var(--quiet-bg);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin: 1rem 0;
}
.notice > :last-child { margin-bottom: 0; }
.notice-ok { border-left-color: var(--ok); background: var(--ok-bg); }
.notice-warn { border-left-color: var(--warn); background: var(--warn-bg); }
.notice-error { border-left-color: var(--urgent); background: var(--urgent-bg); }

/* ---------------- tables ----------------
   A table scrolls inside its own box rather than making the page scroll. */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--surface);
  margin-top: 1rem;
}
table { border-collapse: collapse; width: 100%; }
/* Narrower than this, a subject breaks to one word per line. */
.table-wrap table { min-width: 42rem; }
th, td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}
thead th {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--surface-2);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num { white-space: nowrap; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.row-actions { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.row-actions button, .row-actions select { margin-top: 0; padding: 0.25rem 0.5rem; width: auto; }

/* ---------------- badges ---------------- */
.badge {
  display: inline-block;
  padding: 0.12em 0.6em;
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.badge-urgent { background: var(--urgent-bg); color: var(--urgent); border-color: var(--urgent); }
.badge-quiet { background: var(--quiet-bg); color: var(--quiet); border-color: var(--border-strong); }

/* Weight as well as hue, so the order survives greyscale. */
.prio-urgent { font-weight: 800; }
.prio-high { font-weight: 700; }
.prio-normal { font-weight: 500; }
.prio-low { font-weight: 400; font-style: italic; }

/* ---------------- compact density ---------------- */
body.gi-compact main { padding-top: 1rem; }

/* ---------------- narrow screens ---------------- */
@media (max-width: 720px) {
  main { padding: 1.25rem 0.9rem 3rem; }
}

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