/* brendanaw.com. Single shared stylesheet. Minimal, text-first, levelsio-inspired. */

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

:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --faint: #999999;
  --rule: #eaeaea;
  --link: #1a1a1a;
  --accent: #1a56db;
  --surface: #fafafa;
  --code-bg: #f5f5f5;
  --logo-invert: 0;
  /* Hero pixel-scene palette: fixed monochrome photo effect, same in light/dark.
     Mirrored in assets/pixel-scene.js (canvas needs raw RGB). */
  --pixel-1: #e7e9ee;
  --pixel-2: #c9ccd3;
  --pixel-3: #abaeb6;
  --pixel-4: #8d9099;
  --pixel-5: #6f727b;
  --pixel-6: #52555e;
  --pixel-7: #363942;
  --pixel-8: #1b1e26;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --col: 680px;
  --icon-moon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 3a9 9 0 1 0 9 9 7 7 0 0 1-9-9z' fill='%23000'/%3E%3C/svg%3E");
  --icon-sun: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='4' fill='%23000' stroke='none'/%3E%3Cline x1='12' y1='1.5' x2='12' y2='4'/%3E%3Cline x1='12' y1='20' x2='12' y2='22.5'/%3E%3Cline x1='1.5' y1='12' x2='4' y2='12'/%3E%3Cline x1='20' y1='12' x2='22.5' y2='12'/%3E%3Cline x1='4.2' y1='4.2' x2='6' y2='6'/%3E%3Cline x1='18' y1='18' x2='19.8' y2='19.8'/%3E%3Cline x1='19.8' y1='4.2' x2='18' y2='6'/%3E%3Cline x1='6' y1='18' x2='4.2' y2='19.8'/%3E%3C/svg%3E");
}

/* Dark theme: system preference by default, unless the user forced light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --text: #e7e8ea;
    --muted: #a2a6ac;
    --faint: #71767e;
    --rule: #2a2e35;
    --link: #e7e8ea;
    --accent: #6ea8ff;
    --surface: #1b1e24;
    --code-bg: #1e222a;
    --logo-invert: 1;
  }
}
/* Manual override wins in both directions */
:root[data-theme="dark"] {
  --bg: #14161a;
  --text: #e7e8ea;
  --muted: #a2a6ac;
  --faint: #71767e;
  --rule: #2a2e35;
  --link: #e7e8ea;
  --accent: #6ea8ff;
  --surface: #1b1e24;
  --code-bg: #1e222a;
  --logo-invert: 1;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap {
  max-width: var(--col);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---- Header ---- */
header {
  padding: 32px 0 28px;
}
header .wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: nowrap;
}
.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  margin-right: auto;
}
.brand img {
  display: block;
  height: 22px;
  width: auto;
  filter: invert(var(--logo-invert));
}
nav.site {
  display: flex;
  gap: 20px;
}
nav.site a {
  font-size: 15px;
  color: var(--muted);
  text-decoration: none;
  transition: color .15s;
}
nav.site a:hover, nav.site a[aria-current] { color: var(--text); }

/* Header tools: theme toggle + hamburger */
.nav-tools { display: flex; align-items: center; gap: 8px; }
.theme-toggle {
  width: 34px; height: 34px;
  display: inline-grid; place-items: center;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--faint); }
.theme-toggle::before {
  content: "";
  width: 16px; height: 16px;
  background: currentColor;
  -webkit-mask: var(--icon-moon) center / contain no-repeat;
  mask: var(--icon-moon) center / contain no-repeat;
}
:root[data-theme="dark"] .theme-toggle::before { -webkit-mask-image: var(--icon-sun); mask-image: var(--icon-sun); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle::before { -webkit-mask-image: var(--icon-sun); mask-image: var(--icon-sun); }
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 34px; height: 34px;
  padding: 0 7px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text);
  border-radius: 2px;
  transition: transform .2s ease, opacity .2s ease;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ---- Links ---- */
a { color: var(--link); }
/* Inline links: link color == text color, so the underline is the only signal.
   Keep it full-contrast (currentColor) and thick enough to read, not a faint hairline. */
main a {
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2px;
}
main a:hover { text-decoration-thickness: 3px; }
/* Visible keyboard-focus ring for accessibility (was relying on browser default). */
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---- Home intro ---- */
/* ---- Hero pixel scene ---- */
.pixel-scene-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  overflow: hidden;
  margin: 0 0 32px;
  background: var(--surface);
}
#pixel-scene {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.intro {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin: 12px 0 40px;
}
.avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--rule);
}
.intro h1 { font-size: 22px; font-weight: 600; margin-bottom: 6px; letter-spacing: -0.01em; }
.intro p { color: var(--muted); font-size: 16px; margin: 0; }

/* ---- Sections + post lists ---- */
section { margin: 40px 0; }
.section-title {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 14px;
}

.post-list { list-style: none; }
.post-list li {
  display: flex;
  gap: 16px;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid var(--rule);
}
.post-list li:last-child { border-bottom: none; }
.post-list time {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--faint);
  flex-shrink: 0;
  white-space: nowrap;
}
.post-list a {
  color: var(--text);
  text-decoration: none;
}
.post-list a:hover { text-decoration: underline; text-underline-offset: 2px; }

.more { display: inline-block; margin-top: 14px; font-size: 15px; color: var(--muted); }

/* ---- Newsletter signup (Kit embed lives inside) ---- */
.signup {
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 20px 22px;
  margin: 32px 0;
  background: var(--surface);
}
.signup h2 { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.signup p { font-size: 14px; color: var(--muted); margin-bottom: 14px; }
/* Kit form gets dropped in .signup-form; these style a plain fallback form */
.signup-form { display: flex; gap: 8px; flex-wrap: wrap; }
.signup-form input[type="email"] {
  flex: 1;
  min-width: 200px;
  font: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
.signup-form button {
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  padding: 10px 18px;
  border: none;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  cursor: pointer;
}
.signup-form button:hover { opacity: .88; }

/* Kit inline embed (ck.js enhances). The .signup-form input[type=email] + button
   rules above already style the field/button; these handle Kit's wrapper structure
   and the AJAX alert. All colors are tokens, so it inherits light/dark. */
.signup-form.formkit-form { display: block; }
/* Force email + button onto one line. ck.js injects Kit's responsive rule
   (.formkit-field/.formkit-submit { flex: 1 0 100% }) which stacks them unless the
   container is >=700px; our .signup box is ~636px, so override with !important. */
.signup-form .formkit-fields { display: flex !important; gap: 8px; flex-wrap: wrap; margin: 0 !important; }
.signup-form .formkit-field { flex: 1 1 auto !important; min-width: 200px; margin: 0 !important; }
.signup-form .formkit-submit { flex: 0 0 auto !important; margin: 0 !important; }
/* !important: ck.js injects Kit's own stylesheet at runtime (higher specificity),
   so these are needed to keep the field on the site's tokens in light AND dark. */
.signup-form .formkit-input {
  width: 100% !important;
  background: var(--bg) !important;
  color: var(--text) !important;
  border: 1px solid var(--rule) !important;
  border-radius: 6px !important;
}
.signup-form .formkit-input:focus { border-color: var(--faint) !important; outline: none !important; }
.signup-form .formkit-input::placeholder { color: var(--faint) !important; opacity: 1 !important; }
.signup-form .formkit-submit { white-space: nowrap; }
.signup-form .formkit-spinner { display: none; }
.signup-form .formkit-alert {
  list-style: none;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 6px;
  margin: 0 0 10px;
  border: 1px solid var(--rule);
  background: var(--bg);
  color: var(--text);
}
.signup-form .formkit-alert:empty { display: none; }

/* ---- Video grid ---- */
.video-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.video-card { text-decoration: none; color: inherit; display: block; }
.video-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  overflow: hidden;
  background: var(--rule);
  margin-bottom: 8px;
}
.video-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-title {
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.video-loading { font-family: var(--mono); font-size: 12px; color: var(--faint); }

/* status dot for projects */
.project h3::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--faint);
  display: inline-block;
  flex: 0 0 auto;
  align-self: center;   /* center the dot with the title, not its baseline */
  margin-right: 2px;
}
.project.active h3::before {
  background: #22a06b;
  animation: status-pulse 2.2s ease-out infinite;
}
/* Active = a soft steady green glow + a gentle outward pulse ring. */
@keyframes status-pulse {
  0%   { box-shadow: 0 0 4px 0 rgba(34, 160, 107, 0.7), 0 0 0 0 rgba(34, 160, 107, 0.5); }
  70%  { box-shadow: 0 0 4px 0 rgba(34, 160, 107, 0.7), 0 0 0 5px rgba(34, 160, 107, 0); }
  100% { box-shadow: 0 0 4px 0 rgba(34, 160, 107, 0.7), 0 0 0 0 rgba(34, 160, 107, 0); }
}

/* ---- Article (blog/newsletter post) ---- */
article header { padding: 0; margin-bottom: 28px; }
article h1 { font-size: 30px; font-weight: 700; line-height: 1.25; letter-spacing: -0.02em; margin-bottom: 10px; }
.post-meta { font-family: var(--mono); font-size: 13px; color: var(--faint); }

.prose > * + * { margin-top: 20px; }
.prose h2 { font-size: 22px; font-weight: 600; margin-top: 40px; letter-spacing: -0.01em; }
.prose h3 { font-size: 18px; font-weight: 600; margin-top: 32px; }
.prose ul, .prose ol { padding-left: 24px; }
.prose li + li { margin-top: 6px; }
.prose img { max-width: 100%; height: auto; border-radius: 6px; display: block; margin: 28px auto; }
.prose blockquote {
  border-left: 3px solid var(--rule);
  padding-left: 18px;
  color: var(--muted);
  font-style: italic;
}
.prose code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 2px 5px;
  border-radius: 4px;
}
.prose pre {
  background: var(--code-bg);
  padding: 16px;
  border-radius: 6px;
  overflow-x: auto;
}
.prose pre code { background: none; padding: 0; }
.prose hr { border: none; border-top: 1px solid var(--rule); margin: 40px 0; }

/* Era note for old SEO-era posts */
.era-note {
  font-size: 14px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 28px;
}

/* ---- Projects ---- */
.project { padding: 16px 0; border-bottom: 1px solid var(--rule); }
.project:last-child { border-bottom: none; }
.project h3 { font-size: 17px; font-weight: 600; display: flex; align-items: baseline; gap: 10px; }
.project .status { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); }
.project p { color: var(--muted); font-size: 15px; margin-top: 4px; }

/* ---- Footer ---- */
footer {
  border-top: 1px solid var(--rule);
  margin-top: 64px;
  padding: 28px 0 48px;
}
footer .wrap { display: flex; flex-direction: column; gap: 12px; }
footer, footer a { font-size: 14px; color: var(--muted); }
footer a { text-decoration: none; }
footer a:hover { color: var(--text); }
.social, .legal { display: flex; gap: 16px; flex-wrap: wrap; }
.legal { gap: 14px; }
footer .copyright { color: var(--faint); }

/* ---- Responsive ---- */
@media (max-width: 640px) {
  body { font-size: 16px; }
  header { padding: 22px 0 18px; }
  .nav-toggle { display: flex; }
  nav.site {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--bg);
    border: 1px solid var(--rule);
    border-radius: 10px;
    padding: 6px 4px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.12);
    display: none;
    z-index: 40;
  }
  nav.site.open { display: flex; }
  nav.site a { padding: 10px 12px; font-size: 16px; border-radius: 6px; }
  article h1 { font-size: 26px; }
  .post-list li { flex-direction: column; gap: 2px; }
  .video-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .nav-toggle span, .theme-toggle, nav.site a { transition: none; }
  .project.active h3::before { animation: none; box-shadow: 0 0 4px 0 rgba(34, 160, 107, 0.7); }
  /* Hero pixel-scene steam loop is a JS setInterval, halted via matchMedia in pixel-scene.js. */
}
