/*
 * Components.
 *
 * Each class mirrors a shadcn/ui component's anatomy - .card + .card-header +
 * .card-title, .badge with variants, .btn with variants and sizes - so the
 * markup reads the way a shadcn app's does even though there is no React and
 * no Tailwind here. Tokens come from tokens.css.
 *
 * Mobile first throughout: every layout is one column until a min-width says
 * otherwise, and nothing depends on hover.
 */

@import url('./tokens.css');

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  /* iOS Safari shrinks 16px inputs unless the body agrees they are 16px. */
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  height: auto;
}

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

a:hover {
  text-decoration-style: solid;
}

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: calc(var(--radius) - 4px);
}

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

.container {
  width: 100%;
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in oklab, var(--background) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.5rem;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--foreground);
  text-decoration: none;
  margin-right: auto;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: calc(var(--radius) - 2px);
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 0.8rem;
  font-weight: 700;
  flex: none;
}

.nav {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  flex-wrap: wrap;
}

.nav a {
  color: var(--muted-foreground);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.4rem 0.6rem;
  border-radius: calc(var(--radius) - 4px);
}

.nav a:hover,
.nav a[aria-current='page'] {
  color: var(--foreground);
  background: var(--secondary);
}

main {
  padding: 1.5rem 0 4rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  color: var(--muted-foreground);
  font-size: 0.85rem;
}

.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: baseline;
}

.site-footer a {
  color: var(--muted-foreground);
}

.grid-2 {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}

@media (min-width: 60rem) {
  .grid-2 {
    grid-template-columns: minmax(0, 1fr) 20rem;
    align-items: start;
  }
  .grid-2.reverse {
    grid-template-columns: 20rem minmax(0, 1fr);
  }
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.spread {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: baseline;
  justify-content: space-between;
}

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

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  letter-spacing: -0.015em;
  margin: 0;
  font-weight: 650;
}

h1 {
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.25rem);
}
h2 {
  font-size: 1.35rem;
}
h3 {
  font-size: 1.1rem;
}

.lede {
  color: var(--muted-foreground);
  font-size: 1.05rem;
  margin: 0.5rem 0 0;
}

.muted {
  color: var(--muted-foreground);
}

.small {
  font-size: 0.85rem;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* --- card -------------------------------------------------------------- */

.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
}

.card-header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 650;
  margin: 0;
}

.card-description {
  color: var(--muted-foreground);
  font-size: 0.9rem;
  margin: 0;
}

.card-link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: border-color 120ms ease, transform 120ms ease;
}

.card-link:hover {
  border-color: color-mix(in oklab, var(--primary) 45%, var(--border));
}

@media (prefers-reduced-motion: no-preference) {
  .card-link:hover {
    transform: translateY(-1px);
  }
}

/* --- badge ------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--secondary);
  color: var(--secondary-foreground);
  padding: 0.15rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 550;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-primary {
  background: color-mix(in oklab, var(--primary) 14%, transparent);
  border-color: color-mix(in oklab, var(--primary) 35%, transparent);
  color: color-mix(in oklab, var(--primary) 82%, var(--foreground));
}

.badge-outline {
  background: transparent;
}

.badge-dot::before {
  content: '';
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: currentColor;
  flex: none;
}

.badge-welcome {
  color: color-mix(in oklab, var(--agent-welcome) 80%, var(--foreground));
  border-color: color-mix(in oklab, var(--agent-welcome) 40%, transparent);
  background: color-mix(in oklab, var(--agent-welcome) 12%, transparent);
}

.badge-disclose {
  color: color-mix(in oklab, var(--agent-disclose) 78%, var(--foreground));
  border-color: color-mix(in oklab, var(--agent-disclose) 42%, transparent);
  background: color-mix(in oklab, var(--agent-disclose) 14%, transparent);
}

.badge-human {
  color: var(--muted-foreground);
}

.badge-online {
  color: color-mix(in oklab, var(--online) 80%, var(--foreground));
}
.badge-offline {
  color: var(--muted-foreground);
}

/* --- button ------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid transparent;
  background: var(--primary);
  color: var(--primary-foreground);
  /* 2.75rem clears the 44px minimum tap target without looking chunky. */
  min-height: 2.75rem;
  padding: 0 1rem;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  background: color-mix(in oklab, var(--primary) 88%, black);
}

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

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: color-mix(in oklab, var(--secondary) 85%, var(--foreground) 8%);
}

.btn-ghost {
  background: transparent;
  color: var(--foreground);
}

.btn-ghost:hover {
  background: var(--secondary);
}

.btn-destructive {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

.btn-sm {
  min-height: 2.25rem;
  padding: 0 0.7rem;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

/* --- form -------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.label {
  font-size: 0.88rem;
  font-weight: 600;
}

.hint {
  font-size: 0.82rem;
  color: var(--muted-foreground);
}

.input,
.textarea,
.select {
  width: 100%;
  background: var(--background);
  color: var(--foreground);
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.6rem 0.7rem;
  font: inherit;
  /* Anything under 16px makes iOS Safari zoom the page on focus. */
  font-size: 16px;
  min-height: 2.75rem;
}

.textarea {
  min-height: 9rem;
  resize: vertical;
  line-height: 1.55;
}

.textarea.code {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  min-height: 26rem;
}

.input:focus-visible,
.textarea:focus-visible,
.select:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 1px;
  border-color: var(--ring);
}

.field-error .input,
.field-error .textarea {
  border-color: var(--destructive);
}

.error-text {
  color: var(--destructive);
  font-size: 0.82rem;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0;
}

legend {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0 0.4rem;
}

/* --- alert ------------------------------------------------------------- */

.alert {
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: calc(var(--radius) - 2px);
  padding: 0.75rem 0.9rem;
  background: var(--card);
  font-size: 0.9rem;
}

.alert-error {
  border-left-color: var(--destructive);
  color: color-mix(in oklab, var(--destructive) 75%, var(--foreground));
}

.alert-success {
  border-left-color: var(--success);
}

.alert-warning {
  border-left-color: var(--warning);
}

.alert-info {
  border-left-color: var(--primary);
}

/* --- job list ---------------------------------------------------------- */

.job-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.job-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.job-card .job-title {
  font-size: 1.05rem;
  font-weight: 650;
  margin: 0;
}

.job-card .job-org {
  color: var(--muted-foreground);
  font-size: 0.9rem;
}

.job-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.job-salary {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

@media (min-width: 40rem) {
  .filters-inline {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    align-items: end;
  }
}

.empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted-foreground);
}

/* --- prose (rendered Markdown) ----------------------------------------- */

.prose {
  max-width: 68ch;
}

.prose > :first-child {
  margin-top: 0;
}

.prose h2,
.prose h3,
.prose h4 {
  margin: 1.75rem 0 0.6rem;
}

.prose p,
.prose ul,
.prose ol,
.prose blockquote,
.prose pre {
  margin: 0 0 1rem;
}

.prose ul,
.prose ol {
  padding-left: 1.25rem;
}

.prose li {
  margin: 0.25rem 0;
}

.prose blockquote {
  border-left: 3px solid var(--border);
  padding-left: 1rem;
  color: var(--muted-foreground);
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--muted);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.prose pre {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.9rem;
  overflow-x: auto;
}

.prose pre code {
  background: none;
  padding: 0;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.75rem 0;
}

/* Wide content scrolls inside itself; the page never scrolls sideways. */
.table-wrap {
  overflow-x: auto;
  margin: 0 0 1rem;
}

.prose table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92rem;
}

.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.6rem;
  text-align: left;
}

.prose th {
  background: var(--muted);
  font-weight: 600;
}

/* --- misc -------------------------------------------------------------- */

.code-block {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.9rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  margin: 0;
}

.device-code {
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 1rem + 3vw, 2.5rem);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-align: center;
  padding: 1rem;
  background: var(--muted);
  border-radius: var(--radius);
  margin: 1rem 0;
}

.pagination {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1.5rem;
}

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: 1rem;
  top: 0.5rem;
  z-index: 50;
  background: var(--card);
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--border);
}

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

.source-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
  color: var(--muted-foreground);
}

.source-list li {
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
  padding: 0.2rem 0;
}
