/* =============================================================
 * Josh — Spec stylesheet
 * Layered on top of /docs/_assets/docs.css.
 * Used by /docs/spec/index.html and /docs/spec/<id>.html (generated
 * by bin/build-spec.py from docs/spec/data/<id>.yaml).
 * ============================================================= */

/* ---------- index page: filters + cards ---------- */

.spec-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--josh-s-3);
  align-items: center;
  margin: 0 0 var(--josh-s-6) 0;
  padding: var(--josh-s-3) var(--josh-s-4);
  border: 1px solid var(--josh-line);
  border-radius: var(--josh-r-card);
  background: var(--josh-surface);
}
.spec-toolbar .group {
  display: flex;
  align-items: center;
  gap: var(--josh-s-2);
}
.spec-toolbar .group-label {
  font-family: var(--josh-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--josh-muted);
}
.spec-toolbar button {
  font-family: var(--josh-ui);
  font-size: 12.5px;
  line-height: 18px;
  padding: 4px 10px;
  border: 1px solid var(--josh-line);
  border-radius: var(--josh-r-pill);
  background: var(--josh-bg);
  color: var(--josh-body);
  cursor: pointer;
  transition: background 80ms ease, border-color 80ms ease, color 80ms ease;
}
.spec-toolbar button:hover { border-color: var(--josh-muted-2); color: var(--josh-ink); }
.spec-toolbar button[aria-pressed="true"] {
  background: var(--josh-tint);
  border-color: var(--josh-muted-2);
  color: var(--josh-ink);
  font-weight: 500;
}
.spec-toolbar .spacer { flex: 1; }

.spec-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--josh-s-4);
  margin-bottom: var(--josh-s-7);
}
@media (max-width: 720px) { .spec-grid { grid-template-columns: 1fr; } }

.spec-card {
  position: relative;
  display: block;
  border: 1px solid var(--josh-line);
  border-radius: var(--josh-r-card);
  padding: var(--josh-s-4) var(--josh-s-5);
  background: var(--josh-surface);
  text-decoration: none;
  transition: border-color 80ms ease, box-shadow 80ms ease;
}
.spec-card:hover {
  border-color: var(--josh-muted-2);
  box-shadow: var(--josh-shadow-1);
}
.spec-card .row {
  display: flex;
  align-items: center;
  gap: var(--josh-s-2);
  flex-wrap: wrap;
  margin-bottom: var(--josh-s-2);
}
.spec-card h3 {
  margin: 0 0 var(--josh-s-2) 0;
  font-family: var(--josh-serif);
  font-size: 18px;
  line-height: 24px;
  font-weight: 500;
  color: var(--josh-ink);
  letter-spacing: -0.1px;
}
.spec-card .why {
  margin: 0;
  font-size: 13.5px;
  line-height: 20px;
  color: var(--josh-body);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.spec-card[hidden] { display: none; }

/* ---------- status pills ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--josh-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--josh-r-pill);
  border: 1px solid currentColor;
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

/* status colors (use design tokens; oklch for accents) */
.pill.status-draft        { color: var(--josh-muted-2); background: var(--josh-wash); }
.pill.status-planned      { color: oklch(0.55 0.14 245); background: var(--josh-cool-tint); }
.pill.status-in_progress  { color: oklch(0.7  0.13 90);  background: var(--josh-gold-tint); }
.pill.status-blocked      { color: oklch(0.55 0.18 25);  background: var(--josh-red-tint); }
.pill.status-verified     { color: oklch(0.55 0.13 155); background: var(--josh-green-tint); }
.pill.status-shipped      { color: var(--josh-ink); background: var(--josh-tint); border-color: var(--josh-ink); }

/* category badges */
.pill.cat-substrate { color: var(--josh-ink-2); background: var(--josh-wash); border-color: var(--josh-line); }
.pill.cat-source    { color: oklch(0.55 0.14 245); background: var(--josh-cool-tint); border-color: var(--josh-cool-tint); }
.pill.cat-surface   { color: oklch(0.62 0.14 40);  background: var(--josh-warm-tint); border-color: var(--josh-warm-tint); }
.pill.cat-launch    { color: oklch(0.55 0.13 155); background: var(--josh-green-tint); border-color: var(--josh-green-tint); }

.pill.priority-p0 { color: oklch(0.55 0.18 25); background: var(--josh-red-tint); border-color: var(--josh-red-tint); }
.pill.priority-p1 { color: var(--josh-muted); background: var(--josh-wash); border-color: var(--josh-line); }
.pill.priority-p2 { color: var(--josh-muted-2); background: var(--josh-bg); border-color: var(--josh-line-2); }

/* ---------- spec page: header card ---------- */

.spec-header {
  margin: 0 0 var(--josh-s-7) 0;
}
.spec-header .pills {
  display: flex;
  gap: var(--josh-s-2);
  flex-wrap: wrap;
  margin-bottom: var(--josh-s-3);
}
.spec-header .meta-line {
  font-family: var(--josh-mono);
  font-size: 11.5px;
  color: var(--josh-muted);
  margin: var(--josh-s-2) 0 0 0;
}
.spec-header .meta-line code { background: transparent; padding: 0; font-size: inherit; }

/* ---------- spec page: section blocks ---------- */

.spec-section {
  position: relative;
  border-top: 1px solid var(--josh-line-2);
  padding-top: var(--josh-s-5);
  margin-top: var(--josh-s-6);
}
.spec-section:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.spec-section > h2 {
  margin: 0 0 var(--josh-s-3) 0;
  border-top: none;
  padding-top: 0;
}
.spec-section .section-label {
  font-family: var(--josh-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--josh-muted);
  margin: 0 0 var(--josh-s-2) 0;
}
.spec-section[data-empty="true"] .empty-note {
  font-style: italic;
  color: var(--josh-muted);
  font-size: 13.5px;
}

/* ---------- pencil edit affordance ---------- */

.spec-section .pencil {
  position: absolute;
  top: var(--josh-s-5);
  right: 0;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--josh-line);
  border-radius: var(--josh-r-default);
  background: var(--josh-surface);
  color: var(--josh-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 80ms ease, border-color 80ms ease, color 80ms ease;
  font-size: 14px;
}
.spec-section:first-of-type .pencil { top: 0; }
.spec-section:hover .pencil,
.spec-section .pencil:focus { opacity: 1; }
.spec-section .pencil:hover { border-color: var(--josh-muted-2); color: var(--josh-ink); }
.spec-section .pencil[hidden] { display: none; }

/* ---------- user stories ---------- */

.user-story {
  border-left: 3px solid var(--josh-line);
  padding: var(--josh-s-2) var(--josh-s-4);
  margin: 0 0 var(--josh-s-3) 0;
  background: var(--josh-bg);
  border-radius: 0 var(--josh-r-card) var(--josh-r-card) 0;
}
.user-story p { margin: 0; line-height: 22px; font-size: 14px; }
.user-story .role {
  font-family: var(--josh-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--josh-muted);
  margin-right: 6px;
}

/* ---------- EARS-format acceptance criteria ---------- */

ol.ears {
  list-style: none;
  padding-left: 0;
  counter-reset: ears;
}
ol.ears li {
  counter-increment: ears;
  position: relative;
  padding: var(--josh-s-3) var(--josh-s-4) var(--josh-s-3) calc(var(--josh-s-7) + 4px);
  margin-bottom: var(--josh-s-3);
  border: 1px solid var(--josh-line);
  border-radius: var(--josh-r-card);
  background: var(--josh-surface);
  font-size: 14px;
  line-height: 22px;
}
ol.ears li::before {
  content: "AC " counter(ears, decimal-leading-zero);
  position: absolute;
  left: var(--josh-s-3);
  top: var(--josh-s-3);
  font-family: var(--josh-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.6px;
  color: var(--josh-muted);
}
/* highlight the EARS keyword the criterion starts with */
ol.ears li .keyword {
  display: inline-block;
  font-family: var(--josh-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--josh-ink);
  background: var(--josh-tint);
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 4px;
}

/* ---------- success determiner ---------- */

.determiner {
  border: 1px solid var(--josh-muted-2);
  border-radius: var(--josh-r-card);
  background: var(--josh-surface);
  padding: var(--josh-s-4) var(--josh-s-5);
}
.determiner .kind-row {
  display: flex;
  align-items: center;
  gap: var(--josh-s-2);
  margin-bottom: var(--josh-s-3);
  font-family: var(--josh-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.determiner .kind-pill {
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--josh-r-pill);
  background: var(--josh-ink);
  color: var(--josh-bg);
}
.determiner .kind-row .label {
  color: var(--josh-muted);
}
.determiner pre {
  margin-bottom: var(--josh-s-3);
}
.determiner .field-label {
  font-family: var(--josh-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--josh-muted);
  margin: var(--josh-s-3) 0 var(--josh-s-2) 0;
}
.determiner .expect {
  font-family: var(--josh-mono);
  font-size: 12.5px;
  color: var(--josh-ink-2);
  background: var(--josh-wash);
  padding: 6px 10px;
  border-radius: var(--josh-r-default);
  display: inline-block;
}
.determiner .notes { color: var(--josh-body); font-size: 13.5px; line-height: 21px; margin: var(--josh-s-2) 0 0 0; }

/* ---------- tasks ---------- */

ul.tasks {
  list-style: none;
  padding-left: 0;
  margin: 0;
}
ul.tasks li {
  display: flex;
  align-items: flex-start;
  gap: var(--josh-s-3);
  padding: 6px 10px;
  border-radius: var(--josh-r-default);
  font-size: 13.5px;
  line-height: 20px;
  color: var(--josh-body);
}
ul.tasks li:hover { background: var(--josh-wash); }
ul.tasks li input[type="checkbox"] {
  margin-top: 4px;
  cursor: pointer;
  accent-color: var(--josh-ink);
}
ul.tasks li.done .text { color: var(--josh-muted); text-decoration: line-through; text-decoration-color: var(--josh-line); }
ul.tasks li .id {
  font-family: var(--josh-mono);
  font-size: 11px;
  color: var(--josh-muted-2);
  flex: 0 0 36px;
}

/* ---------- changelog ---------- */

ul.changelog {
  list-style: none;
  padding-left: 0;
  margin: 0;
  border-left: 2px solid var(--josh-line);
}
ul.changelog li {
  position: relative;
  padding: 0 0 var(--josh-s-4) var(--josh-s-5);
  margin-left: 0;
  font-size: 13.5px;
  line-height: 20px;
}
ul.changelog li::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--josh-bg);
  border: 2px solid var(--josh-muted-2);
}
ul.changelog .when {
  font-family: var(--josh-mono);
  font-size: 11px;
  color: var(--josh-muted);
  display: inline-block;
  margin-right: 6px;
}
ul.changelog .arrow { font-family: var(--josh-mono); color: var(--josh-muted-2); margin: 0 4px; }
ul.changelog .note { display: block; margin-top: 4px; color: var(--josh-body); }
ul.changelog .commit {
  font-family: var(--josh-mono);
  font-size: 11.5px;
  background: var(--josh-wash);
  color: var(--josh-ink-2);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 6px;
}

/* ---------- clarifications, out-of-scope, dependencies ---------- */

.callout {
  border-left: 3px solid var(--josh-muted-2);
  background: var(--josh-wash);
  border-radius: 0 var(--josh-r-card) var(--josh-r-card) 0;
  padding: var(--josh-s-3) var(--josh-s-4);
  margin: 0 0 var(--josh-s-3) 0;
}
.callout.warn   { border-left-color: oklch(0.55 0.18 25); background: var(--josh-red-tint); }
.callout.info   { border-left-color: oklch(0.55 0.14 245); background: var(--josh-cool-tint); }
.callout.muted  { border-left-color: var(--josh-muted-2); }
.callout p { margin: 0; }
.callout ul { margin: 0; padding-left: 18px; }
.callout li { font-size: 13.5px; line-height: 21px; color: var(--josh-body); }

/* ---------- editor (modal) ---------- */

dialog.spec-editor {
  border: 1px solid var(--josh-line);
  border-radius: var(--josh-r-surface);
  padding: 0;
  width: min(720px, 92vw);
  max-height: 88vh;
  background: var(--josh-surface);
  color: var(--josh-body);
  box-shadow: var(--josh-shadow-3);
}
dialog.spec-editor::backdrop { background: rgba(15,17,21,0.32); }
dialog.spec-editor .editor-head {
  display: flex;
  align-items: center;
  gap: var(--josh-s-3);
  padding: var(--josh-s-4) var(--josh-s-5);
  border-bottom: 1px solid var(--josh-line);
}
dialog.spec-editor .editor-head h3 {
  margin: 0;
  font-family: var(--josh-serif);
  font-size: 17px;
  font-weight: 500;
}
dialog.spec-editor .editor-head .spacer { flex: 1; }
dialog.spec-editor .editor-head button {
  font-family: var(--josh-ui);
  font-size: 12.5px;
  padding: 4px 12px;
  border: 1px solid var(--josh-line);
  border-radius: var(--josh-r-default);
  background: var(--josh-bg);
  color: var(--josh-body);
  cursor: pointer;
}
dialog.spec-editor .editor-head button.primary {
  background: var(--josh-ink);
  color: var(--josh-bg);
  border-color: var(--josh-ink);
}
dialog.spec-editor .editor-head button.primary:disabled { opacity: 0.4; cursor: not-allowed; }
dialog.spec-editor .editor-body { padding: var(--josh-s-4) var(--josh-s-5); overflow-y: auto; max-height: calc(88vh - 80px); }
dialog.spec-editor label {
  display: block;
  font-family: var(--josh-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--josh-muted);
  margin: var(--josh-s-3) 0 var(--josh-s-2) 0;
}
dialog.spec-editor input[type="text"],
dialog.spec-editor select,
dialog.spec-editor textarea {
  width: 100%;
  font-family: var(--josh-ui);
  font-size: 13.5px;
  line-height: 21px;
  padding: 8px 10px;
  border: 1px solid var(--josh-line);
  border-radius: var(--josh-r-default);
  background: var(--josh-surface);
  color: var(--josh-body);
  box-sizing: border-box;
}
dialog.spec-editor textarea {
  font-family: var(--josh-mono);
  font-size: 12.5px;
  line-height: 19px;
  resize: vertical;
  min-height: 120px;
}
dialog.spec-editor .field-help {
  font-size: 12px;
  color: var(--josh-muted);
  margin: 4px 0 0 0;
  font-style: italic;
}
dialog.spec-editor .errors {
  margin-top: var(--josh-s-3);
  padding: var(--josh-s-3);
  border-left: 3px solid oklch(0.55 0.18 25);
  background: var(--josh-red-tint);
  color: oklch(0.45 0.18 25);
  font-size: 12.5px;
  font-family: var(--josh-mono);
  border-radius: 0 var(--josh-r-default) var(--josh-r-default) 0;
}
dialog.spec-editor .errors:empty { display: none; }

/* ---------- access banner ---------- */

.access-banner {
  display: flex;
  align-items: center;
  gap: var(--josh-s-3);
  padding: var(--josh-s-3) var(--josh-s-5);
  margin: 0 0 var(--josh-s-5) 0;
  border-radius: var(--josh-r-card);
  background: var(--josh-cool-tint);
  border: 1px solid oklch(0.85 0.05 245);
  color: oklch(0.35 0.14 245);
  font-size: 13px;
  line-height: 19px;
}
.access-banner.fallback { background: var(--josh-warm-tint); border-color: oklch(0.85 0.06 60); color: oklch(0.4 0.12 40); }
.access-banner .spacer { flex: 1; }
.access-banner button {
  font-family: var(--josh-ui);
  font-size: 12.5px;
  padding: 4px 12px;
  border: 1px solid currentColor;
  border-radius: var(--josh-r-pill);
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.access-banner button:hover { background: rgba(0,0,0,0.04); }
.access-banner[hidden] { display: none; }

/* ---------- toast ---------- */

.spec-toast {
  position: fixed;
  bottom: var(--josh-s-5);
  right: var(--josh-s-5);
  padding: var(--josh-s-3) var(--josh-s-5);
  border-radius: var(--josh-r-card);
  background: var(--josh-ink);
  color: var(--josh-bg);
  font-size: 13px;
  font-family: var(--josh-ui);
  box-shadow: var(--josh-shadow-3);
  z-index: 9999;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 120ms ease, transform 120ms ease;
  pointer-events: none;
}
.spec-toast.visible { opacity: 1; transform: translateY(0); }
.spec-toast.error { background: oklch(0.45 0.18 25); }
