/* ============================================================
   Firas Bouzazi / blog
   A quiet, typography-first stylesheet. Monochrome by design:
   the only "color" is the text itself. Two themes, no frameworks.
   ============================================================ */

:root {
  /* Type */
  --serif: "Charter", "Bitstream Charter", "Sitka Text", Cambria, Georgia, "Times New Roman", serif;
  --mono:  ui-monospace, "SF Mono", "JetBrains Mono", "Fira Mono", "Cascadia Code", Menlo, Consolas, monospace;

  /* Light theme (default) */
  --bg:      #fbfbfa;
  --fg:      #14140f;
  --muted:   #6b6b64;
  --faint:   #8f8f88;
  --rule:    #e4e3df;
  --mark:    #14140f;      /* underline / marks share the text color */
  --code-bg: #f1f1ee;
  --sel:     #dcdcd6;

  --measure: 40rem;        /* reading width ~ 66 characters */
  --gutter:  clamp(1.25rem, 5vw, 2.5rem);
}

:root[data-theme="dark"] {
  --bg:      #0b0b0b;
  --fg:      #e9e9e4;
  --muted:   #9a9a92;
  --faint:   #6f6f68;
  --rule:    #242422;
  --mark:    #e9e9e4;
  --code-bg: #161615;
  --sel:     #2a2a28;
}

/* Respect the OS when the reader hasn't chosen (no data-theme set) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:      #0b0b0b;
    --fg:      #e9e9e4;
    --muted:   #9a9a92;
    --faint:   #6f6f68;
    --rule:    #242422;
    --mark:    #e9e9e4;
    --code-bg: #161615;
    --sel:     #2a2a28;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.65;
  font-feature-settings: "kern", "liga", "onum", "pnum";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .28s ease, color .28s ease;
}

::selection { background: var(--sel); }

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------- Header ---------- */

.site-head {
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 3.5rem) var(--gutter) 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.site-head a.home {
  font-family: var(--mono);
  font-size: .82rem;
  letter-spacing: .02em;
  text-transform: lowercase;
  color: var(--fg);
  text-decoration: none;
  border: none;
}
.site-head a.home:hover { color: var(--muted); }

/* Theme toggle: a bare glyph, no chrome */
.theme-toggle {
  font-family: var(--mono);
  font-size: .82rem;
  letter-spacing: .02em;
  color: var(--muted);
  background: none;
  border: none;
  padding: .25rem 0;
  cursor: pointer;
  line-height: 1;
}
.theme-toggle:hover { color: var(--fg); }
.theme-toggle:focus-visible { outline: 1.5px solid var(--fg); outline-offset: 3px; }

/* ---------- Links ---------- */

a {
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition: border-color .15s ease, color .15s ease;
}
a:hover { border-color: var(--mark); }
:focus-visible { outline: 1.5px solid var(--fg); outline-offset: 2px; }

/* ---------- Home / index ---------- */

.intro {
  padding: clamp(2.5rem, 7vw, 4rem) 0 clamp(2rem, 5vw, 3rem);
}
.intro h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  line-height: 1.15;
  letter-spacing: -.01em;
  margin: 0 0 .9rem;
}
.intro p {
  margin: 0;
  color: var(--muted);
  font-size: 1.06rem;
  max-width: 34rem;
}

.section-label {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 1.4rem;
  padding-bottom: .7rem;
  border-bottom: 1px solid var(--rule);
}

/* Post list */
.posts { list-style: none; margin: 0 0 4rem; padding: 0; }
.posts li { margin: 0; }
.posts li + li { border-top: 1px solid var(--rule); }

.posts a.entry {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: .5rem 1.5rem;
  padding: 1.15rem 0;
  border: none;
}
.posts a.entry:hover .entry-title { color: var(--muted); }
.entry-title {
  font-size: 1.1rem;
  font-weight: 500;
  transition: color .15s ease;
}
.entry-date {
  font-family: var(--mono);
  font-size: .74rem;
  letter-spacing: .04em;
  color: var(--faint);
  white-space: nowrap;
}
.entry-desc {
  grid-column: 1 / -1;
  margin: .3rem 0 0;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.55;
}

/* ---------- Article ---------- */

article.post { padding: clamp(2rem, 5vw, 3rem) 0 0; }

.post-head { margin-bottom: 2.6rem; }
.post-head .meta {
  font-family: var(--mono);
  font-size: .74rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 1rem;
}
.post-head h1 {
  font-weight: 500;
  font-size: clamp(1.9rem, 5.5vw, 2.6rem);
  line-height: 1.12;
  letter-spacing: -.015em;
  margin: 0;
}

.prose { }
.prose > * + * { margin-top: 1.35rem; }
.prose h2 {
  font-weight: 500;
  font-size: 1.4rem;
  letter-spacing: -.01em;
  line-height: 1.25;
  margin-top: 2.8rem;
}
.prose h3 {
  font-weight: 600;
  font-size: 1.12rem;
  margin-top: 2rem;
}
.prose p, .prose ul, .prose ol { color: var(--fg); }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li + li { margin-top: .4rem; }
.prose a { border-bottom-color: var(--muted); }

.prose blockquote {
  margin: 1.8rem 0;
  padding-left: 1.3rem;
  border-left: 2px solid var(--rule);
  color: var(--muted);
  font-style: italic;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 3rem auto;
  width: 100%;
}

/* Code */
.prose code {
  font-family: var(--mono);
  font-size: .84em;
  background: var(--code-bg);
  padding: .12em .4em;
  border-radius: 3px;
}
.prose pre {
  font-family: var(--mono);
  font-size: .8rem;
  line-height: 1.6;
  background: var(--code-bg);
  padding: 1.1rem 1.2rem;
  border-radius: 5px;
  overflow-x: auto;
  border: 1px solid var(--rule);
}
.prose pre code { background: none; padding: 0; font-size: inherit; }

figure { margin: 2rem 0; }
figure img { display: block; width: 100%; height: auto; border-radius: 4px; }
figcaption {
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--faint);
  margin-top: .6rem;
  text-align: center;
}

/* ---------- Footer ---------- */

.site-foot {
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(3rem, 8vw, 5rem) var(--gutter) clamp(2.5rem, 6vw, 4rem);
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  align-items: baseline;
  font-family: var(--mono);
  font-size: .76rem;
  letter-spacing: .02em;
  color: var(--faint);
}
.site-foot a {
  color: var(--muted);
  border: none;
}
.site-foot a:hover { color: var(--fg); }
.site-foot .spacer { flex: 1; }

/* Back link on article pages */
.back {
  font-family: var(--mono);
  font-size: .76rem;
  letter-spacing: .02em;
  color: var(--muted);
  border: none;
  display: inline-block;
  margin-top: 4rem;
}
.back:hover { color: var(--fg); }
.back::before { content: "\2190\00a0"; }

/* Subtitle under a post title */
.post-head .dek {
  margin: .9rem 0 0;
  color: var(--muted);
  font-size: 1.1rem;
  font-style: italic;
  line-height: 1.45;
}

/* Tables */
.table-wrap { overflow-x: auto; }
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  line-height: 1.5;
}
.prose th, .prose td {
  text-align: left;
  vertical-align: top;
  padding: .65rem 1rem .65rem 0;
  border-bottom: 1px solid var(--rule);
}
.prose th {
  font-family: var(--mono);
  font-size: .7rem;
  font-weight: 400;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
}

/* Diagrams: inline SVG, themed through the same tokens as the text */
.diagram svg {
  display: block;
  width: 100%;
  max-width: 440px;
  height: auto;
  margin: 0 auto;
  color: var(--muted);
  font-family: var(--mono);
}
.diagram .lane-line { stroke: var(--rule); stroke-dasharray: 2 4; }
.diagram .lane-title { fill: var(--faint); font-size: 9.5px; letter-spacing: .12em; text-anchor: middle; }
.diagram .box { fill: var(--bg); stroke: var(--muted); stroke-width: 1; }
.diagram .box.agent, .diagram .box.strong { fill: var(--code-bg); stroke: var(--fg); }
.diagram .box.auto { stroke-dasharray: 3 3; }
.diagram .label { fill: var(--fg); font-size: 11.5px; text-anchor: middle; dominant-baseline: central; }
.diagram .num { fill: var(--faint); font-size: 10px; dominant-baseline: central; }
.diagram .edge { fill: none; stroke: currentColor; stroke-width: 1; }
.diagram .ah { fill: currentColor; }

.diagram .group { fill: none; stroke: var(--rule); stroke-dasharray: 4 4; }
.diagram .group-title { fill: var(--faint); font-size: 9.5px; letter-spacing: .12em; }
.diagram .label.sm, .diagram .label .sm { font-size: 9.5px; fill: var(--muted); }
.diagram .label.xs { font-size: 9px; }
.diagram .cell { fill: none; stroke: var(--muted); stroke-width: 1; }
.diagram .cell.alt { fill: var(--code-bg); }
.diagram .zpath { fill: none; stroke: var(--fg); stroke-width: 1.6; stroke-dasharray: 6 4; }
.diagram .zdot { fill: var(--fg); }
.diagram .caption { fill: var(--faint); font-size: 9.5px; text-anchor: middle; }

/* Short tips inside a post */
.prose .tip {
  border-left: 2px solid var(--rule);
  padding: .1rem 0 .1rem 1rem;
  color: var(--muted);
  font-size: .95rem;
}
.prose .tip::before {
  content: "Note";
  display: block;
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: .15rem;
}
.prose .origin { color: var(--muted); font-size: .9rem; }

@media (max-width: 480px) {
  body { font-size: 18px; }
}
