/* Portal X components. Tokens only - no hex codes in this file. */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

h1 { font-size: 1.4rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 1.25rem 0 .5rem; }

code, .mono { font-family: var(--font-mono); font-size: .87em; }
code { background: var(--surface-2); padding: .1rem .35rem; border-radius: 4px; }

.muted { color: var(--ink-muted); }
.subtle { color: var(--ink-subtle); }

/* ---------- layout ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: .7rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand { font-weight: 700; letter-spacing: .02em; }
.brand span { color: var(--accent); }
.site-nav {
  margin-left: auto;
  display: flex;
  gap: .9rem;
  align-items: center;
  font-size: .9rem;
  color: var(--ink-muted);
}
/* width:100% matters: main is a flex item, and auto margins in the cross axis
   stop a flex item stretching - without it every page shrank to fit its own
   widest content, so no two pages were the same width. */
main {
  width: 100%;
  max-width: var(--page-max);
  margin: 1.5rem auto;
  padding: 0 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-1);
}

/* ---------- tables ---------- */
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); }
th { color: var(--ink-muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

/* ---------- controls ---------- */
.btn, button, input[type="submit"] {
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid transparent;
  padding: .45rem 1rem;
  border-radius: var(--radius-sm);
  font: inherit;
  cursor: pointer;
}
.btn:hover, button:hover, input[type="submit"]:hover { background: var(--accent-hover); }
.btn-quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-quiet:hover { background: var(--surface-2); color: var(--ink); }

/* Every text-like input type, listed out because there is no "all of them"
   selector. Date, time, number and search were missing at first and rendered
   with the browser's default chrome - the PHP portal hit the same gap three
   separate times (time, datetime-local, textarea). Add new types HERE, and
   check the style guide, when a form first uses one. */
input[type="text"], input[type="password"], input[type="email"], input[type="search"],
input[type="tel"], input[type="url"], input[type="number"],
input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"],
select, textarea {
  width: 100%;
  padding: .45rem .5rem;
  font: inherit;
  color: var(--ink);
  background: var(--field-bg);
  border: 1px solid var(--field-line);
  border-radius: var(--radius-sm);
}
select { width: auto; cursor: pointer; }
.form-field select { width: 100%; }

/* The hidden attribute wins over any display rule. Without this, an element
   styled display:flex stays visible when a script sets hidden - it bit the
   Cancelled band and then the relief fields. */
[hidden] { display: none !important; }

/* Two renderings of the same thing, one per width. The list pages use them
   for a table on a desk and cards on a phone. */
@media (max-width: 40rem) { .only-wide { display: none !important; } }
@media (min-width: 40.01rem) { .only-narrow { display: none !important; } }

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

label { display: block; font-size: .9rem; color: var(--ink-muted); margin-bottom: .2rem; }

/* ---------- badges ---------- */
.badge {
  display: inline-block;
  padding: .1rem .5rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--ink-muted);
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- swatches (styleguide) ---------- */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .6rem; }
.swatch { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.swatch .chip { height: 2.75rem; }
.swatch .name { padding: .3rem .45rem; font-family: var(--font-mono); font-size: .72rem; color: var(--ink-muted); background: var(--surface); }

.theme-form { display: flex; align-items: center; gap: .4rem; margin: 0; }
.theme-form label { margin: 0; }
