/* ──────────────────────────────────────────────────
   Reset & Base
─────────────────────────────────────────────────── */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: Arial, sans-serif;
  background-color: #fff;
  color: #333;
}

/* ──────────────────────────────────────────────────
   3-Column Grid for Articles
─────────────────────────────────────────────────── */
#articles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  padding: 1rem;
}
.article {
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
}
.article img {
  width: 100%;
  height: auto;
  object-fit: cover;
}
.article-content {
  padding: 0.75rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.article-content h2 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.pub-date {
  font-size: 0.85rem;
  color: #999;
  margin-top: 4px;
}


/* Space buttons in footer */
.article-footer {
  display: flex;
  gap: 1rem;
  margin-top: auto;
}

/* Button styles */
.article-footer button {
  color: #0073e6;
  text-decoration: none;
  font-weight: bold;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0.75rem;
  font-size: 0.9rem;
}

/* circled play/pause button */
.play-podcast {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 1rem;       /* wider padding to keep text on one line */
  font-weight: bold;          /* bold label */
  font-size: 0.9rem;          /* maintain readable size */
  white-space: nowrap;        /* never wrap “Play Podcast” */
  border: 2px solid #0073e6;
  border-radius: 4px;         /* slightly rounded (not a circle) */
  background: none;
  color: #0073e6;
  cursor: pointer;
  text-transform: uppercase;  /* force all caps */
}
.play-podcast::before {
  content: '▶';
  font-size: 1rem;
  color: #0073e6;
  margin-right: 0.5rem;       /* space between icon and text */
}
.play-podcast.playing::before {
  content: '⏸';
  color: #e60000;
}
.play-podcast.playing {
  font-weight: bold;
}

.hidden {
  display: none;
}

/* create-podcast (text button) */
.create-podcast {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 1rem;       /* match Play-Podcast padding */
  font-weight: bold;          /* bold label */
  font-size: 0.9rem;
  white-space: nowrap;        /* never wrap “Create Podcast” */
  border: 2px solid #0073e6;
  border-radius: 4px;
  background: none;
  color: #0073e6;
  cursor: pointer;
  text-transform: uppercase;  /* force all caps */
}

/* Ensure the “Read” button is also bold and spaced nicely */
.read-article {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 1rem;
  font-weight: bold;          /* bold label */
  font-size: 0.9rem;
  white-space: nowrap;        /* keep “Read” on one line */
  border: 2px solid transparent; /* no border, but keep same height */
  background: none;
  color: #0073e6;
  cursor: pointer;
}

/* ──────────────────────────────────────────────────
   Loading Indicator
─────────────────────────────────────────────────── */
#loading {
  text-align: center;
  padding: 1rem;
  font-size: 1rem;
  color: #555;
}

/* ──────────────────────────────────────────────────
   Read-In-App Modal
─────────────────────────────────────────────────── */
#modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow: auto;
  align-items: flex-start;
  padding-top: 2rem;
}
#modal-content {
  background: #fff;
  padding: 1.5rem;
  border-radius: 8px;
  max-width: 800px;
  width: 100%;
  position: relative;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}
#modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  font-size: 1.5rem;
  cursor: pointer;
}
#modal-image {
  max-width: 100%;
  height: auto;
  margin: 1rem 0;
}

/* Article text styling */
#modal-text {
  white-space: normal;       /* reset pre-wrap to use paragraphs */
  margin-top: 1rem;
}
#modal-text p {
  margin-bottom: 1rem;       /* space between paragraphs */
  line-height: 1.6;          /* comfortable line spacing */
  color: #333;               /* good contrast */
  font-size: 1rem;           /* readable size */
  font-family: Arial, sans-serif; /* match base font */
  text-align: left;          /* left-align text */
}

/* Show the “Original →” link inside the modal */
#modal-original {
  display: inline-block;
  margin-top: 1rem;
  color: #0073e6;
  text-decoration: none;
  font-weight: bold;
}

/* Reader typography tweaks */
#modal-content {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-size: 1.1rem;
  line-height: 1.6;
  color: #333;
}
#modal-content h2 {
  font-family: 'Segoe UI', Tahoma, sans-serif;
  margin-bottom: 0.5rem;
}

/* ──────────────────────────────────────────────────
   Floating Audio Player
─────────────────────────────────────────────────── */
#audio-player-container {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #ffffffee;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.2);
  padding: 0.5rem 1rem 1rem;
  display: none;
  z-index: 9999;
}
#audio-close {
  float: right;
  font-size: 1.5rem;
  margin-bottom: 0.3rem;
  cursor: pointer;
  font-weight: bold;
  color: #888;
}
#audio-player-container audio {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  display: block;
}
#audio-controls {
  margin-top: 0.5rem;
  text-align: center;
}
#audio-controls button,
#audio-controls select {
  margin: 0 0.5rem;
  padding: 0.3rem 0.75rem;
  font-size: 0.9rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #f0f0f0;
  cursor: pointer;
}
#audio-controls label {
  font-size: 0.9rem;
  margin-left: 0.5rem;
}

/* ──────────────────────────────────────────────────
   Back to Top Button
─────────────────────────────────────────────────── */
#back-to-top {
  position: fixed;
  bottom: 80px;
  right: 20px;
  z-index: 9999;
  background: #0073e6;
  color: white;
  border: none;
  padding: 0.5rem 0.75rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.25rem;
  display: none;
}

/* ──────────────────────────────────────────────────
   Podcast-creation Overlay
─────────────────────────────────────────────────── */
#podcast-modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
#podcast-modal-content {
  background: #fff;
  padding: 1rem 2rem;
  border-radius: 8px;
  font-size: 1rem;
  color: #333;
  text-align: center;
}

/* Indeterminate Progress Bar for Podcast Generation */
#podcast-progress-container {
  width: 80%;
  margin: 0.5rem auto 0;
  background-color: #f0f0f0;
  border-radius: 4px;
  overflow: hidden;
  height: 8px;
  display: none;
}
#podcast-progress-bar {
  width: 30%;
  height: 100%;
  background-color: #0073e6;
  animation: progress-indeterminate 1.5s infinite;
}
@keyframes progress-indeterminate {
  0%   { margin-left: -30%; }
  50%  { margin-left: 50%; }
  100% { margin-left: 100%; }
}

/* Sticky only on mobile */
@media screen and (max-width: 768px) {
  #articles {
    grid-template-columns: 1fr;
  }
  #audio-player-container {
    bottom: 0;
    left: 0;
  }
}
