/* sellarafaeli.com — one stylesheet for every page. */

:root {
  --bg: #fbfaf7;
  --bg-2: #f3f1ec;
  --ink: #1b1a17;
  --ink-2: #4a4842;
  --muted: #8a867c;
  --rule: #e6e2d8;
  --accent: #c8461b;
  --accent-soft: #fbe6dc;
  --code-str: #2f7a4b;
  --code-num: #7a4fd6;
  --code-fn: #1f5fa8;
  --chart: #c8461b;

  --serif: "Newsreader", "Iowan Old Style", Palatino, Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --measure: 40rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211; --bg-2: #1c1c1a; --ink: #ecebe6; --ink-2: #c4c1b8; --muted: #8e8b82;
    --rule: #2c2b28; --accent: #ff8a5c; --accent-soft: #3a2219;
    --code-str: #94d3a2; --code-num: #c3a6ff; --code-fn: #8cc2ff; --chart: #e0683a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121211; --bg-2: #1c1c1a; --ink: #ecebe6; --ink-2: #c4c1b8; --muted: #8e8b82;
  --rule: #2c2b28; --accent: #ff8a5c; --accent-soft: #3a2219;
  --code-str: #94d3a2; --code-num: #c3a6ff; --code-fn: #8cc2ff; --chart: #e0683a;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.1875rem/1.65 var(--serif);
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); text-decoration-color: currentColor; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.wrap { max-width: var(--measure); margin: 0 auto; padding: 0 1rem 4rem; }
.muted { color: var(--muted); }

/* ---------- chrome ---------- */

.site-header {
  max-width: var(--measure); margin: 0 auto; padding: 1.25rem 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.brand { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; font-weight: 600; letter-spacing: -.01em; }
.brand img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.home .brand { visibility: hidden; }
.site-header nav { display: flex; align-items: center; gap: 1.1rem; font: 500 .8rem/1 var(--mono); text-transform: uppercase; letter-spacing: .06em; }
.site-header nav a { text-decoration: none; color: var(--ink-2); }
.site-header nav a:hover, .site-header nav a[aria-current] { color: var(--accent); }
.theme-toggle { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--rule); border-radius: 50%; background: transparent; color: var(--ink-2); cursor: pointer; padding: 0; }
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 15px; height: 15px; fill: currentColor; }

.site-footer {
  max-width: var(--measure); margin: 0 auto; padding: 2rem 1rem 3rem;
  border-top: 1px solid var(--rule);
  display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; justify-content: space-between;
  font: .78rem/1.4 var(--mono); color: var(--muted);
}
.site-footer .links { display: flex; gap: 1.1rem; flex-wrap: wrap; }
.site-footer a { text-decoration: none; }

/* ---------- shared bits ---------- */

.kicker { margin: 0 0 .6rem; font: 500 .75rem/1.3 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--accent); text-decoration: none; display: inline-block; }
a.kicker:hover { text-decoration: underline; }
.lede { font-size: 1.3rem; line-height: 1.5; color: var(--ink-2); margin: 0; }
.section-label { margin: 0 0 1rem; font: 500 .75rem/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; }
.section-head a { font: .8rem var(--mono); text-decoration: none; color: var(--ink-2); }
.section-head a:hover { color: var(--accent); }
.block { margin-top: 3.5rem; }

.page-head { padding: 2.5rem 0 2rem; }
.page-head h1, .entry-head h1, .hero h1 { font-weight: 600; letter-spacing: -.025em; line-height: 1.05; margin: 0 0 .9rem; }
.page-head h1 { font-size: clamp(2.6rem, 8vw, 3.75rem); }

/* post lists (blog index, essays, homepage) */
.postlist { list-style: none; margin: 0; padding: 0; }
.postlist li { border-top: 1px solid var(--rule); }
.postlist li:last-child { border-bottom: 1px solid var(--rule); }
.postlist a { display: grid; grid-template-columns: 4.2rem 1fr auto; gap: 1rem; align-items: baseline; padding: .7rem .25rem; text-decoration: none; transition: background .15s, padding .15s; }
.postlist.essays a { grid-template-columns: 1fr auto; }
.postlist a:hover { background: var(--bg-2); padding-left: .6rem; color: inherit; }
.postlist a:hover .t { color: var(--accent); }
.postlist time { font: .78rem var(--mono); color: var(--muted); white-space: nowrap; }
.postlist .t { line-height: 1.35; }
.postlist .star { color: var(--accent); font-size: .8em; }
.postlist .src { font: .7rem var(--mono); color: var(--muted); text-transform: lowercase; white-space: nowrap; }

.year { display: grid; grid-template-columns: 5rem 1fr; gap: 0 1rem; margin-bottom: 2.25rem; }
.year-label { margin: .7rem 0 0; font: 600 1rem/1 var(--mono); color: var(--ink-2); position: sticky; top: 1rem; align-self: start; }
.year .postlist a { grid-template-columns: 3.6rem 1fr auto; }

.toolbar { display: flex; gap: .75rem; align-items: center; margin-bottom: 2.25rem; flex-wrap: wrap; }
.search { flex: 1; min-width: 12rem; display: flex; align-items: center; gap: .5rem; padding: .55rem .8rem; border: 1px solid var(--rule); border-radius: 10px; background: var(--bg-2); }
.search:focus-within { border-color: var(--accent); }
.search svg { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: 1rem var(--serif); outline: none; }
kbd { font: .7rem var(--mono); color: var(--muted); border: 1px solid var(--rule); border-radius: 5px; padding: .1rem .4rem; }
.chip { font: 500 .78rem var(--mono); padding: .6rem .9rem; border-radius: 10px; border: 1px solid var(--rule); background: transparent; color: var(--ink-2); cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--bg); }

.elsewhere { margin-top: 3rem; padding: 1.5rem 1.5rem 1.25rem; background: var(--bg-2); border-radius: 14px; }
.elsewhere h2 { margin: 0 0 .75rem; font: 500 .75rem/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.elsewhere ul { margin: 0; padding-left: 1.1rem; }
.elsewhere li { margin: .3rem 0; }

/* ---------- home ---------- */

.hero { display: grid; grid-template-columns: auto 1fr; gap: 2rem; align-items: start; padding: 2rem 0 0; }
.hero h1 { font-size: clamp(2.8rem, 9vw, 4.25rem); }
.avatar { width: 160px; height: 160px; border-radius: 22px; object-fit: cover; box-shadow: 0 1px 0 var(--rule), 0 18px 40px -22px rgba(0,0,0,.45); transform: rotate(-2deg); transition: transform .3s; }
.avatar:hover { transform: rotate(0) scale(1.02); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.5rem 0 0; }
.btn { font: 500 .8rem/1 var(--mono); text-decoration: none; padding: .7rem 1rem; border-radius: 999px; border: 1px solid var(--rule); color: var(--ink); }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); color: var(--bg); }

.stats { list-style: none; padding: 0; margin: 3rem 0 0; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.stats li { padding: 1.1rem .5rem 1rem 0; }
.stats li + li { padding-left: 1rem; border-left: 1px solid var(--rule); }
.stats b { display: block; font-size: 2rem; font-weight: 600; letter-spacing: -.02em; line-height: 1; }
.stats span { display: block; margin-top: .35rem; font: .7rem/1.35 var(--mono); color: var(--muted); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 5rem 1fr; gap: 1rem; padding: .45rem 0; }
.timeline .when { font: .75rem/2.1 var(--mono); color: var(--muted); }
.timeline b { font-weight: 600; }
.aside { color: var(--ink-2); font-style: italic; margin: 1.25rem 0 0; }

.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
.card { display: block; padding: 1.1rem 1.2rem; border: 1px solid var(--rule); border-radius: 14px; text-decoration: none; transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--accent); transform: translateY(-2px); color: inherit; }
.card b { display: block; font-weight: 600; margin-bottom: .2rem; }
.card:hover b { color: var(--accent); }
.card span { display: block; font-size: .95rem; line-height: 1.45; color: var(--ink-2); }

/* ---------- posts ---------- */

.entry-head { padding: 2.5rem 0 1.75rem; margin-bottom: 2rem; border-bottom: 1px solid var(--rule); }
.entry-head h1 { font-size: clamp(2.1rem, 6vw, 3rem); }
.meta { margin: 0; font: .8rem var(--mono); color: var(--muted); }
.meta .dot { margin: 0 .5rem; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: 3.5rem; }
.pager a { display: block; padding: 1rem 1.1rem; border: 1px solid var(--rule); border-radius: 14px; text-decoration: none; line-height: 1.35; }
.pager a:hover { border-color: var(--accent); color: inherit; }
.pager .newer { text-align: right; grid-column: 2; }
.pager small { display: block; font: .7rem var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .3rem; }

/* ---------- prose (markdown) ---------- */

.prose { padding-top: 1rem; }
.post .prose, .index .prose { padding-top: 0; }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose table, .prose figure { margin: 0 0 1.25rem; }
.prose h1, .prose h2, .prose h3, .prose h4 { line-height: 1.2; letter-spacing: -.015em; font-weight: 600; margin: 2.4rem 0 .8rem; }
.prose h1 { font-size: 2.2rem; }
.prose h2 { font-size: 1.6rem; }
.prose h3 { font-size: 1.3rem; }
.prose h4 { font-size: 1.1rem; }
.prose li { margin: .3rem 0; }
.prose li::marker { color: var(--muted); }
.prose img { max-width: 100%; height: auto; border-radius: 8px; }
.prose hr { border: 0; text-align: center; margin: 2.5rem 0; }
.prose hr::after { content: "* * *"; color: var(--muted); letter-spacing: .5em; }
.prose blockquote { margin-left: 0; padding: .2rem 0 .2rem 1.2rem; border-left: 3px solid var(--accent); color: var(--ink-2); font-style: italic; }
.prose table { border-collapse: collapse; width: 100%; font-size: .95rem; display: block; overflow-x: auto; }
.prose th, .prose td { border-bottom: 1px solid var(--rule); padding: .5rem .75rem .5rem 0; text-align: left; }
.prose figcaption { text-align: center; font-size: .85rem; color: var(--muted); margin-top: .4rem; }
.prose .center { text-align: center; }
.prose .date, .prose .created_at { display: none; }
.prose .star { height: .7em; margin-right: .3em; }
/* drop caps used by the essays */
.prose .start { float: left; font-size: 3.4em; line-height: .85; font-weight: 600; margin: .08em .12em 0 0; color: var(--accent); }

.prose code { font: .86em var(--mono); background: var(--bg-2); padding: .12em .35em; border-radius: 5px; }
.prose pre { background: var(--bg-2); border: 1px solid var(--rule); border-radius: 12px; padding: 1rem 1.1rem; overflow-x: auto; line-height: 1.55; }
.prose pre code { background: none; padding: 0; font-size: .82rem; }
.prose .highlighter-rouge { margin: 0 0 1.25rem; }
.prose .highlighter-rouge pre { margin: 0; }

/* rouge tokens */
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs, .highlight .cp, .highlight .ch, .highlight .cd { color: var(--muted); font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kt, .highlight .kc, .highlight .ow { color: var(--accent); }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sc, .highlight .sd, .highlight .se, .highlight .sh, .highlight .si, .highlight .sx, .highlight .sr, .highlight .ss, .highlight .dl { color: var(--code-str); }
.highlight .m, .highlight .mi, .highlight .mf, .highlight .mh, .highlight .mo, .highlight .il, .highlight .no, .highlight .bp { color: var(--code-num); }
.highlight .nf, .highlight .fm, .highlight .nc, .highlight .nn, .highlight .nb, .highlight .na, .highlight .nt { color: var(--code-fn); }
.highlight .gd { color: var(--accent); }
.highlight .gi { color: var(--code-str); }
.highlight .err { color: inherit; background: none; }

/* ---------- admin (analytics dashboard) ---------- */

.admin .wrap, .admin .site-header, .admin .site-footer { max-width: 72rem; }
.admin-head { padding-bottom: 1.5rem; }
.admin-head h1 { font-size: clamp(2.2rem, 6vw, 3rem); }
.admin-head .kicker a { color: inherit; text-decoration: none; }
.admin .page-path { font: 600 clamp(1.3rem, 4vw, 2rem)/1.2 var(--mono); letter-spacing: -.02em; word-break: break-all; }
.admin .page-path a { text-decoration: none; }
.admin .toolbar { margin: 1.25rem 0 0; gap: .5rem; }
.admin .toolbar .spacer { flex: 1; }
.admin a.chip { text-decoration: none; }

.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: .75rem; margin-bottom: 1rem; }
@media (max-width: 1000px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
.kpi { padding: 1rem 1.1rem; border: 1px solid var(--rule); border-radius: 14px; }
.kpi-l, .kpi small { display: block; font: .7rem/1.4 var(--mono); color: var(--muted); }
.kpi-l { text-transform: uppercase; letter-spacing: .08em; }
.kpi b { display: block; margin: .35rem 0 .3rem; font: 600 1.9rem/1 var(--mono); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kpi .delta { color: var(--ink-2); }

.panel { padding: 1.25rem 1.35rem; border: 1px solid var(--rule); border-radius: 14px; margin-bottom: 1rem; min-width: 0; }
.panel .section-label .muted { text-transform: none; letter-spacing: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 0 1rem; }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.note, .empty { font: .75rem/1.5 var(--mono); color: var(--muted); margin: .9rem 0 0; }
.panel .empty { margin: 0; }
.note code { font-size: 1em; }
.nowrap { white-space: nowrap; }

/* columns chart: bars grow from one baseline, 2px surface gap, 4px rounded tops */
.cols { position: relative; padding-left: 2.6rem; }
.cols-plot { position: relative; height: 11rem; }
.cols-grid span { position: absolute; left: 0; right: 0; border-top: 1px solid var(--rule); }
.cols-grid b { position: absolute; right: 100%; margin-right: .5rem; top: -.35rem; font: 400 .65rem/1 var(--mono); color: var(--muted); }
.cols-bars, .spark { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 2px; border-bottom: 1px solid var(--ink-2); }
.dense .cols-bars, .spark.dense { gap: 1px; }
.col { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: default; min-width: 0; }
.col i { display: block; width: 100%; max-width: 24px; background: var(--chart); border-radius: 4px 4px 0 0; }
.dense .col i { border-radius: 2px 2px 0 0; }
.col:hover i { background: var(--ink); }
.col:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.cols-x { position: relative; height: 1.6rem; font: .65rem/1 var(--mono); color: var(--muted); }
.cols-x span { position: absolute; top: .55rem; transform: translateX(-50%); white-space: nowrap; }
.cols-x span:first-child { transform: none; left: 0 !important; }
.cols-x span:last-child { transform: none; left: auto !important; right: 0; }

.spark { position: relative; width: 8.5rem; height: 1.6rem; border-bottom-color: var(--rule); }
.spark .col i { border-radius: 1px 1px 0 0; min-height: 0; }

/* horizontal bar list: text in ink, the bar sits under it */
.barlist { list-style: none; margin: 0; padding: 0; }
.barlist li { position: relative; display: flex; gap: 1rem; justify-content: space-between; align-items: baseline; padding: .4rem 0 .6rem; font-size: .95rem; line-height: 1.3; }
.barlist .lbl { min-width: 0; overflow-wrap: anywhere; }
.barlist .num { font: .8rem var(--mono); white-space: nowrap; font-variant-numeric: tabular-nums; }
.barlist .num em { font-style: normal; color: var(--muted); }
.barlist i { position: absolute; left: 0; bottom: .2rem; height: 4px; border-radius: 2px; background: var(--chart); opacity: .85; }
.barlist li::after { content: ""; position: absolute; left: 0; right: 0; bottom: .2rem; height: 4px; border-radius: 2px; background: var(--bg-2); z-index: -1; }
.barlist a { text-decoration-color: var(--rule); }

.scroll { overflow-x: auto; margin: 0 -1.35rem; padding: 0 1.35rem; }
.dtable { width: 100%; border-collapse: collapse; font-size: .92rem; }
.dtable th { font: 500 .65rem/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); text-align: right; padding: 0 0 .6rem .9rem; white-space: nowrap; }
.dtable td { border-top: 1px solid var(--rule); padding: .5rem 0 .5rem .9rem; text-align: right; font: .8rem var(--mono); font-variant-numeric: tabular-nums; vertical-align: middle; }
.dtable th:first-child, .dtable td:first-child { text-align: left; padding-left: 0; }
.dtable td.path { font: .95rem/1.35 var(--serif); overflow-wrap: anywhere; min-width: 12rem; }
.dtable.visits td { text-align: left; }
.dtable.visits th { text-align: left; }
.dtable.visits td.path { font-size: .85rem; }
.dtable td .spark { margin-left: auto; }
.dtable tr.zero td { color: var(--muted); }
.dtable small.channel { display: block; font-size: .7rem; }
.datatable { margin-top: .5rem; }
.datatable summary { font: .75rem var(--mono); color: var(--muted); cursor: pointer; }
.datatable .dtable { max-width: 24rem; margin-top: .5rem; }

.tip { position: absolute; z-index: 10; pointer-events: none; background: var(--ink); color: var(--bg); font: .72rem/1.3 var(--mono); padding: .4rem .55rem; border-radius: 6px; white-space: nowrap; }

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  body { font-size: 1.0625rem; }
  .hero { grid-template-columns: 1fr; gap: 1.25rem; padding-top: .5rem; }
  .avatar { width: 112px; height: 112px; border-radius: 18px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats li:nth-child(3) { padding-left: 0; border-left: 0; }
  .stats li:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .cards, .pager { grid-template-columns: 1fr; }
  .pager .newer { grid-column: 1; }
  .year { grid-template-columns: 1fr; }
  .year-label { position: static; margin: 0 0 .6rem; }
  .postlist a, .year .postlist a { grid-template-columns: 3.4rem 1fr; }
  .postlist .src { grid-column: 2; }
  .timeline li { grid-template-columns: 4.2rem 1fr; gap: .75rem; }
  .site-header nav { gap: .8rem; }
  .panel { padding: 1rem; }
  .scroll { margin: 0 -1rem; padding: 0 1rem; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi b { font-size: 1.5rem; }
  .admin .toolbar .spacer { display: none; }
}
