/* =========================================================================
   grapeape.cloud — Ghost theme stylesheet
   Palette sourced verbatim from logo/README.md
   ========================================================================= */

:root {
  /* Brand palette (exact hex from logo README) */
  --violet-light: #7C3AED;
  --violet-mid: #6B46C1;
  --violet-deep: #5B21B6;
  --line-violet: #9B7FD4;
  --line-violet-dark: #B9A3E8;
  --node-violet: #8B5CF6;
  --gold: #F5A623;
  --charcoal-ink: #17151F;
  --charcoal-deep: #14121A;
  --charcoal-page: #1A1A2E;
  --text-light: #F4F1FA;

  /* Derived surface tones */
  --bg-0: var(--charcoal-deep);
  --bg-1: var(--charcoal-page);
  --bg-2: #201d33;
  --bg-card: #211e35;
  --border-subtle: rgba(155, 127, 212, 0.18);
  --border-hover: rgba(155, 127, 212, 0.4);
  --text-primary: var(--text-light);
  --text-secondary: #c8c2dc;
  --text-muted: #8d87a6;

  --font-display: "Jost", "Segoe UI", sans-serif;
  --font-body: "Jost", "Segoe UI", sans-serif;
  --font-mono: "Space Mono", monospace;

  --radius-m: 10px;
  --radius-l: 18px;
  --shadow-card: 0 8px 24px rgba(10, 8, 20, 0.45);
  --shadow-card-hover: 0 18px 40px rgba(91, 33, 182, 0.35);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------------------------------------------------------------------
   Reset & base
   --------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg-0);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 28px;
}

a { color: var(--line-violet-dark); text-decoration: none; }
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin: 0 0 0.5em;
}

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

/* ---------------------------------------------------------------------
   Animated node-graph background (subtle, fixed behind everything)
   --------------------------------------------------------------------- */
.bg-nodes {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 60% at 20% -10%, rgba(107, 70, 193, 0.28), transparent 60%),
    radial-gradient(ellipse 70% 50% at 100% 10%, rgba(124, 58, 237, 0.18), transparent 55%),
    radial-gradient(ellipse 80% 60% at 50% 120%, rgba(91, 33, 182, 0.22), transparent 60%),
    var(--bg-0);
  background-size: 200% 200%, 200% 200%, 200% 200%, auto;
  animation: bg-drift 32s ease-in-out infinite alternate;
}

@keyframes bg-drift {
  0%   { background-position: 0% 0%, 100% 0%, 50% 100%, 0 0; }
  100% { background-position: 20% 15%, 80% 20%, 55% 85%, 0 0; }
}

.bg-nodes-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.35;
}

.node-edges line {
  stroke: var(--line-violet-dark);
  stroke-width: 1;
  opacity: 0.35;
}

.node-dots circle {
  fill: var(--node-violet);
  opacity: 0.7;
  animation: node-pulse 6s ease-in-out infinite;
}

.node-dots circle.node-gold {
  fill: var(--gold);
  opacity: 0.9;
  animation: node-pulse-gold 4s ease-in-out infinite;
}

.node-dots circle:nth-child(odd) { animation-delay: 0.6s; }
.node-dots circle:nth-child(3n) { animation-delay: 1.4s; }
.node-dots circle:nth-child(4n) { animation-delay: 2.1s; }

@keyframes node-pulse {
  0%, 100% { opacity: 0.45; r: 4; }
  50% { opacity: 0.9; r: 5.5; }
}

@keyframes node-pulse-gold {
  0%, 100% { opacity: 0.6; r: 4; }
  50% { opacity: 1; r: 6.5; }
}

@media (prefers-reduced-motion: reduce) {
  .bg-nodes, .node-dots circle { animation: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------------------------------------------------------------------
   Header / nav
   --------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(20, 18, 26, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  padding-top: 16px;
  padding-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--text-primary);
  flex-shrink: 0;
}

.brand-icon {
  width: 32px;
  height: 32px;
  transition: transform 0.5s var(--ease-out), filter 0.5s var(--ease-out);
}

.brand:hover .brand-icon {
  transform: rotate(8deg) scale(1.08);
  filter: drop-shadow(0 0 10px rgba(139, 92, 246, 0.6));
}

.brand-name { letter-spacing: -0.02em; }

.site-nav {
  display: flex;
  gap: 24px;
  margin-left: auto;
  flex-wrap: wrap;
}

.site-nav a {
  position: relative;
  color: var(--text-secondary);
  font-size: 0.95rem;
  padding: 4px 0;
  transition: color 0.25s ease;
}

.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--gold), var(--violet-light));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s var(--ease-out);
}

.site-nav a:hover { color: var(--text-primary); }
.site-nav a:hover::after { transform: scaleX(1); }

.member-actions { display: flex; align-items: center; gap: 14px; }

.nav-signin, .nav-account {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.btn-subscribe {
  background: var(--violet-mid);
  color: var(--text-light);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.25s ease, transform 0.25s var(--ease-out);
}

.btn-subscribe:hover {
  background: var(--violet-light);
  transform: translateY(-1px);
}

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.3s var(--ease-out);
}

.btn-primary {
  background: linear-gradient(135deg, var(--violet-mid), var(--violet-light));
  color: var(--text-light);
  box-shadow: 0 6px 20px rgba(107, 70, 193, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(124, 58, 237, 0.5);
}

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

.btn-ghost:hover {
  background: rgba(155, 127, 212, 0.1);
  border-color: var(--line-violet-dark);
  transform: translateY(-2px);
}

/* ---------------------------------------------------------------------
   Hero
   --------------------------------------------------------------------- */
.hero {
  padding: 96px 0 64px;
  max-width: 780px;
}

.hero-kicker {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  color: var(--gold);
  margin-bottom: 18px;
}

.hero-title {
  font-size: clamp(2.4rem, 5vw, 3.4rem);
  line-height: 1.08;
  background: linear-gradient(135deg, var(--text-light) 30%, var(--line-violet-dark));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 24px;
}

.hero-description {
  color: var(--text-secondary);
  font-size: 1.08rem;
  margin-bottom: 20px;
}

.hero-actions {
  display: flex;
  gap: 16px;
  margin-top: 32px;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------------
   Section heading
   --------------------------------------------------------------------- */
.section-heading {
  margin-bottom: 36px;
}

.section-heading h2 {
  font-size: 1.8rem;
}

.section-sub {
  color: var(--text-muted);
  font-size: 0.98rem;
}

.projects, .changelog-preview { padding: 56px 0; }

/* ---------------------------------------------------------------------
   Project grid
   --------------------------------------------------------------------- */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 22px;
}

.project-card {
  position: relative;
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-l);
  padding: 26px 24px 22px;
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out), border-color 0.35s var(--ease-out);
}

.project-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--border-hover);
}

.project-node {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--violet-light);
  margin-bottom: 14px;
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.15);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.project-card:hover .project-node {
  background: var(--gold);
  box-shadow: 0 0 0 6px rgba(245, 166, 35, 0.18);
}

.project-name {
  font-size: 1.15rem;
  margin-bottom: 10px;
}

.project-desc {
  color: var(--text-secondary);
  font-size: 0.94rem;
  margin-bottom: 16px;
}

.project-link {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--line-violet-dark);
}

/* ---------------------------------------------------------------------
   Post feed / cards (shared: index changelog preview + tag/author pages)
   --------------------------------------------------------------------- */
.post-feed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-l);
  overflow: hidden;
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out), border-color 0.35s var(--ease-out);
}

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

.post-card-link { display: block; color: inherit; }

.post-card-image {
  width: 100%;
  height: 170px;
  object-fit: cover;
  transition: transform 0.6s var(--ease-out);
}

.post-card:hover .post-card-image { transform: scale(1.04); }

.post-card-body { padding: 22px 22px 24px; }

.post-card-title {
  font-size: 1.15rem;
  margin-bottom: 10px;
  transition: color 0.25s ease;
}

.post-card:hover .post-card-title { color: var(--line-violet-dark); }

.post-card-excerpt {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-bottom: 14px;
}

.post-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-muted);
}

.meta-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
}

.changelog-more { margin-top: 40px; text-align: center; }
.changelog-more a, .changelog-more .pagination { color: var(--line-violet-dark); }

/* ---------------------------------------------------------------------
   Full post / page
   --------------------------------------------------------------------- */
.post-full { max-width: 760px; margin: 0 auto; padding: 64px 0 96px; }

.post-full-kicker {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  color: var(--gold);
  margin-bottom: 14px;
}

.post-full-title {
  font-size: clamp(2rem, 4vw, 2.6rem);
  margin-bottom: 18px;
}

.post-full-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 36px;
}

.post-tag {
  color: var(--line-violet-dark);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 2px 10px;
}

.post-full-image {
  margin: 0 0 36px;
  border-radius: var(--radius-l);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.post-full-content {
  color: var(--text-secondary);
  font-size: 1.06rem;
}

.gh-content h2, .gh-content h3 { color: var(--text-primary); margin-top: 1.6em; }
.gh-content p { margin: 0 0 1.2em; }
.gh-content a { color: var(--line-violet-dark); text-decoration: underline; text-underline-offset: 3px; }
.gh-content a:hover { color: var(--gold); }
.gh-content code {
  background: var(--bg-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.9em;
}
.gh-content pre {
  background: var(--charcoal-ink);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-m);
  padding: 18px;
  overflow-x: auto;
}
.gh-content blockquote {
  border-left: 3px solid var(--violet-light);
  margin: 1.5em 0;
  padding: 0.2em 1.2em;
  color: var(--text-primary);
  font-style: italic;
}
.gh-content ul, .gh-content ol { padding-left: 1.4em; }
.gh-content hr { border: none; border-top: 1px solid var(--border-subtle); margin: 2.5em 0; }

/* Koenig editor card support (gallery / bookmark cards) */
.gh-content .kg-width-wide { position: relative; margin: 2em 0; }
.gh-content .kg-width-full {
  position: relative;
  width: 100vw;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
}

.gh-content .kg-gallery-container { display: flex; flex-direction: column; margin: 2em 0; }
.gh-content .kg-gallery-row { display: flex; flex-direction: row; justify-content: center; }
.gh-content .kg-gallery-image {
  position: relative;
  margin: 0 4px 8px;
  border-radius: var(--radius-m);
  overflow: hidden;
}
.gh-content .kg-gallery-image img { display: block; width: 100%; height: 100%; }

.gh-content .kg-bookmark-card { width: 100%; margin: 1.5em 0; }
.gh-content .kg-bookmark-container {
  display: flex;
  min-height: 148px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-m);
  overflow: hidden;
  transition: transform 0.3s var(--ease-out), border-color 0.3s var(--ease-out);
}
.gh-content .kg-bookmark-container:hover {
  transform: translateY(-3px);
  border-color: var(--border-hover);
}
.gh-content .kg-bookmark-content { display: flex; flex-direction: column; flex: 1 1 auto; padding: 20px; order: 1; }
.gh-content .kg-bookmark-title { font-family: var(--font-display); font-weight: 600; color: var(--text-primary); }
.gh-content .kg-bookmark-description {
  color: var(--text-secondary);
  font-size: 0.9em;
  margin-top: 6px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.gh-content .kg-bookmark-metadata {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 0.82em;
  color: var(--text-muted);
}
.gh-content .kg-bookmark-icon { width: 18px; height: 18px; }
.gh-content .kg-bookmark-author, .gh-content .kg-bookmark-publisher { color: var(--text-muted); }
.gh-content .kg-bookmark-thumbnail {
  flex: 1 1 auto;
  max-width: 220px;
  order: 2;
}
.gh-content .kg-bookmark-thumbnail img { width: 100%; height: 100%; object-fit: cover; }

.post-full-footer { margin-top: 48px; }

/* ---------------------------------------------------------------------
   Footer
   --------------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 48px 0 56px;
  margin-top: 40px;
  text-align: center;
}

.footer-inner { display: flex; flex-direction: column; align-items: center; gap: 10px; }

.footer-badge {
  width: 220px;
  max-width: 60vw;
  margin-bottom: 6px;
  transition: filter 0.4s ease;
}

.footer-badge:hover { filter: drop-shadow(0 0 12px rgba(139, 92, 246, 0.45)); }

.footer-tagline { color: var(--text-secondary); font-size: 0.92rem; margin: 0; }
.footer-copy { color: var(--text-muted); font-size: 0.82rem; margin: 0; }

/* ---------------------------------------------------------------------
   Scroll-reveal (progressive enhancement — JS adds .is-visible;
   content is visible by default with no-js so nothing is ever hidden)
   --------------------------------------------------------------------- */
.reveal {
  opacity: 1;
  transform: none;
}

.js-reveal-ready .reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}

.js-reveal-ready .reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.project-grid .reveal:nth-child(2) { transition-delay: 0.06s; }
.project-grid .reveal:nth-child(3) { transition-delay: 0.12s; }
.project-grid .reveal:nth-child(4) { transition-delay: 0.18s; }
.project-grid .reveal:nth-child(5) { transition-delay: 0.24s; }

.post-feed .reveal:nth-child(2) { transition-delay: 0.06s; }
.post-feed .reveal:nth-child(3) { transition-delay: 0.12s; }
.post-feed .reveal:nth-child(4) { transition-delay: 0.18s; }

@media (prefers-reduced-motion: reduce) {
  .js-reveal-ready .reveal,
  .js-reveal-ready .reveal.is-visible {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */
@media (max-width: 760px) {
  .header-inner { flex-wrap: wrap; }
  .site-nav { gap: 16px; order: 3; width: 100%; }
  .hero { padding: 56px 0 40px; }
  .post-full { padding: 40px 0 64px; }
}
