/* ==========================================================================
   stevenpisani.com
   One stylesheet, no framework. Themes are just custom properties:
   light (default), dark (system or chosen), and terminal (chosen).
   ========================================================================== */

:root {
  --bg: #faf7f2;
  --bg-2: #f1ece3;
  --card: #ffffff;
  --ink: #1d1b18;
  --ink-2: #57524a;
  --ink-3: #8a847a;
  --line: #e4ddd1;
  --accent: #e0531f;       /* a warm, slightly-too-loud orange */
  --accent-ink: #ffffff;
  --accent-soft: #fde4d8;
  --link: #b33c10;
  --mark: #ffe38a;
  --shadow: 0 1px 2px rgb(29 27 24 / .05), 0 8px 24px rgb(29 27 24 / .06);

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius: 14px;
  --wrap: 1080px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0c0e1e; --bg-2: #161a33; --card: rgb(22 26 51 / .82);
    --ink: #eef0fa; --ink-2: #b4b9d6; --ink-3: #7c82a8; --line: #2a3060;
    --accent: #ff7a45; --accent-ink: #15171c; --accent-soft: #3a2419;
    --link: #ff9a6e; --mark: #5b4a12;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0e1e; --bg-2: #161a33; --card: rgb(22 26 51 / .82);
  --ink: #eef0fa; --ink-2: #b4b9d6; --ink-3: #7c82a8; --line: #2a3060;
  --accent: #ff7a45; --accent-ink: #15171c; --accent-soft: #3a2419;
  --link: #ff9a6e; --mark: #5b4a12;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
  color-scheme: dark;
}
:root[data-theme="terminal"] {
  --bg: #050805; --bg-2: #0a120a; --card: #081008;
  --ink: #7dff7a; --ink-2: #4fd14c; --ink-3: #2f8f2d; --line: #1b3a1b;
  --accent: #7dff7a; --accent-ink: #050805; --accent-soft: #0f2a0f;
  --link: #b6ffb4; --mark: #1f4d1f;
  --shadow: 0 0 0 1px #1b3a1b;
  --font-display: var(--font-mono);
  --font-body: var(--font-mono);
  --radius: 0;
  color-scheme: dark;
}
:root[data-theme="terminal"] body {
  text-shadow: 0 0 6px rgb(125 255 122 / .35);
  background-image: repeating-linear-gradient(0deg, rgb(0 0 0 / .18) 0 1px, transparent 1px 3px);
}
:root[data-theme="terminal"] img { filter: grayscale(1) sepia(1) hue-rotate(60deg) saturate(3) brightness(.8); }

/* Dark mode is space mode: the old site's Milky Way, fixed behind everything. */
:root[data-theme="dark"] body { background: linear-gradient(rgb(12 14 30 / .82), rgb(12 14 30 / .92)), url("../images/outer_space-p-1600.jpeg") center / cover fixed, #0c0e1e; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) body { background: linear-gradient(rgb(12 14 30 / .82), rgb(12 14 30 / .92)), url("../images/outer_space-p-1600.jpeg") center / cover fixed, #0c0e1e; }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.65 var(--font-body);
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s, color .25s;
}
img { max-width: 100%; height: auto; }
a { color: var(--link); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; letter-spacing: -.01em; margin: 0 0 .5em; }
h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); font-weight: 800; }
h2 { font-size: clamp(1.4rem, 3vw, 1.8rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
mark { background: var(--mark); color: inherit; padding: 0 .2em; border-radius: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--accent); color: var(--accent-ink); }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 10; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { top: 12px; }
.kicker {
  font: 600 .78rem/1.2 var(--font-mono);
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 .75em;
}
.kicker a { color: inherit; text-decoration: none; }
.section { margin-top: 72px; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section__head h2 { margin: 0; }
.section__head a { font: 500 .9rem var(--font-mono); white-space: nowrap; }
.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; margin-top: 56px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Header / footer ---------- */
.site-head { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.site-head__inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 700 1.05rem var(--font-display); }
.brand img { border-radius: 6px; }
.site-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.site-nav a { color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: .95rem; padding: 6px 10px; border-radius: 8px; }
.site-nav a:hover { color: var(--ink); background: var(--bg-2); }
.site-nav a[aria-current="page"] { color: var(--ink); background: var(--accent-soft); }

.theme-btn { flex-shrink: 0; width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 50%; cursor: pointer; }
.theme-btn:hover { border-color: var(--accent); }
.theme-btn__icon::before { content: "☀︎"; font-size: 1rem; line-height: 1; }
:root[data-theme="dark"] .theme-btn__icon::before { content: "✦"; }
:root[data-theme="terminal"] .theme-btn__icon::before { content: ">_"; font: 600 .75rem var(--font-mono); }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .theme-btn__icon::before { content: "✦"; } }
.theme-btn.is-pulsing { animation: pulse 1s ease-in-out 3; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px var(--accent-soft); border-color: var(--accent); } }

.site-foot { margin-top: 96px; border-top: 1px solid var(--line); background: var(--bg-2); }
.site-foot__inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding-top: 28px; padding-bottom: 28px; font-size: .9rem; color: var(--ink-2); }
.site-foot__sig { margin: 0; }
.site-foot__links { display: flex; gap: 16px; flex-wrap: wrap; }
.site-foot__links a { color: var(--ink-2); }

/* ---------- Buttons, chips, cards ---------- */
.btn { display: inline-block; padding: 11px 18px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none; border: 2px solid var(--accent); transition: transform .15s; }
.btn:hover { transform: translateY(-2px); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { border-color: var(--ink); }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0 0 1em; }
.chips li { font: 500 .8rem var(--font-mono); padding: 4px 10px; border-radius: 999px; background: var(--bg-2); color: var(--ink-2); border: 1px solid var(--line); }
.chips--small li { font-size: .72rem; padding: 2px 8px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.card h2 { font-size: 1.5rem; }
.card p { color: var(--ink-2); }
.card__links { display: flex; gap: 18px; flex-wrap: wrap; margin: 0; font-weight: 500; }

/* ---------- Home ---------- */
.hero { display: grid; grid-template-columns: 1fr 320px; gap: 48px; align-items: center; padding-top: 72px; }
.hero__name { font-size: clamp(3rem, 9vw, 5.6rem); line-height: .95; margin-bottom: .35em; }
.hero__name .wave { color: var(--accent); }
.hero__lede { font-size: 1.2rem; color: var(--ink-2); max-width: 36em; }
.hero__cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.hero__photo img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 50%; background: var(--accent-soft); box-shadow: 12px 12px 0 var(--accent); }
@media (max-width: 600px) {
  .site-head__inner { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
  .site-nav { grid-column: 1 / -1; grid-row: 2; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .site-nav a { white-space: nowrap; }
  .site-nav a:first-child { padding-left: 0; }
}
@media (max-width: 720px) {
  .hero { grid-template-columns: 1fr; padding-top: 40px; gap: 32px; }
  .hero__photo { order: -1; max-width: 200px; }
}
.likes p { font: 400 clamp(1.3rem, 3vw, 1.8rem)/1.5 var(--font-display); color: var(--ink-2); max-width: 30em; }

/* Next-launch card */
.card--launch {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px;
  min-height: 300px; color: #fff; text-decoration: none; overflow: hidden; border: 0;
  background: linear-gradient(180deg, rgb(5 10 30 / 0) 25%, rgb(5 10 30 / .85) 100%), var(--launch-img) center 35% / cover, #0b1030;
}
.card--launch .kicker { color: #ffb38a; margin: 0; }
.launch__name { font: 700 1.5rem/1.2 var(--font-display); }
.launch__meta { color: rgb(255 255 255 / .8); font-size: .95rem; }
.launch__clock { font: 600 1.6rem var(--font-mono); letter-spacing: .02em; font-variant-numeric: tabular-nums; min-height: 1.3em; }
.card--launch:hover .launch__name { text-decoration: underline; text-decoration-thickness: 2px; }
:root[data-theme="terminal"] .card--launch { color: var(--ink); background: var(--card); border: 1px solid var(--line); }
:root[data-theme="terminal"] .card--launch .kicker, :root[data-theme="terminal"] .launch__meta { color: var(--ink-2); }

/* ---------- Post lists & covers ---------- */
.cover {
  border-radius: var(--radius); aspect-ratio: 5 / 2; margin: 0 0 40px;
  /* The photo (if any) sits on top of a gradient, so a dead hotlink still looks intentional. */
  background:
    var(--img, none) center / cover no-repeat,
    radial-gradient(circle at 20% 30%, hsl(var(--h1) 85% 65% / .9), transparent 55%),
    radial-gradient(circle at 80% 70%, hsl(var(--h2) 80% 55% / .9), transparent 50%),
    linear-gradient(135deg, hsl(var(--h1) 60% 25%), hsl(var(--h2) 60% 15%));
}
.cover--small { width: 96px; aspect-ratio: 1; margin: 0; border-radius: 10px; flex-shrink: 0; }

.post-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.post-row a { display: flex; align-items: center; gap: 20px; padding: 14px; margin: 0 -14px; border-radius: var(--radius); color: inherit; text-decoration: none; transition: background .2s; }
.post-row a:hover { background: var(--bg-2); }
.post-row__body { display: grid; gap: 4px; flex: 1; min-width: 0; }
.post-row__title { font: 600 1.2rem/1.3 var(--font-display); }
.post-row a:hover .post-row__title { color: var(--link); }
.post-row__excerpt { color: var(--ink-2); font-size: .95rem; }
.post-row time { font: .8rem var(--font-mono); color: var(--ink-3); white-space: nowrap; }
@media (max-width: 600px) {
  .cover--small { width: 64px; }
  .post-row a { align-items: flex-start; gap: 14px; }
  .post-row time { display: none; }
}

/* ---------- Lab ---------- */
.lab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.lab-card { position: relative; display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; color: inherit; text-decoration: none; box-shadow: var(--shadow); transition: transform .2s, border-color .2s; }
.lab-card:hover { transform: translateY(-4px) rotate(-.4deg); border-color: var(--accent); }
.lab-card__emoji { font-size: 2rem; display: block; margin-bottom: 12px; }
.lab-card__status { position: absolute; top: 20px; right: 20px; font: 600 .7rem var(--font-mono); text-transform: uppercase; letter-spacing: .06em; padding: 3px 8px; border-radius: 999px; background: var(--bg-2); color: var(--ink-3); }
.lab-card__status--live { background: #d9f5e3; color: #11663a; }
:root[data-theme="dark"] .lab-card__status--live, :root[data-theme="terminal"] .lab-card__status--live { background: #173a26; color: #7fe0a6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .lab-card__status--live { background: #173a26; color: #7fe0a6; } }
.lab-card h3 { margin-bottom: .35em; }
.lab-card p { color: var(--ink-2); font-size: .95rem; }

/* ---------- Pages & prose ---------- */
.page-head, .post-head { padding-top: 64px; margin-bottom: 40px; max-width: 46rem; }
.lede { font-size: 1.2rem; color: var(--ink-2); }
.meta { font: .85rem var(--font-mono); color: var(--ink-3); }
.post { max-width: calc(46rem + 40px); }
.post-foot { margin-top: 56px; padding-top: 24px; border-top: 1px dashed var(--line); color: var(--ink-2); }
.prose { max-width: 46rem; }
.prose h2 { margin-top: 1.8em; }
.prose h3 { margin-top: 1.5em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin-bottom: .35em; }
.prose blockquote { margin: 1.5em 0; padding: 4px 0 4px 20px; border-left: 4px solid var(--accent); color: var(--ink-2); }
.prose blockquote h3 { display: none; } /* old posts used a heading as a decorative quote mark */
.prose img { border-radius: 10px; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5em 0; }
.prose table { border-collapse: collapse; width: 100%; font-size: .95rem; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; }
code, pre { font-family: var(--font-mono); font-size: .88em; }
:not(pre) > code { background: var(--bg-2); border: 1px solid var(--line); padding: .1em .35em; border-radius: 5px; }
pre { background: #1d1f24; color: #e7e3da; padding: 18px 20px; border-radius: 12px; overflow-x: auto; line-height: 1.55; }
:root[data-theme="terminal"] pre { background: var(--bg-2); color: var(--ink); border: 1px solid var(--line); }
.highlight .c, .highlight .c1, .highlight .cm { color: #8a8f98; font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .ow { color: #ff9a6e; }
.highlight .s, .highlight .s1, .highlight .s2 { color: #a8d98a; }
.highlight .m, .highlight .mi, .highlight .mf { color: #f5c46b; }
.highlight .nf, .highlight .nb { color: #82c7ff; }
:root[data-theme="terminal"] .highlight * { color: inherit !important; }

/* ---------- About ---------- */
.about-intro { display: grid; grid-template-columns: 220px 1fr; gap: 48px; padding-top: 64px; align-items: start; }
.about-intro__photo { border-radius: 50%; aspect-ratio: 1; object-fit: cover; background: var(--accent-soft); box-shadow: 8px 8px 0 var(--accent); }
@media (max-width: 720px) { .about-intro { grid-template-columns: 1fr; gap: 24px; } .about-intro__photo { width: 140px; } }

.timeline { list-style: none; margin: 0; padding: 0 0 0 28px; border-left: 2px solid var(--line); display: grid; gap: 28px; }
.timeline__item { position: relative; }
.timeline__item::before { content: ""; position: absolute; left: -36px; top: 6px; width: 14px; height: 14px; border-radius: 50%; background: var(--bg); border: 3px solid var(--ink-3); }
.timeline__item.is-current::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }
.timeline__item.is-school::before { border-radius: 3px; }
.timeline__item h3 { margin: 2px 0; }
.timeline__item p { margin: 0; color: var(--ink-2); }
.timeline__dates { font: .78rem var(--font-mono); color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Bookshelf ---------- */
.shelf { margin-bottom: 48px; }
.shelf__name { font-size: 1.1rem; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.shelf__books {
  --row: 250px; --plank: 12px;
  list-style: none; margin: 0; padding: 0 10px;
  display: grid; grid-template-columns: repeat(auto-fill, 54px); grid-auto-rows: var(--row);
  column-gap: 5px; row-gap: var(--plank); align-items: end;
  /* a plank under every row */
  background: repeating-linear-gradient(to bottom, transparent 0 var(--row),
    color-mix(in srgb, var(--ink) 55%, #8b5a2b) var(--row) calc(var(--row) + var(--plank)));
  padding-bottom: var(--plank);
}
.spine {
  height: var(--h); width: 100%;
  background: hsl(var(--hue) 45% 40%);
  background-image: linear-gradient(90deg, rgb(0 0 0 / .2), transparent 18%, transparent 82%, rgb(0 0 0 / .25));
  color: #fff; border-radius: 3px 3px 0 0;
  writing-mode: vertical-rl;
  display: flex; flex-direction: column; justify-content: space-between; gap: 8px; padding: 12px 6px;
  cursor: default; transition: transform .2s; overflow: hidden;
}
.spine__title { font: 600 .8rem/1.15 var(--font-display); overflow: hidden; }
.spine__author { font: .62rem/1.1 var(--font-mono); opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spine:hover, .spine:focus { transform: translateY(-10px) rotate(-2deg); }
:root[data-theme="terminal"] .spine { background: var(--card); color: var(--ink); border: 1px solid var(--ink-3); }

/* ---------- Error pages ---------- */
.error-page { display: flex; gap: 40px; align-items: center; padding-top: 96px; flex-wrap: wrap; }
.error-page img { animation: drift 8s ease-in-out infinite; }
@keyframes drift { 50% { transform: translate(8px, -14px) rotate(6deg); } }

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

/* ---------- Lab: SQL formatter ---------- */
.fmt { margin-bottom: 48px; }
.fmt__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-bottom: 16px; }
.fmt__bar label { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.fmt__bar select { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.fmt__bar .btn { cursor: pointer; font: inherit; font-weight: 600; }
.fmt__bar .btn:disabled { opacity: .6; cursor: progress; }
.fmt__dl { font: 500 .9rem var(--font-mono); }
.fmt__panes { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .fmt__panes { grid-template-columns: 1fr; } }
.fmt__pane { display: grid; grid-template-rows: auto 1fr; gap: 6px; min-width: 0; }
.fmt__pane .kicker { display: flex; justify-content: space-between; margin: 0; }
.fmt__pane textarea, .fmt__pane pre { margin: 0; min-height: 300px; width: 100%; font: .88rem/1.55 var(--font-mono); padding: 16px 18px; border-radius: 12px; }
.fmt__pane textarea { resize: vertical; background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.fmt__pane pre { white-space: pre-wrap; }
.fmt__copy { font: 600 .7rem var(--font-mono); text-transform: uppercase; border: 0; background: none; color: var(--link); cursor: pointer; padding: 0; }
.fmt__status { margin: 16px 0 8px; color: var(--ink-2); font-weight: 500; min-height: 1.6em; }
.fmt__issues { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: .92rem; color: var(--ink-2); }
.fmt__issues strong { font-family: var(--font-mono); color: var(--accent); }
.fmt__rule { font: .8rem var(--font-mono); color: var(--ink-3); margin-right: 6px; }

/* ---------- Recipes (/drinks and the bar's "Favorite drinks" panel) ---------- */
.recipes { display: grid; gap: 22px; margin-top: 8px; }
.recipe { display: grid; gap: 6px; padding-top: 16px; border-top: 1px solid var(--line); }
.recipe__name { margin: 0; font: 700 1.3rem/1.2 var(--font-display); color: var(--ink); text-wrap: balance; }
.recipe__meta { margin: 0; font: .78rem/1.4 var(--font-mono); color: var(--ink-3); }
.recipe__build { margin: 4px 0 0; padding-left: 1.1em; display: grid; gap: 2px; color: var(--ink); font-variant-numeric: tabular-nums; }
.recipe__method, .recipe__note { margin: 4px 0 0; color: var(--ink-2); }
