/* ------------------------------------------------------------------
   Martín Chujfi — HTMAA 2026
   One stylesheet for every page. Edit colors and fonts here.
   ------------------------------------------------------------------ */

:root {
  --paper:   #F5F6F8;   /* cool lab-bench white */
  --surface: #FFFFFF;
  --ink:     #19202C;
  --slate:   #5A6375;
  --rule:    #D8DCE3;
  --signal:  #2546C9;   /* cobalt — links and the FID trace */
  --code-bg: #1C2333;
  --code-fg: #DCE2EE;

  --serif: "EB Garamond", Garamond, "Times New Roman", serif;
  --sans:  "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --mono:  ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --measure: 52rem;     /* reading column */
  --wide:    72rem;     /* galleries, video */
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:   #12161F;
    --surface: #1A202C;
    --ink:     #E6E9EF;
    --slate:   #9AA3B5;
    --rule:    #2C3444;
    --signal:  #8EA6FF;
    --code-bg: #0B0E15;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.6;
  font-optical-sizing: auto;
}

img, video { max-width: 100%; height: auto; display: block; }

a { color: var(--signal); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; border-radius: 2px; }

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

.site-header {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.site-header .inner {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  font-family: var(--sans);
}
.site-name {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.site-nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
.site-nav a {
  color: var(--slate);
  text-decoration: none;
  font-size: 0.95rem;
  padding: 0.15rem 0;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--signal); }

/* ---------- Page body ---------- */

main {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 3rem 1.25rem 5rem;
}
main > * { max-width: var(--measure); margin-left: auto; margin-right: auto; }
main > .gallery,
main > video,
main > .video,
main > .wide,
main > pre,
main > model-viewer,
main > .pager { max-width: var(--wide); }

h1, h2, h3 {
  font-family: var(--serif);
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-weight: 500;
  text-wrap: balance;
}
h1 { font-size: clamp(2rem, 4.5vw, 2.9rem); margin: 0 auto 1.5rem; }
h2 { font-size: 1.9rem; margin: 3.5rem auto 1rem; }
h3 { font-size: 1.4rem; margin: 2.25rem auto 0.75rem; }
p  { margin: 0 auto 1.25rem; }
sup { line-height: 0; }

.page-kicker {
  font-family: var(--sans);
  color: var(--slate);
  font-size: 1rem;
  margin-bottom: 0.4rem;
}

/* ---------- Media ---------- */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.75rem;
  margin: 2rem auto 2.25rem;
}
.gallery.single { grid-template-columns: minmax(0, 32rem); justify-content: center; }
.gallery img {
  width: 100%;
  height: 100%;
  max-height: 26rem;
  object-fit: cover;
  border-radius: 4px;
  background: var(--surface);
  cursor: zoom-in;
}
.gallery.single img { max-height: 34rem; object-fit: contain; background: none; width: auto; margin: 0 auto; }

main > video {
  width: 100%;
  margin: 2rem auto 2.25rem;
  border-radius: 4px;
  background: #000;
  max-height: 80vh;
}

model-viewer {
  display: block;
  width: 100%;
  height: 32rem;
  margin: 2rem auto;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
}

/* Diagrams with optional caption */
.figure { margin: 2rem auto 2.25rem; text-align: center; }
.figure img {
  width: auto;
  max-width: 100%;
  margin: 0 auto;
  background: #FFFFFF;   /* diagrams are drawn on white; keeps them readable in dark mode */
  padding: 0.5rem;
  border-radius: 4px;
}
.figure figcaption {
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--slate);
  margin-top: 0.6rem;
}

/* ---------- Code ---------- */

pre {
  position: relative;
  background: var(--code-bg);
  color: var(--code-fg);
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.55;
  padding: 1.25rem 1.5rem;
  border-radius: 6px;
  overflow: auto;
  margin: 1.5rem auto 2rem;
  tab-size: 2;
}
pre.collapsed { max-height: 28rem; overflow: hidden; }
pre.collapsed::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 6rem;
  background: linear-gradient(transparent, var(--code-bg));
}
.code-toggle {
  display: block;
  margin: -1.25rem auto 2.5rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  background: none;
  border: 1px solid var(--rule);
  color: var(--ink);
  padding: 0.45rem 1rem;
  border-radius: 999px;
  cursor: pointer;
}
.code-toggle:hover { border-color: var(--signal); }

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed; inset: 0;
  background: rgba(8, 10, 16, 0.92);
  display: none;
  align-items: center; justify-content: center;
  padding: 2rem;
  z-index: 50;
  cursor: zoom-out;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }

/* ---------- Home ---------- */

.home > * { max-width: var(--wide); }
.home h2 { margin-top: 2.5rem; }
.hero { padding: 1rem 0 1rem; }
.hero h1 {
  font-size: clamp(3.25rem, 11vw, 6.5rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 0.95;
  margin-bottom: 0.75rem;
}
.hero .course { font-family: var(--sans); color: var(--slate); font-size: 1.15rem; margin: 0; }
.fid { display: block; width: 100%; height: auto; margin: 2.25rem 0 0.4rem; overflow: visible; }
.fid line { vector-effect: non-scaling-stroke; }
.fid path { fill: none; stroke: var(--signal); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.fid .axis { stroke: var(--rule); stroke-width: 1; }
.fid-caption { font-family: var(--sans); font-size: 0.85rem; color: var(--slate); margin: 0; }

@media (prefers-reduced-motion: no-preference) {
  .fid path.trace {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: acquire 4.5s cubic-bezier(.4,.1,.3,1) 0.3s forwards;   /* slower draw */
  }
  @keyframes acquire { to { stroke-dashoffset: 0; } }
}
@media (max-width: 640px) {
  .fid path { stroke-width: 3.5; }   /* the curve is scaled down on phones; keep the line visible */
}

/* ---------- Week list (home + weekly index) ---------- */

.week-list { list-style: none; padding: 0; margin: 1rem auto 0; border-top: 1px solid var(--rule); }
.week-list li { border-bottom: 1px solid var(--rule); }
.week-list a {
  display: grid;
  grid-template-columns: 3.25rem 1fr 7.5rem;
  gap: 1.25rem;
  align-items: center;
  padding: 1rem 0;
  color: var(--ink);
  text-decoration: none;
}
.week-list .num {
  font-family: var(--serif);
  font-size: 2.4rem;
  font-weight: 400;
  color: var(--slate);
  font-variant-numeric: lining-nums tabular-nums;
  font-variant-numeric: tabular-nums;
}
.week-list .title { font-family: var(--serif); font-weight: 600; font-size: 1.35rem; line-height: 1.25; }
.week-list .desc { display: block; font-family: var(--serif); font-weight: 400; font-size: 1.1rem; color: var(--slate); margin-top: 0.2rem; }
.week-list img { width: 7.5rem; height: 5rem; object-fit: cover; border-radius: 3px; }
.week-list a:hover .title { color: var(--signal); }
.week-list a:hover .num { color: var(--signal); }

.home-links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.75rem; font-family: var(--sans); margin-top: 2.5rem; }

/* AI note on the home page: equal space above (to the week list) and below (to the footer line) */
.ai-note { font-family: var(--sans); font-size: 0.95rem; color: var(--slate); margin: 4.5rem auto 0; }
main.home { padding-bottom: 4.5rem; }

/* Lists and inline code in write-ups */
main li { margin-bottom: 0.4rem; }
main ul { padding-left: 1.4rem; }
:not(pre) > code { font-family: var(--mono); font-size: 0.85em; background: var(--surface); border: 1px solid var(--rule); border-radius: 3px; padding: 0.05em 0.3em; }

/* ---------- About ---------- */

.portrait { width: 17rem; max-width: 100%; margin: 0 0 2rem; border-radius: 4px; }

/* ---------- Prev / next ---------- */

.pager {
  display: flex; justify-content: space-between; gap: 1rem;
  margin-top: 4.5rem; padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
}
.pager a { text-decoration: none; }
.pager small { display: block; color: var(--slate); font-size: 0.85rem; }
.pager .next { text-align: right; margin-left: auto; }

/* ---------- Footer ---------- */

.site-footer {
  max-width: var(--wide); margin: 0 auto; padding: 2rem 1.25rem 3rem;
  font-family: var(--sans); font-size: 0.9rem; color: var(--slate);
  border-top: 1px solid var(--rule);
}

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
  body { font-size: 1.15rem; }
  main { padding-top: 2rem; }
  .week-list a { grid-template-columns: 2.25rem 1fr; }
  .week-list img { display: none; }
  .week-list .num { font-size: 1.5rem; }
  .gallery { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .gallery.single { grid-template-columns: 1fr; }
  model-viewer { height: 22rem; }
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 1.5rem auto 2rem; }
.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}
.table-wrap th {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.9rem;
  text-align: left;
  color: var(--slate);
  border-bottom: 2px solid var(--ink);
  padding: 0.5rem 0.75rem;
}
.table-wrap td {
  border-bottom: 1px solid var(--rule);
  padding: 0.55rem 0.75rem;
  vertical-align: top;
}
.table-wrap td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap caption {
  caption-side: bottom;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--slate);
  padding-top: 0.6rem;
  text-align: left;
}