/* Main Page Redesign - Header Navigation SPA */

/* ========================================
   CSS Variables
   ======================================== */
:root {
  --bg-grey: #f5f5f5;
  --edge-dark: rgba(0, 0, 0, 0.15);
  --text-primary: #2d2d2d;
  --text-muted: #6b6b6b;
  --text-active: #999;
  --transition-fast: 0.15s ease;
  --transition-medium: 0.3s ease;
  --transition-slow: 0.5s ease-out;
  --header-height: 64px;
  --header-padding: 1.5rem;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'EB Garamond', Georgia, serif;
  cursor: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' style='font-size:24px'><text y='24'>☁️</text></svg>") 16 16, auto;
}

body {
  background: var(--bg-grey);
}

/* Raining cloud on clickable elements */
a, button, [role="button"], .nav-link, .dropdown-link, .viz-card, .expand-btn, .toggle, .hamburger {
  cursor: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' style='font-size:24px'><text y='24'>🌧️</text></svg>") 16 16, pointer;
}

/* Lightning cloud on click */
a:active, button:active, [role="button"]:active, .nav-link:active, .dropdown-link:active, .viz-card:active, .expand-btn:active, .toggle:active, .hamburger:active {
  cursor: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' style='font-size:24px'><text y='24'>⛈️</text></svg>") 16 16, pointer;
}

/* ========================================
   Site Header Navigation
   ======================================== */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  height: var(--header-height);
  padding: 0 var(--header-padding);
  background: linear-gradient(to bottom, var(--bg-grey) 0%, var(--bg-grey) 80%, transparent 100%);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.875rem;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color var(--transition-fast);
  padding: 0.5rem 0;
  display: block;
}

.nav-link:hover {
  color: var(--text-primary);
  text-decoration: none;
}

.nav-link em {
  font-style: italic;
}

/* Active nav link - lighter color */
.nav-link.active {
  color: var(--text-active);
}

/* Static breadcrumb styles (for subpages like Multifractal, blog posts) */
.nav-item.static-breadcrumb {
  display: flex;
  align-items: center;
}

.breadcrumb-divider {
  margin: 0 0.5rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.breadcrumb-current {
  color: var(--text-active);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 30vw;
  display: inline-block;
  padding: 0.5rem 0;
}

/* Hamburger (hidden on desktop) */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  padding: 0;
  margin-left: auto;
}

.hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-primary);
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

/* Mobile Menu */
.mobile-menu {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-grey);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-medium), visibility 0s var(--transition-medium);
}

.mobile-menu.open {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--transition-medium), visibility 0s 0s;
}

.mobile-menu-content {
  padding: calc(var(--header-height) + 2rem) var(--header-padding) 2rem;
}

.mobile-menu .mobile-nav-item {
  margin-bottom: 1.5rem;
}

.mobile-menu .mobile-nav-link {
  display: block;
  font-size: 1.25rem;
  color: var(--text-primary);
  text-decoration: none;
  margin-bottom: 0.5rem;
}

.mobile-menu .mobile-nav-link em {
  font-style: italic;
}

.mobile-menu .mobile-dropdown {
  padding-left: 1rem;
}

.mobile-menu .mobile-dropdown-link {
  display: block;
  font-size: 1rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.5rem 0;
}

.mobile-menu .mobile-dropdown-link:hover {
  color: var(--text-primary);
}

.mobile-menu .mobile-nav-link.active,
.mobile-menu .mobile-dropdown-link.active {
  color: var(--text-active);
}

/* ========================================
   Main Canvas (Background with Gradient)
   ======================================== */
.main-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-grey);
  transform-origin: center center;
  transition: transform 0.1s ease-out;
  will-change: transform;
}


/* ========================================
   3D Surface Visualization
   ======================================== */
.surface-viz-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
}

.surface-viz-container canvas {
  width: 100%;
  height: 100%;
}


/* ========================================
   Page Container & Content
   ======================================== */
.page-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-medium);
}

.page-container.active {
  pointer-events: auto;
  opacity: 1;
}

.page-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--transition-medium), visibility 0s var(--transition-medium);
  padding: calc(var(--header-height) + 2rem) 2rem 4rem 2rem;
  background: var(--bg-grey);
  -webkit-overflow-scrolling: touch;
}

.page-container.active .page-content.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity var(--transition-medium), visibility 0s 0s;
}

/* Page content sections styling */
.page-content h1 {
  font-size: 2rem;
  font-weight: bold;
  margin-bottom: 1rem;
  color: #222;
  font-family: 'EB Garamond', Georgia, serif;
}

.page-content h2 {
  font-size: 2.5rem;
  font-weight: bold;
  margin: 2rem 0 1rem;
  color: #333;
  border-bottom: 2px solid black;
  padding-bottom: 0.5rem;
  font-family: 'EB Garamond', Georgia, serif;
}

.page-content p {
  line-height: 1.7;
  margin-bottom: 1rem;
  color: #444;
  max-width: 800px;
}

/* Links in page content - inherit color, underline, hover effect */
.page-content a {
  color: inherit;
  text-decoration: underline;
}

.page-content a:visited,
.page-content a:active {
  color: inherit;
}

.page-content a:hover {
  -webkit-text-stroke: 1px black;
  -webkit-text-fill-color: transparent;
  text-decoration: none;
}

/* ========================================
   Expanding Animation Origin Point (unused but kept for reference)
   ======================================== */
.expand-origin {
  position: fixed;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: white;
  pointer-events: none;
  z-index: 99;
  transform: scale(0);
  transition: transform 0.6s var(--elastic-soft);
}

.expand-origin.expanding {
  transform: scale(500);
}

/* ========================================
   SEO Content (Hidden)
   ======================================== */
.seo-content {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ========================================
   Iframe Content Styling
   ======================================== */
.page-content iframe {
  width: 100%;
  height: calc(100vh - 160px);
  border: none;
  border-radius: 8px;
  background: #f9f9f9;
}

/* ========================================
   Visualization Hub Specific Styles
   ======================================== */
.viz-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-top: 2rem;
}

.viz-card {
  background: #f9f9f9;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 24px;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  text-decoration: none;
  color: inherit;
  display: block;
}

.viz-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  text-decoration: none;
}

.viz-card h3 {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
  color: #222;
}

.viz-card p {
  font-size: 0.95rem;
  color: #666;
  margin: 0;
}

/* ========================================
   About Page Specific Styles
   ======================================== */
.page-content[data-page="about"] > *,
.page-content[data-page="cv"] > * {
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.about-header {
  display: flex;
  gap: 40px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 3rem;
}

.about-photo {
  width: auto;
  height: 100%;
  max-height: 300px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.about-bio {
  flex: 1;
  text-align: right;
  max-width: 450px;
}

.about-bio h1 {
  margin-bottom: 1rem;
  font-family: 'EB Garamond', Georgia, serif;
}

.about-bio p {
  text-align: right;
  max-width: 450px;
  margin-left: auto;
}

.social-icons {
  display: flex;
  gap: 16px;
  margin-top: 1.5rem;
  justify-content: flex-end;
}

.social-icons a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  transition: transform var(--transition-fast);
}

.social-icons a:hover {
  transform: scale(1.1);
}

.social-icons img {
  width: 26px;
  height: 26px;
}

.social-icons img[alt="Substack"] {
  filter: invert(46%) sepia(84%) saturate(2090%) hue-rotate(11deg) brightness(107%) contrast(104%);
}

/* Highlights section */
.highlights-section {
  margin-top: 3rem;
}

.highlights-section h2 {
  text-align: left;
}

.highlight-box {
  display: flex;
  gap: 40px;
  margin-bottom: 3rem;
  align-items: flex-start;
}

.highlight-box.reverse {
  flex-direction: row-reverse;
}

.highlight-text {
  flex: 1;
  text-align: left;
}

.highlight-text p {
  text-align: left;
}

.highlight-title {
  font-size: 2rem;
  font-weight: bold;
  margin-bottom: 1rem;
  color: #222;
  font-family: 'EB Garamond', Georgia, serif;
  text-align: left;
}

.highlight-media {
  flex: 0 0 300px;
}

.highlight-media img,
.highlight-media video {
  width: 100%;
  border-radius: 8px;
}

/* ========================================
   CV Page Specific Styles
   ======================================== */
.cv-contact-line {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cv-contact-line a {
  padding: 0.4em 0.8em;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-decoration: none;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.cv-contact-line a:hover {
  border-color: #999;
  background: rgba(0,0,0,0.02);
  -webkit-text-stroke: 0;
  -webkit-text-fill-color: inherit;
}

.cv-separator {
  color: #ccc;
}

.cv-section {
  margin-bottom: 2.5rem;
}

.cv-section h2 {
  font-size: 1.3rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cv-item {
  margin-bottom: 1.5rem;
  padding-left: 1rem;
  border-left: 2px solid #e0e0e0;
}

.cv-item-title {
  font-weight: 600;
  color: #222;
  margin-bottom: 0.25rem;
}

.cv-item-meta {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 0.5rem;
}

.cv-item-description {
  font-size: 0.95rem;
  color: #444;
}

.cv-item .badge {
  display: inline-block;
  background: #f0f0f0;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  margin-left: 8px;
}

.cv-item .badge.highlight {
  background: #fff3cd;
  color: #856404;
}

/* ========================================
   Mobile Responsive
   ======================================== */
@media (max-width: 768px) {
  :root {
    --header-padding: 1rem;
  }

  /* Hide desktop nav, show hamburger */
  .site-nav {
    display: none;
  }

  .hamburger {
    display: flex;
  }

  .nav-breadcrumb {
    flex: 1;
  }

  /* Hamburger animation when menu open */
  .site-header.menu-open .hamburger span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
  }

  .site-header.menu-open .hamburger span:nth-child(2) {
    opacity: 0;
  }

  .site-header.menu-open .hamburger span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
  }

  .page-content {
    padding: calc(var(--header-height) + 1rem) 1.5rem 2rem 1.5rem;
  }

  /* Reduce gap on tablets but keep side-by-side */
  .about-header {
    gap: 24px;
  }

  .about-photo {
    max-height: 200px;
  }

  .highlight-box,
  .highlight-box.reverse {
    flex-direction: column;
  }

  .highlight-media {
    flex: 0 0 auto;
    width: 100%;
  }

  .viz-hub-grid {
    grid-template-columns: 1fr;
  }
}

/* Narrow screens: stack headshot with right alignment */
@media (max-width: 400px) {
  .about-header {
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    gap: 16px;
  }

  .about-photo {
    width: auto;
    height: auto;
    max-height: 150px;
  }

  .about-bio {
    max-width: 100%;
  }

  .about-bio p {
    max-width: 100%;
  }
}

/* ========================================
   Loading States
   ======================================== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: #888;
}

.loading::after {
  content: '';
  width: 24px;
  height: 24px;
  border: 2px solid #ddd;
  border-top-color: #666;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 12px;
}

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

/* ========================================
   Print Styles
   ======================================== */
@media print {
  .main-canvas,
  .site-header,
  .mobile-menu,
  .center-animation {
    display: none !important;
  }

  .page-container,
  .page-content {
    position: static !important;
    opacity: 1 !important;
    visibility: visible !important;
    padding: 2rem !important;
  }

  .seo-content {
    position: static !important;
    width: auto !important;
    height: auto !important;
  }
}
