/* ——————————————————————————————————————————————
   Mark & Spencer — site styles
   Warm paper, one serif, mono for the small print.
   —————————————————————————————————————————————— */

/* Newsreader (OFL), self-hosted — variable opsz 6..72 / wght 300..700 */
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('fonts/newsreader-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Newsreader';
  font-style: italic;
  font-weight: 300 700;
  font-display: swap;
  src: url('fonts/newsreader-latin-italic.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('fonts/newsreader-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Newsreader';
  font-style: italic;
  font-weight: 300 700;
  font-display: swap;
  src: url('fonts/newsreader-latin-ext-italic.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light dark;
  --paper: #f6f2e9;
  --paper-2: #eee9db;
  --ink: #211e19;
  --ink-2: #6e685a;
  --faint: #736d5e;
  --line: #ddd6c4;
  --accent: #9c4a26;
  --serif: 'Newsreader', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16140f;
    --paper-2: #1e1b14;
    --ink: #e8e3d5;
    --ink-2: #a49d8a;
    --faint: #8f8875;
    --line: #2d2a20;
    --accent: #d98e5f;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--serif);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(156, 74, 38, 0.18); }

/* faint paper grain */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
  opacity: 0.028;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
}

.page {
  max-width: 1060px;
  margin: 0 auto;
  padding: 48px 28px 40px;
}

.measure { max-width: 640px; }

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

/* ——— small print (mono) ——— */

.small-print {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-2);
}

/* ——— masthead ——— */

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--ink);
}

.masthead h1 {
  font-size: clamp(34px, 5vw, 46px);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.masthead h1 .amp { font-style: italic; font-weight: 400; }

.masthead nav {
  display: flex;
  gap: 26px;
}

.masthead nav a { position: relative; padding-bottom: 2px; }

.masthead nav a:hover,
.masthead nav a[aria-current] { color: var(--accent); }

.tagline {
  margin-top: 10px;
  color: var(--faint);
}

/* ——— index of entries ——— */

.contents { margin: 52px 0 96px; }

.contents .small-print { margin-bottom: 18px; color: var(--faint); }

.contents ol {
  list-style: none;
  max-width: 640px;
}

.contents li { margin: 0; }

.contents a {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 7px 0;
}

.contents .no {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--faint);
  flex: none;
  width: 22px;
}

.contents .t {
  font-size: 17px;
  line-height: 1.4;
}

.contents a:hover .t { color: var(--accent); }

/* ——— entries ——— */

.entry {
  margin-bottom: 110px;
  scroll-margin-top: 32px;
}

.entry-head { max-width: 640px; }

.entry-head .small-print { color: var(--faint); margin-bottom: 10px; }

.entry-head .small-print a { color: inherit; }

.entry-head .small-print a:hover { color: var(--accent); }

.entry h2 {
  font-size: clamp(24px, 3.2vw, 30px);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.005em;
}

.entry .note {
  margin-top: 12px;
  font-style: italic;
  font-size: 17.5px;
  line-height: 1.65;
  color: var(--ink-2);
}

.entry .body {
  max-width: 640px;
  margin-top: 26px;
  font-size: 18px;
  line-height: 1.75;
}

.entry .body p + p { margin-top: 18px; }

/* ——— filmstrip ——— */

.strip {
  display: flex;
  gap: 16px;
  margin-top: 28px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  cursor: grab;
  padding: 2px 2px 6px;
}

.strip::-webkit-scrollbar { display: none; }

.strip.dragging { cursor: grabbing; scroll-snap-type: none; }

.strip figure {
  flex: none;
  scroll-snap-align: start;
}

.strip img,
.strip video {
  height: clamp(250px, 40vw, 420px);
  width: auto;
  max-width: 88vw;
  object-fit: cover;
  display: block;
  border-radius: 2px;
  background: var(--paper-2);
  outline: 1px solid var(--line);
  outline-offset: -1px;
}

.strip img {
  cursor: zoom-in;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.strip.dragging img { cursor: grabbing; }

.strip figure { width: min-content; }

.strip figcaption {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--faint);
  margin-top: 9px;
  min-width: 100%;
  width: 0;
  line-height: 1.5;
  text-transform: lowercase;
}

/* ——— lightbox ——— */

dialog.lightbox {
  margin: auto; /* the * reset above removes the UA's auto-centering */
  border: none;
  padding: 0;
  background: transparent;
  max-width: 100vw;
  max-height: 100vh;
  max-height: 100dvh; /* iOS: the real viewport, toolbar included */
  outline: none;
  overscroll-behavior: contain;
}

dialog.lightbox::backdrop {
  background: rgba(18, 15, 10, 0.93);
}

/* keep the page still underneath the lightbox */
body:has(dialog.lightbox[open]) { overflow: hidden; }

.lightbox .frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px 24px calc(24px + env(safe-area-inset-bottom, 0px));
  touch-action: pan-y;
}

.lightbox img {
  max-width: min(92vw, 1400px);
  max-height: 82vh;
  max-height: 82dvh;
  display: block;
  border-radius: 2px;
}

.lightbox .bar {
  display: flex;
  align-items: center;
  gap: 18px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: #b5ad9c;
  max-width: 92vw;
}

.lightbox button {
  font-family: var(--mono);
  font-size: 13px;
  background: none;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 2px;
  color: #d8d2c4;
  padding: 4px 12px;
  cursor: pointer;
  position: relative;
  touch-action: manipulation;
}

/* invisible touch-target extension to ~44px */
.lightbox button::after {
  content: '';
  position: absolute;
  inset: -8px -6px;
}

.lightbox button:hover { border-color: rgba(255,255,255,0.6); }

/* ——— footer ——— */

footer.colophon {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

footer.colophon a:hover { color: var(--accent); }

/* ——— writing ——— */

.essay-list { margin-top: 56px; }

.essay-list .item {
  display: block;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
  max-width: 640px;
}

.essay-list .item:first-child { border-top: 1px solid var(--line); }

.essay-list .date {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.essay-list h2 {
  font-size: 24px;
  font-weight: 500;
  margin-top: 6px;
  line-height: 1.3;
}

.essay-list .summary {
  margin-top: 6px;
  color: var(--ink-2);
  font-size: 16.5px;
}

.essay-list .item:hover h2 { color: var(--accent); }

/* ——— essay page ——— */

article.essay {
  max-width: 640px;
  margin: 72px auto 0;
}

article.essay .date {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
}

article.essay h1 {
  font-size: clamp(30px, 4.4vw, 40px);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 12px 0 36px;
}

article.essay p {
  font-size: 19px;
  line-height: 1.78;
  margin-bottom: 22px;
}

article.essay h2 {
  font-size: 23px;
  font-weight: 500;
  margin: 40px 0 14px;
}

article.essay a {
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}

article.essay a:hover { color: var(--accent); text-decoration-color: var(--accent); }

article.essay blockquote {
  border-left: 2px solid var(--line);
  padding-left: 20px;
  font-style: italic;
  color: var(--ink-2);
  margin-bottom: 22px;
}

article.essay hr {
  border: none;
  text-align: center;
  margin: 36px 0;
}

article.essay hr::after {
  content: '· · ·';
  color: var(--faint);
  letter-spacing: 0.6em;
}

.essay-footer {
  max-width: 640px;
  margin: 56px auto 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.essay-footer a:hover { color: var(--accent); }

/* ——— misc ——— */

.loading-note {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 40px 0;
}

@media (max-width: 620px) {
  .page { padding: 32px 18px 32px; }
  .contents { margin: 36px 0 64px; }
  .entry { margin-bottom: 76px; }
  .strip { gap: 12px; }
  .masthead nav { gap: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@media print {
  :root {
    --paper: #fff;
    --paper-2: #f2f2f2;
    --ink: #000;
    --ink-2: #444;
    --faint: #555;
    --line: #ccc;
    --accent: #000;
  }
  body::after { display: none; }
  .masthead nav, footer.colophon, #floating-home { display: none; }
  .strip { flex-wrap: wrap; overflow: visible; }
}
