/* Hypermedia Report Style — Component & Layout CSS
 * Expects tokens.css to be loaded first (or bundled before this file).
 */

/* ============================================================
   Reset & base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg, video { display: block; max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color var(--transition); }
a:hover { border-bottom-color: var(--accent); }
hr { border: 0; border-top: 1px solid var(--rule); margin: 3rem 0; }

/* ============================================================
   Typography
   ============================================================ */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: var(--fw-medium);
  color: var(--ink);
  line-height: var(--lh-tight);
  margin: 0 0 0.75em;
  letter-spacing: -0.01em;
  font-variation-settings: "opsz" 144;
}
h1 { font-size: var(--fs-4xl); font-weight: var(--fw-semibold); letter-spacing: -0.025em; }
h2 { font-size: var(--fs-3xl); font-weight: var(--fw-medium); margin-top: 2.5em; }
h3 { font-size: var(--fs-xl); font-weight: var(--fw-semibold); font-variation-settings: "opsz" 24; margin-top: 2em; }
h4 { font-size: var(--fs-lg); font-weight: var(--fw-semibold); font-family: var(--font-body); letter-spacing: -0.005em; margin-top: 1.5em; }

p { margin: 0 0 1em; }
strong, b { font-weight: var(--fw-semibold); color: var(--ink); }
em { font-style: italic; }

small, .text-sm { font-size: var(--fs-sm); color: var(--ink-3); }
.text-xs { font-size: var(--fs-xs); letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); font-weight: var(--fw-semibold); }

code, kbd, samp, pre { font-family: var(--font-mono); font-size: 0.92em; }
code { background: var(--paper-2); padding: 0.12em 0.35em; border-radius: 4px; color: var(--ink-2); }
pre {
  background: var(--ink);
  color: #E6E3DC;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
  line-height: var(--lh-snug);
  font-size: var(--fs-sm);
}
pre code { background: transparent; padding: 0; color: inherit; }

blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-tint);
  color: var(--accent-ink);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
}

/* ============================================================
   Layout primitives
   ============================================================ */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--global-padding);
}
.prose {
  max-width: var(--container-prose);
  margin: 0 auto;
}
.prose > * + * { margin-top: 1em; }
.prose h2, .prose h3 { max-width: none; }

/* ============================================================
   Page skeleton
   ============================================================ */
.site {
  display: grid;
  grid-template-columns: var(--rail-width) 1fr;
  min-height: 100vh;
}

/* Sticky left nav rail */
.rail {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 2rem 1.5rem;
  background: var(--paper-2);
  border-right: 1px solid var(--rule);
  overflow-y: auto;
  font-size: var(--fs-sm);
}
.rail-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 2rem;
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-lg);
  color: var(--ink);
}
.rail-brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: var(--fw-bold);
}
.rail-meta {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-3);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.rail-meta dt {
  margin-top: 0.75rem;
  font-weight: var(--fw-semibold);
  color: var(--ink-muted);
}
.rail-meta dd {
  margin: 0.2rem 0 0;
  color: var(--ink-2);
  font-weight: var(--fw-medium);
  text-transform: none;
  letter-spacing: 0;
  font-size: var(--fs-sm);
  word-break: break-word;
}
.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.rail-nav-group-title {
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: var(--fw-semibold);
  margin-bottom: 0.5rem;
}
.rail-nav a {
  display: block;
  padding: 0.4rem 0.6rem;
  color: var(--ink-2);
  border-radius: var(--radius-sm);
  border: 0;
  transition: background var(--transition), color var(--transition);
  line-height: var(--lh-snug);
}
.rail-nav a:hover {
  background: var(--paper-3);
  color: var(--ink);
  border-bottom: 0;
}
.rail-nav a.is-active {
  background: var(--ink);
  color: var(--paper);
}

/* Main content column */
.main {
  padding: var(--section-padding) var(--global-padding);
  min-width: 0;
}
.main > .prose,
.main > .container { padding-left: 0; padding-right: 0; }

/* Hero */
.report-hero {
  margin-bottom: 4rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--rule);
}
.report-hero .kicker {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-pill);
  background: var(--accent-tint);
  color: var(--accent-ink);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: var(--fw-semibold);
  margin-bottom: 1.25rem;
}
.report-hero h1 {
  margin-bottom: 0.5rem;
  max-width: 18ch;
  font-variation-settings: "opsz" 144;
}
.report-hero .subhead {
  font-size: var(--fs-lg);
  color: var(--ink-3);
  max-width: 56ch;
  margin: 0 0 2rem;
  line-height: var(--lh-snug);
}
.report-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  font-size: var(--fs-sm);
}
.report-hero-meta dt {
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: var(--fw-semibold);
  margin-bottom: 0.35rem;
}
.report-hero-meta dd {
  margin: 0;
  font-weight: var(--fw-medium);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}

/* ============================================================
   Score cards (Lighthouse)
   ============================================================ */
.score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 2rem 0 3rem;
}
.score-card {
  position: relative;
  padding: 1.5rem 1.5rem 1.25rem;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.score-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--score-good);
}
.score-card[data-band="ok"]::before { background: var(--score-ok); }
.score-card[data-band="bad"]::before { background: var(--score-bad); }
.score-card[data-band="na"]::before { background: var(--ink-muted); }

.score-card .score-label {
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: var(--fw-semibold);
}
.score-card .score-value {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 144;
  font-size: clamp(3rem, 2rem + 3vw, 4.25rem);
  font-weight: var(--fw-semibold);
  line-height: 1;
  color: var(--ink);
  margin: 0.5rem 0 0.25rem;
  letter-spacing: -0.02em;
}
.score-card .score-suffix {
  font-size: 0.5em;
  color: var(--ink-muted);
  font-weight: var(--fw-regular);
  margin-left: 0.1em;
}
.score-card .score-context {
  font-size: var(--fs-xs);
  color: var(--ink-muted);
  font-weight: var(--fw-medium);
}

/* Core Web Vitals strip */
.cwv-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin: 1.5rem 0 3rem;
  padding: 1.25rem;
  background: var(--paper-2);
  border-radius: var(--radius-md);
}
.cwv-item .cwv-label {
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: var(--fw-semibold);
}
.cwv-item .cwv-value {
  font-family: var(--font-mono);
  font-size: var(--fs-xl);
  font-weight: var(--fw-medium);
  color: var(--ink);
  margin-top: 0.25rem;
}
.cwv-item[data-band="good"] .cwv-value { color: var(--score-good); }
.cwv-item[data-band="ok"] .cwv-value { color: var(--score-ok); }
.cwv-item[data-band="bad"] .cwv-value { color: var(--score-bad); }

/* ============================================================
   Severity badges & finding cards
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.75;
}
.badge[data-sev="critical"]  { background: var(--sev-critical-bg); color: var(--sev-critical); }
.badge[data-sev="important"] { background: var(--sev-important-bg); color: #92400E; }
.badge[data-sev="minor"]     { background: var(--sev-minor-bg); color: #854D0E; }
.badge[data-sev="nice"]      { background: var(--sev-nice-bg); color: var(--sev-nice); }

.finding {
  padding: 1.25rem 1.5rem;
  background: #fff;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--sev-nice);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
}
.finding[data-sev="critical"]  { border-left-color: var(--sev-critical); }
.finding[data-sev="important"] { border-left-color: var(--sev-important); }
.finding[data-sev="minor"]     { border-left-color: var(--sev-minor); }
.finding[data-sev="nice"]      { border-left-color: var(--sev-nice); }

.finding-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.finding-head h4 {
  margin: 0;
  font-size: var(--fs-lg);
  font-family: var(--font-body);
  font-weight: var(--fw-semibold);
  color: var(--ink);
}
.finding-body { color: var(--ink-2); line-height: var(--lh-normal); }
.finding-body > * + * { margin-top: 0.75rem; }

/* ============================================================
   Callouts
   ============================================================ */
.callout {
  padding: 1.5rem 1.75rem;
  background: var(--accent-tint);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--accent-ink);
  margin: 2rem 0;
}
.callout-title {
  font-family: var(--font-body);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}
.callout.callout-muted {
  background: var(--paper-2);
  border-left-color: var(--ink-3);
  color: var(--ink-2);
}

/* ============================================================
   Tables
   ============================================================ */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0 2.5rem;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
thead th {
  text-align: left;
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: var(--fw-semibold);
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--rule-strong);
}
tbody td {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-2);
  vertical-align: top;
}
tbody tr:nth-child(even) td { background: var(--paper-2); }
tbody tr:last-child td { border-bottom: 0; }

/* Right-align numeric cells (markdown tables usually lack classes;
   rely on containing mono content to hint) */
td code, td.num { font-family: var(--font-mono); }

/* ============================================================
   Screenshots
   ============================================================ */
.screenshot {
  margin: 2rem 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  background: #fff;
}
.screenshot img { width: 100%; display: block; }
.screenshot-caption {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--rule);
  background: var(--paper-2);
  font-size: var(--fs-xs);
  color: var(--ink-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: var(--fw-semibold);
}
.screenshot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

/* Inline images in prose get the same frame */
.prose img, .main img:not(.bare) {
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin: 1.5rem auto;
}

/* ============================================================
   Lists
   ============================================================ */
ul, ol { padding-left: 1.35em; margin: 0 0 1em; }
li { margin-bottom: 0.35em; }
li::marker { color: var(--ink-muted); }
li > ul, li > ol { margin-top: 0.35em; }

/* ============================================================
   Report footer
   ============================================================ */
.report-footer {
  margin-top: 5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  font-size: var(--fs-sm);
  color: var(--ink-3);
  flex-wrap: wrap;
}
.report-footer-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  color: var(--ink);
  font-size: var(--fs-base);
}

/* ============================================================
   Index (landing) page
   ============================================================ */
.report-index {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin: 2rem 0 3rem;
}
.report-index a {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.5rem;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
  border-bottom: 1px solid var(--rule);
}
.report-index a:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--rule-strong);
  border-bottom-color: var(--rule-strong);
}
.report-index .card-kicker {
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: var(--fw-semibold);
}
.report-index .card-title {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: var(--fw-medium);
  color: var(--ink);
  line-height: var(--lh-tight);
}
.report-index .card-body {
  font-size: var(--fs-sm);
  color: var(--ink-3);
  line-height: var(--lh-snug);
}

/* ============================================================
   Responsive — collapse rail on tablet/mobile
   ============================================================ */
@media (max-width: 900px) {
  .site { grid-template-columns: 1fr; }
  .rail {
    position: static;
    height: auto;
    padding: 1.5rem var(--global-padding);
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }
  .rail-nav { flex-direction: row; flex-wrap: wrap; gap: 0.5rem 1rem; }
  .rail-nav-group-title { width: 100%; }
  .rail-nav a { padding: 0.3rem 0.5rem; }
  .main { padding: 2.5rem var(--global-padding); }
  .report-hero { margin-bottom: 2.5rem; padding-bottom: 1.5rem; }
}

/* ============================================================
   Print — remove nav, keep content
   ============================================================ */
@media print {
  body { background: #fff; }
  .rail, .report-footer { display: none; }
  .site { grid-template-columns: 1fr; }
  .main { padding: 0; }
  .score-card, .finding { break-inside: avoid; }
  h1, h2, h3 { break-after: avoid; }
  a { color: var(--ink); border-bottom: 0; }
}

/* ============================================================
   Utility
   ============================================================ */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
