/* ============================================================
   ByteForge Blog — Shared Stylesheet
   A polished tech blog theme with light/dark mode support
   and integrated ad slot styling.
   ============================================================ */

/* ----- CSS Custom Properties (Light Mode) ----- */
:root {
  --font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --color-text: #1a1a2e;
  --color-bg: #ffffff;
  --color-surface: #f4f4f5;
  --color-link: #10b981;
  --color-border: #e2e8f0;
  --color-muted: #71717a;
  --radius: 8px;
  --spacing: 16px;
}

/* ----- Dark Mode ----- */
[data-theme="dark"] {
  --color-text: #e4e4e7;
  --color-bg: #0f0f14;
  --color-surface: #1c1c24;
  --color-border: #2e2e3a;
}

/* ============================================================
   Reset / Normalize
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

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

ul,
ol {
  list-style: none;
}

/* ============================================================
   Base Typography
   ============================================================ */
body {
  font-family: var(--font-family);
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1.3;
  font-weight: 700;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

p {
  margin-bottom: 1rem;
}

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

a:hover {
  text-decoration: underline;
}

code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.9em;
  background: var(--color-surface);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

/* ============================================================
   Layout — Site Header
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 1.5rem;
  background-color: color-mix(in srgb, var(--color-bg) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
}

.site-header .logo {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.site-header .logo span {
  color: var(--color-link);
}

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

.site-header nav a {
  color: var(--color-text);
  font-size: 0.925rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s ease;
}

.site-header nav a:hover {
  color: var(--color-link);
  text-decoration: none;
}

/* ============================================================
   Layout — Main Content
   ============================================================ */
.site-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.content-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
}

/* ============================================================
   Layout — Sidebar
   ============================================================ */
.sidebar {
  position: sticky;
  top: 76px; /* header height (60px) + 16px breathing room */
  align-self: start;
}

/* ============================================================
   Layout — Footer
   ============================================================ */
.site-footer {
  background-color: #1a1a2e;
  color: #a1a1aa;
  padding: 3rem 1.5rem 2rem;
  margin-top: 4rem;
}

.site-footer .footer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.site-footer h4 {
  color: #ffffff;
  margin-bottom: 1rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.site-footer a {
  color: #a1a1aa;
  transition: color 0.15s ease;
}

.site-footer a:hover {
  color: #10b981;
  text-decoration: none;
}

.site-footer ul li {
  padding: 0.3rem 0;
}

.site-footer .footer-bottom {
  text-align: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #2e2e3a;
  font-size: 0.85rem;
}

/* ============================================================
   Article Meta
   ============================================================ */
.article-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--color-muted);
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 9999px;
  background-color: var(--color-link);
  color: #ffffff;
  line-height: 1.5;
}

/* ============================================================
   Article Cards (Index / Category pages)
   ============================================================ */
.article-card {
  padding: 1.5rem;
  border-bottom: 1px solid var(--color-border);
  transition: background-color 0.15s ease;
}

.article-card:hover {
  background-color: var(--color-surface);
}

.article-card h2 {
  margin-bottom: 0.5rem;
}

.article-card h2 a {
  color: var(--color-text);
  text-decoration: none;
  transition: color 0.15s ease;
}

.article-card h2 a:hover {
  color: var(--color-link);
  text-decoration: none;
}

.article-card p {
  color: var(--color-muted);
  margin-bottom: 0;
}

/* ============================================================
   Sidebar Widgets
   ============================================================ */
.sidebar-widget {
  padding: 1.5rem;
  background: var(--color-surface);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}

.sidebar-widget h3 {
  margin-bottom: 1rem;
  font-size: 1rem;
}

.sidebar-widget ul {
  list-style: none;
  padding: 0;
}

.sidebar-widget li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-widget li:last-child {
  border-bottom: none;
}

.sidebar-widget li a {
  color: var(--color-text);
  font-size: 0.925rem;
}

.sidebar-widget li a:hover {
  color: var(--color-link);
  text-decoration: none;
}

/* ============================================================
   Ad Slot Styles
   ============================================================ */
.ad-slot {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  overflow: hidden;
  position: relative;
}

.ad-slot::before {
  content: "Advertisement";
  position: absolute;
  top: 0;
  left: 0;
  font-size: 10px;
  padding: 2px 8px;
  color: var(--color-muted);
  z-index: 1;
  letter-spacing: 0.03em;
}

.ad-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Leaderboard — 728 x 90 */
.ad-slot--leaderboard {
  min-height: 90px;
  max-width: 728px;
  margin: 1rem auto;
}

/* Sidebar — 300 x 250 */
.ad-slot--sidebar {
  min-height: 250px;
  width: 300px;
  max-width: 100%;
}

/* Native / In-feed */
.ad-slot--native {
  min-height: 100px;
  width: 100%;
}

/* Sticky footer (mobile) */
.ad-slot--footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  min-height: 50px;
  z-index: 1000;
  display: none;
  border-radius: 0;
  margin-bottom: 0;
  background: var(--color-surface);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
}

/* Half-page — 300 x 600 */
.ad-slot--halfpage {
  min-height: 600px;
  width: 300px;
  max-width: 100%;
}

/* Text ad */
.ad-slot--text {
  min-height: 60px;
  width: 100%;
}

/* ============================================================
   Article Page — Content & Header
   ============================================================ */
.article-content {
  max-width: 720px;
  font-size: 1.1rem;
  line-height: 1.8;
}

.article-content p {
  margin-bottom: 1.5rem;
}

.article-content h2 {
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.article-content h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.article-content blockquote {
  border-left: 3px solid var(--color-link);
  padding-left: 1rem;
  margin: 1.5rem 0;
  color: var(--color-muted);
  font-style: italic;
}

.article-content pre {
  background: var(--color-surface);
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.article-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

.article-content ul,
.article-content ol {
  margin-bottom: 1.5rem;
  padding-left: 1.25rem;
  list-style: disc;
}

.article-content ol {
  list-style: decimal;
}

.article-content li {
  margin-bottom: 0.4rem;
}

.article-header {
  margin-bottom: 2rem;
}

.article-header h1 {
  font-size: 2.2rem;
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

/* ============================================================
   Utility Classes
   ============================================================ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.btn {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  background-color: var(--color-link);
  color: #ffffff;
  border: none;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.925rem;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.btn:hover {
  opacity: 0.85;
  text-decoration: none;
  color: #ffffff;
}

/* ============================================================
   Theme Toggle Button
   ============================================================ */
#theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  padding: 0.5rem;
  color: var(--color-text);
  transition: color 0.15s ease;
  line-height: 1;
}

#theme-toggle:hover {
  color: var(--color-link);
}

/* ============================================================
   Responsive — Tablet (max-width: 1024px)
   ============================================================ */
@media (max-width: 1024px) {
  .content-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }
}

/* ============================================================
   Responsive — Mobile (max-width: 768px)
   ============================================================ */
@media (max-width: 768px) {
  h1 { font-size: 1.65rem; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.1rem; }

  .site-header {
    padding: 0 1rem;
  }

  .site-header nav {
    gap: 1rem;
  }

  .site-header nav a {
    font-size: 0.85rem;
  }

  .site-main {
    padding: 1.5rem 0.75rem;
  }

  .ad-slot--leaderboard {
    max-width: 100%;
  }

  .ad-slot--footer {
    display: flex;
  }

  .article-header h1 {
    font-size: 1.75rem;
  }

  .article-content {
    font-size: 1rem;
  }

  .site-footer .footer-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  /* Add bottom padding so fixed footer ad doesn't cover content */
  body {
    padding-bottom: 60px;
  }
}
