/* Inner pages (blog posts, Writing index, projects). Builds on style.css. */
body.inner { background: var(--bg); }
body.inner main { padding: 0 var(--gutter); }
.inner .eyebrow a { text-decoration: none; color: var(--coral); }

/* ---- header: text + a floating printed card, like the 3D ones ---- */
.post-head, .index-head {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 360px); gap: 48px; align-items: center;
  padding: 140px 0 56px; border-bottom: 1px solid var(--line);
}
.post-head h1, .index-head h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(40px, 5.4vw, 80px); line-height: 1; letter-spacing: -.01em; margin: 0 0 22px; text-wrap: balance; }
.post-head .lede, .index-head .lede { font-size: clamp(17px, 1.4vw, 21px); max-width: 52ch; color: #d9d4ca; margin: 0 0 22px; }
.count { color: var(--coral); font-size: .5em; vertical-align: super; }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; }
.tags li { font-size: 12px; padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--dim); }

.paper-wrap { perspective: 1200px; }
.paper {
  --bg-p: #efe8da; --fg-p: #1a1c24; --ac-p: #ff6b4a;
  aspect-ratio: 7 / 10; background: var(--bg-p); color: var(--fg-p);
  padding: 7% 7% 6%; display: flex; flex-direction: column;
  box-shadow: 0 40px 60px -30px #000, 0 2px 0 rgba(0,0,0,.15);
  transform: rotateX(6deg) rotateY(-14deg) rotateZ(-3deg);
  animation: paper-float 7s ease-in-out infinite;
}
.paper--coral { --bg-p: #ff6b4a; --fg-p: #1f0f0b; --ac-p: #1f0f0b; }
.paper--sky   { --bg-p: #9fcbff; --fg-p: #0d1b33; --ac-p: #0d1b33; }
.paper--ink   { --bg-p: #161c30; --fg-p: #f2ede3; --ac-p: #ff6b4a; }
.paper-top, .paper-foot { display: flex; justify-content: space-between; font-size: 11px; font-weight: 500; letter-spacing: .03em; text-transform: uppercase; }
.paper-top { border-bottom: 1.5px solid currentColor; padding-bottom: 8px; }
.paper-foot { border-top: 1.5px solid currentColor; padding-top: 8px; margin-top: auto; }
.paper-arrow { color: var(--ac-p); font-size: 15px; }
.paper-title { font-family: var(--serif); font-size: clamp(24px, 2.5vw, 38px); line-height: .95; margin-top: 14px; overflow: hidden; text-wrap: balance; }
.paper--s1 .paper-title { font-family: var(--sans); font-weight: 700; font-size: clamp(19px, 2vw, 30px); line-height: 1.02; }
.paper--s2 .paper-title { font-style: italic; }
@keyframes paper-float {
  0%, 100% { transform: rotateX(6deg) rotateY(-14deg) rotateZ(-3deg) translateY(0); }
  50%      { transform: rotateX(2deg) rotateY(-9deg) rotateZ(-1.5deg) translateY(-12px); }
}
@media (prefers-reduced-motion: reduce), (max-width: 700px), (hover: none) { .paper { animation: none; } }

/* index page: three cards fanned like a hand */
.paper-stack { position: relative; height: 420px; }
.paper-stack .paper-wrap { position: absolute; width: 62%; top: 0; left: 19%; }
.paper-stack .paper-wrap:nth-child(1) { transform: translate(-28%, 24px) rotate(-9deg); }
.paper-stack .paper-wrap:nth-child(2) { transform: translate(28%, 18px) rotate(8deg); }
.paper-stack .paper-wrap:nth-child(3) { z-index: 2; }
.paper-stack .paper-wrap:nth-child(1) .paper { animation-delay: -2s; }
.paper-stack .paper-wrap:nth-child(2) .paper { animation-delay: -4s; }

/* ---- article body ---- */
.prose { max-width: 720px; padding: 48px 0 24px; font-size: 18px; line-height: 1.7; color: #e3ded4; }
.prose h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(30px, 3vw, 42px); line-height: 1.05; margin: 48px 0 14px; color: var(--ink); }
.prose h3 { font-family: var(--serif); font-weight: 400; font-size: 28px; margin: 36px 0 10px; color: var(--ink); }
.prose h4 { font-size: 15px; letter-spacing: .04em; text-transform: uppercase; color: var(--coral); margin: 28px 0 8px; }
.prose p { margin: 0 0 18px; }
.prose strong { color: var(--ink); }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 20px; }
.prose li { margin: 6px 0; }
.prose li::marker { color: var(--coral); }
.prose code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em; background: rgba(242,237,227,.08); padding: 2px 6px; border-radius: 4px; }
.prose pre { background: #070b16; border: 1px solid var(--line); padding: 18px 20px; overflow-x: auto; border-radius: 6px; margin: 0 0 22px; }
.prose pre code { background: none; padding: 0; font-size: 14px; line-height: 1.55; }
.prose blockquote { margin: 0 0 20px; padding: 4px 0 4px 18px; border-left: 3px solid var(--coral); color: var(--ink); font-family: var(--serif); font-size: 24px; line-height: 1.3; }
.prose .table { overflow-x: auto; margin: 0 0 24px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 15px; line-height: 1.45; }
.prose th, .prose td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { color: var(--dim); font-weight: 500; font-size: 13px; letter-spacing: .03em; text-transform: uppercase; }

/* ---- next / previous ---- */
.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 40px 0 28px; border-top: 1px solid var(--line); padding-top: 24px; max-width: 980px; }
.post-nav-link { text-decoration: none; display: block; }
.post-nav-link small { display: block; color: var(--dim); font-size: 13px; margin-bottom: 6px; }
.post-nav-link span { font-family: var(--serif); font-size: 24px; line-height: 1.1; }
.post-nav-link.right { text-align: right; }
.post .ctas { margin-bottom: 80px; }

/* ---- Writing index ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: inherit; font-size: 13px; color: var(--ink); background: none; border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; cursor: pointer; transition: border-color .2s, color .2s, background .2s; }
.chip:hover { border-color: var(--coral); color: var(--coral); }
.chip.is-on { background: var(--coral); border-color: var(--coral); color: #1f0f0b; }
.index-list { padding: 24px 0 80px; }
.index-list .works { max-width: 980px; }
.index-list .work { grid-template-columns: 70px 1fr auto; }
.index-list .work-title { font-size: clamp(22px, 2vw, 30px); }
.index-list .work-title small { display: block; font-family: var(--sans); font-size: 14px; line-height: 1.5; color: var(--dim); margin-top: 6px; max-width: 70ch; }

@media (max-width: 800px) {
  .post-head, .index-head { grid-template-columns: 1fr; padding-top: 110px; }
  .post-head .paper-wrap { max-width: 240px; order: -1; }
  .paper-stack { height: 300px; max-width: 360px; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav-link.right { text-align: left; }
  .index-list .work { grid-template-columns: 1fr; gap: 4px; }
  .index-list .work-meta { text-align: left; }
}

/* ---- Writing index: one screen, the revolving globe of papers in the middle (globe.js) ---- */
body.globe-page { height: 100vh; height: 100svh; overflow: hidden; }
body.globe-page .foot { display: none; }
.globe-stage {
  position: fixed; inset: 0; z-index: 1;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; justify-items: center;
  padding: 72px var(--gutter) 22px; text-align: center;
}
.globe-title .eyebrow { margin: 0 0 6px; }
.globe-title h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(38px, 4.6vw, 68px); line-height: 1; margin: 0 0 8px; }
.globe-title .lede { margin: 0 auto; max-width: 56ch; color: #d9d4ca; font-size: clamp(14px, 1.15vw, 17px); }
.globe-controls { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.globe-controls .chips { justify-content: center; }
.globe-page .globe-hint { position: static; }
.globe-page .globe { width: 100%; height: 100%; min-height: 0; touch-action: none; }
.globe { position: relative; height: min(78vh, 760px); touch-action: pan-y; cursor: grab; user-select: none; }
.globe canvas { width: 100%; height: 100%; display: block; }
.globe-tip {
  position: absolute; left: 0; top: 0; max-width: 300px; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 4px;
  font-family: var(--serif); font-size: 20px; line-height: 1.1;
  opacity: 0; transition: opacity .15s; box-shadow: 0 14px 30px -12px #000;
}
.globe-tip small { display: block; font-family: var(--sans); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: #55565c; margin-bottom: 4px; }
.globe-tip.on { opacity: 1; }

/* The big preview card beside the globe (globe.js): hover a paper, then click the card. */
.globe-card {
  position: fixed; z-index: 5; right: var(--gutter); top: 50%;
  width: min(380px, 27vw); text-decoration: none; color: inherit;
  transform: translate(24px, -50%) rotate(2deg); opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .45s var(--ease);
}
.globe-card.on { opacity: 1; pointer-events: auto; transform: translate(0, -50%) rotate(-1.5deg); }
.globe-card:hover { transform: translate(0, -50%) rotate(0deg) scale(1.02); }
.globe-card-paper { animation: none; transform: none; aspect-ratio: 7 / 10; padding: 26px 26px 22px; box-shadow: 0 40px 70px -30px #000, 0 2px 0 rgba(0,0,0,.2); }
.globe-card .gc-cat { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin-top: 16px; opacity: .75; }
.globe-card .gc-title { font-size: clamp(30px, 2.6vw, 44px); line-height: .98; margin-top: 8px; overflow: visible; }
.globe-card .gc-sum { font-size: 15px; line-height: 1.45; margin: 16px 0 0; opacity: .85; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.globe-card .paper-foot { align-items: center; }
.globe-card .gc-read {
  font-size: 15px; font-weight: 700; letter-spacing: 0; text-transform: none;
  background: var(--ac-p); color: var(--bg-p); padding: 10px 16px; border-radius: 999px;
  transition: transform .2s;
}
.globe-card:hover .gc-read { transform: translateX(4px); }
.gc-close {
  position: absolute; top: -12px; right: -12px; width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 18px; line-height: 1; cursor: pointer;
}
.gc-close:hover { border-color: var(--coral); color: var(--coral); }
.globe-page .globe-tip { display: none; }   /* replaced by the big card */

/* phones and narrow windows: the card sits at the bottom, wide and short */
@media (max-width: 900px) {
  .globe-card { top: auto; bottom: 14px; left: var(--gutter); right: var(--gutter); width: auto;
    transform: translateY(24px); }
  .globe-card.on, .globe-card:hover { transform: none; }
  .globe-card-paper { aspect-ratio: auto; padding: 18px 18px 14px; }
  .globe-card .gc-title { font-size: 28px; }
  .globe-card .gc-sum { -webkit-line-clamp: 2; margin-top: 8px; }
  .globe-card .paper-foot { margin-top: 12px; }
}
.globe-hint { position: absolute; bottom: 0; left: 0; right: 0; text-align: center; margin: 0; color: var(--dim); font-size: 12px; }
@media (max-width: 800px) {
  .globe-stage { padding-top: 64px; }
  .globe-title .lede { display: none; }
  .globe-controls .chips { gap: 6px; }
  .globe-controls .chip { padding: 6px 11px; font-size: 12px; }
}
@media (max-height: 640px) { .globe-title .lede, .globe-page .globe-hint { display: none; } }

/* ---- post pages: 3D layer (post3d.js) ---- */
.post3d-canvas { position: fixed; inset: 0; width: 100%; height: 100vh; height: 100lvh; z-index: 0; pointer-events: none; }
.post-head .paper-wrap.is-3d .paper { visibility: hidden; }        /* the 3D card takes its place */
.related { padding: 56px 0 24px; }
.related-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 40px; align-items: center; }
.related-fan { height: 420px; }
.related-list { list-style: none; padding: 0; margin: 0; }
.related-list li { border-bottom: 1px solid var(--line); }
.related-list a { display: block; padding: 16px 0; text-decoration: none; font-family: var(--serif); font-size: 24px; line-height: 1.15; }
.related-list small { display: block; font-family: var(--sans); font-size: 12px; color: var(--dim); letter-spacing: .03em; text-transform: uppercase; margin-bottom: 4px; }
@media (max-width: 800px) {
  .related-grid { grid-template-columns: 1fr; }
  .related-fan { height: 320px; }
}
