/*
 * AskDimitri member tools: shared styles for /dashboard/tools/ (the hub and every tool page).
 * Colours and fonts come from /css/tokens.css and /css/fonts.css; link both first.
 * Mobile first: one column by default, wider layouts from 720px.
 *
 * Components: .tool-header, .tool-title, .allowance, .ai-note, .card, forms and buttons,
 * .notice, .steps (progress), .light (traffic lights), .status (reference results), .flag,
 * .result-list, .copy-block, .tool-cards (the hub), .print-only and print rules.
 * Meaning is never carried by colour alone: every light and status has a text label, and the
 * lights also differ in shape (circle, triangle, square).
 */

:root {
  /* --gold-tint and --gold-line come from tokens.css. */

  /* Lights and statuses. Text colours are 6.5:1 or more on their fills and on --card; the dots
     are 3.5:1 or more (WCAG 1.4.11) and always sit next to a text label. */
  --green: #22603a;
  --green-bg: #e9f3eb;
  --green-dot: #2f8a4c;
  --amber: #7a4d00;
  --amber-bg: #fbf1dc;
  --amber-dot: #b07408;
  --red: #8a3b2e;
  --red-bg: #fbece8;
  --red-dot: #c0412c;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: radial-gradient(1100px 480px at 50% -8%, var(--glow) 0%, var(--paper) 62%);
  background-color: var(--paper);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}
.page { max-width: 920px; margin: 0 auto; padding: 20px 16px 60px; }
a { color: var(--ink); }
button, input, select, textarea { font-family: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 16px; top: -60px; background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: 8px; z-index: 10; }
.skip:focus { top: 12px; }
.serif { font-family: var(--serif); font-weight: 500; color: var(--ink); }

/* Header */
.tool-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.wordmark { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.wordmark .delta { font-family: var(--serif); font-size: 30px; color: var(--gold); line-height: 1; }
.wordmark .name { font-size: 14.5px; font-weight: 500; }
.tool-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.tool-nav a { font-size: 13.5px; color: var(--muted); text-decoration: none; padding: 8px 10px; border-radius: 8px; min-height: 40px; display: inline-flex; align-items: center; }
.tool-nav a:hover { color: var(--ink); background: var(--tint); }
.tool-nav a[aria-current="page"] { color: var(--ink); font-weight: 500; box-shadow: inset 0 -2px 0 var(--gold); border-radius: 0; }
h1.tool-title { font-size: 26px; line-height: 1.25; margin: 0 0 8px; }
h1.tool-title:focus { outline: none; }
.tool-lede { font-size: 15px; color: var(--muted); margin: 0 0 16px; max-width: 62ch; }
.allowance { display: inline-block; font-size: 12.5px; color: var(--ink); border: 1px solid var(--gold-line); background: var(--gold-tint); border-radius: 20px; padding: 5px 12px; margin: 0 0 14px; }
.allowance.low { border-color: var(--danger-line); background: var(--danger-bg); color: var(--danger); }

/* AI notice (same wording rules as the dashboard's) */
.ai-note { display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; line-height: 1.55; color: var(--muted); background: var(--gold-tint); border: 1px solid var(--gold-line); border-radius: 10px; padding: 9px 12px; margin: 0 0 16px; }
.ai-badge { display: inline-block; flex: 0 0 auto; margin-top: 1px; font-size: 10.5px; font-weight: 500; letter-spacing: .06em; color: var(--ink); background: var(--gold-tint); border: 1px solid var(--gold); border-radius: 5px; padding: 0 5px; line-height: 1.6; text-transform: uppercase; }

/* Cards and text */
.card { background: var(--card); border: 1px solid var(--hairline); border-radius: 14px; padding: 18px 16px; margin-bottom: 16px; }
.center-card { max-width: 520px; margin: 8vh auto 0; }
.card h2, h2.section { font-family: var(--serif); font-weight: 500; color: var(--ink); font-size: 20px; line-height: 1.3; margin: 0 0 8px; }
p.sub { font-size: 14.5px; color: var(--muted); margin: 0 0 10px; }
.fine { font-size: 12px; color: var(--muted); }

/* Forms */
label, .label { display: block; font-size: 13.5px; font-weight: 500; color: var(--text); margin: 14px 0 5px; }
label .opt { font-weight: 400; color: var(--muted); }
input[type="text"], input[type="email"], input[type="number"], input[type="search"], select, textarea {
  display: block; width: 100%; min-height: 44px; padding: 10px 13px; font-size: 16px; line-height: 1.5;
  color: var(--text); background: var(--card); border: 1px solid var(--field-border); border-radius: 8px;
}
textarea { min-height: 140px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--tint); }
[aria-invalid="true"] { border-color: var(--danger) !important; }
.hint { font-size: 12.5px; color: var(--muted); margin: 4px 0 0; }
.char-count { font-size: 12px; color: var(--muted); text-align: right; margin: 4px 0 0; }
.char-count.over { color: var(--danger); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; }
fieldset { border: 1px solid var(--hairline); border-radius: 10px; padding: 4px 14px 14px; margin: 16px 0 0; }
legend { font-size: 13.5px; font-weight: 500; padding: 0 6px; }

.btn-primary, .btn-secondary, .btn-link { font-size: 14px; border-radius: 8px; min-height: 44px; padding: 0 20px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.btn-primary { font-weight: 500; color: var(--paper); background: var(--ink); border: none; transition: background .2s, transform .15s; }
.btn-primary:hover:not(:disabled) { background: var(--delta); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .6; cursor: wait; }
.btn-secondary { color: var(--ink); background: var(--card); border: 1px solid var(--field-border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--delta); }
.btn-secondary:disabled { opacity: .55; cursor: not-allowed; }
.btn-link { color: var(--ink); background: none; border: none; padding: 0 6px; text-decoration: underline; text-underline-offset: 2px; }

/* Messages */
.notice { font-size: 13.5px; color: var(--danger); background: var(--danger-bg); border: 1px solid var(--danger-line); border-radius: 8px; padding: 9px 12px; margin: 12px 0; }
.notice.soft { color: var(--ink); background: var(--gold-tint); border-color: var(--gold-line); }

/* Progress steps: <ol class="steps"><li data-state="done|active|pending|failed">label</li></ol>.
   The state is also written out for screen readers (.sr-only span) by the page. */
.steps { list-style: none; margin: 12px 0; padding: 0; font-size: 14px; }
.steps li { display: flex; align-items: center; gap: 10px; padding: 5px 0; color: var(--muted); }
.steps li::before { content: ""; flex: 0 0 auto; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--field-border); background: var(--card); }
.steps li[data-state="active"] { color: var(--text); font-weight: 500; }
.steps li[data-state="active"]::before { border-color: var(--ink); border-top-color: transparent; animation: spin 1s linear infinite; }
.steps li[data-state="done"] { color: var(--text); }
.steps li[data-state="done"]::before { border-color: var(--green-dot); background: var(--green-dot); box-shadow: inset 0 0 0 2px var(--card); }
.steps li[data-state="failed"] { color: var(--red); }
.steps li[data-state="failed"]::before { border-color: var(--red-dot); background: var(--red-bg); border-radius: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Traffic lights: <span class="light light-green"><span class="dot" aria-hidden="true"></span>Green</span> */
.light { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; padding: 4px 12px 4px 10px; border-radius: 20px; border: 1px solid transparent; }
.light .dot { width: 14px; height: 14px; flex: 0 0 auto; }
.light-green { color: var(--green); background: var(--green-bg); border-color: var(--green-dot); }
.light-green .dot { background: var(--green-dot); border-radius: 50%; }
.light-amber { color: var(--amber); background: var(--amber-bg); border-color: var(--amber-dot); }
.light-amber .dot { background: var(--amber-dot); clip-path: polygon(50% 4%, 100% 96%, 0 96%); }
.light-red { color: var(--red); background: var(--red-bg); border-color: var(--red-dot); }
.light-red .dot { background: var(--red-dot); border-radius: 2px; }
.light.big { font-size: 17px; padding: 8px 18px 8px 14px; }
.light.big .dot { width: 20px; height: 20px; }

/* Reference statuses and integrity flags */
.status, .flag { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; line-height: 1.4; padding: 2px 10px; border-radius: 12px; border: 1px solid var(--hairline); color: var(--ink); background: var(--tint); white-space: nowrap; }
.status-verified { color: var(--green); background: var(--green-bg); border-color: var(--green-dot); }
.status-mismatch { color: var(--amber); background: var(--amber-bg); border-color: var(--amber-dot); }
.status-not_found { color: var(--muted); background: var(--card); border-style: dashed; border-color: var(--field-border); }
.status-ambiguous { color: var(--ink); background: var(--gold-tint); border-color: var(--gold-line); }
.flag-retracted { color: var(--red); background: var(--red-bg); border-color: var(--red-dot); font-weight: 600; }
.flag-corrected, .flag-concern { color: var(--amber); background: var(--amber-bg); border-color: var(--amber-dot); }

/* Results */
.result-list { list-style: none; margin: 0; padding: 0; counter-reset: ref; }
.result-list > li { border-top: 1px solid var(--hairline); padding: 12px 0; display: grid; gap: 6px; }
.result-list > li:first-child { border-top: none; }
.result-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.result-input { font-size: 13.5px; color: var(--muted); overflow-wrap: anywhere; margin: 0; }
.result-match { font-family: var(--serif); font-size: 15.5px; overflow-wrap: anywhere; margin: 0; }
.result-issues { font-size: 13px; margin: 0; padding-left: 18px; }
.meta { font-size: 12.5px; color: var(--muted); }
.copy-block { font-family: var(--serif); font-size: 15px; line-height: 1.6; background: var(--card); border: 1px solid var(--hairline); border-radius: 10px; padding: 12px 14px; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }

/* The tools hub */
.tool-cards { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 14px; }
.tool-card { background: var(--card); border: 1px solid var(--hairline); border-radius: 14px; padding: 18px 16px; position: relative; transition: border-color .2s; }
.tool-card:hover, .tool-card:focus-within { border-color: var(--delta); }
.tool-card h2 { font-family: var(--serif); font-weight: 500; font-size: 20px; margin: 0 0 6px; }
.tool-card h2 a { color: var(--ink); text-decoration: none; }
.tool-card h2 a::after { content: ""; position: absolute; inset: 0; border-radius: 14px; }
.tool-card h2 a:focus-visible { outline: none; }
.tool-card:focus-within { box-shadow: 0 0 0 2px var(--ink); }
.tool-tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 8px; }
.tag { font-size: 11.5px; letter-spacing: .03em; color: var(--muted); border: 1px solid var(--hairline); border-radius: 12px; padding: 1px 9px; }
.tag-ai { color: var(--ink); border-color: var(--gold); background: var(--gold-tint); }
.tool-blurb { font-size: 14.5px; margin: 0 0 8px; }
.tool-allowance { font-size: 13px; color: var(--ink); margin: 0; min-height: 1.4em; }

footer { margin-top: 40px; font-size: 12px; color: var(--muted); }
footer a { color: var(--muted); }

@media (min-width: 720px) {
  .page { padding: 28px 24px 60px; }
  .card { padding: 24px; }
  .tool-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-list > li { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .steps li[data-state="active"]::before { border-top-color: var(--ink); }
}

.print-only { display: none; }
@media print {
  body { background: #fff; color: #000; }
  .page { max-width: none; padding: 0; }
  .tool-nav, .allowance, .form-actions, .btn-primary, .btn-secondary, .btn-link, .skip, .no-print, footer { display: none !important; }
  .print-only { display: block; }
  .card, .tool-card { border: none; padding: 0; }
  .light, .status, .flag { border: 1px solid #000 !important; background: none !important; color: #000 !important; }
  a { color: #000; text-decoration: none; }
  .result-list > li { break-inside: avoid; }
}
