/* Nostalgia Docs: Glassmorphism Theme Overrides (Dark-Only)
   Matching the actual Nostalgia Lab design system from Search/Play/Web.
   No emdashes. */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root,
[data-md-color-scheme="slate"] {
  /* Nostalgia Core Tokens (from app.css) */
  --bg-primary:      #07070d;
  --bg-secondary:    #0f0f1a;
  --bg-card:         rgba(18, 18, 30, 0.85);
  --bg-glass:        rgba(14, 14, 24, 0.75);
  --bg-hover:        rgba(99, 102, 241, 0.08);
  --bg-input:        rgba(24, 24, 40, 0.9);
  --bg-surface:      rgba(20, 20, 35, 0.6);

  --text-primary:     #e8e8f5;
  --text-secondary:   #8b8ba8;
  --text-muted:       #52526a;

  --accent:           #6366f1;
  --accent-hover:     #818cf8;
  --accent-glow:      rgba(99, 102, 241, 0.3);
  --accent-border:    rgba(99, 102, 241, 0.25);
  --accent-dim:       rgba(99, 102, 241, 0.12);

  --border:          rgba(255, 255, 255, 0.05);
  --border-glass:    rgba(255, 255, 255, 0.08);

  --radius-xs:       6px;
  --radius-sm:       10px;
  --radius:          14px;
  --radius-lg:       20px;

  --font-pixel: 'Press Start 2P', monospace;

  --shadow-sm:       0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow:          0 8px 32px rgba(0, 0, 0, 0.45);
  --shadow-lg:       0 16px 56px rgba(0, 0, 0, 0.65);
  --shadow-glow:     0 0 40px rgba(99, 102, 241, 0.15);

  /* MkDocs Material Variable Mappings */
  --md-default-bg-color:             var(--bg-primary);
  --md-default-bg-color--light:      var(--bg-secondary);
  --md-default-fg-color:             var(--text-primary);
  --md-default-fg-color--light:      var(--text-secondary);
  --md-default-fg-color--lighter:    var(--text-muted);

  --md-primary-fg-color:             #12121c;
  --md-primary-fg-color--dark:       #0a0a14;
  --md-primary-bg-color:             var(--text-primary);
  --md-primary-bg-color--light:      #12121c;

  --md-accent-fg-color:              var(--accent);
  --md-accent-fg-color--transparent: var(--bg-hover);

  --md-code-bg-color:                rgba(24, 24, 40, 0.6);
  --md-code-fg-color:                #c4b5fd;
  --md-code-hl-color:                var(--accent-dim);

  --md-typeset-a-color:              var(--accent);

  --md-shadow-z1:                    var(--shadow);
  --md-shadow-z2:                    var(--shadow-lg);
}

/* Gradient Text Utility */
.gradient-text {
  background: linear-gradient(135deg, #6366f1 0%, #a78bfa 50%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Background Glow (matching .bg-glow from app.css) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(ellipse 60% 50% at 20% 10%, rgba(99, 102, 241, 0.08) 0%, transparent 70%),
    radial-gradient(ellipse 40% 40% at 80% 80%, rgba(168, 85, 247, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse 30% 30% at 50% 50%, rgba(99, 102, 241, 0.04) 0%, transparent 60%);
  background-attachment: fixed;
}

/* Custom Scrollbars */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.2);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(99, 102, 241, 0.4); }

/* Header (matching .top-bar from TopBar.svelte) */
.md-header {
  background: rgba(18, 18, 28, 0.75) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
  box-shadow: none !important;
}

.md-header[data-md-state="shadow"] {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) !important;
}

/* Logo sizing */
.md-logo img {
  height: 26px;
  width: auto;
}

/* Site title: pixel font branding */
.md-header__topic:first-child .md-ellipsis {
  font-family: var(--font-pixel);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #e4e4ef;
}

/* Search input */
.md-search__form {
  background-color: rgba(255, 255, 255, 0.04) !important;
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
  border-radius: var(--radius-xs) !important;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.md-search__form:focus-within {
  border-color: rgba(99, 102, 241, 0.4) !important;
  box-shadow: 0 0 12px var(--accent-glow) !important;
}

.md-search__output {
  background: rgba(16, 16, 26, 0.98) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.7) !important;
}

/* Sidebar Navigation */
@media (min-width: 76.25em) {
  .md-sidebar__inner {
    background: rgba(16, 16, 26, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-top: 10px;
  }
}

/* Main Article Content Area */
.md-content {
  background: rgba(18, 18, 30, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 32px;
  margin-top: 10px;
  margin-left: 24px;
}

/* Code Blocks */
.highlight {
  background: rgba(255, 255, 255, 0.03) !important;
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
  border-radius: var(--radius-sm) !important;
}

code {
  border-radius: var(--radius-xs) !important;
}

.md-clipboard {
  color: var(--text-muted) !important;
}
.md-clipboard:hover {
  color: var(--accent-hover) !important;
}

/* Admonition Overrides */
.md-typeset .admonition,
.md-typeset details {
  border-left-width: 4px !important;
  border-radius: var(--radius-sm) !important;
  background: rgba(255, 255, 255, 0.02) !important;
  border-color: rgba(255, 255, 255, 0.06);
}

.md-typeset .admonition > .admonition-title,
.md-typeset details > summary {
  background-color: rgba(255, 255, 255, 0.03) !important;
}

/* Table Styling */
.md-typeset table:not([class]) {
  background: rgba(18, 18, 30, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.md-typeset table:not([class]) th {
  background: rgba(99, 102, 241, 0.08);
  color: var(--accent-hover);
  font-weight: 600;
  border-bottom: 1px solid var(--accent-border);
}

.md-typeset table:not([class]) td {
  border-bottom: 1px solid var(--border);
}

.md-typeset table:not([class]) tr:hover td {
  background: var(--bg-hover);
}

/* Footer */
.md-footer {
  background-color: rgba(18, 18, 28, 0.85) !important;
  border-top: 1px solid rgba(255, 255, 255, 0.06) !important;
}

/* Navigation Title Spacing */
.md-nav__title {
  padding-bottom: 12px !important;
  margin-bottom: 12px !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-weight: 700 !important;
  letter-spacing: 0.02em;
}

/* Navigation Links */
.md-nav__link {
  color: #8b8ba0 !important;
  transition: color 0.2s ease, background-color 0.2s ease, border-left-color 0.2s ease, padding-left 0.2s ease, padding-top 0.2s ease, padding-bottom 0.2s ease;
  border-left: 2px solid transparent !important;
  padding-top: 6px !important;
  padding-bottom: 6px !important;
  margin-top: 2px !important;
  margin-bottom: 2px !important;
}

.md-nav__link:hover {
  color: var(--accent-hover) !important;
  background: rgba(255, 255, 255, 0.02) !important;
  border-left-color: rgba(99, 102, 241, 0.3) !important;
  padding-left: 10px !important;
}

.md-nav__link--active {
  color: var(--accent) !important;
  font-weight: 600;
  background: rgba(99, 102, 241, 0.05) !important;
  border-left-color: var(--accent) !important;
  padding-left: 12px !important;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

/* Smooth Page Transitions */
.md-content__inner {
  animation: fadeSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Back-to-Top Button */
.md-top {
  background-color: var(--accent) !important;
  color: #fff !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: 0 2px 16px var(--accent-glow) !important;
}

.md-top:hover {
  background-color: var(--accent-hover) !important;
}

/* ═══════════════════════════════════════════════════════════════
   NLS TopBar -- ported from TopBar.svelte
   All class names prefixed nls- to avoid collisions with Material
   ═══════════════════════════════════════════════════════════════ */

/* Override Material header height to 52px (matches Svelte top-bar) */
.md-header {
  height: 52px !important;
}
.md-header__inner {
  height: 52px !important;
  padding: 0 20px !important;
  max-width: 100% !important;
  display: grid !important;
  grid-template-columns: auto 1fr auto !important;
  align-items: center !important;
  gap: 12px !important;
}

/* Hide the default Material title block (we render brand ourselves) */
.nls-title-hidden {
  display: none !important;
}

/* Hide hamburger on desktop -- Material already does this but ensure grid integrity */
.md-header__inner > .md-header__button[for="__drawer"] {
  display: none;
}
@media (max-width: 76.1875em) {
  .md-header__inner {
    grid-template-columns: auto auto 1fr auto !important;
  }
  .md-header__inner > .md-header__button[for="__drawer"] {
    display: inline-flex;
  }
}

/* ── Brand ── */
.nls-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  text-decoration: none;
  justify-self: start;
}
.nls-brand-logo {
  height: 26px;
  width: auto;
  display: block;
  flex-shrink: 0;
  user-select: none;
}
.nls-brand-text {
  font-size: 15px;
  font-weight: 600;
  color: #e4e4ef;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* ── Search wrapper -- centered in the header grid on desktop ── */
@media (min-width: 60em) {
  .md-header__search.nls-search-wrap {
    display: flex !important;
    justify-self: center;
    width: 100% !important;
    max-width: 480px !important;
    align-items: center !important;
    flex-grow: 0 !important;
    margin: 0 !important;
  }
  .md-header__search.nls-search-wrap .md-search {
    width: 100% !important;
    padding: 0 !important;
  }
  .md-header__search.nls-search-wrap .md-search__inner {
    float: none !important;
    width: 100% !important;
    max-width: 480px !important;
    margin: 0 auto !important;
  }
  .md-header__search.nls-search-wrap .md-search__form {
    width: 100% !important;
  }
  
  /* Hide mobile search trigger button on desktop */
  .md-header__inner > .md-header__button[for="__search"] {
    display: none !important;
  }
}

/* ── Mobile search mode override ── */
@media (max-width: 59.9375em) {
  /* Hide search wrap by default on mobile/tablet to keep grid clean */
  .md-header__search.nls-search-wrap {
    display: none !important;
  }
  
  /* When search is active, let it display content so the native overlay renders */
  [data-md-toggle="search"]:checked ~ .md-header .md-header__search.nls-search-wrap {
    display: contents !important;
  }
  
  /* Show and position mobile search trigger button on mobile */
  .md-header__inner > .md-header__button[for="__search"] {
    display: inline-flex !important;
    justify-self: end;
  }
}

/* Make search input text, background, and placeholder extremely high-contrast white */
.md-search__input {
  color: #ffffff !important;
  background-color: transparent !important;
}
.md-search__input::placeholder {
  color: rgba(255, 255, 255, 0.75) !important;
}

/* Align search icons inside the glassmorphism input container */
.md-search__form .md-search__icon {
  color: rgba(255, 255, 255, 0.75) !important;
  transition: color 0.15s ease;
}
.md-search__form:focus-within .md-search__icon {
  color: var(--accent) !important;
}
.md-search__icon[type="reset"] {
  color: rgba(255, 255, 255, 0.75) !important;
}
.md-search__icon[type="reset"]:hover {
  color: #ff6b6b !important;
}

/* ── Right button cluster ── */
.nls-bar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  justify-self: end;
}

/* ── Base icon button (matches .hdr-btn from TopBar.svelte exactly) ── */
.nls-hdr-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  color: #8b8ba0;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  flex-shrink: 0;
  line-height: 1;
}
.nls-hdr-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: block;
}

/* ── Per-button hover colors (exact from TopBar.svelte) ── */
.nls-hdr-btn-home:hover {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.08);
}
.nls-hdr-btn-play:hover {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.35);
  background: rgba(34, 197, 94, 0.08);
}
.nls-hdr-btn-search-link:hover {
  color: #a78bfa;
  border-color: rgba(167, 139, 250, 0.35);
  background: rgba(167, 139, 250, 0.08);
}
.nls-hdr-btn-api:hover {
  color: #22d3ee;
  border-color: rgba(34, 211, 238, 0.35);
  background: rgba(34, 211, 238, 0.08);
}
.nls-hdr-btn-key:hover {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
}
.nls-hdr-btn-docs:hover {
  color: #818cf8;
  border-color: rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.08);
}
/* Active state for Docs (current site) */
.nls-hdr-btn--active {
  color: #818cf8 !important;
  border-color: rgba(99, 102, 241, 0.35) !important;
  background: rgba(99, 102, 241, 0.08) !important;
}
.nls-hdr-btn-community:hover {
  color: #818cf8;
  border-color: rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.1);
}
.nls-hdr-btn-donate:hover {
  color: #ff6b6b;
  border-color: rgba(255, 94, 91, 0.35);
  background: rgba(255, 94, 91, 0.08);
}

/* ── CSS Tooltips (exact from TopBar.svelte) ── */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background: rgba(10, 14, 28, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(210, 215, 240, 0.95);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  padding: 4px 9px;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 9999;
}
[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Modal overlay (Community + Support) ── */
.nls-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 14, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: nlsOverlayIn 0.25s ease;
}
.nls-modal-overlay[hidden] {
  display: none;
}
@keyframes nlsOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Modal card ── */
.nls-modal-card {
  position: relative;
  background: #13131f;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 2.5rem 2rem 2rem;
  max-width: 420px;
  width: calc(100% - 32px);
  text-align: center;
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(99, 102, 241, 0.08);
  animation: nlsCardIn 0.35s cubic-bezier(0.34, 1.3, 0.64, 1);
}
@keyframes nlsCardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* ── Modal close button ── */
.nls-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #5a5a72;
  cursor: pointer;
  transition: all 0.15s ease;
}
.nls-modal-close:hover {
  color: #e4e4ef;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

/* ── Modal icon ── */
.nls-modal-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  color: #818cf8;
  margin: 0 auto 1rem;
}
.nls-modal-icon--donate {
  background: rgba(255, 94, 91, 0.1);
  border-color: rgba(255, 94, 91, 0.2);
  color: #ff6b6b;
}

/* ── Modal text ── */
.nls-modal-title {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #e8e8f5;
  margin: 0 0 0.75rem;
  border: none;
}
.nls-modal-desc {
  font-size: 0.875rem;
  color: #6b7280;
  line-height: 1.65;
  margin: 0 0 1.75rem;
}
.nls-modal-thanks {
  font-size: 0.8rem;
  color: #4a4a60;
  margin: 0;
}

/* ── Tile grid ── */
.nls-modal-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 1.5rem;
}
.nls-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 1.5rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.nls-tile:hover {
  transform: translateY(-3px);
}
.nls-tile-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: inherit;
}
.nls-tile-sub {
  font-size: 0.75rem;
  opacity: 0.7;
}

/* Per-tile colors */
.nls-tile--discord { background: rgba(88, 101, 242, 0.07); color: #7289da; }
.nls-tile--discord:hover {
  background: rgba(88, 101, 242, 0.14);
  border-color: rgba(88, 101, 242, 0.35);
  box-shadow: 0 8px 30px rgba(88, 101, 242, 0.18);
}
.nls-tile--reddit { background: rgba(255, 69, 0, 0.07); color: #ff6314; }
.nls-tile--reddit:hover {
  background: rgba(255, 69, 0, 0.14);
  border-color: rgba(255, 69, 0, 0.35);
  box-shadow: 0 8px 30px rgba(255, 69, 0, 0.18);
}
.nls-tile--kofi { background: rgba(255, 94, 77, 0.07); color: #ff6b55; }
.nls-tile--kofi:hover {
  background: rgba(255, 94, 77, 0.13);
  border-color: rgba(255, 94, 77, 0.35);
  box-shadow: 0 8px 30px rgba(255, 94, 77, 0.18);
}
.nls-tile--patreon { background: rgba(255, 102, 0, 0.07); color: #ff7733; }
.nls-tile--patreon:hover {
  background: rgba(255, 102, 0, 0.13);
  border-color: rgba(255, 102, 0, 0.35);
  box-shadow: 0 8px 30px rgba(255, 102, 0, 0.18);
}

/* ── Mobile breakpoints (exact from TopBar.svelte) ── */
@media (max-width: 640px) {
  .md-header__inner {
    padding: 0 12px !important;
    gap: 8px !important;
  }
  .md-header__search.nls-search-wrap {
    max-width: none !important;
  }
  .nls-brand-text {
    display: none;
  }
  .nls-hdr-btn {
    padding: 5px 8px;
  }
  .nls-hdr-btn svg {
    width: 15px;
    height: 15px;
  }
  .nls-bar-right {
    gap: 4px;
  }
  /* Hide lower-priority buttons on narrow screens to prevent header overflow and clipping */
  .nls-hdr-btn-docs,
  .nls-hdr-btn-community,
  .nls-hdr-btn-donate,
  .nls-hdr-btn-search-link,
  .nls-hdr-btn-api,
  .nls-hdr-btn-key {
    display: none !important;
  }
  /* Disable tooltips on touch */
  [data-tooltip]::after {
    display: none;
  }
}
