/* ==================================================================
   plog — white paper, black ink, one blue mark.
   ================================================================== */

*,
*::before,
*::after { box-sizing: border-box; }

:root {
  --bg: #ffffff;
  --ink: #000000;
  --ink-2: #2b2b2b;
  --muted: #8f8f8f;
  --muted-2: #666666;
  --line: #e8e8e8;
  --line-2: #cfcfcf;
  --surface: #fafafa;

  --accent: #20a7db;
  --accent-deep: #1888b4;
  --accent-wash: rgba(32, 167, 219, 0.10);

  --wrap: 1000px;
  --read: 640px;

  --font: "Helvetica Neue", Helvetica, Arial, "Hiragino Kaku Gothic ProN",
          "Hiragino Sans", "Noto Sans JP", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --label: 0.6875rem;
  --small: 0.8125rem;
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.85;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  /* Push the footer to the bottom of the viewport on short pages. */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#main { flex: 1 0 auto; }

::selection { background: var(--accent-wash); }

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

a { color: inherit; }

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

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 40px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--bg);
  color: var(--ink);
  padding: 12px 18px;
  border: 1px solid var(--accent);
  z-index: 10;
}
.skip:focus { left: 12px; top: 12px; }

/* ------------------------------------------------------------------
   Small caps label — the recurring typographic motif
   ------------------------------------------------------------------ */
.label {
  margin: 0;
  font-size: var(--label);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 400;
}

/* ------------------------------------------------------------------
   Header
   ------------------------------------------------------------------ */
.site-header { border-bottom: 1px solid var(--line); }

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
}

.brand {
  display: inline-flex;
  align-items: center;
  font-size: 0.875rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 500;
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 30px;
}

.site-nav a {
  font-size: var(--label);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-2);
  text-decoration: none;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  transition: color 0.18s ease, border-color 0.18s ease;
}

.site-nav a:hover { color: var(--ink); }

.site-nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* ------------------------------------------------------------------
   Page head
   ------------------------------------------------------------------ */
.page-head {
  padding: 72px 0 28px;
}

.page-head .tagline {
  margin: 14px 0 0;
  font-size: var(--small);
  color: var(--muted-2);
  max-width: var(--read);
}

/* ------------------------------------------------------------------
   Post list
   ------------------------------------------------------------------ */
.post-list {
  border-top: 1px solid var(--line);
  margin: 0;
  padding: 0;
  list-style: none;
}

.post-item { border-bottom: 1px solid var(--line); }

.post-item a {
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 32px;
  padding: 30px 0;
  text-decoration: none;
  color: inherit;
}

.post-date {
  font-size: var(--small);
  letter-spacing: 0.06em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding-top: 0.25em;
  transition: color 0.18s ease;
}

.post-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 500;
  line-height: 1.6;
  transition: color 0.18s ease;
}

.post-summary {
  margin: 8px 0 0;
  font-size: var(--small);
  line-height: 1.85;
  color: var(--muted-2);
}

.post-item a:hover .post-title { color: var(--accent); }
.post-item a:hover .post-date { color: var(--ink); }

.list-foot {
  padding: 34px 0 0;
  font-size: var(--small);
  color: var(--muted);
}

/* ------------------------------------------------------------------
   Article
   ------------------------------------------------------------------ */
.article { max-width: var(--read); }

.article-header {
  padding: 76px 0 34px;
  border-bottom: 1px solid var(--line);
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: var(--label);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.article-meta .dot {
  width: 3px;
  height: 3px;
  background: var(--line-2);
  flex: none;
}

.article-title {
  margin: 18px 0 0;
  font-size: 1.875rem;
  line-height: 1.45;
  font-weight: 500;
  letter-spacing: -0.005em;
}

/* ------------------------------------------------------------------
   Prose
   ------------------------------------------------------------------ */
.prose { padding: 40px 0 0; }

.prose > * + * { margin-top: 1.55em; }

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.005em;
  margin-bottom: 0;
}

.prose h1 { font-size: 1.5rem; margin-top: 2.6em; }
.prose h2 { font-size: 1.1875rem; margin-top: 2.8em; }
.prose h3 { font-size: 1rem; margin-top: 2.4em; }
.prose h4 { font-size: 0.9375rem; margin-top: 2.2em; color: var(--ink-2); }

.prose h1 + *,
.prose h2 + *,
.prose h3 + *,
.prose h4 + * { margin-top: 0.85em; }

.heading-anchor {
  margin-left: 0.5em;
  color: var(--line-2);
  text-decoration: none;
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.18s ease, color 0.18s ease;
}

.prose h2:hover .heading-anchor,
.prose h3:hover .heading-anchor,
.heading-anchor:focus { opacity: 1; }
.heading-anchor:hover { color: var(--accent); }

.prose p { margin: 0; }

.prose a {
  color: var(--accent-deep);
  text-decoration: none;
  border-bottom: 1px solid rgba(32, 167, 219, 0.35);
  transition: color 0.18s ease, border-color 0.18s ease;
}

.prose a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.prose strong { font-weight: 600; }

.prose ul,
.prose ol {
  margin-left: 0;
  padding-left: 1.4em;
}

.prose li { line-height: 1.75; }
.prose li + li { margin-top: 0.3em; }
.prose li > ul,
.prose li > ol { margin-top: 0.3em; }

.prose li.task { list-style: none; margin-left: -1.4em; }
.prose li.task input { margin-right: 0.6em; accent-color: var(--accent); }

.prose blockquote {
  margin: 2em 0;
  padding: 0.15em 0 0.15em 26px;
  border-left: 2px solid var(--accent);
  color: var(--muted-2);
}

.prose blockquote > * + * { margin-top: 1em; }

.prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 3.2em 0;
}

/* No border on inline code — a wrapped span would otherwise be cut in half. */
.prose code {
  font-family: var(--mono);
  font-size: 0.8125em;
  background: #f4f4f4;
  padding: 0.16em 0.4em;
  overflow-wrap: break-word;
}

.prose pre {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 20px 22px;
  overflow-x: auto;
  font-size: 0.8125rem;
  line-height: 1.75;
}

.prose pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: 1em;
}

.prose img { display: block; }

.prose figcaption,
.prose img + em {
  font-size: var(--small);
  color: var(--muted);
}

.table-wrap { overflow-x: auto; }

.prose table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--small);
}

.prose th,
.prose td {
  border-bottom: 1px solid var(--line);
  padding: 12px 16px 12px 0;
  text-align: left;
  vertical-align: top;
}

.prose th {
  font-size: var(--label);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--muted-2);
  border-bottom-color: var(--line-2);
}

/* ------------------------------------------------------------------
   About page — center the column so it sits balanced on the page
   (posts keep their left-aligned reading column).
   ------------------------------------------------------------------ */
:root[data-page="about"] .article {
  margin-left: auto;
  margin-right: auto;
}

/* ------------------------------------------------------------------
   Snapshots — two panes: photos down the left, description on the
   right. Clicking a photo fills the description panel.
   ------------------------------------------------------------------ */
.snaps-head {
  padding: 72px 0 22px;
  border-bottom: 1px solid var(--line);
}

.snaps-title {
  margin: 0;
  font-size: 1.875rem;
  line-height: 1.3;
  font-weight: 500;
}

.snaps-sub {
  margin: 12px 0 0;
  font-size: var(--small);
  color: var(--muted-2);
}

.snaps {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 52px;
  align-items: start;
  padding-top: 40px;
}

.snaps-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* A photo is a button so it is keyboard-reachable. */
.snaps-thumb {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  line-height: 0;
  cursor: pointer;
}

/* Only the active photo is in colour; the rest fade to black and white. */
.snaps-thumb img {
  display: block;
  width: 100%;
  height: auto;
  background: #f2f2f2;
  filter: grayscale(1);
  transition: filter 0.45s ease;
}

.snaps-thumb[aria-current="true"] img {
  filter: grayscale(0);
}

/* The description panel follows as you scroll the photos. */
.snaps-detail {
  position: sticky;
  top: 40px;
}

.snaps-count {
  margin: 0;
  font-size: var(--label);
  letter-spacing: 0.16em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.snaps-h {
  margin: 14px 0 0;
  font-size: 1.25rem;
  line-height: 1.4;
  font-weight: 500;
}

.snaps-text {
  margin-top: 16px;
  font-size: var(--small);
  line-height: 1.85;
  color: var(--muted-2);
}

.snaps-text p { margin: 0 0 1em; }
.snaps-text p:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------------
   Photo grid — 2 x 2
   ------------------------------------------------------------------ */
.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  gap: 14px;
  margin-top: 2.6em;
  margin-bottom: 2.6em;
}

/* Each photo keeps its own aspect ratio, scaled to the column width. */
.photo-grid img {
  display: block;
  width: 100%;
  height: auto;
  background: #f2f2f2;
}

/* ------------------------------------------------------------------
   Tags
   ------------------------------------------------------------------ */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 56px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.tag {
  font-size: var(--label);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
  border: 1px solid var(--line);
  padding: 5px 11px;
}

/* ------------------------------------------------------------------
   Previous / next
   ------------------------------------------------------------------ */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-top: 80px;
}

.post-nav a {
  background: var(--bg);
  padding: 28px 26px;
  text-decoration: none;
  color: inherit;
  display: block;
}

.post-nav .next { text-align: right; }

.post-nav .dir {
  display: block;
  font-size: var(--label);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.post-nav .t {
  display: block;
  margin-top: 10px;
  font-size: 0.9375rem;
  line-height: 1.6;
  transition: color 0.18s ease;
}

.post-nav a:hover .t { color: var(--accent); }
.post-nav .empty { background: var(--bg); }

.back-link {
  display: inline-block;
  margin-top: 56px;
  font-size: var(--label);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-2);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.18s ease, border-color 0.18s ease;
}

.back-link:hover {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* ------------------------------------------------------------------
   States
   ------------------------------------------------------------------ */
.js-render {
  opacity: 0;
  transition: opacity 0.18s ease;
}
.js-render.is-ready { opacity: 1; }

.state {
  padding: 72px 0;
  color: var(--muted);
  font-size: var(--small);
  max-width: var(--read);
}

.state p { margin: 0; }
.state-hint { margin-top: 12px !important; color: var(--muted-2); }

.state code {
  font-family: var(--mono);
  background: #f4f4f4;
  padding: 0.16em 0.4em;
  font-size: 0.95em;
}

.state a { color: var(--accent-deep); }

/* ------------------------------------------------------------------
   Footer
   ------------------------------------------------------------------ */
.site-footer {
  margin-top: 110px;
  border-top: 1px solid var(--line);
}

.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  flex-wrap: wrap;
  padding-top: 30px;
  padding-bottom: 60px;
  font-size: var(--small);
  color: var(--muted);
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.18s ease, border-color 0.18s ease;
}

.site-footer a:hover {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.footer-links { display: flex; gap: 22px; }

/* ------------------------------------------------------------------
   Narrow screens
   ------------------------------------------------------------------ */
@media (max-width: 720px) {
  .wrap { padding: 0 22px; }

  .site-header .wrap { min-height: 64px; }
  .site-nav { gap: 20px; }

  .page-head { padding: 48px 0 22px; }

  .post-item a {
    grid-template-columns: 1fr;
    gap: 7px;
    padding: 24px 0;
  }
  .post-date { padding-top: 0; }

  .article-header { padding: 52px 0 28px; }
  .article-title { font-size: 1.5rem; }

  .post-nav { grid-template-columns: 1fr; margin-top: 56px; }
  .post-nav .next { text-align: left; }

  .site-footer { margin-top: 72px; }

  /* Snapshots stacks to one column; the description pins to the top so
     tapping a photo below still updates a visible panel. */
  .snaps-head { padding: 48px 0 20px; }
  .snaps-title { font-size: 1.5rem; }

  .snaps {
    grid-template-columns: 1fr;
    gap: 0;
    padding-top: 26px;
  }

  .snaps-detail {
    position: sticky;
    top: 0;
    order: -1;
    background: var(--bg);
    padding: 14px 0 18px;
    margin-bottom: 22px;
    border-bottom: 1px solid var(--line);
    z-index: 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .js-render { opacity: 1; }
}

/* ------------------------------------------------------------------
   Print
   ------------------------------------------------------------------ */
@media print {
  .site-header,
  .site-nav,
  .site-footer,
  .post-nav,
  .back-link,
  .heading-anchor { display: none; }

  body { font-size: 11pt; }
  .js-render { opacity: 1; }
  .prose a { border: 0; color: inherit; }
}
