/* ==========================================================================
   Design tokens
   ========================================================================== */

:root {
  --color-bg: #121212;
  --color-surface: #1f1f1f;
  --color-surface-raised: #1a1a1a;
  --color-text: #fff;
  --color-text-muted: #aaa;
  --color-nav: #f0f0f0;
  --color-nav-hover: #ababab;
  --color-link: #8ab4f8;
  --color-focus: #8ab4f8;
  --color-scrim: rgb(0 0 0 / 0.45);
  --color-scrim-strong: rgb(0 0 0 / 0.95);

  --font-body: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --container-width: 1200px;
  --gutter: clamp(1rem, 4vw, 2rem);
  --radius-sm: 6px;
  --radius-md: 8px;

  color-scheme: dark;
}

/* ==========================================================================
   Base
   ========================================================================== */

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

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

/* Lock page scroll while a dialog is open. */
html:has(dialog[open]) {
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  line-height: 1.5;
}

h1,
h2,
h3 {
  line-height: 1.2;
}

h1 {
  font-size: clamp(1.75rem, 5vw, 2rem);
}

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

a {
  color: var(--color-link);
}

:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 3px;
}

/* Reset for buttons that should look like plain text or glyphs. */
.icon-button {
  padding: 0.25rem 0.5rem;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  line-height: 1;
  cursor: pointer;
}

/* ==========================================================================
   Layout
   ========================================================================== */

.container {
  flex: 1;
  width: 100%;
  max-width: var(--container-width);
  margin-inline: auto;
  padding: 2rem var(--gutter);
}

.section {
  margin-top: 4rem;
}

.section__title {
  margin: 0 0 1.5rem;
  font-size: clamp(1.5rem, 5vw, 2rem);
  text-align: center;
}

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  padding: 1rem var(--gutter);
  background: var(--color-surface);
}

.site-header__name {
  margin: 0;
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 700;
  line-height: 1.2;
}

.site-header__subtitle {
  margin: 0.25rem 0 0;
  color: var(--color-text-muted);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0 -0.5rem; /* Lines link text up with the header edge when the nav wraps. */
  padding: 0;
  list-style: none;
}

.site-nav a {
  display: block;
  padding: 0.25rem 0.5rem;
  border-radius: 5px;
  color: var(--color-nav);
  font-size: clamp(1rem, 3.5vw, 1.2rem);
  text-decoration: none;
  transition: color 0.2s ease;
}

.site-nav a:hover {
  color: var(--color-nav-hover);
}

/* ==========================================================================
   Intro
   ========================================================================== */

.intro {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2rem;
}

.intro__photo {
  flex-shrink: 0;
  width: 200px;
}

.intro__text {
  flex: 1 1 250px;
}

/* ==========================================================================
   Project cards
   Mobile/touch first: the title and contributions sit below the banner.
   On wide screens with a mouse, they become a hover overlay instead.
   ========================================================================== */

.project-list {
  display: grid;
  gap: 2rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.project-card {
  position: relative;
}

/* Each banner image (1688×452) holds two stacked 226px frames; this window shows
   one at a time. It is one row short of a frame to hide the seam between them. */
.project-card__media {
  aspect-ratio: 1688 / 225;
  overflow: hidden;
}

.project-card__media img {
  width: 100%;
  transition: transform 0.6s ease;
}

.project-card__caption {
  padding-top: 0.75rem;
  text-align: center;
}

.project-card__title {
  margin: 0;
  font-size: 1.17rem;
}

.project-card__caption p {
  margin: 0.25rem 0 0;
  color: var(--color-text-muted);
}

.project-card__button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: inherit;
  cursor: pointer;
}

/* Stretch the button's hit area over the whole card. */
.project-card__button::after {
  content: "";
  position: absolute;
  inset: 0;
}

.project-card__button:focus-visible {
  outline: none;
}

.project-card__button:focus-visible::after {
  outline: 2px solid var(--color-focus);
  outline-offset: 4px;
}

@media (hover: hover) and (min-width: 50em) {
  .project-card__caption {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background-color: var(--color-scrim);
    opacity: 0;
    transition: opacity 0.4s ease;
  }

  .project-card__caption p {
    color: var(--color-text);
  }

  .project-card:hover .project-card__caption,
  .project-card:focus-within .project-card__caption {
    opacity: 1;
  }

  /* Slide to the second frame of the banner. */
  .project-card:hover .project-card__media img,
  .project-card:focus-within .project-card__media img {
    transform: translateY(-50%);
  }
}

/* ==========================================================================
   Project dialog
   ========================================================================== */

.dialog {
  width: min(800px, 100% - 2rem);
  max-width: none;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  padding: 0; /* Padding lives on .dialog__body so clicks on the dialog itself mean "backdrop". */
  border: 0;
  border-radius: var(--radius-md);
  background: var(--color-surface-raised);
  color: var(--color-text);
}

.dialog[open] {
  display: flex;
  flex-direction: column;
}

.dialog::backdrop {
  background-color: var(--color-scrim);
}

.dialog__body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(1.25rem, 4vw, 2rem);
  text-align: center;
}

.dialog__body h2 {
  margin: 0 2rem 1rem; /* Keeps long titles clear of the close button. */
}

.dialog__close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  z-index: 1;
  border-radius: 50%;
  background: var(--color-surface-raised);
  color: #ccc;
  font-size: 2rem;
}

.dialog__close:hover {
  color: var(--color-text);
}

/* ==========================================================================
   Gallery thumbnails
   ========================================================================== */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(120px, 100%), 1fr));
  gap: 1rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.gallery a {
  display: block;
  border-radius: var(--radius-sm);
}

.gallery img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   Lightbox
   ========================================================================== */

.lightbox {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--color-scrim-strong);
  color: var(--color-text);
}

.lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox::backdrop {
  background: transparent;
}

.lightbox__image {
  max-width: 90vw;
  max-height: 80vh;
  max-height: 80dvh;
  border-radius: var(--radius-md);
  touch-action: pan-y pinch-zoom;
}

.lightbox__close,
.lightbox__nav {
  position: absolute;
  z-index: 1;
  font-size: clamp(2rem, 8vw, 3rem);
  text-shadow: 0 0 8px rgb(0 0 0 / 0.8);
  user-select: none;
}

.lightbox__close {
  top: 1rem;
  right: 1rem;
}

.lightbox__nav {
  top: 50%;
  padding: 1rem;
  transform: translateY(-50%);
}

.lightbox__nav--prev {
  left: 0;
}

.lightbox__nav--next {
  right: 0;
}

/* ==========================================================================
   Contact
   ========================================================================== */

.contact {
  margin-bottom: 2rem;
  text-align: center;
}

.contact__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.contact__links a {
  display: block;
}

.contact__links img {
  width: 50px;
  height: 50px;
  transition: transform 0.2s ease;
}

@media (hover: hover) {
  .contact__links a:hover img {
    transform: scale(1.15);
  }
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  padding: 1rem;
  background-color: var(--color-surface);
  text-align: center;
}

/* ==========================================================================
   Motion preferences
   ========================================================================== */

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
