/* theme.css: OIDC Trust Check. "Release gate inspector": a calm checkpoint log.
   Written at the design stage (DESIGN.md); loaded after styles.css, so these rules win.
   The builder keeps it linked and adds layout only if it must: no colours, radii, shadows or
   font sizes outside this file.
   Signature: the dashed conditional lane. The AWS column ("If the job runs") is drawn with dashed
   rules and dashed verdict outlines, because that result only applies if GitHub lets the job run.
   Nothing else on the page is dashed except the second gate in the brand mark. */

:root {
  color-scheme: light dark;

  /* Palette, light. Contrast ratios against --surface (#ffffff) unless noted. */
  --bg: #f4f5f2;            /* page */
  --surface: #ffffff;       /* panels */
  --raised: #eceeea;        /* example code, ad slot, kbd, table head */
  --text: #19201c;          /* 16.4:1 on surface, 15.1:1 on bg */
  --muted: #4f5953;         /* 7.0:1 on surface, 6.5:1 on bg, 5.9:1 on raised */
  --border: #d3d8d2;        /* hairlines only, never text */
  --border-strong: #859087; /* input edges, dashed lane: 3.3:1 on surface */
  --accent: #1d4f73;        /* petrol blue, 8.6:1 with --on-accent */
  --accent-hover: #163e5c;
  --accent-active: #10304a;
  --accent-text: #1d4f73;   /* links, 8.6:1 on surface, 7.9:1 on bg */
  --accent-tint: #e5eef5;   /* focus halo, house card; --text on it 14.6:1 */
  --on-accent: #ffffff;
  --success: #1e6b3a;       /* 6.5:1 on surface, 5.7:1 on --success-tint */
  --success-tint: #e6f2ea;
  --warning: #8a5300;       /* 6.3:1 on surface, 5.6:1 on --warning-tint */
  --warning-tint: #fbf1df;
  --danger: #b42318;        /* 6.6:1 on surface, 5.6:1 on --danger-tint */
  --danger-tint: #fbe9e7;

  /* Type */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --t-xs: 0.8125rem;   /* 13 px caps labels */
  --t-sm: 0.9375rem;   /* 15 px hints, errors, reasons, code */
  --t-md: 1.0625rem;   /* 17 px body */
  --t-lg: 1.3125rem;   /* 21 px h2, summary line */
  --t-xl: 1.625rem;    /* 26 px results heading on desktop */
  --t-2xl: clamp(1.75rem, 4.5vw, 2.5rem); /* h1 */

  /* Space */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

  /* Shape */
  --r-s: 6px; --r-m: 10px; --r-l: 14px; --r-pill: 999px;
  --shadow-1: 0 1px 2px rgb(20 30 25 / 0.06), 0 4px 16px rgb(20 30 25 / 0.06);
  --shadow-2: 0 8px 32px rgb(20 30 25 / 0.18);

  /* Motion */
  --fast: 160ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  /* The template's own names, mapped so its leftover rules follow the palette. */
  --line: var(--border);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513;
    --surface: #191f1c;
    --raised: #222a26;
    --text: #e6ebe7;          /* 14.2:1 on surface */
    --muted: #a5b0a9;         /* 7.4:1 on surface, 6.6:1 on raised */
    --border: #313b36;
    --border-strong: #6c7a72; /* 3.6:1 non-text */
    --accent: #7fb8e0;        /* 8.2:1 with --on-accent */
    --accent-hover: #99c7e8;
    --accent-active: #b3d5ee;
    --accent-text: #8cc0e4;   /* 8.4:1 on surface */
    --accent-tint: #1c2c38;
    --on-accent: #0b1a26;
    --success: #74d295;       /* 9.0:1 on surface, 7.6:1 on tint */
    --success-tint: #16301f;
    --warning: #f0b75a;       /* 9.3:1 on surface, 8.0:1 on tint */
    --warning-tint: #33270f;
    --danger: #ff9184;        /* 7.6:1 on surface, 6.4:1 on tint */
    --danger-tint: #3a1d1a;
    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4), 0 4px 16px rgb(0 0 0 / 0.25);
    --shadow-2: 0 8px 32px rgb(0 0 0 / 0.5);
  }
}

/* ---------- Page ---------- */

html { background: var(--bg); }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--t-md);
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}
header, main, footer { max-width: 68rem; padding-left: var(--s5); padding-right: var(--s5); }
@media (max-width: 40rem) {
  header, main, footer { padding-left: var(--s4); padding-right: var(--s4); }
}

header { border-bottom: 1px solid var(--border); padding-top: var(--s2); padding-bottom: var(--s2); }
.brand {
  display: inline-flex; align-items: center; gap: var(--s2);
  min-height: 44px; line-height: 1.2;
  font-weight: 700; letter-spacing: -0.01em; color: var(--text);
}
.brand::before {
  content: ""; flex: none; width: 28px; height: 28px; border-radius: var(--r-s);
  background: url("icons/favicon.svg") center / cover no-repeat;
}
header nav a { color: var(--muted); text-decoration: none; padding: 0 var(--s2); border-radius: var(--r-s); }
header nav a:hover { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }

h1 {
  font-size: var(--t-2xl); font-weight: 750; letter-spacing: -0.02em; line-height: 1.12;
  margin: var(--s6) 0 var(--s3);
}
.lede { font-size: var(--t-lg); line-height: 1.45; color: var(--muted); max-width: 60ch; margin: 0 0 var(--s5); }
h2 { font-size: var(--t-lg); letter-spacing: -0.01em; line-height: 1.3; margin: var(--s7) 0 var(--s3); }
h3 { font-size: var(--t-md); margin: var(--s5) 0 var(--s1); }
main > p, main > ul, main > ol, main > h3 { max-width: 68ch; }
main li + li { margin-top: var(--s2); }

a { color: var(--accent-text); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

code, kbd, pre, .mono { font-family: var(--font-mono); font-variant-ligatures: none; }
code {
  font-size: 0.9em; padding: 1px 5px; border-radius: 4px;
  background: var(--raised); color: var(--text); overflow-wrap: anywhere;
}
kbd {
  font-size: var(--t-xs); padding: 1px 6px; border-radius: 4px;
  border: 1px solid var(--border); border-bottom-width: 2px; background: var(--surface); color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px var(--accent-tint);
}

/* ---------- Tool: inputs panel ---------- */

.tool { margin: 0; }
.inputs {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l);
  box-shadow: var(--shadow-1); padding: var(--s5);
}
@media (max-width: 40rem) { .inputs { padding: var(--s4); border-radius: var(--r-m); } }

.fields { display: grid; grid-template-columns: 1fr 1fr; column-gap: var(--s5); }
@media (max-width: 52rem) { .fields { grid-template-columns: 1fr; gap: var(--s4); } }

.field { display: flex; flex-direction: column; min-width: 0; }
.field label {
  display: flex; align-items: center; gap: var(--s2);
  font-size: var(--t-xs); font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text); margin-bottom: var(--s1);
}
.field label .step {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: var(--r-pill);
  background: var(--text); color: var(--surface); font-size: var(--t-xs); letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}
.hint { margin: 0 0 var(--s2); font-size: var(--t-sm); color: var(--muted); line-height: 1.45; }

textarea, input[type="text"], select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-m);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
textarea {
  min-height: 18rem; padding: var(--s3) var(--s4); resize: vertical;
  font-family: var(--font-mono); font-size: var(--t-sm); line-height: 1.55; tab-size: 2;
}
textarea::placeholder { color: var(--muted); opacity: 1; }
textarea:hover { border-color: var(--text); }
textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
@media (max-width: 52rem) { textarea { min-height: 13rem; } }

/* Error line under each field: always in the DOM, one line reserved, so nothing jumps. */
.field-error {
  min-height: 1.45em; margin: var(--s2) 0 0; font-size: var(--t-sm); line-height: 1.45;
  color: var(--danger); font-weight: 600;
}
.field-error:not(:empty)::before {
  content: ""; display: inline-block; width: 8px; height: 8px; margin-right: var(--s2);
  border-radius: 2px; background: var(--danger); transform: translateY(-1px) rotate(45deg);
}
.field.invalid textarea, textarea[aria-invalid="true"] {
  border: 2px solid var(--danger); background: var(--danger-tint);
  padding: calc(var(--s3) - 1px) calc(var(--s4) - 1px);
}

/* ---------- Buttons ---------- */

.actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3);
  margin: var(--s4) 0 0; padding-top: var(--s4); border-top: 1px solid var(--border);
}
.actions .push { margin-left: auto; }

.actions button, button.primary, button.secondary, button.quiet, .consent button {
  min-height: 44px; padding: 0 var(--s5); border-radius: var(--r-m);
  font: inherit; font-weight: 650; line-height: 1.2; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease),
    color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.actions button:active, button.primary:active, button.secondary:active, button.quiet:active { transform: translateY(1px); }

button.primary, .actions button.primary {
  min-height: 48px; padding: 0 var(--s6);
  background: var(--accent); color: var(--on-accent); border: 1px solid var(--accent);
  box-shadow: var(--shadow-1);
}
button.primary:hover, .actions button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.primary:active, .actions button.primary:active { background: var(--accent-active); border-color: var(--accent-active); }
button.primary svg { width: 18px; height: 18px; }

/* The template's Clear button arrives filled; every non-primary button is outline or quiet. */
.actions button, button.secondary {
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
}
.actions button:hover, button.secondary:hover { border-color: var(--text); background: var(--raised); }

button.quiet, .actions button.quiet {
  background: transparent; color: var(--accent-text); border: 1px solid transparent; padding: 0 var(--s4);
}
button.quiet:hover, .actions button.quiet:hover { background: var(--accent-tint); color: var(--accent-text); }

button:disabled, button[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }

.kbd-hint { font-size: var(--t-sm); color: var(--muted); }
@media (max-width: 40rem) {
  .actions button.primary { flex: 1 1 100%; }
  .kbd-hint { display: none; }
  .actions .push { margin-left: 0; }
}

/* ---------- Status line ---------- */

#status {
  min-height: 1.55em; margin: var(--s4) 0; font-size: var(--t-md); font-weight: 600;
  color: var(--text); font-variant-numeric: tabular-nums;
}
#status.error { color: var(--danger); }
#status.ok { color: var(--text); }

/* ---------- Output: empty state ---------- */

#output { min-height: 7rem; }
.empty-state {
  display: flex; gap: var(--s4); align-items: flex-start;
  padding: var(--s5); border: 1px dashed var(--border-strong); border-radius: var(--r-l);
  color: var(--muted); background: transparent;
}
.empty-state svg { flex: none; width: 40px; height: 40px; color: var(--border-strong); }
.empty-state strong { display: block; color: var(--text); font-size: var(--t-md); margin-bottom: var(--s1); }
.empty-state p { margin: 0; font-size: var(--t-sm); max-width: 60ch; }

/* ---------- Output: results ---------- */

.results {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l);
  box-shadow: var(--shadow-1); overflow: hidden;
  animation: rise 180ms var(--ease) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.results-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: var(--s3) var(--s5); padding: var(--s5) var(--s5) var(--s4);
  border-bottom: 1px solid var(--border);
}
.results-head h2 { margin: 0; font-size: var(--t-xl); line-height: 1.2; }
@media (max-width: 40rem) { .results-head { padding: var(--s4); } .results-head h2 { font-size: var(--t-lg); } }

.tally { display: flex; flex-wrap: wrap; gap: var(--s2); margin: 0; padding: 0; list-style: none; }
.tally li {
  margin: 0; display: inline-flex; align-items: center; gap: var(--s2);
  min-height: 32px; padding: 0 var(--s3); border-radius: var(--r-pill);
  font-size: var(--t-sm); font-weight: 650; font-variant-numeric: tabular-nums;
  border: 1px solid currentColor;
}
.tally .pass { color: var(--success); background: var(--success-tint); }
.tally .gh, .tally .aws { color: var(--danger); background: var(--danger-tint); }
.tally .unknown { color: var(--warning); background: var(--warning-tint); }

/* Claims readout: the job the AWS check imagines. */
.claims {
  margin: 0; padding: var(--s4) var(--s5); background: var(--raised);
  border-bottom: 1px solid var(--border); font-size: var(--t-sm);
}
.claims dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--s1) var(--s4); margin: 0; }
.claims-title {
  margin: 0 0 var(--s2); font-family: var(--font-sans);
  font-size: var(--t-xs); font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted);
}
.claims dt { font-family: var(--font-mono); color: var(--muted); }
.claims dd { margin: 0; font-family: var(--font-mono); color: var(--text); overflow-wrap: anywhere; min-width: 0; }
@media (max-width: 40rem) {
  .claims { padding: var(--s4); }
  .claims dl { grid-template-columns: max-content minmax(0, 1fr); gap: var(--s1) var(--s3); }
  /* The subject and provider are the first and last claim pairs. */
  .claims dl > :is(:first-of-type, :last-of-type) { grid-column: 1 / -1; }
}

/* The ref table */
table.refs { width: 100%; border-collapse: collapse; font-size: var(--t-sm); table-layout: fixed; }
table.refs col.c-ref { width: 22%; }
table.refs col.c-gh { width: 28%; }
table.refs col.c-aws { width: 30%; }
table.refs col.c-first { width: 20%; }
table.refs th {
  text-align: left; vertical-align: bottom; padding: var(--s3) var(--s4);
  font-size: var(--t-xs); font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted); background: var(--surface); border-bottom: 1px solid var(--border-strong);
}
table.refs th small {
  display: block; margin-top: 2px; font-size: var(--t-xs); font-weight: 600; letter-spacing: 0;
  text-transform: none; color: var(--muted); font-style: italic;
}
table.refs td {
  padding: var(--s4); vertical-align: top; border-bottom: 1px solid var(--border);
  line-height: 1.45; overflow-wrap: anywhere;
}
table.refs tbody tr:last-child td { border-bottom: 0; }
table.refs tbody tr { transition: background-color var(--fast) var(--ease); }
table.refs tbody tr:hover { background: color-mix(in srgb, var(--raised) 45%, transparent); }

/* Signature: the dashed conditional lane. */
table.refs .lane-aws { border-left: 2px dashed var(--border-strong); border-right: 2px dashed var(--border-strong); }
table.refs th.lane-aws { border-top: 0; }

.ref { font-family: var(--font-mono); font-size: var(--t-sm); color: var(--text); word-break: break-all; }
.ref .prefix { color: var(--muted); }
.ref-n { display: block; margin-bottom: 2px; font-family: var(--font-sans); font-size: var(--t-xs); color: var(--muted); font-variant-numeric: tabular-nums; }

/* Verdict: icon + word, never colour alone. */
.verdict {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 28px; padding: 0 var(--s3) 0 var(--s2); border-radius: var(--r-pill);
  font-family: var(--font-sans); font-size: var(--t-sm); font-weight: 700; line-height: 1;
  border: 1.5px solid currentColor; white-space: nowrap;
}
.verdict svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.verdict.match { color: var(--success); background: var(--success-tint); }
.verdict.block { color: var(--danger); background: var(--danger-tint); }
.verdict.unknown { color: var(--warning); background: var(--warning-tint); }
.lane-aws .verdict { border-style: dashed; }
.reason { display: block; margin-top: var(--s2); color: var(--text); }
.reason code { font-size: 0.92em; }

/* First blocker: the row's answer, a coloured edge plus the words. */
.blocker {
  display: block; padding: var(--s1) 0 var(--s1) var(--s3); border-left: 4px solid currentColor;
  font-weight: 750; font-size: var(--t-md); line-height: 1.3;
}
.blocker.github, .blocker.aws { color: var(--danger); }
.blocker.both { color: var(--success); }
.blocker.unknown { color: var(--warning); }
.blocker-label { display: none; }

/* Phone: each row becomes a stacked block, still a table to assistive tech. */
@media (max-width: 46rem) {
  table.refs, table.refs tbody, table.refs tr, table.refs td { display: block; width: 100%; }
  table.refs thead, table.refs colgroup { display: none; }
  table.refs tbody tr { padding: var(--s4); border-bottom: 1px solid var(--border-strong); }
  table.refs tbody tr:last-child { border-bottom: 0; }
  table.refs td { padding: var(--s2) 0; border: 0; }
  table.refs td::before {
    content: attr(data-label); display: block; margin-bottom: var(--s1);
    font-size: var(--t-xs); font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted);
  }
  table.refs td.lane-aws { border: 0; border-left: 2px dashed var(--border-strong); padding-left: var(--s3); margin: var(--s1) 0; }
  table.refs td.cell-ref::before { display: none; }
  table.refs td.cell-ref .ref { font-size: var(--t-md); font-weight: 600; }
}

/* Conditional note under the table. */
.note {
  display: flex; gap: var(--s3); margin: 0; padding: var(--s4) var(--s5);
  border-top: 1px solid var(--border); background: var(--raised);
  font-size: var(--t-sm); color: var(--muted); line-height: 1.5;
}
.note svg { flex: none; width: 18px; height: 18px; margin-top: 2px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.note strong { color: var(--text); }
.note p { margin: 0; max-width: 80ch; }
@media (max-width: 40rem) { .note { padding: var(--s4); } }

/* ---------- Reading section ---------- */

.example {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l);
  padding: var(--s5); margin: var(--s4) 0;
}
.example .files { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
@media (max-width: 52rem) { .example .files { grid-template-columns: 1fr; } }
.example figure { margin: 0; min-width: 0; }
.example figcaption {
  font-size: var(--t-xs); font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted); margin-bottom: var(--s2);
}
.example pre, main pre {
  margin: 0; padding: var(--s4); background: var(--raised); border-radius: var(--r-m);
  font-size: var(--t-sm); line-height: 1.5; color: var(--text);
  overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere;
}
.example table { width: 100%; border-collapse: collapse; margin-top: var(--s4); font-size: var(--t-sm); }
.example th, .example td { text-align: left; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
.example th { font-size: var(--t-xs); letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }

.callout {
  margin: var(--s4) 0 0; padding: var(--s3) var(--s4); border-radius: var(--r-m);
  border-left: 4px solid var(--accent); background: var(--accent-tint); color: var(--text);
  font-size: var(--t-sm); max-width: 80ch;
}
.callout.warn { border-left-color: var(--warning); background: var(--warning-tint); }
.callout strong { color: var(--text); }

/* ---------- Template furniture: restyled, never resized ---------- */

.ad-slot { background: var(--raised); border: 1px solid var(--border); }
.ad-label { opacity: 1; color: var(--muted); font-size: var(--t-xs); letter-spacing: 0.07em; text-transform: uppercase; font-weight: 700; }
.house-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-m);
  transition: border-color var(--fast) var(--ease);
}
.house-card:hover { border-color: var(--accent); }
.house-card strong { color: var(--accent-text); }
.house-card span { color: var(--muted); }

.consent { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-l); box-shadow: var(--shadow-2); }
.consent button { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
.consent button:hover { background: var(--raised); border-color: var(--text); }

footer {
  opacity: 1; color: var(--muted); font-size: var(--t-sm);
  border-top: 1px solid var(--border); margin-top: var(--s8); padding-top: var(--s5); padding-bottom: var(--s6);
}
footer a { color: var(--accent-text); }

/* ---------- Motion off ---------- */

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