:root {
  color-scheme: dark;
  --bg: #0b1224;
  --bg-alt: #10192d;
  --surface: #151f36;
  --surface-alt: #1c2740;
  --border: #263455;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #ec4899;
  --accent-soft: rgba(236, 72, 153, 0.2);
  --accent-2: #8b5cf6;
  --accent-3: #38bdf8;
  --radius-lg: 24px;
  --radius-md: 16px;
  --shadow: 0 24px 48px rgba(15, 23, 42, 0.35);
  font-size: 16px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

a {
  color: hotpink;
  font-weight: bold;
  text-decoration: underline;
}

a:visited {
  text-decoration: none;
}

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

.container {
  width: min(1120px, 92%);
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(11, 18, 36, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(38, 52, 85, 0.5);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
}

.nav-logo span {
  color: var(--muted);
  font-size: 0.95rem;
}

.nav-links {
  display: flex;
  gap: 24px;
  font-size: 0.95rem;
  color: var(--muted);
}

.nav-links a:hover,
.nav-links a:focus {
  color: var(--text);
}

.hero-section {
  margin-top: 48px;
}

.hero {
  margin: auto;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.18), rgba(14, 165, 233, 0.12));
  border: 1px solid rgba(38, 52, 85, 0.6);
  border-radius: var(--radius-lg);
  padding: 32px;
  display: grid;
  gap: 32px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  box-shadow: var(--shadow);
  align-items: center;
  justify-items: center;
}

.hero-card {
  background: rgba(15, 23, 42, 0.65);
  border-radius: 20px;
  padding: 24px;
  display: grid;
  gap: 16px;
  border: 1px solid rgba(38, 52, 85, 0.5);
  justify-self: center;
  max-width: 560px;
  width: 100%;
}

.hero-profile {
  display: flex;
  align-items: center;
  gap: 16px;
}

.hero-profile img {
  width: 64px;
  height: 64px;
}

.hero h1 {
  font-size: clamp(2rem, 3vw, 2.6rem);
  line-height: 1.2;
}

.hero p {
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.button {
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.button-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 24px rgba(236, 72, 153, 0.35);
}

.button-secondary {
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: var(--text);
}

.button:hover {
  transform: translateY(-2px);
}

.section-title {
  margin: 40px 0 16px;
  font-size: 1.3rem;
  font-weight: 600;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.rss-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.rss-link svg {
  width: 18px;
  height: 18px;
}

.highlights {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.highlight-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 18px;
  text-align: center;
  border: 1px solid rgba(38, 52, 85, 0.6);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.highlight-card img {
  margin: 0 auto 12px;
  width: 72px;
  height: 72px;
}

.highlight-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.35);
}

.main-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  margin-bottom: 64px;
}

.posts-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.post-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 20px;
  border: 1px solid rgba(38, 52, 85, 0.6);
  display: grid;
  gap: 12px;
}

.post-card .tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
}

.post-card h3 {
  font-size: 1.1rem;
}

.post-card p {
  color: var(--muted);
  font-size: 0.95rem;
}

.sidebar-card {
  background: var(--surface-alt);
  border-radius: 18px;
  padding: 20px;
  border: 1px solid rgba(38, 52, 85, 0.6);
  display: grid;
  gap: 16px;
}

.newsletter-input {
  background: #0b1224;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
}

.topic-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.topic {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  color: var(--muted);
  font-size: 0.8rem;
  border: 1px solid transparent;
  cursor: pointer;
}

.topic.is-active {
  background: rgba(236, 72, 153, 0.2);
  color: var(--text);
  border-color: rgba(236, 72, 153, 0.5);
}

.social-links {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.social-links a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.95rem;
  text-decoration: none;
}

.social-links svg {
  width: 20px;
  height: 20px;
  color: var(--text);
  flex: 0 0 20px;
}

.post-layout {
  margin: 40px auto;
  max-width: 1120px;
}

.post-layout h1 {
  font-size: clamp(2rem, 3vw, 2.8rem);
  margin-bottom: 12px;
}

.post-layout .post-meta {
  color: var(--muted);
  margin-bottom: 24px;
}

/* =========================================================
   POST LAYOUT: 250px sidenav + 800px content (left-justified)
========================================================= */
.post-shell {
  display: flex;
  gap: 24px;
  justify-content: flex-start;
  align-items: flex-start;
}

.post-sidenav {
  width: 250px;
  flex: 0 0 250px;
  position: sticky;
  top: 96px;
  padding: 14px 12px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(38, 52, 85, 0.6);
  max-height: none;
  overflow: visible;
}

.post-sidenav .sidenav-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 10px;
}

.post-sidenav nav a {
  display: block;
  padding: 6px 8px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
  line-height: 1.25;
  border: 1px solid transparent;
}

.post-sidenav nav a:hover,
.post-sidenav nav a:focus {
  color: var(--text);
  border-color: rgba(236, 72, 153, 0.45);
  background: rgba(236, 72, 153, 0.10);
  outline: none;
}

.post-sidenav nav a.is-active {
  color: var(--text);
  border-color: rgba(236, 72, 153, 0.65);
  background: rgba(236, 72, 153, 0.18);
}

/* TOC hierarchy: smaller white text for h3/h4 */
.post-sidenav nav a.level-h2 {
  font-size: 0.9rem;
  color: var(--text);
}

.post-sidenav nav a.level-h3 {
  font-size: 0.8rem;
  color: #ffffff;
  font-weight: 600;
  padding-left: 18px;
  opacity: 0.85;
}

.post-sidenav nav a.level-h4 {
  font-size: 0.75rem;
  color: #ffffff;
  font-weight: 500;
  padding-left: 30px;
  opacity: 0.85;
}

.post-main {
  width: 800px;
  flex: 0 0 800px;
  min-width: 0;
}

.post-content {
  display: grid;
  gap: 16px;
}

.post-content h2 {
  margin-top: 16px;
}

.post-content p {
  color: #d6e1f0;
}

/* =========================================================
   ANCHORED HEADINGS (h2–h4)
========================================================= */
.post-content h2,
.post-content h3,
.post-content h4 {
  position: relative;
  scroll-margin-top: 96px;
}

.post-content h2 > a.heading-anchor,
.post-content h3 > a.heading-anchor,
.post-content h4 > a.heading-anchor {
  color: inherit;
  text-decoration: none;
  font-weight: inherit;
}

.post-content h2 > a.heading-anchor:hover,
.post-content h3 > a.heading-anchor:hover,
.post-content h4 > a.heading-anchor:hover {
  text-decoration: underline;
  text-decoration-color: hotpink;
  text-decoration-thickness: 2px;
}

.post-content h2 > a.heading-anchor::before,
.post-content h3 > a.heading-anchor::before,
.post-content h4 > a.heading-anchor::before {
  content: "#";
  display: inline-block;
  margin-right: 10px;
  color: hotpink;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.post-content h2:hover > a.heading-anchor::before,
.post-content h3:hover > a.heading-anchor::before,
.post-content h4:hover > a.heading-anchor::before,
.post-content h2 > a.heading-anchor:focus-visible::before,
.post-content h3 > a.heading-anchor:focus-visible::before,
.post-content h4 > a.heading-anchor:focus-visible::before {
  opacity: 1;
  transform: translateX(0);
}

/* =========================================================
   FIGURES: boxed, max 80% width, caption on top (left-justified)
========================================================= */
.post-content figure {
  margin: 18px auto;
  max-width: 80%;
  border: 2px solid rgba(38, 52, 85, 0.9);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.45);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.post-content figure figcaption {
  order: -1;
  padding: 12px 14px;
  background: DarkSlateBlue;
  color: White;
  font-family: "Comic Sans MS", cursive;
  font-weight: 550;
  text-align: left;
  border-bottom: 2px solid rgba(38, 52, 85, 0.9);
}

.post-content figure img,
.post-content figure video,
.post-content figure iframe {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto;
  min-width: 500px;
  max-width: 100%;
  cursor: zoom-in;
}

@media (max-width: 560px) {
  .post-content figure img,
  .post-content figure video,
  .post-content figure iframe {
    min-width: 0;
  }
}

/* =========================================================
   BLOCKQUOTES
========================================================= */
.post-content blockquote {
  margin: 18px 0;
  padding: 16px 18px;
  border-radius: 18px;
  background-image: linear-gradient(to bottom, DarkSlateBlue, Purple);
  color: #fff;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.35);
}

.post-content blockquote p {
  color: inherit;
}

.post-content blockquote a {
  color: #fff;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.7);
}

.post-content blockquote > :first-child {
  margin-top: 0;
}

.post-content blockquote > :last-child {
  margin-bottom: 0;
}

/* =========================================================
   LISTS: indent 30px
========================================================= */
.post-content ul,
.post-content ol {
  padding-left: 30px;
}

/* =========================================================
   GALLERY MODAL (NO SCROLL, FULL IMAGE FIT)
========================================================= */
.gallery-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.72);
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.gallery-modal.is-open {
  display: flex;
}

.gallery-dialog {
  width: min(1100px, 96vw);
  height: min(92vh, 920px);
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(11, 18, 36, 0.85);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.gallery-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.55);
  position: relative;
  z-index: 2;
}

.gallery-title {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.gallery-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(148, 163, 184, 0.12);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  z-index: 3;
}

.gallery-btn:hover {
  transform: translateY(-1px);
}

.gallery-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow: hidden;
}

.gallery-stage img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  cursor: default;
}

.gallery-caption {
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.55);
  color: var(--text);
  font-weight: 700;
  position: relative;
  z-index: 2;
}

/* prev/next click zones */
.gallery-navzone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 22%;
  cursor: pointer;
  z-index: 1;
}

.gallery-navzone.prev {
  left: 0;
}

.gallery-navzone.next {
  right: 0;
}

.page-layout {
  max-width: 1120px;
  margin: 40px auto 80px;
  background: var(--surface);
  padding: 32px;
  border-radius: 20px;
  border: 1px solid rgba(38, 52, 85, 0.6);
}

.site-footer {
  padding: 32px 0 48px;
  border-top: 1px solid rgba(38, 52, 85, 0.6);
  color: var(--muted);
}

@media (max-width: 1000px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
  .nav-links {
    display: none;
  }

  .post-shell {
    flex-direction: column;
  }

  .post-sidenav {
    width: 100%;
    flex: 1 1 auto;
    position: relative;
    top: auto;
  }

  .post-main {
    width: 100%;
    flex: 1 1 auto;
  }
}
