/* ============================================
   ROM4AI Blog - Editorial/Magazine Dark Theme
   Typography: Playfair Display + JetBrains Mono
   Accent: Orange (#ff6b35)
   ============================================ */

/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=JetBrains+Mono:wght@400;500;600&family=Inter:wght@300;400;500;600&display=swap');

/* CSS Variables - Dark Theme (Default) */
:root {
  /* Typography */
  --font-display: "Playfair Display", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", monospace;
  
  /* Dark Theme Colors */
  --bg-primary: #0a0a0a;
  --bg-secondary: #111111;
  --bg-tertiary: #1a1a1a;
  --bg-elevated: #1f1f1f;
  
  --text-primary: #fafafa;
  --text-secondary: #a1a1a1;
  --text-tertiary: #666666;
  --text-muted: #444444;
  
  --accent: #ff6b35;
  --accent-hover: #ff8555;
  --accent-soft: rgba(255, 107, 53, 0.15);
  
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  
  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2.5rem;
  --space-xl: 4rem;
  --space-2xl: 6rem;
  
  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;
}

/* Light Theme */
[data-theme="light"] {
  --bg-primary: #faf9f7;
  --bg-secondary: #f5f3f0;
  --bg-tertiary: #ebe8e3;
  --bg-elevated: #ffffff;
  
  --text-primary: #1a1a1a;
  --text-secondary: #4a4a4a;
  --text-tertiary: #6a6a6a;
  --text-muted: #999999;
  
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.15);
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.12);
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  min-height: 100vh;
  transition: background-color var(--transition-base), color var(--transition-base);
}

/* Grain Texture Overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  opacity: 0.03;
  pointer-events: none;
  z-index: 9999;
}

/* Selection */
::selection {
  background-color: var(--accent-soft);
  color: var(--accent);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-primary);
}

h1 { font-size: clamp(2.5rem, 5vw, 4rem); }
h2 { font-size: clamp(1.75rem, 3vw, 2.5rem); }
h3 { font-size: clamp(1.25rem, 2vw, 1.5rem); }

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

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

/* Code Font */
code, pre, .mono {
  font-family: var(--font-mono);
}

/* ============================================
   Layout
   ============================================ */

.site-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

/* ============================================
   Header
   ============================================ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(10, 10, 10, 0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  transition: background-color var(--transition-base);
}

[data-theme="light"] .site-header {
  background-color: rgba(250, 249, 247, 0.9);
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) 0;
  gap: var(--space-md);
}

.site-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.site-brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
  letter-spacing: 0.05em;
}

.site-brand-copy {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.site-brand-copy strong {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.site-brand-copy span {
  font-size: 0.75rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

/* Navigation */
.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.site-nav a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 0.5rem 0;
  position: relative;
}

.site-nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--accent);
  transition: width var(--transition-base);
}

.site-nav a:hover,
.site-nav a.is-active {
  color: var(--text-primary);
}

.site-nav a:hover::after,
.site-nav a.is-active::after {
  width: 100%;
}

/* Theme Toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.theme-toggle:hover {
  border-color: var(--accent);
  background-color: var(--accent-soft);
}

.theme-toggle svg {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.theme-toggle:hover svg {
  color: var(--accent);
}

/* ============================================
   Hero Section
   ============================================ */

.hero {
  padding: var(--space-2xl) 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
  align-items: center;
  min-height: 70vh;
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    text-align: center;
  }
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1 {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

/* Typewriter Effect */
.typewriter {
  display: inline;
}

.typewriter-cursor {
  display: inline-block;
  width: 3px;
  height: 1em;
  background-color: var(--accent);
  margin-left: 2px;
  animation: blink 1s step-end infinite;
  vertical-align: text-bottom;
}

@keyframes blink {
  50% { opacity: 0; }
}

.hero-description {
  font-size: 1.125rem;
  color: var(--text-secondary);
  max-width: 480px;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
}

@media (max-width: 900px) {
  .hero-actions {
    justify-content: center;
  }
}

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.button-primary {
  background-color: var(--accent);
  color: white;
  border-color: var(--accent);
}

.button-primary:hover {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
  color: white;
}

.button-secondary {
  background-color: transparent;
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.button-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Hero Visual */
.hero-visual {
  display: flex;
  justify-content: center;
  align-items: center;
}

.hero-avatar {
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-elevated) 100%);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.hero-avatar::before {
  content: '';
  position: absolute;
  inset: -50%;
  background: conic-gradient(from 0deg, transparent, var(--accent), transparent 30%);
  animation: rotate 4s linear infinite;
}

.hero-avatar::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: var(--bg-secondary);
}

@keyframes rotate {
  to { transform: rotate(360deg); }
}

.hero-avatar-inner {
  position: relative;
  z-index: 1;
  font-family: var(--font-display);
  font-size: 4rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ============================================
   Posts Grid Section
   ============================================ */

.posts-section {
  padding: var(--space-2xl) 0;
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-size: 0.875rem;
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-lg);
}

/* Post Card */
.post-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  transition: all var(--transition-base);
  cursor: pointer;
}

.post-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.post-card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.post-card-date::after {
  content: '·';
  margin-left: var(--space-xs);
}

.post-card-categories {
  display: flex;
  gap: 0.375rem;
}

.category-tag {
  color: var(--accent);
}

.post-card h3 {
  font-size: 1.25rem;
  margin-bottom: var(--space-sm);
  line-height: 1.3;
}

.post-card h3 a {
  color: var(--text-primary);
}

.post-card h3 a:hover {
  color: var(--accent);
}

.post-card-excerpt {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================
   Article Page
   ============================================ */

.article-page {
  padding: var(--space-xl) 0;
}

.article-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: var(--space-xl);
  max-width: 1100px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .article-layout {
    grid-template-columns: 1fr;
  }
}

/* Article Content */
.article-content {
  min-width: 0;
}

.article-header {
  margin-bottom: var(--space-xl);
}

.article-header .eyebrow {
  margin-bottom: var(--space-sm);
}

.article-header h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  margin-bottom: var(--space-md);
}

.article-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.article-body {
  font-size: 1.0625rem;
  line-height: 1.8;
  color: var(--text-secondary);
}

.article-body h2 {
  font-size: 1.5rem;
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

.article-body h3 {
  font-size: 1.25rem;
  margin-top: var(--space-lg);
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

.article-body p {
  margin-bottom: var(--space-md);
}

.article-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

/* Code Blocks */
.article-body pre {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  overflow-x: auto;
  margin: var(--space-md) 0;
}

.article-body code {
  font-size: 0.875rem;
  color: var(--text-primary);
}

.article-body p code {
  background-color: var(--bg-tertiary);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

/* Article Sidebar */
.article-sidebar {
  position: sticky;
  top: 100px;
  height: fit-content;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding-right: 0.25rem;
}

@media (max-width: 900px) {
  .article-sidebar {
    position: static;
    order: -1;
    max-height: none;
    overflow-y: visible;
    padding-right: 0;
  }
}

.sidebar-section {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.sidebar-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--space-sm);
}

/* Table of Contents */
.toc-list {
  list-style: none;
}

.toc-list li {
  margin-bottom: 0.5rem;
}

.toc-list a {
  font-size: 0.875rem;
  color: var(--text-secondary);
  display: block;
  padding: 0.25rem 0;
  border-left: 2px solid transparent;
  padding-left: 0.75rem;
  margin-left: -0.75rem;
  transition: all var(--transition-fast);
}

.toc-list a:hover,
.toc-list a.is-active {
  color: var(--accent);
  border-left-color: var(--accent);
}

.toc-list li[data-level="3"] a {
  padding-left: 1.5rem;
  font-size: 0.8125rem;
}

/* Back Link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

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

.back-link::before {
  content: '←';
}

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

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: var(--space-2xl);
  padding: var(--space-xl) 0;
}

.site-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

@media (max-width: 600px) {
  .site-footer-inner {
    flex-direction: column;
    text-align: center;
  }
}

.site-footer-copy {
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

.site-footer-links {
  display: flex;
  gap: var(--space-md);
}

.site-footer-links a {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.site-footer-links a:hover {
  color: var(--accent);
}

/* ============================================
   Utilities
   ============================================ */

.hidden {
  display: none !important;
}

.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;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Focus Styles */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Smooth scroll offset for sticky header */
html {
  scroll-padding-top: 100px;
}