/* Plain on purpose: browser defaults plus the few rules the gallery needs. */

/* Colors live here so dark mode (theme.js) can swap them */
:root {
  --bg: #fff;
  --fg: #000;
  --placeholder: #d9d9d9;
  --link: #0000ee;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #121212;
  --fg: #e6e6e6;
  --placeholder: #333;
  --link: #8ab4f8;
  color-scheme: dark;
}
/* Browser-default link blues are too dark on a dark page */
/* (:where keeps these weak, so rules like .text-card still win) */
:where([data-theme="dark"]) a { color: var(--link); }
:where([data-theme="dark"]) a:visited { color: #c58af9; }

body {
  margin: 0 auto;
  padding: 20px;
  max-width: 1200px;
  font-family: sans-serif;
  background: var(--bg);
  color: var(--fg);
}

/* Photos on project pages never run wider than the page */
img {
  max-width: 100%;
  height: auto;
}

/* Header: name on the left, links on the right */
header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding-bottom: 12px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--fg);
}

.site-name,
[data-theme="dark"] .site-name {
  font-size: 1.5em;
  font-weight: bold;
  color: inherit;
  text-decoration: none;
}

/* Dark mode toggle (added to the header by theme.js), styled like the other header links */
.theme-toggle {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--link);
  text-decoration: underline;
  cursor: pointer;
}

/* One block per year */
.year {
  margin-bottom: 48px;
}

/* 5 projects per row; extra projects wrap onto new rows automatically */
.projects {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

/* Thumbnail: a square image (gray behind it while it loads) */
.projects img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--placeholder);
}

/* Hover: dim the picture and show the title (the <span>) over it */
.projects a {
  position: relative;
  overflow: hidden;
}
.projects img {
  transition: filter 0.2s;
}
.projects a:hover img,
.projects a:focus-visible img {
  filter: blur(3px);
}
.projects a span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  font-size: 1.25em;
  font-weight: bold;
  line-height: 1.3;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  background: rgba(0, 0, 0, 0.78);
  opacity: 0;
  transition: opacity 0.2s;
}
.projects a:hover span,
.projects a:focus-visible span {
  opacity: 1;
}

/* Project without a picture yet: gray square with its name */
.projects .text-card {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  padding: 12px;
  box-sizing: border-box;
  background: var(--placeholder);
  color: var(--fg);
  text-align: center;
  text-decoration: none;
}

/* Fewer columns on smaller screens */
@media (max-width: 991px) {
  .projects { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 767px) {
  .projects { grid-template-columns: repeat(2, 1fr); }
}

/* Log: time in its own column, entries spaced apart, lines kept short enough to read */
.log {
  max-width: 50em;
  padding: 0;
  list-style: none;
}
.log li {
  display: grid;
  grid-template-columns: 7em 1fr;
  gap: 4px 16px;
  margin-bottom: 12px;
  line-height: 1.5;
}
.log time {
  opacity: 0.6;
  white-space: nowrap;
}
.log + h2 {
  margin-top: 32px;
}
@media (max-width: 767px) {
  .log li { grid-template-columns: 1fr; }
}
