/* ============================================================
   Good News Radio — Premium Dark Theme
   ============================================================ */

/* --- Design Tokens --- */
:root {
  /* Base palette */
  --bg-deep: #111111; 
  --bg-surface: rgba(0, 0, 0, 0.4); 
  --bg-surface-hover: rgba(255, 255, 255, 0.05);
  --bg-input: rgba(255, 255, 255, 0.1); 

  /* Accent gradient */
  --accent-start: #D9534F; /* Deeper terracotta */
  --accent-end: #E67A53;   /* Rich orange */
  --accent-mid: #DF6951;   
  --accent-gradient: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  --accent-glow: rgba(217, 83, 79, 0.25);

  /* CTA (Main Buttons) */
  --cta-start: #222222; 
  --cta-end: #333333;
  --cta-gradient: linear-gradient(135deg, var(--cta-start), var(--cta-end));

  /* Text - High Contrast */
  --text-primary: #FFFFFF; 
  --text-secondary: rgba(255, 255, 255, 0.8); 
  --text-muted: rgba(255, 255, 255, 0.6); 

  /* Glass */
  --glass-border: rgba(255, 255, 255, 0.1); 
  --glass-blur: 16px;

  /* Radius */
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --radius-xl: 40px;

  /* Shadows - Clean lift without wide muddy cast */
  --shadow-card: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px var(--glass-border);
  --shadow-glow: 0 20px 40px rgba(0, 0, 0, 0.15);

  /* Fonts */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 0.2s var(--ease-out);
  --transition-med: 0.35s var(--ease-out);
  --transition-slow: 0.5s var(--ease-out);
}

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

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: var(--bg-deep); 
  border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2); 
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-deep); /* creates padding around thumb */
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3); 
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) var(--bg-deep);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@media (max-height: 1000px) {
  html { font-size: 15px; }
}

@media (max-height: 900px) {
  html { font-size: 14px; }
}

@media (max-height: 800px) {
  html { font-size: 13px; }
}

@media (max-height: 700px) {
  html { font-size: 12px; }
}

body {
  font-family: var(--font-sans);
  background: var(--bg-deep) url('/assets/newsroom%20-%20landing%20page%20bg.png') center calc(50% - 50px) / cover fixed;
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: -2;
}

body::after {
  content: '';
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 35vh;
  background: linear-gradient(to bottom, transparent 0%, #000000 100%);
  z-index: -1;
  pointer-events: none;
}

/* --- Animated Background Glows --- */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(140px);
  opacity: 0.8;
  pointer-events: none;
  z-index: 0;
  animation: glow-drift 20s ease-in-out infinite alternate;
}

.bg-glow--1 {
  width: 90vw;
  height: 90vh;
  background: #FFEBE1; /* Soft peach */
  top: -20%;
  left: -20%;
  animation-duration: 22s;
}

.bg-glow--2 {
  width: 80vw;
  height: 80vh;
  background: #E8F3E9; /* Soft pale green */
  bottom: -20%;
  right: -20%;
  animation-duration: 28s;
  animation-delay: -10s;
}

.bg-glow--3 {
  width: 70vw;
  height: 70vh;
  background: #FFF7D6; /* Pale warm yellow */
  top: 40%;
  left: 40%;
  transform: translate(-50%, -50%);
  opacity: 0.6;
  animation-duration: 35s;
  animation-delay: -15s;
}

@keyframes glow-drift {
  0% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.05); }
  66% { transform: translate(-20px, 30px) scale(0.95); }
  100% { transform: translate(10px, -10px) scale(1.02); }
}

/* --- App Container --- */
.app-container {
  width: 95%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  justify-content: center;
}

/* --- Layout --- */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 2rem;
  align-items: start;
  transition: max-height 0.6s var(--ease-out), opacity 0.6s var(--ease-out), margin 0.6s var(--ease-out), gap 0.6s var(--ease-out);
  max-height: 2000px;
  opacity: 1;
  overflow: hidden;
}

.main-layout.collapsed {
  max-height: 0;
  opacity: 0;
  margin: 0;
  padding: 0;
  gap: 0;
}

@media (min-width: 860px) {
  .main-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 2rem;
  }
}

.layout-left, .layout-right {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* --- Header --- */
.app-header {
  margin-bottom: 1.25rem;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-icon {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  animation: pulse-subtle 4s ease-in-out infinite;
}

@keyframes pulse-subtle {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 6px var(--accent-glow)); }
  50% { transform: scale(1.05); filter: drop-shadow(0 0 14px var(--accent-glow)); }
}

.app-header h1 {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.tagline {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 400;
  margin-top: 2px;
}

.settings-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.settings-link:hover {
  color: var(--accent-start);
  border-color: rgba(255, 65, 108, 0.3);
  box-shadow: 0 0 20px rgba(255, 65, 108, 0.15);
  transform: rotate(45deg);
}

/* --- Glass Panels --- */
.glass-panel {
  background: var(--bg-surface);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  animation: panel-enter 0.5s var(--ease-out) both;
}

@keyframes panel-enter {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Controls Panel --- */
.controls-panel {
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 560px) {
  .controls-grid { grid-template-columns: 1fr; }
}
.control-group, .field-group {
  margin-bottom: 0.5rem;
}

.control-group:last-child, .field-group:last-child {
  margin-bottom: 0;
}
.control-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.length-input-wrapper {
  position: relative;
}

.length-input-wrapper input {
  width: 100%;
  padding: 0.75rem 5rem 0.75rem 1rem;
  background: var(--bg-input);
  border: 2px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 500;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  -moz-appearance: textfield;
}

.length-input-wrapper input::-webkit-inner-spin-button,
.length-input-wrapper input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.length-input-wrapper input:focus {
  outline: none;
  border-color: var(--accent-start);
  box-shadow: 0 0 0 3px rgba(255, 65, 108, 0.15);
}

.input-suffix {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  color: var(--text-muted);
  pointer-events: none;
}

/* --- Form Elements --- */
select, .custom-select {
  width: 100%;
  height: 44px;
  padding: 0.5rem 2.5rem 0.5rem 1rem;
  background: var(--bg-input);
  border: 2px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1rem;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1em;
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.voice-row {
  display: flex;
  gap: 0.5rem;
}

.voice-row select:focus {
  outline: none;
  border-color: var(--accent-start);
  box-shadow: 0 0 0 3px rgba(255, 65, 108, 0.15);
}

/* --- Hour Grid --- */
.hour-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
}

@media (max-width: 600px) {
  .hour-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 400px) {
  .hour-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.hour-toggle {
  position: relative;
  display: block;
}

.hour-toggle input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.hour-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 36px;
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.hour-toggle input:checked ~ .hour-toggle-btn {
  background: var(--accent-start);
  color: white;
  border-color: var(--accent-start);
}

.hour-toggle:hover .hour-toggle-btn {
  border-color: var(--accent-start);
}

.hour-toggle input:focus ~ .hour-toggle-btn {
  box-shadow: 0 0 0 2px rgba(255, 65, 108, 0.2);
}

.voice-row select option {
  background: #281441;
  color: var(--text-primary);
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.icon-btn:hover:not(:disabled) {
  color: var(--accent-start);
  border-color: rgba(255, 65, 108, 0.3);
  background: rgba(255, 65, 108, 0.08);
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.distribution-section {
}

.section-subtitle {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.sliders-grid {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.slider-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.slider-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-start);
  min-width: 3rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Custom range slider */
.dist-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  outline: none;
  transition: background var(--transition-fast);
}

.dist-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-gradient);
  cursor: pointer;
  border: 2px solid var(--bg-deep);
  box-shadow: 0 0 8px var(--accent-glow);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.dist-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 16px var(--accent-glow);
}

.dist-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-gradient);
  cursor: pointer;
  border: 2px solid var(--bg-deep);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* --- Buttons --- */
.action-row {
  display: flex;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 2rem;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all var(--transition-med);
  text-decoration: none;
  line-height: 1;
}

.btn--primary {
  background: var(--cta-gradient);
  color: #fff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.btn--primary:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.btn--primary:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.btn--glow {
  position: relative;
}

.btn--glow::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: var(--cta-gradient);
  filter: blur(14px);
  opacity: 0;
  z-index: -1;
  transition: opacity var(--transition-med);
}

.btn--glow:hover::before {
  opacity: 0.3;
}

.btn--secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}

.btn--secondary:hover {
  border-color: rgba(255, 65, 108, 0.3);
  box-shadow: 0 0 20px rgba(255, 65, 108, 0.1);
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* --- Status Area --- */
.status-area {
  text-align: center;
  padding: 1rem 0;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.status-text {
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.status-text strong {
  color: var(--accent-start);
  font-weight: 600;
}

.status-text.status-error {
  color: #f87171;
}

/* --- Loader: Radio Wave Animation --- */
.loader-wave {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 28px;
}

.loader-wave span {
  display: block;
  width: 4px;
  border-radius: 2px;
  background: var(--accent-gradient);
  animation: wave-bounce 1.2s ease-in-out infinite;
}

.loader-wave span:nth-child(1) { animation-delay: 0s; height: 10px; }
.loader-wave span:nth-child(2) { animation-delay: 0.1s; height: 18px; }
.loader-wave span:nth-child(3) { animation-delay: 0.2s; height: 28px; }
.loader-wave span:nth-child(4) { animation-delay: 0.1s; height: 18px; }
.loader-wave span:nth-child(5) { animation-delay: 0s; height: 10px; }

@keyframes wave-bounce {
  0%, 100% { transform: scaleY(0.4); opacity: 0.5; }
  50% { transform: scaleY(1); opacity: 1; }
}

/* --- Editor Panel --- */
.editor-panel {
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--glass-border);
}

.panel-title svg {
  color: var(--accent-start);
  flex-shrink: 0;
}

#script-editor {
  width: 100%;
  flex: 1;
  min-height: 280px;
  padding: 1rem 1.25rem;
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.7;
  resize: vertical;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.editor-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
}

#generate-action-area {
  transition: max-height 0.6s var(--ease-out), opacity 0.6s var(--ease-out), margin 0.6s var(--ease-out);
  max-height: 500px;
  opacity: 1;
  overflow: hidden;
}

#generate-action-area.collapsed {
  max-height: 0 !important;
  opacity: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

#script-editor:focus {
  outline: none;
  border-color: var(--accent-start);
  box-shadow: 0 0 0 3px rgba(255, 65, 108, 0.12);
}

#script-editor::placeholder {
  color: var(--text-muted);
}

/* --- Output Panel --- */
.output-panel {
}

.audio-player-wrapper {
  margin: 1rem 0;
}

#audio-player {
  width: 100%;
  border-radius: var(--radius-sm);
  outline: none;
}

/* Style native audio controls in supported browsers */
audio::-webkit-media-controls-panel {
  background: var(--bg-input);
}

/* --- Footer --- */
.app-footer {
  text-align: center;
  padding: 2rem 0 1rem;
  border-top: 1px solid var(--glass-border);
  margin-top: 1rem;
}

.app-footer p {
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 500;
}

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  background: rgba(15, 20, 45, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-size: 0.9rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.4s var(--ease-out);
  max-width: 360px;
}

.toast--error {
  border-color: rgba(248, 113, 113, 0.3);
  color: #fca5a5;
}

.toast--success {
  border-color: rgba(52, 211, 153, 0.3);
  color: #6ee7b7;
}

.toast.toast-out {
  animation: toast-out 0.3s var(--ease-out) forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* --- Generation Overlay --- */
.generation-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 10, 20, 0.9);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s var(--ease-out);
}

.generation-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.animated-text-container {
  text-align: center;
  font-family: var(--font-sans);
  font-size: 3rem;
  font-weight: 700;
  color: white;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
}

.animated-phrase {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) translateY(30px);
  opacity: 0;
  width: 100%;
  padding: 0 2rem;
  animation: slidePhrase 2.5s var(--ease-out) forwards;
}

@keyframes slidePhrase {
  0% { opacity: 0; transform: translate(-50%, -50%) translateY(30px); }
  10% { opacity: 1; transform: translate(-50%, -50%) translateY(0); }
  90% { opacity: 1; transform: translate(-50%, -50%) translateY(0); }
  100% { opacity: 0; transform: translate(-50%, -50%) translateY(-30px); }
}


/* --- Responsive --- */
@media (max-width: 480px) {
  .app-container {
    padding: 1rem 0.75rem 2rem;
  }

  .app-header h1 {
    font-size: 1.4rem;
  }

  .glass-panel {
    padding: 1.25rem;
    border-radius: var(--radius-md);
  }

  .btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
  }

  .logo-icon {
    width: 40px;
    height: 40px;
  }
}
