/* ──────────────────────────────────────────────────────────────
   VIBES FM — late-night tokyo fm
   instrument serif (display) · fragment mono (signal data)
   zen kaku gothic (日本語のアクセント)
   ────────────────────────────────────────────────────────────── */

:root {
  --ink: #f4efe6;          /* warm paper white */
  --ink-dim: rgba(244, 239, 230, 0.62);
  --ink-faint: rgba(244, 239, 230, 0.34);
  --onair: #ff4d3d;        /* broadcast red */
  --amber: #ffb45e;        /* dial lamp amber */
  --scrim: rgba(8, 10, 16, 0.42);
  --glass: rgba(10, 12, 20, 0.46);
  --hairline: rgba(244, 239, 230, 0.16);
  --serif: 'Instrument Serif', 'Times New Roman', serif;
  --mono: 'Fragment Mono', 'Courier New', monospace;
  --jp: 'Zen Kaku Gothic New', sans-serif;
}

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

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

body {
  background: #05060a;
  color: var(--ink);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  cursor: default;
}

body.idle { cursor: none; }

/* ── wallpaper layers + ken burns drift ───────────────────── */

.wall {
  position: fixed;
  inset: -1.5vmax;               /* slight bleed so the drift never shows edges */
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 2.8s ease;
  will-change: transform, opacity;
}

.wall.visible { opacity: 1; }

/* gentle zoom-drift for images near the screen's aspect */
.kb-a { animation: kbA 95s ease-in-out infinite alternate; }
.kb-b { animation: kbB 105s ease-in-out infinite alternate; }
.kb-c { animation: kbC 90s ease-in-out infinite alternate; }
.kb-d { animation: kbD 110s ease-in-out infinite alternate; }

@keyframes kbA { from { transform: scale(1.0) translate(0, 0); }        to { transform: scale(1.05) translate(-0.5%, -0.4%); } }
@keyframes kbB { from { transform: scale(1.045) translate(0.5%, 0.3%); } to { transform: scale(1.0) translate(0, 0); } }
@keyframes kbC { from { transform: scale(1.01) translate(-0.4%, 0.4%); } to { transform: scale(1.055) translate(0.4%, -0.3%); } }
@keyframes kbD { from { transform: scale(1.05) translate(0.3%, -0.5%); } to { transform: scale(1.0) translate(-0.3%, 0.3%); } }

/* slow lateral pan for ultrawide images — fit by height, travel the width */
.kb-pan-l, .kb-pan-r { background-size: auto 103%; }
.kb-pan-l { animation: kbPanL 120s ease-in-out infinite alternate; }
.kb-pan-r { animation: kbPanR 120s ease-in-out infinite alternate; }

@keyframes kbPanL { from { background-position: 0% 50%; }   to { background-position: 100% 50%; } }
@keyframes kbPanR { from { background-position: 100% 50%; } to { background-position: 0% 50%; } }

/* cinematic scrim so type always reads */
#scrim {
  position: fixed; inset: 0; pointer-events: none;
  background:
    linear-gradient(to top, rgba(5, 6, 10, 0.62) 0%, transparent 34%),
    linear-gradient(to bottom, rgba(5, 6, 10, 0.4) 0%, transparent 22%),
    radial-gradient(ellipse at center, transparent 52%, rgba(5, 6, 10, 0.36) 100%);
}

/* film grain — static, whisper-quiet texture */
#grain {
  position: fixed; inset: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 280 280' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.035;
}

/* tuning static burst */
#static {
  position: fixed; inset: 0; pointer-events: none; opacity: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='turbulence' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23s)'/%3E%3C/svg%3E");
}

#static.burst { animation: staticBurst 0.55s steps(6); }

@keyframes staticBurst {
  0% { opacity: 0; }
  15% { opacity: 0.5; transform: translateX(-6px); }
  40% { opacity: 0.35; transform: translateX(5px); }
  70% { opacity: 0.18; transform: translateX(-3px); }
  100% { opacity: 0; transform: none; }
}

/* ── chrome: corners ──────────────────────────────────────── */

.ui {
  position: fixed; z-index: 10;
  transition: opacity 1.4s ease;
}

body.idle .ui { opacity: 0; pointer-events: none; }
body.idle #grain { opacity: 0.025; }

/* wordmark, top-left */
#wordmark { top: 28px; left: 32px; line-height: 1.25; }

#wordmark .mark {
  font-family: var(--serif); font-style: italic;
  font-size: 28px; letter-spacing: 0.01em;
}

#wordmark .mark span { color: var(--amber); }

#wordmark .deco {
  font-size: 10px; letter-spacing: 0.34em;
  color: var(--ink-faint); text-transform: uppercase;
  font-family: var(--jp);
  margin-top: 4px;
}

/* clock, top-right */
#clock { top: 28px; right: 32px; text-align: right; }

#clock .time { font-size: 40px; letter-spacing: 0.04em; font-weight: 400; }

#clock .time .colon { animation: blink 2s steps(1) infinite; color: var(--amber); }

@keyframes blink { 50% { opacity: 0.15; } }

#clock .meta {
  margin-top: 2px; font-size: 10px; letter-spacing: 0.22em;
  color: var(--ink-dim); text-transform: uppercase;
}

#clock .meta .sep { color: var(--ink-faint); padding: 0 6px; }

/* wallpaper caption, mid-right edge */
#wall-caption {
  right: 32px; bottom: 132px;
  writing-mode: vertical-rl;
  font-family: var(--jp);
  font-size: 11px; letter-spacing: 0.42em;
  color: var(--ink-faint);
  text-transform: lowercase;
}

/* ── station block, bottom-left ───────────────────────────── */

#station-block { left: 32px; bottom: 30px; max-width: min(640px, 70vw); }

#onair-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--ink-dim);
}

#onair-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--onair);
  box-shadow: 0 0 10px var(--onair), 0 0 22px rgba(255, 77, 61, 0.5);
  animation: pulse 2.4s ease-in-out infinite;
}

#onair-dot.paused {
  background: var(--ink-faint); box-shadow: none; animation: none;
}

@keyframes pulse { 50% { opacity: 0.45; } }

#st-freq { color: var(--amber); letter-spacing: 0.18em; }

#st-name {
  font-family: var(--serif); font-style: italic; font-weight: 400;
  font-size: clamp(44px, 7vw, 84px);
  line-height: 1.02; margin: 10px 0 2px -3px;
  text-shadow: 0 2px 30px rgba(5, 6, 10, 0.55);
}

#st-sub {
  font-family: var(--jp); font-weight: 300;
  font-size: clamp(14px, 1.6vw, 19px);
  letter-spacing: 0.5em; color: var(--ink-dim);
  margin-bottom: 10px;
}

#st-desc { font-size: 11.5px; letter-spacing: 0.06em; color: var(--ink-dim); }

#nowplaying {
  margin-top: 10px; font-size: 11.5px; color: var(--amber);
  letter-spacing: 0.04em; max-width: 56ch;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

#nowplaying::before { content: '♪ '; color: var(--ink-faint); }

#nowplaying.hidden { visibility: hidden; }

/* dial */
#dial-row { display: flex; align-items: center; gap: 14px; margin-top: 18px; }

#dial { display: flex; align-items: flex-end; gap: 7px; height: 22px; }

.tick {
  width: 3px; height: 12px; border: 0; padding: 0; cursor: pointer;
  background: var(--ink-faint); transition: all 0.25s ease;
}

.tick:hover { background: var(--ink-dim); height: 18px; }

.tick.active {
  background: var(--amber); height: 22px;
  box-shadow: 0 0 8px rgba(255, 180, 94, 0.7);
}

.chev {
  background: none; border: 1px solid var(--hairline); color: var(--ink-dim);
  font-family: var(--mono); font-size: 13px;
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  transition: all 0.25s ease;
}

.chev:hover { border-color: var(--amber); color: var(--amber); }

/* ── transport, bottom-right ──────────────────────────────── */

#transport {
  right: 32px; bottom: 30px;
  display: flex; align-items: center; gap: 16px;
}

#btn-play {
  background: none; border: 1px solid var(--hairline); color: var(--ink);
  width: 52px; height: 52px; border-radius: 50%;
  font-size: 15px; cursor: pointer; font-family: var(--mono);
  backdrop-filter: blur(6px);
  background: var(--glass);
  transition: all 0.25s ease;
}

#btn-play:hover { border-color: var(--amber); color: var(--amber); transform: scale(1.05); }

.mini {
  background: none; border: 0; color: var(--ink-dim);
  font-size: 15px; cursor: pointer; padding: 6px;
  font-family: var(--mono);
  transition: color 0.2s ease;
}

.mini:hover { color: var(--amber); }

#vol-wrap { display: flex; align-items: center; gap: 8px; }

#vol-slider {
  -webkit-appearance: none; appearance: none;
  width: 90px; height: 2px; background: var(--hairline);
  outline: none; cursor: pointer;
}

#vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--ink); cursor: pointer;
  transition: background 0.2s;
}

#vol-slider::-webkit-slider-thumb:hover { background: var(--amber); }

#vol-slider::-moz-range-thumb {
  width: 11px; height: 11px; border-radius: 50%; border: 0;
  background: var(--ink); cursor: pointer;
}

#btn-spotify { font-size: 12px; letter-spacing: 0.14em; text-transform: lowercase; }

/* ── spotify drawer ───────────────────────────────────────── */

#spotify-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 40;
  width: min(420px, 92vw);
  background: rgba(8, 10, 16, 0.88);
  backdrop-filter: blur(18px);
  border-left: 1px solid var(--hairline);
  transform: translateX(102%);
  transition: transform 0.5s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex; flex-direction: column;
  padding: 26px 22px;
}

#spotify-drawer.open { transform: translateX(0); }

#sp-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 14px;
}

#sp-head h2 {
  font-family: var(--serif); font-style: italic; font-weight: 400;
  font-size: 26px;
}

#sp-close {
  background: none; border: 0; color: var(--ink-dim);
  font-size: 18px; cursor: pointer; font-family: var(--mono);
}

#sp-close:hover { color: var(--amber); }

#sp-note { font-size: 10px; color: var(--ink-faint); letter-spacing: 0.08em; margin-bottom: 14px; }

#sp-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }

.sp-tab {
  background: none; border: 1px solid var(--hairline); color: var(--ink-dim);
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.05em;
  padding: 6px 10px; border-radius: 999px; cursor: pointer;
  transition: all 0.2s ease;
}

.sp-tab:hover { color: var(--ink); }

.sp-tab.active { border-color: var(--amber); color: var(--amber); }

#sp-frame { flex: 1; border: 0; border-radius: 12px; min-height: 0; }

/* ── start overlay ────────────────────────────────────────── */

#start-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px;
  background: rgba(5, 6, 10, 0.55);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: opacity 1.1s ease, visibility 1.1s;
}

#start-overlay.gone { opacity: 0; visibility: hidden; }

#start-overlay .big {
  font-family: var(--serif); font-style: italic;
  font-size: clamp(54px, 9vw, 110px);
  animation: fadeUp 1.4s ease both;
}

#start-overlay .big span { color: var(--amber); }

#start-overlay .jp {
  font-family: var(--jp); font-weight: 300;
  letter-spacing: 0.6em; font-size: 13px; color: var(--ink-dim);
  animation: fadeUp 1.4s 0.25s ease both;
}

#start-overlay .hint {
  margin-top: 26px; font-size: 11px; letter-spacing: 0.3em;
  text-transform: uppercase; color: var(--ink-dim);
  border: 1px solid var(--hairline); border-radius: 999px;
  padding: 12px 26px;
  animation: fadeUp 1.4s 0.5s ease both, breathe 3s 2s ease-in-out infinite;
}

#start-overlay .keys {
  font-size: 9.5px; letter-spacing: 0.18em; color: var(--ink-faint);
  animation: fadeUp 1.4s 0.7s ease both;
}

@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

@keyframes breathe { 50% { border-color: var(--amber); color: var(--amber); } }

/* hidden yt player — offscreen but alive */
#yt-stage {
  position: fixed; left: -9999px; top: -9999px;
  width: 480px; height: 270px;
}

/* small screens */
@media (max-width: 640px) {
  #wordmark .deco, #clock .meta, #wall-caption, #st-desc { display: none; }
  #clock .time { font-size: 26px; }
  #station-block { bottom: 96px; max-width: 86vw; }
  #transport { right: 16px; left: 16px; bottom: 24px; justify-content: space-between; }
  #vol-slider { width: 60px; }
  #station-block { left: 16px; }
  #wordmark { left: 16px; top: 20px; }
  #clock { right: 16px; top: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .wall, #grain { animation: none !important; }
}
