/* ==========================================================================
   Reset & base
   ========================================================================== */

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

:root {
  --color-bg: #ffffff;
  --color-bg-subtle: #F8FAFC;
  --color-text: #1E293B;
  --color-text-muted: #64748B;
  --color-accent: #2563EB;
  --color-accent-hover: #1D4ED8;
  --color-border: #E2E8F0;
  --color-nav: #0F172A;
  --color-code-bg: #F1F5F9;
  --color-accent-subtle: rgba(37, 99, 235, 0.3);
  --color-text-light: #B0B7BF;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --nav-height: 56px;
  --width-content: 860px;
  --width-page: 1100px;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (min-width: 1024px) {
  html { font-size: 17px; }
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

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

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

/* ==========================================================================
   Navigation — same on every page
   ========================================================================== */

.nav {
  background: var(--color-nav);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav__inner {
  max-width: var(--width-page);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav__name {
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.nav__name:hover {
  color: #fff;
}

.nav__links {
  display: flex;
  gap: 2rem;
}

.nav__links a {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s ease;
  letter-spacing: -0.01em;
}

.nav__links a:hover,
.nav__links a.active {
  color: #fff;
}

/* ==========================================================================
   Hero (home page)
   ========================================================================== */

.hero {
  background: var(--color-bg);
  text-align: center;
  color: var(--color-text);
  position: relative;
  overflow: hidden;
  padding: 1.5rem;
  min-height: calc(100vh - var(--nav-height));
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Engineering grid pattern */
.hero__pattern {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* Fine grid — positioned from title top */
.hero__pattern::before {
  content: "";
  position: absolute;
  inset: -1px;
  opacity: 0.35;
  background-image:
    linear-gradient(90deg, #CBD5E1 1px, transparent 1px),
    linear-gradient(#CBD5E1 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: var(--grid-x, 0px) var(--grid-y, 0px);
}

/* Major grid lines — 5 fine cells per block */
.hero__pattern::after {
  content: "";
  position: absolute;
  inset: -1px;
  opacity: 0.5;
  background-image:
    linear-gradient(90deg, #CBD5E1 1px, transparent 1px),
    linear-gradient(#CBD5E1 1px, transparent 1px);
  background-size: 160px 160px;
  background-position: var(--grid-x, 0px) var(--grid-y, 0px);
}

/* Dot accents — aligned with major grid */
.hero__dots {
  position: absolute;
  inset: 0;
  opacity: 0.6;
  background-image: radial-gradient(circle 2px at center, #94A3B8 0%, transparent 100%);
  background-size: 160px 160px;
  background-position: var(--grid-x, 0px) var(--grid-y, 0px);
}

/* Radial fade at edges */
.hero__fade {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 65% 55% at 50% 50%, transparent 10%, var(--color-bg) 100%);
  pointer-events: none;
}

.hero__content {
  position: relative;
  z-index: 2;
  max-width: 600px;
  margin: 0 auto;
  padding-bottom: 6rem;
  animation: fadeInUp 0.7s ease-out;
}

.hero h1 {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 0.6rem;
  line-height: 1.1;
}

.hero__bio {
  font-size: 1.05rem;
  color: var(--color-text-muted);
  font-weight: 400;
  margin-bottom: 0.3rem;
  line-height: 1.6;
}

.hero__focus {
  font-size: 0.85rem;
  color: var(--color-text-light);
  font-weight: 400;
  margin-bottom: 1.75rem;
  letter-spacing: 0.02em;
}

.hero__social {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.hero__social a {
  color: var(--color-text-light);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.hero__social a:hover {
  color: var(--color-text);
  background: var(--color-bg-subtle);
}

.hero__social svg {
  width: 18px;
  height: 18px;
}

/* ==========================================================================
   Blog listing (archive)
   ========================================================================== */

/* Shared content container */
.archive,
.post,
.page {
  width: 100%;
  max-width: var(--width-content);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  flex: 1;
}

/* Shared section header */
.archive__header,
.post__header,
.page__header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.archive__title,
.page__title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.post-list {
  list-style: none;
}

.post-list__item {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--color-border);
}

.post-list__item:first-child {
  padding-top: 0;
}

.post-list__item:last-child {
  border-bottom: none;
}

.post-list__link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.post-list__link:hover .post-list__title {
  color: var(--color-accent);
}

.post-list__title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  line-height: 1.35;
  transition: color 0.15s ease;
}

.post-list__meta {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.post-list__meta-sep {
  margin: 0 0.35rem;
}

.post-list__excerpt {
  font-size: 0.92rem;
  color: var(--color-text-muted);
  line-height: 1.6;
  margin: 0;
}

/* ==========================================================================
   Blog post — wider, comfortable reading
   ========================================================================== */

.post__title {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.post__meta {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.post__meta-sep {
  margin: 0 0.35rem;
}

/* Post content typography */
.post__content {
  font-size: 1.05rem;
  line-height: 1.8;
}

.post__content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 2.5rem 0 1rem;
  letter-spacing: -0.01em;
}

.post__content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
}

.post__content h4 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
}

.post__content p {
  margin-bottom: 1.35rem;
}

.post__content ul,
.post__content ol {
  margin-bottom: 1.35rem;
  padding-left: 1.5rem;
}

.post__content li {
  margin-bottom: 0.4rem;
}

.post__content li > ul,
.post__content li > ol {
  margin-top: 0.4rem;
  margin-bottom: 0;
}

.post__content blockquote {
  border-left: 3px solid var(--color-accent);
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--color-text-muted);
  background: var(--color-bg-subtle);
  border-radius: 0 6px 6px 0;
}

.post__content blockquote p:last-child {
  margin-bottom: 0;
}

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

.post__content pre {
  margin: 1.5rem 0;
  padding: 1.25rem 1.5rem;
  background: var(--color-code-bg);
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.55;
  font-size: 0.88rem;
  -webkit-overflow-scrolling: touch;
}

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

.post__content img {
  border-radius: 8px;
  margin: 1.5rem auto;
}

.post__content a {
  text-decoration: underline;
  text-decoration-color: var(--color-accent-subtle);
  text-underline-offset: 2px;
}

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

.post__content hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2.5rem 0;
}

.post__content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.92rem;
}

.post__content th,
.post__content td {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--color-border);
  text-align: left;
}

.post__content th {
  background: var(--color-bg-subtle);
  font-weight: 600;
}

/* Post navigation */
.post__nav {
  display: flex;
  gap: 1.5rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.post__nav-link {
  flex: 1;
  text-decoration: none;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  transition: border-color 0.15s ease;
}

.post__nav-link:hover {
  border-color: var(--color-accent);
}

.post__nav-link--next {
  text-align: right;
}

.post__nav-label {
  display: block;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

.post__nav-title {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
}

/* ==========================================================================
   Page (projects, etc.)
   ========================================================================== */

.page--wide {
  max-width: var(--width-page);
}

/* ==========================================================================
   Project cards
   ========================================================================== */

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(480px, 1fr));
  gap: 1.25rem;
}

.project-entry {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 1.5rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.project-entry:hover {
  border-color: var(--color-text-light);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

.project-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.project-title {
  text-decoration: none;
  color: var(--color-text);
}

.project-title:hover {
  color: var(--color-accent);
}

.project-title h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
}

.tech-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex-shrink: 0;
}

.tech-badge {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--color-text-muted);
  background: var(--color-bg-subtle);
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.project-tagline {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 0.35rem;
}

.project-description {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  line-height: 1.55;
  margin-bottom: 0;
}

.project-image {
  margin-top: 1rem;
  border-radius: 8px;
  overflow: hidden;
}

.project-image img {
  width: 100%;
  border-radius: 8px;
  transition: transform 0.3s ease;
}

.project-entry:hover .project-image img {
  transform: scale(1.02);
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  background: var(--color-nav);
  padding: 1.5rem 1.5rem;
  margin-top: auto;
}

/* On home page, hero fills the viewport — hide the footer */
.home .footer {
  display: none;
}

.footer__inner {
  max-width: var(--width-page);
  margin: 0 auto;
  text-align: center;
}

.footer__links {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.footer__links a {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer__links a:hover {
  color: rgba(255, 255, 255, 0.9);
}

/* ==========================================================================
   Syntax highlighting (rouge — slate theme)
   ========================================================================== */

.highlighter-rouge {
  max-width: 100%;
  overflow: hidden;
  border-radius: 8px;
  margin: 1.5rem 0;
}

.highlight pre {
  margin: 0;
  padding: 1.25rem 1.5rem;
  background: #0F172A;
  color: #E2E8F0;
  font-size: 0.85rem;
  line-height: 1.6;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

/* Comments */
.highlight .c,
.highlight .c1,
.highlight .cm,
.highlight .cs,
.highlight .cp { color: #64748B; font-style: italic; }

/* Strings */
.highlight .s,
.highlight .s1,
.highlight .s2,
.highlight .se,
.highlight .sh,
.highlight .sx,
.highlight .dl { color: #86EFAC; }

/* Keywords */
.highlight .k,
.highlight .kd,
.highlight .kn,
.highlight .kp,
.highlight .kr,
.highlight .kv,
.highlight .kt { color: #C4B5FD; }

/* Numbers */
.highlight .m,
.highlight .mi,
.highlight .mf,
.highlight .mh,
.highlight .mo,
.highlight .il { color: #FCA5A5; }

/* Names / identifiers */
.highlight .n { color: #E2E8F0; }
.highlight .na { color: #93C5FD; }
.highlight .nb { color: #67E8F9; }
.highlight .nc { color: #FDE68A; }
.highlight .nf { color: #93C5FD; }
.highlight .no { color: #FCA5A5; }
.highlight .ni { color: #E2E8F0; }
.highlight .nn { color: #E2E8F0; }
.highlight .nv { color: #E2E8F0; }

/* Operators & punctuation */
.highlight .o,
.highlight .ow { color: #94A3B8; }
.highlight .p,
.highlight .pi { color: #94A3B8; }

/* YAML / config keys */
.highlight .l { color: #86EFAC; }
.highlight .nt { color: #C4B5FD; }
.highlight .ss { color: #93C5FD; }

/* Inline code */
code.highlighter-rouge {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.15em 0.4em;
  background: var(--color-code-bg);
  border-radius: 4px;
  color: var(--color-text);
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
  html {
    font-size: 16px;
  }

  :root {
    --nav-height: 50px;
  }

  .hero h1 {
    font-size: 2.2rem;
  }

  .post__nav {
    flex-direction: column;
    gap: 1rem;
  }

  .post__nav-link--next {
    text-align: left;
  }

  .projects-grid {
    grid-template-columns: 1fr;
  }

  .project-header {
    flex-direction: column;
    gap: 0.5rem;
  }

  .archive__title,
  .page__title,
  .post__title {
    font-size: 1.4rem;
  }
}

@media (max-width: 480px) {
  .nav__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 50%;
  }

  .nav__inner {
    padding: 0 1rem;
  }

  .nav__links {
    gap: 1.25rem;
  }

  .hero__content {
    padding: 0 0.5rem;
  }

  .hero h1 {
    font-size: 1.7rem;
  }

  .post,
  .page,
  .archive {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}
