//
// COACH — light
// =============
// Score tiles + per-advice expandable cards for the Coach tab.
//

//
// 1. Top summary band — small mascot + 4 score tiles
//
.coach-summary {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: center;
  margin-bottom: 24px;
}

.coach-summary-mascot {
  flex: 0 0 auto;
}

.coach-mascot {
  width: 96px;
  height: auto;
  display: block;
}

.coach-summary-scores {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
}

.coach-score-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: $radius--md;
  border: 1px solid $color--border;
  background: $color--surface-card;
  text-decoration: none;
  transition: box-shadow $motion--med, transform $motion--med;

  &.ok { background: $color--ok-bg; border-color: $color--ok-border; color: $color--ok; }
  &.warning { background: $color--warning-bg; border-color: $color--warning-border; color: $color--warning; }
  &.error { background: $color--error-bg; border-color: $color--error-border; color: $color--error; }
  &.info { background: $color--info-bg; border-color: $color--info-border; color: $color--info; }

  // Anchor variants get hover affordance; the non-link Overall tile stays static.
  &[href]:hover {
    box-shadow: $shadow--md;
    transform: translateY(-1px);
  }
}

.coach-score-label {
  font-size: 0.85rem;
  font-weight: $font--weight--medium;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.85;
}

.coach-score-value {
  font-size: 2rem;
  font-weight: $font--weight--semibold;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  line-height: 1;
}

@media (max-width: 720px) {
  .coach-summary {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .coach-summary-mascot {
    margin: 0 auto;
  }
  .coach-mascot {
    width: 72px;
  }
}

//
// 2. Per-category section — header strip + advice cards
//
.coach-section {
  margin-bottom: 28px;
}

.coach-section-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 14px;
}

.coach-section-title {
  margin: 0;
}

// Category-level severity breakdown — sits next to the score chip in
// the section header. Pushed to the right so the title + score stay
// flush left and the breakdown reads as a summary.
.coach-section-severity {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-left: auto;
}

// Severity chip — pill-shaped, colour-coded. Mirrors coach-core's three
// tiers (error / warn / info) with the same palette the rest of the
// report uses for ok/warning/error/info backgrounds.
.coach-severity {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: $radius--pill;
  font-size: 0.72rem;
  font-weight: $font--weight--semibold;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
  white-space: nowrap;

  &--error {
    color: $color--error;
    background: $color--error-bg;
    border-color: $color--error-border;
  }
  &--warn {
    color: $color--warning;
    background: $color--warning-bg;
    border-color: $color--warning-border;
  }
  &--info {
    color: $color--info;
    background: $color--info-bg;
    border-color: $color--info-border;
  }
}

// Numeric score sits next to the severity chip as muted text in
// parentheses — supporting detail rather than a competing chip. Hidden
// for info-severity rows where the score isn't a meaningful urgency
// signal.
.coach-advice-score {
  color: $color--text-muted;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

.coach-section-clear {
  color: $color--ok;
  font-weight: $font--weight--medium;
  margin: 0;
  padding: 14px 16px;
  background: $color--ok-bg;
  border: 1px solid $color--ok-border;
  border-radius: $radius--md;
}

//
// 3. Advice cards — native <details>/<summary> for disclosure
//
.coach-advices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.coach-advice {
  background: $color--surface-card;
  border: 1px solid $color--border;
  border-radius: $radius--md;
  overflow: hidden;
  transition: box-shadow $motion--med;

  &[open] {
    box-shadow: $shadow--sm;
  }
}

.coach-advice-summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  transition: background-color $motion--fast;

  // Hide native disclosure marker; use a CSS chevron instead.
  &::-webkit-details-marker { display: none; }
  &::marker { display: none; }

  &::after {
    content: '';
    width: 8px;
    height: 8px;
    border-right: 2px solid $color--text-muted;
    border-bottom: 2px solid $color--text-muted;
    transform: rotate(45deg);
    margin-left: auto;
    transition: transform $motion--fast;
    flex: 0 0 auto;
  }

  &:hover {
    background: $color--surface;
  }
}

.coach-advice[open] > .coach-advice-summary::after {
  transform: rotate(225deg);
}

.coach-advice-title {
  font-weight: $font--weight--semibold;
  color: $color--text;
  flex: 1 1 auto;
  min-width: 0;
}

.coach-advice-rule {
  font-size: 0.78rem;
  color: $color--text-muted;
  font-family: $font--mono;
  background: transparent;
  border: 0;
  padding: 0;
  white-space: nowrap;
  flex: 0 0 auto;
}

.coach-advice-body {
  padding: 0 16px 16px 16px;
  border-top: 1px solid $color--border;
  margin-top: 0;
}

.coach-advice-text {
  margin: 14px 0 8px 0;
  color: $color--text;
}

.coach-advice-desc {
  margin: 0 0 12px 0;
  color: $color--text-secondary;
  font-style: italic;
  font-size: 0.95rem;
}

.coach-offenders-title {
  font-size: 0.85rem;
  font-weight: $font--weight--semibold;
  color: $color--text-secondary;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 14px 0 8px 0;
}

.coach-offenders-table {
  margin-bottom: 0;
  font-size: 0.9rem;
}

.coach-offenders-list {
  margin: 0 0 0 1rem;
  padding: 0;
  font-size: 0.9rem;

  li {
    margin-bottom: 4px;
    overflow-wrap: anywhere;
  }
}

//
// Detected technologies — one card per tool with a category chip row.
//
.tech-list {
  list-style: none;
  margin: 0;
  padding: 8px 14px 14px 14px;
  border-top: 1px solid $color--border;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

// When nested inside a .listing-card, the card header already supplies
// the divider; drop the list's own border-top and side padding so the
// grid sits flush with the card content area instead of double-bordered.
.listing-card > .tech-list {
  border-top: 0;
  padding: 0;
}

.tech-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid $color--border;
  border-radius: $radius--md;
  background: $color--surface-card;
}

.tech-card-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.tech-name {
  font-weight: $font--weight--semibold;
  color: $color--text;
  text-decoration: none;
  border-bottom: 1px dotted $color--border;
}

.tech-name:hover {
  border-bottom-color: $color--text-muted;
}

.tech-version {
  font-family: $font--mono;
  font-size: 0.8rem;
  color: $color--text-muted;
}

.tech-confidence {
  margin-left: auto;
  display: inline-flex;
  gap: 4px;
  align-items: baseline;
  font-size: 0.78rem;
}

.tech-confidence-label {
  color: $color--text-muted;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tech-confidence-value {
  color: $color--text;
  font-variant-numeric: tabular-nums;
  font-weight: $font--weight--medium;
}

.tech-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tech-category {
  font-size: 0.75rem;
  padding: 1px 8px;
  border: 1px solid $color--border;
  border-radius: $radius--pill;
  background: $color--surface;
  color: $color--text-secondary;
}

//
// Third-party tools — grouped by category, one chip per tool.
//
.tp-tool-categories {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid $color--border;
  padding: 10px 14px 14px 14px;
}

.tp-tool-cat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tp-tool-cat-name {
  font-size: 0.78rem;
  font-weight: $font--weight--semibold;
  color: $color--text-muted;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tp-tool-cat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;

  li {
    font-size: 0.85rem;
    padding: 2px 9px;
    border: 1px solid $color--border;
    border-radius: $radius--pill;
    background: $color--surface;
    color: $color--text;
  }
}

//
// Resource hints — list of preconnect / dns-prefetch / preload URLs.
//
.hints-list {
  border-top: 1px solid $color--border;
  padding: 10px 14px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.listing-card > .hints-list {
  border-top: 0;
  padding: 0;
}

.hints-group-name {
  display: inline-block;
  margin-bottom: 4px;
  font-family: $font--mono;
  font-size: 0.8rem;
  color: $color--text-muted;
  text-transform: lowercase;
}

.hints-group-urls {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hints-group-url {
  font-size: 0.85rem;
  color: $color--text-secondary;
  word-break: break-all;
  overflow-wrap: anywhere;
}
