/* ============================================================
   BerryRift — Shared base: design tokens, reset, header, drawer,
   search, footer, back-to-top, skeletons.
   Loaded first on every page, before the page-specific stylesheet.
   Display: Outfit · Body: Inter · Data: IBM Plex Mono
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Inter:wght@400;500;600&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
  /* Premium Dark Cinematic Palette */
  --ink:        #08070c;   /* Deep space background */
  --ink-2:      #0e0d16;   /* Sticky header / footer */
  --surface:    #151322;   /* Glassmorphic cards, containers */
  --surface-2:  #1d1a30;   /* Interactive hover surfaces */
  --line:       rgba(157, 78, 221, 0.15);   /* Cyber purple line */
  --line-strong:rgba(157, 78, 221, 0.28);

  --bone:       #f5f3f7;   /* Ice-white primary text */
  --ash:        #aba7bd;   /* Cool gray muted text */
  --ash-dim:    #736f8a;   /* Muted subtexts */

  --gold:       #fec84d;   /* Neon yellow-gold */
  --gold-bright:#ffe08a;
  --gold-soft:  rgba(254, 200, 77, 0.14);
  --neon-pink:  #ff007f;   /* Cyber pink */
  --neon-purple:#9d4edd;   /* Neon purple glow */
  --neon-blue:  #00f0ff;   /* Cyber blue */
  --ember:      #ff4a4a;   /* Danger / live indicator */

  /* Gradients */
  --gradient-accent: linear-gradient(135deg, var(--gold) 0%, var(--neon-pink) 100%);
  --gradient-neon: linear-gradient(135deg, var(--neon-blue) 0%, var(--neon-purple) 100%);
  --gradient-glow: linear-gradient(135deg, rgba(254, 200, 77, 0.15) 0%, rgba(255, 0, 127, 0.15) 100%);

  /* Legacy remapped properties for JavaScript compatibility */
  --primary:    var(--gold);
  --secondary:  var(--gold);
  --accent:     var(--neon-pink);
  --text-main:  var(--bone);
  --text-muted: var(--ash);

  /* Typography */
  --font-display: 'Outfit', system-ui, -apple-system, sans-serif;
  --font-sans:    'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:    'IBM Plex Mono', ui-monospace, monospace;

  --radius-sm: 4px;
  --radius:   6px;
  --radius-lg: 12px;
  --ease: cubic-bezier(0.25, 0.8, 0.25, 1);
  --maxw: 1320px;
}

/* ---------- Reset & base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--ink);
  color: var(--bone);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Lock background scroll while a mobile overlay (drawer / search) is open. */
body.no-scroll { overflow: hidden; }

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

::selection { background: var(--gold); color: var(--ink); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--ink); }
::-webkit-scrollbar-thumb { background: #2c2820; border-radius: 99px; border: 2px solid var(--ink); }
::-webkit-scrollbar-thumb:hover { background: #3a3528; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 2px;
}

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 2rem;
}

/* ---------- Header ---------- */
#main-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8, 7, 12, 0.82);
  backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--line);
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
  position: relative;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-display);
  font-size: 1.85rem;
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--bone);
  text-decoration: none;
  white-space: nowrap;
}
.logo-mark {
  font-size: 1.35rem;
  color: var(--gold);
  transform: translateY(1px);
}
.logo span {
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
}
.logo .logo-text { color: inherit; font-style: normal; }

/* Desktop Navigation */
.desktop-nav {
  display: flex;
  align-items: center;
  gap: 1.8rem;
}
.nav-link {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ash);
  text-decoration: none;
  transition: color 0.3s var(--ease);
  position: relative;
  padding: 0.35rem 0;
}
.nav-link:hover {
  color: var(--gold);
}
.nav-link.active {
  color: var(--gold);
}
.nav-link.active::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--gradient-accent);
  border-radius: 99px;
}

/* Hamburger & Search toggles (Mobile) */
.menu-toggle-btn,
.search-toggle-btn {
  background: none;
  border: none;
  color: var(--bone);
  font-size: 1.25rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
  z-index: 10;
}
.menu-toggle-btn:hover,
.search-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--gold);
}

.header-right-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ash);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}
.back-link:hover {
  color: var(--gold);
}

/* Search */
.search-box { position: relative; width: min(320px, 35vw); }

.search-box input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.55rem 1rem 0.55rem 2.5rem;
  color: var(--bone);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.search-box input::placeholder { color: var(--ash-dim); }
.search-box input:focus {
  border-color: var(--gold);
  background: var(--surface-2);
  box-shadow: 0 0 10px rgba(254, 200, 77, 0.15);
}
.search-icon {
  position: absolute;
  left: 0.95rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ash-dim);
  font-size: 0.85rem;
  pointer-events: none;
}

/* Leave room on the right for the clear (×) button */
.search-box input { padding-right: 2.4rem; }

/* Clear (×) button — only visible once the box holds text */
.search-clear-btn {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 50%;
  color: var(--ash-dim);
  font-size: 0.82rem;
  cursor: pointer;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
  z-index: 3;
}
.search-box.has-text .search-clear-btn { display: flex; }
.search-clear-btn:hover { color: var(--gold); background: rgba(255, 255, 255, 0.06); }

/* ---------- Instant search suggestions panel ---------- */
.search-suggest {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  width: 100%;
  max-height: 72vh;
  overflow-y: auto;
  padding: 0.35rem;
  background: var(--ink-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  z-index: 200;
  animation: slideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.search-suggest[hidden] { display: none; }

.search-suggest-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.45rem 0.55rem;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s var(--ease);
}
.search-suggest-item:hover,
.search-suggest-item.is-active { background: var(--surface-2); }

.search-suggest-thumb {
  flex: 0 0 auto;
  width: 34px;
  height: 48px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--surface);
  border: 1px solid var(--line);
}
.search-suggest-text {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.search-suggest-title {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--bone);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-suggest-meta {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ash-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* "See all N results →" footer row */
.search-suggest-all {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.25rem;
  padding: 0.55rem 0.7rem;
  border-top: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ash);
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.search-suggest-all:hover,
.search-suggest-all.is-active { background: var(--surface-2); color: var(--gold); }
.search-suggest-all i { font-size: 0.65rem; transition: transform 0.2s var(--ease); }
.search-suggest-all:hover i,
.search-suggest-all.is-active i { transform: translateX(3px); }

.search-suggest-empty,
.search-suggest-loading {
  padding: 1.4rem 1rem;
  text-align: center;
  color: var(--ash-dim);
  font-size: 0.82rem;
}
.search-suggest-loading i { margin-right: 0.4rem; }

/* Side Navigation Drawer Overlay */
.nav-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 7, 12, 0.65);
  backdrop-filter: blur(8px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--ease);
}
.nav-drawer-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Side Navigation Drawer Panel */
.nav-drawer {
  position: fixed;
  top: 0;
  left: -280px;
  width: 280px;
  height: 100vh;            /* fallback for browsers without dvh */
  height: 100dvh;          /* fit the visible viewport behind the mobile URL bar */
  background: rgba(21, 19, 34, 0.96);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-right: 1px solid var(--line);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
}
.nav-drawer.active {
  transform: translateX(280px);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid var(--line);
}
.drawer-close-btn {
  background: none;
  border: none;
  color: var(--bone);
  font-size: 1.25rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}
.drawer-close-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--neon-pink);
}

.drawer-nav {
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  gap: 0.5rem;
}
.drawer-link {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--ash);
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}
.drawer-link i {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  color: var(--ash-dim);
  transition: color 0.3s var(--ease);
}
.drawer-link:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--gold);
}
.drawer-link:hover i {
  color: var(--gold);
}
.drawer-link.active {
  background: var(--gold-soft);
  color: var(--gold);
  font-weight: 600;
}
.drawer-link.active i {
  color: var(--gold);
}

/* ---------- Footer ---------- */
#main-footer {
  background: var(--ink-2);
  border-top: 1px solid var(--line);
  padding: 3rem 0;
  margin-top: 3rem;
}
.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  text-align: center;
}
.footer-logo { font-size: 1.5rem; }
.footer-note { color: var(--ash); font-size: 0.9rem; }
.footer-copy { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.12em; color: var(--ash-dim); }

/* ---------- Back to top ---------- */
.back-to-top {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--bone);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease), background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}
.back-to-top.visible { opacity: 1; pointer-events: auto; }
.back-to-top:hover { background: var(--gold); color: var(--ink); border-color: var(--gold); transform: translateY(-3px); }

/* ---------- Skeleton base ---------- */
@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.6s infinite linear;
  border-radius: var(--radius);
}

/* ---------- Shared keyframes ---------- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 15px rgba(157, 78, 221, 0.15), 0 0 3px rgba(0, 240, 255, 0.05); }
  50%      { box-shadow: 0 0 25px rgba(157, 78, 221, 0.35), 0 0 10px rgba(0, 240, 255, 0.15); }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Cinematic Effects & Glowing Nebulae ---------- */
body::before {
  content: "";
  position: fixed;
  top: -10%;
  left: -10%;
  width: 45%;
  height: 55%;
  background: radial-gradient(circle, rgba(157, 78, 221, 0.09) 0%, transparent 70%);
  z-index: -1;
  pointer-events: none;
}
body::after {
  content: "";
  position: fixed;
  bottom: -10%;
  right: -10%;
  width: 45%;
  height: 55%;
  background: radial-gradient(circle, rgba(0, 240, 255, 0.07) 0%, transparent 70%);
  z-index: -1;
  pointer-events: none;
}

/* ---------- Responsive: shared header + search ---------- */
@media (max-width: 768px) {
  .container { padding: 0 1rem; }

  .menu-toggle-btn,
  .search-toggle-btn {
    display: flex;
  }
  .desktop-nav {
    display: none !important;
  }
  .back-link {
    display: none;
  }
  .logo {
    position: absolute;
    left: 50%;
    transform: translateX(-50%) !important;
    font-size: 1.4rem;
  }
  .logo-mark { font-size: 1.15rem; }

  /* Make search box act as a full-width overlay when active */
  .search-box {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    padding: 0.6rem 1.25rem;
    background: var(--ink-2);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    z-index: 99;
  }
  .search-box.active {
    display: block;
    animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
  }
  .search-box input {
    width: 100%;
    min-height: 44px;
    font-size: 16px; /* keep >=16px so iOS doesn't zoom on focus */
  }

  /* The mobile search overlay adds 1.25rem of side padding, so the absolutely
     positioned icon/clear button must be offset by that much to sit inside the
     actual input box instead of floating in the overlay's padding. */
  .search-box .search-icon { left: 2.2rem; }       /* 1.25rem overlay + 0.95rem */
  .search-box .search-clear-btn { right: 1.75rem; } /* 1.25rem overlay + 0.5rem */

  /* Suggestions panel sits flush under the full-width mobile search overlay */
  .search-box .search-suggest {
    top: calc(100% + 0.4rem);
    max-height: 60vh;
  }
}

@media (max-width: 480px) {
  .logo { font-size: 1.25rem; }
  .logo-mark { font-size: 1.05rem; }
  .back-to-top {
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    right: 1rem;
    width: 42px;
    height: 42px;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .lazy-image { opacity: 1; }
}
