/* =========================================
   1. Arian Theme Tokens & Page Colors
   ========================================= */

:root {
  /* Layout */
  --dock-radius: 24px;
  --dock-height: 72px;
  --dock-gap: 8px;
  --container-width: 94vw; 
  
  /* Default Accent (Safety Fallback) */
  --page-accent: #6366f1;
}

/* --- Dynamic Page Colors (Neon/Metal Pastel) --- */
body[data-active-page="About"]           { --page-accent: #38bdf8; } /* Sky Blue */
body[data-active-page="Founders"]        { --page-accent: #f472b6; } /* Neon Rose */
body[data-active-page="Documents"]       { --page-accent: #fbbf24; } /* Amber Gold */
body[data-active-page="News"]            { --page-accent: #34d399; } /* Emerald */
body[data-active-page="EventTimeline"]   { --page-accent: #a78bfa; } /* Violet */
body[data-active-page="Trade"]           { --page-accent: #2dd4bf; } /* Teal */
body[data-active-page="BackToTheFuture"] { --page-accent: #f87171; } /* Coral Red */

body.arian {
  /* Light Mode Base */
  --bg-gradient: radial-gradient(circle at 50% 0%, #f1f5f9 0%, #e2e8f0 100%);
  --ink: #0f172a;
  --muted: #64748b;
  
  /* Glass Surfaces */
  --glass-panel: rgba(255, 255, 255, 0.75);
  --glass-border: rgba(255, 255, 255, 0.8);
  --glass-shadow: 
    0 4px 6px -1px rgba(0, 0, 0, 0.1), 
    0 2px 4px -1px rgba(0, 0, 0, 0.06),
    inset 0 0 20px rgba(255, 255, 255, 0.5); 
  
  --active-bg: rgba(255, 255, 255, 0.95);
  --tooltip-bg: #0f172a;
  --tooltip-text: #ffffff;
}

body.dark.arian {
  /* Dark Mode Base */
  --bg-gradient: radial-gradient(circle at 50% -10%, #1e293b 0%, #020617 100%);
  --ink: #f8fafc;
  --muted: #94a3b8;

  /* Glass Surfaces */
  --glass-panel: rgba(15, 23, 42, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-shadow: 
    0 10px 15px -3px rgba(0, 0, 0, 0.5),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05);

  --active-bg: rgba(30, 41, 59, 0.8);
  --tooltip-bg: #e2e8f0;
  --tooltip-text: #0f172a;
}

/* Global Reset & Body */
body.arian {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--ink);
  font-family: "Vazirmatn", system-ui, sans-serif;
  overflow-x: hidden;
  padding-bottom: calc(var(--dock-height) + 40px + env(safe-area-inset-bottom)); 
  transition: background 0.6s ease, color 0.6s ease;
}

/* =========================================
   2. Main Layout
   ========================================= */

.arian-main-layout {
  width: var(--container-width);
  max-width: 2000px;
  margin: 0 auto;
  padding: 20px 10px;
  animation: fadeIn 0.5s ease-out;
}

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

.arian-page-host {
  min-height: 60vh;
  position: relative;
}

/* Loading Spinner */
.arian-page-host[data-loading]::before {
  content: "";
  position: absolute;
  top: 150px; 
  left: 50%;
  width: 50px; 
  height: 50px;
  margin-left: -25px;
  border: 4px solid var(--glass-border);
  border-top-color: var(--page-accent); 
  border-radius: 50%;
  animation: spin 0.8s cubic-bezier(0.55, 0.055, 0.675, 0.19) infinite;
  z-index: 10;
  box-shadow: 0 0 15px var(--page-accent);
}

@keyframes spin { to { transform: rotate(360deg); } }

.arian-error {
  text-align: center;
  padding: 40px;
  color: #f87171;
  background: var(--glass-panel);
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  max-width: 600px;
  margin: 40px auto;
}

/* =========================================
   3. Floating Dock
   ========================================= */

.arian-dock-container {
  position: fixed;
  bottom: 24px;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 0; 
  right: 0;
  display: flex;
  justify-content: center;
  z-index: 1000;
  pointer-events: none;
}

.arian-dock {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--dock-gap);
  padding: 8px 12px;
  background: var(--glass-panel);
  border: 1px solid var(--glass-border);
  border-radius: var(--dock-radius);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  max-width: 95vw;
  
  overflow: visible; 
}

/* Scroller Wrapper (Desktop default: just display contents) */
.dock-scroller {
  display: contents; 
}

/* --- Common Item Styles --- */
.dock-item {
  position: relative;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 12px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  min-width: 56px;
  flex-shrink: 0;
}

.dock-icon {
  width: 26px;
  height: 26px;
  transition: transform 0.2s;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
}

/* --- Tooltip --- */
.dock-label {
  position: absolute;
  bottom: 100%;
  margin-bottom: 14px;
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  font-family: "Vazirmatn", system-ui, sans-serif;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  opacity: 0;
  transform: translateY(8px) scale(0.9);
  pointer-events: none;
  transition: all 0.2s ease;
  white-space: nowrap;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 2000;
}

.dock-item:hover .dock-label {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.dock-item:hover {
  background: rgba(255,255,255,0.15);
  color: var(--ink);
  transform: translateY(-4px);
}

.dock-item:hover .dock-icon {
  transform: scale(1.15);
}

/* --- Active State (GLOBAL: Icon Only, No Background) --- */
.dock-item.is-active {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--page-accent);
  
  /* Slight lift for desktop feeling, overridden in mobile if needed */
  transform: translateY(-5px);
}

/* Apply Glow and Boldness to the Icon itself */
.dock-item.is-active .dock-icon {
  transform: scale(1.25);
  stroke: var(--page-accent);
  stroke-width: 2.5; /* Bold active icon */
  /* This creates the neon glow AROUND the shape */
  filter: drop-shadow(0 0 8px var(--page-accent)); 
}

/* The Dot Indicator */
.dock-item.is-active::after {
  content: '';
  position: absolute;
  bottom: 6px;
  width: 4px;
  height: 4px;
  background: var(--page-accent);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--page-accent);
  opacity: 0.8;
}

/* =========================================
   4. Theme Button Styling
   ========================================= */

.dock-divider {
  width: 1px;
  height: 32px;
  background: var(--glass-border);
  margin: 0 4px;
  flex-shrink: 0;
  opacity: 0.6;
}

#themeBtn {
  border-radius: 50%;
  width: 52px;
  height: 52px;
  padding: 0;
  background: rgba(125, 125, 125, 0.08);
  border: 1px solid var(--glass-border);
  overflow: hidden; 
}

body.dark #themeBtn {
  background: rgba(255, 255, 255, 0.08);
}

#themeBtn:hover {
  background: var(--active-bg);
  transform: scale(1.1);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

/* Icon Visibility Logic */
#themeBtn .dock-icon { display: none !important; }

#themeBtn[data-theme="light"] .theme-icon--sun { 
  display: block !important; 
  fill: #f59e0b;
  stroke: #f59e0b;
  filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.5));
}

#themeBtn[data-theme="dark"] .theme-icon--moon { 
  display: block !important; 
  fill: #fcd34d;
  stroke: transparent;
  filter: drop-shadow(0 0 4px rgba(253, 211, 77, 0.5));
}

/* =========================================
   5. Mobile Adaptive (Split Layout)
   ========================================= */

@media (max-width: 768px) {
  .arian-dock-container {
    bottom: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .arian-dock {
    width: 70%;
    max-width: 320px;
    padding: 6px 8px;
    
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    overflow: hidden;
  }

  /* 1. Scroller */
  .dock-scroller {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px; 
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none; 
    -ms-overflow-style: none;
    padding-left: 8px;
    -webkit-mask-image: none;
    mask-image: none;
  }
  .dock-scroller::-webkit-scrollbar { display: none; }

  .dock-item {
    min-width: 36px;
    padding: 6px; 
    border-radius: 8px;
    flex-shrink: 0;
  }

  /* 2. Remove desktop lift on mobile */
  .dock-item.is-active {
    transform: none !important;
  }

  /* 3. Icon Style Inherits from Global, just ensure size fits */
  .dock-item.is-active .dock-icon {
    transform: scale(1.2); 
  }

  .dock-item.is-active::after {
    bottom: 2px; 
  }

  /* 4. Fixed Left Elements */
  .dock-divider {
    display: block;
    margin: 0 6px;
    height: 20px;
    background: rgba(150, 150, 150, 0.3);
  }

  #themeBtn {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin-left: 0;
    background: rgba(0,0,0,0.04);
    box-shadow: none;
  }
  
  .dock-icon { width: 22px; height: 22px; }
  .dock-label { display: none; }
  .dock-item:hover { transform: none; }
}

/* =========================================
   6. Floating Back Button (Lighthouse)
   ========================================= */

.arian-back-btn {
  position: fixed;
  bottom: 25px; /* Aligned vertically with Dock */
  bottom: max(25px, env(safe-area-inset-bottom));
  left: 30px; /* Positioned at bottom-left */
  
  display: flex;
  align-items: center;
  justify-content: center;
  
  width: 50px;
  height: 50px;
  color: var(--muted);
  
  /* The Floating Animation */
  animation: floatLighthouse 3s ease-in-out infinite;
  
  z-index: 900; /* Behind dock (1000) if overlap, but normally distinct */
  transition: color 0.3s ease, transform 0.3s ease;
  cursor: pointer;
}

/* Simple Up/Down Bobbing */
@keyframes floatLighthouse {
  0%   { transform: translateY(0px); }
  50%  { transform: translateY(-8px); } /* Moves up like hovering */
  100% { transform: translateY(0px); }
}

.arian-back-btn svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.arian-back-btn:hover {
  color: var(--page-accent); /* Glows with page color on hover */
  /* Pause floating on hover? Or intensify? Let's scale it slightly */
  animation-play-state: paused;
  transform: scale(1.1) translateY(-5px);
}

/* Mobile Tweak: Ensure it doesn't overlap the dock */
@media (max-width: 768px) {
  .arian-back-btn {
    left: 15px; /* Closer to edge on mobile */
    bottom: 20px;
    bottom: max(20px, env(safe-area-inset-bottom));
    width: 40px;
    height: 40px;
  }
}