/*
 * Collection page grader.
 *
 * Loaded only on tool pages, on top of style.css. Every colour, font and radius
 * comes from the site's existing custom properties (DYE tokens: primary green
 * #157a50, signal amber #fcd34d, dark #1a1a2e) so the tools inherit the site
 * look instead of introducing a second one.
 */

/* ---- Header --------------------------------------------------------------- */

.tool-header {
  padding: 3rem 0 1.5rem;
  text-align: center;
}
.tool-header__eyebrow {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-primary);
  margin-bottom: 0.75rem;
}
.tool-header__title {
  font-size: clamp(1.9rem, 4vw, 3rem);
  font-weight: 800;
  color: var(--color-dark);
  margin-bottom: 1rem;
}
.tool-header__tagline {
  max-width: 46rem;
  margin: 0 auto;
  color: var(--color-text-light);
  font-size: 1.075rem;
}

/* ---- Input band ----------------------------------------------------------- */

.tool-form-band {
  background: var(--color-bg-light);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: 2.5rem 0;
}
.tool-form {
  max-width: 40rem;
  margin: 0 auto;
}
.tool-form__label {
  display: block;
  font-weight: 700;
  color: var(--color-dark);
  margin-bottom: 0.5rem;
}
.tool-form__row {
  display: flex;
  gap: 0.75rem;
}
.tool-form__row input {
  flex: 1;
  min-width: 0;
  padding: 0.8rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--color-dark);
  background: #fff;
}
.tool-form__row input:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
  border-color: var(--color-primary);
}
.tool-form__row .btn { white-space: nowrap; }
.tool-form__row .btn[disabled] { opacity: 0.65; cursor: progress; }
.tool-form__help {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--color-text-light);
}
.tool-status {
  max-width: 40rem;
  margin: 1rem auto 0;
  font-size: 0.95rem;
  color: var(--color-text-light);
}
.tool-error {
  max-width: 40rem;
  margin: 1.25rem auto 0;
  padding: 1rem 1.25rem;
  border: 1px solid #f0c7c7;
  border-left: 4px solid #c0392b;
  border-radius: 8px;
  background: #fdf3f2;
  color: #7d2c22;
}

/* ---- Results shell -------------------------------------------------------- */

.tool-results { padding: 3rem 0; }
.tool-results > .container { max-width: 52rem; }

/* The site header is position:sticky, so anything the client JS scrolls to
   lands underneath it without this. */
.tool-results { scroll-margin-top: 6rem; }
.tool-subhead {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--color-dark);
  margin: 2.5rem 0 1rem;
}
.tool-subhead--quiet {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text-light);
  margin-top: 2.5rem;
}

/* ---- Example collections -------------------------------------------------- */

/* Buttons, not links: they run the grader in place rather than navigating. They
   are styled as links anyway, because that is what a visitor reads them as. */
.tool-examples { margin-top: 1.5rem; }
.tool-examples__heading {
  font-size: 0.9rem;
  color: var(--color-text-light);
  margin: 0 0 0.6rem;
}
.tool-examples__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
}
.tool-examples__item {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: #fff;
  color: var(--color-primary);
  cursor: pointer;
}
.tool-examples__item:hover,
.tool-examples__item:focus-visible {
  border-color: var(--color-primary);
  background: var(--color-bg-light);
}
.tool-examples__item:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

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

.grade-card {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  padding: 1.75rem;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(26, 26, 46, 0.06);
}
.grade-card__letter {
  flex: 0 0 auto;
  width: 5.5rem;
  height: 5.5rem;
  display: grid;
  place-items: center;
  border-radius: 14px;
  font-family: var(--font-heading);
  font-size: 3rem;
  font-weight: 800;
  color: #fff;
  background: var(--color-primary);
}
/* Grade colour is a temperature, not a judgement: green through to slate.
   Never red, because the register is opportunity rather than failure. */
/* S sits above the scale rather than on it, so it gets metal rather than a
   greener green. Earned only on a perfect score and a complete read. */
.grade-card__letter[data-grade="S"] {
  background: linear-gradient(150deg, #b8860b, #8a6508);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
}
.grade-card__letter[data-grade="A"] { background: #157a50; }
.grade-card__letter[data-grade="B"] { background: #2f8f5b; }
.grade-card__letter[data-grade="C"] { background: #b98900; }
.grade-card__letter[data-grade="D"] { background: #a2662a; }
.grade-card__letter[data-grade="F"] { background: #5b6472; }
.grade-card__heading {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-light);
  margin-bottom: 0.35rem;
}
.grade-card__collection {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--color-dark);
  margin-bottom: 0.4rem;
}
.grade-card__verdict {
  color: var(--color-text);
  margin: 0;
}
.grade-card__link { margin: 0.6rem 0 0; }
.grade-card__link a {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-primary);
}

/* ---- What I read off your page -------------------------------------------- */

/* Quiet on purpose. This is evidence under the verdict, not a second verdict,
   so it sits between the grade card and the ranked fixes without competing
   with either. */
.detected {
  margin-top: 2rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-bg-light);
}
.detected .tool-subhead { margin-top: 0; }
.detected__list {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(6rem, max-content) 1fr;
  gap: 0.5rem 1rem;
}
.detected__list dt {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-light);
}
.detected__list dd {
  margin: 0;
  color: var(--color-dark);
  /* A title tag can be one unbroken 200-character string. Let it wrap rather
     than push the panel wider than the page. */
  overflow-wrap: anywhere;
}
.detected__label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-light);
  margin: 1.1rem 0 0.4rem;
}
.detected__description {
  margin: 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--color-primary);
  background: #fff;
  border-radius: 0 8px 8px 0;
  color: var(--color-text);
  font-size: 0.95rem;
  /* Descriptions run from zero words to several hundred. Cap the height and
     scroll rather than truncating, so nothing is hidden without saying so. */
  max-height: 14rem;
  overflow-y: auto;
}
.detected .is-empty {
  color: var(--color-text-light);
  font-style: italic;
}

/* ---- Ranked fixes --------------------------------------------------------- */

.fix-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: fix;
}
.fix-list__item {
  counter-increment: fix;
  position: relative;
  padding: 1.25rem 1.25rem 1.25rem 3.5rem;
  margin-bottom: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: #fff;
}
.fix-list__item::before {
  content: counter(fix);
  position: absolute;
  left: 1.1rem;
  top: 1.25rem;
  width: 1.75rem;
  height: 1.75rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.9rem;
}
.fix-list__item.is-partial::before { background: var(--color-signal); color: var(--color-dark); }
.fix-list__label {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--color-dark);
  margin: 0 0 0.35rem;
}
.fix-list__finding {
  margin: 0 0 0.5rem;
  color: var(--color-dark);
  font-weight: 600;
}
.fix-list__sowhat {
  margin: 0 0 0.75rem;
  color: var(--color-text-light);
}
.fix-list__chapter {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-primary);
}

/* ---- Footnotes (never the headline) --------------------------------------- */

.footnote-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.925rem;
  color: var(--color-text-light);
}
.footnote-list__item {
  padding: 0.5rem 0 0.5rem 1.25rem;
  border-left: 2px solid var(--color-border);
  margin-bottom: 0.35rem;
}
.footnote-list__item.is-pass { border-left-color: var(--color-primary); }
.footnote-list__item b { color: var(--color-text); }

/* ---- The opt-in ----------------------------------------------------------- */

/* Sits after the results, never in front of them: the grade is already given,
   so this is an offer rather than a gate. Styled quieter than the grade card
   for the same reason. */
.tool-optin {
  margin: 2.5rem 0 0;
  padding: 2rem;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-bg-light);
}
.tool-optin__heading {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-dark);
  margin: 0 0 0.5rem;
}
.tool-optin__body { color: var(--color-text-light); margin: 0 0 1.25rem; }
.tool-optin__fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.tool-optin__fields input {
  flex: 1 1 12rem;
  min-width: 0;
  padding: 0.8rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--color-dark);
}
.tool-optin__fields input:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}
.tool-optin__disclosure {
  margin: 0.9rem 0 0;
  font-size: 0.85rem;
  color: var(--color-text-light);
}
.tool-optin__done {
  margin: 0;
  font-weight: 700;
  color: var(--color-primary);
}
.tool-optin iframe { display: none; }

/* ---- Notes + CTA ---------------------------------------------------------- */

.tool-notes {
  list-style: none;
  margin: 2rem 0 0;
  padding: 1rem 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-bg-light);
  font-size: 0.9rem;
  color: var(--color-text-light);
}
.tool-notes li { margin-bottom: 0.4rem; }
.tool-notes li:last-child { margin-bottom: 0; }

.tool-cta { margin-top: 2.5rem; text-align: center; }
.tool-cta p { color: var(--color-text-light); margin-bottom: 1rem; }
.link-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.95rem;
  color: var(--color-primary);
  text-decoration: underline;
  cursor: pointer;
}
.tool-prose { padding: 0 0 3rem; }

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

/* ---- Mobile --------------------------------------------------------------- */

@media (max-width: 640px) {
  .tool-header { padding: 2rem 0 1rem; }
  .tool-form__row { flex-direction: column; }
  .tool-form__row .btn { width: 100%; }
  .grade-card { flex-direction: column; text-align: center; gap: 1rem; }
  .grade-card__letter { width: 4.5rem; height: 4.5rem; font-size: 2.5rem; }
  .tool-optin { padding: 1.5rem 1.25rem; }
  .tool-optin__fields input { flex-basis: 100%; }
  .tool-optin__fields .btn { width: 100%; }
  .fix-list__item { padding: 1.1rem 1rem 1.1rem 3rem; }
  .fix-list__item::before { left: 0.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  .tool-page * { scroll-behavior: auto !important; }
}
