/*
 * TechToSpeech.
 *
 * The old theme inlined ~200 KB of CSS into every page and pulled Muli and Open
 * Sans from Google Fonts over http. This is one file, no webfonts, no framework.
 * The brand blue (#0d42a2) and its lighter partner (#116ace) are carried over
 * because they are the site's only real visual signature.
 *
 * Nine of these pages are long technical write-ups full of shell and Terraform,
 * so code blocks get first-class treatment rather than being an afterthought.
 */

:root {
  --accent: #0d42a2;
  --accent-light: #116ace;
  --accent-ink: #ffffff;

  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --card: #ffffff;
  --border: #e3e6ec;
  --ink: #14171f;
  --ink-soft: #5a6273;
  --ink-faint: #8b93a3;

  --code-bg: #12182b;
  --code-ink: #e6ebf5;

  --wrap: 1120px;
  --narrow: 720px;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .05);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

/* Dark palette, defined twice on purpose.
 *
 * The media query alone is not enough once there is a toggle: a reader on a
 * dark-set OS who explicitly picks light must get light. So the tokens are
 * declared for (a) system-dark with no explicit choice, and (b) an explicit
 * dark choice regardless of the OS. `:root:not([data-theme="light"])` is what
 * lets the light choice win inside a dark media query.
 *
 * Three states, not two: light, dark, and unset (follow the OS). Unset is the
 * default and stamps no attribute at all. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #6fa2ff;
    --accent-light: #8fb8ff;
    --accent-ink: #0a1020;
    --bg: #0d1017;
    --bg-soft: #131824;
    --card: #141a26;
    --border: #232b3b;
    --ink: #e8ecf4;
    --ink-soft: #a4adbf;
    --ink-faint: #7b8496;
    --code-bg: #0a0e18;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

:root[data-theme="dark"] {
  --accent: #6fa2ff;
  --accent-light: #8fb8ff;
  --accent-ink: #0a1020;
  --bg: #0d1017;
  --bg-soft: #131824;
  --card: #141a26;
  --border: #232b3b;
  --ink: #e8ecf4;
  --ink-soft: #a4adbf;
  --ink-faint: #7b8496;
  --code-bg: #0a0e18;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
}

/* Tells the browser to render form controls and scrollbars to match. */
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { 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: 17px/1.65 var(--font);
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-ink); padding: .7rem 1rem;
}
.skip:focus { left: 0; }

.wrap { width: min(100% - 2.5rem, var(--wrap)); margin-inline: auto; }
.wrap.narrow { width: min(100% - 2.5rem, var(--narrow)); }

/* ---------------------------------------------------------------- header */

.site-head {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 40;
}
.head-inner { display: flex; align-items: center; gap: 2rem; min-height: 68px; }
.brand img { max-height: 34px; width: auto; }

.nav { margin-left: auto; }
.nav ul { display: flex; gap: 1.6rem; list-style: none; margin: 0; padding: 0; }
.nav a {
  color: var(--ink); text-decoration: none;
  font-size: 13px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
}
.nav a:hover { color: var(--accent); }
.nav .has-sub { position: relative; }
.nav .sub {
  display: none; position: absolute; top: 100%; left: -1rem; padding: .6rem 0;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); min-width: 190px; flex-direction: column; gap: 0;
}
.nav .has-sub:hover .sub, .nav .has-sub:focus-within .sub { display: flex; }
.nav .sub a { display: block; padding: .5rem 1.2rem; letter-spacing: .04em; }

/* ------------------------------------------------------- theme toggle */

.theme-toggle {
  margin-left: 1.4rem; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0;
  background: none; border: 1px solid var(--border); border-radius: 999px;
  color: var(--ink-soft); cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; display: block; }

/* Exactly one icon shows, chosen by the resolved theme rather than by script,
   so the right one is painted on the first frame with no swap. */
.theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: block; }
}

/* ------------------------------------------------------------------ hero */

.hero-band {
  background: linear-gradient(-45deg, var(--accent-light), var(--accent));
  color: #fff; padding: 3.2rem 0 3rem; margin-bottom: 3rem;
}
.hero-band h1 { margin: 0 0 .5rem; font-size: clamp(2rem, 5vw, 2.8rem); letter-spacing: -.02em; }
.hero-band .lede { margin: 0; max-width: 62ch; color: rgba(255, 255, 255, .92); font-size: 1.08rem; }

/* --------------------------------------------------------------- headings */

h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -.015em; font-weight: 800; }

.listing-head { margin: 2.6rem 0 2rem; }
.listing-head h1 { margin: 0 0 .5rem; font-size: clamp(1.8rem, 4vw, 2.4rem); }
.lede { color: var(--ink-soft); font-size: 1.05rem; margin: 0; max-width: 65ch; }

.section-title {
  font-size: 1.35rem; margin: 3rem 0 1.2rem;
  padding-bottom: .6rem; border-bottom: 2px solid var(--border);
}

.crumbs { font-size: .82rem; color: var(--ink-faint); margin-bottom: .7rem; }
.crumbs a { color: var(--ink-soft); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }

/* ----------------------------------------------------------------- chips */

.chips { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; padding: 0; margin: .9rem 0 0; }
.chip {
  display: inline-block; padding: .22rem .6rem; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
  text-decoration: none;
}
a.chip:hover { background: var(--accent); color: var(--accent-ink); }
.chip-plain { background: none; border-color: transparent; padding-inline: 0; }

/* ----------------------------------------------------------------- cards */

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.6rem; }
.cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.cards-wide { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
  transition: box-shadow .16s ease, transform .16s ease;
}
.card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.card img { aspect-ratio: 1200 / 630; object-fit: cover; width: 100%; }
.card-body { padding: 1.1rem 1.2rem 1.3rem; display: flex; flex-direction: column; gap: .45rem; }
.card h2, .card h3 { margin: 0; font-size: 1.1rem; }
.card h2 a, .card h3 a { color: var(--ink); text-decoration: none; }
.card h2 a:hover, .card h3 a:hover { color: var(--accent); }
.excerpt { margin: 0; color: var(--ink-soft); font-size: .93rem; }
.card-meta { margin: 0; color: var(--ink-faint); font-size: .82rem; }

.lead { display: grid; gap: 1.8rem; margin-bottom: 1rem; }
@media (min-width: 860px) { .lead { grid-template-columns: 1.3fr 1fr; align-items: center; } }
.lead img { border-radius: var(--radius); aspect-ratio: 1200 / 630; object-fit: cover; }
.lead-body { display: flex; flex-direction: column; gap: .6rem; align-items: flex-start; }
.lead h2 { margin: 0; font-size: clamp(1.5rem, 3.2vw, 2rem); }
.lead h2 a { color: var(--ink); text-decoration: none; }
.lead h2 a:hover { color: var(--accent); }

/* ---------------------------------------------------------------- topics */

.topic-grid, .topic-tree { list-style: none; margin: 0; padding: 0; }
.topic-grid { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.topic-grid a {
  display: flex; justify-content: space-between; align-items: baseline; gap: .6rem;
  padding: .8rem 1rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); text-decoration: none; color: var(--ink);
}
.topic-grid a:hover { border-color: var(--accent); color: var(--accent); }
.topic-grid span { color: var(--ink-faint); font-size: .82rem; }

.topic-tree > li { padding: 1.1rem 0; border-bottom: 1px solid var(--border); }
.topic-parent {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  text-decoration: none; color: var(--ink); font-size: 1.15rem;
}
.topic-parent:hover strong { color: var(--accent); }
.topic-parent span { color: var(--ink-faint); font-size: .85rem; font-weight: 400; }

/* ------------------------------------------------------------------ post */

.post { max-width: var(--narrow); margin-inline: auto; padding-top: 2.4rem; }
.post-head h1 { margin: .3rem 0 .8rem; font-size: clamp(1.9rem, 5vw, 2.6rem); }
.post-meta { margin: 0; color: var(--ink-faint); font-size: .9rem; }
.post-meta a { color: var(--ink-soft); }
.hero { border-radius: var(--radius); margin: 1.8rem 0 2.2rem; width: 100%; }

.prose { font-size: 1.06rem; }
.prose > * + * { margin-top: 1.15em; }
.prose h2 { font-size: 1.5rem; margin-top: 2.4em; }
.prose h3 { font-size: 1.2rem; margin-top: 1.9em; }
.prose img { border-radius: var(--radius); margin: 1.8rem 0; border: 1px solid var(--border); }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li + li { margin-top: .35em; }
.prose blockquote {
  margin-inline: 0; padding: .3rem 0 .3rem 1.2rem;
  border-left: 3px solid var(--accent); color: var(--ink-soft);
}
.prose table { width: 100%; border-collapse: collapse; font-size: .93rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: .5rem .7rem; text-align: left; }
.prose th { background: var(--bg-soft); font-weight: 700; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2.4rem 0; }

/* Code. One post carries four Enlighter blocks of shell and SQL; the rest use
   inline <code>. Both need to be readable, and a wide line must scroll inside
   its own box rather than widening the page. */
.prose code {
  font-family: var(--mono); font-size: .88em;
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  padding: .12em .38em; border-radius: 4px;
}
.prose pre {
  background: var(--code-bg); color: var(--code-ink);
  padding: 1.1rem 1.2rem; border-radius: var(--radius);
  overflow-x: auto; font-family: var(--mono); font-size: .86rem; line-height: 1.55;
  position: relative;
}
.prose pre code { background: none; padding: 0; font-size: inherit; color: inherit; }
.prose pre[data-lang]::before {
  content: attr(data-lang);
  position: absolute; top: .5rem; left: 1.2rem;
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-faint);
}
.prose pre[data-lang] { padding-top: 1.9rem; }

.copy-btn {
  position: absolute; top: .45rem; right: .5rem;
  padding: .25rem .6rem; border-radius: 6px;
  background: rgba(255, 255, 255, .08); color: var(--code-ink);
  border: 1px solid rgba(255, 255, 255, .18);
  font: 600 11px/1.4 var(--font); cursor: pointer;
  opacity: 0; transition: opacity .15s ease;
}
.prose pre:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { background: rgba(255, 255, 255, .16); }
/* Touch devices have no hover, so the button would be unreachable. */
@media (hover: none) { .copy-btn { opacity: 1; } }

.prevnext { display: grid; gap: 1rem; margin: 3rem 0 1rem; }
@media (min-width: 700px) { .prevnext { grid-template-columns: 1fr 1fr; } }
.pn {
  border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1.1rem;
  text-decoration: none; color: var(--ink); background: var(--card);
}
.pn:hover { border-color: var(--accent); }
.pn span { display: block; font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-faint); margin-bottom: .25rem; }
.pn.next { text-align: right; }

.related { margin: 3.5rem auto 4rem; }
.related h2 { font-size: 1.3rem; margin-bottom: 1.2rem; }

/* ---------------------------------------------------------------- author */

.author-card {
  display: flex; gap: 1.4rem; align-items: flex-start; flex-wrap: wrap;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.4rem; margin-top: 2rem;
}
.author-card img { border-radius: 50%; width: 96px; height: 96px; object-fit: cover; }
.author-card > div { flex: 1 1 320px; }
.author-card h2 { margin: 0 0 .5rem; font-size: 1.2rem; }
.author-card p { margin: 0 0 .7rem; font-size: .95rem; color: var(--ink-soft); }
.socials { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .88rem; }

.link-list { list-style: none; padding: 0; margin: 0; }
.link-list li { padding: .7rem 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.link-list time { color: var(--ink-faint); font-size: .84rem; }

.empty {
  border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 2.2rem; text-align: center; color: var(--ink-soft); background: var(--bg-soft);
}
.empty p { margin: 0 0 .6rem; }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-block; padding: .6rem 1.1rem; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
  font-weight: 700; font-size: .92rem; text-decoration: none; cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: var(--accent-light); border-color: var(--accent-light); }
.btn-quiet { background: none; color: var(--accent); }
.btn-quiet:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); }

/* ---------------------------------------------------------------- footer */

.site-foot {
  margin-top: 4.5rem; padding: 2.4rem 0 3rem;
  background: linear-gradient(-45deg, var(--accent-light), var(--accent));
  color: rgba(255, 255, 255, .85);
}
.site-foot ul { display: flex; flex-wrap: wrap; gap: 1.4rem; list-style: none; margin: 0 0 1.2rem; padding: 0; }
.site-foot a { color: #fff; text-decoration: none; font-size: .9rem; }
.site-foot a:hover { text-decoration: underline; }
.foot-meta { margin: 0; font-size: .85rem; }

/* The bespoke consent banner and its styles are gone: Google's certified CMP
   is now the only consent surface, and it brings its own UI. See
   data/site.json for why a second banner of our own cannot work. */

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media print {
  .site-head, .site-foot, .consent, .prevnext, .related { display: none; }
  body { font-size: 11pt; }
}
