/* Example report page.
   Loads on top of styles.css for tokens and shared components. The layout
   mirrors the ScanReport contract (src/modules/scans/contracts.ts) field for
   field, so what a reader sees here is the shape the API actually returns. */

.report-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 32px;
}

/* ---------- nav ---------- */

.report-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 0;
  flex-wrap: wrap;
}

.report-nav .left {
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.back-link {
  font-size: 15px;
  color: var(--paper-3);
}
.back-link:hover { color: var(--orange); }

/* ---------- fictional-example banner ---------- */

.fiction {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  border: 1px solid #4a2c1f;
  background: #1d1109;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 32px;
}

.fiction svg { flex: none; margin-top: 2px; }

.fiction b {
  display: block;
  font-size: 13px;
  letter-spacing: 0.12em;
  color: var(--orange);
  margin-bottom: 5px;
}

.fiction p {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--paper-3);
}

/* ---------- report header ---------- */

.report-head { margin-bottom: 28px; }

.report-head h1 {
  font-weight: 800;
  font-size: 44px;
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

.report-url {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--teal-bright);
  margin: 0 0 22px;
  word-break: break-all;
}

/* Per-item borders rather than a 1px-gap background: the item count is not a
   multiple of the responsive column count, and the gap technique painted the
   trailing empty cells. */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.meta-item {
  background: var(--panel-deep);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 14px 16px;
}

.meta-item .k {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--paper-6);
  margin-bottom: 6px;
}

.meta-item .v {
  font-size: 14px;
  line-height: 1.4;
  color: var(--paper);
  word-break: break-word;
}

.meta-item .v.mono { font-family: var(--mono); font-size: 12.5px; }

.src {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 3px;
  vertical-align: 1px;
}
.src-request { background: #16303d; color: #7fd3e6; }
.src-inferred { background: #3a2d12; color: #e0b955; }

/* ---------- section frames ---------- */

.rsection { margin: 0 0 22px; }

.rsection > h2 {
  font-weight: 800;
  font-size: 30px;
  margin: 0 0 6px;
}

.rsection > .sub {
  margin: 0 0 20px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--paper-3);
  max-width: 780px;
}

.panel-cream {
  background: var(--cream);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 30px 28px;
}

.panel-dark {
  background: var(--panel-deep);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
}

.ai-guide {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 24px;
}

.ai-guide h3 { margin: 0 0 12px; font-size: 20px; }
.ai-guide ol { margin: 0; padding-left: 20px; color: var(--ink-2); line-height: 1.7; }

.report-prompt {
  margin: 0;
  border-radius: 9px;
  background: var(--panel-deep);
  color: var(--paper-2);
  padding: 17px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 12px/1.65 var(--mono);
}

/* ---------- scores ---------- */

.scores {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 32px;
  align-items: start;
}

.overall {
  border: 1px solid var(--cream-line);
  border-radius: 12px;
  background: var(--cream-card);
  padding: 22px;
  text-align: center;
}

.overall .n {
  display: block;
  font-family: var(--serif);
  font-weight: 800;
  font-size: 66px;
  line-height: 1;
  color: var(--ink);
}

.overall .of { font-size: 13px; color: var(--ink-4); }

.overall .lbl {
  display: block;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}

.overall .formula {
  margin: 12px 0 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-5);
  font-family: var(--mono);
}

.subscores {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.subscore {
  border: 1px solid var(--cream-line);
  border-radius: 10px;
  background: var(--cream-card);
  padding: 14px 16px;
}

.subscore .n {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 28px;
  color: var(--ink);
}

.subscore .k {
  display: block;
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 2px;
}

.subscore .w {
  display: block;
  font-size: 11px;
  color: var(--ink-5);
  margin-top: 4px;
  font-family: var(--mono);
}

.dims-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  margin: 0 0 12px;
}

.dim {
  display: grid;
  grid-template-columns: 1fr 74px 130px 44px;
  gap: 12px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--cream-line-3);
  font-size: 13.5px;
}
.dim:last-child { border-bottom: 0; }

.dim .w { font-family: var(--mono); font-size: 12px; color: var(--ink-5); }

.dim .bar {
  height: 7px;
  background: var(--cream-fill);
  border-radius: 4px;
  overflow: hidden;
}
.dim .bar i { display: block; height: 7px; background: var(--teal-2); }
.dim .bar i.low { background: var(--amber); }
.dim .bar i.bad { background: var(--orange); }

.dim .n { font-family: var(--mono); font-size: 13px; text-align: right; }

/* ---------- strengths ---------- */

.strengths { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }

.strength {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  border: 1px solid var(--line-inner);
  border-radius: 10px;
  padding: 15px 16px;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--paper);
}
.strength svg { flex: none; margin-top: 2px; }

/* ---------- top leaks ---------- */

.leaks { display: flex; flex-direction: column; gap: 12px; }

.leak {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 16px;
  align-items: center;
  border: 1px solid var(--cream-line);
  border-radius: 10px;
  background: var(--cream-card);
  /* sits outside .panel-cream, so it must set its own ink — otherwise it
     inherits the page's near-white body colour onto a cream card */
  color: var(--ink);
  padding: 16px 18px;
}

.leak .rank {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--teal);
  color: var(--white);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.leak b { display: block; font-size: 16px; line-height: 1.35; margin-bottom: 5px; }
.leak .tags { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.leak .prio {
  text-align: right;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-4);
  white-space: nowrap;
}
.leak .prio b { font-size: 20px; color: var(--ink); margin: 0; display: block; }

/* ---------- findings ---------- */

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.filter {
  border: 1px solid var(--line-inner);
  background: transparent;
  color: var(--paper-3);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: var(--sans);
  font-size: 13.5px;
  cursor: pointer;
}
.filter:hover { border-color: var(--line-mute); color: var(--paper); }
.filter[aria-pressed="true"] {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--white);
  font-weight: 600;
}

.findings { display: flex; flex-direction: column; gap: 14px; }

.finding {
  background: var(--cream);
  color: var(--ink);
  border-radius: 12px;
  overflow: hidden;
}

.finding-top {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--cream-line);
  flex-wrap: wrap;
}

.finding-top .headline { flex: 1; min-width: 240px; }

.finding-top h3 {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 17.5px;
  line-height: 1.35;
  margin: 0 0 9px;
  letter-spacing: 0;
}

.finding-tags { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.pill {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--cream-fill);
  color: var(--ink-3);
}
.pill-measured { background: var(--teal-badge-bg); color: var(--teal-badge-ink); }
.pill-inferred { background: var(--violet-badge-bg); color: var(--violet-badge-ink); }
.pill-analytics { background: #dce9f6; color: #24507d; }
.pill-hypothesis { background: #fbe6d8; color: #9a4a1c; }

.scoreline {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-4);
}
.scoreline b { color: var(--ink); font-weight: 500; }

.finding-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

/* min-width:0 — grid items default to min-content, so a long unbreakable URL
   in a metric widened the track past the card and .finding's overflow:hidden
   clipped the text instead of wrapping it. */
.fblock { padding: 18px 22px; border-right: 1px solid var(--cream-line); min-width: 0; }
.fblock:last-child { border-right: 0; }
.finding-body > .fblock:nth-child(-n+2) { border-bottom: 1px solid var(--cream-line); }

.fblock h4 {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  margin: 0 0 9px;
}

.fblock p { margin: 0; font-size: 14px; line-height: 1.55; color: var(--ink-2); }

.evidence-row {
  border: 1px solid var(--cream-line-2);
  border-radius: 8px;
  background: var(--white);
  padding: 11px 13px;
  margin-bottom: 9px;
  font-size: 12.5px;
  line-height: 1.6;
}
.evidence-row:last-child { margin-bottom: 0; }

.evidence-row .where {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-5);
  margin-bottom: 7px;
}

.evidence-row .sel {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  word-break: break-all;
}

.metric {
  display: inline-flex;
  flex-wrap: wrap;
  max-width: 100%;
  gap: 4px 8px;
  align-items: baseline;
  margin-top: 7px;
  font-family: var(--mono);
  font-size: 12px;
  background: #f2efe7;
  border-radius: 5px;
  padding: 5px 9px;
}
.metric .val { color: #b5442a; font-weight: 500; word-break: break-all; }
.metric .thr { color: var(--ink-4); word-break: break-all; }

.rewrites { margin: 10px 0 0; padding: 0; list-style: none; }
.rewrites li {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-2);
  padding: 7px 10px;
  background: #f2f1ec;
  border-radius: 5px;
  margin-bottom: 6px;
}

.sources {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-5);
  line-height: 1.6;
}

/* ---------- corrections / patches ---------- */

.patch { margin-top: 10px; }
.patch .del {
  border: 1px solid #f1c6b8;
  border-radius: 6px 6px 0 0;
  background: #fdf1ee;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: #b5442a;
  line-height: 1.5;
}
.patch .add {
  border: 1px solid var(--cream-line-2);
  border-top: 0;
  border-radius: 0 0 6px 6px;
  background: #f2f1ec;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: #2f3a33;
  line-height: 1.5;
}

/* ---------- performance ---------- */

.perf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }

.perf-metric {
  border: 1px solid var(--line-inner);
  border-radius: 10px;
  padding: 14px 16px;
}
.perf-metric .n { font-family: var(--mono); font-size: 22px; color: var(--paper); }
.perf-metric .k { display: block; font-size: 12.5px; color: var(--paper-6); margin-top: 4px; }

/* ---------- comparison ---------- */

.cmp-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }

.cmp-cell {
  display: flex;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line-inner);
  border-radius: 10px;
  padding: 15px 16px;
}

.cmp-cell .orb {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  color: var(--white);
  font-weight: 700;
}

.cmp-cell b { display: block; font-size: 15px; }
.cmp-cell .s { font-size: 12.5px; color: var(--paper-6); }

.delta {
  display: flex;
  gap: 14px;
  align-items: baseline;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--paper-3);
  border-top: 1px solid var(--line-inner);
  padding-top: 16px;
}
.delta .up { color: var(--teal-bright); font-size: 20px; }

/* ---------- limitations ---------- */

.limits { margin: 0; padding: 0; list-style: none; }
.limits li {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
  line-height: 1.55;
  color: var(--paper-3);
}
.limits li:last-child { border-bottom: 0; }
.limits svg { flex: none; margin-top: 3px; }

/* ---------- closing cta ---------- */

.report-cta {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 36px 32px;
  text-align: center;
  margin: 40px 0 56px;
}

.report-cta h2 { font-weight: 800; font-size: 32px; margin: 0 0 10px; }
.report-cta p { margin: 0 auto 22px; max-width: 560px; font-size: 15.5px; line-height: 1.6; color: var(--paper-3); }
.report-cta .btn-primary { font-size: 18px; padding: 17px 34px; border-radius: 10px; }

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .report-shell { padding: 0 16px; }
  .scores,
  .ai-guide,
  .finding-body,
  .leak { grid-template-columns: 1fr; }
  .fblock { border-right: 0; border-bottom: 1px solid var(--cream-line); }
  .fblock:last-child { border-bottom: 0; }
  .finding-body > .fblock:nth-child(-n+2) { border-bottom: 1px solid var(--cream-line); }
  .leak .prio { text-align: left; }
  .dim { grid-template-columns: 1fr 60px 44px; }
  .dim .bar { display: none; }
  .report-head h1 { font-size: 30px; }
  .rsection > h2 { font-size: 24px; }
  .report-cta h2 { font-size: 24px; }
  .panel-cream, .panel-dark { padding: 22px 18px; }
}
