/* Design system — quiet, text-first, grayscale.
   Poppins self-hosted locally (latin subset, woff2); no CDN dependency. */

@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/poppins-400.woff2') format('woff2');
}

@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/poppins-500.woff2') format('woff2');
}

@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/poppins-600.woff2') format('woff2');
}

:root {
  --bg: #ffffff;
  --ink: #111111;
  --text: #3a3a3a;
  --muted: #5a5a5a;
  --muted-soft: #6b6b6b;
  --rule: #eaeaea;
  --code-bg: #f6f6f6;
  --num: #8f8f8f;

  --measure: 42rem;
  --pad: 1.25rem;
  --font-sans: 'Poppins', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono',
    monospace;
}

* { box-sizing: border-box; }

html {
  overflow-x: clip;
  color-scheme: light;
  scroll-behavior: smooth;
}

[id] { scroll-margin-top: 1.5rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'kern' 1, 'liga' 1;
}

/* Headings sit in Poppins — the "classy" modern counterpoint to the sans
   body. They stay near-black while running text is lighter. */
h1,
h2,
h3 {
  color: var(--ink);
  font-family: var(--font-sans);
  font-weight: 500;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

/* Links — no underlines by default; they lean on their dark color. On
   hover/focus a hairline underline sweeps in from the left. */
a {
  color: var(--ink);
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  transition: background-size 240ms cubic-bezier(0.33, 1, 0.68, 1),
    color 150ms linear;
}

a:hover,
a:focus-visible {
  background-size: 100% 1px;
}

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

::selection {
  background: #1a73e8;
  color: #fff;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 0.5rem 0.75rem;
  background: var(--ink);
  color: var(--bg);
}

.skip-link:focus { position: fixed; left: 0.5rem; top: 0.5rem; z-index: 100; }

/* ---------- Layout ---------- */

.site-main,
.site-footer {
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: var(--pad);
}

.site-main { padding-block: 2.5rem 1.75rem; }

.site-footer {
  padding-bottom: 3rem;
}

.site-footer p {
  margin: 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  color: var(--muted-soft);
  font-size: 0.78125rem;
}

/* ---------- Two-column wrap (Arham-style) ---------- */

/* The persistent "Common" column (intro, About, Currently, Elsewhere, Pages)
   sits on the left; each page's content fills the right column. On narrow
   screens the layout stacks into one column. */
.wrap {
  display: grid;
  grid-template-columns: 300px 1px 1fr;
  column-gap: 2.5rem;
  align-items: start;
}

.wrap .rule {
  width: 1px;
  align-self: stretch;
  background: var(--rule);
}

.wrap .col-right { min-width: 0; }

/* Only pages that use the two-column wrap get the wider measure; article
   reading width is governed by the column itself. */
.site-main:has(.wrap) { max-width: 60rem; }

/* On wide screens the "Common" column stays put while the right column
   scrolls — reading posts never loses the nav. */
@media (min-width: 721px) {
  .wrap .col-left {
    position: sticky;
    top: 2.5rem;
  }
}

/* ---------- Home ---------- */

.intro h1,
.intro .site-name {
  margin: 0 0 0.5rem;
  font-size: clamp(1.75rem, 6vw, 2.25rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
  font-weight: 600;
}

.intro .site-name { color: var(--ink); }

.role {
  margin: 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

/* Theme toggle — quiet pill that follows the site's text-first language. */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1.25rem;
  padding: 0.28rem 0.65rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78125rem;
  line-height: 1;
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--muted-soft);
}

.section { margin-top: 2.25rem; }

.section-label {
  margin: 0 0 0.875rem;
  font-size: 0.6875rem;
  font-weight: 600;
  font-family: var(--font-sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-soft);
}

.section p { margin: 0 0 0.75rem; }
.section p:last-child { margin-bottom: 0; }

.plain-list,
.link-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.plain-list li { margin-bottom: 0.5rem; }
.plain-list li:last-child { margin-bottom: 0; }

.link-list li { margin-bottom: 0.35rem; }
.link-list li:last-child { margin-bottom: 0; }

.link-label { color: var(--muted-soft); }

.external { font-size: 0.85em; }

/* Gmail address — the one blue accent in an otherwise grayscale site.
   Kept on one line so the address never splits mid-word. */
.email {
  color: #1a73e8;
  white-space: nowrap;
  overflow-wrap: normal;
}
.email:hover { color: #0b57d0; }

/* Elsewhere: label column + aligned link column. */
.elsewhere-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.elsewhere-list li {
  display: grid;
  grid-template-columns: 4.25rem 1fr;
  align-items: baseline;
  column-gap: 1rem;
  margin-bottom: 0.35rem;
}

.elsewhere-list li:last-child { margin-bottom: 0; }

/* Pages section: the current page is darkened and marked with an arrow. */
.page-link { color: var(--muted-soft); }
.page-link:hover { color: var(--ink); }
.page-link.is-active {
  color: var(--ink);
  font-weight: 600;
}

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

/* ---------- Connect ---------- */

/* Quiet contact form under "Pages" — hairline underline inputs keep the
   text-first language of the rest of the column. */
.connect-form {
  display: grid;
  gap: 0.7rem;
}

/* Honeypot field: rendered but invisible and unreachable for humans. */
.hp {
  position: absolute !important;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.connect-form input:not(.hp),
.connect-form textarea {
  width: 100%;
  padding: 0.25rem 0;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.875rem;
}

.connect-form textarea {
  resize: vertical;
  min-height: 3.2rem;
}

.connect-form ::placeholder {
  color: var(--muted-soft);
  opacity: 1;
}

.connect-form input:focus,
.connect-form textarea:focus {
  border-bottom-color: var(--ink);
}
/* Keyboard focus keeps the site-wide outline; mouse focus darkens the hairline. */

.connect-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.connect-form button {
  padding: 0.26rem 0.8rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78125rem;
  line-height: 1.4;
  cursor: pointer;
}

.connect-form button:hover {
  color: var(--ink);
  border-color: var(--muted-soft);
}

.connect-form button:disabled {
  opacity: 0.55;
  cursor: default;
}

.connect-status {
  min-height: 1em;
  color: var(--muted-soft);
  font-size: 0.8125rem;
}

/* ---------- Images gallery ---------- */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
  align-items: start;
}

.gallery-item { margin: 0; }

.gallery-item a {
  display: block;
  overflow: hidden;
  border-radius: 6px;
  background-image: none;
}

.gallery-item img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: var(--code-bg);
  transition: transform 320ms ease;
}

.gallery-item a:hover img,
.gallery-item a:focus-visible img {
  transform: scale(1.02);
}

.gallery-item figcaption {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---------- Numbered writing index ---------- */

.numbered-list { margin-top: 0; }

.numbered-item {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  padding: 1.15rem 0;
  border-top: 1px solid var(--rule);
}

.numbered-item:last-child { border-bottom: 1px solid var(--rule); }

/* The subtle index number — deliberately small, light, and top-aligned.
   Kept on one line so "01" never wraps into "0 / 1" on narrow columns. */
.num {
  padding-top: 0.3rem;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--num);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

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

.numbered-title {
  margin: 0;
  font-size: 1.1875rem;
  line-height: 1.35;
}

.numbered-desc {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.numbered-body time {
  display: block;
  margin-top: 0.3rem;
  color: var(--muted-soft);
  font-size: 0.8125rem;
  font-variant-numeric: oldstyle-nums;
}

/* ---------- Post ---------- */

.post-back,
.post-back a { color: var(--muted); }

.post-back a { font-size: 0.875rem; }
.post-back:hover a { text-decoration: underline; }

.post-head time {
  color: var(--muted-soft);
  font-size: 0.875rem;
  font-variant-numeric: oldstyle-nums;
}

.post-head h1 {
  margin: 0.5rem 0 0.75rem;
  font-size: clamp(1.55rem, 4.5vw, 1.95rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  font-weight: 600;
}

.post-description {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.post-tags {
  margin: 1.25rem 0 0;
  color: var(--muted-soft);
  font-size: 0.875rem;
}

/* ---------- Prose (rendered markdown) ---------- */

.prose {
  margin-top: 2.25rem;
  font-size: 1rem;
  line-height: 1.7;
}

.prose h2 {
  margin: 2.4rem 0 0.8rem;
  font-size: 1.375rem;
  line-height: 1.35;
}

.prose h3 {
  margin: 1.8rem 0 0.6rem;
  font-size: 1.125rem;
  line-height: 1.35;
}

.prose p { margin: 0 0 1.1rem; }

.prose ul,
.prose ol { margin: 0 0 1.1rem; padding-left: 1.5rem; }

.prose li { margin-bottom: 0.35rem; }
.prose li:last-child { margin-bottom: 0; }

.prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.12em 0.35em;
  border-radius: 3px;
}

.prose pre {
  margin: 0 0 1.4rem;
  padding: 1rem 1.1rem;
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow-x: auto;
  line-height: 1.55;
}

.prose pre code {
  display: block;
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 0.88em;
}

.code-lang {
  display: block;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.7rem;
  color: var(--muted-soft);
  font-family: var(--font-sans);
}

.prose blockquote {
  margin: 0 0 1.1rem;
  padding-left: 1rem;
  border-left: 3px solid var(--rule);
  color: var(--muted);
}

.prose blockquote p:last-child { margin-bottom: 0; }

.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.75rem auto;
  border-radius: 4px;
}

.prose hr {
  margin: 2.5rem 0;
  border: 0;
  border-top: 1px solid var(--rule);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.1rem;
  font-size: 0.95rem;
}

.prose th,
.prose td {
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

/* ---------- Motion ---------- */

/* Reveal-on-scroll is opt-in: the head script adds `.reveal-on` to <html>
   only when the browser supports IntersectionObserver and motion is allowed.
   Without it, content is visible by default — the page can never blank. */
.reveal-on .reveal {
  opacity: 0;
  transform: translateY(0.6rem);
  transition: opacity 520ms ease, transform 520ms ease;
  transition-delay: var(--reveal-delay, 0ms);
}

.reveal-on .reveal.is-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal-on .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .gallery-item img { transition: none; }
}

/* ---------- Reading progress (post pages only) ---------- */

.progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--ink);
  z-index: 80;
  pointer-events: none;
}

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 12, 12, 0.92);
  opacity: 0;
  visibility: hidden;
  transition: opacity 240ms ease, visibility 240ms;
}

.lightbox.is-open {
  opacity: 1;
  visibility: visible;
}

.lightbox img {
  max-width: 92vw;
  max-height: 82vh;
  border-radius: 6px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
}

.lightbox .lb-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1.25rem;
  text-align: center;
  color: #ddd;
  font-size: 0.875rem;
  padding-inline: 2.5rem;
}

.lightbox .lb-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  min-width: 3rem;
  height: 3rem;
  border: 0;
  background: transparent;
  color: #eee;
  font-size: 1.4rem;
  cursor: pointer;
  border-radius: 999px;
}

.lightbox .lb-btn:hover { background: rgba(255, 255, 255, 0.12); }
.lightbox .lb-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.lightbox .lb-prev { left: 0.75rem; }
.lightbox .lb-next { right: 0.75rem; }

.lightbox .lb-close {
  top: auto;
  bottom: 0.65rem;
  right: 0.65rem;
  transform: none;
  font-size: 1rem;
}

@media (max-width: 720px) {
  .lightbox .lb-caption { display: none; }
}

/* ---------- Responsive ---------- */

/* Narrow screens: stack the two columns. The "Common" block keeps a bottom
   border as a separator before the page content, like the reference. */
@media (max-width: 720px) {
  .wrap {
    grid-template-columns: 1fr;
    column-gap: 0;
  }

  .wrap .rule { display: none; }

  .wrap .col-left {
    border-bottom: 1px solid var(--rule);
    padding-bottom: 1.5rem;
    margin-bottom: 1rem;
  }

  .site-main:has(.wrap) { max-width: var(--measure); }
}

@media (max-width: 420px) {
  :root { --pad: 1rem; }
  .site-main { padding-top: 2.25rem; }
  .elsewhere-list li { grid-template-columns: 4.25rem 1fr; }
}

/* ---------- Dark mode ---------- */

/* Theme is set by a head script as data-theme="light"|"dark" on <html>.
   It defaults to the OS preference until the visitor toggles it. */
html[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0f0f0f;
  --ink: #f2f2f2;
  --text: #c9c9c9;
  --muted: #a3a3a3;
  --muted-soft: #909090;
  --rule: #262626;
  --code-bg: #1a1a1a;
  --num: #747474;
}

/* Gmail blue, softened for dark backgrounds. */
html[data-theme='dark'] .email { color: #8ab4f8; }
html[data-theme='dark'] .email:hover { color: #a8c7fa; }