/* Webquarters kid player — iOS 9 Safari 9 safe CSS.
   No grid, no custom properties, no sticky, no flex gap, no shadows/filters.
   Flex properties doubled with -webkit- prefixes. */

* {
  margin: 0;
  padding: 0;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: #ffe9c7;
  background: -webkit-linear-gradient(top, #ffe9c7, #ffd6c2);
  background: linear-gradient(to bottom, #ffe9c7, #ffd6c2);
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  font-size: 0; /* kills stray whitespace; no visible text anywhere */
}

img {
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* ---------------- views ---------------- */

.view {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

.view.active {
  display: block;
}

.grid-view.active {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#view-home.active {
  padding: 20px 0;
}

#view-folder.active {
  padding: 108px 0 20px 0; /* clears the fixed home button */
}

/* ---------------- tile grid ---------------- */

.grid {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  -webkit-justify-content: flex-start;
  justify-content: flex-start;
  padding: 0 1.5%;
}

.tile {
  position: relative;
  width: 27.333%;
  margin: 3%;
  cursor: pointer;
}

.tile-art {
  position: relative;
  width: 100%;
  padding-bottom: 100%;
  border-radius: 28px;
  overflow: hidden;
  background-color: #ffffff;
  border: 7px solid #ffffff;
  -webkit-transition: -webkit-transform 0.12s ease-out;
  transition: transform 0.12s ease-out;
}

.tile:active .tile-art {
  -webkit-transform: scale(0.96);
  transform: scale(0.96);
}

.tile-art img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
}

/* cheerful rotating accent borders (assigned by JS: c0..c5) */
.tile.c0 .tile-art { border-color: #ffb347; }
.tile.c1 .tile-art { border-color: #6fce6f; }
.tile.c2 .tile-art { border-color: #6aa9e9; }
.tile.c3 .tile-art { border-color: #ff8177; }
.tile.c4 .tile-art { border-color: #f393c4; }
.tile.c5 .tile-art { border-color: #a98fd8; }

/* playing / last-played marker */
.tile.tile-playing .tile-art {
  border-color: #2fc75f;
}

/* Favourite episodes are the offline pack. A double gold rim reads as a glow
   without box-shadow/filter, which are deliberately avoided on Safari 9. */
.tile.is-favourite .tile-art {
  border-color: #f4b400;
  border-width: 10px;
}

.tile.is-favourite .tile-art:after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  right: 2px;
  bottom: 2px;
  border: 4px solid #ffe58a;
  border-radius: 20px;
  pointer-events: none;
}

/* offline: tiles not in the downloaded car pack — dimmed + muted border, not
   tappable (no filter, per this file's rules — opacity reads as disabled) */
.tile-locked {
  opacity: 0.4;
}
.tile-locked .tile-art {
  border-color: #cfd4dc;
}

.play-marker {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background-color: #2fc75f;
  border: 4px solid #ffffff;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
}

/* Filled, non-interactive overview status. Favouriting itself is only
   available from the episode view. */
.favourite-marker {
  position: absolute;
  top: -12px;
  left: -10px;
  width: 54px;
  height: 54px;
  z-index: 5;
}

.favourite-marker svg {
  display: block;
}

/* "new" star — gold sticker, top-right, on never-played tracks */
.new-star {
  position: absolute;
  top: -12px;
  right: -10px;
  width: 54px;
  height: 54px;
  -webkit-transform: rotate(12deg);
  transform: rotate(12deg);
}

.new-star svg {
  display: block;
}

/* The episode view's standalone heart: a large visible glyph with a still
   larger transparent hit target. No circle/background competing with the art. */
.favourite-button {
  position: absolute;
  width: 72px;
  height: 72px;
  background: transparent;
  border: 0;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  -webkit-transition: -webkit-transform 0.12s ease-out, opacity 0.12s ease-out;
  transition: transform 0.12s ease-out, opacity 0.12s ease-out;
}

.favourite-button.is-on {
  background: transparent;
}

.favourite-button:active {
  -webkit-transform: scale(0.9);
  transform: scale(0.9);
}

@-webkit-keyframes heartpending {
  0% { opacity: 1; }
  50% { opacity: 0.45; }
  100% { opacity: 1; }
}
@keyframes heartpending {
  0% { opacity: 1; }
  50% { opacity: 0.45; }
  100% { opacity: 1; }
}
.favourite-button.is-pending {
  -webkit-animation: heartpending 0.8s ease-in-out infinite;
  animation: heartpending 0.8s ease-in-out infinite;
}

@-webkit-keyframes heartpop {
  0% { -webkit-transform: scale(1); }
  45% { -webkit-transform: scale(1.3); }
  70% { -webkit-transform: scale(0.92); }
  100% { -webkit-transform: scale(1); }
}
@keyframes heartpop {
  0% { transform: scale(1); }
  45% { transform: scale(1.3); }
  70% { transform: scale(0.92); }
  100% { transform: scale(1); }
}
.favourite-button.is-accepted {
  -webkit-animation: heartpop 0.55s ease-out;
  animation: heartpop 0.55s ease-out;
}

@-webkit-keyframes heartreject {
  0% { -webkit-transform: translateX(0); }
  20% { -webkit-transform: translateX(-9px); }
  40% { -webkit-transform: translateX(8px); }
  60% { -webkit-transform: translateX(-6px); }
  80% { -webkit-transform: translateX(4px); }
  100% { -webkit-transform: translateX(0); }
}
@keyframes heartreject {
  0% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
  100% { transform: translateX(0); }
}
.favourite-button.is-rejected {
  -webkit-animation: heartreject 0.55s ease-out;
  animation: heartreject 0.55s ease-out;
}

/* announce badge — >=64px circular speaker button, bottom-right */
.announce-badge {
  position: absolute;
  bottom: -8px;
  right: -8px;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background-color: #ff9f43;
  border: 4px solid #ffffff;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  cursor: pointer;
  -webkit-transition: -webkit-transform 0.12s ease-out;
  transition: transform 0.12s ease-out;
}

.announce-badge:active {
  -webkit-transform: scale(0.9);
  transform: scale(0.9);
}

/* duration chip, bottom-left inside the art — parent-facing, understated */
.dur-chip {
  position: absolute;
  bottom: 12px;
  left: 12px;
  padding: 3px 10px;
  border-radius: 13px;
  background-color: rgba(35, 22, 8, 0.55);
  color: #ffffff;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  font-weight: bold;
}

/* ---------------- round buttons ---------------- */

.btn-round {
  border-radius: 50%;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  cursor: pointer;
  -webkit-transition: -webkit-transform 0.12s ease-out, opacity 0.12s ease-out;
  transition: transform 0.12s ease-out, opacity 0.12s ease-out;
}

.btn-round:active {
  -webkit-transform: scale(0.92);
  transform: scale(0.92);
  opacity: 0.85;
}

@-webkit-keyframes btnpulse {
  0% { opacity: 1; }
  50% { opacity: 0.45; }
  100% { opacity: 1; }
}
@keyframes btnpulse {
  0% { opacity: 1; }
  50% { opacity: 0.45; }
  100% { opacity: 1; }
}
.btn-play.is-loading {
  -webkit-animation: btnpulse 1s ease-in-out infinite;
  animation: btnpulse 1s ease-in-out infinite;
}

.btn-home {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 84px;
  height: 84px;
  background-color: #6aa9e9;
  border: 5px solid #ffffff;
  z-index: 20;
}

/* The home button is a direct <body> child (never inside a
   -webkit-overflow-scrolling container — position:fixed breaks there on iOS 9). */
#homebtn { display: none; }
#homebtn.show {
  display: -webkit-flex;
  display: flex;
}

/* ---------------- now playing ---------------- */

#view-now.active {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  background: #ffe2b8;
  background: -webkit-linear-gradient(top, #ffe2b8, #ffcdb8);
  background: linear-gradient(to bottom, #ffe2b8, #ffcdb8);
}

.now-art {
  position: relative;
  width: 300px;
  height: 300px;
  border-radius: 32px;
  overflow: visible;
  background-color: #ffffff;
  border: 8px solid #ffffff;
}

.now-art.is-favourite {
  border-color: #f4b400;
}

.now-favourite-button {
  top: -22px;
  left: -22px;
}

.now-art img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  border-radius: 24px;
}

.now-controls {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  margin-top: 28px;
}

.btn-prev, .btn-next {
  width: 104px;
  height: 104px;
  background-color: #6aa9e9;
  border: 5px solid #ffffff;
  margin: 0 26px;
}

.btn-play {
  width: 150px;
  height: 150px;
  background-color: #ff8177;
  border: 6px solid #ffffff;
  margin: 0 26px;
}

/* play/pause icon swap */
.btn-play .ic-pause { display: none; }
.btn-play .ic-play { display: block; }
.btn-play.is-playing .ic-play { display: none; }
.btn-play.is-playing .ic-pause { display: block; }

/* fat progress bar, scrubbable — invisible touch padding around the visual
   bar gives the finger something to land on */
.progress-hit {
  width: 70%;
  max-width: 620px;
  padding: 18px 0;
  margin-top: 12px;
}

.progress {
  width: 100%;
  height: 12px;
  border-radius: 6px;
  background-color: rgba(120, 70, 30, 0.18);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: 6px;
  background-color: #ff8177;
}

/* remaining-time countdown for parents; the child can't read it anyway */
.time-left {
  margin-top: -6px;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 20px;
  font-weight: bold;
  color: rgba(120, 70, 30, 0.5);
}

/* ---------------- mini player bar ---------------- */
/* Direct <body> child (fixed elements break inside -webkit-overflow-scrolling
   containers on iOS 9). Cover-art bubble pokes above the bar's top edge. */

#minibar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 88px;
  background-color: #fff6e9;
  border-top: 2px solid rgba(120, 70, 30, 0.16);
  border-radius: 26px 26px 0 0;
  z-index: 25;
}

#minibar.show {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
}

/* grids keep their last row clear of the bar (and the poking bubble) */
body.has-minibar #view-home.active,
body.has-minibar #view-folder.active {
  padding-bottom: 140px;
}

/* progress sliver along the bar's top edge, inset past the rounded corners */
.mini-progress {
  position: absolute;
  top: 0;
  left: 26px;
  right: 26px;
  height: 6px;
  border-radius: 0 0 3px 3px;
  background-color: rgba(120, 70, 30, 0.14);
  overflow: hidden;
}

.mini-progress-fill {
  width: 0%;
  height: 100%;
  background-color: #ff8177;
}

/* skip buttons — same blue circles as the now view, kid-sized */
.mini-skip {
  width: 68px;
  height: 68px;
  background-color: #6aa9e9;
  border: 5px solid #ffffff;
  margin: 0 8px;
}

/* the cover bubble: tap = play/pause */
.mini-bubble {
  position: relative;
  width: 116px;
  height: 116px;
  margin: 0 26px;
  -webkit-align-self: flex-start;
  align-self: flex-start;
  margin-top: -40px; /* peeks over the bar */
  z-index: 1;        /* above the progress sliver */
  cursor: pointer;
  -webkit-transition: -webkit-transform 0.12s ease-out;
  transition: transform 0.12s ease-out;
}

.mini-bubble:active {
  -webkit-transform: scale(0.94);
  transform: scale(0.94);
}

.mini-bubble-art {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 50%;
  overflow: hidden;
  background-color: #ffffff;
  border: 6px solid #ffffff;
}

.mini-bubble-art img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
}

/* paused: dark scrim + big play triangle over the art */
.mini-scrim {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(35, 22, 8, 0.45);
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
}

/* playing: clean art, green "this one is playing" ring, gentle breathing */
.mini-bubble.is-playing .mini-scrim { display: none; }
.mini-bubble.is-playing .mini-bubble-art {
  border-color: #2fc75f;
  -webkit-animation: minipulse 1.8s ease-in-out infinite;
  animation: minipulse 1.8s ease-in-out infinite;
}

/* buffering: quick pulse so a slow start doesn't look dead */
.mini-bubble.is-loading .mini-bubble-art {
  -webkit-animation: btnpulse 1s ease-in-out infinite;
  animation: btnpulse 1s ease-in-out infinite;
}

@-webkit-keyframes minipulse {
  0%   { -webkit-transform: scale(1); }
  50%  { -webkit-transform: scale(1.05); }
  100% { -webkit-transform: scale(1); }
}

@keyframes minipulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* the usual orange speaker, bubble-sized, in its usual corner */
.mini-badge {
  bottom: -4px;
  right: -10px;
  width: 58px;
  height: 58px;
}

/* ---------------- offline (sleeping cloud) ---------------- */

#view-offline {
  background: #43567f;
  background: -webkit-linear-gradient(top, #43567f, #2e3c5c);
  background: linear-gradient(to bottom, #43567f, #2e3c5c);
}

#view-offline.active {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
}

/* ---------------- debug overlay ---------------- */

#debug {
  display: none;
  position: fixed;
  bottom: 8px;
  left: 8px;
  right: 8px;
  top: auto;
  max-height: 40%;
  overflow: hidden;
  pointer-events: none; /* never blocks taps on the UI underneath */
  background-color: transparent;
  color: #8dff8d;
  font-family: Menlo, Courier, monospace;
  font-size: 11px;
  line-height: 1.4;
  padding: 6px 8px;
  z-index: 9999;
  -webkit-user-select: text;
}

#debug div {
  background-color: rgba(0, 0, 0, 0.75);
  border-radius: 6px;
  padding: 2px 8px;
  margin-top: 2px;
  opacity: 1;
  -webkit-transition: opacity 0.8s;
  transition: opacity 0.8s;
}

/* announce badge on the now-playing artwork (inside the rounded clip) */
.now-art .announce-badge {
  bottom: 10px;
  right: 10px;
  width: 78px;
  height: 78px;
}
