/* Vítor Vieira */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Space+Mono:wght@400;700&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;1,9..40,400&display=swap');

:root {
  --moss: #4a7c59;
  --fern: #6a9f5b;
  --gold: #d4a843;
  --amber: #c4912a;
  --terracotta: #c67a4a;
  --clay: #a0634a;

  --bg: #f2f5f0;
  --bg-surface: #f0ebe1;
  --fg: #1d1a14;
  --fg-muted: #5c544a;
  --fg-faint: #847b6f;
  --accent: var(--moss);
  --accent-soft: color-mix(in oklch, var(--accent) 10%, var(--bg));
  --border: #ddd7cb;
  --selection: color-mix(in oklch, var(--accent) 20%, transparent);
  --code-bg: #f3efe7;

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'DM Sans', Georgia, serif;
  --font-mono: 'Space Mono', 'Courier New', monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1.05rem;
  --text-lg: 1.25rem;
  --text-xl: 1.5rem;
  --text-2xl: 1.875rem;
  --text-3xl: 2.25rem;

  --page-max: 1200px;
  --content-max: 680px;
  --sidebar-width: 260px;
  --gap: 2rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #181f18;
    --bg-surface: #212b21;
    --fg: #f4f1e8;
    --fg-muted: #c9c2b2;
    --fg-faint: #97917f;
    --accent: #8fc97a;
    --border: #2e3a2e;
    --accent-soft: color-mix(in oklch, var(--accent) 10%, var(--bg));
    --code-bg: #1e271e;
    --selection: color-mix(in oklch, var(--accent) 25%, transparent);
  }
}

/* Manual override set by the background toggle button. The [data-theme]
   attribute outranks the prefers-color-scheme query above, so the page can be
   forced dark/light even when a forced-dark extension hides the OS query. */
:root[data-theme="dark"] {
  --bg: #181f18;
  --bg-surface: #212b21;
  --fg: #f4f1e8;
  --fg-muted: #c9c2b2;
  --fg-faint: #97917f;
  --accent: #8fc97a;
  --border: #2e3a2e;
  --accent-soft: color-mix(in oklch, var(--accent) 10%, var(--bg));
  --code-bg: #1e271e;
  --selection: color-mix(in oklch, var(--accent) 25%, transparent);
}

:root[data-theme="light"] {
  --bg: #f2f5f0;
  --bg-surface: #f0ebe1;
  --fg: #1d1a14;
  --fg-muted: #5c544a;
  --fg-faint: #847b6f;
  --accent: var(--moss);
  --border: #ddd7cb;
  --accent-soft: color-mix(in oklch, var(--accent) 10%, var(--bg));
  --code-bg: #f3efe7;
  --selection: color-mix(in oklch, var(--accent) 20%, transparent);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  /* Organic background is handled by WebGL canvas */
  overflow-x: hidden;
}

/* Organic Background Canvas (rendered at reduced resolution, upscaled here).
   z-index 0 (not -1): forced-dark layers (Dark Reader, browser color
   overrides) inject opaque html+body backgrounds, and body's background
   paints over negative-z-index elements. At 0 the canvas stays above any
   body background but below the z-index:1 site wrapper. */
.organic-background {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  display: block;
}

/* Ensure content is visible over the background */
.site-wrapper {
  position: relative;
  z-index: 1;
}

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

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

.site-wrapper {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--gap);
}

/* ============================================================
   HEADER — logo/name far left, nav far right
   ============================================================ */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
}

.site-header__name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--fg);
}

.site-header__name:hover {
  text-decoration: none;
  color: var(--accent);
}

.site-nav {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}

.site-nav a {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--fg-muted);
}

.site-nav a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* ============================================================
   HOMEPAGE — everything fits in one viewport
   ============================================================ */

/* Name row: headshot + name inline */
.home-intro {
  padding: 2.5rem 0 1.5rem;
}

.home-intro__namerow {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.home-intro__headshot {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border);
  object-fit: cover;
  flex-shrink: 0;
}

.home-intro__namerow h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  line-height: 1.2;
}

.home-intro__bio {
  font-size: var(--text-lg);
  line-height: 1.55;
  color: var(--fg-muted);
  max-width: 48em;
}

.home-intro__bio p {
  margin-bottom: 0.75rem;
}

.home-intro__bio a {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* Three-column grid: Experience | Interviews | About this site */
.home-columns {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 2.5rem;
  padding: 1.75rem 0 2rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
  .home-columns {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

.home-section h2 {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 0.75rem;
}

.home-section ul {
  list-style: none;
}

.home-section li {
  padding: 0.25rem 0;
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--fg);
}

.home-section li a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--fg-faint);
  text-underline-offset: 0.15em;
}

.home-section li a:hover {
  text-decoration-color: var(--accent);
  color: var(--accent);
}

.home-about {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  line-height: 1.6;
}

.home-about a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--fg-faint);
  text-underline-offset: 0.15em;
}

.home-about a:hover {
  text-decoration-color: var(--accent);
  color: var(--accent);
}

/* Dark mode: the IR-sun background is busy, so push every bit of home-page
   text to a clear warm yellow for legibility — not just the bio, which alone
   was on --fg-muted. Applies under both the auto media query and the manual
   [data-theme="dark"] override. Hover keeps the accent. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .home-intro__bio,
  :root:not([data-theme]) .home-intro__bio a,
  :root:not([data-theme]) .home-section h2,
  :root:not([data-theme]) .home-section li,
  :root:not([data-theme]) .home-section li a,
  :root:not([data-theme]) .home-about,
  :root:not([data-theme]) .home-about a {
    color: #f6e6a4;
  }
}

:root[data-theme="dark"] .home-intro__bio,
:root[data-theme="dark"] .home-intro__bio a,
:root[data-theme="dark"] .home-section h2,
:root[data-theme="dark"] .home-section li,
:root[data-theme="dark"] .home-section li a,
:root[data-theme="dark"] .home-about,
:root[data-theme="dark"] .home-about a {
  color: #f6e6a4;
}

:root:not([data-theme]) .home-section li a:hover,
:root:not([data-theme]) .home-about a:hover,
:root[data-theme="dark"] .home-section li a:hover,
:root[data-theme="dark"] .home-about a:hover {
  color: var(--accent);
}

/* ============================================================
   FOOTER — two horizontal rows of links, subscribe on far right
   ============================================================ */
.site-footer {
  margin-top: 3rem;
  padding: 1.5rem 0 2rem;
  border-top: 1px solid var(--border);
}

.site-footer__inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
}

@media (max-width: 640px) {
  .site-footer__inner {
    flex-direction: column;
  }
}

/* Left: two horizontal rows of links */
.site-footer__links {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.site-footer__row {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}

.site-footer__row a {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--fg);
}

.site-footer__row a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* Right: subscribe */
.site-footer__subscribe {
  flex-shrink: 0;
}

.site-footer__subscribe h2 {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.site-footer__subscribe-form {
  display: flex;
  gap: 0;
}

.site-footer__subscribe-form input[type="email"] {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 999px 0 0 999px;
  background: var(--bg);
  color: var(--fg);
  outline: none;
  width: 160px;
}

.site-footer__subscribe-form input[type="email"]:focus {
  border-color: var(--accent);
}

.site-footer__subscribe-form button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 0 999px 999px 0;
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.site-footer__subscribe-form button:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

/* ============================================================
   BLOG LIST
   ============================================================ */
.blog-list-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.blog-list-header h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
}

.blog-list-header__rss {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--fg-muted);
}

.blog-tabs {
  display: flex;
  gap: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.blog-tabs a {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--fg-muted);
  padding-bottom: 0.75rem;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
}

.blog-tabs a:hover {
  color: var(--fg);
  text-decoration: none;
}

.blog-tabs a.active {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

.blog-year-group {
  margin-bottom: 2.5rem;
}

.blog-year-group__year {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--fg-muted);
  margin-bottom: 0.5rem;
}

.blog-year-group ul {
  list-style: none;
}

.blog-year-group li {
  border-bottom: 1px solid var(--border);
}

.blog-year-group li a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0;
  color: var(--fg);
  font-size: var(--text-sm);
  transition: padding-left 0.15s ease;
}

.blog-year-group li a:hover {
  color: var(--accent);
  text-decoration: none;
  padding-left: 0.2rem;
}

.blog-year-group li a time {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--fg-faint);
  flex-shrink: 0;
}

/* Genre view */
.genre-group {
  margin-bottom: 2.5rem;
}

.genre-group__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.genre-group ul {
  list-style: none;
}

.genre-group li {
  padding: 0.25rem 0;
  font-size: var(--text-sm);
}

.genre-group li a {
  color: var(--fg);
}

.genre-group li a:hover {
  color: var(--accent);
}

/* ============================================================
   SINGLE POST — content left, sticky ToC right
   ============================================================ */
.post-cover {
  width: 100%;
  border: 1px solid var(--border);
  margin-bottom: 2rem;
}

.post-layout {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  gap: calc(var(--gap) * 2);
  align-items: start;
}

@media (max-width: 860px) {
  .post-layout {
    grid-template-columns: 1fr;
  }
}

.post-header {
  margin-bottom: 2rem;
}

.post-header h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.post-meta {
  display: flex;
  gap: 1rem;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--fg-muted);
}

.post-meta a {
  color: var(--fg-muted);
}

.post-meta a:hover {
  color: var(--accent);
}

.post-body h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  margin: 2.5rem 0 0.75rem;
}

.post-body h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  margin: 2rem 0 0.5rem;
}

.post-body p {
  margin-bottom: 1.2rem;
}

.post-body ul,
.post-body ol {
  margin-bottom: 1.2rem;
  padding-left: 1.5rem;
}

.post-body li {
  margin-bottom: 0.3rem;
}

.post-body blockquote {
  border-left: 2px solid var(--accent);
  padding: 0.6rem 1.25rem;
  margin: 1.5rem 0;
  background: var(--accent-soft);
  font-style: italic;
  color: var(--fg-muted);
}

.post-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.12em 0.3em;
  border-radius: 2px;
}

.post-body pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.post-body pre code {
  background: none;
  padding: 0;
}

.post-body img {
  margin: 1.5rem 0;
  border: 1px solid var(--border);
}

.post-body a {
  text-decoration: underline;
  text-decoration-color: color-mix(in oklch, var(--accent) 40%, transparent);
  text-underline-offset: 0.15em;
}

.post-body a:hover {
  text-decoration-color: var(--accent);
}

/* ToC sidebar */
.post-toc {
  position: sticky;
  top: 2rem;
  padding: 1.25rem;
  background: var(--accent-soft);
  border: 1px solid var(--border);
}

.post-toc__title {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 0.6rem;
}

.post-toc nav ul {
  list-style: none;
}

.post-toc nav li {
  margin-bottom: 0.3rem;
}

.post-toc nav a {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  color: var(--fg-muted);
}

.post-toc nav a:hover {
  color: var(--accent);
  text-decoration: none;
}

.post-toc nav ul ul {
  padding-left: 0.75rem;
  margin-top: 0.2rem;
}

/* Series */
.post-series {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
}

.post-series__title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}

.post-series ul {
  list-style: none;
  margin-top: 0.5rem;
}

.post-series li {
  padding: 0.2rem 0;
  font-size: var(--text-sm);
}

/* ---- Utility ---- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.aside {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  background: var(--accent-soft);
  /* Subtle moss tint */
  border: 1px solid var(--border);
  border-left: 3px solid var(--terracotta);
  /* Accent color from your palette */
  font-size: var(--text-sm);
  color: var(--fg-muted);
  line-height: 1.6;
}

.aside::before {
  content: "Note: ";
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--terracotta);
}

.site-header__name img {
  height: 32px;
  width: 32px;
  border-radius: 50%;
  object-fit: cover;
}
