/*
 * Layout is Posterous's stock "cleansheet" theme, recovered from a 2012
 * Wayback capture: the date sits in a left gutter, the text column is narrow,
 * the leading is generous.
 *
 * Colour is Flexoki by Steph Ango (MIT, stephango.com/flexoki) — a warm paper
 * and a warm near-black rather than white and black, which is what keeps a
 * page of family photos from feeling like a dashboard.
 *
 * Type is deliberately flat: headings sit at weight 500 and only a little
 * larger than body text, so hierarchy comes from colour and space instead of
 * from shouting.
 */

:root {
  /* Flexoki, light */
  --paper: #fffcf0;      /* paper   */
  --raised: #f2f0e5;     /* 50      */
  --ink: #100f0f;        /* black   */
  --muted: #6f6e69;      /* 600     */
  --faint: #b7b5ac;      /* 300     */
  --rule: #e6e4d9;       /* 100     */
  --rule-soft: #f2f0e5;  /* 50      */
  --accent: #bc5215;     /* orange-600 */

  --gutter: 116px;
  --measure: 37rem;
  --gap: 40px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* Flexoki, dark */
    --paper: #100f0f;    /* black   */
    --raised: #1c1b1a;   /* 950     */
    --ink: #cecdc3;      /* 200     */
    --muted: #878580;    /* 500     */
    --faint: #575653;    /* 700     */
    --rule: #282726;     /* 900     */
    --rule-soft: #1c1b1a;/* 950     */
    --accent: #da702c;   /* orange-400 */
  }
}

:root[data-theme="dark"] {
  --paper: #100f0f;
  --raised: #1c1b1a;
  --ink: #cecdc3;
  --muted: #878580;
  --faint: #575653;
  --rule: #282726;
  --rule-soft: #1c1b1a;
  --accent: #da702c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 18px/1.65 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

.skip { position: absolute; left: -9999px; }
.skip:focus {
  left: 12px; top: 12px; z-index: 10; background: var(--paper);
  padding: 10px 14px; border: 1px solid var(--rule); border-radius: 4px;
}

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

/* A quiet grey label, not a heading. Used for section furniture. */
.label {
  font: 400 15px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--muted);
  margin: 0 0 14px;
}

.shell { max-width: calc(var(--gutter) + var(--gap) + var(--measure)); margin: 0 auto; padding: 0 24px; }

/* ---------- header ---------- */

.site-header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  padding: 52px 0 0;
}

.site-identity { min-width: 0; }

.site-title {
  margin: 0;
  font: 500 20px/1.3 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: -0.01em;
}
.site-title a { color: var(--ink); text-decoration: none; }
.site-title a:hover { color: var(--accent); }

.site-tagline {
  margin: 3px 0 0;
  color: var(--muted);
  font: 400 15px/1.5 ui-sans-serif, system-ui, sans-serif;
}

.site-nav {
  display: flex; align-items: center; gap: 18px;
  font: 400 15px/1.4 ui-sans-serif, system-ui, sans-serif;
}
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--accent); }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0;
  background: none; border: 1px solid var(--rule); border-radius: 4px;
  color: var(--muted); cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 15px; height: 15px; display: block; }
.theme-toggle .icon-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-dark { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-dark { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-light { display: none; }
}

/* ---------- flash ---------- */

.flash {
  margin: 20px 0 0; padding: 11px 15px; border-radius: 4px;
  font: 400 16px/1.5 ui-sans-serif, system-ui, sans-serif;
  background: var(--raised); border-left: 2px solid var(--accent);
}
.flash-alert { border-left-color: #af3029; }

/* ---------- posts ---------- */

.posts { padding-top: 40px; }

.post {
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, var(--measure));
  gap: var(--gap);
  padding-bottom: 48px;
  margin-bottom: 48px;
  border-bottom: 1px solid var(--rule);
}
.posts > .post:last-child { border-bottom: 0; }

.post-date { text-align: right; padding-top: 7px; }
.post-date-link {
  font: 400 14px/1.4 ui-sans-serif, system-ui, sans-serif;
  color: var(--muted); text-decoration: none;
}
.post-date-link:hover { color: var(--accent); }

.post-body { min-width: 0; }

.post-title {
  margin: 0 0 12px;
  font: 500 22px/1.3 "Iowan Old Style", Palatino, Georgia, serif;
  letter-spacing: -0.005em;
  text-wrap: balance;
}
.post-title a { color: var(--ink); text-decoration: none; }
.post-title a:hover { color: var(--accent); }

.prose > *:first-child { margin-top: 0; }
.prose > *:last-child { margin-bottom: 0; }
.prose p { margin: 0 0 1.05em; }
.prose h1, .prose h2, .prose h3 {
  margin: 1.5em 0 .45em; line-height: 1.3; font-weight: 500; font-size: 1.05em;
}
.prose ul, .prose ol { padding-left: 1.3em; margin: 1em 0; }
.prose li { margin: .25em 0; }
.prose blockquote {
  margin: 1.15em 0; padding-left: 18px;
  border-left: 2px solid var(--rule); color: var(--muted);
}
.prose code {
  font: 0.86em/1.5 ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--raised); padding: 1px 5px; border-radius: 3px;
}
.prose pre {
  background: var(--raised); padding: 14px 16px; border-radius: 4px;
  overflow-x: auto; font-size: 14px; line-height: 1.6;
}
.prose pre code { background: none; padding: 0; }
.prose table { border-collapse: collapse; width: 100%; font-size: 15px; }
.prose th, .prose td { border-bottom: 1px solid var(--rule); padding: 8px 10px; text-align: left; }
.prose img { max-width: 100%; height: auto; }

/* ---------- photos ---------- */

.gallery { margin: 20px 0 0; }
.gallery img { display: block; width: 100%; height: auto; border-radius: 6px; }
.gallery-item { margin: 0; }
.gallery-link { display: block; text-decoration: none; }

.gallery-single .gallery-item + .gallery-item { margin-top: 10px; }

/* No forced aspect ratio anywhere: a photo is shown at the shape it was taken.
   Cropping to a tidy grid quietly throws away the top of a tall picture, which
   for a photo blog is the wrong trade — ragged bottoms are the honest cost. */
.gallery-pair,
.gallery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
}

.gallery-link { cursor: zoom-in; }

/* ---------- lightbox ---------- */

.lightbox {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #f5f2ea;
  overflow: hidden;
}
/* Opaque, not merely dark: at 94% the page's own high-contrast elements —
   the Subscribe button especially — still read through it. */
.lightbox::backdrop { background: #0c0b09; }

.lightbox-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 44px 16px 56px;
}
.lightbox-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;   /* the whole picture, never cropped */
  border-radius: 3px;
}

.lightbox button {
  position: absolute;
  background: rgba(0, 0, 0, 0.4);
  color: #f5f2ea;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font: 400 26px/1 ui-sans-serif, system-ui, sans-serif;
  width: 44px;             /* a comfortable tap target */
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox button:hover { background: rgba(0, 0, 0, 0.7); }
.lightbox button:focus-visible { outline: 2px solid #f5f2ea; outline-offset: 2px; }

.lightbox-close { top: 12px; right: 12px; font-size: 22px; }
.lightbox-prev  { left: 12px;  top: 50%; transform: translateY(-50%); }
.lightbox-next  { right: 12px; top: 50%; transform: translateY(-50%); }

.lightbox-count {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font: 400 13px ui-sans-serif, system-ui, sans-serif;
  color: rgba(245, 242, 234, 0.7);
  font-variant-numeric: tabular-nums;
}

/* ---------- video ---------- */

.video {
  margin: 20px 0 0; aspect-ratio: 16 / 9;
  background: var(--raised); border-radius: 6px; overflow: hidden;
}
.video iframe { width: 100%; height: 100%; border: 0; display: block; }

.post-permalink { margin: 20px 0 0; font: 400 14px/1.4 ui-sans-serif, system-ui, sans-serif; }
.post-permalink a { color: var(--muted); text-decoration: none; }
.post-permalink a:hover { color: var(--accent); }

/* ---------- archive ---------- */

.archive { padding: 40px 0 0; }
.archive-intro { margin-left: calc(var(--gutter) + var(--gap)); max-width: var(--measure); }

.archive-year {
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, var(--measure));
  gap: var(--gap);
  padding-bottom: 26px;
}
.archive-year > h2 {
  margin: 0; text-align: right; padding-top: 2px;
  font: 400 14px/1.7 ui-sans-serif, system-ui, sans-serif;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.archive-list { list-style: none; margin: 0; padding: 0; }
.archive-row {
  display: flex; gap: 14px; align-items: baseline;
  font: 400 16px/1.7 ui-sans-serif, system-ui, sans-serif;
}
.archive-month {
  flex: none; width: 30px;
  color: var(--faint); font-size: 14px; font-variant-numeric: tabular-nums;
}
.archive-row a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--rule); }
.archive-row a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.archive-count {
  flex: none; display: inline-flex; align-items: center; gap: 3px;
  color: var(--faint); font-size: 13px; font-variant-numeric: tabular-nums;
}
.archive-count svg { width: 12px; height: 12px; display: block; }

/* ---------- pagination, empty ---------- */

.pagination {
  display: flex; gap: 24px; justify-content: space-between;
  padding: 0 0 20px;
  margin-left: calc(var(--gutter) + var(--gap));
}
.pagination-link { font: 400 15px/1.4 ui-sans-serif, system-ui, sans-serif; text-decoration: none; }
.pagination-link:hover { text-decoration: underline; }

.empty { margin-left: calc(var(--gutter) + var(--gap)); max-width: var(--measure); padding: 40px 0 0; }
.empty h2 { font: 500 20px/1.3 ui-sans-serif, system-ui, sans-serif; margin: 0 0 8px; }
.empty p { color: var(--muted); margin: 0; }
.empty code {
  font: 0.9em ui-monospace, Menlo, monospace;
  background: var(--raised); padding: 2px 6px; border-radius: 3px; color: var(--ink);
}

/* ---------- footer ---------- */

.site-footer { padding: 36px 0 72px; border-top: 1px solid var(--rule); margin-top: 8px; }

.subscribe { margin-left: calc(var(--gutter) + var(--gap)); max-width: var(--measure); }

.subscribe-form { display: flex; gap: 8px; flex-wrap: wrap; }

.subscribe-input {
  flex: 1 1 220px; min-width: 0; padding: 9px 11px;
  font: 400 16px ui-sans-serif, system-ui, sans-serif;
  color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule); border-radius: 4px;
}
.subscribe-input::placeholder { color: var(--faint); }
.subscribe-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.subscribe-button {
  padding: 9px 18px;
  font: 400 16px ui-sans-serif, system-ui, sans-serif;
  color: var(--paper); background: var(--ink);
  border: 1px solid var(--ink); border-radius: 4px; cursor: pointer;
}
.subscribe-button:hover { background: var(--accent); border-color: var(--accent); }

.subscribe-note {
  margin: 11px 0 0; font: 400 14px/1.6 ui-sans-serif, system-ui, sans-serif; color: var(--muted);
}

.colophon {
  margin: 32px 0 0 calc(var(--gutter) + var(--gap));
  font: 400 14px ui-sans-serif, system-ui, sans-serif; color: var(--faint);
}

/* ---------- narrow screens: the gutter folds above the post ---------- */

@media (max-width: 820px) {
  :root { --gap: 0px; --measure: 100%; }

  body { font-size: 17px; }

  .post, .archive-year { grid-template-columns: 1fr; gap: 6px; }
  .post-date { text-align: left; padding-top: 0; }
  .archive-year > h2 { text-align: left; margin-bottom: 6px; }

  .pagination, .subscribe, .colophon, .empty, .archive-intro { margin-left: 0; }

  .site-header { padding-top: 36px; }
}

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

/* ---------- compose ---------- */

.compose {
  margin-left: calc(var(--gutter) + var(--gap));
  max-width: var(--measure);
  padding: 40px 0 0;
}

.compose-form { display: flex; flex-direction: column; }

.compose-label {
  font: 400 14px/1.4 ui-sans-serif, system-ui, sans-serif;
  color: var(--muted);
  margin: 18px 0 6px;
}
.compose-form > .compose-label:first-of-type { margin-top: 0; }

.compose-input,
.compose-textarea {
  width: 100%;
  padding: 10px 12px;
  font: 400 17px/1.5 "Iowan Old Style", Palatino, Georgia, serif;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.compose-textarea { resize: vertical; min-height: 9em; }
.compose-input::placeholder,
.compose-textarea::placeholder { color: var(--faint); }
.compose-input:focus-visible,
.compose-textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.compose-file {
  font: 400 15px ui-sans-serif, system-ui, sans-serif;
  color: var(--muted);
  padding: 10px 0;
}

.compose-hint {
  margin: 6px 0 0;
  font: 400 14px/1.6 ui-sans-serif, system-ui, sans-serif;
  color: var(--muted);
}
.compose-footnote { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--rule); }

.compose-button {
  align-self: flex-start;
  margin-top: 26px;
  padding: 11px 26px;
  font: 400 17px ui-sans-serif, system-ui, sans-serif;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 4px;
  cursor: pointer;
}
.compose-button:hover { background: var(--accent); border-color: var(--accent); }
.compose-button:disabled { opacity: .5; cursor: default; }

/* Picking a post to edit. A plain list rather than a grid: on a phone the
   titles are what you are scanning, and they need the full width. */
.compose-list { list-style: none; margin: 0; padding: 0; }

.compose-list-item { border-bottom: 1px solid var(--rule); }
.compose-list-item:first-child { border-top: 1px solid var(--rule); }

.compose-list-link {
  display: block;
  padding: 14px 0;
  text-decoration: none;
  color: inherit;
  background: none;
}
.compose-list-link:hover .compose-list-title { color: var(--accent); }

.compose-list-title { display: block; font-weight: 500; }

.compose-list-meta {
  display: block;
  margin-top: 3px;
  font: 400 13px/1.5 ui-sans-serif, system-ui, sans-serif;
  color: var(--muted);
}

/* Existing photos, each a checkbox you untick to drop. Tapping anywhere on the
   picture toggles it, because a bare checkbox is a poor target on a phone. */
.compose-photos {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

.compose-photo label { display: block; position: relative; cursor: pointer; }

.compose-photo img {
  display: block;
  width: 100%;
  /* Square and cropped, unlike the gallery. These are controls for picking a
     photo, not the photo itself: an even grid is easier to scan and to hit,
     and nothing here is the presentation the reader sees. */
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 2px;
  /* Unticked reads as "on its way out" without removing it from the page. */
  transition: opacity .12s ease, filter .12s ease;
}

.compose-photo input { position: absolute; top: 6px; left: 6px; z-index: 1; }

.compose-photo input:not(:checked) ~ img { opacity: .35; filter: grayscale(1); }

@media (max-width: 820px) {
  .compose { margin-left: 0; padding-top: 24px; }
  /* 16px stops iOS zooming the page when a field takes focus. */
  .compose-input, .compose-textarea { font-size: 16px; }
}
