/* ==========================================================================
   Mad Max F1Tenth — Light · Minimal · Compact
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --bg:           #ffffff;
  --bg-soft:      #fafafa;
  --bg-card:      #ffffff;
  --border:       #e6e6e6;
  --border-strong:#cfcfcf;

  --text:         #1a1a1a;
  --text-muted:   #555;
  --text-dim:     #888;

  --accent:       #c92a2a;
  --accent-soft:  #fff3f3;
  --link:         #c92a2a;
  --link-hover:   #8e1d1d;

  --font-body:    -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono:    ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --max-width:    820px;
  --radius:       6px;
}

/* ---------- Global ---------- */
* { box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  margin: 0;
  padding: 0;
}

/* Hide quarto chrome */
.navbar-brand, .nav-footer { display: none !important; }
#quarto-content { padding-top: 0; }
.page-layout-full .content { max-width: 100%; padding: 0; }
#TOC, .quarto-secondary-nav, .sidebar { display: none !important; }

/* Links */
a { color: var(--link); text-decoration: none; transition: color .12s ease; }
a:hover { color: var(--link-hover); text-decoration: underline; }

/* Reset section default spacing from Quarto */
section { margin: 0; padding: 0; }

/* ---------- HERO ---------- */
.hero-section {
  text-align: center;
  padding: 3rem 1.25rem 2rem;
  max-width: var(--max-width);
  margin: 0 auto;
  border-bottom: 1px solid var(--border);
}

.hero-section > .title,
.hero-section h1.title {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 0.5rem;
  color: var(--accent);
  border-bottom: none;
}

.hero-section .subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 540px;
  margin: 0 auto 1.1rem;
  font-weight: 400;
}

.author-list {
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 0.25rem;
  font-weight: 500;
}
.author-list a {
  color: var(--text);
  font-weight: 500;
  border-bottom: 1px solid transparent;
}
.author-list a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-decoration: none;
}

.affiliation-list {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 1.1rem;
}

/* ---------- Buttons ---------- */
.button-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.4rem;
}
.button-row .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none !important;
  border: 1px solid var(--border-strong);
  transition: all .12s ease;
}
.button-row .btn-primary {
  background: var(--accent);
  color: #fff !important;
  border-color: var(--accent);
}
.button-row .btn-primary:hover {
  background: var(--link-hover);
  border-color: var(--link-hover);
}
.button-row .btn-secondary {
  background: #fff;
  color: var(--text) !important;
}
.button-row .btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent) !important;
}

/* ---------- Section Container ---------- */
.section-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.6rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.section-container:last-of-type { border-bottom: none; }

/* Section H2 — clean, simple heading.
   Quarto applies the section class to the wrapping <section>, so we target
   only the H2 directly to avoid inheriting properties to body content. */
.section-container > h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 1rem;
  letter-spacing: -0.01em;
  border-bottom: none;
  padding: 0 0 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* ---------- Generic text ---------- */
p { margin: 0 0 0.7rem; }
p:last-child { margin-bottom: 0; }

/* ---------- Video ---------- */
.video-container {
  max-width: 720px;
  margin: 0 auto;
}
.video-container iframe,
.video-container video {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* Quarto's {{< video >}} shortcode wraps in .quarto-video — give it a 16:9 box */
.quarto-video,
.ratio.ratio-16x9 {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
}
.quarto-video iframe,
.ratio.ratio-16x9 iframe,
.quarto-video video,
.ratio.ratio-16x9 video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Slightly smaller embed inside challenge-image (which sits next to text) */
.challenge-image .quarto-video,
.challenge-image .ratio.ratio-16x9 {
  max-width: 100%;
}
.result-card .quarto-video,
.result-card .ratio.ratio-16x9 {
  margin-bottom: 0.35rem;
}

.video-placeholder,
.video-placeholder-large {
  border: 1px dashed var(--border-strong);
  background: var(--bg-soft);
  border-radius: var(--radius);
  text-align: center;
  color: var(--text-dim);
  font-size: 0.78rem;
}
.video-placeholder { padding: 0.9rem 0.8rem; }
.video-placeholder-large { padding: 2rem 1.2rem; }
.video-placeholder-large strong {
  color: var(--text);
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
  font-weight: 600;
}

/* ---------- Pipeline (Flowchart) ---------- */
.pipeline {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  max-width: 460px;
  margin: 0 auto;
}
.pipeline-node {
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.55rem 0.95rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
}
.pipeline-node.node-final {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.node-num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}
.node-final .node-num { color: var(--accent); }
.pipeline-arrow {
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1;
  padding: 0.25rem 0;
  text-align: center;
  width: 100%;
}

.diagram-caption {
  font-size: 0.8rem;
  color: var(--text-dim);
  max-width: 580px;
  margin: 1rem auto 0;
  line-height: 1.55;
  text-align: center;
  font-style: italic;
}

/* ---------- Prose Block (narrative sections) ---------- */
.prose-block {
  max-width: 720px;
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text);
}
.prose-block p {
  margin: 0 0 0.75rem;
  color: var(--text-muted);
}
.prose-block p:last-child { margin-bottom: 0; }
.prose-block strong { color: var(--text); font-weight: 600; }
.prose-block h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin: 1.25rem 0 0.45rem;
  padding: 0;
  border-bottom: none;
  letter-spacing: -0.005em;
}
.prose-block h3:first-child { margin-top: 0; }
.prose-block ul {
  margin: 0 0 0.75rem;
  padding-left: 1.2rem;
}
.prose-block li {
  margin-bottom: 0.3rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.prose-block li strong { color: var(--text); }
.prose-block code {
  font-family: var(--font-mono);
  background: var(--bg-soft);
  color: var(--accent);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  font-size: 0.85em;
  border: 1px solid var(--border);
}

/* ---------- Approach Cards ---------- */
.approach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.7rem;
}
.approach-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  transition: border-color .12s ease;
}
.approach-card:hover { border-color: var(--accent); }
.approach-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  margin-bottom: 0.45rem;
}
.approach-card h3 {
  font-size: 0.92rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
  color: var(--text);
  border-bottom: none;
}
.approach-card p {
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.55;
  margin: 0;
}
.approach-detail {
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.5;
}
.approach-detail p { color: var(--text-dim); font-size: 0.78rem; margin: 0; }
.approach-detail strong { color: var(--text); font-weight: 600; }

/* ---------- Tuning View ---------- */
.run-block {
  margin-bottom: 0.9rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
}
.run-block:last-of-type { margin-bottom: 0; }
.run-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}
.run-header p { margin: 0; }
.run-badge {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  background: var(--accent);
  color: #fff;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-weight: 600;
  margin-right: 0.4rem;
}
.run-badge-alt { background: #1a1a1a; }
.tuning-img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  margin-bottom: 0.7rem;
  display: block;
}
.tuning-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.5rem;
}
.tuning-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem;
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-dim);
}
.tuning-card img {
  width: 100%;
  border-radius: 3px;
  background: #fff;
  margin-bottom: 0.3rem;
  display: block;
}
.tuning-card strong {
  color: var(--text);
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
}

.callout-box {
  margin-top: 0.9rem;
  padding: 0.65rem 0.85rem;
  background: var(--accent-soft);
  border-left: 2px solid var(--accent);
  border-radius: 3px;
  font-size: 0.86rem;
  color: var(--text);
  line-height: 1.55;
}
.callout-box p { margin: 0; }
.callout-box strong { color: var(--accent); font-weight: 600; }

/* ---------- Metric Cards ---------- */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.6rem;
}
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  transition: border-color .12s ease;
}
.metric-card:hover { border-color: var(--accent); }
.metric-num {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  display: block;
  margin-bottom: 0.3rem;
}
.metric-card h4 {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 0.3rem;
  letter-spacing: 0.02em;
  border-bottom: none;
}
.metric-headline {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.35rem;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.metric-card p {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.5;
  margin: 0;
}

/* ---------- Results ---------- */
.results-summary-text {
  background: var(--bg-soft);
  border-left: 2px solid var(--accent);
  padding: 0.7rem 0.9rem;
  border-radius: 3px;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 0.9rem;
}
.results-summary-text p { margin: 0; }
.results-summary-text strong { color: var(--accent); font-weight: 600; }

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.7rem;
}
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  text-align: center;
  font-size: 0.74rem;
  color: var(--text-dim);
}
.result-card img {
  width: 100%;
  border-radius: 3px;
  background: #fff;
  margin-bottom: 0.35rem;
  display: block;
}
.result-card p { margin: 0; }

/* ---------- Challenges ---------- */
.challenge-block {
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  gap: 0.7rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 0.6rem;
}
.challenge-block:last-of-type { margin-bottom: 0; }
.challenge-num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.08em;
  padding-top: 0.18rem;
}
.challenge-body h4 {
  font-size: 0.92rem;
  font-weight: 600;
  margin: 0 0 0.3rem;
  color: var(--text);
  border-bottom: none;
}
.challenge-body p {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.55;
  margin: 0 0 0.4rem;
}
.challenge-body strong { color: var(--text); font-weight: 600; }
.challenge-image {
  margin-top: 0.55rem;
  max-width: 340px;
}
.challenge-image img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  display: block;
}

/* Side-by-side image pair inside a challenge */
.challenge-image.challenge-image-pair {
  max-width: 440px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}
.challenge-image-item p {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-align: center;
  margin: 0.3rem 0 0;
  line-height: 1.35;
}

@media (max-width: 600px) {
  .challenge-block { grid-template-columns: 1fr; gap: 0.3rem; }
  .challenge-image.challenge-image-pair { grid-template-columns: 1fr; }
}

/* ---------- Future Work ---------- */
.future-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.6rem;
}
.future-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.future-card p { margin: 0; }
.future-card strong {
  color: var(--text);
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.88rem;
  font-weight: 600;
}

/* ---------- Takeaway ---------- */
.takeaway-box {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.95rem 1.1rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
}
.takeaway-box p { margin: 0; }
.takeaway-box strong { color: var(--accent); font-weight: 600; }

/* ---------- Code / BibTeX ---------- */
.section-container pre {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  font-size: 0.74rem;
  font-family: var(--font-mono);
  overflow-x: auto;
  color: var(--text);
  margin: 0;
}
.section-container code {
  font-family: var(--font-mono);
  background: var(--bg-soft);
  color: var(--accent);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  font-size: 0.85em;
  border: 1px solid var(--border);
}
.section-container pre code {
  background: transparent;
  color: var(--text);
  padding: 0;
  border: none;
  font-size: 0.74rem;
}

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 1.2rem 1.25rem 1.6rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  max-width: var(--max-width);
  margin: 0 auto;
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--accent); }

/* ---------- Quarto figure cleanup ---------- */
figure { margin: 0; }
figcaption {
  font-size: 0.74rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 0.3rem;
  font-style: italic;
}

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
  html, body { font-size: 14.5px; }
  .hero-section { padding: 2.2rem 1rem 1.4rem; }
  .section-container { padding: 1.2rem 1rem; }
  .hero-section h1.title { font-size: 1.55rem; }
}
