/* Component styles — spec 004a. Every color, font, and radius comes from
   tokens.css; the only allowed literals are transparent/currentColor/inherit
   and white as text on brand fills. */

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--pp-bg);
  color: var(--pp-ink);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
}

/* ---- type scale ---- */

h1 {
  margin: 0 0 var(--s5);
  font-size: var(--fs-h1);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--pp-ink-strong);
  line-height: 1.2;
}

/* The single decorative use of orange: one marker beneath the h1's first
   word (AC-004a-4). Orange is never a text color — it fails AA. */
h1::after {
  content: "";
  display: block;
  width: 2.5em;
  height: 4px;
  margin-top: var(--s2);
  background: var(--pp-accent);
}

h2 {
  margin: var(--s6) 0 var(--s3);
  font-size: var(--fs-h2);
  font-weight: 600;
  color: var(--pp-ink-strong);
}

h3 {
  margin: var(--s5) 0 var(--s2);
  font-size: var(--fs-h3);
  font-weight: 600;
  color: var(--pp-ink-strong);
}

.label {
  font-size: var(--fs-label);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--pp-ink-muted);
}

.small {
  font-size: var(--fs-small);
  color: var(--pp-ink-muted);
}

.num {
  font-variant-numeric: tabular-nums;
}

a {
  color: var(--pp-brand);
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: var(--focus);
  outline-offset: 2px;
}

/* ---- shared layout ---- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s3) var(--s4);
  max-width: var(--content-max);
  margin-inline: auto;
  padding: var(--s4) var(--gutter);
}

/* Section tabs (spec 005) — rendered only on client pages. */
.site-header .tabs {
  display: flex;
  gap: var(--s5);
}

.site-header .tabs a {
  padding: 6px 0;
  border-bottom: 2px solid transparent;
  color: var(--pp-ink);
  text-decoration: none;
  font-weight: 500;
}

.site-header .tabs a[aria-current="page"] {
  color: var(--pp-brand-strong);
  border-bottom-color: var(--pp-brand);
}

/* ---- client switcher (spec 006) — multi-client users only ---- */

.header-left {
  display: flex;
  align-items: center;
  gap: var(--s4);
  min-width: 0;
}

.client-switch {
  position: relative;
}

.client-switch summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: 6px 14px;
  border: 1px solid var(--pp-line-strong);
  border-radius: var(--r-pill);
  font-size: calc(var(--fs-body) - 1px);
  font-weight: 600;
  color: var(--pp-ink-strong);
  background: var(--pp-bg);
  white-space: nowrap;
}

.client-switch summary::-webkit-details-marker {
  display: none;
}

/* CSS-drawn chevron; no image asset, flips nothing when open (native
   details semantics carry the state). */
.client-switch summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--pp-ink-muted);
  border-bottom: 2px solid var(--pp-ink-muted);
  transform: rotate(45deg) translateY(-2px);
}

.client-switch[open] summary {
  border-color: var(--pp-brand);
}

.client-switch summary:focus-visible {
  outline: var(--focus);
  outline-offset: 2px;
}

.switch-menu {
  position: absolute;
  top: calc(100% + var(--s2));
  left: 0;
  z-index: 10;
  min-width: 240px;
  /* Keeps the menu on screen at 400px viewports. */
  max-width: calc(100vw - 2 * var(--gutter));
  margin: 0;
  padding: var(--s2);
  list-style: none;
  background: var(--pp-bg);
  border: 1px solid var(--pp-line-strong);
  border-radius: var(--r-md);
}

.switch-menu a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-sm);
  color: var(--pp-ink-strong);
  text-decoration: none;
  font-size: calc(var(--fs-body) - 1px);
}

.switch-menu a:hover {
  background: var(--pp-surface);
}

.switch-menu a[aria-current="true"] {
  background: var(--pp-brand-tint);
  color: var(--pp-brand-strong);
  font-weight: 600;
}

.switch-slug {
  font-size: var(--fs-small);
  font-weight: 400;
  color: var(--pp-ink-muted);
}

.switch-all {
  margin-top: var(--s1);
  padding-top: var(--s2);
  border-top: 1px solid var(--pp-line);
}

.switch-all a {
  color: var(--pp-brand-strong);
  font-weight: 500;
}

.site-header .brand {
  display: inline-flex;
  align-items: center;
}

.site-header .brand img {
  display: block;
  height: 28px;
  width: auto;
}

.site-header .session {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-width: 0;
}

.session-email {
  font-size: var(--fs-small);
  color: var(--pp-ink-muted);
  overflow-wrap: anywhere;
}

main {
  max-width: var(--content-max);
  margin-inline: auto;
  padding: var(--s6) var(--gutter) var(--s7);
}

.note {
  margin: 0 0 var(--s5);
  max-width: 34rem;
  color: var(--pp-ink-muted);
}

/* ---- buttons ---- */

.btn {
  display: inline-block;
  padding: 9px 22px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  font: inherit;
  font-size: calc(var(--fs-body) - 1px);
  font-weight: 600;
  line-height: var(--lh-body);
  text-decoration: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--pp-brand);
  border-color: var(--pp-brand);
  color: white;
}

.btn-primary:hover {
  background: var(--pp-brand-strong);
  border-color: var(--pp-brand-strong);
}

.btn-secondary {
  background: transparent;
  border-color: var(--pp-brand);
  color: var(--pp-brand);
}

.btn-secondary:hover {
  background: var(--pp-brand-tint);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- status pills (defined here; spec 004 applies them) ---- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-small);
  font-weight: 600;
}

.pill::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: var(--r-pill);
  background: currentColor;
}

.st-waiting  { color: var(--st-waiting-fg);  background: var(--st-waiting-bg); }
.st-progress { color: var(--st-progress-fg); background: var(--st-progress-bg); }
.st-done     { color: var(--st-done-fg);     background: var(--st-done-bg); }
.st-blocked  { color: var(--st-blocked-fg);  background: var(--st-blocked-bg); }
.st-backlog  { color: var(--st-backlog-fg);  background: var(--st-backlog-bg); }

/* ---- forms ---- */

input {
  font: inherit;
  padding: 8px 14px;
  border: 1px solid var(--pp-line-strong);
  border-radius: var(--r-sm);
  background: var(--pp-bg);
  color: var(--pp-ink-strong);
  min-width: 0;
}

/* Send-failed banner on /login (spec 007) — status tokens only, no new ones. */
.login-error {
  background: var(--st-blocked-bg);
  color: var(--st-blocked-fg);
  border-radius: var(--r-md);
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s4);
}

.login-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}

.login-form input {
  flex: 1 1 16rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- client chooser (spec 003) ---- */

.client-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--s2);
}

.client-list a {
  display: block;
  padding: var(--s3) var(--s4);
  background: var(--pp-surface);
  border: 1px solid var(--pp-line);
  border-radius: var(--r-md);
  text-decoration: none;
}

/* ---- /admin (spec 002) ---- */

/* Sign-in attempts table (spec 008) — the repo's first table component;
   existing tokens only. */
.attempts {
  width: 100%;
  border-collapse: collapse;
  background: var(--pp-surface);
  border: 1px solid var(--pp-line);
  border-radius: var(--r-md);
  font-size: var(--fs-small);
}

.attempts th,
.attempts td {
  padding: var(--s2) var(--s3);
  text-align: left;
  border-bottom: 1px solid var(--pp-line);
}

.attempts th {
  font-weight: 600;
  color: var(--pp-ink-muted);
}

.attempts tbody tr:last-child td {
  border-bottom: none;
}

.refresh-status {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--s1) var(--s5);
  margin: 0 0 var(--s5);
  padding: var(--s4) var(--s5);
  background: var(--pp-surface);
  border: 1px solid var(--pp-line);
  border-radius: var(--r-md);
}

.refresh-status dt {
  color: var(--pp-ink-muted);
}

.refresh-status dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.outcome-ok {
  color: var(--st-done-fg);
}

.outcome-failed {
  color: var(--st-blocked-fg);
}

.outcome-unknown {
  color: var(--pp-ink-muted);
}

.refresh-error {
  margin: 0;
  font: inherit;
  font-size: var(--fs-small);
  white-space: pre-wrap;
}

/* /admin sync status (spec 011) — the attempts table rules apply to every
   admin table; the guard-trip banner reuses the blocked status tokens like
   the login error banner (spec 007). No new tokens. */
.admin-table {
  margin-bottom: var(--s5);
}

.sync-banner {
  background: var(--st-blocked-bg);
  color: var(--st-blocked-fg);
  border-radius: var(--r-md);
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s4);
}

.sync-banner code {
  font: inherit;
  font-size: var(--fs-small);
}
