/* --- General Styles --- */
body {
  font-family: "Crimson Text", sans-serif;
  margin: 0;
  overflow-x: hidden;
}

p {
  line-height: 2;
  text-indent: 30px;
}

/* --- Sidebar Styles --- */
.sidebar {
  font-family: "Crimson Text", sans-serif;
  height: 100%;
  width: 350px;
  position: fixed;
  z-index: 1;
  top: 0;
  left: 0;
  background-color: #a41e34;
  overflow-x: hidden;
  overflow-y: auto;
  transition: transform 0.5s ease;
  transform: translateX(-350px);
  padding-top: 0;
  box-shadow: 2px 0 5px rgba(0,0,0,0.2);
}

.sidebar a {
  padding: 12px 24px;
  text-decoration: none;
  font-size: 18px;
  color: #ffffff;
  display: block;
  transition: background-color 0.3s, color 0.3s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar a:hover {
  background-color: #d32d45;
  color: #ffffff;
}

.sidebar a.active {
    background-color: #8c1a2b;
    font-weight: bold;
}

.breadcrumb {
  color: white;
  text-align: left;
  padding: 16px 24px;
  font-size: 20px;
  background-color: #8c1a2b;
  font-weight: bold;
  position: sticky;
  top: 0;
  z-index: 2;
}

.breadcrumb span {
    cursor: pointer;
}
.breadcrumb span:hover {
    text-decoration: underline;
}

/* --- Toggle Button Styles --- */
.openbtn {
  font-size: 20px;
  cursor: pointer;
  background-color: #a41e34;
  color: white;
  padding: 0;
  border: none;
  position: fixed;
  top: 5px;
  left: 5px;
  width: 40px;
  height: 40px;
  text-align: center;
  line-height: 40px;
  transition: transform 0.5s ease, background-color 0.3s;
  z-index: 3;
  border-radius: 3px;
}

.openbtn:hover {
  background-color: #d32d45;
}

.arrow {
  display: inline-block;
  transform: rotate(0deg);
  transition: transform 0.3s;
}

.sidebar.open {
    transform: translateX(0px);
}
.openbtn.open {
  transform: translateX(350px);
}
.openbtn.open .arrow {
  transform: rotate(180deg);
}

/* --- Main Content Area Styles --- */
#main {
  transition: margin-left .5s ease;
  padding: 16px;
  padding-top: 60px;
  margin-left: 0;
}

#main.shifted {
    margin-left: 350px;
}

#mainContent {
  line-height: 1.6;
}



.audio-widget-header {
  cursor: move;
  touch-action: none;
  background-color: #a41e34;
  color: white;
  border-bottom: 1px solid #8c1a2b;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 38px;
  padding: 0 8px 0 10px;
  box-sizing: border-box;
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
}

.audio-widget-header .drag-handle {
  font-size: 18px;
  margin-right: 10px;
  cursor: grab;
}
.audio-widget-header:active {
    cursor: grabbing;
}

.audio-widget-header .audio-info {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  font-size: 14px;
  padding: 0 8px;
}

.audio-info-track {
  display: inline-block;
  white-space: nowrap;
}

.audio-info.is-overflowing {
  text-align: left;
}

.audio-info.is-overflowing .audio-info-track {
  padding-left: 100%;
  animation: scroll-audio-title 12s linear infinite;
}

.audio-info.is-overflowing:hover .audio-info-track {
  animation-play-state: paused;
}

@keyframes scroll-audio-title {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

@media (prefers-reduced-motion: reduce) {
  .audio-info.is-overflowing .audio-info-track {
    animation: none;
    padding-left: 0;
    text-overflow: ellipsis;
    max-width: 100%;
    overflow: hidden;
  }
}

#miniToggleBtn {
  position: relative;
  z-index: 3;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  line-height: 1;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

#miniToggleBtn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

/* Visible hover labels supplement the native title and accessible name. */
#audioWidget button[data-tooltip] {
  position: relative;
}

#audioWidget button[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 7px);
  transform: translateX(-50%) translateY(3px);
  width: max-content;
  max-width: 180px;
  padding: 5px 8px;
  border-radius: 4px;
  background: rgba(35, 26, 28, 0.94);
  color: #fff;
  font-family: "Crimson Text", sans-serif;
  font-size: 13px;
  font-weight: normal;
  line-height: 1.15;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 10;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
}

#audioWidget button[data-tooltip]:hover::after,
#audioWidget button[data-tooltip]:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

#miniToggleBtn[data-tooltip]::after {
  top: 50%;
  right: calc(100% + 8px);
  bottom: auto;
  left: auto;
  transform: translateY(-50%) translateX(3px);
}

#miniToggleBtn[data-tooltip]:hover::after,
#miniToggleBtn[data-tooltip]:focus-visible::after {
  transform: translateY(-50%) translateX(0);
}

.audio-widget-header .close-widget-btn {
  background: none;
  border: none;
  color: white;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  padding: 0 5px;
  line-height: 1;
}
.audio-widget-header .close-widget-btn:hover {
  color: #f0f0f0;
}

.audio-widget-content {
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#audioPlayer {
    display: none;
}


.audio-source-selector label {
    font-size: 14px;
    color: #333;
    white-space: nowrap;
}

.audio-source-selector select {
    font-family: inherit; /* Use body font */
    font-size: 14px;
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    flex-grow: 1; /* Allow select to take available space */
    max-width: 150px; /* Prevent it getting too wide */
    cursor: pointer;
}
/* ******************************************* */


.audio-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  margin-bottom: 8px; /* Reduced margin */
  width: 100%;
}

.audio-controls button {
  background-color: #a41e34;
  color: white;
  border: none;
  padding: 6px 10px;
  font-size: 18px;
  cursor: pointer;
  border-radius: 4px;
  transition: background-color 0.3s;
  line-height: 1;
}

.audio-controls button:hover {
  background-color: #d32d45;
}
.audio-controls button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.progress-container {
    width: 95%;
    margin-top: 5px;
}

#seekBar {
    width: 100%;
    cursor: pointer;
    height: 8px;
    accent-color: #a41e34;
}
#seekBar:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}
/* Base widget: floating panel (normal mode, compact) */
#audioWidget {
  position: fixed;
  box-sizing: border-box;
  top: 20px;
  right: 20px;
  width: 320px;

  min-width: 260px;
  max-width: 520px;
 
  height: 126px;

  min-height: 118px;
  max-height: 260px;

  background-color: #f8f8f8;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.25);
  z-index: 1000;
  display: block;
  font-family: "Crimson Text", sans-serif;
  resize: both;
  overflow: hidden;
 

}

/* -------- MINI MODE -------- */
#audioWidget.mini-mode {
  width: 60px;
  height: 60px;
  min-width: 0;
  min-height: 0;
  max-width: none;
  max-height: none;

  border-radius: 50%;
  padding: 0;
  background-color: #a41e34;          /* crimson bubble */
  border: 2px solid rgba(255,255,255,0.82);
  box-shadow: 0 6px 18px rgba(0,0,0,0.28);

  display: flex;
  justify-content: center;
  align-items: center;

  overflow: visible;                  
  resize: none;                       
  touch-action: none;
}

/* Hide everything we don't want in mini mode */
#audioWidget.mini-mode .audio-widget-header,
#audioWidget.mini-mode #miniToggleBtn,
#audioWidget.mini-mode #rewindBtn,
#audioWidget.mini-mode #fastForwardBtn,
#audioWidget.mini-mode .progress-container,
#audioWidget.mini-mode audio {
  display: none !important;
}

/* Use the content area as the circle interior */
.audio-widget-content {
  position: relative;   /* so restore button can be positioned inside */
}

/* In mini mode, center the play/pause button */
#audioWidget.mini-mode .audio-widget-content {
  width: 100%;
  height: 100%;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Big central play/pause icon, white on crimson */
#audioWidget.mini-mode #playPauseBtn {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 26px;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

#audioWidget.mini-mode #playPauseBtn:hover {
  background: rgba(255,255,255,0.12);
}

/* Default: hide restore button in normal mode */
#restoreBtn {
  display: none;
}

/* Mini mode: clear exit control, distinct from a browser resize handle. */
#audioWidget.mini-mode #restoreBtn {
  display: flex;
  position: absolute;
  bottom: 6px;
  right: 6px;

  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;

  font-size: 17px;
  line-height: 1;
  align-items: center;
  justify-content: center;
  cursor: pointer;

  background:#a41e34;
  color: white;
  padding: 0;
  z-index: 4;
  pointer-events: auto;
}

/* Phone/tablet sidebar: overlay the page instead of pushing it off-screen. */
@media screen and (max-width: 768px) {
  .sidebar {
    width: min(320px, calc(100vw - 48px));
    transform: translateX(-100%);
    box-shadow: 4px 0 18px rgba(0,0,0,0.28);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  #main,
  #main.shifted {
    margin-left: 0;
  }

  .openbtn {
    top: 8px;
    left: 8px;
    z-index: 4;
  }
}
