/* ---------- Design tokens ---------- */
/*
 * A single, deliberate dark theme — not adaptive to system preference.
 * Palette is a restrained take on Celtic manuscript colors (black,
 * forest green, antique gold), tuned first for contrast/readability
 * and second for mood. See README "Theming" section for how to swap
 * these out for a different palette.
 */
:root {
  /* Scales with viewport width (roughly half the screen on large
     monitors) but never gets uncomfortably narrow or absurdly wide. */
  --max-width: clamp(40rem, 50vw, 68rem);
  --gap: 1.25rem;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-heading: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --color-bg: #0d1411;        /* near-black, faint green undertone */
  --color-bg-alt: #121a16;    /* slightly lifted panel (dialogs, cards) */
  --color-fg: #e8e6dd;        /* warm parchment white */
  --color-muted: #93a39a;     /* muted sage for secondary text */
  --color-border: #24322b;    /* dark mossy border */
  --color-link: #5fbf8f;      /* soft forest green */
  --color-link-hover: #86d9ab;/* brighter green on hover/focus */
  --color-code-bg: #16201b;
  --color-accent: #b99a55;    /* antique gold, used sparingly */
}

/* ---------- Reset-ish basics ---------- */
* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--color-fg);
  background: var(--color-bg);
}

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

a { color: var(--color-link); text-decoration: none; }
a:hover { color: var(--color-link-hover); text-decoration: underline; }

.container {
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
}
.skip-link:focus {
  left: 1rem;
  top: 1rem;
  background: var(--color-bg);
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-border);
  z-index: 100;
}

/* ---------- Header / Nav ---------- */
.site-header {
  border-bottom: 1px solid var(--color-border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: 1rem;
  position: relative;
}

.nav-brand {
  font-weight: 700;
  color: var(--color-fg);
  text-decoration: none;
}

.nav-menu {
  list-style: none;
  display: flex;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
}

.nav-menu a { color: var(--color-fg); }
.nav-menu a[aria-current="page"] { color: var(--color-link); font-weight: 600; }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  width: 2.2rem;
  height: 2.2rem;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
}
.nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--color-fg);
}

/* ---------- Responsive nav ---------- */
@media (max-width: 640px) {
  .nav-toggle { display: flex; }

  .nav-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 1.25rem;
    gap: 0.75rem;
    display: none;
  }

  .nav-menu.is-open { display: flex; }
}

/* ---------- Main content ---------- */
main.container {
  padding-block: 2.5rem;
  min-height: 60vh;
}

h1, h2, h3 {
  font-family: var(--font-heading);
  line-height: 1.25;
}

h2 {
  color: var(--color-link);
  font-weight: 600;
}

a:focus-visible,
button:focus-visible,
.gallery-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ---------- Post list ---------- */
.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.post-list li {
  display: flex;
  gap: 0.75rem;
  padding-block: 0.5rem;
  border-bottom: 1px dashed var(--color-border);
  flex-wrap: wrap;
}
.post-list-date {
  color: var(--color-muted);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  white-space: nowrap;
}

/* ---------- Post page ---------- */
.post-header { margin-bottom: 1.5rem; }
.post-title { margin-bottom: 0.25rem; }
.post-meta {
  color: var(--color-muted);
  font-size: 0.9rem;
}
.tag {
  display: inline-block;
  background: var(--color-code-bg);
  color: var(--color-accent);
  border: 1px solid var(--color-border);
  border-radius: 0.3rem;
  padding: 0.05rem 0.4rem;
  font-size: 0.8rem;
}

pre, code {
  font-family: var(--font-mono);
  background: var(--color-code-bg);
  border-radius: 0.3rem;
}
code { padding: 0.1rem 0.35rem; }
pre { padding: 1rem; overflow-x: auto; }
pre code { padding: 0; background: none; }

blockquote {
  margin: 0;
  padding-left: 1rem;
  border-left: 3px solid var(--color-accent);
  color: var(--color-muted);
}

/* ---------- Photo gallery ---------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: 0.6rem;
  margin-block: 1.5rem;
}

.gallery-item {
  padding: 0;
  border: 1px solid var(--color-border);
  background: none;
  cursor: zoom-in;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 0.35rem;
  background: var(--color-bg-alt);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.15s ease;
}

.gallery-item:hover img,
.gallery-item:focus-visible img {
  transform: scale(1.04);
}

.lightbox {
  border: 1px solid var(--color-border);
  border-radius: 0.6rem;
  padding: 1rem;
  background: var(--color-bg-alt);
  color: var(--color-fg);
  width: min(96vw, 72rem);
  max-width: 96vw;
  max-height: 92vh;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
}

.lightbox::backdrop {
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(2px);
}

.lightbox-shell {
  display: grid;
  gap: 0.75rem;
}

.lightbox-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.lightbox-counter {
  color: var(--color-muted);
  font-size: 0.95rem;
}

.lightbox-viewport {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
}

.lightbox-main {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: clamp(16rem, 70vh, 38rem);
}

.lightbox-main img {
  display: block;
  max-width: 100%;
  max-height: clamp(16rem, 70vh, 38rem);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 0.3rem;
}

.lightbox-nav {
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-fg);
  width: 2.5rem;
  height: 2.5rem;
  cursor: pointer;
}

.lightbox-nav:hover,
.lightbox-nav:focus-visible {
  background: rgba(255, 255, 255, 0.16);
}

.lightbox-caption {
  text-align: center;
  color: var(--color-muted);
  margin: 0;
  min-height: 1.4rem;
}

.lightbox-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
}

.lightbox-thumb {
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  padding: 0;
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 0.3rem;
  overflow: hidden;
  cursor: pointer;
}

.lightbox-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lightbox-thumb.is-active {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 1px var(--color-accent);
}

.lightbox-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--color-fg);
  padding: 0;
}

@media (max-width: 640px) {
  .lightbox {
    padding: 0.75rem;
  }

  .lightbox-viewport {
    grid-template-columns: 1fr;
  }

  .lightbox-nav {
    display: none;
  }

  .lightbox-main {
    min-height: min(60vh, 24rem);
  }
}

/* ---------- Notebooks ---------- */
.notebook-frame {
  width: 100%;
  height: 80vh;
  border: 1px solid var(--color-border);
  border-radius: 0.4rem;
}

/* ---------- CV ---------- */
.cv-header { margin-bottom: 2rem; }
.cv-label {
  color: var(--color-link);
  font-family: var(--font-heading);
  margin-top: 0;
}
.cv-meta { margin-bottom: 0.25rem; }
.cv-links { margin-top: 0; }
.cv-pdf { margin-top: 1rem; }

.cv-section {
  margin-block: 2rem;
  padding-top: 1rem;
  border-top: 2px solid var(--color-link);
}
.cv-section h2 {
  font-size: 1.3rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-link);
  margin-bottom: 1.5rem;
  font-weight: 600;
}

.cv-item { margin-block: 1rem; }
.cv-item h3 {
  margin-bottom: 0.3rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-fg);
}
.cv-item .post-meta {
  margin-top: 0;
  margin-bottom: 0.5rem;
  color: var(--color-muted);
}

/* Divider between individual items (narrower than section divider) */
.cv-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  opacity: 0.95;
  margin: 1.25rem auto;
  width: 60%;
  max-width: 24rem;
}

/* Courses list in education & highlights in work experience */
.cv-courses,
.cv-highlights {
  margin-top: 0.5rem;
  margin-bottom: 0;
  padding-left: 1.2rem;
  color: var(--color-muted);
  font-size: 0.95rem;
}
.cv-courses li,
.cv-highlights li {
  margin-bottom: 0.2rem;
}

.cv-score { 
  font-style: italic; 
  color: var(--color-muted);
}

.cv-tags .tag { margin: 0.15rem 0.3rem 0.15rem 0; }

/* ---------- Publications ---------- */
.publications {
  list-style: none;
  padding: 0;
}

.publications li {
  margin-bottom: 1.2em;
  line-height: 1.5;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--color-border);
  margin-top: 3rem;
}
.footer-inner {
  padding-block: 1.5rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  color: var(--color-muted);
  font-size: 0.9rem;
}
.footer-links { display: flex; gap: 1rem; }
