/* ==========================================================================
   The Inner Loop — Editorial Dark Theme
   ========================================================================== */

:root {
  --bg: #0a0a0f;
  --bg-surface: #101018;
  --bg-card: #14141e;
  --border: #1e1e2e;
  --border-hover: #2a2a3e;
  --text: #e4e4ef;
  --text-muted: #8888a0;
  --text-dim: #55556a;
  --accent: #00c8e0;
  --accent-light: #40d8ee;
  --accent-glow: rgba(0, 200, 224, 0.1);
  --accent-warm: #f0a050;
  --gradient-1: #00c8e0;
  --gradient-2: #7c5cfc;
  --radius: 8px;
  --radius-lg: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Subtle grain overlay */
.grain-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.025;
  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");
}

a { color: var(--accent-light); text-decoration: none; transition: color 0.2s; }
a:hover { color: #fff; }

::selection { background: var(--accent); color: #fff; }

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

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  background: rgba(10, 10, 15, 0.85);
  border-bottom: 1px solid var(--border);
}

.nav-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
}

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

.logo-icon {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
}

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

.nav-link {
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.2s;
}

.nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-muted);
  border-radius: 2px;
  transition: all 0.3s;
}

.nav-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.nav-toggle.active span:nth-child(2) { opacity: 0; }
.nav-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

@media (max-width: 768px) {
  .nav-toggle { display: flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 1rem;
  }
  .nav-links.open { display: flex; }
}

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

.hero {
  position: relative;
  min-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 6rem 2rem 4rem;
}

.hero-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.hero-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.2;
  animation: float 25s ease-in-out infinite;
}

.hero-orb-1 {
  width: 600px;
  height: 600px;
  background: var(--gradient-1);
  top: -20%;
  right: -10%;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(20px, -20px) scale(1.03); }
  66% { transform: translate(-15px, 15px) scale(0.97); }
}

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 700px;
}

.hero-title {
  font-size: clamp(2.8rem, 7vw, 5rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: 1.5rem;
}

.hero-line { display: block; }

.gradient-text {
  background: linear-gradient(135deg, var(--gradient-1), var(--gradient-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  background-size: 200% 200%;
  animation: gradient-shift 10s ease infinite;
}

@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 520px;
  margin: 0 auto 1rem;
  line-height: 1.7;
}

.hero-byline {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 2.5rem;
}

.hero-byline strong {
  color: var(--text-muted);
}

.hero-cta {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.7rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.25s;
  cursor: pointer;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #0a0a0f;
  box-shadow: 0 2px 12px rgba(0, 200, 224, 0.2);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(0, 200, 224, 0.35);
  color: #0a0a0f;
  background: var(--accent-light);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--text);
}

/* ==========================================================================
   Sections
   ========================================================================== */

.section-container {
  max-width: 740px;
  margin: 0 auto;
  padding: 0 2rem;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.section-intro {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 2.5rem;
  line-height: 1.7;
}

.writing-section {
  padding: 5rem 0;
  background: var(--bg);
}

.about-section {
  padding: 5rem 0;
  background: var(--bg-surface);
}

.subscribe-section {
  padding: 5rem 0;
  background: var(--bg);
}

/* ==========================================================================
   Article List
   ========================================================================== */

.article-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.article-item {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.25rem 1.5rem;
  background: var(--bg-card);
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
}

.article-item:hover {
  background: #1a1a28;
  color: var(--text);
}

.article-num {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 2rem;
  opacity: 0.7;
}

.article-info {
  flex: 1;
  min-width: 0;
}

.article-info h3 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.article-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
  font-family: var(--font-mono);
}

.article-arrow {
  color: var(--text-dim);
  font-size: 1.1rem;
  transition: all 0.2s;
  flex-shrink: 0;
}

.article-item:hover .article-arrow {
  color: var(--accent);
  transform: translateX(3px);
}

/* ==========================================================================
   About Section
   ========================================================================== */

.about-content {
  max-width: 740px;
}

.about-content p {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: 1.25rem;
}

.about-content a {
  color: var(--accent-light);
  text-decoration: underline;
  text-decoration-color: rgba(64, 216, 238, 0.3);
  text-underline-offset: 3px;
}

.about-content a:hover {
  text-decoration-color: var(--accent-light);
  color: #fff;
}

.about-links {
  display: flex;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.about-links a {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-light);
  text-decoration: none;
  transition: color 0.2s;
}

.about-links a:hover { color: #fff; }

/* ==========================================================================
   Subscribe Section
   ========================================================================== */

.subscribe-box {
  text-align: center;
  padding: 3rem 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
}

.subscribe-box h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.subscribe-box p {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* ==========================================================================
   Post & Page Layout
   ========================================================================== */

.post-page,
.page-content {
  padding: 8rem 2rem 4rem;
}

.post-container,
.page-container {
  max-width: 740px;
  margin: 0 auto;
}

.post-header { margin-bottom: 3rem; }

.post-page-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-top: 1rem;
}

.page-header { margin-bottom: 3rem; }

.page-title {
  font-size: clamp(2rem, 5vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

/* Post/page body typography */
.post-body,
.page-body {
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--text);
}

.post-body h2, .page-body h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
  letter-spacing: -0.02em;
}

.post-body h3, .page-body h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
}

.post-body p, .page-body p { margin-bottom: 1.5rem; }

.post-body ul, .post-body ol,
.page-body ul, .page-body ol { margin: 0 0 1.5rem 1.25rem; }

.post-body li, .page-body li { margin-bottom: 0.5rem; }

.post-body a, .page-body a {
  color: var(--accent-light);
  text-decoration: underline;
  text-decoration-color: rgba(64, 216, 238, 0.3);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s;
}

.post-body a:hover, .page-body a:hover {
  text-decoration-color: var(--accent-light);
}

.post-body code, .page-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.15em 0.4em;
  border-radius: 4px;
  background: var(--accent-glow);
  color: var(--accent-light);
}

.post-body pre, .page-body pre {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.post-body pre code, .page-body pre code {
  background: none;
  padding: 0;
  color: var(--text);
}

.post-body blockquote, .page-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1.5rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
  font-style: italic;
}

.post-body img, .page-body img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 1.5rem 0;
}

.post-footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.back-link {
  font-weight: 600;
  color: var(--text-muted);
  transition: color 0.2s;
}

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

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

.site-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 3rem 0 2rem;
}

.footer-container {
  max-width: 740px;
  margin: 0 auto;
  padding: 0 2rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer-heading {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.footer-tagline {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

.footer-col h4 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}

.footer-links {
  list-style: none;
  padding: 0;
}

.footer-links li { margin-bottom: 0.4rem; }

.footer-links a {
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: color 0.2s;
}

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

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
  text-align: center;
}

.footer-bottom p {
  font-size: 0.78rem;
  color: var(--text-dim);
}

@media (max-width: 768px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

/* ==========================================================================
   404 Page
   ========================================================================== */

.error-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6rem 2rem;
  text-align: center;
}

.error-code {
  font-size: clamp(6rem, 15vw, 12rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.05em;
  background: linear-gradient(135deg, var(--gradient-1), var(--gradient-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
}

.error-message {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

/* ==========================================================================
   Scroll Animations
   ========================================================================== */

.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

.fade-in:nth-child(2) { transition-delay: 0.08s; }
.fade-in:nth-child(3) { transition-delay: 0.16s; }
.fade-in:nth-child(4) { transition-delay: 0.24s; }
.fade-in:nth-child(5) { transition-delay: 0.32s; }
.fade-in:nth-child(6) { transition-delay: 0.40s; }
.fade-in:nth-child(7) { transition-delay: 0.48s; }

.hero .fade-in {
  animation: fade-up 0.7s ease forwards;
}

.hero .fade-in:nth-child(1) { animation-delay: 0.1s; }
.hero .fade-in:nth-child(2) { animation-delay: 0.25s; }
.hero .fade-in:nth-child(3) { animation-delay: 0.4s; }
.hero .fade-in:nth-child(4) { animation-delay: 0.55s; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 640px) {
  .hero { padding: 5rem 1.5rem 3rem; min-height: 80vh; }
  .section-container { padding: 0 1.5rem; }
  .hero-cta { flex-direction: column; align-items: center; }
  .article-item { padding: 1rem 1.25rem; gap: 1rem; }
  .article-info h3 { font-size: 0.95rem; }
  .about-links { flex-direction: column; gap: 0.75rem; }
  .subscribe-box { padding: 2rem 1.5rem; }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
