/* ============================================
   WRITING PAGE - Dark Editorial Theme
   Matching main site aesthetic
   ============================================ */

/* Design Tokens */
:root {
  /* Backgrounds */
  --bg: #0d0f14;
  --bg2: #12151c;
  --card: #181c25;
  --card2: #1e232e;
  
  /* Text */
  --text: #e8eaed;
  --text-secondary: #b8bcc4;
  --muted: #7a8290;
  
  /* Accent - Soft Cyan/Electric Blue */
  --accent: #5eb5d6;
  --accent-hover: #7ac8e4;
  --accent-glow: rgba(94, 181, 214, 0.15);
  
  /* Borders & Shadows */
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --shadow: rgba(0, 0, 0, 0.4);
  --shadow-lg: rgba(0, 0, 0, 0.6);
  
  /* Effects */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --ring: 0 0 0 3px rgba(94, 181, 214, 0.3);
  
  /* Typography */
  --font-serif: 'Playfair Display', 'Georgia', serif;
  --font-sans: 'DM Sans', 'Inter', system-ui, -apple-system, sans-serif;
  
  /* Timing */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  
  /* Grain */
  --grain-opacity: 0.025;
}

/* Light Mode */
[data-theme="light"] {
  --bg: #fafbfc;
  --bg2: #f0f2f5;
  --card: #ffffff;
  --card2: #f5f7f9;
  --text: #111827;
  --text-secondary: #374151;
  --muted: #6b7280;
  --accent: #0891b2;
  --accent-hover: #0e7490;
  --accent-glow: rgba(8, 145, 178, 0.12);
  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.15);
  --shadow: rgba(0, 0, 0, 0.05);
  --shadow-lg: rgba(0, 0, 0, 0.1);
  --ring: 0 0 0 3px rgba(8, 145, 178, 0.25);
  --grain-opacity: 0.008;
}

/* Light mode nav */
[data-theme="light"] .main-nav {
  background: rgba(250, 251, 252, 0.95);
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

/* Light mode cards */
[data-theme="light"] .post-card,
[data-theme="light"] .coming-soon-card,
[data-theme="light"] .faq-item {
  background: var(--card);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Light mode theme toggle */
[data-theme="light"] .theme-toggle {
  border-color: rgba(0, 0, 0, 0.12);
}

/* ============================================
   GLOBAL RESET & BASE STYLES
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.7;
  overflow-x: hidden;
}

/* Grain 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.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  opacity: var(--grain-opacity);
  pointer-events: none;
  z-index: 9999;
}

/* Vignette */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 0%, transparent 50%, rgba(0,0,0,0.4) 100%);
  pointer-events: none;
  z-index: 9998;
}

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

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

/* ============================================
   NAVIGATION
   ============================================ */
.main-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 1rem 0;
  background: rgba(13, 15, 20, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  transition: all 0.3s var(--ease-out-expo);
}

.nav-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 2.5rem);
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 2.5rem;
}

.nav-brand {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.nav-brand:hover {
  text-decoration: none;
  color: var(--accent);
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.nav-links a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s var(--ease-out-expo);
  position: relative;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--accent);
  transform: translateX(-50%);
  transition: width 0.3s var(--ease-out-expo);
}

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

.nav-links a:hover::after {
  width: 100%;
}

/* Theme Toggle Button */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.3s var(--ease-out-expo);
  margin-left: auto;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-hover);
  background: var(--card);
}

.theme-toggle:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform 0.3s var(--ease-out-expo);
}

.theme-toggle:hover svg {
  transform: rotate(15deg);
}

/* Show/hide icons based on theme */
.theme-toggle .icon-sun {
  display: none;
}

.theme-toggle .icon-moon {
  display: block;
}

[data-theme="light"] .theme-toggle .icon-sun {
  display: block;
}

[data-theme="light"] .theme-toggle .icon-moon {
  display: none;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 100px clamp(1.25rem, 4vw, 2.5rem) 80px;
}

/* ============================================
   HERO SECTION
   ============================================ */
.hero-section {
  display: flex;
  flex-direction: row;
  gap: 3rem;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  margin: 0 auto 4rem;
  padding: 2rem clamp(1.25rem, 4vw, 2.5rem);
}

.hero-media-wrapper {
  position: relative;
  width: 280px;
  min-width: 280px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px var(--shadow-lg);
  border: 1px solid var(--border);
  aspect-ratio: 1 / 1;
}

.hero-media {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.hero-text {
  display: flex;
  align-items: center;
  min-width: 320px;
  width: 320px;
}

.hero-title-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  line-height: 1.2;
}

.hero-title-line {
  display: block;
  opacity: 0;
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0;
  padding: 0;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-title-line.typing {
  opacity: 1;
  overflow: hidden;
  border-right: 2px solid var(--text);
  white-space: nowrap;
  animation: typing-hero steps(var(--chars)) var(--duration) forwards, caret-hero .75s steps(1) infinite;
}

.hero-title-line.done {
  opacity: 1;
  border-right: none;
  animation: none;
}

@keyframes typing-hero {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes caret-hero {
  50% { border-right-color: transparent; }
}

/* ============================================
   COMING SOON CARD
   ============================================ */
.coming-soon-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin: 0 0 4rem;
  text-align: center;
}

.coming-soon-card h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--text);
}

.coming-soon-card p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

/* ============================================
   SECTIONS
   ============================================ */
.section {
  margin: 4rem 0;
}

.section h2 {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 600;
  margin: 0 0 1.5rem;
  color: var(--text);
  letter-spacing: -0.02em;
  position: relative;
}

.section h2::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 0;
  width: 40px;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent);
  border-radius: 2px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

/* ============================================
   SEARCH
   ============================================ */
.search-container {
  flex: 1;
  max-width: 300px;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 50px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.3s var(--ease-out-expo), background 0.3s var(--ease-out-expo);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--card2);
}

.search-input::placeholder {
  color: var(--muted);
}

/* ============================================
   TAG FILTERS
   ============================================ */
.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.tag-pill {
  padding: 0.5rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 50px;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.3s var(--ease-out-expo);
}

.tag-pill:hover {
  background: var(--card2);
  border-color: var(--border-hover);
  color: var(--text);
}

.tag-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

/* ============================================
   POSTS
   ============================================ */
.posts-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.post-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: all 0.4s var(--ease-out-expo);
  cursor: pointer;
}

.post-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  box-shadow: 0 15px 35px var(--shadow);
  background: var(--card2);
}

.post-card.hidden {
  display: none;
}

.post-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  color: var(--text);
  line-height: 1.4;
}

.post-summary {
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.7;
  margin: 0 0 1rem;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.post-tag {
  padding: 0.25rem 0.75rem;
  background: rgba(94, 181, 214, 0.1);
  border: 1px solid rgba(94, 181, 214, 0.2);
  border-radius: 50px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

/* ============================================
   ARCHIVE
   ============================================ */
.archive-container {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.archive-year {
  border-bottom: 1px solid var(--border);
  padding-bottom: 2rem;
}

.archive-year:last-child {
  border-bottom: none;
}

.archive-year-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 1.25rem;
}

.archive-year-posts {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.archive-post {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  transition: all 0.3s var(--ease-out-expo);
}

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

.archive-post:hover {
  padding-left: 0.5rem;
}

.archive-post-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
}

.archive-post-title {
  font-size: 1.05rem;
  color: var(--text);
  flex: 1;
  transition: color 0.2s var(--ease-out-expo);
}

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

.archive-post-date {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

/* ============================================
   TAGS SECTION
   ============================================ */
.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.tag-chip {
  padding: 0.5rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 50px;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  transition: all 0.3s var(--ease-out-expo);
}

.tag-chip:hover {
  background: var(--card2);
  border-color: var(--accent);
  transform: translateY(-2px);
}

/* ============================================
   FAQ
   ============================================ */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.faq-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: all 0.3s var(--ease-out-expo);
}

.faq-item:hover {
  border-color: var(--border-hover);
}

.faq-item h3 {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.5rem;
}

.faq-item p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.7;
  margin: 0;
}

/* ============================================
   FOOTER
   ============================================ */
.page-footer {
  text-align: center;
  color: var(--muted);
  margin-top: 5rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

.page-footer a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  color: var(--accent);
  transition: color 0.2s var(--ease-out-expo);
}

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

.page-footer p {
  margin: 0;
  color: var(--muted);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
  .hero-section {
    flex-direction: column;
    gap: 2rem;
    text-align: center;
  }

  .hero-media-wrapper {
    width: 250px;
    min-width: 250px;
    margin: 0 auto;
  }

  .hero-text {
    justify-content: center;
  }

  .hero-title-wrapper {
    align-items: center;
  }
}

@media (max-width: 768px) {
  .nav-container {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .nav-links {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    gap: 1rem;
    margin-top: 0.5rem;
  }
  
  .theme-toggle {
    margin-left: auto;
    order: 2;
  }

  .main-content {
    padding-top: 120px;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .search-container {
    max-width: 100%;
    width: 100%;
  }

  .post-title {
    font-size: 1.15rem;
  }

  .archive-post-link {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .post-card:hover,
  .archive-post:hover,
  .tag-chip:hover {
    transform: none;
  }

  .hero-title-line.typing {
    animation: none;
    opacity: 1;
    border-right: none;
  }

  #hero-video {
    display: none !important;
  }

  #hero-image {
    display: block !important;
  }
}
