/* =============================================================================
   main.css — Portell Blog Stylesheet
   =============================================================================
   Single stylesheet for the entire blog. No CSS framework is used.
   All design decisions are encoded as CSS custom properties (tokens) at the top.

   AI INSTRUCTIONS:
   - Change brand colors ONLY in the :root block below, not scattered in rules.
   - Do not add external @import rules — keep the stylesheet self-contained.
   - Do not use !important — it indicates a specificity problem that should be
     fixed at the source.
   - Section order: Tokens → Reset → Base → Layout → Components → Pages → Utility

   FONT STACK:
   Uses the system font stack — no external font requests, zero latency.
   If a custom font is added later, add it in the Typography section only.
   ============================================================================= */


/* =============================================================================
   1. DESIGN TOKENS (CSS Custom Properties)
   AI: This is the ONLY place to change colors, spacing, or type scales.
   Changing values here cascades correctly across the entire stylesheet.
   ============================================================================= */
:root {
  /* Brand */
  --color-brand:        #5C40F5;   /* Primary violet — keep in sync with site.js themeColor */
  --color-brand-hover:  #4A32D4;
  --color-brand-light:  #EEF0FF;   /* Background tint for CTA block */

  /* Neutral palette */
  --color-bg:           #FFFFFF;
  --color-bg-subtle:    #F8F8FB;   /* Alternate section backgrounds */
  --color-border:       #E8E8F0;
  --color-text:         #0F0F13;   /* Near-black body text */
  --color-text-muted:   #6B6B80;   /* Dates, meta, captions */
  --color-text-faint:   #A0A0B0;   /* Placeholder, dividers */

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               Helvetica, Arial, sans-serif, "Apple Color Emoji";
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;

  --text-xs:   0.75rem;    /* 12px */
  --text-sm:   0.875rem;   /* 14px */
  --text-base: 1rem;       /* 16px */
  --text-lg:   1.125rem;   /* 18px */
  --text-xl:   1.25rem;    /* 20px */
  --text-2xl:  1.5rem;     /* 24px */
  --text-3xl:  1.875rem;   /* 30px */
  --text-4xl:  2.25rem;    /* 36px */
  --text-5xl:  3rem;       /* 48px */

  --leading-tight:  1.2;
  --leading-snug:   1.4;
  --leading-normal: 1.6;
  --leading-loose:  1.75;

  --font-weight-normal:   400;
  --font-weight-medium:   500;
  --font-weight-semibold: 600;
  --font-weight-bold:     700;

  /* Spacing scale (multiples of 4px) */
  --space-1:  0.25rem;   /* 4px  */
  --space-2:  0.5rem;    /* 8px  */
  --space-3:  0.75rem;   /* 12px */
  --space-4:  1rem;      /* 16px */
  --space-5:  1.25rem;   /* 20px */
  --space-6:  1.5rem;    /* 24px */
  --space-8:  2rem;      /* 32px */
  --space-10: 2.5rem;    /* 40px */
  --space-12: 3rem;      /* 48px */
  --space-16: 4rem;      /* 64px */
  --space-20: 5rem;      /* 80px */
  --space-24: 6rem;      /* 96px */

  /* Layout */
  --container-max:         1200px;
  --container-narrow-max:  700px;   /* Reading column width */
  --container-padding:     var(--space-6);

  /* Borders & Radius */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-pill: 9999px;
  --border-width: 1px;

  /* Transitions */
  --transition-fast:   120ms ease;
  --transition-normal: 200ms ease;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
}


/* =============================================================================
   2. RESET & BASE
   ============================================================================= */

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

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

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

/* Make main grow to push footer to bottom */
main {
  flex: 1;
}

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

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* Accessibility: focus outline */
:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}


/* =============================================================================
   3. SKIP LINK (accessibility)
   ============================================================================= */

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  background: var(--color-brand);
  color: #fff;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  z-index: 9999;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: var(--space-4);
}


/* =============================================================================
   4. LAYOUT — Container & Grid
   ============================================================================= */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-padding);
}

/* Narrow container for reading content */
.container--narrow {
  max-width: var(--container-narrow-max);
}


/* =============================================================================
   5. COMPONENT — Buttons
   ============================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  text-decoration: none;
  transition: background-color var(--transition-fast),
              color var(--transition-fast),
              transform var(--transition-fast);
  white-space: nowrap;
  cursor: pointer;
}

.btn--primary {
  background-color: var(--color-brand);
  color: #fff;
}

.btn--primary:hover {
  background-color: var(--color-brand-hover);
}

.btn--primary:active {
  transform: translateY(1px);
}

/* Smaller variant used in the header */
.btn--sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
}


/* =============================================================================
   6. COMPONENT — Site Header
   ============================================================================= */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: var(--border-width) solid var(--color-border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  height: 60px;
}

/* Logo */
.site-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  flex-shrink: 0;
}

.logo-mark {
  height: 22px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.logo-text {
  font-size: var(--text-base);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  letter-spacing: -0.01em;
}

/* Nav */
.site-nav {
  flex: 1;
}

.nav-list {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  list-style: none;
}

.nav-link {
  display: inline-block;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.nav-link:hover,
.nav-link--active {
  color: var(--color-text);
  background-color: var(--color-bg-subtle);
}

.nav-link--active {
  font-weight: var(--font-weight-semibold);
}


/* =============================================================================
   7. COMPONENT — Site Footer
   ============================================================================= */

.site-footer {
  border-top: var(--border-width) solid var(--color-border);
  padding-block: var(--space-12);
  margin-top: var(--space-16);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-6);
  text-align: center;
}

.footer-tagline {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
}

.footer-nav-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2) var(--space-6);
  list-style: none;
}

.footer-link {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  transition: color var(--transition-fast);
}

.footer-link:hover {
  color: var(--color-text);
}

.footer-copy {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}


/* =============================================================================
   8. COMPONENT — Post List Item
   ============================================================================= */

.posts-list {
  display: flex;
  flex-direction: column;
}

.post-item {
  position: relative;
  padding-block: var(--space-8);
  border-bottom: var(--border-width) solid var(--color-border);
}

.post-item:first-child {
  border-top: var(--border-width) solid var(--color-border);
}

/* Invisible full-area click target */
.post-item-link {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.post-item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
}

.post-tag {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-brand);
  background-color: var(--color-brand-light);
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.post-date,
.post-read-time {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.post-item-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--leading-snug);
  letter-spacing: -0.02em;
  margin-bottom: var(--space-3);
}

.post-item-title-link {
  position: relative;
  z-index: 1;
  text-decoration: none;
  color: var(--color-text);
  transition: color var(--transition-fast);
}

.post-item:hover .post-item-title-link {
  color: var(--color-brand);
}

.post-item-excerpt {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  line-height: var(--leading-loose);
  max-width: 60ch;
}


/* =============================================================================
   9. COMPONENT — CTA Block
   ============================================================================= */

.cta-block {
  margin-top: var(--space-16);
  padding: var(--space-10) var(--space-8);
  background-color: var(--color-brand-light);
  border-radius: var(--radius-lg);
  border: var(--border-width) solid rgba(92, 64, 245, 0.15);
}

.cta-inner {
  max-width: 480px;
}

.cta-heading {
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-bold);
  letter-spacing: -0.02em;
  line-height: var(--leading-tight);
  margin-bottom: var(--space-3);
  color: var(--color-text);
}

.cta-body {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  line-height: var(--leading-loose);
  margin-bottom: var(--space-6);
}


/* =============================================================================
   10. PAGE — Hero (Homepage)
   ============================================================================= */

.hero {
  padding-block: var(--space-20) var(--space-16);
  border-bottom: var(--border-width) solid var(--color-border);
}

.hero-title {
  font-size: var(--text-4xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: -0.03em;
  max-width: 640px;
  margin-bottom: var(--space-4);
  color: var(--color-text);
}

.hero-subtitle {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
}


/* =============================================================================
   11. PAGE — Posts Section (Homepage)
   ============================================================================= */

.posts-section {
  padding-block: var(--space-12);
}

.view-all-wrap {
  padding-top: var(--space-8);
  text-align: center;
}

.view-all-link {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-brand);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.view-all-link:hover {
  color: var(--color-brand-hover);
}


/* =============================================================================
   12. PAGE — Blog Listing & Generic Page Header
   ============================================================================= */

.page-section {
  padding-block: var(--space-16);
}

.page-header {
  margin-bottom: var(--space-12);
  padding-bottom: var(--space-8);
  border-bottom: var(--border-width) solid var(--color-border);
}

.page-title {
  font-size: var(--text-4xl);
  font-weight: var(--font-weight-bold);
  letter-spacing: -0.03em;
  line-height: var(--leading-tight);
  color: var(--color-text);
}

.page-subtitle {
  margin-top: var(--space-3);
  font-size: var(--text-lg);
  color: var(--color-text-muted);
}


/* =============================================================================
   13. PAGE — Article (Blog Post)
   ============================================================================= */

.article-page {
  padding-bottom: var(--space-20);
}

.article-header {
  padding-block: var(--space-16) var(--space-10);
  border-bottom: var(--border-width) solid var(--color-border);
  margin-bottom: var(--space-10);
}

.article-tag {
  margin-bottom: var(--space-4);
}

.article-title {
  font-size: var(--text-4xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: -0.03em;
  color: var(--color-text);
  margin-bottom: var(--space-4);
}

.article-description {
  font-size: var(--text-xl);
  color: var(--color-text-muted);
  line-height: var(--leading-snug);
  margin-bottom: var(--space-5);
  max-width: 56ch;
}

.article-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.post-author {
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
}

.meta-sep {
  color: var(--color-text-faint);
}


/* =============================================================================
   14. PROSE — Article Body Typography
   =============================================================================
   AI RESTRICTION: Only adjust typography here. Do not add layout, colors, or
   spacing outside the prose block using these selectors — it would affect
   content written by authors, not design decisions.
   ============================================================================= */

.prose {
  font-size: var(--text-lg);
  line-height: var(--leading-loose);
  color: var(--color-text);
}

.prose > * + * {
  margin-top: var(--space-6);
}

.prose h2 {
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-bold);
  letter-spacing: -0.02em;
  line-height: var(--leading-snug);
  color: var(--color-text);
  margin-top: var(--space-12);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: var(--border-width) solid var(--color-border);
}

.prose h3 {
  font-size: var(--text-xl);
  font-weight: var(--font-weight-semibold);
  letter-spacing: -0.01em;
  color: var(--color-text);
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
}

.prose h4 {
  font-size: var(--text-base);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  margin-top: var(--space-6);
  margin-bottom: var(--space-2);
}

.prose p {
  color: var(--color-text);
}

.prose a {
  color: var(--color-brand);
  text-decoration: underline;
  text-decoration-color: rgba(92, 64, 245, 0.3);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--transition-fast);
}

.prose a:hover {
  text-decoration-color: var(--color-brand);
}

.prose ul,
.prose ol {
  padding-left: var(--space-6);
}

.prose ul {
  list-style: disc;
}

.prose ol {
  list-style: decimal;
}

.prose li + li {
  margin-top: var(--space-2);
}

.prose blockquote {
  border-left: 3px solid var(--color-brand);
  padding-left: var(--space-5);
  color: var(--color-text-muted);
  font-style: italic;
}

.prose hr {
  border: none;
  border-top: var(--border-width) solid var(--color-border);
  margin-block: var(--space-10);
}

/* Inline code */
.prose code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background-color: var(--color-bg-subtle);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.35em;
  color: var(--color-text);
}

/* Code blocks */
.prose pre {
  background-color: #0F0F13;
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
  overflow-x: auto;
  font-size: var(--text-sm);
  line-height: 1.7;
}

.prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: #E0E0F0;
}

/* Tables */
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  margin-block: var(--space-8);
}

.prose th,
.prose td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-width) solid var(--color-border);
}

.prose th {
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-muted);
  border-bottom-width: 2px;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.prose td:first-child {
  font-weight: var(--font-weight-medium);
}

.prose img {
  border-radius: var(--radius-md);
  margin-inline: auto;
}

.prose strong {
  font-weight: var(--font-weight-semibold);
}


/* =============================================================================
   15. PAGE — 404 Error Page
   ============================================================================= */

.error-page {
  display: flex;
  align-items: center;
  padding-block: var(--space-24);
}

.error-code {
  font-size: 6rem;
  font-weight: var(--font-weight-bold);
  color: var(--color-brand-light);
  line-height: 1;
  margin-bottom: var(--space-4);
  letter-spacing: -0.04em;
}

.empty-state {
  color: var(--color-text-muted);
  padding-block: var(--space-12);
  text-align: center;
}


/* =============================================================================
   16. RESPONSIVE — Mobile adjustments
   AI NOTE: Mobile styles are additive. Base styles are mobile-first where
   possible. These overrides handle larger screens or reduce sizes on small ones.
   ============================================================================= */

@media (max-width: 640px) {
  :root {
    --container-padding: var(--space-4);
  }

  .hero-title {
    font-size: var(--text-3xl);
  }

  .article-title {
    font-size: var(--text-3xl);
  }

  .post-item-title {
    font-size: var(--text-xl);
  }

  /* Collapse header on mobile: hide nav text links, keep logo + CTA */
  .site-nav {
    display: none;
  }

  .cta-block {
    padding: var(--space-8) var(--space-5);
  }
}

@media (max-width: 400px) {
  .header-inner .btn--sm {
    display: none; /* Hide header CTA on very small screens */
  }
}
