/* Shared styles for every page */

/* Charis SIL is built from Bitstream Charter, the resume's font; real Charter is used where installed */
@import url("https://fonts.googleapis.com/css2?family=Charis+SIL:ital,wght@0,400;0,700;1,400&display=swap");

:root {
  --bg: white;
  --surface: #ececec;     /* Light grey panels, like the intro */
  --text: black;
  --text-muted: #333;
  --text-faint: #666;
  --divider: #1b1b1d;     /* Lines between projects */
  --divider-width: 4px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  /* Stop phone browsers from enlarging text differently on text-heavy pages */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: Charter, "Bitstream Charter", "Charis SIL", Georgia, serif;
  color: var(--text);
  background: var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

/* Header: name on the left, links on the right */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 2000px;
  height: 100px;
  margin: 0 auto;
  padding: 0 50px;
}

.site-name,
.site-links a {
  font-size: 1.4rem;
}

.site-links a {
  margin-left: 1.5rem;
}

.site-links a:hover {
  text-decoration: underline;
}

.site-footer {
  max-width: 2000px;
  margin: 0 auto 30px;
  padding: 0 50px;
  text-align: right;
  font-size: 0.9rem;
}

/* ---------- Home page grid ---------- */

.projects {
  container-type: inline-size; /* Tiles size themselves with cqw units */
  max-width: 2000px;
  margin: 0 auto 50px;
  padding: 0 50px;
}

/* Justified rows: each tile grows in proportion to its image's ratio (--r),
   so every tile in a row is the same height and the row fills the full
   width. Both edges line up and nothing is cropped. The thin gaps show the
   grid's dark background, drawing a line between projects. */
.grid,
.row {
  display: flex;
  gap: var(--divider-width);
  background: var(--divider);
}

.grid {
  flex-direction: column;
  border: var(--divider-width) solid var(--divider); /* Same line around the outside */
}

.tile {
  flex: var(--r, 1) 1 0;
  min-width: 0;
  aspect-ratio: var(--r, 1);
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* Never crop */
  display: block;
}

/* Intro: square photo on the left, text on the right */
.intro-tile {
  display: flex;
  background: var(--surface);
}

.tile .intro-photo {
  width: auto;
  aspect-ratio: 1;
  object-fit: cover;
}

.intro-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.4cqw;
  padding: 2cqw 2.2cqw;
  font-size: clamp(0.8rem, 1.3cqw, 1.5rem);
  line-height: 1.55;
}

.intro-text h1 {
  font-size: 1.5em;
  font-weight: normal;
  line-height: 1.2;
}

/* Hover caption: title above the line, description below */
.caption {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 10%;
  text-align: center;
  background: rgba(255, 255, 255, 0.85);
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.caption h3 {
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.5);
  font-variant: small-caps;
  font-weight: normal;
  letter-spacing: 2px;
  font-size: clamp(1.1rem, 1.6cqw, 1.8rem);
}

.caption p {
  padding-top: 0.5rem;
  font-style: italic;
  font-size: clamp(0.9rem, 1.1cqw, 1.2rem);
}

.caption h3,
.caption p {
  transform: translateY(2rem);
  transition: transform 0.4s cubic-bezier(0, 0, 0, 1);
}

.tile:hover .caption {
  opacity: 1;
}

.tile:hover .caption h3,
.tile:hover .caption p {
  transform: none;
}

/* Small screens: one column, each tile at its own ratio, caption under the image */
@media (max-width: 900px) {
  .site-header,
  .site-footer,
  .projects {
    padding: 0 16px;
  }

  .grid,
  .row {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    background: none; /* Stacked projects are separated by space instead */
    border: none;
  }

  .tile {
    flex: none;
    aspect-ratio: auto;
  }

  .tile img {
    height: auto;
    aspect-ratio: var(--r, 1);
  }

  .tile .intro-photo {
    width: 40%;
  }

  .intro-text {
    gap: 0.5rem;
    padding: 1rem;
    font-size: 1rem;
  }

  .caption {
    position: static;
    opacity: 1;
    padding: 0.75rem 0 0;
    background: none;
  }

  .caption h3,
  .caption p {
    transform: none;
  }
}

/* ---------- Project pages ---------- */

.project {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px 50px;
}

.project h1 {
  font-size: 2.5rem;
  font-weight: normal;
  margin: 1rem;
}

.project h2 {
  font-size: 1.1rem;
  font-weight: normal;
  font-style: italic;
  color: var(--text-faint);
  text-align: center;
}

.project img {
  max-width: 100%;
  max-height: 450px;
  margin: 1rem 0;
}

.project p {
  text-align: center;
  font-size: 1rem;
  line-height: 1.8;
  max-width: 800px;
  margin: 1rem auto;
  color: var(--text-muted);
}

.project ul {
  line-height: 1.8;
  color: var(--text-muted);
}
