/* ==========================================================================
   CSS Reset & Base Styles
   ========================================================================== */

:root {
  --nav-h: 30px;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  min-height: 60vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Navigation Bar
   ========================================================================== */

.nav-bar {
  width: 100%;
  background: rgb(255, 255, 255);
  backdrop-filter: blur(6px);
  border-bottom: 0px solid #eee;
  position: fixed;
  top: 0;
  z-index: 1000;
  height: var(--nav-h);
  cursor: pointer;
}

.nav-content {
  width: 80vw;
  max-width: 1200px;
  height: 100%;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  position: relative;
  z-index: 2;
}

.nav-brand {
  font-size: 20px;
  color: #ffa500;
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 20px;
  align-items: center;
}

.nav-link {
  text-decoration: none;
  color: #666;
  font-size: 14px;
}

.nav-link:hover {
  color: #333;
}

.nav-link.active {
  color: #ffa500;
}

/* ==========================================================================
   Footer & Social Links
   ========================================================================== */

.footer {
  width: 20vw;
  margin: 0px auto;
  padding: 20px 0;
  position: relative;
  z-index: 1001;
  background: white;
}

.social-section {
  width: 20vw;
  margin: 0px auto;
  padding: 20px 0;
  position: relative;
  z-index: 1001;
  background: white;
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 20px;
}

.social-links a {
  color: #666;
  font-size: 18px;
  transition: color 0.3s ease;
  padding: 10px;
  line-height: 1;
}

.social-links a:hover {
  color: #ffa500;
}

/* ==========================================================================
   Homepage Styles
   ========================================================================== */

main {
  height: calc(100vh - var(--nav-h) - 80px);
  position: relative;
  margin-top: var(--nav-h);
}

#orreryCanvas {
  position: relative;
  width: 100%;
  height: calc(80vh - var(--nav-h));
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ==========================================================================
   About Page Styles
   ========================================================================== */

.content-container {
  width: 80vw;
  max-width: 800px;
  margin: 120px auto 50px;
  padding-top: 20px;
  color: #333;
}

.about-section {
  margin-bottom: 30px;
}

.about-section p {
  margin-bottom: 1px;
  font-size: 12px;
  color: #444;
}

/* Canvas positioning for INDEX PAGE ONLY - specific to orrery */
#orreryCanvas {
  display: block;
  width: 100% !important;
  position: absolute;
  top: var(--nav-h);
  left: 0;
  z-index: 1;
}

/* About page animation canvas - keep it relative and in the nav */
#nav-animation canvas {
  position: relative !important;
  display: block !important;
  top: 0 !important;
  left: 0 !important;
  z-index: 0 !important;
}

/* ==========================================================================
   Projects Page Styles
   ========================================================================== */

.master-container {
  width: 80vw;
  margin: 90px auto 0;
  padding-top: 20px;
  flex: 1;
  padding-bottom: 50px;
}

.projects-section {
  overflow: hidden;
}

.project-card {
  border-top: 1px solid #eee;
  margin-left: 0px;
  overflow: hidden;
}

.project-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 0;
  cursor: pointer;
  user-select: none;
}

.project-title {
  font-size: 12px;
  font-weight: 500;
  margin: 0;
}

.project-category {
  font-size: 12px;
  color: #999;
}

.project-content {
  max-height: 0;
  opacity: 0;
  transition: all 0.3s ease;
  overflow: hidden;
  pointer-events: none;
}

.project-card.active .project-content {
  max-height: 500px;
  opacity: 1;
  padding: 0 0 20px 0;
  pointer-events: auto;
}

.project-details {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-top: 20px;
}

.video-preview {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

.music-container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  height: 120px;
  background: #f5f5f5;
  border-radius: 4px;
  overflow: hidden;
}

.description {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  font-size: 14px;
  line-height: 1.5;
  color: #666;
}

.video-container {
  position: relative;
  padding-bottom: 56.25%;
  background: #f5f5f5;
  border-radius: 4px;
  overflow: hidden;
}

iframe {
  border: 0;
  width: 100%;
  height: 100%;
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
}

.play-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.play-button:after {
  content: '';
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 7px 0 7px 12px;
  border-color: transparent transparent transparent #ffffff;
  margin-left: 3px;
}

.video-container:hover .play-button {
  display: flex;
}

.video-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding: 0 4px;
}

.mute-button {
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.mute-button svg {
  width: 16px;
  height: 16px;
  fill: #666;
  transition: fill 0.2s;
}

.mute-button:hover svg {
  fill: #333;
}

.mute-button.muted svg path:last-child {
  display: none;
}

.video-link {
  display: block;
  text-align: right;
  color: #666;
  font-size: 12px;
  text-decoration: none;
}

.video-link:hover {
  color: #333;
}

/* ==========================================================================
   Writing Preview (Projects)
   ========================================================================== */

.writing-container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  height: 120px;
  background: #f5f5f5;
  border-radius: 4px;
  overflow: hidden;
}

.writing-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 100%;
  padding: 12px;
  text-decoration: none;
}

.writing-thumb {
  width: 96px;
  height: 96px;
  flex: 0 0 96px;
  border-radius: 4px;
  overflow: hidden;
  background: #e9e9e9;
}

.writing-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.writing-meta {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.writing-link {
  color: #666;
  font-size: 12px;
  text-decoration: none;
}

.writing-preview:hover .writing-link {
  color: #333;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (max-width: 768px) {
  .nav-content {
    width: 90vw;
  }

  .footer {
    width: 90vw;
  }

  .social-section {
    width: 90vw;
  }

  .content-container {
    width: 90vw;
  }

  .master-container {
    width: 90vw;
  }

  .video-preview, .music-container, .description {
    max-width: 100%;
  }

  .project-card.active .project-content {
    max-height: 800px;
  }
}

@media (max-width: 640px) {
  :root {
    --nav-h: 60px;
  }

  .nav-bar {
    height: auto;
    min-height: var(--nav-h);
  }

  .nav-content {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 20px;
    align-items: flex-start;
    height: auto;
  }
  
  .nav-links {
    width: 100%;
    justify-content: flex-start;
    gap: 15px;
  }

  main {
    height: calc(100vh - 60px - 80px);
    margin-top: 60px;
  }

  #orreryCanvas {
    height: calc(80vh - 60px);
    top: 60px;
  }

  /* Fix for About page p5.js canvas inside nav */
  #nav-animation canvas {
    height: 60px !important;
    position: relative !important;
    top: 0 !important;
    left: 0 !important;
  }

  .content-container {
    margin: 140px auto 50px;
    padding-top: 20px;
  }

  .master-container {
    margin: 120px auto 0;
    padding-top: 20px;
  }
}

@media (max-width: 480px) {
  .project-title {
    width: 100%;
    line-height: 1.25;
  }

  .project-category {
    width: 100%;
    font-size: 11px;
    color: #aaa;
  }
}