/* ————————————————————————————————————————
   blinker.ink — sumi-e ink wash, mellow blink
   ———————————————————————————————————————— */

:root {
  --paper:      #f4f1ea;
  --paper-deep: #ece7dc;
  --ink:        #232220;
  --ink-soft:   #4a4844;
  --ink-faint:  #8b877e;
  --ink-wash:   rgba(35, 34, 32, 0.06);
  --seal:       #a4453a;
  --serif: "EB Garamond", "Iowan Old Style", Georgia, serif;
  --brush: "Ma Shan Zheng", var(--serif);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100vh;
  background:
    /* faint paper grain */
    radial-gradient(ellipse at 20% 10%, rgba(0,0,0,0.025), transparent 55%),
    radial-gradient(ellipse at 85% 90%, rgba(0,0,0,0.03),  transparent 50%),
    var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ——— per-song ink splash ——— */
.splash-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity 1.6s ease; /* old wash fades away */
}
.splash-layer.on { opacity: 1; }

/* wrapper is animated (cheap composited transform);
   the filtered child is rasterised once — keeps turbulence filters off the animation path */
.blob, .droplet {
  position: absolute;
  transform-origin: var(--origin, 0% 50%); /* stroke is laid down from one end */
  transform: scale(0.1) rotate(var(--rot, 0deg));
  opacity: 0;
  animation:
    splat 2.3s cubic-bezier(0.22, 0.65, 0.28, 1) var(--delay, 0s) both,
    floaty 34s ease-in-out calc(var(--delay, 0s) + 2.5s) infinite alternate;
}
.blob-ink {
  width: 100%; height: 100%;
  background: radial-gradient(closest-side,
    var(--ink-core) 30%,
    var(--ink-rim) 60%,
    transparent 78%);
  filter: var(--ink-filter);
  mix-blend-mode: multiply;
}
.droplet {
  border-radius: 50%;
  filter: url(#ink-dot);
  mix-blend-mode: multiply;
}

/* paper tooth over the washes, under the content */
.grain {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: 0.35;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="260" height="260"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.75" numOctaves="2" stitchTiles="stitch" seed="8"/><feColorMatrix type="matrix" values="0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.9 -0.62"/></filter><rect width="260" height="260" filter="url(%23n)"/></svg>');
}

@keyframes splat {
  0%   { transform: scale(0.1) rotate(var(--rot, 0deg)); opacity: 0; }
  55%  { opacity: var(--peak, 1); }
  78%  { transform: scale(1.03) rotate(var(--rot, 0deg)); }
  100% { transform: scale(1) rotate(var(--rot, 0deg)); opacity: var(--peak, 1); }
}
@keyframes floaty {
  from { translate: 0 0; }
  to   { translate: var(--drift-x, 2vmax) var(--drift-y, 3vmax); }
}

/* ——— layout ——— */
.page {
  position: relative;
  z-index: 1;
  max-width: 34rem;
  margin: 0 auto;
  padding: clamp(2rem, 6vh, 4.5rem) 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ——— player ——— */
.player {
  width: 100%;
  background: rgba(255,255,255,0.35);
  border: 1px solid rgba(35,34,32,0.14);
  border-radius: 10px;
  padding: 1.1rem 1.25rem 1.25rem;
  box-shadow: 0 1px 0 rgba(255,255,255,0.5) inset, 0 10px 30px -18px rgba(35,34,32,0.35);
  backdrop-filter: blur(2px);
}

.now-playing {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
  min-height: 1.6em;
}
.now-label {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.track-title {
  font-size: 1.15rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.1rem;
  margin-bottom: 1rem;
}
.ctl {
  appearance: none;
  border: 1px solid rgba(35,34,32,0.2);
  background: transparent;
  color: var(--ink-soft);
  width: 44px; height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background-color 0.35s ease, color 0.35s ease, transform 0.35s ease;
}
.ctl svg { width: 20px; height: 20px; fill: currentColor; }
.ctl svg[hidden] { display: none; } /* `hidden` attr is not honoured on SVG */
.ctl:hover { background: var(--ink-wash); color: var(--ink); }
.ctl:active { transform: scale(0.94); }
.ctl-play {
  width: 58px; height: 58px;
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.ctl-play:hover { background: var(--ink-soft); color: var(--paper); }
.ctl-play svg { width: 24px; height: 24px; }
.ctl:focus-visible, #seek:focus-visible, .track:focus-visible {
  outline: 2px solid var(--seal);
  outline-offset: 3px;
}

.timeline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.time {
  font-size: 0.8rem;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  min-width: 2.6em;
}
.time:last-child { text-align: right; }

#seek {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  height: 22px;
  background: transparent;
  cursor: pointer;
}
#seek::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(to right,
    var(--ink) 0%, var(--ink) var(--fill, 0%),
    rgba(35,34,32,0.18) var(--fill, 0%));
}
#seek::-moz-range-track {
  height: 3px; border-radius: 2px;
  background: rgba(35,34,32,0.18);
}
#seek::-moz-range-progress {
  height: 3px; border-radius: 2px;
  background: var(--ink);
}
#seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--ink);
  margin-top: -5px;
  transition: transform 0.3s ease;
}
#seek::-moz-range-thumb {
  width: 13px; height: 13px; border: none;
  border-radius: 50%;
  background: var(--ink);
}
#seek:hover::-webkit-slider-thumb { transform: scale(1.25); }

/* ——— track list ——— */
.tracklist {
  width: 100%;
  list-style: none;
  margin-top: 1.75rem;
  border-top: 1px solid rgba(35,34,32,0.14);
}
.track {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.8rem 0.5rem;
  border: none;
  border-bottom: 1px solid rgba(35,34,32,0.1);
  background: transparent;
  font-family: var(--serif);
  font-size: 1.08rem;
  color: var(--ink-soft);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.4s ease, color 0.4s ease, padding-left 0.4s ease;
}
.track:hover { background: var(--ink-wash); color: var(--ink); padding-left: 0.85rem; }
.track .num {
  font-size: 0.75rem;
  color: var(--ink-faint);
  min-width: 1.6em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.track .name { flex: 1; }
.track.active { color: var(--ink); }
.track.active .name { font-weight: 500; }

/* slow ink pulse on the playing row — no strobing */
.pulse {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--seal);
  opacity: 0;
  flex-shrink: 0;
}
.track.playing .pulse { opacity: 0.9; animation: ink-pulse 3.2s ease-in-out infinite; }
@keyframes ink-pulse {
  0%, 100% { transform: scale(0.7); opacity: 0.45; }
  50%      { transform: scale(1);   opacity: 0.9; }
}

/* ——— the blink: occasional gentle double-flash of the fresh wash ——— */
.splash-layer.double-flash { animation: double-flash 1.9s ease-in-out; }
@keyframes double-flash {
  0%, 100% { opacity: 1; }
  14%      { opacity: 0.5; }
  28%      { opacity: 1; }
  42%      { opacity: 0.5; }
  60%      { opacity: 1; }
}

/* ——— calm always wins: no motion for those who ask ——— */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.15s !important;
  }
}
