/* ═══════════════════════════════════════════════════════════
   style.css — embeddedtai.dev

   Table of contents:
     1.  Imports
     2.  Custom Properties
     3.  Reset & Base
     4.  Typography
     5.  Page Layout
     6.  Skip Link
     7.  Header
     8.  Navigation
     9.  Sections
    10.  Prose
    11.  Footer
    12.  Sidebar Layout  (blog / projects pages)
    13.  Blog Styles
    14.  Project / Carousel Styles
    15.  Utilities
    16.  Responsive — tablet  (≤900px)
    17.  Responsive — mobile  (≤480px)
    18.  Reduced Motion
   ═══════════════════════════════════════════════════════════ */


/* ── 1. Imports ────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Serif:ital,wght@0,400;0,500;1,400&family=JetBrains+Mono:ital,wght@0,400;0,500;1,400&display=swap');


/* ── 2. Custom Properties ──────────────────────────────── */
:root {
  /* — Matcha palette — */
  --c-bg:           #f0ead8;
  --c-bg-alt:       #e8e1cb;
  --c-bg-raised:    #ede6d2;
  --c-text:         #252518;
  --c-text-muted:   #6b6550;
  --c-accent:       #4a6e38;
  --c-accent-dark:  #2d4920;
  --c-accent-light: #daebc8;
  --c-border:       #c4b98e;
  --c-border-light: #ddd5b8;
  --c-mono:         #557040;
  --c-mark:         #d6eab8;
  --c-danger:       #8b3a20;   /* for error states */

  /* — Fonts — */
  --font-serif: 'IBM Plex Serif', Georgia, serif;
  --font-mono:  'JetBrains Mono', 'Courier New', Courier, monospace;

  /* — Type scale (fluid) — */
  --text-2xs:  0.7rem;
  --text-xs:   0.78rem;
  --text-sm:   0.9rem;
  --text-base: clamp(1.08rem, 1.2vw + 0.75rem, 1.2rem);
  --text-lg:   clamp(1.2rem,  2vw + 0.6rem,    1.4rem);
  --text-xl:   clamp(1.5rem,  3vw + 0.5rem,    2rem);
  --text-name: clamp(1.7rem,  4vw + 0.6rem,    2.5rem);

  --leading-tight:  1.3;
  --leading-normal: 1.75;
  --leading-prose:  1.9;

  /* — Spacing — */
  --sp-2xs: 0.25rem;
  --sp-xs:  0.5rem;
  --sp-sm:  0.875rem;
  --sp-md:  1.5rem;
  --sp-lg:  2.75rem;
  --sp-xl:  4.5rem;
  --sp-2xl: 7rem;

  /* — Layout — */
  --max-width:     680px;
  --sidebar-width: 210px;
  --page-x:        clamp(1.25rem, 6vw, 2.75rem);
  --header-top:    clamp(2rem, 5vw, 3.5rem);
  --section-gap:   clamp(2.5rem, 6vw, 4.5rem);
  --header-h:      9rem; /* approximate sticky header height — tune if off */

  /* — Transitions — */
  --t-fast: 140ms ease;
  --t-mid:  220ms ease;
}


/* ── 3. Reset & Base ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 1.5rem;
}

body {
  background-color: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-serif);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-image:
    radial-gradient(circle at 15% 85%, rgba(74,110,56,0.05) 0%, transparent 55%),
    radial-gradient(circle at 85% 15%, rgba(74,110,56,0.03) 0%, transparent 50%);
}

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

a {
  color: var(--c-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--t-fast);
}
a:hover, a:focus-visible { color: var(--c-accent-dark); }
a:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 3px;
  border-radius: 2px;
}

ul, ol { list-style: none; }


/* ── 4. Typography ─────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 500;
  line-height: var(--leading-tight);
}

.section-label {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--c-text-muted);
  margin-bottom: var(--sp-md);
  padding-left: var(--sp-sm);
  border-left: 2px solid var(--c-accent);
}

.mono, code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.875em;
  color: var(--c-mono);
}

code {
  background: var(--c-bg-alt);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

pre {
  background: var(--c-bg-alt);
  padding: var(--sp-md);
  border-radius: 4px;
  overflow-x: auto;
  font-size: var(--text-sm);
  border-left: 3px solid var(--c-border);
  line-height: 1.6;
}

pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

mark {
  background: var(--c-mark);
  color: var(--c-text);
  padding: 0.05em 0.2em;
}


/* ── 5. Page Layout ────────────────────────────────────── */
/* Single-column pages (index) */
.site-header,
main,
.site-footer {
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--page-x);
}

main { padding-bottom: var(--sp-2xl); }


/* ── 6. Skip Link ──────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--page-x);
  background: var(--c-accent);
  color: #fff;
  padding: var(--sp-xs) var(--sp-md);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  z-index: 100;
  border-radius: 0 0 4px 4px;
  text-decoration: none;
  transition: top var(--t-fast);
}
.skip-link:focus { top: 0; }


/* ── 7. Header ─────────────────────────────────────────── */
.site-header {
  padding-top: var(--header-top);
  padding-bottom: var(--sp-lg);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-md);
  border-bottom: 1px solid var(--c-border-light);
  margin-bottom: var(--section-gap);
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--c-bg);
}

/* On sidebar pages, header spans full layout width */
.site-header--wide {
  max-width: none;
  padding-inline: var(--page-x);
}

.header-identity {
  display: flex;
  align-items: baseline;
  gap: var(--sp-sm);
  flex-wrap: wrap;
}

.site-name {
  font-size: var(--text-name);
  font-weight: 500;
  line-height: 1;
  color: var(--c-text);
  text-decoration: none;
  letter-spacing: -0.01em;
  transition: color var(--t-fast);
}
.site-name:hover, .site-name:focus-visible { color: var(--c-accent); }

.site-domain {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  white-space: nowrap;
}


/* ── 8. Navigation ─────────────────────────────────────── */
.site-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.nav-link {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  color: var(--c-text-muted);
  text-decoration: none;
  transition: color var(--t-fast);
  padding-block: var(--sp-2xs);
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--c-accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--t-mid);
}

.nav-link:hover,
.nav-link:focus-visible,
.nav-link[aria-current="true"],
.nav-link.active {
  color: var(--c-accent);
}

.nav-link[aria-current="true"]::after,
.nav-link.active::after,
.nav-link:hover::after { transform: scaleX(1); }

.nav-sep {
  color: var(--c-border);
  user-select: none;
  font-size: var(--text-sm);
}


/* ── 9. Sections ───────────────────────────────────────── */
.section { margin-bottom: var(--section-gap); }


/* ── 10. Prose ─────────────────────────────────────────── */
.prose {
  line-height: var(--leading-prose);
  max-width: 62ch;
}

.prose p + p { margin-top: var(--sp-md); }

.prose h1, .prose h2, .prose h3, .prose h4 {
  margin-top: var(--sp-lg);
  margin-bottom: var(--sp-sm);
}

.prose h1 { font-size: var(--text-xl); }
.prose h2 { font-size: var(--text-lg); }
.prose h3 { font-size: var(--text-base); font-weight: 500; }

.prose ul, .prose ol {
  padding-left: var(--sp-md);
  margin-top: var(--sp-sm);
  margin-bottom: var(--sp-sm);
}

.prose ul { list-style: none; }

.prose ul > li::before {
  content: '—';
  color: var(--c-border);
  margin-right: var(--sp-xs);
  font-family: var(--font-mono);
}

.prose ol { list-style: decimal; list-style-position: outside; }
.prose li { margin-bottom: var(--sp-xs); }

.prose a {
  text-decoration-color: var(--c-border);
  transition: text-decoration-color var(--t-fast), color var(--t-fast);
}
.prose a:hover { text-decoration-color: var(--c-accent); }

.prose blockquote {
  margin-block: var(--sp-md);
  padding-left: var(--sp-md);
  border-left: 2px solid var(--c-border);
  color: var(--c-text-muted);
  font-style: italic;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--c-border-light);
  margin-block: var(--sp-lg);
}

.prose strong { font-weight: 500; }
.prose em { font-style: italic; }


/* ── 11. Footer ────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--c-border-light);
  padding-top: var(--sp-lg);
  padding-bottom: var(--sp-xl);
}

/* Wide footer for sidebar pages */
.site-footer--wide {
  max-width: none;
  padding-inline: var(--page-x);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  max-width: var(--max-width);
  margin-inline: auto;
}

.site-footer--wide .footer-inner { margin-inline: 0; }

.contact-note {
  font-size: var(--text-base);
  color: var(--c-text-muted);
  font-style: italic;
  max-width: 52ch;
  line-height: var(--leading-normal);
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-xs) var(--sp-md);
}

.contact-links a {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  text-decoration: none;
  transition: color var(--t-fast);
}
.contact-links a:hover, .contact-links a:focus-visible { color: var(--c-accent); }

.footer-copy {
  font-size: var(--text-xs);
  color: var(--c-border);
  margin-top: var(--sp-md);
}


/* ═══════════════════════════════════════════════════════════
   12. Sidebar Layout
   Sidebar is position:fixed so it never pushes main content.
   Main content stays centered exactly like index.html.
   ═══════════════════════════════════════════════════════════ */

/* page-wrap is just a centered content container — no grid */
.page-wrap {
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--page-x);
  padding-bottom: var(--sp-2xl);
}

.page-wrap > .page-main { padding-inline: 0; }

/* Sidebar floats fixed to the left of the centered content */
.site-sidebar {
  position: fixed;
  top: var(--header-h);
  /* sit just left of the centered content column */
  left: calc(50% - var(--max-width) / 2 - var(--sidebar-width) - var(--sp-lg));
  width: var(--sidebar-width);
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding-bottom: var(--sp-xl);
}

/* Sidebar */
.site-sidebar {
  padding-top: 0;
  padding-bottom: var(--sp-xl);
}

.sidebar-section { margin-bottom: var(--sp-lg); }

.sidebar-label {
  font-size: var(--text-2xs);
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-text-muted);
  margin-bottom: var(--sp-sm);
  display: block;
}

.sidebar-list { display: flex; flex-direction: column; gap: 0; }

.sidebar-link {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--c-text-muted);
  text-decoration: none;
  padding-block: 0.3rem;
  border-left: 2px solid transparent;
  padding-left: var(--sp-sm);
  line-height: 1.4;
  transition: color var(--t-fast), border-color var(--t-fast);
}

.sidebar-link:hover,
.sidebar-link:focus-visible,
.sidebar-link.active {
  color: var(--c-accent);
  border-left-color: var(--c-accent);
}

.sidebar-link-sub {
  font-size: var(--text-2xs);
  color: var(--c-border);
  display: block;
  font-style: italic;
}

/* Tag filter buttons */
.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2xs);
}

.tag-btn {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  letter-spacing: 0.05em;
  color: var(--c-text-muted);
  background: var(--c-bg-alt);
  border: 1px solid var(--c-border-light);
  border-radius: 3px;
  padding: 0.2em 0.5em;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.tag-btn:hover,
.tag-btn.active {
  background: var(--c-accent);
  color: #fff;
  border-color: var(--c-accent);
}


/* ═══════════════════════════════════════════════════════════
   13. Blog Styles
   ═══════════════════════════════════════════════════════════ */

/* Post list */
.post-list { display: flex; flex-direction: column; gap: var(--sp-xl); }

.post-card {
  border-top: 1px solid var(--c-border-light);
  padding-top: var(--sp-lg);
}

.post-card:first-child { border-top: none; padding-top: 0; }

.post-card-title {
  font-size: var(--text-lg);
  font-weight: 500;
  margin-bottom: var(--sp-xs);
}

.post-card-title a {
  color: var(--c-text);
  text-decoration: none;
  transition: color var(--t-fast);
}
.post-card-title a:hover { color: var(--c-accent); }

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-xs) var(--sp-sm);
  margin-bottom: var(--sp-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--c-text-muted);
}

.post-summary {
  color: var(--c-text-muted);
  line-height: var(--leading-normal);
  max-width: 58ch;
}

.read-more {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--c-accent);
  text-decoration: none;
  display: inline-block;
  margin-top: var(--sp-sm);
  transition: color var(--t-fast);
}
.read-more:hover { color: var(--c-accent-dark); }

/* Tags (used in meta rows) */
.tag {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  letter-spacing: 0.04em;
  color: var(--c-mono);
  background: var(--c-accent-light);
  padding: 0.15em 0.45em;
  border-radius: 2px;
  text-decoration: none;
}

/* Single post view */
.back-link {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--c-text-muted);
  text-decoration: none;
  display: inline-block;
  margin-bottom: var(--sp-lg);
  transition: color var(--t-fast);
}
.back-link:hover { color: var(--c-accent); }

.post-full-header { margin-bottom: var(--sp-lg); }

.post-full-header h1 {
  font-size: var(--text-xl);
  font-weight: 500;
  margin-bottom: var(--sp-sm);
}

/* Empty/loading states */
.state-msg {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--c-text-muted);
  padding: var(--sp-lg) 0;
}


/* ═══════════════════════════════════════════════════════════
   14. Project / Carousel Styles
   ═══════════════════════════════════════════════════════════ */

.project-list { display: flex; flex-direction: column; gap: var(--sp-xl); }

.project-card {
  border-top: 1px solid var(--c-border-light);
  padding-top: var(--sp-lg);
}

.project-card:first-child { border-top: none; padding-top: 0; }

/* Carousel container */
.carousel {
  position: relative;
  background: var(--c-bg-alt);
  border-radius: 4px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  margin-bottom: var(--sp-md);
  user-select: none;
}

.carousel-media {
  width: 100%;
  height: 100%;
}

.carousel-item {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Nav buttons */
.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(37, 37, 24, 0.55);
  color: var(--c-bg);
  border: none;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background var(--t-fast);
}
.carousel-btn:hover { background: rgba(37, 37, 24, 0.8); }
.carousel-btn--prev { left: var(--sp-xs); }
.carousel-btn--next { right: var(--sp-xs); }

/* Dots */
.carousel-dots {
  position: absolute;
  bottom: var(--sp-xs);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  z-index: 2;
}

.carousel-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(240, 234, 216, 0.5);
  transition: background var(--t-fast), transform var(--t-fast);
}
.carousel-dot.active {
  background: var(--c-bg);
  transform: scale(1.3);
}

/* Counter */
.carousel-counter {
  position: absolute;
  top: var(--sp-xs);
  right: var(--sp-sm);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  color: var(--c-bg);
  background: rgba(37, 37, 24, 0.45);
  padding: 0.15em 0.5em;
  border-radius: 2px;
  z-index: 2;
}

/* Project info below carousel */
.project-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-md);
  flex-wrap: wrap;
  margin-bottom: var(--sp-xs);
}

.project-title {
  font-size: var(--text-lg);
  font-weight: 500;
}

.github-link {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--c-text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--t-fast);
}
.github-link:hover { color: var(--c-accent); }

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2xs);
  margin-bottom: var(--sp-sm);
}

.project-description {
  color: var(--c-text-muted);
  font-size: var(--text-base);
}

.project-description p:first-child { margin-top: 0; }


/* ── 15. Utilities ─────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.muted { color: var(--c-text-muted); }

[hidden] { display: none !important; }


/* ── 16. Responsive — tablet ───────────────────────────── */
@media (max-width: 900px) {
  /* Collapse sidebar above content */
  .page-wrap {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "sidebar"
      "main"
      "footer";
    column-gap: 0;
  }

  .site-sidebar {
    border-bottom: 1px solid var(--c-border-light);
    padding-bottom: var(--sp-md);
    margin-bottom: var(--sp-lg);
  }

  /* Horizontal scroll for sidebar links on tablet */
  .sidebar-list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--sp-2xs) var(--sp-sm);
  }

  .sidebar-link {
    border-left: none;
    border-bottom: 1px solid transparent;
    padding-left: 0;
    padding-bottom: 2px;
  }

  .sidebar-link:hover,
  .sidebar-link.active {
    border-left-color: transparent;
    border-bottom-color: var(--c-accent);
  }
}

@media (max-width: 768px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-sm);
  }
}


/* ── 17. Responsive — mobile ───────────────────────────── */
@media (max-width: 480px) {
  :root {
    --header-top:  1.5rem;
    --section-gap: 2rem;
    --sp-lg:       2rem;
  }

  .header-identity { flex-direction: column; gap: var(--sp-2xs); }
  .site-name { font-size: clamp(1.4rem, 8vw, 1.7rem); }
  .contact-links { flex-direction: column; }
  .post-card-title { font-size: var(--text-base); }
}


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