/* Red Protocol: File 01, the playlist. Builds on theme.css + app.css */

/* ---------- sticky status bar (phones) ---------- */

.status-bar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 40;
  margin-top: 18px;
  background: rgba(7, 5, 5, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-block: 1px solid var(--line-soft);
}

.status-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 11px var(--gutter-r) 11px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.votes-left { display: flex; align-items: center; gap: 12px; font-size: 0.86rem; font-weight: 500; }

/* ---------- layout ---------- */

.layout {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px var(--gutter-r) 40px var(--gutter);
  display: grid;
  gap: 24px;
}

.layout[hidden] { display: none; }
.sidebar { display: grid; gap: 20px; align-content: start; min-width: 0; }
.list-section { min-width: 0; }

@media (min-width: 960px) {
  .layout { grid-template-columns: 340px minmax(0, 1fr); gap: 36px; padding-top: 36px; }
  .sidebar {
    position: sticky;
    top: 24px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
  }
  .status-bar { display: none; }
}

@media (max-width: 959px) {
  .votes-card { display: none; }
  .kbd { display: none; }
}

/* ---------- cards ---------- */

.votes-card {
  border-color: var(--red-line);
  box-shadow: 0 20px 50px -28px rgba(255, 20, 20, 0.6);
}

.votes-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.votes-card-head h2 { margin-bottom: 0; }
.votes-big { margin: 20px 0 14px; }
.votes-text { margin: 0; font-weight: 600; font-size: 1rem; }
.votes-help { margin: 6px 0 0; font-size: 0.84rem; color: var(--muted); }

/* ---------- toolbar ---------- */

.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; }

.segmented {
  display: inline-flex;
  flex-shrink: 0;
  padding: 3px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.seg {
  font-family: var(--f-ui);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 9px 14px;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.seg:hover { color: var(--text); }
.seg.is-active { color: #fff; background: var(--red-wash); box-shadow: inset 0 0 0 1px var(--red-line); }

.search { position: relative; flex: 1; max-width: 320px; }
.search input { padding: 10px 36px 10px 13px; font-size: 0.92rem; }

.kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font: 700 0.72rem var(--f-mono);
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 6px;
  pointer-events: none;
}

.search input:focus + .kbd { display: none; }

.list-meta { margin: 16px 2px 12px; font-size: 0.8rem; color: var(--dim); letter-spacing: 0.04em; }

/* ---------- song list ---------- */

.songs { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.song {
  position: relative;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 16px 16px 16px 12px;
  background: linear-gradient(180deg, var(--ink-3), var(--ink-2));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
}

.song:hover { border-color: var(--line); background: linear-gradient(180deg, var(--ink-4), var(--ink-3)); }
.song.is-voted { border-color: var(--red-line); }
.song.flash { animation: flash 1.8s var(--ease); }

.song.top-1 {
  border-color: rgba(255, 52, 52, 0.55);
  box-shadow: 0 0 0 1px rgba(255, 40, 40, 0.1), 0 18px 46px -24px rgba(255, 20, 20, 0.7);
}

.rank {
  font-family: var(--f-display);
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--dim);
  line-height: 1;
}

.top-1 .rank { color: var(--red-hot); text-shadow: 0 0 14px rgba(255, 30, 30, 0.55); }
.top-2 .rank, .top-3 .rank { color: var(--silver-2); }

.info { min-width: 0; }

.title { margin: 0; font-weight: 600; font-size: 1.04rem; line-height: 1.3; overflow-wrap: anywhere; }
.meta { margin: 3px 0 0; font-size: 0.88rem; color: var(--muted); overflow-wrap: anywhere; }
.sub { margin: 3px 0 0; font-family: var(--f-type); font-size: 0.78rem; color: var(--dim); overflow-wrap: anywhere; }

.listen { color: inherit; text-decoration: none; white-space: nowrap; transition: color 0.2s; }
.by + .listen::before { content: "/"; margin: 0 8px; opacity: 0.6; }
.listen:hover { color: var(--red-hot); }

.bar {
  position: relative;
  display: block;
  height: 2px;
  margin-top: 12px;
  background: var(--line-soft);
  overflow: hidden;
}

.bar::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--share, 0%);
  background: linear-gradient(90deg, var(--red-deep), var(--red-hot));
  box-shadow: 0 0 8px var(--red-glow);
  transition: width 0.5s var(--ease);
}

/* vote button: an empty seal ring that becomes a wax seal when voted */
.vote {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 62px;
  padding: 4px 6px;
  font: inherit;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
}

.vote-seal {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px dashed var(--red-line);
  transition: transform 0.2s var(--ease), border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.vote-seal svg { width: 20px; height: 18px; color: var(--dim); transition: color 0.2s; }

.vote .count {
  font-family: var(--f-mono);
  font-weight: 700;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.vote:hover:not(:disabled) .vote-seal { border-style: solid; border-color: var(--red-hot); box-shadow: 0 0 16px -2px var(--red-glow); }
.vote:hover:not(:disabled) .vote-seal svg { color: var(--red-hot); }
.vote:active:not(:disabled) .vote-seal { transform: scale(0.92); }

.vote[aria-pressed="true"] .vote-seal {
  border: 0;
  border-radius: 46% 54% 50% 50% / 52% 48% 54% 46%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 140, 120, 0.55), transparent 40%),
    radial-gradient(circle at 50% 50%, #c4121b 0 52%, #8e0a10 72%, #5e060a 100%);
  box-shadow: 0 0 0 3px rgba(150, 10, 16, 0.5), 0 6px 16px rgba(0, 0, 0, 0.6), 0 0 18px -2px var(--red-glow), inset 0 -4px 8px rgba(0, 0, 0, 0.45);
  animation: press 0.45s var(--ease);
}

.vote[aria-pressed="true"] .vote-seal svg { color: #6e070c; filter: drop-shadow(0 1px 0 rgba(255, 130, 120, 0.45)); }
.vote[aria-pressed="true"] .count { color: var(--red-hot); }

.vote:disabled { cursor: not-allowed; }
.vote:disabled:not([aria-pressed="true"]) .vote-seal { opacity: 0.35; }
.vote[aria-pressed="true"]:disabled .vote-seal { opacity: 0.8; }
.voting-closed .vote:disabled { cursor: default; }

.remove {
  position: absolute;
  top: -9px;
  right: -9px;
  width: 26px;
  height: 26px;
  font-size: 1rem;
  line-height: 1;
  color: var(--muted);
  background: var(--ink-4);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
}

.remove:hover { color: #fff; background: var(--red); border-color: var(--red-hot); }

@media (hover: hover) {
  .remove { opacity: 0; transition: opacity 0.15s; }
  .song:hover .remove, .remove:focus-visible { opacity: 1; }
}

@keyframes press { 0% { transform: scale(1.35) rotate(-8deg); opacity: 0.4; } 60% { transform: scale(0.94); opacity: 1; } 100% { transform: none; } }

/* ---------- small screens ---------- */

@media (max-width: 560px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .search { max-width: none; }
  .segmented { align-self: flex-start; }
  .seg { padding: 9px 11px; letter-spacing: 0.14em; }
  .song { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; padding: 14px 10px 14px 6px; }
  .rank { font-size: 1.25rem; }
  .vote { min-width: 52px; }
  .vote-seal { width: 40px; height: 40px; }
  .votes-left { font-size: 0.8rem; gap: 10px; }
}

/* ---------- atmosphere: a scan line sweeps a row on hover ---------- */

.song::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(90deg, transparent 40%, rgba(255, 50, 50, 0.06) 47%, rgba(255, 90, 80, 0.3) 49.5%, transparent 50%) no-repeat;
  background-size: 300% 100%;
  background-position: 100% 0;
  opacity: 0;
}

.song:hover::after { animation: rowscan 0.9s var(--ease) 1; }
.song .remove { z-index: 2; }

@keyframes rowscan {
  0% { background-position: 100% 0; opacity: 1; }
  100% { background-position: 0% 0; opacity: 1; }
}
