/* Shared styles for every page. Replace freely. */
:root {
  --bg: #fafaf8;
  --fg: #1d1d1b;
  --muted: #6b6a65;
  --accent: #2f6fdb;
  --border: #dddcd5;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #161615; --fg: #ecebe6; --muted: #9c9a92; --border: #33332f; --accent: #78a6f0; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); line-height: 1.6; }
header { border-bottom: 1px solid var(--border); }
nav, main { max-width: 860px; margin: 0 auto; padding: 1rem; }
nav { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; align-items: baseline; }
nav a { color: var(--muted); text-decoration: none; }
nav a.brand { color: var(--fg); font-weight: 600; margin-right: auto; }
nav a:hover, nav a[aria-current="page"] { color: var(--accent); }
.card { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 1rem 0; }
.muted { color: var(--muted); }
main a { color: var(--accent); }
.error { color: #c0392b; }
button { background: var(--accent); color: #fff; border: 0; border-radius: var(--radius); padding: .5rem 1rem; cursor: pointer; }
button:disabled { opacity: .5; cursor: progress; }
canvas#canvas { width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius); display: block; background: #fff; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }

/* Homepage profile sections */
section { margin: 2rem 0; }
h2 { border-bottom: 1px solid var(--border); padding-bottom: .25rem; }
.entries { list-style: none; padding: 0; }
.entries li { display: flex; flex-direction: column; margin: .75rem 0; }
.entry { margin: 1rem 0; }
.entry h3 { margin-bottom: 0; }
.entry p { margin: .25rem 0; }
.tags { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.tags li { border: 1px solid var(--border); border-radius: 999px; padding: .15rem .8rem; }

/* PRNU report */
.report h4 { margin-bottom: .25rem; }
.report .plot { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: var(--radius); margin: 1rem 0; }
.report .small { font-size: .85rem; }
.callout { border-left: 4px solid var(--border); padding: .5rem 1rem; background: color-mix(in srgb, var(--fg) 5%, transparent); }
.callout.same { border-color: #1baf7a; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; overflow-x: auto; display: block; }
table.data th, table.data td { text-align: left; padding: .35rem .6rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.badge { padding: .1rem .55rem; border-radius: 999px; border: 1px solid var(--border); font-size: .8rem; }
.badge.same { border-color: #1baf7a; color: #1baf7a; }
.badge.inconclusive, .badge.incomparable { border-color: #eda100; color: #b07a00; }
.badge.different { color: var(--muted); }
.thumbs { display: flex; flex-wrap: wrap; gap: 1rem; }
.thumbs figure { margin: 0; max-width: 220px; font-size: .85rem; overflow-wrap: anywhere; }
.thumbs img { width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--border); display: block; margin-bottom: .25rem; }
table.data tbody th { font-weight: normal; color: var(--muted); }

/* Photography gallery */
main.wide { max-width: 1200px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.gallery { columns: 3 280px; column-gap: 1rem; }
.gallery figure { break-inside: avoid; margin: 0 0 1rem; }
.gallery img, .gallery video { width: 100%; height: auto; display: block; border-radius: var(--radius); }
.gallery figcaption { display: flex; flex-direction: column; font-size: .9rem; padding-top: .35rem; }

/* Admin pages */
.stack { display: grid; gap: .75rem; }
.stack label { display: grid; gap: .25rem; }
.stack input:not([type="file"]), .stack textarea {
  font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius); padding: .4rem .6rem; width: 100%;
}
.stack h2 { margin: 0; }
.narrow { max-width: 360px; }
.narrow-ish { max-width: 560px; }
.small { font-size: .85rem; }
.notice { border-left: 4px solid var(--accent); padding: .25rem .75rem; }
.notice.error { border-color: #c0392b; }
.admin-item { display: grid; grid-template-columns: 180px 1fr; gap: 1rem; align-items: start; }
.admin-item img, .admin-item video { width: 100%; display: block; border-radius: var(--radius); }
@media (max-width: 600px) { .admin-item { grid-template-columns: 1fr; } }
button.secondary { background: transparent; color: var(--fg); border: 1px solid var(--border); }
button.danger { background: #c0392b; }

/* Rendering gallery */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.25rem; }
.project-card { display: flex; flex-direction: column; gap: .25rem; color: var(--fg); text-decoration: none; }
main a.project-card { color: var(--fg); }
.project-card img, .project-card .placeholder {
  width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: .25rem;
}
.project-card img { display: block; }
.project-card:hover strong { color: var(--accent); }
.project-card:hover img { border-color: var(--accent); }
.placeholder {
  display: flex; align-items: center; justify-content: center;
  background: repeating-linear-gradient(45deg, transparent 0 12px, color-mix(in srgb, var(--fg) 5%, transparent) 12px 24px);
}
.viewer { width: 100%; aspect-ratio: 16 / 10; max-height: 80vh; border: 1px solid var(--border); border-radius: var(--radius); display: block; background: #fff; }
.placeholder.viewer { display: flex; background-color: transparent; }

/* Renderer module (C rasterizer / raytracer fragments) */
.renderer select {
  font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius); padding: .3rem .5rem; margin-left: .5rem;
}
.render-controls { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; }
/* The output gets most of the width; the reference is there to compare against. */
.render-pair { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1rem; margin: 1rem 0; align-items: start; }
@media (max-width: 600px) { .render-pair { grid-template-columns: 1fr; } }
.render-pair figure { margin: 0; }
.render-pair figcaption { font-size: .85rem; color: var(--muted); padding-top: .25rem; }
.render-pair img {
  /* Outputs are tiny (20x30 to 256x256): scale up without smoothing, and show
     transparent pixels against a checkerboard. */
  width: 100%; height: auto; max-height: 60vh; object-fit: contain; display: block;
  image-rendering: pixelated; border: 1px solid var(--border); border-radius: var(--radius);
  background: repeating-conic-gradient(#8884 0 25%, transparent 0 50%) 0 0 / 16px 16px;
}
/* Scaled renders have real detail; shrinking them to fit needs smoothing, not pixel doubling. */
.render-pair img.smooth { image-rendering: auto; }
.renderer details pre { overflow: auto; max-height: 24rem; font-size: .8rem; padding: .75rem; border: 1px solid var(--border); border-radius: var(--radius); }

/* Architecture page (diagram styles live inside the SVG itself) */
svg.arch { width: 100%; height: auto; display: block; margin: 1.5rem 0; }
.flow h3 { margin-top: 0; }
.flow li { margin: .4rem 0; }
code { font-size: .9em; }

.profile { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.profile h1 { margin: 0; }
.avatar { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
