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

/* Atkinson Hyperlegible, kept in fonts/ (Latin letters only; anything else falls back to sans-serif) */
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-hyperlegible-latin-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-hyperlegible-latin-700-italic.woff2") format("woff2");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

/* 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: "Atkinson Hyperlegible", sans-serif;
  background: var(--bg);
  color: var(--fg);
}

/* Photos on project pages never run wider than the page or taller than the screen,
   so a whole photo is always visible without scrolling (svh = the screen height
   with phone browser bars showing; older browsers use the vh line).
   contain + left keeps a too-tall photo's shape, shrunk against the left edge. */
img {
  max-width: 100%;
  height: auto;
  max-height: 100vh;
  max-height: 100svh;
  object-fit: contain;
  object-position: left;
}

/* Header: name and links on the left, dark mode switch on the right */
header {
  display: flex;
  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): a sliding switch,
   sun on the left, moon on the right */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--fg);
  cursor: pointer;
}
.theme-toggle svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}
.theme-toggle svg:last-child {
  fill: currentColor;
  stroke: none;
}
.theme-toggle .track {
  position: relative;
  width: 34px;
  height: 18px;
  border: 1px solid currentColor;
  border-radius: 9px;
  box-sizing: border-box;
}
.theme-toggle .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: currentColor;
  transition: transform .15s;
}
.theme-toggle[aria-checked="true"] .knob {
  transform: translateX(16px);
}
/* margin-left: auto pushes the switch to the far right of the header */
.theme-toggle {
  margin-left: auto;
  align-self: center;
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 3px;
}

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

/* Cards, the same everywhere (home page, Archive, class pages, Link Tree):
   a square picture, then the title, then the year.
   5 per row; extra cards wrap onto new rows automatically. */
.projects,
.featured {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 24px 16px;
}
.featured {
  margin-bottom: 64px;
}
.projects a,
.featured a {
  color: inherit;
  text-decoration: none;
}

/* Picture: a square (gray behind it while it loads) */
.projects img,
.featured img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: center;
  background: var(--placeholder);
  margin-bottom: 8px;
}

/* No picture yet: an empty gray square in its place */
.text-card::before {
  content: "";
  display: block;
  aspect-ratio: 1 / 1;
  background: var(--placeholder);
  margin-bottom: 8px;
}

/* Title, underlined on hover; year below it in gray */
.projects span,
.featured span {
  display: block;
  font-weight: bold;
  line-height: 1.3;
}
.projects a:hover span,
.projects a:focus-visible span,
.featured a:hover span,
.featured a:focus-visible span {
  text-decoration: underline;
}
.projects small,
.featured small {
  opacity: 0.6;
}

/* Link Tree: the site's logo small in the middle of the gray square.
   Logos are black SVGs, turned light in dark mode; the invert also flips the
   gray behind them, so #dfdfdf comes out as the dark-mode gray (#333). */
.logo-card img {
  object-fit: contain;
  padding: 30%;
  box-sizing: border-box;
}
[data-theme="dark"] .logo-card img {
  filter: invert(0.9);
  background: #dfdfdf;
}

/* Fewer columns on smaller screens */
@media (max-width: 991px) {
  .projects,
  .featured { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 767px) {
  .projects,
  .featured { 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; }
}

/* Log activity grid: a square per day, darker the more edits that day */
.activity {
  max-width: 50em;
  margin-bottom: 40px;
}
.activity-stats {
  display: flex;
  margin-bottom: 24px;
}
.activity-stats div {
  flex: 1;
  text-align: center;
}
.activity-stats div + div {
  border-left: 1px solid var(--placeholder);
}
.activity-stats b {
  display: block;
  font-size: 2em;
}
.activity-stats span,
.activity-months,
.activity-grid .weekday,
.activity-summary {
  opacity: 0.6;
}
.activity-grid,
.activity-months {
  display: grid;
  grid-template-columns: 1.5em repeat(var(--weeks), minmax(0, 1fr));
  gap: 3px;
}
.activity-grid > :not(.weekday) {
  aspect-ratio: 1;
  border-radius: 3px;
}
.activity-grid .weekday {
  grid-column: 1;
  font-size: 0.75em;
  align-self: center;
}
.activity-grid .l0 { background: var(--placeholder); opacity: 0.5; }
.activity-grid .l1 { background: color-mix(in srgb, var(--fg) 30%, var(--bg)); }
.activity-grid .l2 { background: color-mix(in srgb, var(--fg) 50%, var(--bg)); }
.activity-grid .l3 { background: color-mix(in srgb, var(--fg) 75%, var(--bg)); }
.activity-grid .l4 { background: var(--fg); }
.activity-grid a:hover,
.activity-grid a:focus-visible {
  outline: 2px solid var(--link);
}
.activity-months {
  margin-top: 6px;
  font-size: 0.8em;
}
.activity-months span {
  white-space: nowrap;
}

/* Archive view switcher (Chronological · School) */
/* Archive views: two tabs sitting on a line; the current one opens into the page */
.views {
  display: flex;
  gap: 4px;
  margin: -8px 0 32px;
  border-bottom: 1px solid var(--fg);
}
.views a {
  padding: 8px 16px;
  border: 1px solid var(--placeholder);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  color: inherit;
  text-decoration: none;
}
.views a:hover,
.views a:focus-visible {
  background: var(--placeholder);
}
.views a[aria-current="page"] {
  margin-bottom: -1px;
  border-color: var(--fg);
  background: var(--bg);
  font-weight: bold;
}

/* Code on homework pages: long lines scroll inside the box instead of widening the page */
pre {
  overflow-x: auto;
  tab-size: 4;
}
