@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;800&display=swap');

:root {
  --glass-bg: rgba(255, 255, 255, 0.15);
  --glass-border: rgba(255, 255, 255, 0.3);
  --text-primary: #ffffff;
  --text-secondary: #e0e0e0;
  --accent-color: #ff9800;
  --font-main: 'Nunito', sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body, html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: var(--font-main);
  background-color: #121212;
  color: var(--text-primary);
  overflow: hidden; /* Prevent body scroll, everything is in the app container */
}

/* Dynamic Background */
.background-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  filter: blur(20px) brightness(0.4);
  transform: scale(1.1); /* Prevent blur edges */
  z-index: -1;
  transition: background-image 1.5s ease-in-out;
}

/* Main App Layout */
.app-container {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px;
  gap: 20px;
}

.app-container > * {
  min-width: 0;
}

/* Header & Story Carousel */
.top-bar {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
  min-width: 0; /* Prevent flex blowout */
  width: 100%;
}

.top-bar h1 {
  margin: 0;
  font-size: 2.2rem;
  font-weight: 800;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
  text-align: center;
}

.carousel-container {
  display: flex;
  overflow-x: auto;
  width: 100%;
  max-width: 1200px;
  gap: 15px;
  padding: 10px;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none; /* Firefox */
  min-width: 0; /* Prevent flex blowout */
}
.carousel-container::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.story-card {
  flex: 0 0 auto;
  width: 140px;
  scroll-snap-align: start;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.story-card.active {
  transform: scale(1.05) translateY(-5px);
  border-color: var(--accent-color);
  box-shadow: 0 8px 25px rgba(255, 152, 0, 0.4);
}

.story-card:hover {
  transform: translateY(-5px);
}

.story-card img {
  width: 100%;
  height: 100px;
  object-fit: cover;
}

.story-card h3 {
  font-size: 0.9rem;
  margin: 8px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main Content Area: Split View */
.main-stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  height: 100%;
  min-height: 0; /* Allows grid items to shrink */
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.main-stage > * {
  min-width: 0;
}

/* Left: Animated Image Viewer */
.image-viewer {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  background: rgba(0,0,0,0.3);
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

#story-image {
  width: 100%;
  height: 100%;
  object-fit: contain; /* Don't crop the image */
  transition: opacity 1s ease-in-out;
}

/* Ken Burns Animation Class */
.ken-burns {
  animation: kenburns 15s infinite alternate ease-in-out;
}

@keyframes kenburns {
  0% { transform: scale(1); }
  100% { transform: scale(1.08); }
}

/* Right: Teleprompter / Subtitles */
.transcript-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 30px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-height: 0; /* Extremely important for grid shrinking */
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  scrollbar-width: thin;
  scrollbar-color: var(--accent-color) transparent;
}

.transcript-panel::-webkit-scrollbar {
  width: 6px;
}
.transcript-panel::-webkit-scrollbar-thumb {
  background-color: var(--accent-color);
  border-radius: 10px;
}

#story-title {
  font-size: 2.2rem;
  margin-top: 0;
  margin-bottom: 20px;
  color: var(--accent-color);
  text-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.story-text {
  font-size: 1.6rem;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap; /* Respect newlines */
}

/* Floating Audio Player Dock */
.audio-dock {
  background: rgba(20, 20, 20, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 100px;
  padding: 15px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  gap: 20px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 15px;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, color 0.2s;
  padding: 10px;
  border-radius: 50%;
}

.btn-icon:hover {
  transform: scale(1.1);
  color: var(--accent-color);
  background: rgba(255, 255, 255, 0.1);
}

.btn-icon.play-btn {
  background: var(--accent-color);
  color: #000;
  width: 60px;
  height: 60px;
}

.btn-icon.play-btn:hover {
  background: #ffb74d;
  transform: scale(1.1);
}

.btn-icon .material-icons {
  font-size: 32px;
}
.btn-icon.play-btn .material-icons {
  font-size: 40px;
}

.progress-container {
  flex-grow: 1;
  display: flex;
  align-items: center;
  gap: 15px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.progress-bar {
  flex-grow: 1;
  height: 8px;
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent-color);
  width: 0%;
  border-radius: 4px;
  transition: width 0.1s linear;
}

/* Responsive Design */
/* Responsive Design */
@media (max-width: 1050px) {
  .main-stage {
    grid-template-columns: 1fr;
    grid-template-rows: 40vh 1fr;
    gap: 15px;
  }
  .app-container {
    padding: 10px;
    gap: 10px;
  }
  .audio-dock {
    border-radius: 24px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 15px;
  }
  .top-bar h1 {
    font-size: 1.6rem;
  }
  .story-text {
    font-size: 1.3rem;
  }
  .transcript-panel {
    padding: 20px;
  }
}

@media (max-width: 600px) {
  .main-stage {
    grid-template-rows: 30vh 1fr;
  }
  .top-bar h1 {
    font-size: 1.3rem;
  }
  .story-card {
    width: 110px;
  }
  .story-card img {
    height: 80px;
  }
  .transcript-panel {
    padding: 15px;
    border-radius: 16px;
  }
  #story-title {
    font-size: 1.5rem;
    margin-bottom: 10px;
  }
  .story-text {
    font-size: 1.1rem;
    line-height: 1.4;
  }
  .audio-dock {
    padding: 10px;
  }
  .btn-icon.play-btn {
    width: 50px;
    height: 50px;
  }
  .btn-icon.play-btn .material-icons {
    font-size: 32px;
  }
}
