/* =============================================
   iPod Classic - スタイルシート
   ライトモード / ダークモード対応
   ============================================= */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ================================================
   CSS Custom Properties (テーマカラー)
   ================================================ */

:root {
  /* ── ライトモード (シルバー iPod) ── */
  --ipod-body-top: #e4e4e4;
  --ipod-body-bottom: #c8c8c8;
  --ipod-body-edge: #b0b0b0;
  --ipod-body-highlight: rgba(255, 255, 255, 0.55);
  --ipod-body-shadow: rgba(0, 0, 0, 0.08);
  --ipod-border-outer: rgba(0, 0, 0, 0.18);

  --bezel-bg: #3a3a3c;
  --bezel-inner: #2c2c2e;

  --screen-bg: #e8e8e4;
  --screen-text: #1a1a1a;
  --screen-header-top: #d6d6d0;
  --screen-header-bottom: #c8c8c2;
  --screen-header-border: rgba(0, 0, 0, 0.12);
  --screen-separator: rgba(0, 0, 0, 0.08);

  --highlight-top: #4c9fef;
  --highlight-bottom: #1a6fce;
  --highlight-text: #ffffff;

  --wheel-bg: #f2f2f2;
  --wheel-border: rgba(0, 0, 0, 0.08);
  --wheel-shadow-outer: rgba(0, 0, 0, 0.12);
  --wheel-shadow-inner: rgba(0, 0, 0, 0.06);
  --center-top: #dcdcdc;
  --center-bottom: #b8b8b8;
  --center-highlight: rgba(255, 255, 255, 0.45);
  --center-border: rgba(0, 0, 0, 0.12);
  --label-color: #5a5a5a;

  --scrollbar-track: rgba(0, 0, 0, 0.08);
  --scrollbar-thumb: rgba(0, 0, 0, 0.3);

  --np-progress-bg: rgba(0, 0, 0, 0.15);
  --np-progress-fill: #1a6fce;

  --page-bg-top: #2d2d3a;
  --page-bg-bottom: #0f0f15;
}

[data-theme="dark"] {
  /* ── ダークモード (ブラック iPod) ── */
  --ipod-body-top: #4e4e50;
  --ipod-body-bottom: #333335;
  --ipod-body-edge: #252527;
  --ipod-body-highlight: rgba(255, 255, 255, 0.12);
  --ipod-body-shadow: rgba(0, 0, 0, 0.2);
  --ipod-border-outer: rgba(0, 0, 0, 0.4);

  --bezel-bg: #1a1a1c;
  --bezel-inner: #111113;

  --screen-bg: #e8e8e4;
  --screen-text: #1a1a1a;
  --screen-header-top: #d6d6d0;
  --screen-header-bottom: #c8c8c2;
  --screen-header-border: rgba(0, 0, 0, 0.12);
  --screen-separator: rgba(0, 0, 0, 0.08);

  --highlight-top: #4c9fef;
  --highlight-bottom: #1a6fce;
  --highlight-text: #ffffff;

  --wheel-bg: #2a2a2c;
  --wheel-border: rgba(0, 0, 0, 0.3);
  --wheel-shadow-outer: rgba(0, 0, 0, 0.35);
  --wheel-shadow-inner: rgba(0, 0, 0, 0.2);
  --center-top: #555558;
  --center-bottom: #3e3e40;
  --center-highlight: rgba(255, 255, 255, 0.08);
  --center-border: rgba(0, 0, 0, 0.3);
  --label-color: #c0c0c0;

  --scrollbar-track: rgba(0, 0, 0, 0.1);
  --scrollbar-thumb: rgba(0, 0, 0, 0.35);

  --np-progress-bg: rgba(0, 0, 0, 0.18);
  --np-progress-fill: #1a6fce;

  --page-bg-top: #1a1a24;
  --page-bg-bottom: #08080c;
}

/* ================================================
   ベース・リセット
   ================================================ */

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 40%, var(--page-bg-top), var(--page-bg-bottom));
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
}

/* ================================================
   iPod 本体
   ================================================ */

.ipod-body {
  position: relative;
  width: 280px;
  height: 484px;
  border-radius: 24px;
  background: linear-gradient(180deg, var(--ipod-body-top) 0%, var(--ipod-body-bottom) 100%);
  box-shadow:
    0 0 0 1px var(--ipod-border-outer),
    0 2px 4px rgba(0, 0, 0, 0.15),
    0 12px 40px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 var(--ipod-body-highlight);
  transition: background 0.5s ease, box-shadow 0.5s ease, transform 0.3s ease;
  cursor: default;
  /* JS自動スケーリング用 */
  transform: scale(var(--ipod-scale, 1));
  transform-origin: center center;
}

/* アルマイト加工風の粒状テクスチャ (SVGフィルター参照) */
.ipod-body::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: white;
  filter: url(#grain-texture);
  opacity: 0.06;
  pointer-events: none;
  z-index: 1;
  /* 角丸の外側にはみ出さないようクリップ */
  clip-path: inset(0 round 24px);
}

/* エッジの光沢 */
.ipod-body::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(105deg,
      rgba(255, 255, 255, 0.15) 0%,
      transparent 40%,
      transparent 60%,
      rgba(255, 255, 255, 0.05) 100%);
  pointer-events: none;
  z-index: 2;
}

/* ================================================
   画面ベゼル
   ================================================ */

.screen-bezel {
  position: absolute;
  top: 28px;
  left: 50%;
  transform: translateX(-50%);
  width: 232px;
  height: 178px;
  background: var(--bezel-bg);
  border-radius: 6px;
  padding: 6px;
  box-shadow:
    inset 0 1px 4px rgba(0, 0, 0, 0.6),
    0 1px 0 var(--ipod-body-highlight);
  z-index: 3;
  transition: background 0.5s ease;
}

/* ================================================
   画面 (LCD)
   ================================================ */

.screen {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--screen-bg);
  border-radius: 3px;
  overflow: hidden;
  transition: background 0.5s ease;
}

/* LCDグロス反射 */
.screen::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg,
      rgba(255, 255, 255, 0.12) 0%,
      rgba(255, 255, 255, 0.04) 35%,
      transparent 55%);
  pointer-events: none;
  z-index: 50;
  border-radius: inherit;
}

/* ── ヘッダーバー ── */

.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 22px;
  padding: 0 6px;
  background: linear-gradient(180deg, var(--screen-header-top), var(--screen-header-bottom));
  border-bottom: 1px solid var(--screen-header-border);
  position: relative;
  z-index: 10;
  transition: background 0.5s ease;
}

.header-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--screen-text);
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.play-indicator {
  font-size: 8px;
  color: var(--screen-text);
  display: none;
  letter-spacing: -1px;
}

/* バッテリーアイコン (CSS描画) */
.battery-icon {
  display: inline-block;
  width: 18px;
  height: 9px;
  border: 1.5px solid var(--screen-text);
  border-radius: 2px;
  position: relative;
  opacity: 0.7;
}

.battery-icon::before {
  content: '';
  position: absolute;
  right: -4px;
  top: 1.5px;
  width: 2.5px;
  height: 4px;
  background: var(--screen-text);
  border-radius: 0 1px 1px 0;
}

.battery-icon::after {
  content: '';
  position: absolute;
  left: 1px;
  top: 1px;
  width: calc(12px * var(--battery-level, 1));
  height: 5px;
  background: var(--battery-color, #3ddc57);
  border-radius: 0.5px;
  transition: width 0.5s ease, background 0.3s ease;
}

/* ── 画面ボディ ── */

.screen-body {
  position: relative;
  height: calc(100% - 22px);
  overflow: hidden;
}

/* ビューコンテナ */
.screen-view {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
}

.screen-view.active,
#current-view {
  display: block;
}

#current-view {
  position: absolute;
  inset: 0;
}

/* スライドアニメーション */
@keyframes slideOutLeft {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-100%);
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(100%);
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }

  to {
    transform: translateX(0);
  }
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(0);
  }
}

.slide-out-left {
  animation: slideOutLeft 0.28s ease-in-out forwards;
}

.slide-out-right {
  animation: slideOutRight 0.28s ease-in-out forwards;
}

.slide-in-right {
  animation: slideInRight 0.28s ease-in-out forwards;
}

.slide-in-left {
  animation: slideInLeft 0.28s ease-in-out forwards;
}

/* ── スクロールバー ── */

.scrollbar {
  position: absolute;
  right: 1px;
  top: 2px;
  bottom: 2px;
  width: 5px;
  background: var(--scrollbar-track);
  border-radius: 3px;
  z-index: 20;
  display: none;
}

.scrollbar-thumb {
  position: absolute;
  width: 100%;
  background: var(--scrollbar-thumb);
  border-radius: 3px;
  min-height: 10px;
  transition: top 0.12s ease, height 0.12s ease;
}

/* ================================================
   メニューリスト
   ================================================ */

.menu-list {
  height: 100%;
  overflow: hidden;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 22px;
  padding: 0 8px 0 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--screen-text);
  border-bottom: 1px solid var(--screen-separator);
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  transition: none;
}

.menu-item.selected {
  background: linear-gradient(180deg, var(--highlight-top), var(--highlight-bottom));
  color: var(--highlight-text);
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

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

.menu-item-arrow {
  font-size: 11px;
  margin-left: 4px;
  opacity: 0.7;
  flex-shrink: 0;
}

.menu-item.selected .menu-item-arrow {
  opacity: 1;
}

/* ================================================
   Now Playing (1.png 準拠 - 横並びレイアウト)
   ================================================ */

.now-playing {
  height: 100%;
  padding: 2px 6px 4px;
  display: flex;
  flex-direction: column;
}

/* シャッフル/リピート アイコン (右上) */
.np-icons-row {
  display: flex;
  justify-content: flex-end;
  gap: 3px;
  height: 12px;
  margin-bottom: 1px;
}

.np-shuffle,
.np-repeat {
  font-size: 8px;
  color: var(--screen-text);
  opacity: 0.2;
  line-height: 12px;
}

.np-shuffle.active,
.np-repeat.active {
  opacity: 0.65;
}

/* メインコンテンツ (左: アート / 右: 情報) */
.np-content {
  display: flex;
  gap: 6px;
  flex: 1;
  min-height: 0;
  align-items: center;
}

.np-art-container {
  perspective: 350px;
  flex-shrink: 0;
}

.np-album-art {
  width: 82px;
  height: 82px;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotateY(7deg);
  box-shadow:
    -3px 2px 5px rgba(0, 0, 0, 0.3),
    -5px 4px 14px rgba(0, 0, 0, 0.15);
}

.np-art-icon {
  font-size: 24px;
  opacity: 0.4;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* 曲情報 (右側) */
.np-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  justify-content: center;
}

.np-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--screen-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}

.np-artist {
  font-size: 9px;
  font-weight: 500;
  color: var(--screen-text);
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}

.np-album-label {
  font-size: 8px;
  color: var(--screen-text);
  opacity: 0.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}



.np-track-num {
  font-size: 8px;
  color: var(--screen-text);
  opacity: 0.45;
  line-height: 1.4;
}

/* プログレスバー */
.np-progress-container {
  width: 100%;
  margin-top: auto;
  padding-top: 2px;
}

.np-progress-bar {
  position: relative;
  height: 3px;
  background: var(--np-progress-bg);
  border-radius: 1.5px;
  overflow: visible;
}

.np-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: var(--np-progress-fill);
  border-radius: 1.5px;
  transition: width 1s linear;
}

.np-progress-diamond {
  position: absolute;
  top: 50%;
  width: 5px;
  height: 5px;
  background: var(--screen-text);
  transform: translate(-50%, -50%) rotate(45deg);
  transition: left 1s linear;
}

.np-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 2px;
}

.np-time {
  font-size: 8px;
  color: var(--screen-text);
  opacity: 0.55;
  min-width: 28px;
}

.np-time-left {
  text-align: left;
}

.np-time-right {
  text-align: right;
}

.np-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 11px;
  color: var(--screen-text);
  opacity: 0.5;
}

/* ================================================
   Cover Flow (2.png 準拠 - 3Dカルーセル)
   ================================================ */

.cover-flow {
  height: 100%;
  background: linear-gradient(180deg, #d8d8d8 0%, #eee 40%, #f6f6f6 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.cf-stage {
  flex: 1;
  position: relative;
  perspective: 500px;
  overflow: hidden;
}

.cf-album {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 80px;
  height: 80px;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  will-change: transform, opacity;
  transition: transform 0.35s ease, opacity 0.35s ease, box-shadow 0.35s ease;
}

.cf-art-icon {
  font-size: 26px;
  color: rgba(255, 255, 255, 0.7);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* 中央アルバム */
.cf-album.cf-center {
  transform: translate(-50%, -58%);
  z-index: 10;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

/* 左 -1 */
.cf-album.cf-left-1 {
  transform: translate(-125%, -58%) rotateY(55deg) scale(0.78);
  z-index: 5;
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.2);
}

/* 左 -2 */
.cf-album.cf-left-2 {
  transform: translate(-170%, -58%) rotateY(55deg) scale(0.65);
  z-index: 2;
  opacity: 0.5;
}

/* 右 +1 */
.cf-album.cf-right-1 {
  transform: translate(25%, -58%) rotateY(-55deg) scale(0.78);
  z-index: 5;
  box-shadow: -2px 2px 8px rgba(0, 0, 0, 0.2);
}

/* 右 +2 */
.cf-album.cf-right-2 {
  transform: translate(70%, -58%) rotateY(-55deg) scale(0.65);
  z-index: 2;
  opacity: 0.5;
}

.cf-info {
  position: absolute;
  bottom: 6px;
  left: 0;
  right: 0;
  text-align: center;
  z-index: 20;
}

.cf-album-name {
  font-size: 9px;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 10px;
  line-height: 1.3;
}

.cf-artist-name {
  font-size: 8px;
  color: #666;
  padding: 0 10px;
  line-height: 1.3;
}

/* ================================================
   歌詞表示
   ================================================ */

.lyrics-display {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
}

.lyrics-text {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-size: 9px;
  line-height: 1.7;
  color: var(--screen-text);
  text-align: center;
  padding: 6px 10px;
}

.lyrics-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  font-size: 11px;
  color: var(--screen-text);
  opacity: 0.5;
}

/* ================================================
   時計・メッセージ
   ================================================ */

.clock-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 4px;
}

.clock-time {
  font-size: 36px;
  font-weight: 700;
  color: var(--screen-text);
  letter-spacing: 1px;
}

.clock-seconds {
  font-size: 20px;
  font-weight: 400;
  opacity: 0.5;
}

.clock-date {
  font-size: 11px;
  color: var(--screen-text);
  opacity: 0.6;
}

.message-display {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 11px;
  color: var(--screen-text);
  text-align: center;
  padding: 12px;
  line-height: 1.6;
  opacity: 0.8;
}

/* ================================================
   クリックホイール
   ================================================ */

.click-wheel-container {
  position: absolute;
  bottom: 46px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
}

.click-wheel {
  position: relative;
  width: 178px;
  height: 178px;
  border-radius: 50%;
  background: var(--wheel-bg);
  box-shadow:
    0 0 0 1px var(--wheel-border),
    0 2px 8px var(--wheel-shadow-outer),
    inset 0 1px 2px var(--wheel-shadow-inner);
  cursor: pointer;
  touch-action: none;
  transition: background 0.5s ease, box-shadow 0.5s ease;
}

/* ホイールの微妙なテクスチャ */
.click-wheel::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%,
      rgba(255, 255, 255, 0.08) 0%,
      transparent 60%);
  pointer-events: none;
}

/* センターボタン */
.center-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--center-top), var(--center-bottom));
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.18),
    0 0 0 1px var(--center-border),
    inset 0 1px 0 var(--center-highlight);
  cursor: pointer;
  z-index: 10;
  transition: background 0.5s ease, box-shadow 0.5s ease;
  overflow: hidden;
}

/* センターボタンの粒状テクスチャ */
.center-button::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: white;
  filter: url(#grain-texture);
  opacity: 0.08;
  pointer-events: none;
  clip-path: inset(0 round 50%);
}

.center-button:hover {
  filter: brightness(1.03);
}

.center-button.pressed {
  filter: brightness(0.92);
  box-shadow:
    0 0 2px rgba(0, 0, 0, 0.2),
    0 0 0 1px var(--center-border),
    inset 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* ── ホイールラベル ── */

.wheel-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.wheel-label {
  position: absolute;
  font-size: 9px;
  font-weight: 600;
  color: var(--label-color);
  letter-spacing: 0.8px;
  transition: color 0.5s ease;
}

.wheel-label.top {
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  text-transform: uppercase;
}

.wheel-label.bottom {
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  letter-spacing: 1px;
}

.wheel-label.left {
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
}

.wheel-label.right {
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
}

/* ── ゾーン押下フィードバック ── */

.click-wheel[data-pressed-zone="menu"] .wheel-label.top,
.click-wheel[data-pressed-zone="play"] .wheel-label.bottom,
.click-wheel[data-pressed-zone="prev"] .wheel-label.left,
.click-wheel[data-pressed-zone="next"] .wheel-label.right {
  opacity: 0.5;
}

/* ================================================
   フォーカスリセット
   ================================================ */

*:focus {
  outline: none;
}