/* ---------- Tokens ---------- */
:root {
  --paper: #f6f1e7;
  --paper-2: #efe7d8;
  --card: #fffdf8;
  --ink: #1b1a17;
  --ink-soft: #57524a;
  --rule: #ddd3c1;
  --red: #d7261e;
  --red-deep: #7b1f1f;
  --blue: #2c5aa8;
  --display: "Oswald", "Arial Narrow", sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16140f;
    --paper-2: #1e1b15;
    --card: #221f19;
    --ink: #f1ebdf;
    --ink-soft: #b3aa9a;
    --rule: #3a3429;
    --red: #ff5a4a;
    --red-deep: #ff8a78;
    --blue: #8fb0ff;
  }
}

/* ---------- Base ---------- */
html { scroll-behavior: smooth; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.65;
  overflow-x: hidden;
  padding-top: 72px;
}
body .main-container { max-width: 1160px; padding: 0 24px; }
a { color: var(--red-deep); text-decoration: none; background-image: linear-gradient(currentColor, currentColor); background-size: 0 1px; background-position: 0 100%; background-repeat: no-repeat; transition: background-size .3s var(--ease), color .2s; }
a:hover, a:focus { color: var(--red); text-decoration: none; background-size: 100% 1px; }
::selection { background: var(--red); color: #fff; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: .01em; color: var(--ink); text-transform: uppercase; line-height: 1.05; }
img { max-width: 100%; }

/* ---------- Navbar ---------- */
.navbar-default {
  background: transparent;
  border: 0;
  min-height: 72px;
  transition: background .3s, box-shadow .3s, backdrop-filter .3s;
}
.navbar-default.scrolled {
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 var(--rule);
}
.navbar-default .navbar-brand {
  font-family: var(--display); font-weight: 700; text-transform: uppercase;
  font-size: 22px; letter-spacing: .04em; color: var(--ink); height: 72px; line-height: 40px;
  background: none;
}
.navbar-default .navbar-brand:hover { color: var(--red); }
.navbar-default .navbar-nav > li > a {
  font-family: var(--sans); font-weight: 600; font-size: 14px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-soft); line-height: 40px; position: relative; background: none;
}
.navbar-default .navbar-nav > li > a::after {
  content: ""; position: absolute; left: 15px; right: 15px; bottom: 22px; height: 2px;
  background: var(--red); transform: scaleX(0); transform-origin: left; transition: transform .3s var(--ease);
}
.navbar-default .navbar-nav > li > a:hover { color: var(--ink); background: none; }
.navbar-default .navbar-nav > li > a:hover::after,
.navbar-default .navbar-nav > .active > a::after { transform: scaleX(1); }
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus { background: none; color: var(--ink); }
.navbar-default .navbar-toggle { border-color: var(--rule); margin-top: 19px; }
.navbar-default .navbar-toggle .icon-bar { background: var(--ink); }
.navbar-default .navbar-collapse { border: 0; box-shadow: none; }
@media (max-width: 767px) {
  .navbar-default .navbar-collapse { background: var(--paper); }
  .navbar-default .navbar-nav > li > a::after { display: none; }
}

/* ---------- Reveal animations ---------- */
.js .reveal, .js .entries > p, .js .chips > p, .js .section-block {
  opacity: 0; transform: translateY(24px);
  transition: opacity .8s var(--ease), transform .8s var(--ease);
  transition-delay: calc(var(--i, 0) * 70ms);
}
.js .in { opacity: 1 !important; transform: none !important; }

/* ---------- Hero ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 40px; align-items: center;
  min-height: calc(100vh - 150px); padding: 24px 0 56px;
}
.eyebrow, .kicker, .meta, .num {
  font-family: var(--sans); font-size: 13px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--red);
}
.eyebrow { display: inline-block; }
.eyebrow::before { content: ""; display: inline-block; width: 36px; height: 2px; background: var(--red); vertical-align: middle; margin-right: 12px; }
.hero-name {
  font-size: clamp(60px, 9.5vw, 132px); font-weight: 700; line-height: .9; margin: 18px 0 28px; letter-spacing: -.005em;
}
.hero-name .line { display: block; overflow: hidden; padding-bottom: .04em; }
.hero-name .line > span { display: inline-block; animation: rise 1s var(--ease) both; }
.hero-name .line:nth-child(2) > span { animation-delay: .12s; color: var(--red); }
@keyframes rise { from { transform: translateY(105%); } to { transform: none; } }
.hero-lede { font-size: 21px; color: var(--ink-soft); max-width: 34em; }
.hero-lede p { margin: 0; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 32px; }
.hero-actions p { display: contents; }
.btn-primary-x, .btn-ghost {
  font-family: var(--sans); font-weight: 600; font-size: 15px; letter-spacing: .02em;
  padding: 14px 24px; border-radius: 999px; background-image: none; transition: transform .25s var(--ease), box-shadow .25s, background .25s, color .25s;
}
.btn-primary-x { background: var(--red); color: #fff; box-shadow: 0 8px 24px -10px var(--red); }
.btn-primary-x:hover, .btn-primary-x:focus { color: #fff; transform: translateY(-2px); box-shadow: 0 14px 30px -10px var(--red); }
.btn-ghost { color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.btn-ghost:hover, .btn-ghost:focus { background: var(--ink); color: var(--paper); }

/* Fanned stack of covers */
.cover-stack { position: relative; height: 480px; }
.cover-stack p { margin: 0; }
.cover {
  position: absolute; top: 50%; left: 50%; width: 46%; aspect-ratio: 2 / 3; background: none;
  box-shadow: 0 30px 50px -20px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.15);
  border-radius: 3px; overflow: hidden;
  transition: transform .6s var(--ease), box-shadow .4s;
  animation: dealIn 1.1s var(--ease) both;
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover.c1 { transform: translate(-105%, -46%) rotate(-10deg); animation-delay: .25s; }
.cover.c2 { transform: translate(-50%, -54%) rotate(0deg); z-index: 2; animation-delay: .35s; }
.cover.c3 { transform: translate(5%, -46%) rotate(9deg); z-index: 3; animation-delay: .45s; }
.cover-stack:hover .c1 { transform: translate(-128%, -48%) rotate(-14deg); }
.cover-stack:hover .c3 { transform: translate(28%, -48%) rotate(13deg); }
.cover:hover { z-index: 5 !important; box-shadow: 0 40px 60px -20px rgba(0,0,0,.55); }
.cover-stack .cover.c2:hover { transform: translate(-50%, -60%) rotate(0deg) scale(1.04); }
@keyframes dealIn { from { opacity: 0; margin-top: 60px; } to { opacity: 1; margin-top: 0; } }

/* ---------- Ticker ---------- */
.ticker {
  width: 100vw; margin-left: calc(50% - 50vw); overflow: hidden;
  background: var(--ink); color: var(--paper); padding: 18px 0;
  transform: rotate(-1.2deg); margin-top: 8px; margin-bottom: 40px;
}
.ticker-track { display: flex; width: max-content; animation: marquee 32s linear infinite; }
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker span {
  font-family: var(--display); font-size: 28px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
  padding: 0 28px; white-space: nowrap;
}
.ticker span::after { content: "✦"; color: var(--red); font-size: 18px; margin-left: 56px; vertical-align: middle; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- Books band ---------- */
.band { padding: 72px 0 40px; }
.band h2, .contact h2 { font-size: clamp(34px, 5vw, 56px); margin: 10px 0 48px; max-width: 14em; }
.book-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 40px; }
.book .book-cover {
  display: block; aspect-ratio: 2 / 3; border-radius: 3px; overflow: hidden; background: none;
  box-shadow: 0 20px 40px -18px rgba(0,0,0,.45);
  transition: transform .35s var(--ease), box-shadow .35s; will-change: transform;
}
.book .book-cover:hover { box-shadow: 0 34px 50px -18px rgba(0,0,0,.55); }
.book .book-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.book p { margin: 0; }
.book .meta { display: block; margin-top: 22px; font-size: 12px; color: var(--ink-soft); }
.book h3 { font-size: 30px; margin: 8px 0 6px; }
.book h3 a { color: var(--ink); }
.book h3 a:hover { color: var(--red); }
.book .section p { color: var(--ink-soft); font-style: italic; font-size: 17px; line-height: 1.45; }

/* ---------- Contact ---------- */
.contact {
  position: relative; margin: 64px 0 80px; padding: 56px 48px; border-radius: 20px; overflow: hidden;
  background: var(--red); color: #fff;
}
.contact::before {
  content: "@"; position: absolute; right: -20px; bottom: -120px; font-family: var(--display); font-weight: 700;
  font-size: 420px; line-height: 1; color: rgba(255,255,255,.1); pointer-events: none;
  animation: drift 12s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate(-30px, -20px) rotate(-8deg); } }
.contact .kicker, .contact h2 { color: #fff; }
.contact h2 { margin-bottom: 12px; }
.contact p { font-size: 20px; margin: 0 0 20px; position: relative; }
.contact a.email {
  display: inline-block; font-family: var(--display); font-size: clamp(26px, 4.4vw, 44px); font-weight: 600;
  color: #fff; background-image: linear-gradient(#fff, #fff); background-size: 100% 2px; cursor: pointer;
}
.contact a.email:hover { background-size: 0 2px; background-position: 100% 100%; }

/* ---------- Writings page ---------- */
#header { padding: 48px 0 8px; }
#header h1.title { font-size: clamp(56px, 10vw, 128px); font-weight: 700; margin: 0; animation: rise 1s var(--ease) both; }
#header h1.title::after { content: "."; color: var(--red); }
.page-intro { font-size: 22px; color: var(--ink-soft); max-width: 32em; margin-bottom: 56px; }
.section-block {
  display: grid; grid-template-columns: 90px 1fr; column-gap: 24px;
  border-top: 2px solid var(--ink); padding: 28px 0 56px;
}
.section-block > p:first-child { margin: 0; grid-row: 1 / span 2; }
.section-block .num { font-family: var(--display); font-size: 44px; font-weight: 700; letter-spacing: 0; line-height: 1; color: var(--red); }
.section-block > .section, .section-block > .entries, .section-block > .chips, .section-block > .feed { grid-column: 2; }
.section-block h1 { font-size: 40px; margin: 0 0 24px; }

.entries > p {
  position: relative; margin: 0; padding: 20px 56px 20px 0; border-bottom: 1px solid var(--rule);
  transition: padding .3s var(--ease), background .3s;
}
.entries > p::after {
  content: "→"; position: absolute; right: 12px; top: 50%; font-family: var(--sans); color: var(--red);
  transform: translate(-8px, -50%); opacity: 0; transition: transform .3s var(--ease), opacity .3s;
}
.entries > p:hover { padding-left: 16px; background: var(--paper-2); }
.entries > p:hover::after { opacity: 1; transform: translate(0, -50%); }
.entries > p a { font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 12px; }
.chips > p { margin: 0; }
.chips > p, .chips > p a {
  font-family: var(--sans); font-size: 15px; font-weight: 600;
}
.chips > p {
  padding: 10px 18px; border-radius: 999px; border: 1.5px solid var(--rule); color: var(--ink-soft);
  transition: border-color .25s, transform .25s var(--ease), background .25s;
}
.chips > p:has(a) { border-color: var(--ink); }
.chips > p:has(a):hover { background: var(--ink); transform: translateY(-3px); }
.chips > p a { color: var(--ink); background: none; }
.chips > p a em { font-style: normal; }
.chips > p:has(a):hover a { color: var(--paper); }

/* Substack cards */
.feed { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.feed-loading { color: var(--ink-soft); font-style: italic; }
.post {
  position: relative; display: flex; flex-direction: column; gap: 8px; padding: 24px 24px 48px;
  background: var(--card); border: 1px solid var(--rule); border-radius: 14px; color: var(--ink);
  background-image: none; overflow: hidden;
  transition: transform .35s var(--ease), box-shadow .35s, border-color .35s;
}
.post::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--red);
  transform: scaleX(0); transform-origin: left; transition: transform .4s var(--ease);
}
.post:hover, .post:focus { color: var(--ink); transform: translateY(-6px); box-shadow: 0 24px 40px -24px rgba(0,0,0,.4); border-color: transparent; }
.post:hover::before, .post:focus::before { transform: scaleX(1); }
.post-date { font-family: var(--sans); font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--red); }
.post-title { font-family: var(--display); font-size: 24px; font-weight: 600; line-height: 1.15; text-transform: uppercase; }
.post-excerpt { font-size: 16px; line-height: 1.5; color: var(--ink-soft); }
.post-arrow { position: absolute; left: 24px; bottom: 16px; font-family: var(--sans); color: var(--red); transition: transform .3s var(--ease); }
.post:hover .post-arrow { transform: translateX(8px); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; min-height: 0; gap: 16px; }
  .cover-stack { height: 380px; max-width: 460px; width: 100%; margin: 0 auto; }
  .book-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  body { font-size: 18px; }
  body .main-container { padding: 0 16px; }
  .cover-stack { height: 300px; }
  .book-grid { grid-template-columns: 1fr; max-width: 340px; }
  .section-block { grid-template-columns: 1fr; }
  .section-block > p:first-child { grid-row: auto; margin-bottom: 8px; }
  .section-block > * { grid-column: 1 !important; }
  .contact { padding: 40px 24px; }
  .ticker span { font-size: 22px; }
}

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

.more-link {
  display: inline-block; margin-top: 20px; font-family: var(--sans); font-weight: 600; font-size: 15px;
  padding: 10px 20px; border-radius: 999px; background-image: none; box-shadow: inset 0 0 0 1.5px var(--red); color: var(--red);
  transition: background .25s, color .25s;
}
.more-link:hover, .more-link:focus { background: var(--red); color: #fff; }
.section-block .section > p:has(.more-link) { margin: 0; }
