/* gremlin-den theme: the site's only stylesheet.

   Flat "printed comic" look: thick ink borders, square corners, and
   hard-edged shadows with zero blur. Never add a blurred box-shadow.

   Before adding a rule, check whether an existing one can be grouped or
   extended; visually identical things should share one rule.
   Nothing essential may depend on :hover (touch screens have none).

   Supports browsers from March 2022 on (Chrome 99, Firefox 98, Safari
   15.4). A property given twice in a row is a fallback pair: older
   browsers drop the second, newer value and keep the first. */

/* ---------- Tokens ---------- */
:root {
  --paper: #F0EEE6;
  --paper-dim: #E4E1D6;
  --ink: #17171B;
  --ink-soft: #55555E;
  --blue: #2647E0;
  --red: #E8432E;

  --font-display: 'Big Shoulders Display', sans-serif; /* headings, nav: always uppercase */
  --font-body: 'Source Serif 4', serif;
  --font-mono: 'JetBrains Mono', monospace;            /* dates, tags, labels */

  --max-width: 1200px;
  --gutter: 24px;
  --measure: 68ch; /* longest line of running text */

  --border: 3px solid var(--ink);
  --card-shadow: 5px 5px 0 0 rgba(23, 23, 27, 0.18);
}

/* ---------- Base ---------- */
/* The `font:` shorthand resets line-height: always give one (13px/1.5). */
* { box-sizing: border-box; }

/* Always reserve the scrollbar's space, so pages that do and don't scroll
   don't shift sideways (no effect with overlay scrollbars). */
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.5 var(--font-body);
}

main {
  flex: 1;
  padding: 40px 0 64px;
}

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

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

/* Nav lists and lists with a class are layout components; plain lists in
   prose keep their bullets. :where() keeps this at zero specificity so any
   class rule (e.g. .breadcrumb's margin) can override it. */
:where(nav ul, ul[class], ol[class]) { margin: 0; padding: 0; list-style: none; }

figure { margin: 0; }

figcaption {
  margin-top: 10px;
  font-size: 14px;
  font-style: italic;
  color: var(--ink-soft);
}

h1, h2 { text-wrap: balance; }

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

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

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------- Header and nav ---------- */
.site-header { border-bottom: var(--border); }

.site-header .container,
.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-block: 20px;
}

/* The logo's height and the nav links' height set the header's height. */
.site-logo img { height: 26px; }

/* Child combinator on purpose: a descendant selector would also match the
   dropdown's <ul> and force it visible. */
.nav > ul { display: flex; flex-wrap: wrap; gap: 32px; }

/* Nav items and list-row titles share one size on purpose. */
.nav-link,
.entry-list-title {
  font: 700 24px var(--font-display);
  text-transform: uppercase;
}

.nav-link {
  display: block;
  position: relative;
  padding-bottom: 2px;
  line-height: 1;
  letter-spacing: 0.01em;
}

/* An underline that sweeps in: blue on hover/focus and while the dropdown
   is open; red, and always drawn, for the current page or section (the
   header marks "Work" current when the dropdown holds it). */
.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: 0;
  height: 3px;
  background: var(--blue);
  transition: right 0.18s ease;
}

.nav-link:is(:hover, :focus-visible, [aria-current])::after,
details[open] > .nav-link::after {
  right: 0;
}

.nav-link[aria-current]::after { background: var(--red); }

summary.nav-link { cursor: pointer; }
summary.nav-link::-webkit-details-marker { display: none; }

.nav details { position: relative; }

/* Close an open dropdown by clicking anywhere else, without JavaScript:
   while open, the summary stretches an invisible layer over the viewport
   (beneath the menu), so a click outside lands on the summary and toggles
   it shut. Moving the pointer away does nothing. */
.nav details[open] > summary::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 10;
  cursor: default;
}

.dropdown-caret {
  display: inline-block;
  margin-left: 2px;
  font-size: 11px;
}

details[open] .dropdown-caret { transform: rotate(180deg); }

.dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 20;
  min-width: 190px;
  margin-top: 12px;
  padding: 6px 0;
  background: var(--paper);
  border: var(--border);
}

.dropdown li > * {
  display: block;
  padding: 10px 16px;
  font: 14px/1.5 var(--font-mono);
}

/* Current page or section: a darker background, and a ">" hanging in the
   left padding so the text stays aligned with the other items. */
.dropdown [aria-current] { background: #B6B4AB; } /* --paper-dim, 20% darker */

.dropdown [aria-current]::before {
  content: ">";
  content: ">" / "";
  display: inline-block;
  width: 1ch;
  margin: 0 0.5ch 0 -1.5ch;
}

/* ---------- Footer ---------- */
.site-footer { border-top: var(--border); }

.site-footer p { margin: 0; }

/* Right-hand side, even when it wraps below the breadcrumb on phones. */
.footer-meta { margin-left: auto; }

/* Icon + label link (footer RSS, About page email). The SVG draws in
   currentColor: red at rest, then icon and text turn blue together. */
.icon-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
}

.icon-link:is(:hover, :focus-visible) { color: var(--blue); }
.icon-link:not(:hover, :focus-visible) svg { color: var(--red); }

/* ---------- Shared type ---------- */
/* Small mono label: page eyebrows, card labels, section headings in prose. */
.eyebrow,
.prose h2 {
  margin: 0 0 10px;
  font: 12px/1.5 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue);
}

.page-title {
  font: 900 44px/1 var(--font-display);
  text-transform: uppercase;
}

/* Small print: dates, breadcrumb, footer. */
.meta,
.breadcrumb,
.site-footer {
  font: 13px/1.5 var(--font-mono);
  color: var(--ink-soft);
}

/* Breadcrumb, eyebrow, date, title, tags, lede: one even gap between each. */
.page-intro {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: var(--measure);
  margin-bottom: 32px;
}

.page-intro > * { margin: 0; }

.page-lede { color: var(--ink-soft); }

/* overflow-wrap: a long URL can't widen the column and scroll the page. */
.prose {
  max-width: var(--measure);
  overflow-wrap: anywhere;
}

.prose > * { margin: 0 0 20px; }
.prose > * + h2 { margin-top: 32px; }
.prose > :last-child { margin-bottom: 0; }

/* Links written in markdown (components carry their own classes). */
.prose a:not([class], .link-list a) {
  color: var(--blue);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Secondary links: a simple color shift on hover. The bolder underline
   sweep and card invert are reserved for primary nav and cards. */
.prose a:not([class], .link-list a):is(:hover, :focus-visible),
.breadcrumb a:is(:hover, :focus-visible),
.tag-list a:is(:hover, :focus-visible) {
  color: var(--ink);
}

/* Plain vertical list of links. In markdown: put {.link-list} on the
   line after the list. */
.link-list { display: grid; gap: 8px; }
.link-list a:is(:hover, :focus-visible) { color: var(--blue); }

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-list a {
  display: block;
  padding: 4px 10px;
  border: 1px solid currentColor;
  font: 12px/1.5 var(--font-mono);
  color: var(--ink-soft);
}

/* Breadcrumb and the footer's RSS | copyright: items split by a glyph.
   The breadcrumb's "/" trails each item, so a long title that wraps (on
   phones) starts its line with text. The "|" leads instead, to keep it
   out of the RSS link. */
.breadcrumb,
.footer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.breadcrumb li:not(:last-child)::after { content: "/"; content: "/" / ""; margin-left: 8px; }
.footer-meta > * + *::before { content: "|"; content: "|" / ""; margin-right: 8px; }

.breadcrumb a { color: var(--blue); }

.breadcrumb [aria-current] { color: var(--ink); font-weight: 600; }

/* ---------- Images ---------- */
/* Content images get the panel border. A view's border is on its box. */
main img,
.view {
  border: var(--border);
}

/* A view shows part of an image: the box clips, and inline styles from
   _partials/image.html size and offset the full original inside it.
   content-box so the aspect ratio applies inside the border. */
.view {
  box-sizing: content-box;
  overflow: hidden;
}

.view img {
  max-width: none;
  border: 0;
}

.hero { margin-bottom: 48px; }

/* ---------- Lightbox (js/lightbox.js) ---------- */
/* A copy of the clicked image (or view) and its caption, as large as fits
   in 80% of the screen (all of it on phones), over a darkened page. JS
   sets --ratio (the image's width/height), handles all clicks, and stops
   the page scrolling behind it. */
.zoomable { cursor: zoom-in; }

.lightbox {
  --w: 80vw;
  width: var(--w);
  height: 80vh;
  height: 80dvh;
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  background: none;
  overflow: visible; /* not auto: sub-pixel overflow would add scrollbars */
  outline: none; /* it takes focus when opened: no focus ring around it */
  cursor: zoom-out;
}

/* Only when open: a display value here would override the hidden state. */
.lightbox[open] {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

/* The backdrop and close X match Tumblr's lightbox. */
.lightbox::backdrop { background: rgba(0, 0, 0, 0.85); }

/* Full height unless that's too wide; shrinks to leave room for the
   caption, and the width follows the image's own aspect ratio. */
.lightbox > :is(img, .view) {
  min-height: 0;
  width: auto;
  height: min(100%, var(--w) / var(--ratio));
  border: 0;
}

.lightbox > figcaption {
  margin: 0;
  padding-inline: var(--gutter); /* off the screen's edges on phones */
  text-align: center;
  color: var(--paper);
}

/* Close X: Tumblr's icon, a 14px white X centered in a 48px square 8px
   from the top left corner. Decorative: a click anywhere closes. */
.lightbox::before {
  content: "";
  position: fixed;
  top: 8px;
  left: 8px;
  width: 48px;
  height: 48px;
  cursor: pointer;
  background: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='white'><path d='M9.527 8l6.164-6.188a1.066 1.066 0 0 0 0-1.5 1.053 1.053 0 0 0-1.495 0L8 6.531 1.805.311a1.053 1.053 0 0 0-1.495 0 1.064 1.064 0 0 0 0 1.5L6.473 8 .31 14.188a1.064 1.064 0 0 0 0 1.501 1.052 1.052 0 0 0 1.495 0L8 9.47l6.195 6.22a1.052 1.052 0 0 0 1.495 0 1.066 1.066 0 0 0 0-1.5L9.527 8z'/></svg>") center / 14px no-repeat;
}

/* Phones, either way up: the whole screen. */
@media (max-width: 640px), (max-height: 640px) {
  .lightbox { --w: 100vw; height: 100vh; height: 100dvh; }
}

/* ---------- Cards (home panels, portfolio thumbnails) ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
}

.card {
  background: var(--paper);
  border: var(--border);
  box-shadow: var(--card-shadow);
}

/* Signature interaction: a panel inverts to ink on hover, like a printed
   plate flipping to its negative. */
.panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 28px 24px 32px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

/* The same invert for dropdown links and thumbnail captions. */
.panel:is(:hover, :focus-visible),
.dropdown a:is(:hover, :focus-visible),
.thumb:is(:hover, :focus-visible) .thumb-title {
  background: var(--ink);
  color: var(--paper);
}

.panel .eyebrow { margin: 0; }

.panel-title {
  margin: 4px 0 8px;
  font: 900 34px/1.05 var(--font-display);
  text-transform: uppercase;
}

.panel-copy {
  flex: 1;
  margin: 0;
  font-size: 15px;
  color: var(--ink-soft);
}

.panel-arrow {
  margin-top: 12px;
  font: 700 22px/1.5 var(--font-display);
}

.panel .meta { margin: 0 0 8px; }

.panel-news .panel-title {
  font-size: 24px;
  font-weight: 700;
}

.panel:is(:hover, :focus-visible) :is(.panel-copy, .meta) {
  color: var(--paper-dim);
}

/* Thumbnails: the image sits flush in the card; only the caption bar
   inverts on hover, and it's always visible. */
.thumb .view { border-width: 0 0 3px; }

.thumb-title {
  margin: 0;
  padding: 14px 16px 16px;
  font: 700 18px/1.5 var(--font-display);
  text-transform: uppercase;
  transition: background-color 0.15s ease, color 0.15s ease;
}

/* ---------- Portfolio piece ---------- */
.prose + .piece-media { margin-top: 40px; }

/* Always the full content width: large originals scale down, small ones
   scale up. Natural aspect ratio, so tall pieces can exceed the screen. */
.piece-image { width: 100%; }

/* Detail views: all the same size (the box shape is set in the template),
   each half the row, so a pair lines up with the main image's edges. A
   single or odd last one is centered; one per row on phones. */
.detail-views {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin-top: 20px;
}

.detail-views figure { flex: 0 0 calc(50% - 10px); }

/* ---------- Links to other entries: prev/next and lists ---------- */
.entry-pagination {
  display: flex;
  margin-top: 48px;
  padding-top: 24px;
  border-top: var(--border);
}

/* Label, title (and summary) stacked. */
.entry-pagination a,
.entry-list a {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.entry-pagination a { max-width: 45%; }

.entry-pagination [rel="next"] {
  margin-left: auto;
  text-align: right;
}

.pagination-label {
  font: 12px/1.5 var(--font-mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.pagination-title {
  font: 700 20px/1.5 var(--font-display);
  text-transform: uppercase;
}

.entry-pagination a:is(:hover, :focus-visible) .pagination-title {
  color: var(--blue);
}

/* The one list view: Updates, the sidebar on each post, tag pages. */
.entry-list {
  display: grid;
  gap: 4px;
  max-width: var(--measure);
}

.entry-list a {
  padding: 14px 16px;
  border-left: 3px solid transparent;
}

.entry-list a:is(:hover, :focus-visible),
.entry-list a[aria-current] {
  background: var(--paper-dim);
}

.entry-list a[aria-current] { border-left-color: var(--blue); }

/* Inset, so the sidebar's scroll box doesn't clip the focus ring. */
.entry-list a:focus-visible { outline-offset: -3px; }

.entry-list-summary { color: var(--ink-soft); }

/* ---------- Two-column layouts ---------- */
.updates-layout,
.page-with-image {
  display: grid;
  gap: 48px;
  align-items: start;
}

/* Update: list on the left, post on the right. The post comes first in
   the source; pinning the list to column 1 puts the post in column 2. */
.updates-layout { grid-template-columns: 1fr 2fr; }

/* The list scrolls on its own once it outgrows the screen, instead of
   stretching the page. Inactive until there are enough posts. */
.updates-layout > aside {
  grid-area: 1 / 1;
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

/* Page with an image beside the text (About). */
.page-with-image { grid-template-columns: 2fr 1fr; }

/* ---------- Narrow screens ---------- */
@media (max-width: 900px) {
  .card-grid { grid-template-columns: 1fr 1fr; }

  .updates-layout,
  .page-with-image {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .updates-layout > aside {
    grid-area: auto;
    position: static;
    max-height: 320px;
  }

  /* Stacked: keep the side image about as big as it was as a column. */
  .page-with-image > img { max-width: min(320px, 100%); margin: 0 auto; }
}

@media (max-width: 640px) {
  .nav > ul { gap: 20px; }
  .card-grid { grid-template-columns: 1fr; }
  .detail-views figure { flex-basis: 100%; }
}
