/* ======================================================================
   Editorial layer
   Design answers: mood editorial, light, brand = ink (black and white).
   Warm paper, near-black ink, serif headings over a sans interface,
   hairlines instead of boxes, underlined ink links, fades only.
   The homepage loads this file alone. Inner pages load it after
   styles.css, where the html.ed rules restyle the older components.
   ====================================================================== */
:root {
  --paper: #faf9f6;
  --ink: #141311;
  --muted: #66645f;
  --faint: #99968f;
  --rule: #e6e3dc;
  --rule-strong: #cbc8bf;
  --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  /* hover is a darker tint of the button's own background, never an inversion */
  --paper-hover: color-mix(in oklab, var(--paper), var(--ink) 7%);
  --ink-hover: #000;
}
html.ed { background: var(--paper); }
html.ed *, html.ed *::before, html.ed *::after { box-sizing: border-box; }
html.ed body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font-sans); font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
html.ed ::selection { background: var(--ink); color: var(--paper); }
html.ed a { color: inherit; text-decoration: none; }
html.ed img { max-width: 100%; }

/* Links: ink, underlined with a hairline that darkens on hover. The underline
   sits on the inner span so an icon inside the link is never underlined. */
.lnk > span, a.lnk-u, .by a, .case-facts a {
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
  text-decoration-color: var(--rule-strong); transition: text-decoration-color .16s var(--ease);
}
html.ed .lnk { color: var(--ink); white-space: nowrap; }
.lnk:hover > span, a.lnk-u:hover, .by a:hover, .case-facts a:hover { text-decoration-color: var(--ink); }
.ico { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: 5px; }
img.ico { filter: grayscale(1) contrast(1.1); }
svg.ico, .btn-back svg, .foot-icons svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ico.after { margin: 0 0 0 3px; width: 11px; height: 11px; vertical-align: -1px; color: var(--faint); }

/* ---------- Homepage ---------- */
.home-col { width: min(520px, 100% - 48px); margin: 0 auto; padding: clamp(56px, 17vh, 176px) 0 56px; }
.portrait {
  display: block; width: 88px; height: 88px; object-fit: cover; margin: 0 0 28px;
  border: 1px solid var(--rule);
}
.home-lead { font-family: var(--font-display); font-weight: 500; font-size: 16px; line-height: 1.6; letter-spacing: -.003em; margin: 0 0 16px; color: var(--ink); }
.home-col p { font-size: 16px; font-weight: 400; line-height: 1.65; color: var(--muted); margin: 0 0 12px; }
.home-col .nolnk { color: var(--ink); white-space: nowrap; }
.home-col > * { animation: ed-in .7s ease both; }
.home-col > *:nth-child(2) { animation-delay: .06s; } .home-col > *:nth-child(3) { animation-delay: .12s; }
.home-col > *:nth-child(4) { animation-delay: .18s; } .home-col > *:nth-child(5) { animation-delay: .24s; }
@keyframes ed-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Shared: footer and Return home ---------- */
.ed-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--rule); font-size: 12px; color: var(--faint); }
.foot-icons { display: flex; gap: 4px; margin-left: -8px; }
.foot-icons a { display: grid; place-items: center; width: 32px; height: 32px; color: var(--muted); transition: color .16s var(--ease), background .16s var(--ease); }
.foot-icons a:hover { color: var(--ink); background: var(--paper-hover); }
.foot-icons svg { width: 16px; height: 16px; }
.topbar { padding: 28px 0 0; }
.btn-back {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px 0 11px;
  border: 1px solid var(--rule-strong); border-radius: 0; background: transparent;
  font-family: var(--font-sans); font-size: 13px; font-weight: 500; line-height: 1; color: var(--ink);
  transition: background .16s var(--ease), color .16s var(--ease), border-color .16s var(--ease);
}
.btn-back svg { width: 14px; height: 14px; transition: transform .2s var(--ease); }
.btn-back:hover { background: var(--paper-hover); }
.btn-back:hover svg { transform: translateX(-2px); }
html.ed :focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ======================================================================
   Inner pages: restyle the older components (loaded after styles.css)
   ====================================================================== */
html.ed body {
  --bg: var(--paper); --ink-2: #55534e; --ink-3: #8b8983; --line: var(--rule);
  --brand: var(--ink); --serif: var(--font-display); --sans: var(--font-sans);
  /* product screenshots sit on plain white boxes: no sky, clouds or glows */
  --sky-a: transparent; --sky-b: transparent; --sky-c: transparent; --sky-top: #fff; --sky-bottom: #fff;
  --glow-1: transparent; --glow-2: transparent; --glow-3: transparent;
}
/* project pages keep the 1120px measure their mockups were drawn for; text-led pages narrow */
html.ed body.narrow .wrap { width: min(960px, 100% - 48px); }
/* any nested brand scope stays ink too */
html.ed [class*="brand-"] { --brand: var(--ink); }
html.ed .glow, html.ed .headshot-glow { display: none !important; }
html.ed .display { font-family: var(--font-display); font-weight: 500; letter-spacing: -.02em; line-height: 1.12; }
html.ed .display .lt { color: var(--muted); }
html.ed h1.display, html.ed .case-hero h1 { font-size: clamp(32px, 4.6vw, 44px); }
html.ed h2.display { font-size: clamp(24px, 3vw, 30px); }
html.ed h3.display, html.ed .step h3 { font-size: 22px; letter-spacing: -.012em; line-height: 1.2; }
html.ed .lede { font-size: 16px; line-height: 1.65; color: var(--ink-2); }
html.ed .ui-k { color: var(--faint); letter-spacing: .07em; }
/* motion is fades only */
html.ed.js .reveal { transform: none; transition: opacity .5s ease var(--d, 0s); }
html.ed.js .reveal.in { transform: none; }

/* zero radius on buttons, chips and tags; primary buttons are ink */
html.ed .btn { border-radius: 0; box-shadow: none; font-family: var(--font-sans); }
html.ed .btn-primary { background: var(--ink); color: var(--paper); }
html.ed .btn-primary:hover { background: var(--ink-hover); box-shadow: none; }
html.ed .btn-ghost { background: transparent; border: 1px solid var(--rule-strong); }
html.ed .btn-ghost:hover { background: var(--paper-hover); }
html.ed .chip, html.ed .tag { border-radius: 0; background: transparent; border: 1px solid var(--rule); box-shadow: none; backdrop-filter: none; color: var(--ink-2); }
html.ed .chip .dot { background: var(--ink); border-radius: 0; }

/* case study */
html.ed .case-hero { padding: 44px 0 0; }
html.ed .case-hero .wrap { grid-template-columns: 1.1fr 1fr; gap: 48px; }
html.ed .case-hero .wrap > .right { padding-top: 38px; }
html.ed .case-facts { gap: 0; border-top: 1px solid var(--rule); }
html.ed .case-facts div { flex: 1 1 0; min-width: 120px; padding: 12px 16px 0 0; }
html.ed .case-facts span:last-child { font-weight: 400; }
html.ed .by { color: var(--faint); }
html.ed .by a { color: var(--ink-2); border-bottom: 0; }
html.ed .case-stage, html.ed .case-stage.fit { margin-top: 44px; padding: 0 0 8px; }
html.ed .steps { margin-top: 64px; gap: 0; }
html.ed .step { padding: 44px 0; border-top: 1px solid var(--rule); }
html.ed .step .n { color: var(--faint); font-family: var(--font-sans); }
html.ed .shot { border-radius: 0; border: 1px solid var(--rule); background: #fff; }
html.ed .shot::before { background-image: none; }
html.ed .brand-rarity .shot.rwbox, html.ed .brand-rarity .shot.rgrid, html.ed .step .shot.flow { background: #fff; }
html.ed .case-nav { margin-top: 24px; gap: 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
html.ed .case-nav a { border-radius: 0; border: 0; background: transparent; padding: 22px 0; transition: opacity .16s var(--ease); }
html.ed .case-nav a + a { border-left: 1px solid var(--rule); padding-left: 24px; }
html.ed .case-nav a:hover { box-shadow: none; opacity: .6; }

/* library: square books and popups, quieter headings */
html.ed .library { padding-top: 40px; }
html.ed .library-head h1 { font-size: clamp(32px, 4.6vw, 44px); }
html.ed .shelf-sec h2.display { font-size: 22px; letter-spacing: -.012em; }
html.ed .book > img, html.ed .book .nocover { border-radius: 0; }
html.ed .book-tip { border-radius: 0; border: 1px solid var(--ink); box-shadow: none; background: var(--paper); }
html.ed .book-tip b { font-family: var(--font-display); font-weight: 500; }

/* inner-page footer sits in the page container */
html.ed footer.ed-foot.wrap { margin: 88px auto 0; padding-bottom: 44px; }
@media (max-width: 860px) {
  html.ed .case-hero .wrap { grid-template-columns: 1fr; gap: 20px; }
  html.ed .case-hero .wrap > .right { padding-top: 0; }
  html.ed .step { padding: 32px 0; }
}
@media (max-width: 520px) {
  html.ed body.narrow .wrap { width: calc(100% - 32px); }
  .home-col { width: calc(100% - 40px); }
  .topbar { padding-top: 20px; }
  html.ed .case-nav a + a { padding-left: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .home-col > * { animation: none; }
  .btn-back, .btn-back svg { transition: none; }
}

/* ======================================================================
   Writings: an index of pieces by date, and one reading page per piece
   ====================================================================== */
.read { width: min(640px, 100% - 48px); margin-left: auto; margin-right: auto; }
html.ed footer.ed-foot.read { margin-top: 88px; padding-bottom: 44px; }
.page-title { font-family: var(--font-display); font-weight: 500; font-size: clamp(32px, 4.6vw, 44px); letter-spacing: -.02em; line-height: 1.12; margin: 40px 0 28px; }
.toc { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.toc li { border-bottom: 1px solid var(--rule); }
.toc-row { display: grid; grid-template-columns: 132px 1fr; column-gap: 20px; row-gap: 2px; align-items: baseline; padding: 18px 0; }
.toc-row time, .stamp { font-family: var(--font-sans); font-size: 11px; font-weight: 500; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); font-variant-numeric: tabular-nums; }
.toc-row .t { font-family: var(--font-display); font-weight: 500; font-size: 19px; letter-spacing: -.01em; line-height: 1.3; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; text-decoration-color: transparent; transition: text-decoration-color .16s var(--ease); }
.toc-row .d { grid-column: 2; font-size: 14px; color: var(--muted); }
.toc-row:hover .t { text-decoration-color: var(--ink); }
.post { margin-top: 48px; }
.post h1 { font-family: var(--font-display); font-weight: 500; font-size: clamp(30px, 4.4vw, 40px); letter-spacing: -.02em; line-height: 1.12; margin: 12px 0 10px; }
.post .dek { font-size: 16px; color: var(--muted); margin: 0 0 30px; }
.prose { font-family: var(--font-display); font-size: 17px; line-height: 1.7; color: var(--ink); }
.prose p, .prose ol { margin: 0 0 1.15em; }
.prose ol { padding-left: 1.3em; }
.prose li { margin-bottom: .35em; padding-left: .2em; }
.prose h2 { font-family: var(--font-display); font-weight: 600; font-size: 21px; letter-spacing: -.012em; line-height: 1.25; margin: 1.9em 0 .6em; }
.prose strong { font-weight: 600; }
.prose a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: var(--rule-strong); transition: text-decoration-color .16s var(--ease); }
.prose a:hover { text-decoration-color: var(--ink); }
.w-fig { margin: 0 0 1.6em; }
.prose p + .w-fig, .prose p + .w-video, .prose ol + .w-fig { margin-top: 1.7em; }
.w-fig img { display: block; width: 100%; height: auto; border: 1px solid var(--rule); }
.w-fig.narrow { max-width: 400px; margin-left: auto; margin-right: auto; }
.prose > h2:first-child { margin-top: 0; }
.w-video { position: relative; aspect-ratio: 16 / 9; margin: 1.7em 0; border: 1px solid var(--rule); background: #000; }
.w-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
@media (max-width: 520px) {
  .read { width: calc(100% - 40px); }
  .toc-row { grid-template-columns: 1fr; }
  .toc-row .d { grid-column: 1; }
  .post { margin-top: 36px; }
}

/* ======================================================================
   Page transitions (see transitions.js)
   html[data-vt] is set on the incoming page for the length of the
   transition. --vt-k scales every duration; it exists for testing.
   ====================================================================== */
@view-transition { navigation: auto; }
::view-transition-group(root) { animation-duration: .2s; }

html[data-vt]::view-transition-old(root),
html[data-vt]::view-transition-new(root) { mix-blend-mode: normal; animation: none; }
html[data-vt]::view-transition-image-pair(root) { isolation: auto; }
html[data-vt]::view-transition { background: var(--paper); }

/* ---------- Book page: the leaf turns on its left edge, the spine ----------
   Only transform animates by default, which the compositor handles on its own.
   The shading filters are added for desktop-class devices further down. */
html[data-vt="flip-fwd"]::view-transition-old(root) {
  z-index: 2; transform-origin: 0 50%;
  animation: vt-turn-away calc(.85s * var(--vt-k, 1)) cubic-bezier(.45, .05, .2, 1) both;
}
html[data-vt="flip-fwd"]::view-transition-new(root) { z-index: 1; }
html[data-vt="flip-back"]::view-transition-new(root) {
  z-index: 2; transform-origin: 0 50%;
  animation: vt-turn-back calc(.85s * var(--vt-k, 1)) cubic-bezier(.45, .05, .2, 1) both;
}
html[data-vt="flip-back"]::view-transition-old(root) { z-index: 1; }
@keyframes vt-turn-away { from { transform: perspective(240vw) rotateY(0); } to { transform: perspective(240vw) rotateY(-91deg); } }
@keyframes vt-turn-back { from { transform: perspective(240vw) rotateY(-91deg); } to { transform: perspective(240vw) rotateY(0); } }
@keyframes vt-leaf-shade { from { filter: brightness(1); } to { filter: brightness(.8); } }
@keyframes vt-under-shade { from { filter: brightness(.88); } to { filter: brightness(1); } }
@media (hover: hover) and (pointer: fine) and (min-width: 861px) {
  html[data-vt="flip-fwd"]::view-transition-old(root) {
    animation: vt-turn-away calc(.85s * var(--vt-k, 1)) cubic-bezier(.45, .05, .2, 1) both,
               vt-leaf-shade calc(.85s * var(--vt-k, 1)) ease-in both;
  }
  html[data-vt="flip-fwd"]::view-transition-new(root) { animation: vt-under-shade calc(.85s * var(--vt-k, 1)) ease-out both; }
  html[data-vt="flip-back"]::view-transition-new(root) {
    animation: vt-turn-back calc(.85s * var(--vt-k, 1)) cubic-bezier(.45, .05, .2, 1) both,
               vt-leaf-shade calc(.85s * var(--vt-k, 1)) ease-out reverse both;
  }
  html[data-vt="flip-back"]::view-transition-old(root) { animation: vt-under-shade calc(.85s * var(--vt-k, 1)) ease-in reverse both; }
}

/* ---------- Door: a door opens in the page and you walk through it ---------- */
.vt-door, .vt-frame { display: none; }
html[data-vt^="door"] .vt-door, html[data-vt^="door"] .vt-frame {
  display: block; position: fixed; z-index: 9999; pointer-events: none;
  left: calc(50vw - 17vh); top: 16vh; width: 34vh; height: 68vh;
}
html[data-vt^="door"] .vt-frame { border: 1px solid var(--ink); view-transition-name: vt-frame; }
html[data-vt^="door"] .vt-door { background: var(--paper); border: 1px solid var(--ink); view-transition-name: vt-door; }
.vt-door::before { content: ''; position: absolute; inset: 7% 13%; border: 1px solid var(--rule-strong); }
.vt-door::after { content: ''; position: absolute; right: 6%; top: 50%; width: 1.4vh; height: 1.4vh; margin-top: -.7vh; border-radius: 50%; background: var(--ink); }
html[data-vt^="door"]::view-transition-group(vt-door),
html[data-vt^="door"]::view-transition-group(vt-frame) { animation: none; }

/* going in: the door appears, swings open, and the doorway grows past the screen */
html[data-vt="door-in"]::view-transition-old(root) { z-index: 1; transform-origin: 50% 50%; animation: vt-wall-in calc(1s * var(--vt-k, 1)) linear both; }
html[data-vt="door-in"]::view-transition-new(root) { z-index: 2; animation: vt-room-in calc(1s * var(--vt-k, 1)) linear both; }
html[data-vt="door-in"]::view-transition-new(vt-frame) { transform-origin: 50% 50%; animation: vt-frame-in calc(1s * var(--vt-k, 1)) linear both; }
html[data-vt="door-in"]::view-transition-new(vt-door) { transform-origin: 0 50%; animation: vt-leaf-open calc(1s * var(--vt-k, 1)) linear both; }
@keyframes vt-wall-in {
  0%, 52% { transform: scale(1); animation-timing-function: cubic-bezier(.6, 0, .25, 1); }
  100% { transform: scale(8); }
}
@keyframes vt-room-in {
  0%, 13.9% { opacity: 0; clip-path: inset(16vh calc(50vw - 17vh)); }
  14% { opacity: 1; clip-path: inset(16vh calc(50vw - 17vh)); }
  52% { opacity: 1; clip-path: inset(16vh calc(50vw - 17vh)); animation-timing-function: cubic-bezier(.6, 0, .25, 1); }
  100% { opacity: 1; clip-path: inset(-222vh calc(50vw - 136vh)); }
}
@keyframes vt-frame-in {
  0% { opacity: 0; transform: scale(1); }
  14%, 52% { opacity: 1; transform: scale(1); animation-timing-function: cubic-bezier(.6, 0, .25, 1); }
  100% { opacity: 1; transform: scale(8); }
}
@keyframes vt-leaf-open {
  0% { opacity: 0; transform: perspective(1500px) rotateY(0); filter: brightness(1); }
  14% { opacity: 1; transform: perspective(1500px) rotateY(0); filter: brightness(1); animation-timing-function: cubic-bezier(.5, 0, .2, 1); }
  52% { opacity: 1; transform: perspective(1500px) rotateY(84deg); filter: brightness(.9); }
  62%, 100% { opacity: 0; transform: perspective(1500px) rotateY(84deg); filter: brightness(.9); }
}

/* coming out: the room shrinks back into the doorway and the door closes on it */
html[data-vt="door-out"]::view-transition-old(root) { z-index: 2; animation: vt-room-out calc(1s * var(--vt-k, 1)) linear both; }
html[data-vt="door-out"]::view-transition-new(root) { z-index: 1; transform-origin: 50% 50%; animation: vt-wall-out calc(1s * var(--vt-k, 1)) linear both; }
html[data-vt="door-out"]::view-transition-new(vt-frame) { transform-origin: 50% 50%; animation: vt-frame-out calc(1s * var(--vt-k, 1)) linear both; }
html[data-vt="door-out"]::view-transition-new(vt-door) { transform-origin: 0 50%; animation: vt-leaf-close calc(1s * var(--vt-k, 1)) linear both; }
@keyframes vt-room-out {
  0% { opacity: 1; clip-path: inset(-222vh calc(50vw - 136vh)); animation-timing-function: cubic-bezier(.75, 0, .4, 1); }
  48%, 85.9% { opacity: 1; clip-path: inset(16vh calc(50vw - 17vh)); }
  86%, 100% { opacity: 0; clip-path: inset(16vh calc(50vw - 17vh)); }
}
@keyframes vt-wall-out {
  0% { transform: scale(8); animation-timing-function: cubic-bezier(.75, 0, .4, 1); }
  48%, 100% { transform: scale(1); }
}
@keyframes vt-frame-out {
  0% { opacity: 1; transform: scale(8); animation-timing-function: cubic-bezier(.75, 0, .4, 1); }
  48%, 86% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}
@keyframes vt-leaf-close {
  0%, 38% { opacity: 0; transform: perspective(1500px) rotateY(84deg); filter: brightness(.9); }
  48% { opacity: 1; transform: perspective(1500px) rotateY(84deg); filter: brightness(.9); animation-timing-function: cubic-bezier(.5, 0, .2, 1); }
  86% { opacity: 1; transform: perspective(1500px) rotateY(0); filter: brightness(1); }
  100% { opacity: 0; transform: perspective(1500px) rotateY(0); filter: brightness(1); }
}
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}
