/* ==========================================================================
   colinmasters.com — editorial / industrial design system
   Tokens first, then primitives, then components. Light + dark themes.
   ========================================================================== */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/inter-latin-1f021a24.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("/assets/jetbrains-mono-latin-7c88d0cc.woff2") format("woff2");
}

/* ---- Tokens ------------------------------------------------------------- */

:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --bg: #f7f8f9;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --frost: rgba(255, 255, 255, 0.72);
  --text: #16191d;
  --text-secondary: #454c54;
  --muted: #6b747e;
  --border: #e0e4e8;
  --border-strong: #c8ced5;
  --accent: #0b66d0;
  --accent-soft: rgba(11, 102, 208, 0.09);
  --glow: rgba(11, 102, 208, 0.10);
  --blueprint-line: rgba(22, 25, 29, 0.05);
  --code-bg: #14181d;

  --radius: 10px;
  --content: 44rem;
  --wide: 72rem;
}

[data-theme="dark"] {
  --bg: #0e1116;
  --surface: #141920;
  --surface-raised: #1a2028;
  --frost: rgba(14, 17, 22, 0.72);
  --text: #e8ebee;
  --text-secondary: #aeb6bf;
  --muted: #7d8791;
  --border: #232a33;
  --border-strong: #333c47;
  --accent: #5aa2ff;
  --accent-soft: rgba(90, 162, 255, 0.10);
  --glow: rgba(90, 162, 255, 0.07);
  --blueprint-line: rgba(232, 235, 238, 0.045);
  --code-bg: #10141a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116;
    --surface: #141920;
    --surface-raised: #1a2028;
    --frost: rgba(14, 17, 22, 0.72);
    --text: #e8ebee;
    --text-secondary: #aeb6bf;
    --muted: #7d8791;
    --border: #232a33;
    --border-strong: #333c47;
    --accent: #5aa2ff;
    --accent-soft: rgba(90, 162, 255, 0.10);
    --glow: rgba(90, 162, 255, 0.07);
    --blueprint-line: rgba(232, 235, 238, 0.045);
    --code-bg: #10141a;
  }
}

/* ---- Base --------------------------------------------------------------- */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text);
}

::selection { background: var(--accent-soft); }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

/* ---- Navigation --------------------------------------------------------- */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--frost);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.site-nav-inner {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0.875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-name {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.site-name:hover { text-decoration: none; }

.site-mark {
  width: 9px;
  height: 9px;
  border: 1.5px solid var(--accent);
  border-radius: 2px;
  transform: rotate(45deg);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.site-name:hover .site-mark { transform: rotate(135deg); }

.site-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.site-links > a {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.site-links > a:hover { color: var(--text); text-decoration: none; }

.theme-toggle {
  width: 38px;
  height: 22px;
  padding: 2px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.theme-toggle-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.25s ease, background-color 0.25s ease;
}

[data-theme="dark"] .theme-toggle-dot { transform: translateX(14px); background: var(--accent); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle-dot { transform: translateX(14px); background: var(--accent); }
}

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

.page { min-height: 70vh; }

.flash {
  max-width: var(--content);
  margin: 1.25rem auto 0;
  padding: 0.75rem 1.125rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.9375rem;
}
.flash-notice { border-left: 3px solid var(--accent); }
.flash-alert { border-left: 3px solid #d0453b; }

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 5rem;
}

.site-footer-inner {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.footer-meta { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.02em; }

/* ---- Hero ---------------------------------------------------------------- */

.hero {
  position: relative;
  border-bottom: 1px solid var(--border);
  background-image:
    radial-gradient(ellipse 60% 80% at 70% -10%, var(--glow), transparent),
    linear-gradient(var(--blueprint-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--blueprint-line) 1px, transparent 1px);
  background-size: auto, 32px 32px, 32px 32px;
}

.hero-inner {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 5.5rem 1.5rem 4.5rem;
}

.hero h1 {
  font-size: clamp(2.25rem, 5.5vw, 3.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 1.25rem;
}

.hero-lede {
  max-width: 34rem;
  font-size: 1.1875rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0;
}

/* ---- Catalog: search, filters, cards ------------------------------------ */

.catalog {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 0;
}

.catalog-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.search { flex: 1 1 16rem; max-width: 24rem; }

.search input {
  width: 100%;
  padding: 0.625rem 1rem;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search input::placeholder { color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.filter {
  padding: 0.375rem 0.875rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}
.filter:hover { border-color: var(--border-strong); color: var(--text); text-decoration: none; }
.filter.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
  gap: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: 0 12px 32px -16px rgba(0, 0, 0, 0.25), 0 0 0 1px var(--accent-soft);
}

.card-link { display: block; color: inherit; }
.card-link:hover { text-decoration: none; }

.card-visual {
  color: var(--muted);
  background:
    radial-gradient(ellipse 80% 120% at 50% -20%, var(--glow), transparent),
    var(--surface-raised);
  border-bottom: 1px solid var(--border);
  transition: color 0.25s ease;
}
.card:hover .card-visual { color: var(--accent); }

.post-motif { display: block; width: 100%; height: 8.5rem; }

.card-body { padding: 1.25rem 1.375rem 1.5rem; }

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.71875rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.tag {
  padding: 0.125rem 0.5rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
}

.card-body h2 {
  font-size: 1.25rem;
  margin: 0.75rem 0 0.5rem;
}

.card-body p {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.empty-state {
  padding: 4rem 0;
  text-align: center;
  color: var(--muted);
}

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

.progress-track {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 200;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
}

.article-layout {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 3.5rem 1.5rem 0;
  display: grid;
  grid-template-columns: minmax(0, var(--content)) 15rem;
  justify-content: center;
  gap: 4rem;
}

.article-header { margin-bottom: 2.5rem; }

.article-header h1 {
  font-size: clamp(1.875rem, 4.5vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0.875rem 0 0;
}

.article-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.back-link { font-family: var(--font-mono); font-size: 0.8125rem; }

/* Floating table of contents */

.toc {
  position: sticky;
  top: 5.5rem;
  align-self: start;
  font-size: 0.8125rem;
  padding-left: 1.25rem;
  border-left: 1px solid var(--border);
}

.toc-title {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0.5rem 0; }
.toc .toc-sub { padding-left: 0.875rem; }

.toc a {
  color: var(--muted);
  display: block;
  line-height: 1.4;
  transition: color 0.2s ease;
}
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.active { color: var(--accent); }

@media (max-width: 64rem) {
  .article-layout { grid-template-columns: minmax(0, var(--content)); }
  .toc { display: none; }
}

/* ---- Prose (rendered markdown) ------------------------------------------ */

.prose { font-size: 1.0625rem; color: var(--text); }

.prose > p:first-child {
  font-size: 1.1875rem;
  color: var(--text-secondary);
}

.prose h2, .prose h3 {
  margin: 2.5rem 0 0.875rem;
  scroll-margin-top: 5rem;
}
.prose h2 { font-size: 1.5rem; }
.prose h3 { font-size: 1.1875rem; }

.prose h2::before {
  content: "";
  display: block;
  width: 2rem;
  border-top: 2px solid var(--accent);
  margin-bottom: 0.875rem;
}

.prose p { margin: 1.125rem 0; }

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

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
  position: relative;
}
.prose hr::after {
  content: "◆";
  position: absolute;
  top: -0.6em;
  left: 50%;
  transform: translateX(-50%) scale(0.5);
  color: var(--border-strong);
  background: var(--bg);
  padding: 0 0.75rem;
}

.prose blockquote {
  margin: 2rem 0;
  padding: 0.25rem 0 0.25rem 1.5rem;
  border-left: 2px solid var(--accent);
  font-size: 1.1875rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-secondary);
}
.prose blockquote p { margin: 0.5rem 0; }

.prose ul, .prose ol { padding-left: 1.5rem; }
.prose li { margin: 0.375rem 0; }
.prose li::marker { color: var(--muted); }

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  margin: 1.5rem 0;
}
.prose th {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-align: left;
}
.prose th, .prose td {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border);
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--accent-soft);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

.prose pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.125rem 1.25rem;
  overflow-x: auto;
  line-height: 1.6;
  margin: 1.5rem 0;
}

.prose pre code {
  background: none;
  padding: 0;
  font-size: 0.8125rem;
  color: #d6dde4;
}

/* ---- Syntax highlighting (Rouge) ----------------------------------------
   One dark, engineering-toned palette for both themes — code blocks stay
   matte dark like a terminal. */

.highlight .c, .highlight .c1, .highlight .cm { color: #66737f; font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kr { color: #82aaff; }
.highlight .kt, .highlight .kc { color: #6fc3df; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sh { color: #97c98b; }
.highlight .si, .highlight .se { color: #b8d9ae; }
.highlight .mi, .highlight .mf, .highlight .mh, .highlight .il { color: #e0b184; }
.highlight .nf, .highlight .fm { color: #dfc890; }
.highlight .nc, .highlight .nn { color: #6fc3df; }
.highlight .no, .highlight .nb, .highlight .bp { color: #c792ea; }
.highlight .nv, .highlight .vi, .highlight .vg { color: #d6dde4; }
.highlight .ss, .highlight .sx { color: #c792ea; }
.highlight .o, .highlight .ow { color: #89ddff; }
.highlight .p, .highlight .pi { color: #9aa7b3; }
.highlight .gd { color: #e06c75; }
.highlight .gi { color: #97c98b; }
.highlight .err { color: #e06c75; background: none; }

/* ---- Forms & buttons ------------------------------------------------------ */

.field { margin-bottom: 1.25rem; }

.field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="search"],
.field textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.field textarea { font-family: var(--font-mono); font-size: 0.875rem; line-height: 1.6; }
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-row { display: flex; gap: 1.5rem; align-items: end; flex-wrap: wrap; }
.field-row .field:first-child { flex: 1 1 14rem; }

.field-checkbox { display: flex; align-items: center; gap: 0.5rem; padding-bottom: 0.625rem; }
.field-checkbox label { margin: 0; }
.field-checkbox input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }

.field-hint { font-size: 0.8125rem; color: var(--muted); margin: 0.5rem 0 0; }

.button, input[type="submit"] {
  display: inline-block;
  padding: 0.625rem 1.25rem;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: filter 0.2s ease, transform 0.15s ease;
}
.button:hover, input[type="submit"]:hover { filter: brightness(1.1); text-decoration: none; }
.button:active, input[type="submit"]:active { transform: translateY(1px); }

.button-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.button-secondary:hover { border-color: var(--accent); color: var(--accent); filter: none; }

.button-ghost {
  padding: 0.25rem 0.625rem;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.button-ghost:hover { color: #d0453b; background: rgba(208, 69, 59, 0.08); }

.button-block { display: block; width: 100%; text-align: center; }

.form-errors {
  padding: 0.875rem 1.125rem;
  margin-bottom: 1.25rem;
  border: 1px solid rgba(208, 69, 59, 0.4);
  border-left: 3px solid #d0453b;
  border-radius: var(--radius);
  font-size: 0.9375rem;
}
.form-errors ul { margin: 0; padding-left: 1.125rem; }

/* ---- Auth ----------------------------------------------------------------- */

.auth-card {
  max-width: 24rem;
  margin: 4.5rem auto;
  padding: 2rem 2rem 1.75rem;
  background: var(--frost);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 24px 48px -24px rgba(0, 0, 0, 0.25);
}

.auth-card h1 { font-size: 1.5rem; margin: 0 0 1.25rem; }
.auth-card p { font-size: 0.9375rem; color: var(--text-secondary); }

.auth-error {
  color: #d0453b;
  font-size: 0.875rem;
  margin: 0.75rem 0 0;
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin: 1.5rem 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}

.passkey-list { list-style: none; margin: 0; padding: 0; font-size: 0.875rem; }
.passkey-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.passkey-list form { margin: 0; }

/* ---- Admin ----------------------------------------------------------------- */

.admin, .admin-form-page {
  max-width: 52rem;
  margin: 0 auto;
  padding: 3rem 1.5rem 0;
}

.admin-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}
.admin-header h1 { margin: 0; font-size: 1.75rem; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.admin-table th {
  font-family: var(--font-mono);
  font-size: 0.71875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-align: left;
}
.admin-table th, .admin-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table a { color: var(--text); font-weight: 500; }
.admin-table a:hover { color: var(--accent); text-decoration: none; }

.admin-actions { display: flex; align-items: center; gap: 0.75rem; justify-content: flex-end; }
.admin-actions a { font-size: 0.8125rem; color: var(--muted); font-weight: 400; }

.status {
  font-family: var(--font-mono);
  font-size: 0.71875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
}
.status-live { color: #2f9e5f; background: rgba(47, 158, 95, 0.1); }
.status-draft { color: var(--muted); background: var(--accent-soft); }

.admin-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  font-size: 0.875rem;
}

.admin-form { max-width: 44rem; }

/* ---- Motion ----------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}
