/* === THEME VARIABLES === */
:root {
  color-scheme: light dark;
  --color-surface: #f8f8f8;
  --color-on-surface: #111;
  --color-surface-container: #fff;
  --color-card-shadow: rgba(0, 0, 0, 0.15);
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-surface: #121212;
    --color-on-surface: #eee;
    --color-surface-container: #1e1e1e;
    --color-card-shadow: rgba(0, 0, 0, 0.6);
  }
}

/* === BASE === */
html {
  margin: 0;
}

body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: "Atkinson Hyperlegible Next", sans-serif;
  background: var(--color-surface);
  color: var(--color-on-surface);
  margin: 0;
  width: 100%;
  min-height: 100vh;
}

.main-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 960px; /*for desktops */
  width: 100%; /*for mobile*/
}

header,
footer {
  text-align: center;
  padding: 1.5rem;
}

footer {
  margin-top: auto;
  opacity: 0.6;
  font-size: 0.8rem;
}

/* TITLE */
#title {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  margin: 0 auto 10px;
}

#title svg {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.subtitle {
  font-size: 1.2rem;
}

/* CARD */
main {
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
}

.card {
  background: var(--color-surface-container);
  border-radius: 16px;
  box-shadow: 0 2px 8px var(--color-card-shadow);
  padding: 1.8rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.stream-input-container {
  display: flex;
  position: relative;
}

.stream-input {
  position: relative;
  flex: 1;
  margin-right: 1rem;
  width: 100%;
}

.stream-input-text {
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 0.6rem;
  font-size: 1rem;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stream-input-tooltip {
  position: absolute;
  bottom: 100%;
  left: 0;
  transform: translateY(-12px);
  background: #333;
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  display: none;
  z-index: 10;
}

.stream-input-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 2rem;
  border-width: 12px 6px 0 6px;
  border-style: solid;
  border-color: #333 transparent transparent transparent;
}

.stream-input-container:hover .stream-input-tooltip {
  display: block;
}

.load-button-container {
  flex: 0 auto;
  margin-left: 1rem;
}

/* STATUS */
.player-status {
  text-align: left;
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  font-size: 1.1rem;
  background: rgba(0, 0, 0, 0.05);
  transition: background 0.3s, color 0.3s;
}
.player-status.playing {
  color: #000;
}
.player-status.live {
  color: #c0eb34;
  font-weight: bold;
}
.player-status.error {
  background: rgba(255, 0, 0, 0.15);
  color: #b00020;
}

/* SLIDER DELAY */
.slider-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.delay-slider-label-container {
  margin-left: 0.3rem;
  font-size: 1.2rem;
}

.delay-slider-status {
  margin-left: 0.3rem;
  cursor: default;
}

#delaySlider {
  width: 100%;
  accent-color: #c0eb34;
}

/* BUTTONS */
.buttons-group {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 3rem;
}

.volume-container {
  margin-left: auto;
}

#loadBtn,
#resetBtn {
  height: 40px;
  padding: 0 16px;
  border-radius: 40px;
  background: rgba(28, 28, 28, 0.6);
  color: white;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

#loadBtn:hover,
#resetBtn:hover {
  background: rgba(40, 40, 40, 0.8);
}

/* PLAY/PAUSE BUTTON */
.play-pause-btn {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: none;
  background: rgba(28, 28, 28, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.2s ease;
}
.play-pause-btn:hover {
  opacity: 0.9;
}
.play-pause-btn:active {
  transform: scale(0.95);
}
.play-pause-btn.fade-out {
  opacity: 0;
  transform: scale(0.8);
}
.play-pause-btn.fade-in {
  opacity: 1;
  transform: scale(1);
}
.icon.play {
  width: 0;
  height: 0;
  border-left: 24px solid #fff;
  border-top: 14px solid transparent;
  border-bottom: 14px solid transparent;
  margin-left: 3px;
}
.icon.pause {
  display: flex;
  gap: 8px;
}
.icon.pause span {
  width: 8px;
  height: 28px;
  background: white;
  border-radius: 1px;
}

/* VOLUME */
.volume-container {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 16px;
  border-radius: 40px;
  background: rgba(28, 28, 28, 0.6);
  cursor: pointer;
  transition: background 0.2s;
}
.volume-container:hover {
  background: rgba(40, 40, 40, 0.8);
}
.volume-icon {
  width: 28px;
  height: 28px;
  fill: white;
}
.volume-slider {
  -webkit-appearance: none;
  width: 160px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.3);
  outline: none;
  cursor: pointer;
  vertical-align: middle;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  position: relative;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  margin-top: -1px;
  transition: background 0.2s;
}

/* Firefox alignment */
.volume-slider::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.3);
}
.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  border: none;
  transition: background 0.2s;
}

/* Tooltip styling */
.volume-tooltip {
  position: absolute;
  top: -34px; /* distance above thumb */
  left: 0;
  transform: translateX(-50%);
  background: rgba(20, 20, 20, 0.85);
  color: #fff;
  padding: 4px 8px;
  font-size: 0.75rem;
  border-radius: 6px;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.volume-container:hover .volume-tooltip {
  opacity: 1;
}

/* FEEDBACK TOAST */
.feedback-toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -120%);
  background: rgba(20, 20, 20, 0.85);
  color: #fff;
  font-size: 1rem;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 9999;
}
.feedback-toast.show {
  opacity: 1;
  transform: translate(-50%, -150%);
}

/* Modal overlay */
.terms-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* Modal content */
.terms-modal-content {
  background: var(--color-surface-container);
  color: var(--color-on-surface);
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 960px;
  width: 90%;
  position: relative;
  overflow-y: auto;
  max-height: 90vh;
}

/* Close button */
.terms-close-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(28, 28, 28, 0.65);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}
.terms-close-btn:hover {
  opacity: 0.85;
}

@media (prefers-color-scheme: light) {
  .feedback-toast {
    background: rgba(255, 255, 255, 0.9);
    color: #000;
  }
}

/* === MOBILE LAYOUT (max-width ~ 600px) === */
@media (max-width: 600px) {
  /* Let the wrappers expand to full screen */
  .main-wrapper,
  main {
    width: 100%;
    max-width: none;
    padding: 0; /* allow the card to control the spacing */
  }

  /* Main wrapper fills phone width with 1-character padding */
  .main-wrapper {
    padding-left: 0.5rem; /* about 1 character */
    padding-right: 0.5rem; /* about 1 character */
  }

  header,
  footer {
    padding: 1rem 0.5rem;
  }

  /* Card fits full width */
  .card {
    width: 100%;
    margin-left: 0.5rem; /* ≈ 1 character */
    margin-right: 0.5rem; /* ≈ 1 character */
    padding: 1.2rem;
    border-radius: 12px;
  }

  /* Stream input + button stack vertically */
  .stream-input-container {
    flex-direction: column;
    gap: 0.8rem;
  }

  .stream-input {
    margin-right: 0;
  }

  .stream-input-text {
    width: 100%;
    box-sizing: border-box;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .load-button-container {
    margin-left: 0;
    width: 100%;
  }

  #loadBtn {
    width: 100%;
  }

  /* Buttons group becomes vertical */
  .buttons-group {
    flex-direction: column;
    gap: 2rem;
  }

  .volume-container {
    width: 100%; /* fill card width */
    max-width: 100%; /* prevent overflow */
    box-sizing: border-box; /* keep padding inside */
    padding-left: 0.5rem; /* match card padding */
    padding-right: 0.5rem; /* match card padding */
    gap: 0.5rem; /* reduce spacing */
    overflow: hidden; /* safety */
  }

  .volume-slider {
    width: 100%; /* flexible width */
    max-width: 100%; /* prevent it pushing out */
    flex: 1; /* fill remaining space */
    box-sizing: border-box;
  }

  .volume-icon {
    flex-shrink: 0; /* keeps icon visible but doesn't stretch */
  }

  /* Play/pause button slightly smaller on phones */
  .play-pause-btn {
    width: 60px;
    height: 60px;
  }

  .icon.play {
    border-left-width: 20px;
    border-top-width: 12px;
    border-bottom-width: 12px;
  }

  .icon.pause span {
    height: 24px;
  }

  .terms-modal-content {
    width: 100%;
    height: 100%;
    border-radius: 0;
    max-height: 100vh;
  }

  .terms-close-btn {
    top: 2rem;
    right: 1rem;
  }
}
