/* ==========================================================================
   16-825 Learning for 3D Vision — assignment writeup stylesheet
   Shared across assignments. Edit colors in :root if you want a new accent.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --fg: #1c1e21;
  --fg-muted: #5c6570;
  --border: #e2e5e9;
  --accent: #b8102e;          /* CMU cardinal */
  --accent-soft: #fdf0f2;
  --code-bg: #f2f3f5;
  --maxw: 980px;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
          Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c;
    --bg-soft: #1e2126;
    --fg: #e6e8ea;
    --fg-muted: #a0a8b2;
    --border: #2d3138;
    --accent: #ff6b83;
    --accent-soft: #2a1a1e;
    --code-bg: #22262c;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 1.5rem; }

body {
  margin: 0;
  padding: 0 1.25rem 6rem;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

header.page-header {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 3.5rem 0 1.75rem;
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  font-size: 0.8rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 0.5rem;
}

header.page-header h1 {
  margin: 0 0 0.6rem;
  font-size: 2.3rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.byline {
  margin: 0;
  color: var(--fg-muted);
  font-size: 0.98rem;
}

.byline code { font-size: 0.9em; }

/* ------------------------------------------------------------------ toc -- */

nav.toc {
  max-width: var(--maxw);
  margin: 2.25rem auto 0;
}

nav.toc h2 {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

nav.toc ul {
  margin: 0;
  padding: 0;
  list-style: none;          /* section headings already carry their numbers */
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.7rem;
}

nav.toc li { margin: 0; break-inside: avoid; }

/* Each entry is a card: number badge on the left, section title on the right. */
nav.toc a {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  height: 100%;
  padding: 0.7rem 0.9rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font-size: 0.95rem;
  line-height: 1.35;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

nav.toc a:hover,
nav.toc a:focus-visible {
  background: var(--accent-soft);
  border-color: var(--border);
  border-left-color: var(--accent);
  transform: translateY(-1px);
}

nav.toc .toc-num {
  flex: none;
  min-width: 1.35em;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  nav.toc a { transition: none; }
  nav.toc a:hover { transform: none; }
}

/* ------------------------------------------------------------- sections -- */

main { max-width: var(--maxw); margin: 0 auto; }

section.question {
  padding-top: 2.75rem;
  margin-top: 0.5rem;
}

section.question > h2 {
  margin: 0 0 0.35rem;
  font-size: 1.55rem;
  letter-spacing: -0.01em;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

section.question h3 {
  margin: 2rem 0 0.4rem;
  font-size: 1.13rem;
}

.points {
  display: inline-block;
  margin-left: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: middle;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
}

.prompt {
  margin: 0.9rem 0 1.2rem;
  padding: 0.8rem 1.1rem;
  background: var(--bg-soft);
  border-left: 3px solid var(--border);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--fg-muted);
  font-size: 0.95rem;
}

.prompt p:first-child { margin-top: 0; }
.prompt p:last-child { margin-bottom: 0; }

/* ------------------------------------------------------- chat transcript -- */
/* <div class="chat">
     <div class="turn me"><div class="who">Me</div><div class="bubble">…</div></div>
     <div class="turn bot"><div class="who">ChatGPT</div><div class="bubble">…</div></div>
   </div> */

.chat {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1.4rem 0;
}

.chat .turn {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 0 1rem;
  align-items: start;
}

.chat .who {
  padding-top: 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--fg-muted);
  text-align: right;
}

.chat .turn.me .who { color: var(--accent); }

.chat .bubble {
  padding: 0.75rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

/* The human turn reads as the question: tinted, with an accent spine. */
.chat .turn.me .bubble {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
}

.chat .bubble > :first-child { margin-top: 0; }
.chat .bubble > :last-child { margin-bottom: 0; }

.chat .bubble p + p { margin-top: 0.7rem; }

/* Stack the speaker label above the bubble once the columns get cramped. */
@media (max-width: 560px) {
  .chat .turn { grid-template-columns: minmax(0, 1fr); gap: 0.3rem; }
  .chat .who { padding-top: 0; text-align: left; }
}

a { color: var(--accent); }

/* Long URLs used as their own link text break instead of overflowing. */
a { overflow-wrap: anywhere; }

/* Attribution line under a figure, when the credit needs its own paragraph
   rather than living inside the figcaption. */
.source {
  margin-top: -0.5rem;
  font-size: 0.88rem;
  color: var(--fg-muted);
}

/* Printed copies lose hrefs, so spell out external URLs after the link text. */
@media print {
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    word-break: break-all;
  }
}

/* ----------------------------------------------------------------- code -- */

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--code-bg);
  border-radius: 4px;
  padding: 0.12em 0.38em;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.5;
}

pre code { background: none; padding: 0; font-size: inherit; }

/* ---------------------------------------------------------------- media -- */

figure {
  margin: 1.25rem 0;
  text-align: center;
}

figure img,
figure video {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

figcaption {
  margin-top: 0.55rem;
  font-size: 0.88rem;
  color: var(--fg-muted);
}

/* Side-by-side / grid of results. Add .cols-3 or .cols-4 for tighter grids. */
.gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin: 1.25rem 0;
}

.gallery.cols-1 { grid-template-columns: minmax(0, 1fr); }
.gallery.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gallery.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.gallery figure { margin: 0; }

@media (max-width: 720px) {
  .gallery,
  .gallery.cols-3,
  .gallery.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 460px) {
  .gallery,
  .gallery.cols-2,
  .gallery.cols-3,
  .gallery.cols-4 { grid-template-columns: minmax(0, 1fr); }
}

/* Placeholder shown where a result image has not been dropped in yet. */
.todo {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--fg-muted);
  font-family: var(--mono);
  font-size: 0.82rem;
  text-align: center;
  padding: 1rem;
}

/* --------------------------------------------------------------- tables -- */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.94rem;
}

th, td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

th { background: var(--bg-soft); font-weight: 600; }

/* --------------------------------------------------------------- footer -- */

footer.page-footer {
  max-width: var(--maxw);
  margin: 4rem auto 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: 0.88rem;
}

/* ---------------------------------------------------------------- print -- */

@media print {
  body { padding: 0; font-size: 11pt; }
  nav.toc { break-inside: avoid; }
  section.question { break-inside: avoid-page; }
}
