/* Define base variables for the LIGHT theme in :root */
:root {
  --background-color: #f8f8f8;
  --text-color-primary: #18191b;
  --text-color-secondary: #a2a2a2;
  --text-color-tertiary: #888; /* For creative menu and big title */
  --text-color-light-hover: #444; /* For center-link hover light mode */
  --header-footer-bg: transparent; /* For header/footer on homepage, often transparent */
  --footer-text-color: #1a1a1a;
  --theme-icon-stroke: #18191b;
  --loader-bg: #f8f8f8;
  --loader-text-primary: #bcbcbc;
  --loader-text-loaded: #222;
  --button-hover-bg: rgba(30,30,30,0.08);

  /* Carousel / Sound Page Specific Light Mode Colors */
  --carousel-item-inactive-opacity: 0.3;
  --carousel-item-inactive-scale: 0.65;
  --carousel-item-bg: #e0e0e0;
  --carousel-item-text: #1a1a1a;
  --carousel-box-shadow-active: 0 4px 32px 0 rgba(30,30,40,0.13), 0 0 0 2px #2196f3;

  /* Sound Player Specific Light Mode Colors */
  --sound-disc-bg: #e9e9e9;
  --sound-disc-center-bg: #1a1a1a;
  --sound-disc-play-icon-fill: #ffffff;
  --sound-progress-text-color: #555;
  --sound-progress-bar-track-bg: #ccc;
  --sound-progress-bar-thumb-border: #f8f8f8;
  --sound-description-color: #333;
}

/* Override variables for the DARK theme in body.dark */
body.dark {
  --background-color: #1a1a1a;
  --text-color-primary: #f8f8f8;
  --text-color-secondary: #d0d0d0;
  --text-color-tertiary: #b0b0b0; /* Adjust for creative menu and big title */
  --text-color-light-hover: #f8f8f8;
  --header-footer-bg: #1a1a1a;
  --footer-text-color: #f8f8f8;
  --theme-icon-stroke: #f8f8f8;
  --loader-bg: #111;
  --loader-text-primary: #444;
  --loader-text-loaded: #fff;
  --button-hover-bg: rgba(255,255,255,0.10);

  /* Carousel / Sound Page Specific Dark Mode Colors */
  --carousel-item-bg: #222;
  --carousel-item-text: #fff;
  --carousel-box-shadow-active: 0 4px 32px 0 rgba(0,0,0,0.4), 0 0 0 2px #2196f3;

  /* Sound Player Specific Dark Mode Colors */
  --sound-disc-bg: #333;
  --sound-disc-center-bg: #f8f8f8;
  --sound-disc-play-icon-fill: #1a1a1a;
  --sound-progress-text-color: #bbb;
  --sound-progress-bar-track-bg: #555;
  --sound-progress-bar-thumb-border: #1a1a1a;
  --sound-description-color: #f0f0f0;
}

/* Now, use these variables consistently throughout your CSS */

html, body {
  height: 100%;
  width: 100vw;
  margin: 0;
  padding: 0;
  overflow-x: hidden; /* Keep this to prevent horizontal scroll */
  background: var(--background-color);
  font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
  color: var(--text-color-primary);
  transition: background 0.3s ease, color 0.3s ease;
}
* {
  box-sizing: border-box;
}

.container {
    width: 100%; /* Use 100% instead of 100vw to respect parent padding if any */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    opacity: 0; /* This is handled by JS, set to 1 after loader */
    transition: opacity 0.35s ease-in-out;
}

#homepage,
#sound-detail-page,
.creative-page {
  /* Remove fixed 100vw/min-width/max-width here. Let container manage width */
  width: 100%;
  min-height: 100vh; /* Keep min-height */
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--background-color);
  transition: background 0.3s ease;
}

/* HEADER */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start; /* Keeps Vitruvian Man aligned to top, or center if you change this to 'center' */
  padding: 2.2rem 2.7vw 0.7rem 2.7vw;
  width: 100%;
  background: var(--header-footer-bg);
  transition: background 0.3s ease;
  flex-wrap: wrap; /* Allows items to wrap onto the next line */
  gap: 10px; /* Provides consistent spacing when items wrap */
}

.header-left,
.header-right {
  flex: 1; /* Makes them take equal available space */
  display: flex;
  align-items: center;
  min-width: 100px; /* Ensure they don't shrink too much */
}

.header-left {
  justify-content: flex-start;
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 50px; /* Ensure vitruvian has some minimum space */
}

.header-right {
  justify-content: flex-end;
  min-width: 120px; /* Keep your existing min-width if necessary for datetime */
}

.logo-img {
  width: 104px; /* Maintain your desired desktop size */
  height: 17px;
  object-fit: contain;
  max-width: 100%; /* Ensures it scales down if container is smaller */
}
.vitruvian-img {
  height: 35px; /* Maintain your desired desktop size */
  width: auto;
  display: inline-block;
  vertical-align: middle;
  max-width: 100%; /* Ensures it scales down if container is smaller */
}

.datetime {
  font-size: 12.2px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-color-primary);
  padding-top: 0.1em;
  transition: color 0.3s ease;
  white-space: nowrap; /* Prevent date/time from breaking */
}

/* CENTER - (Used for homepage central links like CREATIVE, CONCEPT, DESIGN) */
.center-words {
  flex: 1;
  display: flex;
  justify-content: space-around; /* Horizontal distribution for larger screens */
  align-items: center;
  font-size: 1.16rem; /* Using rem for better scalability with root font-size */
  letter-spacing: 1.2px;
  color: var(--text-color-secondary);
  font-weight: 500;
  text-align: center;
  margin: 0;
  height: 100%;
  /* Added padding to prevent links from touching edges on very small screens */
  padding: 20px 10px;
}
/* This div wraps each center-link */
.center-words > div {
  flex: 1;
  min-width: 80px;
  /* Allow text to wrap if it's too long, but for single words, it's fine */
  white-space: nowrap;
}

/* FOOTER */
.main-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end; /* Aligns footer items to the bottom */
  padding: 1.3rem 2.7vw 1.1rem 2.7vw;
  font-size: 0.87rem;
  color: var(--footer-text-color);
  width: 100%;
  background: var(--header-footer-bg);
  transition: background 0.3s ease, color 0.3s ease;
  flex-wrap: wrap; /* Allows items to wrap */
  gap: 10px; /* Consistent spacing */
}
.footer-left,
.footer-center,
.footer-right {
  display: flex;
  align-items: center;
  flex: 1; /* Allow them to grow and shrink */
  min-width: 100px; /* Prevent them from collapsing too much */
}
.footer-left { justify-content: flex-start; }
.footer-center { justify-content: center; }
.footer-right { justify-content: flex-end; }


/* THEME ICON BUTTON (footer) */
.theme-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: none !important;
  border: none;
  padding: 0;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  transition: background 0.2s;
  outline: none;
}
.theme-icon-btn svg {
  width: 18px !important;
  height: 18px !important;
  stroke: var(--theme-icon-stroke);
  background: none;
  display: block;
  margin: 0;
  padding: 0;
  vertical-align: middle;
}
.theme-icon-btn:hover,
.theme-icon-btn:focus { background: var(--button-hover-bg); }


.center-link {
  color: var(--text-color-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: inherit; /* Inherit from .center-words, which uses rem */
  letter-spacing: inherit;
  transition: color 0.2s;
  cursor: pointer;
  display: inline-block;
  padding: 5px 10px; /* Add some padding for touch targets */
}
.center-link:hover { color: var(--text-color-light-hover); text-decoration: underline; }


/* ---- CREATIVE PAGE LAYOUT ---- */
.creative-layout {
  display: flex;
  flex: 1;
  height: 68vh;
  align-items: center;
  justify-content: center;
  padding: 0 2.7vw;
}

.creative-left {
  flex: 1;
}

.creative-center {
  flex: 2;
  text-align: center;
}

.creative-title {
  font-size: 1.23rem;
  color: var(--text-color-secondary);
  letter-spacing: 1.1px;
  font-weight: 500;
}

.creative-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0;
}

.creative-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  text-align: right;
}

.creative-menu li {
  font-size: 1.01rem;
  color: var(--text-color-tertiary);
  margin: 1.1em 0;
  letter-spacing: 1px;
  font-weight: 500;
  cursor: default;
}

.creative-box {
  max-width: 90vw;
  width: 82vw;
  min-width: 360px;
  min-height: 88vh;
  margin: 40px auto;
  background: var(--background-color);
  border-radius: 8px;
  box-shadow: 0 4px 32px 0 rgba(30,30,40,0.13), 0 0 0 2px #2196f3;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}


.creative-menu a,
.creative-link {
  color: var(--text-color-tertiary);
  text-decoration: none;
  font-weight: 500;
  letter-spacing: 1px;
  transition: color 0.2s;
}
.creative-menu a:hover,
.creative-link:hover {
  color: var(--text-color-primary);
  text-decoration: underline;
}

/* LOADER */
.loader-overlay {
  position: fixed; z-index: 2000; inset: 0; background: var(--loader-bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.5s;
}
.creative-loader-word {
  font-size: 1.1rem; font-family: inherit; font-weight: bold;
  letter-spacing: 2.5px; color: var(--loader-text-primary);
  display: flex; gap: 0.06em;
}
.creative-loader-letter { color: var(--loader-text-primary); transition: color 0.18s cubic-bezier(.7,.3,.35,1.35);}
.creative-loader-letter.loaded { color: var(--loader-text-loaded); }

/* --- CINEMA GALLERY STYLES --- */
.carousel-track {
    display: flex;
    align-items: center;
    gap: 5vw;
    padding: 0 calc(50vw - 280px);
    /* Add overflow for horizontal scrolling on smaller screens */
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch; /* for smooth scrolling on iOS */
}
.carousel-item {
    scroll-snap-align: center;
    flex: 0 0 560px; /* Fixed width for desktop */
    height: 315px; /* Fixed height for desktop */
    background-color: var(--carousel-item-bg);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    transform: scale(var(--carousel-item-inactive-scale));
    opacity: var(--carousel-item-inactive-opacity);
    transition: transform 0.5s ease, opacity 0.5s ease, box-shadow 0.5s ease;
    text-decoration: none;
    color: var(--carousel-item-text);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    flex-shrink: 0;
}
.carousel-item.active {
    transform: scale(1);
    opacity: 1;
    box-shadow: var(--carousel-box-shadow-active);
}
.video-title {
    color: var(--carousel-item-text);
    padding: 1rem; /* Added padding for readability */
    font-size: 1.1rem; /* Default font size */
    text-align: center;
    width: 100%; /* Ensure title takes full width */
}


/* --- CONCEPT PAGE SPECIFIC STYLES --- */
.concept-carousel-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    min-height: 60vh;
    padding: 2rem 0;
    background: var(--background-color);
    transition: background 0.3s ease;
}

.concept-track {
    display: flex;
    white-space: nowrap;
    animation: marquee-scroll 60s linear infinite;
    padding: 0 5vw;
}

.concept-track:hover {
    animation-play-state: paused;
}

.concept-logo-item {
    flex-shrink: 0;
    margin: 0 4vw;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: inherit;
    transition: transform 0.3s ease;
}

.concept-logo-item:hover {
    transform: scale(1.05);
}

.concept-logo-img {
    height: 60px;
    width: auto;
    opacity: 0.8;
    transition: opacity 0.3s ease;
    max-width: 100%; /* Ensure logos don't exceed their natural size within item */
}

.concept-logo-item:hover .concept-logo-img {
    opacity: 1;
}

/* Keyframe for Marquee Scroll */
@keyframes marquee-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* --- SOUND DETAIL PAGE STYLES --- */
.content-section {
    max-width: 1600px;
    margin: 0 auto;
    padding: 40px;
    flex-grow: 1;
    box-sizing: border-box;
    background: var(--background-color);
    transition: background 0.3s ease;
}

.sound-detail-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 800px;
    margin: 20px auto;
    padding: 0 20px;
    flex-grow: 1;
    color: var(--text-color-primary);
}

.sound-detail-title {
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--text-color-primary);
    margin-bottom: 40px;
    text-align: center;
    transition: color 0.3s ease;
}

.disc-image {
    position: relative;
    width: 320px;
    height: 320px;
    background-color: var(--sound-disc-bg);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin-bottom: 35px;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.disc-image::before {
    content: '';
    position: absolute;
    width: 90px;
    height: 90px;
    background-color: var(--sound-disc-center-bg);
    border-radius: 50%;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.5);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.play-pause-btn {
    /* Ensure this is also flexible if it's an image or icon */
    display: flex;
    justify-content: center;
    align-items: center;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 2; /* Ensure it's above the ::before pseudo-element */
}

.play-pause-btn svg {
    fill: var(--sound-disc-play-icon-fill);
    width: 36px;
    height: 36px;
    transition: fill 0.3s ease;
}

.sound-progress-container {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 400px; /* Limit progress bar width for readability */
    margin-bottom: 25px;
    gap: 10px; /* Space between time and bar */
}

.current-time, .total-duration {
    font-size: 0.9rem;
    color: var(--sound-progress-text-color);
    min-width: 40px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    transition: color 0.3s ease;
}

.progress-bar {
    -webkit-appearance: none;
    appearance: none;
    flex-grow: 1;
    height: 6px;
    background: linear-gradient(to right, #2ab471 0%, var(--sound-progress-bar-track-bg) 0%);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    transition: background 0.3s ease;
}

.progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #2ab471;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--sound-progress-bar-thumb-border);
    box-shadow: 0 0 5px rgba(0,0,0,0.3);
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.progress-bar::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #2ab471;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--sound-progress-bar-thumb-border);
    box-shadow: 0 0 5px rgba(0,0,0,0.3);
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.sound-description-wrapper {
    text-align: center;
    color: var(--sound-description-color);
    max-width: 650px;
    line-height: 1.7;
    transition: color 0.3s ease;
}

.main-desc {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.sub-desc {
    font-size: 1rem;
    color: var(--sound-progress-text-color);
    transition: color 0.3s ease;
}

/* --- RESPONSIVE ADJUSTMENTS --- */

/* Adjusting existing media queries and adding more specific ones */

/* For screens smaller than 900px */
@media (max-width: 900px) {
  .main-header, .main-footer { padding-left: 1.5vw; padding-right: 1.5vw; } /* Slightly more padding than 1vw */
  .center-words { font-size: 0.96rem; /* margin-top: 8vw; Remove this margin, let flex handle spacing */ }
}

/* For screens smaller than 700px (tablet portrait, larger phones) */
@media (max-width: 700px) {
  .main-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;   /* ✅ force all items on one line */
    padding: 0.4rem 5vw;   /* tighter padding */
  }

  .header-left,
  .header-center,
  .header-right {
    flex: 1;
    display: flex;
    align-items: center;   /* ✅ vertical alignment fix */
  }

  .header-left   { justify-content: flex-start; }
  .header-center { justify-content: center; }
  .header-right  { justify-content: flex-end; }

  /* ✅ Smaller elements */
  .logo-img      { width: 62px; height: auto; }
  .vitruvian-img { height: 18px; width: auto; }
  .datetime {
    font-size: 0.68rem;   /* much smaller clock */
    letter-spacing: 0.06em;
    margin: 0 0.5rem;     /* gap from screen edges */
  }
}




/* For screens smaller than 500px (most phones) */
@media (max-width: 500px) {
  .logo-img { width: 66px; height: auto; } /* Even smaller logo */
  .vitruvian-img { height: 14px; width: auto; } /* Even smaller vitruvian */
  .datetime { font-size: 0.75rem; }

  .main-header, .main-footer {
      padding: 0.8rem 1.5vw; /* Reduce padding slightly more */
  }

  .center-words {
    font-size: 1rem; /* Adjust font size for very small screens */
    gap: 1.2rem;
    margin-top: 3vh;
    margin-bottom: 3vh;
  }

  /* Cinematography Carousel Responsive */
  .carousel-track {
        gap: 4vw; /* Reduce gap */
        padding: 0 calc(50vw - 150px); /* Adjust padding for smaller item size */
    }
    .carousel-item {
        flex-basis: 300px; /* Make items narrower */
        height: 168.75px; /* Maintain 16:9 aspect ratio for 300px width */
    }
    .video-title {
        font-size: 0.8rem;
        padding: 0.5rem;
    }

    /* Sound Detail Page Responsive */
    .disc-image {
        width: 200px; /* Smaller disc */
        height: 200px;
      }
      .disc-image::before {
        width: 60px;
        height: 60px;
      }
      .play-pause-btn svg {
        width: 25px;
        height: 25px;
      }
      .sound-detail-title {
        font-size: 1.8rem;
        margin-bottom: 25px;
      }
      .sound-progress-container {
        max-width: 300px; /* Narrower progress bar */
      }
      .main-desc {
        font-size: 1rem;
      }
      .sub-desc {
        font-size: 0.9rem;
      }
}

/* Responsive adjustments for Creative Layout */
@media (max-width: 900px) {
  .creative-box {
    width: 95vw; /* Slightly less than 99vw */
    min-width: unset; /* Allow it to shrink below 360px if needed */
    margin: 12px auto;
    box-shadow: var(--carousel-box-shadow-active); /* Use variable for consistency */
  }
  .creative-layout {
    flex-direction: column;
    height: auto;
    padding: 20px 2.7vw; /* Add vertical padding */
  }
  .creative-left, .creative-center, .creative-right {
    width: 100%; /* Take full width when stacked */
    justify-content: center; /* Center content */
    text-align: center;
  }
  .creative-left { order: 2; margin-top: 1.5rem; } /* Reorder if desired, or remove */
  .creative-center { order: 1; margin-bottom: 1.5rem; }
  .creative-right { order: 3; margin-top: 1.5rem; }

  .creative-menu {
    text-align: center; /* Center the menu items */
  }
}

/* Specific adjustments for Concept Logos at different screen sizes */
@media (max-width: 1200px) {
    .concept-logo-img {
        height: 55px;
    }
}

@media (max-width: 992px) {
    .concept-logo-img {
        height: 50px;
    }
    .concept-logo-item {
        margin: 0 3.5vw;
    }
    .concept-track {
      animation-duration: 50s;
    }
}

@media (max-width: 768px) {
    .concept-logo-img {
        height: 45px;
    }
    .concept-logo-item {
        margin: 0 3vw;
    }
    .concept-track {
      animation-duration: 45s;
    }
}

@media (max-width: 576px) {
    .concept-logo-img {
        height: 40px;
    }
    .concept-logo-item {
        margin: 0 2.5vw;
    }
    .concept-track {
      animation-duration: 40s;
    }
}

@media (max-width: 400px) {
    .concept-logo-img {
        height: 35px;
    }
    .concept-logo-item {
        margin: 0 2vw;
    }
    .concept-track {
      animation-duration: 35s;
    }
}

#toggle-theme {
  display: flex !important;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 9999;     /* stays above other elements */
}

/* Mobile-specific fix */
@media (max-width: 700px) {
  .footer-right {
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }

  #toggle-theme {
    width: 30px;
    height: 30px;
    margin-left: 8px;   /* small spacing from edge */
  }
}