/* Govt Job Readiness Checker — ToolNest brand (design-spec tokens).
   Mobile-first, system fonts only, no external requests. */

:root {
  --bg: #F7F5F0;
  --surface: #FFFFFF;
  --surface-muted: #EFF2EE;
  --ink: #17211D;
  --muted: #4E5D55;
  --border: #D8DFD9;
  --primary: #0B6B57;
  --primary-dark: #084E3F;
  --primary-soft: #E2EFEA;
  --accent: #F2A93B;
  --success: #177245;
  --success-bg: #E5F3EA;
  --danger: #B3261E;
  --danger-bg: #FBEAE8;
  --warning: #8A5A00;
  --warning-bg: #FFF3DC;
  --focus: #0B6B57;
  --shadow: 0 1px 2px rgba(23, 33, 29, .06), 0 4px 16px rgba(23, 33, 29, .06);
  --radius-card: 16px;
  --radius-control: 10px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

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

.icon {
  flex: none;
  vertical-align: -4px;
}

/* Header */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-mark {
  flex: none;
}

.brand-name {
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--ink);
}

.brand-tool {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.help-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  padding: 10px 8px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.help-link:hover {
  text-decoration: underline;
}

/* Layout */

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px;
}

.intro h1 {
  font-size: 28px;
  line-height: 1.2;
  margin: 8px 0;
}

.intro-sub {
  color: var(--muted);
  margin: 0 0 16px;
  max-width: 65ch;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.card h2 {
  font-size: 19px;
  line-height: 1.3;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card h3 {
  font-size: 16px;
  line-height: 1.35;
  margin: 0 0 8px;
}

.step-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--primary);
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 700;
  flex: none;
}

.card-purpose {
  color: var(--muted);
  margin: 0 0 16px;
}

/* Fields */

.field {
  margin-bottom: 16px;
}

.field > label,
fieldset.field legend {
  display: block;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  padding: 0;
}

fieldset.field {
  border: 0;
  margin: 0 0 16px;
  padding: 0;
}

.field input[type="date"],
.field input[type="number"],
.field textarea {
  width: 100%;
  min-height: 48px;
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-control);
  padding: 10px 12px;
}

.field textarea {
  line-height: 1.5;
  resize: vertical;
}

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

.field input[aria-invalid="true"] {
  border-color: var(--danger);
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.input-row input {
  flex: 1 1 auto;
  min-width: 0;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 16px;
}

.hint {
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
  margin: 6px 0 0;
}

.field-error {
  font-size: 14px;
  line-height: 1.45;
  color: var(--danger);
  margin: 6px 0 0;
  font-weight: 600;
}

.privacy-line {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: var(--primary-soft);
  border-radius: var(--radius-control);
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.45;
  margin: 8px 0 0;
}

.privacy-line .icon {
  color: var(--primary);
  margin-top: 1px;
}

.notice-line {
  background: var(--warning-bg);
  color: var(--warning);
  border-radius: var(--radius-control);
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  margin: 8px 0 0;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 16px;
  font-size: 16px;
  font-family: inherit;
  font-weight: 600;
  border-radius: var(--radius-control);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

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

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

.btn-danger-quiet {
  background: var(--surface);
  border-color: var(--border);
  color: var(--danger);
}

.btn-danger-quiet:hover {
  background: var(--danger-bg);
}

.btn-small {
  min-height: 44px;
  font-size: 14px;
  padding: 8px 12px;
}

.btn:active {
  transform: scale(0.99);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 16px 0 0;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 0;
}

.copy-status {
  color: var(--success);
  font-weight: 600;
  font-size: 14px;
}

.confirm-row {
  background: var(--warning-bg);
  border-radius: var(--radius-control);
  padding: 12px;
  margin-top: 12px;
}

.confirm-row p {
  margin: 0 0 10px;
}

.confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Radio pills + checkbox */

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 15px;
  background: var(--surface);
}

.pill input {
  accent-color: var(--primary);
  width: 18px;
  height: 18px;
  margin: 0;
}

.pill:has(input:checked) {
  background: var(--primary-soft);
  border-color: var(--primary);
  font-weight: 600;
}

.pill:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.check-label input {
  accent-color: var(--primary);
  width: 20px;
  height: 20px;
  margin: 0;
  flex: none;
}

/* Verdict + countdown */

.empty-state {
  background: var(--surface-muted);
  border-radius: var(--radius-control);
  padding: 12px;
  color: var(--muted);
  margin: 16px 0 0;
}

.verdict-panel {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-control);
  padding: 16px;
  margin-top: 16px;
}

.verdict-age {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
  font-variant-numeric: tabular-nums;
}

.verdict-completed {
  color: var(--muted);
  margin: 0 0 12px;
  font-variant-numeric: tabular-nums;
}

.verdict-headline {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 8px;
}

.verdict-panel.is-within {
  border-color: var(--success);
  background: var(--success-bg);
}

.verdict-panel.is-within .verdict-headline {
  color: var(--success);
}

.verdict-panel.is-notyet {
  border-color: var(--warning);
  background: var(--warning-bg);
}

.verdict-panel.is-notyet .verdict-headline {
  color: var(--warning);
}

.verdict-panel.is-tooold {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.verdict-panel.is-tooold .verdict-headline {
  color: var(--danger);
}

.convention-note {
  font-size: 14px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 12px;
}

.countdown-line {
  font-size: 18px;
  font-weight: 700;
  margin: 8px 0 0;
  font-variant-numeric: tabular-nums;
}

.countdown-line.is-passed {
  color: var(--danger);
}

.countdown-line.is-lastday {
  color: var(--warning);
}

/* Typing test */

.passage-box {
  position: relative;
  white-space: pre-wrap;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface-muted);
  padding: 14px;
  font-size: 20px;
  line-height: 1.7;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 16px;
  overflow-wrap: break-word;
}

.passage-box .cluster {
  border-bottom: 2px solid transparent;
  border-radius: 2px;
}

/* Correctness is never colour alone: correct clusters get a solid
   teal underline, incorrect clusters a wavy red underline on a tint,
   and the current cluster a highlighted background with a caret bar. */
.passage-box .cluster-correct {
  color: var(--success);
  border-bottom: 2px solid var(--success);
}

.passage-box .cluster-incorrect {
  color: var(--danger);
  background: var(--danger-bg);
  text-decoration: underline wavy var(--danger) 1.5px;
  text-underline-offset: 3px;
}

.passage-box .cluster-current {
  background: var(--accent);
  border-bottom: 2px solid var(--ink);
}

.passage-box .cluster-pending {
  color: var(--muted);
}

.live-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.stat {
  background: var(--surface-muted);
  border-radius: var(--radius-control);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.result-panel {
  border: 1.5px solid var(--primary);
  background: var(--primary-soft);
  border-radius: var(--radius-control);
  padding: 16px;
  margin-top: 16px;
}

.result-net {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 8px;
  font-variant-numeric: tabular-nums;
}

.result-list {
  margin: 0 0 12px;
  padding-left: 20px;
  font-variant-numeric: tabular-nums;
}

/* History */

.best-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.best-table caption {
  text-align: left;
  font-weight: 700;
  font-size: 15px;
  padding-bottom: 6px;
}

.best-table th,
.best-table td {
  border-bottom: 1px solid var(--border);
  padding: 8px 6px;
  text-align: left;
}

.best-table th {
  color: var(--muted);
  font-weight: 600;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-list li {
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.history-list .history-main {
  font-weight: 600;
}

.history-list .history-meta {
  color: var(--muted);
}

/* Help */

.faq {
  border-bottom: 1px solid var(--border);
  padding: 4px 0;
}

.faq summary {
  font-weight: 600;
  cursor: pointer;
  padding: 12px 0;
  min-height: 44px;
}

.faq p {
  margin: 0 0 12px;
  color: var(--ink);
  max-width: 65ch;
}

.site-footer {
  color: var(--muted);
  font-size: 14px;
  padding: 8px 0 24px;
}

/* Wider screens */

@media (min-width: 720px) {
  .page {
    padding: 24px 16px;
  }

  .intro h1 {
    font-size: 32px;
  }

  .card {
    padding: 24px;
  }

  .field-row {
    grid-template-columns: 1fr 1fr;
  }

  .live-stats {
    grid-template-columns: repeat(4, 1fr);
  }

  .passage-box {
    font-size: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn {
    transition: none;
  }

  .btn:active {
    transform: none;
  }
}
