/* ==========================================================================
   Variables — the entire palette and scale live here. Change values in
   :root to re-theme the whole site; nothing below this block should
   hard-code a color, spacing, or font value.
   ========================================================================== */
:root {
  color-scheme: dark;

  /* Color palette — indigo backgrounds (--color-bg family) paired with
     a periwinkle-blue text/accent family (built around --color-text,
     c0caf5) for a cohesive dark blue-violet theme. */
  --color-bg: #191726;
  --color-bg-elevated: #211e33;
  --color-border: #322e4a;
  --color-text: #c0caf5;
  --color-text-secondary: #a9b1d6;
  --color-text-muted: #7982b0;
  --color-accent: #7aa2f7;
  --color-accent-hover: #9dbdff;

  /* Syntax highlighting — code-block token colors, kept in the same
     blue-violet family as the rest of the palette. */
  --syntax-keyword: #bb9af7;
  --syntax-type: #7aa2f7;
  --syntax-string: #9ece6a;
  --syntax-number: #ff9e64;
  --syntax-comment: #7982b0;
  --syntax-function: #7dcfff;
  --syntax-operator: #a9b1d6;

  /* Transitions applied when the theme toggle flips data-theme */
  --theme-transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;

  /* Typography */
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-size-base: 17px;
  --font-size-sm: 0.875rem;
  --font-size-lg: 1.25rem;
  --line-height-base: 1.65;

  /* Spacing scale */
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  --space-5: 4rem;

  /* Layout */
  --content-width: 800px;
  --hero-media-width: 140px;
  --radius: 4px;

  /* Rail — the connective dot/line motif shared by the entry-list timeline
     and the navbar's underline indicator. */
  --rail-gutter: 1.5rem;
  --rail-line-x: 0.3125rem;
  --rail-dot-size: 0.625rem;
}

/* Light theme — same periwinkle/indigo hue family as the dark palette,
   just inverted in lightness. Backgrounds stay lavender-gray rather than
   pure white so the page keeps the same "tinted" feel as the dark mode. */
:root[data-theme="light"] {
  color-scheme: light;

  --color-bg: #dcdfec;
  --color-bg-elevated: #eef0f8;
  --color-border: #c7cbe0;
  --color-text: #2b2f4c;
  --color-text-secondary: #454a72;
  --color-text-muted: #6b7099;
  --color-accent: #3d5ccc;
  --color-accent-hover: #2c46a8;

  --syntax-keyword: #5a4a78;
  --syntax-type: #34548a;
  --syntax-string: #485e30;
  --syntax-number: #965027;
  --syntax-comment: #6b7099;
  --syntax-function: #33635c;
  --syntax-operator: #454a72;
}

/* ==========================================================================
   Reset
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

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

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

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ==========================================================================
   Base
   ========================================================================== */
body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  -webkit-font-smoothing: antialiased;
  transition: var(--theme-transition);
}

h1,
h2,
h3 {
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 var(--space-2);
}

h1 {
  font-size: 1.75rem;
}

h2 {
  font-size: 1.25rem;
}

h3 {
  font-size: 1.05rem;
}

p {
  margin: 0 0 var(--space-2);
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover,
a:focus-visible {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

a[href=""],
a[href=""]:hover,
a[href=""]:focus-visible {
  text-decoration: none;
  cursor: default;
  pointer-events: none;
}

/* ==========================================================================
   Layout
   ========================================================================== */
.page {
  max-width: var(--content-width);
  margin: var(--space-4) auto;
  padding: var(--space-2) var(--space-3) var(--space-1);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: var(--theme-transition);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.site-title {
  color: var(--color-text);
  font-weight: 600;
  font-size: var(--font-size-lg);
}

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

/* ==========================================================================
   Navbar — one thin horizontal row. Each link carries a rail dot (the same
   motif as the entry-list timeline) that fills in solid for the active page.
   ========================================================================== */
.navbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

.nav-link:hover,
.nav-link:focus-visible {
  color: var(--color-text);
  text-decoration: none;
}

.nav-dot {
  width: var(--rail-dot-size);
  height: var(--rail-dot-size);
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--color-border);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.nav-link:hover .nav-dot,
.nav-link:focus-visible .nav-dot {
  border-color: var(--color-accent-hover);
}

.nav-link.is-active {
  color: var(--color-text);
}

.nav-link.is-active .nav-dot {
  border-color: var(--color-accent);
  background: var(--color-accent);
  transform: scale(1.1);
}

/* ==========================================================================
   Theme toggle
   ========================================================================== */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  transition: var(--theme-transition), transform 0.15s ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  color: var(--color-text);
  border-color: var(--color-accent-hover);
}

.theme-toggle:active {
  transform: scale(0.9);
}

.theme-toggle-icon::before {
  content: "\263E"; /* ☾ crescent moon — shown in dark mode */
}

[data-theme="light"] .theme-toggle-icon::before {
  content: "\2600"; /* ☀ sun — shown in light mode */
}

.site-main > .section,
.site-main > .hero {
  margin-bottom: var(--space-2);
}

.site-footer {
  margin-top: var(--space-5);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

/* ==========================================================================
   Hero
   ========================================================================== */
.hero-content {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
}

.hero-media {
  flex: 0 0 var(--hero-media-width);
  width: var(--hero-media-width);
}

.hero .avatar {
  width: 100%;
  height: var(--hero-media-width);
  border-radius: var(--radius);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-2);
}

.hero .location {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-2);
}

.hero .social-links {
  margin: 0;
  font-size: var(--font-size-sm);
}

.hero .social-links a:not(:last-child)::after {
  content: " · ";
  color: var(--color-text-muted);
}

.hero .bio {
  flex: 1;
  min-width: 0;
  color: var(--color-text-secondary);
  margin: 0;
}

@media (max-width: 480px) {
  .hero-content {
    flex-direction: column;
  }

  .hero-media {
    width: var(--hero-media-width);
  }
}

/* ==========================================================================
   Sections
   ========================================================================== */
.section-title {
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-3);
}

.entry-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  position: relative;
  padding-left: var(--rail-gutter);
}

.entry-list::before {
  content: "";
  position: absolute;
  top: 0.6em;
  bottom: 0.6em;
  left: var(--rail-line-x);
  width: 1px;
  background: linear-gradient(
    to bottom,
    transparent,
    var(--color-border) 4%,
    var(--color-border) 96%,
    transparent
  );
}

/* ==========================================================================
   Entries — shared by experience, project, and blog list items so the
   whole site reads as one consistent system. Resume style: exactly three
   rows (title + date, description, stack) with small margins between them.
   Each entry gets a rail dot, connected by the line on .entry-list::before.
   ========================================================================== */
.entry {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.entry-title {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-1) var(--space-2);
  margin-bottom: 0;
}

.entry-title::before {
  content: "";
  position: absolute;
  top: 0.5em;
  left: calc(var(--rail-line-x) - var(--rail-gutter) - (var(--rail-dot-size) / 2));
  width: var(--rail-dot-size);
  height: var(--rail-dot-size);
  border-radius: 50%;
  background: var(--color-bg-elevated);
  border: 2px solid var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-bg-elevated);
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.entry:hover .entry-title::before {
  border-color: var(--color-accent-hover);
  background: var(--color-accent);
  transform: scale(1.2);
}

.entry-company {
  color: var(--color-accent);
}

.entry-date {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-weight: 400;
  white-space: nowrap;
}

.entry-title-main {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--space-2);
  min-width: 0;
}

.entry-title-tags {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-weight: 400;
}

.entry-description {
  color: var(--color-text-secondary);
  margin-bottom: 0;
}

.entry-tags {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  margin-bottom: 0;
}

.entry-links {
  display: flex;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
}

/* ==========================================================================
   Entry toggle — a collapsible group below the main .entry-list, e.g.
   "Tutoring" under Experience. The rail stops at the last entry above it;
   the toggle heading carries an arrow where a rail dot would sit, and its
   nested list reuses .entry-list unchanged so a fresh rail starts there.
   ========================================================================== */
.entry-toggle-summary {
  position: relative;
  display: block;
  width: fit-content;
  padding-left: var(--rail-gutter);
  color: var(--color-text);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.entry-toggle-summary::marker,
.entry-toggle-summary::-webkit-details-marker {
  content: "";
  display: none;
}

.entry-toggle-summary:hover,
.entry-toggle-summary:focus-visible {
  color: var(--color-accent);
}

.entry-toggle-caret {
  position: absolute;
  top: 0.35em;
  left: calc(var(--rail-line-x) - 0.4375rem);
  width: 0.875rem;
  height: 0.875rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
  font-size: 0.85rem;
  line-height: 1;
}

.entry-toggle-summary:hover .entry-toggle-caret,
.entry-toggle-summary:focus-visible .entry-toggle-caret {
  color: var(--color-accent-hover);
}

.entry-toggle-caret::before {
  content: "\203A"; /* › */
}

.entry-toggle[open] > .entry-toggle-summary .entry-toggle-caret {
  transform: rotate(90deg);
}

/* ==========================================================================
   Blog post
   ========================================================================== */
.blog-post-header {
  margin-bottom: var(--space-3);
}

.blog-post-content h1,
.blog-post-content h2,
.blog-post-content h3 {
  margin-top: var(--space-4);
}

.blog-post-content figure {
  margin: 0 0 var(--space-2);
  text-align: center;
}

.blog-post-content figure img {
  max-height: 70vh;
  width: auto;
  max-width: 100%;
  margin: 0 auto;
}

.blog-post-content figcaption {
  margin-top: var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  text-align: center;
}

.blog-post-content pre {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-2);
  overflow-x: auto;
  margin: 0 0 var(--space-2);
}

.blog-post-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.blog-post-content pre code {
  background: none;
  border: none;
  padding: 0;
}

.blog-post-content :not(pre) > code {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  padding: 0.1em 0.35em;
}

/* Syntax highlighting — token classes emitted by Chroma (see cmd/genblog),
   prefixed with chroma- to avoid colliding with other class names. */
.chroma-k,
.chroma-kc,
.chroma-kd,
.chroma-kn,
.chroma-kp,
.chroma-kr,
.chroma-ow {
  color: var(--syntax-keyword);
}

.chroma-kt,
.chroma-nc,
.chroma-nn {
  color: var(--syntax-type);
}

.chroma-s,
.chroma-s1,
.chroma-s2,
.chroma-sa,
.chroma-sb,
.chroma-sc,
.chroma-dl,
.chroma-sd,
.chroma-se,
.chroma-sh,
.chroma-si,
.chroma-sx,
.chroma-sr,
.chroma-ss {
  color: var(--syntax-string);
}

.chroma-m,
.chroma-mb,
.chroma-mf,
.chroma-mh,
.chroma-mi,
.chroma-mo {
  color: var(--syntax-number);
}

.chroma-c,
.chroma-c1,
.chroma-ch,
.chroma-cm,
.chroma-cp,
.chroma-cpf,
.chroma-cs {
  color: var(--syntax-comment);
  font-style: italic;
}

.chroma-nf,
.chroma-nb,
.chroma-fm {
  color: var(--syntax-function);
}

.chroma-o,
.chroma-p {
  color: var(--syntax-operator);
}

.chroma-gp {
  color: var(--syntax-comment);
}

.chroma-err {
  color: var(--syntax-string);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 480px) {
  :root {
    --font-size-base: 16px;
  }

  .page {
    padding: var(--space-3) var(--space-2) var(--space-4);
  }
}
