/* Word500 Solver — aggregate-feedback workbench and supporting guide. */

.w500-page {
  width: min(100% - 2rem, 980px);
  margin: 0 auto;
  padding: 2.25rem 0 4rem;
}

.w500-page > .related-tools {
  margin-top: 2rem;
}

.w500-hero {
  max-width: 760px;
  margin: 0 auto 1.75rem;
  text-align: center;
}

.w500-eyebrow,
.w500-step {
  margin: 0 0 0.4rem;
  color: var(--accent-text);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.w500-hero h1 {
  margin: 0;
  font-size: clamp(2rem, 6.5vw, 3.45rem);
  line-height: 1.04;
  letter-spacing: -0.045em;
}

.w500-deck {
  max-width: 62ch;
  margin: 0.9rem auto 0;
  color: var(--text-secondary);
  font-size: clamp(1rem, 2vw, 1.12rem);
  line-height: 1.65;
}

.w500-official-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.9rem;
  color: var(--accent-text);
  font-size: 0.9rem;
  font-weight: 700;
  text-underline-offset: 0.18em;
}

.w500-workspace {
  max-width: 860px;
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 1.75rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.w500-workspace__heading,
.w500-results__heading,
.w500-candidates__heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.w500-workspace__heading h2,
.w500-results__heading h2,
.w500-editorial h2,
.w500-disclaimer h2 {
  margin: 0;
  letter-spacing: -0.025em;
}

.w500-workspace__heading h2,
.w500-results__heading h2 {
  font-size: 1.4rem;
}

.w500-results__heading {
  display: block;
}

.w500-text-button,
.w500-add {
  border: 0;
  background: transparent;
  color: var(--accent-text);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.w500-text-button:hover,
.w500-add:hover {
  color: var(--accent-hover);
}

.w500-text-button:focus-visible,
.w500-add:focus-visible,
.w500-remove:focus-visible {
  border-radius: var(--radius-sm);
  outline: 3px solid var(--accent-soft);
  outline-offset: 3px;
}

.w500-form {
  margin-top: 1.35rem;
}

.w500-difficulty-field {
  display: grid;
  grid-template-columns: auto minmax(150px, 220px);
  align-items: center;
  justify-content: start;
  gap: 0.75rem;
}

.w500-label {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
}

#w500-difficulty,
.w500-guess,
.w500-count {
  min-width: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

#w500-difficulty {
  min-height: 44px;
  padding: 0 2.25rem 0 0.75rem;
  cursor: pointer;
}

#w500-difficulty:focus,
.w500-guess:focus,
.w500-count:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: 0;
}

.w500-field-help,
.w500-form-help,
.w500-section-help {
  color: var(--text-secondary);
  font-size: 0.84rem;
  line-height: 1.5;
}

.w500-field-help {
  max-width: 62ch;
  margin: 0.45rem 0 0;
}

.w500-form-help {
  max-width: 72ch;
  margin: 1.25rem 0 0.85rem;
}

.w500-row-head,
.w500-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 78px 78px 64px auto;
  gap: 0.65rem;
}

.w500-row-head {
  align-items: end;
  padding: 0 0.65rem 0.38rem;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.w500-row-head span:not(:first-child) {
  text-align: center;
}

.w500-rows {
  display: grid;
  gap: 0.65rem;
}

.w500-row {
  position: relative;
  align-items: center;
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
}

.w500-row.has-invalid-total {
  border-color: var(--danger);
}

.w500-row-number,
.w500-mobile-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.w500-row-field {
  display: block;
  min-width: 0;
}

.w500-guess,
.w500-count,
.w500-red {
  width: 100%;
  height: 46px;
}

.w500-guess {
  padding: 0 0.75rem;
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.w500-count {
  padding: 0 0.35rem 0 0.7rem;
  text-align: center;
}

.w500-red {
  display: grid;
  place-items: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
}

.w500-row.has-invalid-total .w500-red {
  border-color: var(--danger);
  color: var(--danger);
}

.w500-remove {
  min-height: 40px;
  padding: 0.25rem 0;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
}

.w500-remove:hover {
  color: var(--danger);
}

.w500-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.75rem;
}

.w500-add {
  padding: 0.35rem 0;
}

.w500-add[disabled] {
  color: var(--muted);
  cursor: default;
  text-decoration: none;
}

.w500-row-limit {
  color: var(--muted);
  font-size: 0.78rem;
}

.w500-submit {
  width: 100%;
  min-height: 48px;
  margin-top: 1rem;
}

.w500-submit[disabled] {
  cursor: wait;
  opacity: var(--disabled-opacity);
}

.w500-error,
.w500-status {
  min-height: 1.35rem;
  margin: 0.7rem 0 0;
  font-size: 0.88rem;
  font-weight: 600;
}

.w500-error {
  color: var(--danger);
}

.w500-status {
  margin-top: 0;
  color: var(--text-secondary);
}

.w500-results {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.w500-result-summary {
  margin: 0.55rem 0 0;
  color: var(--text-secondary);
  line-height: 1.55;
}

.w500-suggestions,
.w500-candidates {
  margin-top: 1.35rem;
}

.w500-suggestions h3,
.w500-candidates h3,
.w500-empty h3 {
  margin: 0;
  font-size: 1.08rem;
}

.w500-section-help {
  margin: 0.35rem 0 0;
}

.w500-suggestion-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0.85rem 0 0;
  padding: 0;
  list-style: none;
  counter-reset: suggestion-rank;
}

.w500-suggestion {
  position: relative;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  counter-increment: suggestion-rank;
}

.w500-suggestion::before {
  content: "#" counter(suggestion-rank);
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.w500-suggestion__word,
.w500-candidate-link {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.w500-suggestion__word {
  display: inline-block;
  padding-right: 1.8rem;
  color: var(--accent-text);
  font-size: 1.24rem;
}

.w500-suggestion__metrics {
  display: grid;
  gap: 0.42rem;
  margin: 0.7rem 0 0;
}

.w500-suggestion__metric {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.w500-suggestion__metric strong {
  color: var(--text);
  font-size: 0.86rem;
}

.w500-candidates__heading {
  align-items: baseline;
}

.w500-candidate-count {
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.w500-candidate-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.5rem;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.w500-candidate-link {
  display: block;
  padding: 0.55rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: 0.86rem;
  text-align: center;
  text-decoration: none;
}

.w500-candidate-link:hover,
.w500-candidate-link:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft-solid);
  color: var(--accent-text);
}

.w500-truncated,
.w500-dictionary-note {
  margin: 0.75rem 0 0;
  color: var(--text-secondary);
  font-size: 0.8rem;
  line-height: 1.5;
}

.w500-dictionary-note:empty {
  display: none;
}

.w500-empty {
  margin-top: 1.25rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
}

.w500-empty p {
  margin: 0.45rem 0 0;
  color: var(--text-secondary);
  line-height: 1.55;
}

.w500-noscript {
  max-width: 860px;
  margin: 0.75rem auto 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  color: var(--danger);
}

.w500-editorial {
  max-width: 860px;
  margin: 2.4rem auto 0;
}

.w500-editorial__intro {
  max-width: 700px;
}

.w500-editorial__intro > p:last-child {
  margin: 0.65rem 0 0;
  color: var(--text-secondary);
  line-height: 1.7;
}

.w500-explainer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1.25rem;
}

.w500-explainer-grid article {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel);
}

.w500-explainer-grid h3 {
  margin: 0.7rem 0 0;
  font-size: 1rem;
}

.w500-explainer-grid p {
  margin: 0.4rem 0 0;
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.55;
}

.w500-colour-key {
  display: inline-flex;
  padding: 0.25rem 0.48rem;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.w500-colour-key--green {
  background: var(--green);
}

.w500-colour-key--yellow {
  background: var(--yellow-dark);
}

.w500-colour-key--red {
  background: var(--danger);
}

.w500-details,
.w500-disclaimer {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel);
}

.w500-details summary {
  cursor: pointer;
  font-weight: 700;
}

.w500-details p,
.w500-details ul,
.w500-disclaimer p {
  color: var(--text-secondary);
  line-height: 1.65;
}

.w500-details p:last-child,
.w500-details ul:last-child,
.w500-disclaimer p:last-child {
  margin-bottom: 0;
}

.w500-disclaimer h2 {
  font-size: 1.1rem;
}

.w500-disclaimer p {
  margin-top: 0.5rem;
}

@media (max-width: 760px) {
  .w500-page {
    width: min(100% - 1rem, 980px);
    padding-top: 1.35rem;
  }

  .w500-workspace {
    border-radius: var(--radius-lg);
  }

  .w500-row-head {
    display: none;
  }

  .w500-row {
    grid-template-columns: repeat(3, minmax(52px, 1fr)) auto;
    padding-top: 0.85rem;
  }

  .w500-row-number,
  .w500-mobile-label {
    position: static;
    width: auto;
    height: auto;
    padding: 0;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
  }

  .w500-row-number {
    grid-column: 1 / -1;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.055em;
    text-transform: uppercase;
  }

  .w500-mobile-label {
    display: block;
    margin-bottom: 0.3rem;
    color: var(--text-secondary);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.045em;
    text-transform: uppercase;
  }

  .w500-row-field--word {
    grid-column: 1 / -1;
  }

  .w500-red {
    align-self: end;
    position: relative;
  }

  .w500-red::before {
    content: "Red";
    position: absolute;
    bottom: calc(100% + 0.3rem);
    left: 0;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.045em;
    text-transform: uppercase;
  }

  .w500-remove {
    align-self: end;
  }

  .w500-suggestion-list,
  .w500-explainer-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 440px) {
  .w500-workspace__heading {
    align-items: baseline;
  }

  .w500-difficulty-field {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }

  #w500-difficulty {
    width: 100%;
  }

  .w500-row {
    column-gap: 0.45rem;
  }

  .w500-remove {
    width: 40px;
    overflow: hidden;
    color: transparent;
    white-space: nowrap;
  }

  .w500-remove::before {
    content: "×";
    color: var(--text-secondary);
    font-size: 1.35rem;
  }
}
