/*
 * style.css – Consolidated Stylesheet for the HomoDynamics site.
 * This stylesheet combines global styles, responsive rules from the React build,
 * and base styles from the original static site.
 */

/* Root colour variables for easy theming */
:root {
  --bg-light: #FDFBF6;
  --panel-bg: #FCFBF8;
  --text-dark: #3A3A3A;
  --text-medium: #4A4A4A;
  --border-light: #EAE8E1;
  --highlight-bg: #F1F0EC;
  --primary: #3A3A3A;
}

body {
  margin: 0;
  background-color: var(--bg-light);
  color: var(--text-dark);
  font-family: 'Georgia', serif;
  overflow-x: hidden;
}

/* Custom Scrollbar for a refined look */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: #F1F1F1;
}
::-webkit-scrollbar-thumb {
  background: #C1C1C1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #A8A8A8;
}

/* Root layout for React app */
#root {
  display: flex;
}

/* Sidebar navigation */
.sidebar {
  width: 320px; /* From React inline styles */
  min-width: 320px; /* From React inline styles */
  background-color: var(--panel-bg);
  border-right: 1px solid var(--border-light);
  padding: 2rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  box-sizing: border-box;
  z-index: 998; /* Lower z-index than overlay for mobile */
  transition: transform 0.3s ease-in-out; /* Keep transition for smooth mobile opening */
}

/* .sidebar.is-open is only for mobile, handled within media query */

.sidebar h1 {
  font-size: 1.8rem; /* From React inline styles */
  margin-bottom: 2rem;
  color: var(--primary);
  font-family: 'Georgia', serif; /* From React inline styles */
  font-weight: normal;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 1rem;
}

.sidebar nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar nav a {
  display: block;
  padding: 0.75rem 1rem; /* From React inline styles */
  border-radius: 4px;
  color: var(--text-medium);
  text-decoration: none;
  font-size: 0.95rem; /* From React inline styles */
  transition: background 0.2s ease, color 0.2s ease;
}

.sidebar nav a.active {
  background-color: var(--highlight-bg); /* Original active state */
  color: var(--primary);
  font-weight: bold;
}

/* Specific to React's way of managing active links, overriding general hover */
.sidebar nav a[aria-current="page"] {
    background-color: var(--highlight-bg);
    color: var(--primary);
    font-weight: bold;
}

.sidebar nav a:hover {
  background-color: var(--highlight-bg);
  color: var(--primary);
}


/* Main content area */
.main-content {
  flex: 1;
  padding: 2rem 4rem; /* Base padding */
  box-sizing: border-box;
  height: auto; /* Allow content to expand */
  min-height: 100vh;
  overflow-y: visible; /* Allow natural scrolling */
  display: block; /* Ensure block display for scrolling */
}

/* Desktop: Full viewport height sections */
.main-content > div {
  min-height: 100vh;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4rem 0;
}

.main-content > div:last-child {
  margin-bottom: 0;
}

/* Hero section gets special treatment */
.main-content > div:first-child .hero {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}


/* Hero section */
.hero {
  margin: -2rem -4rem 2rem -4rem; /* Original static site margin */
  padding: 4rem 0;
  background-color: var(--primary);
  color: var(--bg-light);
  text-align: center;
  position: relative;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Hero title container */
.hero-title-container {
  display: flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
}

/* Hero words */
.hero-word {
  font-family: 'Georgia', serif;
  font-weight: normal;
  color: #FDFBF6;
  display: inline-block;
  vertical-align: baseline;
  font-size: clamp(2.5rem, 8vw, 5rem);
  transition: transform 0.8s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.5s ease;
}

/* Hero plus symbol */
.hero-plus {
  font-family: 'Georgia', serif;
  font-weight: normal;
  color: #FDFBF6;
  display: inline-block;
  vertical-align: baseline;
  font-size: clamp(2.5rem, 8vw, 5rem);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.4s ease,
              margin 0.8s cubic-bezier(0.25, 1, 0.5, 1),
              max-width 0.8s cubic-bezier(0.25, 1, 0.5, 1);
  margin: 0 0.5rem;
  max-width: 5rem;
}

/* Hero byline */
.hero-byline {
  font-family: 'Georgia', serif;
  font-size: 1.2rem;
  color: #C1C1C1;
  margin-top: 1.5rem;
  opacity: 0;
  transition: opacity 1s ease;
}

/* Legacy support for old hero classes */
.hero-title {
  font-size: clamp(3rem, 8vw, 6rem);
  margin: 0;
  font-weight: normal;
}

.hero-title .plus {
  margin: 0 0.5rem;
  /* For hero animation: hide overflow, animate margin and width */
  display: inline-block;
  overflow: hidden;
  max-width: 5rem;
  opacity: 0;
  transition: opacity 0.4s ease,
              margin 0.8s cubic-bezier(0.25, 1, 0.5, 1),
              max-width 0.8s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Byline fades in after hero animation */
.hero-credit {
  opacity: 0;
  transition: opacity 1s ease;
}

.hero-subtitle {
  font-size: 1.5rem;
  margin: 1rem 0;
  color: #C1C1C1;
}

.hero-symbol {
  margin: 2rem auto;
}

/* Section pages */
.section-page {
  margin-bottom: 4rem;
}

.section-page header h2 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  font-weight: normal;
}

.section-page header .divider {
  width: 80px;
  height: 2px;
  background-color: var(--primary);
  margin-bottom: 2rem;
}

.section-page-grid { /* From React build output */
  display: grid;
  grid-template-columns: 55% 40%;
  gap: 5%;
}

.section-page .content { /* Original static site, but applies to React text */
  min-width: 0;
}

.section-page .viz { /* Original static site, but applies to React visualizations */
  position: sticky;
  top: 2rem;
  align-self: flex-start;
}

.section-page .viz .viz-container { /* Original static site container */
  border: 1px solid var(--border-light);
  border-radius: 4px;
  background-color: var(--panel-bg);
  padding: 1.5rem;
}

.section-page .viz canvas { /* Original static site canvas style */
  width: 100%;
  height: auto;
  max-width: 100%;
  border-radius: 2px;
  background-color: #FAF9F5;
  display: block;
}


/* ContentDisplay component styles (derived from inline styles and old style.css) */
.section-page h3 { /* General h3, from ContentDisplay and old static site */
  font-size: 1.75rem; /* From ContentDisplay */
  margin-bottom: 1.5rem; /* From ContentDisplay */
  color: var(--text-dark); /* From ContentDisplay */
  font-weight: normal;
}

.section-page p { /* General p, from ContentDisplay and old static site */
  line-height: 1.8;
  font-size: 1.1rem;
  color: var(--text-medium);
  margin: 0 0 1.5em 0;
}

.section-page h4 { /* General h4, from ContentDisplay and old static site */
  font-size: 1.4rem; /* From ContentDisplay */
  margin-bottom: 1rem; /* From ContentDisplay */
  color: var(--text-dark); /* From ContentDisplay */
  font-weight: normal;
}

/* Specific style for strong tags to match the React app's inline style */
.section-page p strong {
  color: #1A1A1A;
}

.sub-block { /* Original static site */
  margin-top: 2rem;
  border-left: 2px solid var(--border-light);
  padding-left: 2rem;
}

/* New styles for detailed sub-section layouts (from React build output) */
.sub-section-list {
  display: flex;
  flex-direction: column;
  gap: 3rem;
  margin-bottom: 2rem;
}

.sub-section {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1.5rem;
}

.sub-section .text {
  flex: 1 1 60%;
  min-width: 250px;
}

.sub-section canvas {
  flex: 0 0 320px;
  width: 320px;
  height: 320px;
  max-width: 100%;
  border: 1px solid var(--border-light);
  background-color: var(--panel-bg);
  display: block;
}

/* Caption styling for sub‑section artwork */
.art-caption {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-medium);
}


/* Footer */
.footer {
  padding: 1rem 4rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-medium);
  border-top: 1px solid var(--border-light);
  margin-top: 4rem;
}

/* Mobile menu button (from React build output) */
.menu-button {
  display: none; /* Hidden by default */
  position: fixed;
  top: 1.5rem; /* Adjusted for better spacing */
  left: 1.5rem; /* Adjusted for better spacing */
  z-index: 1001;
  background: var(--panel-bg);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  width: 44px;
  height: 44px;
  padding: 8px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  -webkit-tap-highlight-color: transparent;
}

.menu-button div {
  width: 100%;
  height: 2px;
  background-color: var(--primary);
  margin: 5px 0;
  transition: transform 0.3s ease;
}

/* Transform lines into X when open (from original script.js logic, but styles defined here) */
.menu-button.open div:nth-child(1) { /* Changed span to div as per React output */
  transform: rotate(45deg) translateY(7px); /* Adjusted for visual alignment */
}

.menu-button.open div:nth-child(2) { /* Changed span to div as per React output */
  opacity: 0;
}

.menu-button.open div:nth-child(3) { /* Changed span to div as per React output */
  transform: rotate(-45deg) translateY(-7px); /* Adjusted for visual alignment */
}

/* Overlay for mobile sidebar (from React build output) */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.overlay.is-visible { /* From React build output */
  display: block;
  opacity: 1;
}

/* Responsive styles (from React build output) */
@media (max-width: 800px) {
  html {
    height: 100%;
    width: 100%;
  }

  body {
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
    margin: 0;
    padding: 0;
  }

  #root {
    flex-direction: column !important;
    min-height: 100vh !important;
    width: 100% !important;
  }

  .sidebar {
    position: fixed !important; /* Override desktop sticky for mobile */
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    z-index: 1000 !important; /* Higher z-index for mobile when open */
    transform: translateX(-100%) !important; /* Hidden by default on mobile */
    box-shadow: 4px 0px 15px rgba(0,0,0,0.1) !important;
    border-right: none !important;
    width: 100% !important;
    max-width: none !important;
    height: 100vh !important;
  }

  .sidebar.is-open {
    transform: translateX(0) !important; /* Visible when open on mobile */
  }

  .menu-button {
    display: block !important;
  }

  .overlay {
    display: block !important;
  }

  .main-content {
    flex: 1 !important;
    width: 100% !important;
    padding: 1rem 2.5rem !important;
    margin: 0 !important;
    height: auto !important;
    min-height: 100vh !important;
    overflow-y: visible !important;
    box-sizing: border-box !important;
    display: block !important; /* Ensure block display for scrolling */
  }

  /* Section spacing for mobile */
  .main-content > div {
    margin-bottom: 2rem !important;
  }

  .main-content > div:last-child {
    margin-bottom: 2rem !important;
  }

  .hero {
    margin: 0 !important;
    min-height: 250px !important;
    height: auto !important;
    padding: 2rem 2.5rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .hero-title-container {
    flex-direction: row !important; /* Keep horizontal for animation */
    align-items: baseline !important;
    justify-content: center !important;
    flex-wrap: nowrap !important; /* Force no wrapping */
    gap: 0 !important; /* Remove gap to allow proper merging */
    white-space: nowrap !important; /* Prevent text wrapping */
    overflow: visible !important;
  }

  .hero-word {
    font-size: clamp(1.5rem, 8vw, 3rem) !important; /* Smaller for mobile */
    white-space: nowrap !important;
    display: inline-block !important;
  }

  .hero-plus {
    font-size: clamp(1.5rem, 8vw, 3rem) !important;
    margin: 0 0.3rem !important; /* Smaller margin for mobile */
    white-space: nowrap !important;
    display: inline-block !important;
  }

  .hero-byline {
    font-size: 1rem !important;
    margin-top: 1rem !important;
  }
  /* Full-page sections on mobile */
  .section-page-grid {
    display: block !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .section-page .content {
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .section-page .viz {
    width: 100% !important;
    box-sizing: border-box !important;
  }
  /* Typography adjustments */
  h2 {
    font-size: 2rem !important;
  }
  h3 {
    font-size: 1.5rem !important;
  }
  h4 {
    font-size: 1.25rem !important;
  }

  .sub-section {
    flex-direction: column;
  }
  .sub-section canvas {
    width: 100%;
    height: 250px;
  }

  .footer {
    padding: 1rem 2.5rem !important;
    margin: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
}
