/* nathan shakura: plain HTML portfolio. No frameworks, no scripts. One self-hosted font (Crimson Text, OFL). */

@font-face { font-family: "Crimson Text"; src: url("fonts/CrimsonText-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Crimson Text"; src: url("fonts/CrimsonText-Italic.ttf") format("truetype"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Crimson Text"; src: url("fonts/CrimsonText-SemiBold.ttf") format("truetype"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Crimson Text"; src: url("fonts/CrimsonText-SemiBoldItalic.ttf") format("truetype"); font-weight: 600; font-style: italic; font-display: swap; }
@font-face { font-family: "Crimson Text"; src: url("fonts/CrimsonText-Bold.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Crimson Text"; src: url("fonts/CrimsonText-BoldItalic.ttf") format("truetype"); font-weight: 700; font-style: italic; font-display: swap; }

:root {
  --bg: #fff;
  --fg: #000;
  --muted: #595959;
  --rule: #d4d4d4;
  --accent: #40ad48;
  --body: 1.125rem;
  --large: calc(var(--body) * 1.3);  /* wordmark and large statement text */
  --pad: clamp(1rem, 3vw, 2.5rem);
  --code-col: 4.5rem;
  --title-col: minmax(0, 24rem);
  color-scheme: light dark;
}

/* Dark colours: follow the device setting unless the visitor picked a mode with the footer toggle
   (theme.js sets data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000;
    --fg: #fff;
    --muted: #a8a8a8;
    --rule: #333;
    --accent: #40ad48;
  }
}
:root[data-theme="dark"] {
  --bg: #000;
  --fg: #fff;
  --muted: #a8a8a8;
  --rule: #333;
  --accent: #40ad48;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Crimson Text", Georgia, "Times New Roman", serif;
  font-size: var(--body);
  line-height: 1.45;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; padding: 0 var(--pad); width: 100%; max-width: 100rem; margin: 0 auto; }

::selection { background: var(--accent); color: #000; }

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

b, strong { font-weight: 600; }

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

.skip {
  position: absolute; left: var(--pad); top: -4rem;
  background: var(--fg); color: var(--bg); padding: 0.5rem 0.75rem; z-index: 10;
}
.skip:focus { top: 0.5rem; }

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

.top {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: 0.5rem 2rem;
  padding: var(--pad);
  max-width: 100rem; margin: 0 auto; width: 100%;
}
.name {
  font-size: var(--large); font-style: italic; text-decoration: none;
  color: var(--accent); margin-right: auto;
}
.name:hover { color: var(--fg); }
.top nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; }
.top nav a { text-decoration: none; }
.top nav a:hover { text-decoration: underline; color: var(--fg); }

/* ---------- home ---------- */

.statement { padding: clamp(2.5rem, 9vw, 7rem) 0 clamp(3rem, 8vw, 6rem); }
.statement p {
  margin: 0; max-width: 30em;
  font-size: var(--large);
  line-height: 1.3; letter-spacing: 0; font-weight: 400;
}

.list { margin-bottom: clamp(3rem, 7vw, 5rem); }
.list h2 {
  margin: 0 0 0.75rem; font-size: 1rem; font-weight: 600;
}

.rows { list-style: none; margin: 0; padding: 0; }
.rows li {
  display: grid;
  grid-template-columns: var(--code-col) var(--title-col) minmax(0, 1fr);
  gap: 0.25rem 1.5rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--rule);
}
.rows li:last-child { border-bottom: 1px solid var(--rule); }
.code { color: var(--muted); font-variant-numeric: tabular-nums; }
.title { font-weight: 600; text-decoration: none; }
.title:hover { text-decoration: underline; }
.desc { color: var(--muted); max-width: 46rem; }

.rows.plain li .title { grid-column: 2; }
.rows.plain li .desc { grid-column: 3; }

.pubs li { display: block; max-width: 52rem; }
.pubs a { font-style: italic; }  /* citations, styled like the CV PDF */

/* ---------- project / text pages ---------- */

.project { padding-top: clamp(1.5rem, 5vw, 4rem); }

.phead h1 {
  margin: 0; max-width: 18em;
  font-size: 1.375rem;  /* two sizes above the 18px body */
  line-height: 1.2; font-style: italic; font-weight: 600;
}
.meta { margin-top: 1.25rem; color: var(--muted); }
.meta p { margin: 0; }

.prose { max-width: 62ch; margin-top: 2rem; font-size: 1.0625rem; line-height: 1.55; }
.prose p { margin: 0 0 1.1em; }
/* All running text is justified; hyphens keep narrow phone lines from gapping. Single-line paragraphs are unaffected. */
.prose p, .statement p { text-align: justify; hyphens: auto; }
.prose a { text-decoration: underline; }
.prose.lead { max-width: 36em; font-size: clamp(1.25rem, 2.3vw, 1.8rem); line-height: 1.3; letter-spacing: -0.005em; }
.prose.contact { margin-top: 1.5rem; font-size: 1rem; }
.prose.contact p { margin-bottom: 0.3em; }

.gallery {
  margin-top: clamp(2.5rem, 6vw, 4.5rem);
  --row: 18rem;  /* target row height; rows stretch slightly from this to fill the width */
  display: flex; flex-wrap: wrap; gap: 1rem;
}
/* Justified rows, no cropping: each figure grows in proportion to its width/height (--r, written by
   make-web-images.py), so every image in a row ends up the same height and the row fills the width. */
.gallery figure {
  margin: 0;
  flex: var(--r, 1) 1 calc(var(--r, 1) * var(--row));
}
.gallery::after { content: ""; flex: 1e6 1 0; }  /* keeps the last row from stretching */
.gallery .br { display: none; }  /* row breaks, used on phones only */
@media (max-width: 1100px) { .gallery { --row: 11rem; } }
.gallery img {
  width: 100%;
  max-width: none !important;  /* overrides the per-image max-width in older HTML */
  background: color-mix(in srgb, var(--fg) 7%, transparent);
}
.gallery img.zoomable { cursor: zoom-in; }
.gallery img.zoomable:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Enlarged view (lightbox.js): the image at 40% of the screen width, over the blurred page. */
.lightbox {
  border: 0; padding: 0; margin: auto; background: transparent;
  max-width: none; max-height: none; overflow: visible;
}
.lightbox::backdrop {
  background: color-mix(in srgb, var(--bg) 45%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.lightbox img { display: block; width: auto; height: auto; max-width: 40vw; max-height: 80vh; }
.lightbox-close {
  position: fixed; top: var(--pad); right: var(--pad);
  font: inherit; font-size: var(--large); font-style: italic; color: var(--accent);
  background: none; border: 0; padding: 0.25rem; cursor: pointer;
}
.lightbox-close:hover { color: var(--fg); }
.lightbox-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
html:has(.lightbox[open]) { overflow: hidden; }  /* page stays put behind the enlarged image */

.pager {
  display: flex; justify-content: space-between; gap: 2rem;
  margin: clamp(3rem, 7vw, 5rem) 0 0; padding: 1.1rem 0 0;
  border-top: 1px solid var(--rule);
  font-weight: 600;
}
.pager a { text-decoration: none; max-width: 22rem; }
.pager a:hover { text-decoration: underline; }
.pager a::before { display: block; font-weight: 400; color: var(--muted); }
.pager .prev::before { content: "Previous"; }
.pager .next::before { content: "Next"; }
.pager .next { margin-left: auto; text-align: right; }

/* ---------- CV ---------- */

.cvsec { margin-top: 2.75rem; max-width: 60rem; }
.cvsec h2 { margin: 0 0 0.6rem; font-size: 1rem; font-weight: 600; }
.cvsec ul { list-style: none; margin: 0; padding: 0; }
.cvsec li {
  display: grid; grid-template-columns: 12rem minmax(0, 1fr); gap: 0 1.5rem;
  padding: 0.6rem 0; border-top: 1px solid var(--rule);
}
.cvsec li.sub { display: block; padding: 0.15rem 0 0.35rem 13.5rem; border-top: 0; color: var(--muted); }
.cvsec .when { color: var(--muted); }

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

.foot {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem 2rem;
  margin-top: clamp(4rem, 9vw, 7rem);
  padding: 1.25rem var(--pad) 2.5rem;
  border-top: 1px solid var(--rule);
  width: 100%; max-width: 100rem; align-self: center;
  font-size: 0.95rem;
}
.foot p { margin: 0 0 0.25rem; }
.theme { margin-top: 0.75rem; color: var(--muted); }
.theme button {
  font: inherit; color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer;
}
.theme button[aria-pressed="true"] { color: var(--fg); text-decoration: underline; text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
.theme button:hover { color: var(--accent); }
.theme button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- small screens ---------- */

@media (max-width: 760px) {
  :root { --code-col: 3.25rem; }
  .top nav { width: 100%; max-width: 24rem; justify-content: space-between; gap: 0.25rem 0.5rem; font-size: 1rem; }
  .rows li { grid-template-columns: var(--code-col) minmax(0, 1fr); gap: 0.15rem 1rem; }
  .rows li .desc { grid-column: 2; }
  .rows.plain li .title { grid-column: 1 / -1; }
  .rows.plain li .desc { grid-column: 1 / -1; }
  .cvsec li { grid-template-columns: 1fr; }
  .cvsec li.sub { padding-left: 1rem; }
  .foot { grid-template-columns: 1fr; }
  .pager { flex-direction: column; gap: 1.25rem; }
  .pager .next { margin-left: 0; text-align: left; }
  /* Phones: exactly two images per row, still uncropped and equal in height. Each figure's width follows
     its proportions (--r), and a .br after every second figure (written by make-web-images.py) starts a new row. */
  .gallery { column-gap: 0.5rem; row-gap: 0; }
  .gallery figure { flex: var(--r, 1) 1 0; margin-bottom: 0.5rem; }
  .gallery .br { display: block; flex-basis: 100%; height: 0; }
  .gallery::after { display: none; }
  .lightbox img { max-width: 92vw; }  /* 40% of a phone screen would be smaller than the grid image */
}

@media print {
  .top nav, .skip, .pager { display: none; }
  body { color: #000; background: #fff; }
}
