/* alexhornstein.com: a project log.
   Each category owns a color ("lane"); it shows up as the tile bar on the
   home board, the vertical lanes on the log, and the chips on entries. */

:root {
  --paper: #edf0ee;
  --surface: #f8f9f7;
  --ink: #1a2529;
  --muted: #586669;
  --rule: #cdd5d2;
  --link: #24489f;
  --focus: #24489f;

  --sans: "Schibsted Grotesk", system-ui, sans-serif;
  --serif: "Newsreader", Georgia, serif;
  --gutter: clamp(16px, 3vw, 40px);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131a1c;
    --surface: #1b2427;
    --ink: #dce4e1;
    --muted: #93a3a3;
    --rule: #2e3b3e;
    --link: #8fb0f5;
    --focus: #8fb0f5;
    color-scheme: dark;
  }
}

/* Lane colors */
.c-cobalt  { --c: #2b54c8; }
.c-kelp    { --c: #2d7d4f; }
.c-amber   { --c: #a96f00; }
.c-magenta { --c: #b3326f; }
.c-teal    { --c: #12807f; }
.c-rust    { --c: #b9501b; }
.c-violet  { --c: #6544be; }
.c-slate   { --c: #4c5d66; }

@media (prefers-color-scheme: dark) {
  .c-cobalt  { --c: #7d9bf0; }
  .c-kelp    { --c: #6cc08e; }
  .c-amber   { --c: #e5b341; }
  .c-magenta { --c: #ec7fb0; }
  .c-teal    { --c: #5cc6c3; }
  .c-rust    { --c: #ee8c5a; }
  .c-violet  { --c: #a992f0; }
  .c-slate   { --c: #a2b3bc; }
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.5 var(--sans);
  font-feature-settings: "tnum" 0;
}
a { color: var(--link); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
img { max-width: 100%; height: auto; }
time { font-variant-numeric: tabular-nums; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: var(--gutter); top: 8px; background: var(--surface); padding: 6px 10px; z-index: 10; }

/* Masthead */
.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem 2rem;
  flex-wrap: wrap;
  padding: clamp(14px, 2.5vh, 28px) var(--gutter);
}
.wordmark {
  margin: 0;
  font: 800 1.25rem/1.1 var(--sans);
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
}
.tagline { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.95rem; }
.masthead nav { display: flex; gap: 1.25rem; font-weight: 500; }
.masthead nav a { color: var(--ink); text-decoration: none; }
.masthead nav a:hover { color: var(--link); text-decoration: underline; }

/* ---------- Home: the board fits exactly one screen ---------- */

body.home {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
body.home .wordmark { font-size: clamp(1.6rem, 3.2vw, 2.6rem); }
body.home main { min-height: 0; padding: 0 var(--gutter) var(--gutter); }

.board {
  list-style: none;
  margin: 0;
  padding: 0;
  height: 100%;
  display: grid;
  gap: clamp(8px, 1.2vw, 16px);
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
}

.tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
  border-left: 6px solid var(--c);
  border-radius: 0 6px 6px 0;
  transition: background-color 0.15s;
}
.tile:hover, .tile:focus-within { background: color-mix(in srgb, var(--c) 7%, var(--surface)); }

.tile-inner {
  container-type: size;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: clamp(12px, 2vh, 24px) clamp(14px, 1.6vw, 24px) 0;
  overflow: hidden;
}

.tile h2 {
  margin: 0;
  font: 800 clamp(1.25rem, 10cqi, 3.25rem)/1 var(--sans);
  letter-spacing: -0.03em;
}
/* The whole tile is the category link; entry links sit above it. */
.tile-link { color: var(--ink); text-decoration: none; }
.tile-link::after { content: ""; position: absolute; inset: 0; }
.tile-link:focus-visible { outline: none; }
.tile:has(.tile-link:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }

.tile-meta { margin: 0.45rem 0 0; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.tile-meta:empty { display: none; }

.tile-recent, .tile-desc {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  margin: 0.9rem 0 0;
}
/* Whatever doesn't fit fades out instead of being cut mid-line. */
.tile-recent, .tile-desc {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 2.5rem), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 2.5rem), transparent);
}
.tile-recent { list-style: none; padding: 0; }
.tile-recent li {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.35rem 0;
  border-top: 1px solid var(--rule);
  font: 400 clamp(0.95rem, 3.6cqi, 1.15rem)/1.3 var(--serif);
}
.tile-recent a {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile-recent time { margin-left: auto; flex: none; color: var(--muted); font: 400 0.8rem/1 var(--sans); }
@container (max-width: 18rem) {
  .tile-recent time { display: none; }
}
.tile-recent a { position: relative; z-index: 1; color: var(--ink); text-decoration: none; }
.tile-recent a:hover { color: var(--link); text-decoration: underline; }
.tile-desc { font: 400 clamp(0.95rem, 3.6cqi, 1.15rem)/1.45 var(--serif); color: var(--ink); }
.tile-desc p { margin: 0 0 0.5em; }
.tile-desc a { position: relative; z-index: 1; }

/* Past year of activity: one tick per entry, today at the right edge. */
.ticks {
  position: relative;
  flex: none;
  height: 16px;
  margin: auto calc(-1 * clamp(14px, 1.6vw, 24px)) 0;
  border-top: 1px solid var(--rule);
}
.ticks span {
  position: absolute;
  bottom: 0;
  width: 2px;
  height: 11px;
  margin-left: -1px;
  background: var(--c);
}

/* Hover images (Images/<Category>/). Photos fill the tile; logos sit whole on a
   backdrop chosen to suit them. hover.js sets the fit, backdrop and tone. */
.tile-photo {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.tile-photo .page { position: absolute; inset: 0; }
.tile-photo img { display: block; width: 100%; height: 100%; }
/* Logos keep clear of the name at the top. */
.tile-photo .page[data-fit="contain"] img { padding: clamp(3.5rem, 30%, 7rem) 12% 10%; }
/* Over photos, darken the top so the name stays readable. */
.tile.photo-cover .tile-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(to bottom, rgb(0 0 0 / 0.6), rgb(0 0 0 / 0) 45%);
}
.tile.has-photos .tile-inner { position: relative; z-index: 3; } /* name stays above the turning page */
.tile.show-photo .tile-photo { opacity: 1; }
.tile.show-photo .tile-link { color: #fff; }
.tile.show-photo.photo-light .tile-link { color: #1a2529; }
.tile.show-photo .tile-meta,
.tile.show-photo .tile-desc,
.tile.show-photo .tile-recent,
.tile.show-photo .ticks { opacity: 0; }
.tile-meta, .tile-desc, .tile-recent, .ticks { transition: opacity 0.3s ease; }

/* Page turn (Teaching): the top page swings away around its left edge, like a
   book page, revealing the next logo underneath. */
.tile-photo.effect-page-turn { opacity: 1; visibility: hidden; perspective: 1600px; transition: none; }
.tile.show-photo .tile-photo.effect-page-turn { visibility: visible; }
.effect-page-turn .page.top {
  z-index: 1;
  transform-origin: left center;
  backface-visibility: hidden;
  box-shadow: 0 0 0 rgb(0 0 0 / 0);
}
/* Shadow that deepens as the page lifts. */
.effect-page-turn .page.top::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to left, rgb(0 0 0 / 0.35), rgb(0 0 0 / 0) 60%);
  opacity: 0;
}
.effect-page-turn .page.top.turned {
  transform: rotateY(-178deg);
  box-shadow: -18px 0 30px rgb(0 0 0 / 0.25);
  transition: transform 0.75s cubic-bezier(0.45, 0.05, 0.3, 1), box-shadow 0.75s ease;
}
.effect-page-turn .page.top.turned::after { opacity: 1; transition: opacity 0.4s ease; }

/* Photography tile: gallery thumbnails stacked as bricks. Without JS (or with
   reduced motion) they sit in a plain stack; bricks.js positions them absolutely
   and runs the physics once it adds .is-live. */
.bricks {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap-reverse;
  justify-content: center;
  border-radius: inherit;
  pointer-events: none;
}
.brick {
  display: block;
  width: 25%;
  aspect-ratio: 320 / 250;
  border: 2px solid var(--surface);
  border-radius: 4px;
  overflow: hidden;
  background: var(--rule);
  pointer-events: auto;
}
.brick img { display: block; width: 100%; height: 100%; object-fit: cover; -webkit-user-drag: none; user-select: none; }
.brick:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }
.bricks.is-live { top: 0; display: block; overflow: hidden; }
.bricks.is-live .brick { position: absolute; left: 0; top: 0; width: auto; aspect-ratio: auto; will-change: transform; }
.tile.has-bricks { touch-action: none; }
.tile.has-bricks .ticks { visibility: hidden; }

/* Flying emojis (the "Flying emojis" field on a category). swarm.js moves them;
   they pass under the tile's name and never catch clicks. */
.swarm {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
}
.bug {
  position: absolute;
  left: 0;
  top: 0;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-size: 1.5rem;
  line-height: 1;
  user-select: none;
  will-change: transform;
}
.tile.has-swarm .tile-inner { position: relative; z-index: 2; }
@media (max-width: 640px) { .bug { font-size: 1.15rem; } }

/* Small tiles drop detail rather than overflow. */
@container (max-height: 9.5rem) {
  .tile-recent, .tile-desc { display: none; }
}
@container (max-height: 5.5rem) {
  .tile-meta { display: none; }
}

/* Portrait screens (phones): narrower grid. */
@media (max-aspect-ratio: 4/5), (max-width: 640px) {
  .board {
    grid-template-columns: repeat(var(--p-cols), minmax(0, 1fr));
    grid-template-rows: repeat(var(--p-rows), minmax(0, 1fr));
  }
  .tagline { display: none; }
}
@media (max-height: 520px) {
  .tagline { display: none; }
}
/* Below this, fitting one screen would make the board unreadable; let it scroll. */
@media (max-height: 340px) {
  body.home { height: auto; overflow: auto; display: block; }
  .board { height: auto; grid-template-rows: none; grid-auto-rows: 9rem; }
}

.empty { color: var(--muted); }

/* ---------- Reading pages ---------- */

.page {
  max-width: 46rem;
  margin: 0 auto;
  padding: clamp(16px, 4vh, 48px) var(--gutter) 96px;
}
.page-title {
  margin: 0 0 0.75rem;
  font: 800 clamp(2rem, 6vw, 3.5rem)/1.02 var(--sans);
  letter-spacing: -0.03em;
}
.cat-title { border-left: 8px solid var(--c); padding-left: 0.9rem; margin-left: calc(-0.9rem - 8px); }
@media (max-width: 760px) { .cat-title { margin-left: 0; } }
.lede { color: var(--muted); font: 400 1.2rem/1.55 var(--serif); max-width: 36em; }
.lede p { margin: 0 0 0.6em; }
.subtle { color: var(--muted); font-size: 0.9rem; }
.notice {
  padding: 0.6rem 0.9rem;
  border-left: 4px solid var(--c, var(--link));
  background: var(--surface);
  font-size: 0.95rem;
}

/* Category chips */
.lanes-key, .chips { display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; margin: 1.5rem 0 1rem; }
.key { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--ink); text-decoration: none; font-weight: 500; font-size: 0.95rem; }
.key i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.key:hover { color: var(--c); }

/* Timeline with lanes */
.timeline { list-style: none; margin: 1.5rem 0 0; padding: 0; }
.row { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 1.25rem; }
.rail { display: flex; }
.lane { position: relative; width: 14px; }
.lane::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 6px;
  width: 2px;
  background: var(--c, var(--rule));
  opacity: 0.45;
}
.row:first-child .lane::before { top: 2.3rem; }
.row:last-child .lane::before { bottom: auto; height: 2.3rem; }
.lane b {
  position: absolute;
  top: 1.95rem;
  left: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 3px var(--paper);
}

.entry { padding: 1rem 0 1.75rem; }
.entry time { color: var(--muted); font-size: 0.85rem; }
.entry h2 { margin: 0.15rem 0 0.35rem; font: 700 1.35rem/1.2 var(--sans); letter-spacing: -0.01em; }
.entry h2 a { color: var(--ink); text-decoration: none; }
.entry h2 a:hover { color: var(--link); text-decoration: underline; }
.entry p { margin: 0; font: 400 1.08rem/1.55 var(--serif); color: var(--ink); }

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.95rem;
}
.pager > :last-child { text-align: right; }

/* Single entry */
.post header time { color: var(--muted); }
.post header .chips { margin: 0 0 2rem; }

.prose { font: 400 1.18rem/1.65 var(--serif); }
.prose > * { max-width: 36em; }
.prose h2, .prose h3, .prose h4 { font-family: var(--sans); letter-spacing: -0.01em; line-height: 1.2; margin: 2em 0 0.5em; }
.prose h2 { font-size: 1.5rem; }
.prose h3 { font-size: 1.2rem; }
.prose img { display: block; margin: 1.5em 0; border-radius: 4px; }
.prose figure, .prose p:has(> img:only-child) { max-width: none; }
.prose blockquote { margin: 1.5em 0; padding-left: 1.1em; border-left: 3px solid var(--rule); color: var(--muted); }
.prose code { font-size: 0.85em; background: var(--surface); padding: 0.1em 0.3em; border-radius: 3px; }
.prose pre { overflow-x: auto; padding: 1rem 1.1rem; background: var(--surface); border-radius: 6px; font-size: 0.85rem; line-height: 1.5; max-width: none; }
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose table { border-collapse: collapse; font: 0.95rem/1.4 var(--sans); display: block; overflow-x: auto; }
.prose th, .prose td { padding: 0.4rem 0.8rem; border-bottom: 1px solid var(--rule); text-align: left; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5em 0; }

/* Entry body blocks */
html { overflow-x: clip; }
.prose > .block-image, .prose > .block-gallery, .prose > .block-video, .prose > .block-file, .prose > .block-code { max-width: none; }
.block-text > :first-child { margin-top: 0; }
.figure, .gallery { margin: 2rem 0; }
.figure img, .figure video, .gallery img { display: block; width: 100%; height: auto; margin: 0; border-radius: 4px; }
.figure.size-text { max-width: 36em; }
.figure.size-wide { width: min(100vw - 2 * var(--gutter), 68rem); margin-left: calc(50% - min(100vw - 2 * var(--gutter), 68rem) / 2); }
.figure.size-full { width: 100vw; margin-left: calc(50% - 50vw); }
.figure.size-full img, .figure.size-full video { border-radius: 0; }
.figure audio { display: block; width: 100%; }
.file-link { display: flex; justify-content: space-between; gap: 1rem; padding: 0.9rem 1rem; border: 1px solid var(--rule); border-radius: 4px; background: var(--surface); color: inherit; text-decoration: none; font: 500 1rem/1.3 var(--sans); }
.file-link:hover { border-color: currentColor; }
.file-meta { color: var(--muted); white-space: nowrap; }
figcaption { margin-top: 0.6rem; color: var(--muted); font: 400 0.9rem/1.4 var(--sans); }
.figure.size-full figcaption { padding: 0 var(--gutter); }
.gallery { width: min(100vw - 2 * var(--gutter), 68rem); margin-left: calc(50% - min(100vw - 2 * var(--gutter), 68rem) / 2); }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 8px; }
.gallery-grid img { aspect-ratio: 4 / 3; object-fit: cover; }
.block-video { margin: 2rem 0; }
.block-video .responsive-object { position: relative; }
.block-video .responsive-object iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 4px; }
.prose blockquote footer { margin-top: 0.4rem; font: 400 0.9rem/1.4 var(--sans); }
.prose blockquote footer::before { content: "– "; }

/* About page */
.about-head {
  display: grid;
  grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
  gap: clamp(1.25rem, 4vw, 2.5rem);
  align-items: end;
  margin: 1.5rem 0 2.5rem;
}
.about-head.no-portrait { grid-template-columns: minmax(0, 1fr); }
.portrait { display: block; width: 100%; height: auto; border-radius: 4px; border-bottom: 6px solid var(--c, var(--rule)); }
.about-intro { margin: 0; font: 400 clamp(1.35rem, 3.2vw, 1.75rem)/1.4 var(--serif); }
@media (max-width: 560px) {
  .about-head { grid-template-columns: minmax(0, 1fr); }
  .portrait { max-width: 14rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
