/* ============================
   listen.css — 聴く画面固有スタイル
   ============================ */

/* --- Variable overrides --- */

:root {
  --bg: #f5eee6;
  --panel-soft: #fff6ea;
  --shadow: 0 20px 42px rgba(42, 33, 25, 0.14);
}

/* --- Page background --- */

body {
  background:
    radial-gradient(circle at 10% 10%, rgba(255, 227, 196, 0.7), transparent 55%),
    radial-gradient(circle at 88% 16%, rgba(198, 231, 225, 0.65), transparent 55%),
    linear-gradient(120deg, #f5eee6 0%, #eef2f0 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    repeating-linear-gradient(30deg, rgba(255, 255, 255, 0.2) 0, rgba(255, 255, 255, 0.2) 6px, transparent 6px, transparent 18px);
  opacity: 0.3;
  pointer-events: none;
}

/* --- Header sticky --- */

header {
  position: sticky;
  top: 16px;
  z-index: 10;
}

/* --- Layout --- */

.layout {
  margin-top: 26px;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.left {
  display: grid;
  gap: 18px;
}

/* --- Card dashed border --- */

.card::after {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 18px;
  border: 1px dashed rgba(199, 155, 59, 0.25);
  pointer-events: none;
}

/* --- Now Playing Grid --- */

.now-grid {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 16px;
}

.thumb {
  border-radius: 18px;
  border: 1px solid var(--stroke);
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.9), rgba(230, 242, 242, 0.95)),
    radial-gradient(circle at 70% 20%, rgba(224, 123, 67, 0.2), transparent 60%);
  position: relative;
  display: grid;
  place-items: center;
  min-height: 170px;
  font-weight: 700;
  color: var(--secondary);
}

.thumb span {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(44, 111, 111, 0.15);
  border: 1px solid rgba(44, 111, 111, 0.3);
  font-size: 12px;
}

.scene-pill {
  position: absolute;
  bottom: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(224, 123, 67, 0.18);
  border: 1px solid rgba(224, 123, 67, 0.35);
  color: var(--primary);
  font-size: 11px;
}

.now-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
}

/* --- Meta --- */

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 12px;
  color: var(--muted);
}

.meta-pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(44, 111, 111, 0.12);
  color: var(--secondary);
  border: 1px solid rgba(44, 111, 111, 0.25);
  font-weight: 700;
}

.meta-pill.primary {
  background: rgba(224, 123, 67, 0.2);
  border-color: rgba(224, 123, 67, 0.45);
  color: var(--primary);
}

/* --- Info Block --- */

.info-block {
  display: grid;
  gap: 8px;
  font-size: 13px;
}

.info-block strong {
  color: var(--secondary);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.summary {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

/* --- Control Bar --- */

.control-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.control-bar input {
  flex: 1;
  min-width: 180px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  padding: 10px 12px;
  font-size: 12px;
  background: #fff;
}

/* --- Subtitle List --- */

.subtitle-list {
  display: grid;
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 8px;
  border-left: 3px solid rgba(44, 111, 111, 0.35);
  padding-left: 12px;
}

.subtitle-line {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  font-size: 13px;
  line-height: 1.5;
}

.subtitle-line.is-active {
  background: rgba(224, 123, 67, 0.1);
  border-radius: 12px;
  padding: 6px 8px;
}

.timecode {
  font-size: 11px;
  color: var(--muted);
}

.who {
  font-size: 11px;
  font-weight: 700;
  color: var(--secondary);
  background: rgba(44, 111, 111, 0.12);
  border-radius: 999px;
  padding: 4px 8px;
  display: inline-block;
}

.jump {
  border: 1px solid rgba(44, 111, 111, 0.35);
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(44, 111, 111, 0.1);
  color: var(--secondary);
  font-size: 11px;
  height: 26px;
  align-self: center;
  cursor: pointer;
}

/* --- List / List Item --- */

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 6px;
}

/* --- Section Title (listen) --- */

.section-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--secondary);
}

/* --- Session List --- */

.session-list {
  display: grid;
  gap: 12px;
  max-height: 400px;
  overflow-y: auto;
}

.session-card {
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 14px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.session-card:hover {
  border-color: var(--secondary);
  background: rgba(44, 111, 111, 0.05);
}

.session-card.is-active {
  border-color: var(--primary);
  background: rgba(224, 123, 67, 0.08);
}

.session-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.session-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
}

.session-duration {
  font-size: 11px;
  color: var(--muted);
  padding: 2px 8px;
  background: rgba(44, 111, 111, 0.1);
  border-radius: 999px;
}

.session-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  font-size: 11px;
}

.session-tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(224, 123, 67, 0.12);
  color: var(--primary);
}

.session-summary {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- Filter UI --- */

.filter-section {
  display: grid;
  gap: 12px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.filter-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  min-width: 50px;
}

.filter-chip {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: #fff;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-chip:hover {
  border-color: var(--secondary);
}

.filter-chip.is-active {
  background: var(--secondary);
  color: #fff;
  border-color: var(--secondary);
}

.filter-clear {
  font-size: 11px;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  margin-left: auto;
}

/* --- Playlist Queue --- */

.queue-section {
  border-top: 1px solid var(--stroke);
  padding-top: 14px;
  margin-top: 14px;
}

.queue-list {
  display: grid;
  gap: 8px;
  max-height: 150px;
  overflow-y: auto;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(44, 111, 111, 0.08);
  border-radius: 12px;
  font-size: 12px;
}

.queue-item.is-current {
  background: rgba(224, 123, 67, 0.15);
  border: 1px solid rgba(224, 123, 67, 0.3);
}

.queue-number {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--secondary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
}

.queue-item.is-current .queue-number {
  background: var(--primary);
}

.queue-remove {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}

/* --- Session Time --- */

.session-time {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
}

/* --- Queue Add Button --- */

.btn-queue-add {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(44, 111, 111, 0.4);
  background: rgba(44, 111, 111, 0.1);
  color: var(--secondary);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-queue-add:hover {
  background: var(--secondary);
  color: #fff;
}

/* --- Related Sessions Button --- */

.btn-related {
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(44, 111, 111, 0.35);
  background: rgba(44, 111, 111, 0.1);
  color: var(--secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-related:hover {
  background: var(--secondary);
  color: #fff;
}

.btn-related:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Scrollbar --- */

.subtitle-list::-webkit-scrollbar,
.session-list::-webkit-scrollbar,
.queue-list::-webkit-scrollbar {
  width: 8px;
}

.subtitle-list::-webkit-scrollbar-thumb,
.session-list::-webkit-scrollbar-thumb,
.queue-list::-webkit-scrollbar-thumb {
  background: rgba(44, 111, 111, 0.35);
  border-radius: 999px;
}

.subtitle-list::-webkit-scrollbar-track,
.session-list::-webkit-scrollbar-track,
.queue-list::-webkit-scrollbar-track {
  background: rgba(226, 209, 193, 0.5);
  border-radius: 999px;
}

/* --- Playing Indicator --- */

.session-card.is-playing {
  border-color: var(--primary);
  background: rgba(224, 123, 67, 0.12);
  position: relative;
}

.session-card.is-playing::before {
  content: "\25B6 \518D\751F\4E2D";
  position: absolute;
  top: 10px;
  right: 10px;
  color: #fff;
  background: var(--primary);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}

/* --- Listened Indicator --- */

.session-card.is-listened .session-title::after {
  content: " \2713";
  color: var(--secondary);
  font-size: 14px;
  font-weight: 700;
}

/* --- NEW Badge --- */

.badge-new {
  display: inline-block;
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
  animation: pulse-new 2s ease-in-out infinite;
}

@keyframes pulse-new {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* --- Heartbeat Pulse Animation (pending state) --- */

@keyframes pulse-heartbeat {
  0% { transform: scale(1); }
  5% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.btn.pulse-heartbeat {
  animation: pulse-heartbeat 1s ease-out infinite;
}

/* --- Play Session Button --- */

.btn-play-session {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  border: none;
  background: var(--secondary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-play-session:hover {
  background: #245858;
  transform: translateY(-1px);
}

.btn-play-session::before {
  content: "\25B6";
  font-size: 10px;
}

/* --- Playlist hidden elements --- */

.btn-queue-add,
#addRelatedBtn,
#queueSection {
  display: none !important;
}

/* --- Auto-next Dialog --- */

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.dialog-box {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 24px 32px;
  box-shadow: var(--shadow);
  text-align: center;
  max-width: 360px;
  animation: float-in 0.3s ease;
}

.dialog-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.dialog-summary {
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 16px;
  padding: 12px;
  background: var(--panel-soft);
  border-radius: 12px;
  line-height: 1.5;
}

.dialog-countdown {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 20px;
}

.dialog-countdown #countdownNumber {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.dialog-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--stroke);
  color: var(--muted);
}

.btn-secondary:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* --- Responsive --- */

@media (max-width: 1020px) {
  header { position: static; }
  .layout { grid-template-columns: 1fr; }
  .now-grid { grid-template-columns: 1fr; }
}
