/* === Custom Properties === */
:root {
  --color-bg: #ffffff;
  --color-surface: #f8f9fb;
  --color-border: #e2e5ea;
  --color-border-light: #eef0f3;
  --color-text: #1a1d23;
  --color-text-secondary: #5a6170;
  --color-text-muted: #6b7280;
  --color-accent: #0e7490;
  --color-accent-hover: #155e75;
  --color-accent-subtle: #ecfeff;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --content-width: 740px;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
  --transition: 150ms ease;
}

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* === Typography === */
h1, h2, h3, h4 {
  line-height: 1.25;
  margin-top: 1.75em;
  margin-bottom: 0.5em;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

h1 { font-size: 2em; }
h2 { font-size: 1.45em; }
h3 { font-size: 1.15em; }

p {
  margin: 0 0 1.1em;
}

a {
  color: var(--color-accent);
  font-weight: 500;
  text-decoration: none;
  transition: color var(--transition);
}

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

ul, ol {
  margin: 0 0 1.1em;
  padding-left: 1.5em;
}

li {
  margin-bottom: 0.3em;
}

blockquote {
  margin: 1.25em 0;
  padding: 0.75em 1.25em;
  border-left: 3px solid var(--color-accent);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

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

/* === Code === */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--color-surface);
  padding: 0.15em 0.45em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-light);
}

pre {
  background: var(--color-surface);
  padding: 1.25em 1.5em;
  overflow-x: auto;
  border-radius: var(--radius);
  margin: 0 0 1.5em;
  border: 1px solid var(--color-border-light);
}

pre code {
  background: none;
  padding: 0;
  border: none;
  font-size: 0.85em;
}

/* === Layout === */
.main {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 2.5em 1.5rem 4em;
}

/* === Site Header === */
.site-header {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.92);
}

.site-header-inner {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05em;
  color: var(--color-text);
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.01em;
}

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

.site-logo img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.site-nav a {
  padding: 0.35em 0.75em;
  color: var(--color-text-secondary);
  font-weight: 500;
  font-size: 0.9em;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  margin-left: 0;
}

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

.site-nav a.active {
  color: var(--color-accent);
  background: var(--color-accent-subtle);
}

/* === Site Footer === */
.site-footer {
  border-top: 1px solid var(--color-border);
  margin-top: 2em;
}

.site-footer-inner {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82em;
  color: var(--color-text-muted);
}

.footer-links {
  display: flex;
  gap: 0.5em;
}

.footer-links a {
  color: var(--color-text-muted);
  font-weight: 500;
  padding: 0.25em 0.5em;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}

.footer-links a:hover {
  color: var(--color-accent);
  background: var(--color-accent-subtle);
  text-decoration: none;
}

/* === Home Page === */
.home-intro {
  margin-bottom: 3em;
}

.home-intro p {
  font-size: 1.15em;
  color: var(--color-text-secondary);
  line-height: 1.75;
}

.featured-projects {
  margin-bottom: 3.5em;
}

.featured-projects h2 {
  font-size: 0.8em;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  margin-top: 0;
  margin-bottom: 1.75em;
  font-weight: 600;
}

.project-item {
  margin-bottom: 2.5em;
  padding-bottom: 2.5em;
  border-bottom: 1px solid var(--color-border-light);
}

.project-item:last-child {
  border-bottom: none;
}

.project-item h3 {
  margin-top: 0.85em;
  margin-bottom: 0.3em;
}

.project-item p {
  color: var(--color-text-secondary);
}

.project-item img {
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.project-item a:hover img {
  box-shadow: var(--shadow-md);
}

.project-links {
  margin-top: 0.6em;
  font-size: 0.9em;
}

.project-links a {
  margin-right: 1em;
}

.recent-articles h2 {
  font-size: 0.8em;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  margin-top: 0;
  margin-bottom: 1.5em;
  font-weight: 600;
}

/* === Post List (home + articles page) === */
.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-item {
  margin-bottom: 1.5em;
  padding: 1.25em 1.5em;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius);
  background: var(--color-bg);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.post-item:hover {
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}

.post-item:last-child {
  margin-bottom: 0;
}

.post-item-title {
  font-size: 1.1em;
  font-weight: 600;
  display: block;
  margin-bottom: 0.25em;
}

.post-item-meta {
  display: flex;
  align-items: center;
  gap: 0.75em;
  margin-bottom: 0.4em;
}

.post-item-date {
  font-size: 0.82em;
  color: var(--color-text-muted);
  font-weight: 400;
}

.post-item-series {
  font-size: 0.75em;
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  padding: 2px 10px;
  border-radius: 12px;
  font-weight: 600;
}

.post-item-desc {
  font-size: 0.9em;
  color: var(--color-text-secondary);
  margin: 0;
  line-height: 1.6;
}

/* === Post Layout === */
.post-header {
  margin-bottom: 2.25em;
  padding-bottom: 1.25em;
  border-bottom: 1px solid var(--color-border-light);
}

.post-title {
  margin-top: 0;
  margin-bottom: 0.4em;
  font-size: 2em;
}

.post-date {
  font-size: 0.85em;
  color: var(--color-text-muted);
  font-weight: 400;
}

.post-series {
  display: inline-block;
  margin-left: 0.75em;
  font-size: 0.78em;
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  padding: 3px 12px;
  border-radius: 12px;
  font-weight: 600;
}

.post-demo-link {
  display: inline-block;
  margin-top: 0.85em;
  font-size: 0.9em;
  padding: 0.4em 1em;
  background: var(--color-accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: background var(--transition);
}

.post-demo-link:hover {
  background: var(--color-accent-hover);
  color: #fff;
  text-decoration: none;
}

.post-content {
  margin-bottom: 2.5em;
}

.post-content img {
  margin: 1.75em auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.post-footer {
  padding-top: 1.5em;
  border-top: 1px solid var(--color-border-light);
  font-size: 0.9em;
}

.post-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 0.75em;
  font-size: 0.9em;
}

/* === Page Layout === */
.page-title {
  margin-top: 0;
  margin-bottom: 1.25em;
  padding-bottom: 0.6em;
  border-bottom: 1px solid var(--color-border-light);
}

/* === Projects Page === */
.projects-list .project-item h2 {
  margin-top: 0;
}

/* === 404 === */
.not-found {
  text-align: center;
  padding: 5em 0;
}

.not-found h1 {
  font-size: 5em;
  margin-bottom: 0.2em;
  color: var(--color-border);
  font-weight: 700;
}

.not-found p {
  color: var(--color-text-secondary);
}

/* === Mobile (phones) === */
@media (max-width: 640px) {
  .site-header-inner {
    height: auto;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .site-nav {
    flex-wrap: wrap;
    gap: 0.125rem;
  }

  .site-nav a {
    padding: 0.3em 0.6em;
  }

  .site-footer-inner {
    flex-direction: column;
    gap: 0.5em;
    text-align: center;
  }

  .footer-links {
    justify-content: center;
  }

  .main {
    padding: 1.75em 1.25rem 3em;
  }

  .home-intro p {
    font-size: 1.05em;
  }

  .post-item {
    padding: 1em 1.15em;
  }

  .post-title {
    font-size: 1.6em;
  }
}

/* === Tablet === */
@media (min-width: 641px) and (max-width: 1024px) {
  .main {
    padding: 2.25em 2rem 3.5em;
  }
}

/* === Large desktops (27"+ 4K/5K) === */
@media (min-width: 1800px) {
  :root {
    --content-width: 800px;
  }

  body {
    font-size: 17px;
  }
}

@media (min-width: 2400px) {
  :root {
    --content-width: 860px;
  }

  body {
    font-size: 18px;
  }
}
