/* =====================================================================
   PAVNXET PREMIUM CREAMY DESIGN SYSTEM — ARTICLE TOKENS
   ===================================================================== */
:root {
  /* Color Palette (Creamy Light Mode Base) */
  --bg-primary: #faf6f0;
  --bg-surface: #ffffff;
  --bg-inner: #f6efe5;
  --bg-active: #f3ebe0;

  /* Additional Cream Scale Variants */
  --cream: #faf6f0;
  --cream2: #f4ede2;
  --cream3: #ecdfd0;

  /* Text & Ink Colors */
  --ink: #1e1a15;
  --ink2: #4a4038;
  --ink3: #8c7e6e;
  --text-main: #2c2a27;
  --text-muted: #7a7266;
  --text-inverse: #ffffff;

  /* Accent & Decorative Colors */
  --accent: #b07d4a;
  --accent-soft: #f0e4d0;
  --accent-cocoa: #8e7c68;
  --accent-cocoa-light: #f2ece4;
  --accent-gold: #c5a880;
  --warm: #c9a87c;
  --warm2: #e8d5b7;

  /* Status Colors */
  --status-completed-bg: #eaf2ec;
  --status-completed-text: #4e7e5c;
  --status-ongoing-bg: #faf0e6;
  --status-ongoing-text: #c07f4e;
  --status-error-bg: #f8e6e0;
  --status-error-text: #b04a2e;
  --status-info-bg: #eae8f5;
  --status-info-text: #5040a0;

  /* Border Radii */
  --radius: 16px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  /* Typography Scale */
  --font-primary: 'Outfit', 'Segoe UI', system-ui, sans-serif;
  --font-sans: 'Sora', 'Segoe UI Variable', system-ui, sans-serif;
  --font-serif: 'Lora', Georgia, 'Times New Roman', serif;
  --font-code: 'Consolas', 'Courier New', Courier, monospace;

  /* Transition Curves */
  --transition-fast: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-elastic: all 0.25s cubic-bezier(.22,.68,0,1.1);

  /* Shadows — Tinted with Warm Hue */
  --shadow-sm: 0 2px 8px rgba(142, 124, 104, 0.04);
  --shadow: 0 4px 20px rgba(160, 120, 70, 0.08);
  --shadow-md: 0 10px 24px rgba(142, 124, 104, 0.06);
  --shadow-lg: 0 20px 40px rgba(142, 124, 104, 0.1);
  --shadow-hover: 0 24px 48px rgba(142, 124, 104, 0.15);
}

/* =====================================================================
   BASE RESET & LAYOUT
   ===================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { scroll-behavior: smooth; overflow-x: hidden; width: 100%; }

body {
  background-color: var(--bg-primary);
  color: var(--ink);
  font-family: var(--font-primary);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  width: 100%;
}

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

a { color: var(--accent); text-decoration: none; transition: var(--transition-fast); }
a:hover { color: var(--accent-cocoa); }

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

/* =====================================================================
   NAVIGATION — Sticky Back to Home / Logo
   ===================================================================== */
nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 246, 240, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--warm2);
  padding: 0 clamp(20px, 5vw, 80px);
}
.nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 62px;
}
.back-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink2);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  transition: var(--transition-elastic);
}
.back-link:hover {
  background: var(--accent-cocoa-light);
  color: var(--accent);
  transform: translateX(-3px);
}
.back-icon {
  width: 16px; height: 16px;
  stroke: currentColor;
  stroke-width: 2.5;
  fill: none;
}
.logo {
  display: flex;
  align-items: center;
}
.logo-text {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 20px;
  color: var(--accent);
  letter-spacing: -0.01em;
}
.logo-x {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  color: var(--accent-gold);
  font-weight: 600;
}

/* =====================================================================
   ARTICLE HEADER / HERO
   ===================================================================== */
.article-header {
  max-width: 820px;
  margin: 0 auto;
  padding: clamp(40px, 8vw, 70px) 20px 30px;
  text-align: center;
}
.tag {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 20px;
}
.article-title {
  font-family: var(--font-serif);
  font-size: clamp(28px, 4.5vw, 44px);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 24px;
}
.article-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--ink3);
  font-weight: 400;
  flex-wrap: wrap;
}
.meta-avatar {
  width: 28px; height: 28px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--cream2);
  padding: 2px;
  border: 1px solid var(--warm2);
}
.meta-author {
  font-weight: 500;
  color: var(--ink2);
}
.meta-dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background-color: var(--warm);
}

.hero-image-wrap {
  max-width: 960px;
  margin: 20px auto 40px;
  padding: 0 20px;
}
.hero-banner {
  background: var(--cream2);
  border-radius: var(--radius);
  border: 1px solid var(--warm2);
  padding: clamp(20px, 6vw, 60px);
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: var(--shadow);
}
.hero-banner img {
  max-width: 100%;
  height: auto;
  max-height: 320px;
  object-fit: contain;
  filter: drop-shadow(0 6px 18px rgba(142, 124, 104, 0.12));
}

/* =====================================================================
   PAGE LAYOUT GRID
   ===================================================================== */
.page-layout {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 80px;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 60px;
}

/* Sticky TOC Sidebar */
.toc-sidebar {
  position: sticky;
  top: 100px;
  height: fit-content;
  align-self: start;
}
.toc-card {
  background: var(--bg-surface);
  border: 1px solid var(--warm2);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.toc-heading {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink3);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--cream2);
}
.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.toc-link {
  display: block;
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--ink3);
  font-weight: 400;
  transition: var(--transition-elastic);
  padding-left: 0;
  border-left: 2px solid transparent;
}
.toc-link:hover {
  color: var(--accent);
  padding-left: 6px;
}
.toc-link.active {
  color: var(--accent);
  font-weight: 600;
  padding-left: 10px;
  border-left: 2.5px solid var(--accent);
}

/* Main Article Column */
.article-container {
  max-width: 720px;
  min-width: 0;
}
article {
  font-family: var(--font-serif);
  font-size: 17.5px;
  color: var(--ink2);
  line-height: 1.8;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
}
article p {
  margin-bottom: 24px;
}
article p strong {
  color: var(--ink);
  font-weight: 600;
}
article h2 {
  font-family: var(--font-sans);
  font-size: 26px;
  font-weight: 600;
  color: var(--ink);
  margin: 48px 0 20px;
  letter-spacing: -0.01em;
  scroll-margin-top: 90px;
}
article h3 {
  font-family: var(--font-sans);
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
  margin: 32px 0 16px;
  scroll-margin-top: 90px;
}

/* =====================================================================
   ELEMENTS STYLING
   ===================================================================== */
blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 0 8px 24px;
  margin: 32px 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 19px;
  color: var(--accent);
  line-height: 1.6;
}
pre, code {
  font-family: var(--font-code);
  font-size: 14.5px;
  background: var(--cream2);
  border-radius: var(--radius-sm);
}
code {
  padding: 2.5px 6px;
  border: 1px solid var(--warm2);
  color: var(--accent);
}
pre {
  padding: 18px;
  overflow-x: auto;
  border: 1px solid var(--warm2);
  margin-bottom: 28px;
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  line-height: 1.6;
}
pre code {
  padding: 0;
  border: none;
  background: none;
  color: var(--ink2);
}
/* Basic code syntax highlighting support */
pre .kw { color: var(--accent); font-weight: 500; }
pre .str { color: var(--status-completed-text); }
pre .com { color: var(--ink3); font-style: italic; }

/* Table styling */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 32px 0;
  font-family: var(--font-sans);
  font-size: 14.5px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--warm2);
}
th, td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--cream2);
}
th {
  background: var(--cream2);
  color: var(--accent-cocoa);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11.5px;
  letter-spacing: 0.08em;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: var(--transition-fast); }
tbody tr:hover { background: var(--accent-cocoa-light); }

/* Showcase / Embedded Media Card */
.showcase-card {
  background: var(--cream2);
  border: 1px solid var(--warm2);
  border-radius: var(--radius);
  padding: 16px;
  margin: 32px 0;
  box-shadow: var(--shadow);
  transition: var(--transition-elastic);
}
.showcase-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.showcase-image {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--warm2);
}
.showcase-caption {
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--ink3);
  text-align: center;
  margin-top: 12px;
  font-style: italic;
}

/* Lists styling */
article ul {
  list-style: none;
  margin: 20px 0 28px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
article ul li {
  position: relative;
  padding-left: 24px;
}
article ul li::before {
  content: "✦";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 14px;
}

/* Author bio section */
.author-card {
  margin-top: 64px;
  padding-top: 40px;
  border-top: 1px solid var(--warm2);
  display: flex;
  gap: 24px;
  align-items: center;
}
.author-card .meta-avatar {
  width: 72px; height: 72px;
  border-radius: var(--radius-sm);
  padding: 3px;
  background: var(--cream2);
  border: 1px solid var(--warm2);
}
.author-info h4 {
  font-family: var(--font-sans);
  font-size: 16px;
  color: var(--ink);
  margin-bottom: 6px;
}
.author-info p {
  font-family: var(--font-sans);
  font-size: 14.5px;
  color: var(--ink3);
  margin-bottom: 0;
  line-height: 1.6;
}

/* Alerts / feedback inside articles */
.alert {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.6;
  border: 1px solid transparent;
  margin: 24px 0;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--status-completed-bg); color: var(--status-completed-text); border-color: rgba(78, 126, 92, 0.2); }
.alert-warning { background: var(--status-ongoing-bg); color: var(--status-ongoing-text); border-color: rgba(192, 127, 78, 0.2); }
.alert-error   { background: var(--status-error-bg); color: var(--status-error-text); border-color: rgba(176, 74, 46, 0.2); }
.alert-info    { background: var(--status-info-bg); color: var(--status-info-text); border-color: rgba(80, 64, 160, 0.2); }
.alert strong { font-weight: 600; }

/* =====================================================================
   DYNAMICS & OVERLAYS (FAB, Progress, Spotlight, Blobs)
   ===================================================================== */
/* Scroll progress bar */
.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-cocoa), var(--accent), var(--accent-gold));
  z-index: 60;
  width: 0%;
  transition: width 0.08s linear;
  box-shadow: 0 0 12px rgba(176, 125, 74, 0.4);
}

/* Spotlight overlay */
.spotlight {
  position: fixed;
  pointer-events: none;
  top: 0; left: 0;
  width: 520px; height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(176, 125, 74, 0.1) 0%, rgba(176, 125, 74, 0) 60%);
  transform: translate(-50%, -50%);
  z-index: 1;
  opacity: 0;
  transition: opacity 0.4s;
  mix-blend-mode: multiply;
}

/* Floating decorative blobs */
.blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(70px);
  pointer-events: none;
  z-index: 0;
}
.blob-1 {
  top: -140px; right: -120px;
  width: 420px; height: 420px;
  background: radial-gradient(circle, var(--warm), transparent 70%);
  opacity: 0.22;
  animation: float 20s ease-in-out infinite;
}
.blob-2 {
  bottom: -120px; left: -140px;
  width: 360px; height: 360px;
  background: radial-gradient(circle, var(--accent-gold), transparent 70%);
  opacity: 0.18;
  animation: float 26s ease-in-out infinite reverse;
}

/* Floating action button */
.fab {
  position: fixed;
  bottom: 26px;
  left: 26px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--accent-cocoa);
  color: var(--text-inverse);
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-lg);
  z-index: 40;
  transition: var(--transition-elastic);
  opacity: 0;
  transform: translateY(20px) scale(0.8);
  pointer-events: none;
}
.fab.visible { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.fab:hover { background: var(--ink); transform: translateY(-4px) scale(1.06); }
.fab svg { width: 20px; height: 20px; stroke: currentColor; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(24px, -22px) rotate(4deg); }
  66% { transform: translate(-18px, 18px) rotate(-3deg); }
}

/* Layout z-index overrides for blobs */
nav, .article-header, .hero-image-wrap, .page-layout {
  position: relative;
}
nav { z-index: 50; }
.article-header, .hero-image-wrap, .page-layout { z-index: 2; }

/* =====================================================================
   RESPONSIVE LAYOUT CONSTRAINTS
   ===================================================================== */
@media (max-width: 900px) {
  .page-layout {
    grid-template-columns: 1fr;
    gap: 24px;
    padding-bottom: 60px;
  }
  
  .toc-sidebar {
    position: static;
    order: -1;
    min-width: 0;
    width: 100%;
  }
  
  .article-container {
    max-width: 100%;
  }
  
  .toc-card {
    padding: 16px 20px;
  }
  
  .toc-heading {
    display: none;
  }
  
  .toc-list {
    flex-direction: row;
    gap: 16px;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  
  .toc-list::-webkit-scrollbar {
    height: 3px;
  }
  .toc-list::-webkit-scrollbar-thumb {
    background: var(--cream3);
    border-radius: 2px;
  }
  
  .toc-link {
    padding: 6px 14px;
    border-left: none;
    border-bottom: 2.5px solid transparent;
    font-size: 13px;
    background: var(--cream2);
    border-radius: var(--radius-pill);
  }
  .toc-link:hover { padding-left: 14px; color: var(--accent); }
  .toc-link.active {
    background: var(--accent-soft);
    border-bottom-color: var(--accent);
    padding-left: 14px;
    border-left: none;
  }
  
  .article-header {
    padding-bottom: 10px;
  }
}

@media (max-width: 480px) {
  nav {
    padding: 0 15px;
  }
  .nav-inner {
    height: 56px;
  }
  .back-link {
    font-size: 12px;
    padding: 4px 10px;
  }
  .logo-text {
    font-size: 17px;
  }
  .article-title {
    font-size: 24px;
    margin-bottom: 16px;
  }
  .hero-banner {
    padding: 20px;
  }
  .hero-banner img {
    max-height: 200px;
  }
  .author-card {
    flex-direction: column;
    text-align: center;
    gap: 16px;
  }
}

html, body {
  width: 100%;
  overflow-x: hidden;
}
img, svg, video, iframe, canvas {
  max-width: 100%;
  height: auto;
}
pre {
  overflow-x: auto;
  max-width: 100%;
}
