/* tech.leonardotamiano.xyz — violet/black, high contrast, built to be read */

:root {
  /* dark is the primary design; light is a legible inversion */
  --bg:          #0c0a12;
  --bg-raised:   #14111d;
  --bg-code:     #12101a;
  --bg-inline:   #1d1830;
  --border:      #292338;
  --border-soft: #1e1a2b;

  --fg:          #ded9ee;
  --fg-strong:   #f4f1ff;
  --fg-muted:    #8f89a8;
  --fg-faint:    #635d7a;

  --violet:      #a97bff;
  --violet-dim:  #8358d6;
  --violet-glow: rgba(169, 123, 255, 0.16);
  --cyan:        #5fd3dd;
  --rose:        #f08aa8;
  --string:      #8fd48a;

  --link:        #b98cff;
  --link-hover:  #d9c2ff;

  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "SF Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;

  --measure: 74ch;   /* prose line length */
  --wrap: 92ch;      /* page shell: the measure plus room for code to break out */
  --radius: 6px;
}

:root[data-theme="light"] {
  --bg:          #faf8ff;
  --bg-raised:   #ffffff;
  --bg-code:     #1a1626;   /* code stays dark in both themes: it reads better */
  --bg-inline:   #efe9fb;
  --border:      #ddd5ee;
  --border-soft: #eae4f6;

  --fg:          #241f33;
  --fg-strong:   #120f1c;
  --fg-muted:    #605978;
  --fg-faint:    #8b839f;

  --violet:      #6b34cc;
  --violet-dim:  #7c4ddb;
  --violet-glow: rgba(107, 52, 204, 0.10);
  --cyan:        #10707c;
  --rose:        #c03a63;
  --string:      #1c7a44;

  --link:        #6b34cc;
  --link-hover:  #4c1ba1;
}

* { box-sizing: border-box; }

/* class-level `display` beats the UA rule for [hidden], and the filter relies
   on the attribute — so make it win everywhere */
[hidden] { display: none !important; }

/* Fluid root size: ~16.5px on a phone, ~21px at 1280, ~25px at 1920, capped at
   26px. The floor keeps small screens at a normal reading size; the steep ramp
   is what makes a large monitor feel zoomed in rather than sparse. The rem term
   keeps browser zoom and user font-size settings working — a pure vw value
   would not. Everything else is sized in rem/em/ch and scales with it. */
html {
  font-size: clamp(16.5px, 0.9rem + 0.55vw, 26px);
  scroll-behavior: smooth;
  scroll-padding-top: 2rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* faint violet wash at the top of the page, purely decorative */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 420px at 50% -180px, var(--violet-glow), transparent 70%);
}

/* measured in ch so the shell keeps its proportion to the 74ch reading column
   as the root size grows — otherwise big screens just widen the right gutter */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 1.5rem;
  position: relative;
  z-index: 1;
}

/* ---------------------------------------------------------------- header */

.site-header {
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.site-title {
  font-family: var(--font-mono);
  font-size: 1.0rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg-strong);
  text-decoration: none;
  border: none;
  white-space: nowrap;
}

/* the title is an s-expression, tokenised like a code block */
.site-title .paren { color: var(--fg-faint); }
.site-title .fn    { color: var(--violet); }
.site-title .str   { color: var(--string); }

.site-title:hover .paren { color: var(--violet); }
.site-title:hover .str   { color: var(--fg-strong); }

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.site-nav a {
  color: var(--fg-muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.site-nav a:hover { color: var(--violet); border-bottom-color: var(--violet); }

/* A single bit: 1 = dark, 0 = light. Drawn as a 5x7 pixel glyph so it stays
   crisp at any zoom without shipping a bitmap font. */
#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 2px;
  cursor: pointer;
  line-height: 0;
  padding: 0.3rem 0.45rem;
}

#theme-toggle .bit {
  fill: var(--fg-muted);
  shape-rendering: crispEdges;
  display: block;
  width: 0.75em;
  height: 1.05em;
}

#theme-toggle:hover { border-color: var(--violet-dim); }
#theme-toggle:hover .bit { fill: var(--violet); }

#theme-toggle:focus-visible {
  outline: none;
  border-color: var(--violet-dim);
  box-shadow: 0 0 0 3px var(--violet-glow);
}

/* show only the bit matching the active theme */
#theme-toggle .bit-0 { display: none; }
:root[data-theme="light"] #theme-toggle .bit-1 { display: none; }
:root[data-theme="light"] #theme-toggle .bit-0 { display: block; }

main.wrap { padding: 3rem 1.5rem 5rem; }

/* -------------------------------------------------------- index / search */

.page-title {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--fg-strong);
  margin: 0 0 1.5rem;
}

.page-title::before { content: "> "; color: var(--violet); }

.controls { margin-bottom: 1.5rem; }

.result-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fg-faint);
  margin: 0 0 1.5rem;
}

#filter {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  padding: 0.6rem 0.85rem;
}

#filter::placeholder { color: var(--fg-faint); }
#filter:focus {
  outline: none;
  border-color: var(--violet-dim);
  box-shadow: 0 0 0 3px var(--violet-glow);
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.9rem;
}

.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--fg-muted);
  background: var(--bg-inline);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 0.18rem 0.6rem;
  text-decoration: none;
}

.tag span { color: var(--fg-faint); }

button.tag { cursor: pointer; }

button.tag:hover,
a.tag:hover {
  color: var(--violet);
  border-color: var(--violet-dim);
}

button.tag.active {
  background: var(--violet-dim);
  border-color: var(--violet-dim);
  color: #fff;
}

button.tag.active span { color: rgba(255, 255, 255, 0.7); }

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.year-sep {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fg-faint);
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin: 2.2rem 0 1rem;
}

.year-sep:first-child { margin-top: 0; }

.year-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-soft);
}

.post-card { margin: 0 0 0.4rem; }

.post-card a {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 1rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: background 0.15s, border-color 0.15s;
}

.post-card a:hover {
  background: var(--bg-raised);
  border-color: var(--border);
}

.post-card time {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--fg-faint);
}

.post-card h2 {
  margin: 0.25rem 0 0.4rem;
  font-size: 1.14rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--fg-strong);
}

.post-card a:hover h2 { color: var(--violet); }

.post-card p {
  margin: 0 0 0.6rem;
  font-size: 0.92rem;
  color: var(--fg-muted);
  max-width: var(--measure);
}

.post-card .tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.no-results {
  color: var(--fg-faint);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 2rem 0;
}

/* ------------------------------------------------------------------ post */

.back-link {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--fg-muted);
  text-decoration: none;
  margin-bottom: 2rem;
}

.back-link:hover { color: var(--violet); }
.back-link.bottom { margin: 3rem 0 0; }

.post-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.post-header h1 {
  margin: 0 0 0.6rem;
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--fg-strong);
}

.post-meta {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--fg-faint);
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.post-meta .sep { color: var(--border); }
.post-meta .section { color: var(--cyan); }

.post-header .tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }

article { max-width: var(--measure); }

article p { margin: 0 0 1.3rem; }

article h2, article h3, article h4, article h5, article h6 {
  color: var(--fg-strong);
  line-height: 1.3;
  letter-spacing: -0.01em;
  scroll-margin-top: 5rem;
  position: relative;
}

article h2 {
  font-size: 1.5rem;
  margin: 3rem 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-soft);
}

article h3 { font-size: 1.2rem;  margin: 2.2rem 0 0.8rem; }
article h4 { font-size: 1.03rem; margin: 1.8rem 0 0.6rem; color: var(--violet); }
article h5,
article h6 { font-size: 0.95rem; margin: 1.5rem 0 0.5rem; color: var(--fg-muted); }

.anchor {
  color: var(--violet-dim);
  text-decoration: none;
  margin-left: 0.5rem;
  opacity: 0;
  font-weight: 400;
  transition: opacity 0.15s;
}

h2:hover .anchor, h3:hover .anchor, h4:hover .anchor,
h5:hover .anchor, h6:hover .anchor { opacity: 1; }

a { color: var(--link); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--link) 35%, transparent); }
a:hover { color: var(--link-hover); border-bottom-color: var(--link-hover); }

article ul, article ol { margin: 0 0 1.3rem; padding-left: 1.4rem; }
article li { margin-bottom: 0.5rem; }
article li::marker { color: var(--violet-dim); }

/* org checkbox lists: - [ ] / - [X] / - [-] */
article ul.checklist { list-style: none; padding-left: 0.2rem; }

article ul.checklist li.task {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

article ul.checklist li.task::marker { content: none; }

article ul.checklist input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  width: 1em;
  height: 1em;
  margin: 0;
  transform: translateY(0.12em);
  border: 1px solid var(--violet-dim);
  border-radius: 3px;
  background: var(--bg-inline);
  cursor: default;
}

article ul.checklist input[type="checkbox"]:checked {
  background: var(--violet-dim);
  border-color: var(--violet-dim);
}

/* the tick, drawn with a rotated border so no glyph font is needed */
article ul.checklist input[type="checkbox"]:checked::after {
  content: "";
  display: block;
  width: 0.28em;
  height: 0.55em;
  margin: 0.02em auto 0;
  border: solid #fff;
  border-width: 0 0.13em 0.13em 0;
  transform: rotate(42deg);
}

article ul.checklist li.done > span { color: var(--fg-muted); }

/* [-] partial: a dash rather than a tick */
article ul.checklist li.partial input[type="checkbox"] {
  background: var(--bg-inline);
  border-color: var(--violet-dim);
}
article ul.checklist li.partial input[type="checkbox"]::after {
  content: "";
  display: block;
  width: 0.5em;
  height: 0.13em;
  margin: 0.42em auto 0;
  background: var(--violet);
}

article strong { color: var(--fg-strong); font-weight: 650; }
article em { color: var(--fg); }
article del { color: var(--fg-faint); }

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 3rem 0;
}

.math-display {
  margin: 1.6rem 0;
  overflow-x: auto;
  overflow-y: hidden;
}

blockquote {
  margin: 1.6rem 0;
  padding: 0.2rem 0 0.2rem 1.2rem;
  border-left: 2px solid var(--violet-dim);
  color: var(--fg-muted);
  font-style: italic;
}

blockquote p:last-child { margin-bottom: 0; }

/* inline code */
article code,
.post-card code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--bg-inline);
  color: var(--violet);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  border: 1px solid var(--border-soft);
  word-break: break-word;
}

:root[data-theme="light"] article code { color: var(--violet); }

/* ------------------------------------------------------------ code blocks */

.code-block {
  margin: 1.6rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-code);
  overflow: hidden;
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0.75rem;
  background: color-mix(in srgb, #ffffff 4%, var(--bg-code));
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.code-lang { color: var(--violet); }
.code-block.example .code-lang { color: #6f6a86; }

.copy-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 3px;
  color: #6f6a86;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  padding: 0.1rem 0.4rem;
}

.copy-btn:hover { color: var(--violet); border-color: #292338; }
.copy-btn.done { color: #8fd48a; }

.code-block pre {
  margin: 0;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  color: #d8d4e8;
  tab-size: 4;
}

.code-block pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
  white-space: pre;
}

.code-block pre.example { color: #a9a3c0; }

.code-block figcaption {
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: #6f6a86;
}

.code-block.terminal .code-lang { color: #8fd48a; }
.code-block.terminal pre .prompt {
  color: #8fd48a;
  font-weight: 600;
  user-select: none;
}

/* ---------------------------------------------------------------- video */

figure.video { margin: 2rem 0; }

.video-frame {
  position: relative;
  padding-top: 56.25%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}

.video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

pre.verse {
  font-family: var(--font-mono);
  background: var(--bg-code);
  color: #d8d4e8;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow-x: auto;
}

/* --------------------------------------------------------------- figures */

figure.img {
  margin: 2rem 0;
  text-align: center;
}

figure.img img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  cursor: zoom-in;
}

figure.img figcaption {
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: var(--fg-faint);
  font-style: italic;
}

article p img { max-width: 100%; height: auto; border-radius: 3px; }

/* ---------------------------------------------------------------- tables */

.table-wrap {
  overflow-x: auto;
  margin: 1.6rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

caption {
  caption-side: bottom;
  padding: 0.6rem;
  font-size: 0.78rem;
  color: var(--fg-faint);
  font-style: italic;
}

th, td {
  padding: 0.55rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}

thead th {
  background: var(--bg-raised);
  color: var(--violet);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-raised); }

/* ------------------------------------------------------------------- toc */

.toc {
  margin: 0 0 2.5rem;
  padding: 1rem 1.2rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-left: 2px solid var(--violet-dim);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.toc-head {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-faint);
  margin-bottom: 0.6rem;
}

.toc ol {
  margin: 0;
  padding-left: 1.2rem;
  list-style: decimal;
}

.toc ol ol { padding-left: 1rem; margin-top: 0.25rem; list-style: lower-alpha; }
.toc li { margin: 0.2rem 0; }
.toc a { color: var(--fg-muted); border: none; }
.toc a:hover { color: var(--violet); }
.toc li::marker { color: var(--fg-faint); font-family: var(--font-mono); font-size: 0.8em; }

/* ------------------------------------------------------------- tag pages */

.tag-title {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  color: var(--violet);
  margin: 0 0 0.2rem;
}

/* -------------------------------------------------------------- lightbox */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 4, 12, 0.94);
  cursor: zoom-out;
  padding: 2rem;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ---------------------------------------------------------------- footer */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--fg-faint);
}

.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-footer a {
  color: var(--fg-muted);
  border-bottom: 1px solid transparent;
}

.site-footer a:hover { color: var(--violet); border-bottom-color: var(--violet); }

/* Code, tables and figures get to breathe past the prose measure on wide
   screens — the reading column stays narrow, the evidence does not. */
@media (min-width: 900px) {
  article > .code-block,
  article > .table-wrap,
  article > figure.img,
  article > figure.video {
    margin-left: -3rem;
    margin-right: -3rem;
  }
}

/* --------------------------------------------------------------- mobile */

@media (max-width: 640px) {
  main.wrap { padding: 2rem 1.1rem 3rem; }
  /* the s-expression title does not wrap, so let the nav drop to its own row
     when the two no longer fit side by side */
  .header-inner { flex-wrap: wrap; gap: 0.5rem 1rem; }
  .site-nav { margin-left: auto; gap: 0.9rem; }
  .site-title { font-size: 0.82rem; }
  .post-card a { padding: 0.85rem 0; }
  .post-card a:hover { border-color: transparent; background: none; }
  .code-block pre { font-size: 0.76rem; }
  .anchor { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

@media print {
  .site-header, .site-footer, .back-link, .controls, .scanlines, .copy-btn { display: none; }
  body { background: #fff; color: #000; }
}
