/* ================================================
   DIWA — Dimension Walkers
   Dark Paranormal Investigation Design System
   ================================================ */

/* --- CSS Custom Properties --- */
:root {
  /* Backgrounds */
  --bg-midnight: #07090F;
  --bg-deep-blue: #0F1624;
  --bg-panel: #1B2436;
  --border-panel: #2C3A55;

  /* Paranormal Energy */
  --portal-blue: #3FA9FF;
  --spectral-cyan: #4CEBFF;
  --dimensional-violet: #7A5CFF;
  --lightning-glow: #9CEBFF;

  /* Sensor */
  --sensor-green: #42FF8F;
  --alert-red: #FF3B3B;
  --signal-amber: #FFC857;

  /* Typography */
  --font-title: "Cinzel", serif;
  --font-body: "Inter", "Roboto", sans-serif;

  /* Spacing */
  --header-height: 70px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg-midnight);
  color: #d0d8e8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: rgba(63, 169, 255, 0.3);
  color: #fff;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-deep-blue);
}
::-webkit-scrollbar-thumb {
  background: var(--border-panel);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--portal-blue);
}

/* ================================================
   HEADER
   ================================================ */
#site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(15, 22, 36, 0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-panel);
  height: var(--header-height);
}

.header-inner {
  width: 100%;
  padding: 0 2rem;
  height: 100%;
  display: flex;
  align-items: center;
}

.header-right {
  display: flex;
  align-items: center;
  margin-left: auto;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
}

.logo-glyph {
  font-size: 1.8rem;
  color: var(--portal-blue);
  text-shadow: 0 0 15px rgba(63, 169, 255, 0.6);
  animation: pulse-glow 3s ease-in-out infinite;
}

.logo-title {
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.15em;
  display: block;
  line-height: 1.1;
}

.logo-subtitle {
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--portal-blue);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  display: block;
}

/* Navigation */
#main-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

#main-nav a {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  color: #8899b3;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  transition: all 0.25s ease;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  position: relative;
}

#main-nav a:hover {
  color: var(--spectral-cyan);
  background: rgba(63, 169, 255, 0.08);
}

#main-nav a.active {
  color: var(--portal-blue);
  background: rgba(63, 169, 255, 0.12);
}

#main-nav a.active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 2px;
  background: var(--portal-blue);
  box-shadow: 0 0 8px rgba(63, 169, 255, 0.5);
  border-radius: 1px;
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: #8899b3;
  border-radius: 2px;
  transition: all 0.3s ease;
}

/* Social Links */
#social-links {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: 0.5rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--border-panel);
}

#social-links:empty {
  display: none;
}

.social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  color: #5a6a80;
  transition: all 0.25s ease;
  text-decoration: none;
}

.social-link:hover {
  color: var(--spectral-cyan);
  background: rgba(76, 235, 255, 0.08);
  box-shadow: 0 0 12px rgba(76, 235, 255, 0.2);
}

.social-link svg {
  display: block;
}

.social-link .material-symbols-outlined {
  font-size: 18px;
}

/* ================================================
   MAIN CONTENT
   ================================================ */
main {
  flex: 1 0 auto;
  min-height: calc(100vh - var(--header-height) - 80px);
  margin-top: var(--header-height);
  padding: 3rem 2rem;
  max-width: 1100px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* Loading */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 6rem 0;
  color: #5a6a80;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-panel);
  border-top-color: var(--portal-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ================================================
   MARKDOWN CONTENT RENDERING
   ================================================ */
.page-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-panel);
}

.page-header h1 {
  font-family: var(--font-title);
  font-size: 2.2rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.page-header .page-description {
  color: #6a7b94;
  font-size: 1rem;
}

.md-content h1 {
  font-family: var(--font-title);
  font-size: 2rem;
  color: #fff;
  margin: 2.5rem 0 1rem;
  letter-spacing: 0.03em;
}

.md-content h2 {
  font-family: var(--font-title);
  font-size: 1.5rem;
  color: var(--lightning-glow);
  margin: 2rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgba(44, 58, 85, 0.5);
}

.md-content h3 {
  font-family: var(--font-title);
  font-size: 1.2rem;
  color: var(--spectral-cyan);
  margin: 1.5rem 0 0.5rem;
}

.md-content h4, .md-content h5, .md-content h6 {
  font-family: var(--font-title);
  color: var(--portal-blue);
  margin: 1.25rem 0 0.5rem;
}

.md-content p {
  margin-bottom: 1rem;
  color: #c0c8d8;
}

.md-content a {
  color: var(--portal-blue);
  text-decoration: none;
  border-bottom: 1px solid rgba(63, 169, 255, 0.3);
  transition: all 0.2s ease;
}

.md-content a:hover {
  color: var(--spectral-cyan);
  border-bottom-color: var(--spectral-cyan);
  text-shadow: 0 0 8px rgba(76, 235, 255, 0.3);
}

.md-content strong {
  color: #e8ecf4;
  font-weight: 600;
}

.md-content em {
  color: var(--signal-amber);
  font-style: italic;
}

.md-content ul, .md-content ol {
  margin: 0.75rem 0 1.25rem 1.5rem;
}

.md-content li {
  margin-bottom: 0.4rem;
  color: #b8c0d0;
}

.md-content li::marker {
  color: var(--portal-blue);
}

.md-content blockquote {
  border-left: 3px solid var(--dimensional-violet);
  background: rgba(122, 92, 255, 0.06);
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  border-radius: 0 8px 8px 0;
  color: #a8b0c8;
}

.md-content blockquote p:last-child {
  margin-bottom: 0;
}

.md-content code {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  background: rgba(15, 22, 36, 0.8);
  color: var(--sensor-green);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.88em;
  border: 1px solid rgba(44, 58, 85, 0.5);
}

.md-content pre {
  background: var(--bg-deep-blue);
  border: 1px solid var(--border-panel);
  border-radius: 10px;
  padding: 1.25rem;
  margin: 1.25rem 0;
  overflow-x: auto;
}

.md-content pre code {
  background: none;
  border: none;
  padding: 0;
  color: #c0c8d8;
  font-size: 0.85rem;
  line-height: 1.6;
}

.md-content hr {
  border: none;
  height: 1px;
  background: linear-gradient(
    to right,
    transparent,
    var(--border-panel),
    var(--portal-blue),
    var(--border-panel),
    transparent
  );
  margin: 2rem 0;
}

.md-content img {
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border-panel);
  margin: 1rem 0;
}

.md-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  background: var(--bg-panel);
  border: 1px solid var(--border-panel);
  border-radius: 10px;
  overflow: hidden;
}

.md-content th {
  background: var(--bg-deep-blue);
  color: var(--portal-blue);
  font-weight: 600;
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-panel);
}

.md-content td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid rgba(44, 58, 85, 0.4);
  color: #b8c0d0;
}

.md-content tr:last-child td {
  border-bottom: none;
}

.md-content tr:hover td {
  background: rgba(63, 169, 255, 0.04);
}

/* ================================================
   INVESTIGATION PANELS (reusable card style)
   ================================================ */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-panel);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.panel:hover {
  box-shadow: 0 0 20px rgba(63, 169, 255, 0.15);
  border-color: rgba(63, 169, 255, 0.3);
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0;
}

/* ================================================
   FOOTER
   ================================================ */
#site-footer {
  background: var(--bg-deep-blue);
  border-top: 1px solid var(--border-panel);
  padding: 1.5rem 2rem;
  text-align: center;
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  color: #4a5a70;
  font-size: 0.8rem;
}

/* ================================================
   ANIMATIONS
   ================================================ */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse-glow {
  0%, 100% { text-shadow: 0 0 15px rgba(63, 169, 255, 0.6); }
  50%      { text-shadow: 0 0 25px rgba(63, 169, 255, 0.9), 0 0 40px rgba(76, 235, 255, 0.3); }
}

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

.page-enter {
  animation: fade-in 0.4s ease forwards;
}

/* ================================================
   RESPONSIVE
   ================================================ */
@media (max-width: 768px) {
  .nav-toggle {
    display: flex;
  }

  #main-nav {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: rgba(15, 22, 36, 0.98);
    backdrop-filter: blur(16px);
    flex-direction: column;
    padding: 1rem;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border-panel);
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
  }

  #main-nav.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  #main-nav a {
    width: 100%;
    padding: 0.75rem 1rem;
  }

  #social-links {
    border-left: none;
    margin-left: auto;
    padding-left: 0;
  }

  main {
    padding: 2rem 1rem;
  }

  .page-header h1 {
    font-size: 1.6rem;
  }

  .md-content h1 { font-size: 1.6rem; }
  .md-content h2 { font-size: 1.3rem; }

  .panel-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .logo-title {
    font-size: 1.2rem;
  }
  .logo-subtitle {
    font-size: 0.55rem;
  }
  .header-inner {
    padding: 0 1rem;
  }
}
