/* All measurements are in the iPod's own 230 x 480 canvas. app.js sets --scale:
   life size on a computer (like the original), filling the screen on a phone. */
:root {
  --scale: 1;

  --screen-blue: #14aee9;
  --text: #050505;
  --wheel: #f7f7f4;
  --wheel-shadow: #c9c9c4;
  --wheel-label: #8f8f8b;

  --row: 20px;
  --row-small: 30px;

  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }

html { overscroll-behavior: none; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, .85), transparent 28rem),
    linear-gradient(135deg, #eef5f7, #cad8dc 48%, #edf2f3);
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Owner-only control, styled like the original's corner pills. */
.corner-pill {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  left: 16px;
  z-index: 30;
  height: 34px;
  min-width: 72px;
  padding: 0 12px;
  border: 1px solid rgba(105, 113, 116, .5);
  border-radius: 999px;
  color: #33434a;
  background: transparent;
  font: 700 11px Arial, Helvetica, sans-serif;
  cursor: pointer;
}

.corner-pill:disabled { opacity: .35; cursor: default; }
.corner-pill[hidden] { display: none; }

/* ---------- Stage ---------- */

.app-shell {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow: hidden;
}

.stage {
  width: calc(230px * var(--scale));
  height: calc(480px * var(--scale));
  display: grid;
  place-items: center;
  touch-action: none;
  transform: rotate(var(--stage-rotate, 0deg));
  transition: width .28s ease, height .28s ease, transform .32s ease;
}

/* ---------- Body ---------- */

.ipod {
  position: relative;
  flex: none;
  width: 198px;
  height: 471px;
  transform: scale(var(--scale));
  border-radius: 7px 7px 2px 2px / 6px 6px 2px 2px;
  /* The top and bottom edges bow out slightly, like the aluminium shell. */
  clip-path: polygon(
    0 3px, 5% 1.65px, 18% .6px, 50% 0, 82% .6px, 95% 1.65px, 100% 3px,
    100% calc(100% - 3px), 95% calc(100% - 1.65px), 82% calc(100% - .6px), 50% 100%,
    18% calc(100% - .6px), 5% calc(100% - 1.65px), 0 calc(100% - 3px)
  );
  transition: transform .32s ease;
  background: linear-gradient(90deg,
    #012e58 0%, #02639e 5.77%, #0078b2 12.11%, #0286c0 20.1%, #018cc6 27.84%,
    #098ac5 37.11%, #038bc6 48.07%, #018cc6 60.18%, #0288c1 73.58%,
    #0377b2 86.79%, #046ca9 93.4%, #045c97 96.7%, #002c51 100%);
  overflow: hidden;
}

/* ---------- Screen ---------- */

.screen-shell {
  position: absolute;
  left: 14px;
  top: 15px;
  width: 170px;
  height: 225px;
  padding: 8px 8px 6px;
  border-radius: 2px;
  background: linear-gradient(180deg, #080808, #151515 8%, #111 92%, #050505), #151515;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .13),
    inset 0 0 0 2px rgba(0, 0, 0, .86),
    0 1px 2px rgba(0, 0, 0, .82),
    0 2px 5px rgba(0, 42, 66, .45);
  z-index: 2;
}

.screen {
  height: 100%;
  position: relative;
  overflow: hidden;
  border-radius: 1px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
}

.app-shell.is-coverflow .screen {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 211px;
  height: 154px;
  transform: translate(-50%, -50%) rotate(90deg);
}

.status {
  height: 13px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  padding: 0 3px 0 4px;
  border-bottom: 1px solid #bdbdbd;
  background: linear-gradient(#f7f7f7 0%, #eee 48%, #dadada 100%);
  color: #111;
  font: 700 8px/13px Arial, Helvetica, sans-serif;
}

.status-title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.battery {
  position: relative;
  width: 16px;
  height: 7px;
  border: 1px solid #78877b;
  border-radius: 1px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .78), rgba(255, 255, 255, 0) 45%),
    linear-gradient(180deg, #96de75 0%, #6bc24a 48%, #39a72e 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18), 0 0 0 1px rgba(255, 255, 255, .55);
}

.battery::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, .45), transparent 22%, rgba(0, 0, 0, .08) 100%);
}

.viewport {
  height: calc(100% - 13px);
  position: relative;
  overflow: hidden;
  background: #fff;
  touch-action: none;
}

/* ---------- Menus ---------- */

.menu-list {
  height: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: hidden;
}

.menu-list.is-main { height: calc(var(--row) * 7); }

.menu-item {
  position: relative;
  height: var(--row);
  padding: 0 21px 0 4px;
  display: flex;
  align-items: center;
  font-size: 12px;
  line-height: 18px;
  font-weight: 700;
  white-space: nowrap;
}

.menu-item .label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-item.is-active {
  color: #fff;
  background: linear-gradient(#45c9f5 0%, var(--screen-blue) 48%, #047fc2 100%);
}

.menu-item .chevron {
  position: absolute;
  top: calc(50% - 2px);
  right: 5px;
  transform: translateY(-50%);
  font-size: 17px;
  line-height: 17px;
  font-weight: 700;
}

.menu-item.small {
  height: var(--row-small);
  padding-top: 2px;
  padding-bottom: 2px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  line-height: 14px;
}

.menu-item.small .label { display: block; }

.menu-item .meta {
  display: block;
  opacity: .62;
  font-size: 9px;
  line-height: 10px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-item.is-active .meta { opacity: .8; }

/* ---------- Album strip under the main menu ---------- */

.album-strip {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--row) * 7 + 4px);
  height: 55px;
  padding: 2px;
  border-top: 2px solid #171717;
  background: #111;
  overflow: hidden;
}

.album-strip-track {
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.album-strip-track.is-sliding {
  width: 133.333%;
  grid-template-columns: repeat(4, 1fr);
  animation: album-slide 1.15s linear forwards;
}

@keyframes album-slide {
  from { transform: translateX(0); }
  to { transform: translateX(-25%); }
}

.album-card {
  border-radius: 1px;
  background: var(--art) center / 100% no-repeat;
}

/* ---------- Text panels ---------- */

.panel {
  height: 100%;
  padding: 8px 7px 6px;
  background: linear-gradient(#fff, #f3f3f3);
  font-weight: 700;
  text-align: center;
}

.panel h2 { margin: 6px 0 7px; font-size: 16px; }
.panel p { margin: 0 0 4px; color: #555; font-size: 10px; line-height: 1.35; }

.about-screen {
  height: 100%;
  padding: 8px 8px 7px;
  overflow: hidden;
}

.about-screen-inner { padding-bottom: 9px; }

.about-screen h2 {
  margin: 0 0 6px;
  font-size: 15px;
  line-height: 17px;
  font-weight: 800;
}

.about-screen p {
  margin: 0 0 7px;
  color: #2f2f2f;
  font-size: 10px;
  line-height: 13px;
  font-weight: 700;
}

/* ---------- Now Playing ---------- */

.now-playing {
  height: 100%;
  padding: 8px 7px 6px;
  text-align: center;
  background: linear-gradient(#fff, #f2f2f2);
}

.now-art {
  width: 69px;
  height: 69px;
  margin: 6px auto;
  background:
    radial-gradient(circle at 37% 38%, rgba(255, 255, 255, .65) 0 13px, transparent 14px),
    linear-gradient(135deg, var(--art), #222);
  background-size: cover;
  background-position: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
}

.track-title,
.track-artist {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.track-title { font-size: 13px; line-height: 15px; font-weight: 700; }
.track-artist { margin-top: 1px; color: #555; font-size: 10px; line-height: 12px; }

.progress-row {
  display: grid;
  grid-template-columns: 27px 1fr 27px;
  align-items: center;
  gap: 3px;
  margin-top: 8px;
  color: #333;
  font-size: 9px;
}

.progress {
  height: 7px;
  border: 1px solid #979797;
  background: #e9e9e9;
  overflow: hidden;
}

.progress-fill {
  width: var(--progress);
  height: 100%;
  background: linear-gradient(#54c9ff, #087eca);
}

.play-state {
  margin-top: 7px;
  color: #333;
  font-size: 10px;
  font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.screen-note {
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 5px;
  min-height: 17px;
  padding: 3px 4px;
  border: 1px solid #a76515;
  background: #fff4bf;
  color: #4b3400;
  font-size: 9px;
  line-height: 10px;
  font-weight: 700;
  text-align: center;
}

/* ---------- Photos ---------- */

.photo-grid {
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 3px;
  padding: 4px;
}

.photo-tile {
  position: relative;
  border: 2px solid transparent;
  overflow: hidden;
  background: #d9d9d9;
}

.photo-tile.is-active {
  border-color: var(--screen-blue);
  box-shadow: inset 0 0 0 1px #fff;
}

.photo-tile img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* The "add a photo" tile: a dotted rectangle with a plus. */
.photo-tile.is-add {
  background: #fff;
  border-color: transparent;
}

.photo-tile.is-add::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1.5px dashed #9a9a9a;
  border-radius: 2px;
}

.photo-tile.is-add::after {
  content: "+";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #8a8a8a;
  font-size: 22px;
  line-height: 1;
  font-weight: 400;
}

.photo-tile.is-add.is-active { border-color: var(--screen-blue); }
.photo-tile.is-add.is-active::before { border-color: var(--screen-blue); }
.photo-tile.is-add.is-active::after { color: var(--screen-blue); }

.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 54px;
  align-items: center;
  gap: 12px;
  padding: 24px;
  background: rgba(5, 11, 16, .88);
}

.photo-viewer[hidden] { display: none; }

.photo-viewer-image {
  grid-column: 2;
  max-width: min(100%, 1200px);
  max-height: calc(100dvh - 104px);
  justify-self: center;
  border: 1px solid rgba(255, 255, 255, .24);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .45);
  background: #111;
}

.photo-viewer-button {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, .34);
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, .12);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.photo-viewer-prev { grid-column: 1; justify-self: end; }
.photo-viewer-next { grid-column: 3; justify-self: start; }

.photo-viewer-close {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  right: 18px;
  width: 34px;
  height: 34px;
  font-size: 22px;
}

/* ---------- Add My Playlist / Add My Fav Podcast ---------- */

.add-form {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 7px 6px;
  background: linear-gradient(#fff, #f3f3f3);
  font-weight: 700;
}

.add-hint {
  margin: 0 0 1px;
  color: #444;
  font-size: 9px;
  line-height: 11px;
}

.add-row {
  display: flex;
  gap: 3px;
}

.add-form .add-row input { flex: 1; }

.add-form input {
  min-width: 0;
  flex: none;
  height: 20px;
  padding: 0 4px;
  border: 1px solid #a9a9a9;
  border-radius: 2px;
  background: #fff;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .12);
  color: #111;
  font: 700 10px Arial, Helvetica, sans-serif;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}

.add-form input:focus { border-color: var(--screen-blue); }

.add-small-button {
  height: 20px;
  padding: 0 6px;
  border: 1px solid #a9a9a9;
  border-radius: 2px;
  background: linear-gradient(#fff, #e3e3e3);
  color: #222;
  font: 700 9px Arial, Helvetica, sans-serif;
}

.add-submit {
  height: 20px;
  margin-top: 2px;
  border: 0;
  color: #fff;
  background: linear-gradient(#45c9f5 0%, var(--screen-blue) 48%, #047fc2 100%);
  font: 700 11px Arial, Helvetica, sans-serif;
}

.add-submit:disabled { opacity: .6; }

.add-status {
  min-height: 22px;
  margin: 0;
  color: #555;
  font-size: 9px;
  line-height: 11px;
}

.add-status.is-error { color: #a33a00; }

/* ---------- Cover Flow ---------- */

.coverflow-screen {
  height: 100%;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #fff 0%, #f8f8f8 54%, #ededed 100%);
  color: #111;
}

.coverflow-stage {
  height: calc(100% - 34px);
  position: relative;
  perspective: 260px;
  overflow: hidden;
}

.coverflow-item {
  position: absolute;
  left: 50%;
  top: 16px;
  width: 72px;
  height: 72px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, .28);
  background: linear-gradient(135deg, rgba(255, 255, 255, .16), rgba(0, 0, 0, .1)), var(--art);
  background-size: cover;
  background-position: center;
  box-shadow: 0 7px 11px rgba(0, 0, 0, .28), 0 0 0 1px rgba(255, 255, 255, .75);
  transform:
    translateX(calc(-50% + var(--offset) * 46px))
    translateZ(calc((3 - var(--distance)) * 2px))
    rotateY(calc(var(--offset) * -38deg))
    scale(calc(1 - var(--distance) * .1));
  opacity: calc(1 - var(--distance) * .16);
  transition: transform .18s ease, opacity .18s ease;
  cursor: pointer;
}

.coverflow-item.is-active { border-color: #fff; }

.coverflow-item::after {
  content: "";
  position: absolute;
  left: -1px;
  right: -1px;
  top: calc(100% + 2px);
  height: 44px;
  background: inherit;
  transform: scaleY(-1);
  opacity: .3;
  -webkit-mask-image: linear-gradient(rgba(0, 0, 0, .68), transparent 78%);
  mask-image: linear-gradient(rgba(0, 0, 0, .68), transparent 78%);
}

.coverflow-title {
  height: 34px;
  padding: 2px 6px 0;
  border-top: 1px solid rgba(0, 0, 0, .08);
  background: linear-gradient(180deg, rgba(255, 255, 255, .86), rgba(238, 238, 238, .78));
  text-align: center;
}

.coverflow-title strong,
.coverflow-title span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.coverflow-title strong { font-size: 11px; line-height: 14px; }
.coverflow-title span { color: rgba(0, 0, 0, .58); font-size: 9px; line-height: 11px; }

.rotate-corner {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 8;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: grab;
  touch-action: none;
}

.app-shell.is-touch .rotate-corner { display: none; }

/* ---------- Click wheel ---------- */

.click-wheel {
  position: absolute;
  left: 27px;
  top: 276px;
  width: 145px;
  height: 145px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, transparent 0 36px, rgba(255, 255, 255, .99) 37px 100%),
    radial-gradient(circle at 47% 40%, rgba(255, 255, 255, .74) 0 28px, transparent 49px),
    linear-gradient(135deg, #fff 0%, var(--wheel) 44%, #ececE8 74%, var(--wheel-shadow) 100%);
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, .82),
    inset 0 -2px 4px rgba(0, 0, 0, .12),
    0 1px 2px rgba(0, 49, 77, .28);
  z-index: 3;
  touch-action: none;
}

/* A larger invisible ring so a thumb that drifts off the wheel keeps scrolling. */
.wheel-touch-zone {
  position: absolute;
  left: -1px;
  top: 248px;
  width: 201px;
  height: 201px;
  border-radius: 50%;
  z-index: 2;
  touch-action: none;
}

.center-button {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 70px;
  height: 70px;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 50%;
  background:
    linear-gradient(90deg, rgba(0, 66, 101, .22), transparent 29%, transparent 69%, rgba(255, 255, 255, .17)),
    linear-gradient(#08afe0, #038fcb);
  box-shadow: inset 4px 0 6px rgba(255, 255, 255, .16), inset -4px 0 8px rgba(0, 65, 91, .25);
  cursor: pointer;
}

.wheel-button {
  position: absolute;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  color: var(--wheel-label);
  background: transparent;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .65);
  cursor: pointer;
}

.click-wheel button:focus { outline: none; }

.wheel-button:active,
.center-button:active { filter: brightness(.93); }

.wheel-menu {
  left: 44px;
  top: 7px;
  width: 56px;
  height: 24px;
  font-family: "Myriad Set Pro", "Myriad Pro", Myriad, Arial, Helvetica, sans-serif;
  font-size: 10px;
  letter-spacing: .4px;
}

.wheel-prev,
.wheel-next {
  top: 58px;
  width: 30px;
  height: 28px;
}

.wheel-prev { left: 5px; }
.wheel-next { right: 4px; }

.wheel-button svg {
  width: 16px;
  height: auto;
  display: block;
  opacity: .95;
  pointer-events: none;
}

.wheel-prev svg { transform: rotate(180deg); }

.wheel-play {
  left: 52px;
  bottom: 4px;
  width: 40px;
  height: 24px;
}

