/* Python Wiki — Custom Theme Overrides
   Aesthetic: "The Archive" — editorial authority, warm Python branding
   ────────────────────────────────────────────────────────────────── */

/* ── Webfonts ───────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,600;12..96,800&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;1,8..60,400&display=swap');

/* ── Python Brand Colors ─────────────────────────────────── */
:root {
  --python-blue: #306998;
  --python-blue-dark: #1e4f72;
  --python-blue-darker: #0d2137;
  --python-blue-light: #4b8bbe;
  --python-blue-pale: #e8f0f8;
  --python-yellow: #ffd43b;
  --python-yellow-dark: #f0c020;
  --python-yellow-muted: #ffe873;
  --python-bg-warm: #fefcf5;

  --wiki-font-display: 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif;
  --wiki-font-body: 'Source Serif 4', Georgia, 'Times New Roman', serif;

  --wiki-hero-gradient: linear-gradient(160deg, #306998 0%, #1e4f72 40%, #0d2137 100%);
  --wiki-hero-accent: linear-gradient(135deg, #ffd43b 0%, #f0c020 100%);
  --wiki-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --wiki-card-shadow-hover: 0 20px 60px rgba(48, 105, 152, 0.15), 0 8px 20px rgba(0, 0, 0, 0.06);

  --wiki-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --wiki-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Reveal Animation ───────────────────────────────────── */
@keyframes wiki-reveal {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes wiki-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes wiki-scale-in {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes hero-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-8px) rotate(1deg); }
}

@keyframes grain-drift {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-2%, -2%); }
  30% { transform: translate(3%, 1%); }
  50% { transform: translate(-1%, 3%); }
  70% { transform: translate(2%, -1%); }
  90% { transform: translate(-3%, 2%); }
}

@keyframes stat-count-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

/* ── Landing Page Global ────────────────────────────────── */
body[data-page="index"] .yue {
  font-family: var(--wiki-font-body);
  overflow-x: hidden;
}


body[data-page="index"] .yue h2 {
  font-family: var(--wiki-font-display);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: 2rem;
  position: relative;
  display: inline-block;
  text-align: left;
  animation: wiki-reveal 0.8s var(--wiki-ease-out) both;
}

body[data-page="index"] .yue h2::after {
  content: '';
  position: absolute;
  bottom: -0.3rem;
  left: 0;
  width: 2.5rem;
  height: 3px;
  background: var(--wiki-hero-accent);
  border-radius: 2px;
}

/* ── Hero Backdrop — Snake Curves & Grain ───────────────── */
.hero-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 520px;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

body[data-page="index"] .yue section:first-of-type {
  position: relative;
  z-index: 1;
  text-align: center;
}

.hero-snake {
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  opacity: 0.07;
  animation: hero-float 20s ease-in-out infinite;
}

.hero-snake--left {
  background: radial-gradient(circle at 30% 30%, var(--python-yellow) 0%, transparent 70%);
  top: -200px;
  left: -200px;
  animation-delay: 0s;
}

.hero-snake--right {
  background: radial-gradient(circle at 70% 70%, var(--python-blue-light) 0%, transparent 70%);
  top: -100px;
  right: -200px;
  animation-delay: -10s;
}

.hero-grain {
  position: absolute;
  inset: 0;
  opacity: 0.3;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  background-size: 256px 256px;
  animation: grain-drift 8s steps(1) infinite;
}

/* ── Hero Title ─────────────────────────────────────────── */
body[data-page="index"] .yue h1:first-of-type {
  font-family: var(--wiki-font-display);
  font-size: clamp(2.8rem, 6vw, 4.5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.05;
  margin-bottom: 0.4rem;
  margin-top: 2rem;
  background: linear-gradient(
    135deg,
    var(--python-blue) 0%,
    var(--python-blue-dark) 40%,
    var(--python-yellow-dark) 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: wiki-reveal 0.7s var(--wiki-ease-out) 0.1s both;
}

/* ── Lead Paragraph ─────────────────────────────────────── */
body[data-page="index"] .yue .lead p {
  font-family: var(--wiki-font-body);
  font-size: 1.25rem;
  line-height: 1.7;
  color: var(--sy-c-text-weak);
  max-width: 38rem;
  margin: 0 auto 1.5rem;
  animation: wiki-reveal 0.7s var(--wiki-ease-out) 0.2s both;
}

/* ── Hero Buttons ───────────────────────────────────────── */
.hero-buttons {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 1.5rem 0 2rem;
  animation: wiki-reveal 0.7s var(--wiki-ease-out) 0.3s both;
}

.hero-buttons a {
  display: inline-flex;
  align-items: center;
  padding: 0.7rem 1.8rem;
  border-radius: 0.5rem;
  font-family: var(--wiki-font-display);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: all 0.25s ease;
}

/* Primary CTA */
.hero-buttons .btn-primary {
  background: var(--python-blue);
  color: #fff;
}

.hero-buttons .btn-primary:hover {
  background: var(--python-blue-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(48, 105, 152, 0.3);
  color: #fff;
}

/* Ghost buttons */
.hero-buttons .btn-ghost {
  background: transparent;
  color: var(--sy-c-text);
  border: 1.5px solid var(--sy-c-divider);
}

.hero-buttons .btn-ghost:hover {
  border-color: var(--python-blue);
  color: var(--python-blue);
}

/* ── Stats Bar ──────────────────────────────────────────── */
.wiki-stats {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.5rem 0 0.5rem;
  margin: 0 auto 1.5rem;
  max-width: 44rem;
}

.wiki-stats .stat {
  text-align: center;
  padding: 1rem 2rem;
  background: var(--sy-c-bg-weak);
  border-radius: 1rem;
  border: 1px solid var(--sy-c-divider);
  min-width: 140px;
  animation: stat-count-in 0.6s var(--wiki-ease-spring) both;
  animation-delay: calc(var(--delay, 0) * 0.12s + 0.5s);
  transition: all 0.3s var(--wiki-ease-out);
}

.wiki-stats .stat:hover {
  border-color: var(--python-blue-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(48, 105, 152, 0.08);
}

.wiki-stats .stat-number {
  display: block;
  font-family: var(--wiki-font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--python-blue);
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.wiki-stats .stat-label {
  font-family: var(--wiki-font-display);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--sy-c-text-weak);
  font-weight: 600;
  margin-top: 0.15rem;
}

/* ── Section Cards (Wiki Sections) ──────────────────────── */
body[data-page="index"] .section-cards {
  animation: wiki-reveal 0.8s var(--wiki-ease-out) 0.2s both;
}

body[data-page="index"] .section-card {
  border: 1px solid var(--sy-c-divider);
  border-radius: 1rem;
  transition: all 0.4s var(--wiki-ease-out);
  overflow: hidden;
  position: relative;
}

body[data-page="index"] .section-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--wiki-hero-accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.5s var(--wiki-ease-out);
}

body[data-page="index"] .section-card:hover::before {
  transform: scaleX(1);
}

body[data-page="index"] .section-card:hover {
  border-color: var(--python-blue-light);
  box-shadow: var(--wiki-card-shadow-hover);
  transform: translateY(-4px);
}

body[data-page="index"] .section-card .sd-card-header {
  border-bottom: none;
  padding: 1.4rem 1.5rem 0.6rem;
  font-family: var(--wiki-font-display);
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

body[data-page="index"] .section-card .sd-card-body {
  padding: 0.5rem 1.5rem 1rem;
  font-family: var(--wiki-font-body);
  line-height: 1.65;
}

body[data-page="index"] .section-card .sd-card-footer {
  padding: 0.8rem 1.5rem;
  background: var(--sy-c-bg-weak);
  font-family: var(--wiki-font-display);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: var(--sy-c-text-weak);
  border-top: 1px solid var(--sy-c-divider);
}

/* Individual section card accents */
body[data-page="index"] .section-card--python:hover {
  border-color: var(--python-blue-light);
}
body[data-page="index"] .section-card--python::before {
  background: linear-gradient(90deg, var(--python-blue), var(--python-yellow));
}

body[data-page="index"] .section-card--psf:hover {
  border-color: var(--python-yellow-dark);
}
body[data-page="index"] .section-card--psf::before {
  background: linear-gradient(90deg, var(--python-yellow), var(--python-blue));
}

body[data-page="index"] .section-card--jython:hover {
  border-color: #6b9bd2;
}
body[data-page="index"] .section-card--jython::before {
  background: linear-gradient(90deg, #6b9bd2, var(--python-blue));
}

/* ── Topic Cards (Popular Topics) ───────────────────────── */
body[data-page="index"] .topic-grid {
  animation: wiki-reveal 0.8s var(--wiki-ease-out) 0.3s both;
}

body[data-page="index"] .topic-card {
  border: 1px solid var(--sy-c-divider) !important;
  background: var(--sy-c-bg) !important;
  border-radius: 0.875rem !important;
  transition: all 0.35s var(--wiki-ease-out) !important;
  position: relative;
  overflow: hidden;
}

body[data-page="index"] .topic-card .sd-card-header {
  font-family: var(--wiki-font-display);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 1.1rem 1.2rem 0.2rem;
  border-bottom: none;
  color: var(--python-blue);
  letter-spacing: -0.01em;
}

body[data-page="index"] .topic-card .sd-card-body {
  font-family: var(--wiki-font-body);
  padding: 0.2rem 1.2rem 1rem;
  font-size: 0.9rem;
  color: var(--sy-c-text-weak);
  line-height: 1.55;
}

body[data-page="index"] .topic-card::after {
  content: '\2192';
  position: absolute;
  bottom: 0.9rem;
  right: 1rem;
  font-size: 1.1rem;
  color: var(--python-blue);
  opacity: 0;
  transform: translateX(-6px);
  transition: all 0.35s var(--wiki-ease-out);
}

body[data-page="index"] .topic-card:hover {
  border-color: var(--python-blue) !important;
  box-shadow: 0 12px 40px rgba(48, 105, 152, 0.12), 0 4px 12px rgba(0, 0, 0, 0.04) !important;
  transform: translateY(-3px) !important;
  background: var(--sy-c-bg) !important;
}

body[data-page="index"] .topic-card:hover::after {
  opacity: 1;
  transform: translateX(0);
}

body[data-page="index"] .topic-card:hover .sd-card-header {
  color: var(--python-blue-dark);
}

/* ── Archive Notice ─────────────────────────────────────── */
.archive-notice {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  background: linear-gradient(135deg, rgba(255, 212, 59, 0.06), rgba(48, 105, 152, 0.04));
  border: 1px solid rgba(48, 105, 152, 0.12);
  border-left: 3px solid var(--python-yellow);
  border-radius: 0.75rem;
  padding: 1.1rem 1.4rem;
  font-family: var(--wiki-font-body);
  font-size: 0.9rem;
  line-height: 1.65;
  margin: 1.5rem 0;
  animation: wiki-fade 0.6s ease 0.5s both;
}

.archive-notice-icon {
  flex-shrink: 0;
  color: var(--python-blue);
  margin-top: 0.1rem;
}

.archive-notice a {
  color: var(--python-blue);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: rgba(48, 105, 152, 0.3);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.2s ease;
}

.archive-notice a:hover {
  text-decoration-color: var(--python-blue);
}

/* ── Legacy Wiki Notice (on every imported page) ─────────── */
.admonition.note .admonition-title:has(+ p a[href="https://www.python.org"]),
.admonition.note:has(p a[href="https://www.python.org"]) {
  font-size: 0.88rem;
  border-left-color: var(--python-blue);
  background: linear-gradient(135deg, rgba(48, 105, 152, 0.04), rgba(255, 212, 59, 0.03));
}

/* ── Horizontal Rules — subtle dividers ──────────────────── */
body[data-page="index"] .yue hr {
  border: none;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--sy-c-divider) 20%,
    var(--sy-c-divider) 80%,
    transparent 100%
  );
  margin: 3rem 0;
}

/* ── Dark Mode ──────────────────────────────────────────── */
html[data-theme="dark"] {
  --python-blue: #5a9fd4;
  --python-blue-dark: #4b8bbe;
  --python-blue-light: #6bb0e0;
  --python-blue-pale: rgba(90, 159, 212, 0.1);
}

html[data-theme="dark"] body[data-page="index"] .yue h1:first-of-type {
  background: linear-gradient(
    135deg,
    #6bb0e0 0%,
    #5a9fd4 40%,
    var(--python-yellow) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
}

html[data-theme="dark"] .hero-buttons .btn-primary {
  background: #4b8bbe;
}

html[data-theme="dark"] .hero-buttons .btn-ghost {
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--sy-c-text);
}

html[data-theme="dark"] .wiki-stats .stat {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .wiki-stats .stat-number {
  color: var(--python-yellow);
}

html[data-theme="dark"] .hero-snake--left {
  opacity: 0.04;
}

html[data-theme="dark"] .hero-snake--right {
  opacity: 0.04;
}

html[data-theme="dark"] .archive-notice {
  background: linear-gradient(135deg, rgba(255, 212, 59, 0.04), rgba(48, 105, 152, 0.06));
  border-color: rgba(255, 255, 255, 0.06);
  border-left-color: var(--python-yellow-dark);
}

html[data-theme="dark"] body[data-page="index"] .topic-card .sd-card-header {
  color: var(--python-yellow);
}

html[data-theme="dark"] body[data-page="index"] .topic-card:hover .sd-card-header {
  color: var(--python-yellow-muted);
}

html[data-theme="dark"] body[data-page="index"] .topic-card::after {
  color: var(--python-yellow);
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  body[data-page="index"] .yue h1:first-of-type {
    margin-top: 1rem;
  }

  .wiki-stats {
    gap: 0.6rem;
  }

  .wiki-stats .stat {
    padding: 0.8rem 1.2rem;
    min-width: 100px;
  }

  .wiki-stats .stat-number {
    font-size: 1.5rem;
  }

  .hero-backdrop {
    height: 400px;
  }

  body[data-page="index"] .topic-card::after {
    display: none;
  }
}

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