/* A plain essay site: one column, serif text, no decoration. Light and dark follow the system. */

:root {
  --bg: #fbfaf7;
  --text: #1d1c1a;
  --muted: #74706a;
  --rule: #e6e2da;
  --link: #1d1c1a;
  --accent: #b4532a;
  --code-bg: #f1eee7;
  --panel: #f8f7f4;
  --serif: "Newsreader", "Iowan Old Style", Charter, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --text: #e9e6e0;
    --muted: #96918a;
    --rule: #2c2a27;
    --link: #e9e6e0;
    --accent: #e08a5c;
    --code-bg: #22201e;
    --panel: #191817;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

a { color: inherit; text-decoration-color: var(--muted); text-underline-offset: 0.15em; }
a:hover { color: var(--accent); text-decoration-color: var(--accent); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 21px/1.6 var(--serif);
  font-optical-sizing: auto;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

header.site, main, footer.site {
  max-width: 42rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

header.site {
  padding-top: 2.5rem;
  padding-bottom: 3.5rem;
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

header.site .name {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

header.site { display: flex; justify-content: space-between; align-items: baseline; }
header.site nav { display: flex; gap: 1.4rem; }
header.site nav a { color: var(--muted); text-decoration: none; transition: color 0.15s; }
header.site nav a:hover { color: var(--text); }
header.site nav a[aria-current="page"] { color: var(--text); }

body { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
body > main { flex: 1 0 auto; width: 100%; }
header.site, footer.site { width: 100%; }

footer.site {
  position: relative;
  margin-top: 6rem;
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--muted);
}

footer.site { display: flex; justify-content: space-between; align-items: baseline; }
footer.site a { color: var(--muted); text-decoration: none; transition: color 0.15s; }
footer.site a:hover { color: var(--text); }
footer.site::before { content: ""; position: absolute; top: 0; left: 1.25rem; right: 1.25rem; border-top: 1px solid var(--rule); }

/* home */

.home-title, .about h1 {
  margin: 0 0 2rem;
  font-size: 0.8rem;
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.post-list { list-style: none; margin: 0; padding: 0; }
.post-list a { display: block; padding: 1.4rem 0 1.5rem; border-top: 1px solid var(--rule); color: var(--text); text-decoration: none; }
.post-list li:last-child a { border-bottom: 1px solid var(--rule); }
.post-list time { display: block; margin-bottom: 0.35rem; font: 0.72rem var(--sans); color: var(--muted); letter-spacing: 0.02em; }
.post-list .title { display: block; font-size: 1.45rem; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; transition: color 0.15s; }
.post-list .excerpt { display: block; margin-top: 0.45rem; color: var(--muted); font-size: 1rem; }
.post-list a:hover .title { color: var(--accent); }

/* about */

.about p { margin: 0 0 1.5rem; }
.about a { color: var(--text); text-decoration-color: var(--muted); text-underline-offset: 0.15em; }
.about a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.about .links { list-style: none; margin: 2.5rem 0 0; padding: 0; font: 0.85rem var(--sans); border-top: 1px solid var(--rule); }
.about .links li { display: flex; justify-content: space-between; align-items: baseline; padding: 0.75rem 0; border-bottom: 1px solid var(--rule); }
.about .links span { color: var(--muted); font-size: 0.78rem; }

.post-link {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.9rem 0;
  border-top: 1px solid var(--rule);
  color: var(--text);
  text-decoration: none;
}
.post-link:last-child { border-bottom: 1px solid var(--rule); }
.post-link .title { font-weight: 500; }
.post-link .date { flex: none; font-family: var(--sans); font-size: 0.75rem; color: var(--muted); }
.post-link:hover .title { color: var(--accent); }

/* article */

.post header h1 {
  margin: 0 0 0.5rem;
  font-size: 2.1rem;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.post .meta {
  margin: 0 0 2.75rem;
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--muted);
}

.post .draft { color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; }

.post h2 {
  margin: 7rem 0 1.1rem;
  font-size: 1.65rem;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.post p, .post ul, .post ol, .post blockquote { margin: 0 0 1.15rem; }
.post li { margin: 0.25rem 0; }
.post ul, .post ol { padding-left: 1.3rem; }

.post a { color: var(--link); text-decoration-color: var(--muted); text-underline-offset: 0.15em; }
.post a:hover { color: var(--accent); text-decoration-color: var(--accent); }

.post blockquote {
  padding-left: 1rem;
  border-left: 2px solid var(--rule);
  color: var(--muted);
  font-style: italic;
}

.post strong { font-weight: 600; }

.post code {
  font: 0.82em var(--mono);
  background: var(--code-bg);
  padding: 0.1em 0.3em;
  border-radius: 4px;
}

.post pre {
  margin: 0 0 1.25rem;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  background: var(--code-bg);
  border-radius: 6px;
  font: 0.8rem/1.55 var(--mono);
}
.post pre code { background: none; padding: 0; font-size: inherit; }

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

/* diagrams run wider than the text, never wider than the screen */
.post .diagram {
  width: min(56rem, calc(100vw - 2.5rem));
  margin: 1.4rem 0 4.5rem;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  padding: clamp(0.75rem, 3vw, 1.75rem);
  background: var(--panel);
  border-radius: 16px;
}
.post .diagram svg { display: block; width: 100%; height: auto; }
.post .diagram > svg { position: relative; z-index: 1; }
/* hovering the Hue lights warms the whole panel up */
.post .diagram:has(svg.d7)::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1  0 0 0 0 .9  0 0 0 0 .8  0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(46% 70% at 96% 104%, #ffc46b 0%, rgba(255, 196, 107, 0) 68%),
    radial-gradient(44% 64% at 90% -8%, #ff8a3d 0%, rgba(255, 138, 61, 0) 70%),
    radial-gradient(52% 80% at -6% 106%, #ff2f6d 0%, rgba(255, 47, 109, 0) 70%),
    radial-gradient(42% 62% at 14% -12%, #ff5638 0%, rgba(255, 86, 56, 0) 70%),
    linear-gradient(120deg, #a3134f 0%, #d8342f 48%, #ee7a1c 100%);
  background-size: 160px 160px, 130% 130%, 130% 130%, 130% 130%, 130% 130%, 100% 100%;
  background-position: 0 0, 100% 100%, 100% 0, 0 100%, 0 0, 0 0;
  opacity: 0; transition: opacity 0.8s ease;
}
.post .diagram:has(svg.d7 .r3:hover)::before { animation: hue-drift 9s ease-in-out infinite alternate; }
/* hovering the coffee machine fills the panel with coffee */
.post .diagram:has(svg.d7) { overflow: hidden; }
.post .diagram:has(svg.d7)::after {
  content: ""; position: absolute; left: -6%; right: -6%; bottom: -40px; height: 0; pointer-events: none; z-index: 0;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='20'%3E%3Cpath d='M0 10 Q30 2 60 10 T120 10 T180 10 T240 10 V20 H0Z' fill='%23d9a874' fill-opacity='.9'/%3E%3C/svg%3E") repeat-x 0 0 / 240px 20px,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='24'%3E%3Cpath d='M0 12 Q40 3 80 12 T160 12 T240 12 T320 12 V24 H0Z' fill='%237a4527'/%3E%3C/svg%3E") repeat-x 0 6px / 320px 24px,
    linear-gradient(to bottom, rgba(0, 0, 0, 0) 0 16px, #7a4527 16px, #5a2f18 55%, #3a1c0d 100%);
  transform-origin: 50% 100%;
  transition: height 1.3s cubic-bezier(.5, 0, .7, .4);
}
.post .diagram.coffee-on:has(svg.d7)::after {
  height: calc(100% + 90px);
  transition: height 5s cubic-bezier(.25, .1, .25, 1);
  animation: coffee-waves 2.6s linear infinite, coffee-slosh 3.4s ease-in-out infinite;
}
@keyframes coffee-waves { to { background-position: 240px 0, -320px 6px, 0 0; } }
@keyframes coffee-slosh {
  0%, 100% { transform: skewY(0deg) translateY(0); }
  25% { transform: skewY(-1.2deg) translateY(2px); }
  50% { transform: skewY(0.3deg) translateY(-2px); }
  75% { transform: skewY(1deg) translateY(1px); }
}
@media (prefers-reduced-motion: reduce) { .post .diagram.coffee-on:has(svg.d7)::after { animation: none; transition: none; } }
@keyframes hue-drift {
  to { background-position: 0 0, 80% 86%, 88% 14%, 14% 84%, 12% 10%, 0 0; }
}
.post .diagram:has(svg.d7 .r3:hover)::before { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .post .diagram:has(svg.d7)::before { transition: none; animation: none !important; } }
/* the push notification slides in from behind the frame's top edge */
.post .diagram:has(svg.d5), .post .diagram:has(svg.d10) { overflow: hidden; }

/* a text conversation with Jarvis */
.post .chats { display: flex; flex-direction: column; gap: 0.6rem; margin: 1.4rem 0 4.5rem; }
.post .chat { display: flex; flex-direction: column; gap: 0.45rem; margin: 0; padding: clamp(1rem, 3vw, 1.6rem); background: var(--panel); border-radius: 16px; font: 15.5px/1.4 var(--sans); }
.post .chat p { margin: 0; max-width: 78%; padding: 0.55rem 0.9rem; border-radius: 18px; }
.post .chat .me { align-self: flex-end; background: #2f7bf6; color: #fff; border-bottom-right-radius: 6px; }
.post .chat .wave { width: 15px; height: 15px; margin-right: 6px; vertical-align: -2px; opacity: 0.8; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.post .chat .jv { align-self: flex-start; background: var(--code-bg); color: var(--text); border-bottom-left-radius: 6px; }
.post .chat .me + .jv, .post .chat .jv + .me { margin-top: 0.15rem; }
.post .chat .jv + .me { margin-top: 0.9rem; }
.post .chat .day { align-self: stretch; max-width: none; display: flex; align-items: center; gap: 0.75rem; margin: 0.9rem 0 0.3rem; padding: 0; border-radius: 0; color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em; }
.post .chat .day::before, .post .chat .day::after { content: ""; flex: 1; border-top: 1px solid var(--rule); }
.post .chat .when { align-self: center; padding: 0.4rem 0 0.1rem; background: none; color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em; }

/* wire-up diagram hover effects: Spotify, Calendar, Email */
.post .diagram .fx-under, .post .diagram .fx-over { position: absolute; inset: 0; overflow: hidden; clip-path: inset(0 round 16px); pointer-events: none; }
.post .diagram .fx-under { z-index: 0; }
.post .diagram .fx-over { z-index: 2; }
.post .diagram .eq { position: absolute; left: 0; right: 0; bottom: 0; height: 58%; display: flex; align-items: flex-end; gap: 4px; padding: 0 4px; opacity: 0; transition: opacity 0.5s ease; }
.post .diagram.spotify-on .eq { opacity: 1; }
.post .diagram .eq i { flex: 1; height: 100%; border-radius: 4px 4px 0 0; background: linear-gradient(to top, rgba(30, 215, 96, 0.55), rgba(30, 215, 96, 0.05)); transform-origin: 50% 100%; transform: scaleY(0.08); }
.post .diagram.spotify-on .eq i { animation: eq var(--d) ease-in-out var(--o) infinite alternate; }
@keyframes eq { from { transform: scaleY(0.08); } to { transform: scaleY(var(--h)); } }
.post .diagram .cal { position: absolute; top: 0; padding: 5px 9px; border-radius: 7px; border-left: 4px solid rgba(0, 0, 0, 0.22); color: #fff; font: 600 12px/1.25 var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25); transition: transform 0.55s cubic-bezier(0.3, 1.25, 0.5, 1), opacity 0.35s ease; }
.post .diagram .cal small { display: block; font-weight: 500; opacity: 0.8; font-size: 10.5px; }
.post .diagram .env { position: absolute; top: 0; left: 0; width: 30px; height: 21px; }
.post .diagram .unread { position: absolute; top: 14px; right: 16px; min-width: 26px; padding: 3px 9px; border-radius: 999px; background: #ff3b30; color: #fff; font: 700 13px/1.3 var(--sans); text-align: center; box-shadow: 0 4px 12px rgba(255, 59, 48, 0.4); transform: scale(0); transition: transform 0.25s cubic-bezier(0.3, 1.5, 0.5, 1); }
.post .diagram .unread.on { transform: scale(1); }

/* notes to self while drafting: [TK ...] */
.post .tk { color: var(--accent); font-family: var(--sans); font-size: 0.8em; }

.post .diagram .edge { display: none; }

/* phones: diagrams keep a readable size and scroll sideways; taps trigger the hover states */
@media (max-width: 40rem) {
  .post .diagram {
    width: calc(100vw - 1.5rem);
    display: flex;
    padding: 0.9rem 0.9rem;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .post .diagram::-webkit-scrollbar { display: none; }
  .post .diagram .edge { display: block; }
  .post .diagram > svg { flex: none; width: 700px; max-width: none; }
  .post .diagram .edge { display: block; position: sticky; flex: none; width: 0; z-index: 3; pointer-events: none; }
  .post .diagram .edge-l { left: 0; }
  .post .diagram .edge-r { right: 0; }
  .post .diagram .edge::before { content: ""; position: absolute; top: -0.9rem; bottom: -0.9rem; width: 56px; opacity: 0; transition: opacity 0.25s ease; }
  .post .diagram .edge-l::before { left: -0.9rem; background: linear-gradient(to right, var(--panel), transparent); border-radius: 16px 0 0 16px; }
  .post .diagram .edge-r::before { right: -0.9rem; background: linear-gradient(to left, var(--panel), transparent); border-radius: 0 16px 16px 0; }
  .post .diagram.can-l .edge-l::before, .post .diagram.can-r .edge-r::before { opacity: 1; }
  .post .diagram .edge-r i {
    position: absolute; right: -0.2rem; top: 50%; width: 28px; height: 28px; margin-top: -14px; border-radius: 50%;
    background: color-mix(in srgb, var(--text) 12%, transparent); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    opacity: 0; transition: opacity 0.25s ease;
  }
  .post .diagram .edge-r i::after {
    content: ""; position: absolute; left: 9px; top: 9.5px; width: 7px; height: 7px;
    border-top: 2px solid var(--text); border-right: 2px solid var(--text); transform: rotate(45deg);
  }
  .post .diagram.can-r:not(.swiped) .edge-r i { opacity: 0.85; animation: nudge 1.6s ease-in-out infinite; }
  @keyframes nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(4px); } }
  .post .chats { margin-left: -0.5rem; margin-right: -0.5rem; }
  .post .chat { padding: 0.9rem; }
}
@media (hover: none) {
  .post .diagram .d-row { cursor: pointer; }
}

@media (max-width: 34rem) {
  body { font-size: 18px; }
  .post header h1 { font-size: 1.75rem; }
  .post h2 { margin-top: 4.5rem; font-size: 1.45rem; }
  .post .chat { font-size: 15px; }
  .post .chat p { max-width: 86%; }
  header.site { padding-top: 1.75rem; padding-bottom: 2.5rem; }
  .post-list .title { font-size: 1.3rem; }
  .post-link { flex-direction: column; gap: 0.2rem; }
}
