@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Source+Serif+4:ital,wght@0,400;1,400&display=swap');
/* ...font-face rules remain unchanged... */

:root {
    --bg: #181818;
    --text: #e7e7e7;
    --muted: #cfcfcf;
    --shadow: rgba(0, 0, 0, 0.55);
    --glass: rgba(255, 255, 255, 0.08);
    --glass-strong: rgba(255, 255, 255, 0.14);
    --card-border: rgba(255, 255, 255, 0.25);
    --rule: rgba(255, 255, 255, 0.35);
    --container: 1100px;
}

html.light-mode {
  --bg: #f7f7f7;
  --text: #181818;
  --muted: #444;
  --shadow: rgba(0,0,0,0.08);
  --glass: rgba(0,0,0,0.04);
  --glass-strong: rgba(0,0,0,0.08);
  --card-border: rgba(0,0,0,0.10);
  --rule: rgba(0,0,0,0.10);
}


* { box-sizing: border-box; }
html { height: 100%; }
body { min-height: 100%; }
html {
	/* Use a single document scrollbar (avoid double-scrollbar look) */
	overflow-y: auto;
	background: var(--bg);
	color-scheme: dark;
}
html.light-mode {
	color-scheme: light;
}
body {
  margin: 0;
  font-family: 'Inter', system-ui, Segoe UI, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-y: visible;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.6;
}

/* Smooth theme transitions (avoid sudden flashes)
   Enabled only after JS marks the page as ready, so navigation doesn't animate. */
html.theme-ready body {
  transition: background-color 220ms ease, color 220ms ease;
}
html.theme-ready .site-header,
html.theme-ready .divider,
html.theme-ready .nav,
html.theme-ready .brand,
html.theme-ready .links a,
html.theme-ready .footer,
html.theme-ready .card,
html.theme-ready .card-media,
html.theme-ready .project-card,
html.theme-ready .project-card .img-overlay,
html.theme-ready .icon,
html.theme-ready .socials .icon img,
html.theme-ready .contact-container .icon img,
html.theme-ready .theme-toggle .theme-icon img {
  transition:
    background-color 220ms ease,
    color 220ms ease,
    border-color 220ms ease,
    opacity 220ms ease,
    filter 220ms ease;
}

@media (prefers-reduced-motion: reduce) {
  html.theme-ready body,
  html.theme-ready .site-header,
  html.theme-ready .divider,
  html.theme-ready .nav,
  html.theme-ready .brand,
  html.theme-ready .links a,
  html.theme-ready .footer,
  html.theme-ready .card,
  html.theme-ready .card-media,
  html.theme-ready .project-card,
  html.theme-ready .project-card .img-overlay,
  html.theme-ready .icon,
  html.theme-ready .socials .icon img,
  html.theme-ready .contact-container .icon img,
  html.theme-ready .theme-toggle .theme-icon img {
    transition: none !important;
  }
}

/* Some pages are short; keep a consistent scrollbar without reintroducing the home-page gutter issue */
html:has(body.contact-page) {
	overflow-y: scroll;
}

html:has(body.force-scroll) {
  overflow-y: scroll;
}

@supports not selector(html:has(body.contact-page)) {
  body.contact-page {
    min-height: 101vh;
  }
}

@supports not selector(html:has(body.force-scroll)) {
  body.force-scroll {
    min-height: 101vh;
  }
}

/* Headings: Inter, negative letter-spacing, neutral weight */
h1, h2, h3, h4, h5, h6, .project-title-centered {
  font-family: 'Inter', system-ui, Segoe UI, Helvetica, Arial, sans-serif;
  letter-spacing: -0.01em;
  font-weight: 500;
}

/* Editorial/long-form text: Source Serif 4 */
.editorial, .about-content, .long-desc, .project-desc.serif {
  font-family: 'Source Serif 4', Georgia, Times, 'Times New Roman', serif;
  font-size: 1.13em;
  line-height: 1.65;
  font-weight: 400;
}

/* Default project-desc remains sans-serif unless .serif is added */

.background {
    position: fixed;
    inset: 0;
    background: url('base2.png') center/cover no-repeat fixed;
    filter: grayscale(100%) contrast(1.05) brightness(0.85);
    z-index: -2;
}

.background::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(120% 60% at 50% 10%, rgba(255,255,255,0.35), rgba(255,255,255,0) 60%),
        radial-gradient(120% 80% at 50% 100%, rgba(0,0,0,0.75), rgba(0,0,0,0.1) 60%);
    pointer-events: none;
}

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 24px;
}

/* Header should span full viewport so brand and nav hug the edges */
.site-header .container {
  max-width: none;
  /* Keep a comfortable edge gutter even on ultrawide screens */
  padding-inline: clamp(16px, 3vw, 48px);
}

.site-header { position: sticky; top: 0; backdrop-filter: blur(4px); z-index: 10; }
.nav {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  padding: 22px 0 10px;
}
.brand {
  font-family: 'Inter', system-ui, Segoe UI, Helvetica, Arial, sans-serif;
  font-weight: 400;
  letter-spacing: 0.12em;
  font-size: 24px;
  text-transform: uppercase;
  color: var(--text);
  opacity: 0.92;
  text-decoration: none;
}
.links { display: flex; gap: 28px; margin: 0 0 0 auto; padding: 0; list-style: none; }
.links a { color: var(--text); text-decoration: none; font-size: 20px; opacity: 0.9; }

.clock {
  margin-left: 0;
  font-size: 20px;
  letter-spacing: 0.03em;
  opacity: 0.9;
  width: 7ch;
  text-align: right;
  display: inline-block;
}
.divider { height: 1px; background: var(--rule); opacity: 0.6; }

/* Featured showcase (home page) */
.featured-showcase {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}
.home-page .featured-showcase {
	/* Match page width without risking 100vw overflow */
	width: 100%;
	margin-left: 0;
}
.featured-showcase-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  /* Keep it big enough on short viewports but not overwhelming */
  min-height: 240px;
  max-height: 72vh;
  overflow: hidden;
	outline: none;
}
.featured-showcase-frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: none;
  border: 0;
	object-fit: cover;
	object-position: center;
	/* Keep it purely visual (no click-to-pause / no context menu interactions) */
	pointer-events: none;
}

.featured-showcase-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 18px 24px;
  background: rgba(0, 0, 0, 0);
  opacity: 0;
  transition: opacity 180ms ease, background-color 180ms ease;
  pointer-events: auto;
}

.featured-showcase-title {
  display: inline-block;
  color: #fff;
  font-family: 'Inter', system-ui, Segoe UI, Helvetica, Arial, sans-serif;
  font-size: clamp(18px, 2.3vw, 28px);
  letter-spacing: -0.01em;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  text-shadow: none;
  cursor: pointer;
}

.featured-showcase-title:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.75);
  outline-offset: 6px;
  border-radius: 6px;
}

.featured-showcase-frame:hover .featured-showcase-overlay,
.featured-showcase-frame:focus-within .featured-showcase-overlay {
  opacity: 1;
  background: rgba(0, 0, 0, 0.35);
}

@media (prefers-reduced-motion: reduce) {
  .featured-showcase-overlay {
    transition: none;
  }
}

.hero { text-align: center; padding: clamp(70px, 14vw, 140px) 0 250px; }
.hero h1 { font-size: clamp(42px, 8vw, 82px); line-height: 1.05; margin: 0; }

/* Home hero: keep heading perfectly centered horizontally */
body.home-page .hero.container {
  text-align: center;
  max-width: none;
}
body.home-page .hero.container h1 {
  width: 100%;
  display: flex;
  justify-content: center;
}
body.home-page .hero-glow {
  width: 100%;
  display: flex;
  justify-content: center;
}

.projects { text-align: center; position: relative; margin-top: clamp(200px, 40vw, 400px); }
.projects-page .projects { margin-top: clamp(40px, 10vw, 120px); }
.projects-page .projects.container { max-width: none; }
.projects-page .cards {
    display: block;
    overflow: visible;
    padding-bottom: 0;
    column-count: 5;
    column-gap: 18px;
    width: 100%;
    margin: 0 auto;
}
@media (min-width: 1800px) { .projects-page .cards { column-count: 7; column-gap: 22px; } }
@media (min-width: 1500px) and (max-width: 1799.98px) { .projects-page .cards { column-count: 6; column-gap: 20px; } }
@media (min-width: 1200px) and (max-width: 1499.98px) { .projects-page .cards { column-count: 5; } }
@media (min-width: 900px) and (max-width: 1199.98px) { .projects-page .cards { column-count: 4; column-gap: 18px; } }
@media (min-width: 600px) and (max-width: 899.98px) { .projects-page .cards { column-count: 3; column-gap: 16px; } }
@media (max-width: 599.98px) { .projects-page .cards { column-count: 2; column-gap: 14px; } }
.projects-page .projects.container { padding-inline: 24px; }
.projects-page .card {
    width: 100%;
    display: inline-block;
    margin: 0 0 18px;
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 16px;
    overflow: hidden;
}
.projects-page .card-media { aspect-ratio: 3 / 4; border-radius: 16px; overflow: hidden; }
.projects-page .card-media img { height: 100%; width: 100%; object-fit: cover; display: block; border-radius: 16px; transition: transform .2s ease, filter .2s ease; }
.projects-page .card.square .card-media { aspect-ratio: 1 / 1; }
.projects-page .cards .card:nth-child(3n) .card-media { aspect-ratio: 1 / 1; }
.projects-page .cards .card:nth-child(10n+5) .card-media { aspect-ratio: 2 / 3; }
.projects-page .cards .card:nth-child(8n+4) .card-media { aspect-ratio: 4 / 5; }
.projects-page .card-body { display: none; }

/* Social icons: white in dark mode, dark in light mode */
.socials .icon img {
  filter: invert(1) brightness(1.05);
}
html.light-mode .socials .icon img {
  filter: invert(1) brightness(0.5) contrast(1.2) !important;
}

/* Contact icons are separate from the socials section */
html.light-mode .contact-container .icon img {
  filter: invert(1) brightness(0.5) contrast(1.2) !important;
}
.projects h2 { font-size: clamp(28px, 5vw, 48px); margin: 0 0 22px; }
.cards {
  display: flex;
  flex-wrap: nowrap;
  gap: 32px;
  margin-top: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.cards::-webkit-scrollbar { display: none; }
.card {
  display: grid; grid-template-rows: auto 1fr;
  text-decoration: none; color: var(--text);
  width: clamp(180px, 22vw, 240px);
  flex: 0 0 auto;
  border-radius: 16px;
  background: var(--glass);
  border: 1px solid var(--card-border);
  box-shadow: none;
  overflow: hidden;
  text-align: center;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  margin-right: 8px;
}
.card-media { position: relative; overflow: hidden; aspect-ratio: 4 / 3; background: var(--glass); }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; filter: contrast(0.95) brightness(0.9); -webkit-user-drag: none; }
.card-body { padding: 10px 12px 14px; text-align: center; }
.card-title { margin: 0 0 6px; font-size: clamp(16px, 2.6vw, 22px); font-weight: 300; }
.card-desc { margin: 0; color: var(--muted); font-size: clamp(12px, 2.2vw, 14px); line-height: 1.35; }


.currently { text-align: center; margin-top: 48px; }
.currently .rule { height: 2px; background: var(--rule); opacity: 0.5; margin: 26px 0; width: 100%; border: none; }
.currently h3 { font-size: clamp(24px, 3.8vw, 40px); font-weight: 300; margin: 0 0 4px; }
.currently p { margin: 6px 0; font-size: clamp(18px, 2.7vw, 28px); color: var(--muted); }
.currently .school { font-size: clamp(20px, 3.2vw, 32px); color: var(--text); }

.socials { text-align: center; margin-top: 8px; }
.socials h3 { font-size: clamp(24px, 3.8vw, 40px); font-weight: 300; margin: 8px 0 18px; }
.icons { display: flex; justify-content: center; gap: 22px; }
.icon { color: var(--text); width: 52px; height: 52px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; background: transparent; border: none; box-shadow: none; backdrop-filter: none; }
/* Theme toggle button styles */
.theme-toggle {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1em;
  margin-left: 0.5em;
  cursor: pointer;
  padding: 0.08em 0.18em;
    border-radius: 0;
    transition: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    max-width: 32px;
    max-height: 32px;
}
.theme-toggle .theme-icon {
  width: 22px;
  height: 22px;
  display: block;
  background: none;
  padding: 0;
}
  .theme-toggle:focus {
    outline: none;
    background: none;
  }
  .theme-toggle:hover {
    background: none;
  }

.socials .rule { height: 2px; background: var(--rule); opacity: 0.5; margin: 26px 0; width: 100%; border: none; }

.footer { text-align: center; color: var(--muted); padding: 10px 0 30px; font-size: 16px; }

@media (max-width: 900px) {
    .links { gap: 18px; }
    .cards { gap: 22px; }
    .card img { height: 100%; }
	.container { padding-inline: 16px; }
}

/* Hide the theme toggle and clock on small screens to save header space (mobile) */
@media (max-width: 599.98px) {
  .theme-toggle, #clock { display: none !important; }
}

/* Mobile slide-in panel (re-usable for mobile menu) */
.mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 220ms ease, visibility 0s linear 220ms;
  z-index: 999;
}
.mobile-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 220ms ease, visibility 0s linear 0s;
}

.mobile-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(300px, 80vw);
  background: #fff;
  transform: translateX(100%);
  transition: transform 220ms ease;
  z-index: 1000;

  display: flex;
  flex-direction: column;
  padding: 20px 18px;

  box-shadow: none !important;
  filter: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  overflow: auto;
}
.mobile-panel.open { transform: translateX(0); }

.mobile-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
  padding-bottom: 14px;
}
.mobile-panel-title { font-size: 1.05rem; font-weight: 600; color: var(--text); }
.mobile-panel-close { background: transparent; border: 0; padding: 6px; margin: 0; cursor: pointer; color: var(--text); }
.mobile-panel-close:focus, .mobile-panel-close:active { outline: none !important; box-shadow: none !important; }
.mobile-panel-close-x { position: relative; width: 18px; height: 18px; display: inline-block; }
.mobile-panel-close-x::before, .mobile-panel-close-x::after { content: ""; position: absolute; inset: 50% 0 auto 0; height: 2px; background: currentColor; transform-origin: center; }
.mobile-panel-close-x::before { transform: translateY(-50%) rotate(45deg); }
.mobile-panel-close-x::after { transform: translateY(-50%) rotate(-45deg); }

/* Keep clock visible in the panel, but hide theme-toggle there */
.mobile-panel #clock { display: none !important; }
.mobile-panel .theme-toggle { display: none !important; }

html:not(.light-mode) .mobile-panel { background: #16181c; }

.mobile-panel-body .mobile-links {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 6px;
}
.mobile-panel-body .mobile-links a {
  display: block;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  padding: 8px 4px;
}
.mobile-panel-body .mobile-links a:active,
.mobile-panel-body .mobile-links a:focus,
.mobile-panel-body .mobile-links a:hover { opacity: 0.9; }

/* Show the mobile hamburger and hide desktop links on small screens */
@media (max-width: 599.98px) {
  /* Ensure the mobile menu button is visible even if inline style hides it */
  .mobile-menu-li { display: inline-block !important; }

  /* Hide other nav links to reduce clutter */
  .nav .links > li:not(.mobile-menu-li) { display: none !important; }

  /* Make the mobile menu button look like an icon-only control */
  .mobile-menu-btn {
    background: transparent;
    border: 0;
    padding: 6px;
    margin: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
  }

  /* Keep the brand visible and aligned left while clock is hidden */
  .brand { margin-right: 0; }
}


.home-page .hero {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 70vh;
}

/* Home page: bring “I make things...” closer to the hero heading */
.home-page .projects {
  margin-top: clamp(28px, 6vw, 72px);
}



.about-page .background,
.projects-page .background {
  display: none;
}

.projects-page {
  background: var(--bg);
}
.masonry-board {
  background: var(--bg);
}

.nav .links a {
  position: relative;
  overflow: hidden;
  transition: color 0.18s;
}
.nav .links a::after {
  content: '';
  position: absolute;
  right: 0;
  left: 0;
  bottom: 0;
  height: 2px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.22s cubic-bezier(.4,0,.2,1);
}
.nav .links a:hover::after,
.nav .links a:focus-visible::after {
  transform: scaleX(1);
  left: 0;
  right: 0;
  transform-origin: left;
}

.cards-track {
  overflow: visible;
  gap: 1.5em;
}
.cards-track .card {
  position: relative;
  transition: box-shadow 0.22s cubic-bezier(.4,0,.2,1), border-color 0.22s cubic-bezier(.4,0,.2,1);
  z-index: 1;
  border: none;
  box-shadow: none;
  outline: none;
  border-radius: 0;
  margin-right: 0;
}

.project-card {
  background: var(--glass);
  border: 1px solid var(--card-border);
  color: var(--text);
  box-shadow: none;
  outline: none;
}

.project-card .img-overlay {
  background: linear-gradient(to bottom, var(--shadow, rgba(0,0,0,0.08)) 0%, var(--glass-strong, rgba(0,0,0,0.08)) 60%, var(--glass, rgba(0,0,0,0.04)) 100%);
}

.cards-track .card-media img {
  filter: none;
  transition: filter 0.22s cubic-bezier(.4,0,.2,1);
}

.cards[data-source="projects"] {
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  transform: none;
  box-sizing: border-box;
  padding-left: 24px;
  padding-right: 24px;
  border-radius: 0;
  grid-template-columns: none;
  gap: 0;
  background: none;
  box-shadow: none;
  overflow-x: visible;
}

@media (max-width: 900px) {
  .cards[data-source="projects"] {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* Home page infinite projects scroller: no card background fill */
.cards[data-source="projects"] .card {
	background: transparent;
	border: none;
}
.cards[data-source="projects"] .card-media {
	background: transparent;
}

/* Home page infinite projects scroller: make thumbnails bigger */
body.home-page .cards[data-source="projects"] .card {
  width: clamp(240px, 28vw, 340px);
}
body.home-page .cards-track {
  gap: 2.1em;
}

.projects[data-source="projects"], section.projects[data-source="projects"] {
  padding-left: 0;
  padding-right: 0;
}

body, html {
  overflow-x: hidden;
}

.cards[data-source="projects"] {
  overflow-x: hidden;
}

.projects-page .project-card:focus-visible,
.projects-page .project-card {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border: none;
  outline: none;
}
.projects-page .project-card::after {
  display: none;
  content: none;
  box-shadow: none;
  border: none;
}

.project-card.wide .img-wrap {
  aspect-ratio: 3/2;
}
.project-card.tall .img-wrap {
  aspect-ratio: 2/3;
}
.project-card.default .img-wrap,
.project-card:not(.square):not(.tall):not(.wide):not(.default) .img-wrap {
  aspect-ratio: 16/10;
}

.projects-grid .project-card .img-wrap {
  height: auto;
  min-height: 0;
  max-height: none;
}

.project-card.square .img-wrap {
  aspect-ratio: 1/1;
}
.project-card.tall .img-wrap {
  aspect-ratio: 2/3;
}
.project-card.wide .img-wrap {
  aspect-ratio: 3/2;
}
.project-card.default .img-wrap,
.project-card:not(.square):not(.tall):not(.wide):not(.default) .img-wrap {
  aspect-ratio: 16/10;
}

@media (max-width: 600px) {
  .clock {
    display: none !important;
  }
}

/* Posters viewer (100 Days 100 Posters, reusable) */

/* A4 “slot” so posters scale consistently without cropping */
.posters-stack .poster-row,
.posters-grid .poster-tile {
  aspect-ratio: 210 / 297; /* A4 portrait */
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden; /* safe: image is contain so no crop */
}

/* Stack: keep it readable by not stretching beyond a sensible width */
.posters-stack .poster-row {
  max-width: 980px;
  margin-inline: auto;
}

/* Never crop posters */
.posters-stack .poster-row img,
.posters-grid .poster-tile img {
  width: 100%;
  height: 100%;
  object-fit: contain;      /* key: no cropping */
  background: transparent;
  /* override any inline aspectRatio set by JS previously */
  aspect-ratio: auto !important;
}

.posters-stack {
  display: grid;
  gap: 18px;
  margin-top: 6px;
}
.posters-stack .poster-row {
  border-radius: 0;         /* was 12px */
  border: none;             /* remove bevel/card border */
  background: transparent;  /* remove card fill */
  overflow: visible;        /* no rounded clipping needed */
}
.posters-stack .poster-row img {
  width: 100%;
  height: auto;
  display: block;
}

.posters-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  margin-top: 6px;
}
@media (min-width: 900px) {
  .posters-grid {
    gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  }
}
.posters-grid .poster-tile {
  border-radius: 0;         /* was 12px */
  border: none;             /* remove bevel/card border */
  background: transparent;  /* remove card fill */
  overflow: visible;        /* no rounded clipping needed */
  cursor: pointer;
  outline: none;
  transition: transform 160ms ease, border-color 160ms ease;
}
.posters-grid .poster-tile:hover {
  transform: translateY(-2px);
  border-color: transparent; /* override earlier hover border-color */
}
.posters-grid .poster-tile:focus-visible {
  outline: 2px solid color-mix(in oklab, var(--text) 30%, transparent);
  outline-offset: 2px;
}
.posters-grid .poster-tile img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain; /* was cover */
}

/* Lightbox */
body.lightbox-open { overflow: hidden !important; }

.lightbox {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(0, 0, 0, 0.78);
  z-index: 2000;
  padding: 18px;
}
html.light-mode .lightbox { background: rgba(0, 0, 0, 0.68); }

.lightbox.open { display: grid; }

.lightbox-figure {
  margin: 0;
  /* Use container-relative sizing so padding is respected on ultra-small screens */
  width: 100%;
  max-width: 1100px;
  max-height: 86vh;
  display: grid;
  gap: 10px;
  align-items: center;
  justify-items: center;
}
.lightbox-figure img {
  max-width: 100%;
  max-height: 78vh;
  width: auto;
  height: auto;
  display: block;
  border-radius: 0; /* was 12px */
  border: none;     /* remove frame */
  background: transparent;
}

.lightbox-caption {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  text-align: center;
}
html.light-mode .lightbox-caption { color: rgba(255, 255, 255, 0.88); }

.lightbox-close {
  position: fixed;
  top: 14px;
  right: 14px;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(0,0,0,0.25);
  color: #fff;
  font: inherit;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.lightbox-close:focus-visible {
  outline: 2px solid rgba(255,255,255,0.55);
  outline-offset: 2px;
}
.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 64px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(0,0,0,0.25);
  color: #fff;
  font: inherit;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  z-index: 2; /* keep arrows above the image when they don't overlap */
}

/* When the poster gets too wide and the nav would overlap it, hide the nav entirely. */
.lightbox-nav.is-clipping {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.lightbox-prev { left: 14px; }
.lightbox-next { right: 14px; }

@media (max-width: 520px) {
  .lightbox-nav { width: 40px; height: 56px; font-size: 30px; }
  .lightbox-prev { left: 10px; }
  .lightbox-next { right: 10px; }
  .lightbox-close { top: 10px; right: 10px; }
}

/* Posters: status + missing-state (prevents "flash then disappear") */
/* .posters-status { ... } */

/* Allow overlay UI */
.posters-stack .poster-row,
.posters-grid .poster-tile {
  position: relative;
}

/* Missing overlay */
.poster-missing {
  opacity: 0.85;
}
.poster-missing::after {
  content: attr(data-missing);
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  text-align: center;
  color: var(--text);
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(2px);
}

/* Lightbox: focus styles for arrows too */
.lightbox-nav:focus-visible {
  outline: 2px solid rgba(255,255,255,0.55);
  outline-offset: 2px;
}

/* Ensure [hidden] always hides even if other layout styles apply */
[hidden] { display: none !important; }

/* Posters: ensure gallery does NOT re-enable cropping (you still have a later cover override) */
.posters-grid .poster-tile img {
  object-fit: contain; /* was cover */
}

/* Lightbox view (page mode) */
.posters-lightbox {
  margin-top: 10px;
  display: flex;              /* was grid */
  flex-direction: column;
  gap: 14px;

  /* Key: keep the whole lightbox-view block within the viewport */
  height: min(82svh, 900px);
  overflow: hidden;
}

.lb-view-figure {
  margin: 0 auto;
  width: min(720px, 92vw);

  position: relative;

  /* Key: let figure consume remaining height above thumbs */
  flex: 1 1 auto;
  min-height: 0;

  /* Ensure image row can shrink */
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto; /* was 1fr auto */
  gap: 10px;

  /* Remove the fixed A4 container height so it can't exceed viewport */
  aspect-ratio: auto; /* was 210 / 297 */
}

.lb-view-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 52px;
  border-radius: 14px;
  border: none;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  display: grid;
  place-items: center;
  padding: 0;

  /* Contrast against varying backgrounds (poster + page) */
  mix-blend-mode: difference;
  filter: drop-shadow(0 2px 12px rgba(0,0,0,0.55)) drop-shadow(0 1px 2px rgba(0,0,0,0.65));
}

.lb-view-prev { left: 10px; }
.lb-view-next { right: 10px; }

.lb-view-nav:hover {
  opacity: 0.78;
}

.lb-view-nav:focus-visible {
  outline: none;
  box-shadow: none;
  opacity: 0.7;
}

.lb-view-nav:focus {
  outline: none;
  box-shadow: none;
}

@media (max-width: 520px) {
  .lb-view-nav { width: 32px; height: 48px; font-size: 28px; }
  .lb-view-prev { left: 8px; }
  .lb-view-next { right: 8px; }
}

.lb-view-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.lb-view-thumbs {
  width: min(980px, 92vw);
  margin: 0 auto;

  /* Key: fixed strip height so it never pushes poster off-screen */
  height: 140px;
  flex: 0 0 auto;

  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(84px, 110px);
  gap: 10px;

  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 2px 10px;
  -webkit-overflow-scrolling: touch;
}

.lb-thumb {
  height: 100%;              /* make each thumb fill the strip height */
  aspect-ratio: 210 / 297;   /* keep A4 ratio */
  display: grid;
  place-items: center;
  border: none;           /* remove stroke */
  outline: none;
  background: transparent;
  overflow: hidden;       /* ensure img stays inside the thumb frame */
}

.lb-thumb.active {
  border-color: transparent;   /* ensure no border ever appears */
  opacity: 0.78;               /* simple active affordance without stroke */
}

.lb-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;     /* fit to frame without cropping */
  display: block;
}

.lb-view-caption {
  width: 100%;
  text-align: center;   /* center "Poster No92 / 100" */
  justify-self: center;
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;            /* avoid default figcaption margins */
}

@media (max-width: 520px) {
  .posters-lightbox { height: min(78svh, 820px); }
  .lb-view-thumbs { height: 110px; }
  .lb-view-thumbs { grid-auto-columns: minmax(70px, 92px); }
}

/* Projects page: "Sort by" select arrow fitting */
.projects-page .sort-by select,
.projects-page select#sort-by,
.projects-page .sort-select {
  /* Don't force menulist; let the browser render the native control/arrow correctly */
  -webkit-appearance: initial;
  -moz-appearance: initial;
  appearance: auto;

  /* keep the minimal look you liked */
  background: transparent;
  border: 0;

  /* ensure the arrow has space without affecting its scale */
  padding-right: 1.6em;
}