/* A-Music · 聽見音樂 — mobile-first responsive styles */
/* Copyright (C) 2026 Yueyu Hoshizora · SPDX-License-Identifier: AGPL-3.0-or-later */

/* Two explicit themes. js/theme.js always sets data-theme on <html>
 * (stored choice, otherwise the OS preference), so no media query is needed. */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0b12;
  --bg-soft: #13131f;
  --surface: #181826;
  --surface-2: #1f1f30;
  --line: #2b2b40;
  --text: #f2f2f7;
  --muted: #a0a0b8;
  --brand: #7c5cff;
  --brand-2: #ff5c9d;
  --ring: rgba(124, 92, 255, .55);
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --thumb-bg: #1f1f30;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f6fb;
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-2: #eeeef6;
  --line: #e0e0ee;
  --text: #17172a;
  --muted: #5b5b78;
  --brand: #6741f0;
  --brand-2: #e63f86;
  --ring: rgba(103, 65, 240, .45);
  --shadow: 0 10px 28px rgba(23, 23, 42, .1);
  --thumb-bg: #e6e6f0;
}

:root {
  --radius: 16px;
  --radius-sm: 10px;
  --maxw: 1240px;
  --header-h: 64px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans TC", "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI",
               "Hiragino Sans", "PingFang TC", "Microsoft JhengHei", Roboto, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
@media (hover: hover) and (pointer: fine) {
  a:hover { text-decoration: none; }
}
h1, h2, h3 { line-height: 1.25; margin: 0; }
p { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
mark { background: linear-gradient(transparent 55%, rgba(255, 92, 157, .45) 0); color: inherit; padding: 0 .1em; border-radius: 3px; }

:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--brand); color: #fff; padding: .6rem 1rem; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

/* ---------------- header ---------------- */

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: var(--maxw); margin: 0 auto;
  min-height: var(--header-h);
  padding: .6rem clamp(.9rem, 3vw, 1.5rem);
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: .6rem; margin-right: auto; }
.brand-mark { border-radius: 10px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-size: 1.05rem; letter-spacing: .02em; }
.brand-sub { font-size: .7rem; color: var(--muted); letter-spacing: .22em; text-transform: uppercase; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text); cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }
@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover { border-color: var(--brand); }
}

.nav-toggle .bars, .nav-toggle .bars::before, .nav-toggle .bars::after {
  display: block; width: 18px; height: 2px; background: currentColor; border-radius: 2px; position: relative;
}
.nav-toggle .bars::before, .nav-toggle .bars::after { content: ""; position: absolute; left: 0; }
.nav-toggle .bars::before { top: -6px; }
.nav-toggle .bars::after { top: 6px; }

.header-tools {
  display: none;
  width: 100%;
  flex-direction: column; gap: .75rem;
  padding: .4rem 0 .6rem;
}
body.nav-open .header-tools { display: flex; }

.site-nav { display: flex; gap: .35rem; flex-wrap: wrap; flex: 0 0 auto; }
.site-nav a {
  padding: .45rem .85rem; border-radius: 999px; font-size: .95rem;
  border: 1px solid transparent; color: var(--muted);
}
@media (hover: hover) and (pointer: fine) {
  .site-nav a:hover { color: var(--text); background: var(--surface-2); }
}
.site-nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); border-color: var(--line); }

.search-form { display: flex; gap: .5rem; flex: 0 0 auto; align-items: stretch; }
/* Pills must keep their intrinsic width: the search field absorbs the slack. */
.lang-switch, .theme-switch { align-self: flex-start; flex: 0 0 auto; }
.search-form input {
  flex: 1 1 auto; min-width: 0; height: 40px;
  padding: .6rem .9rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text); font: inherit; font-size: .95rem;
}
.search-form input::placeholder { color: var(--muted); }

.lang-switch { display: flex; gap: .25rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: .2rem; }
.lang-switch button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font: inherit; font-size: .82rem; padding: .3rem .7rem; border-radius: 999px; white-space: nowrap;
}
.lang-switch button.active { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }

.theme-switch { display: flex; gap: .2rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: .2rem; }
.theme-switch button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 26px; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.theme-switch button svg { width: 16px; height: 16px; fill: currentColor; }
.theme-switch button.active { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }

@media (min-width: 900px) {
  .nav-toggle { display: none; }
  .header-tools { display: flex !important; flex-direction: row; align-items: center; width: auto; padding: 0; gap: 1rem; }
  .search-form { flex: 0 1 320px; }
}

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

.app { max-width: var(--maxw); margin: 0 auto; padding: clamp(1rem, 3vw, 2rem) clamp(.9rem, 3vw, 1.5rem) 4rem; }
.view { display: flex; flex-direction: column; gap: clamp(1.75rem, 4vw, 2.75rem); }
.block { display: flex; flex-direction: column; gap: 1rem; }

.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem 1rem; }
.section-head h1, .section-head h2 { font-size: clamp(1.15rem, 2.6vw, 1.5rem); }
.section-head .muted { flex: 1 1 200px; font-size: .9rem; }
.section-link { color: var(--brand); font-size: .9rem; }
@media (hover: hover) and (pointer: fine) {
  .section-link:hover { text-decoration: underline; }
}

/* ---------------- hero ---------------- */

.hero {
  position: relative; overflow: hidden;
  border-radius: clamp(18px, 3vw, 26px);
  padding: clamp(1.5rem, 5vw, 3.25rem);
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(124, 92, 255, .35), transparent 55%),
    radial-gradient(120% 140% at 100% 20%, rgba(255, 92, 157, .3), transparent 55%),
    var(--surface);
  border: 1px solid var(--line);
}
.hero-copy { display: flex; flex-direction: column; gap: .9rem; max-width: 46rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .22em; font-size: .72rem; color: var(--brand-2); }
.hero h1 { font-size: clamp(1.75rem, 6vw, 3rem); }
.lede { color: var(--muted); font-size: clamp(.95rem, 2.2vw, 1.05rem); }
.hero-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .3rem; }

.stats { display: flex; flex-wrap: wrap; gap: 1.25rem 2rem; margin: 1rem 0 0; }
.stats .stat { display: flex; flex-direction: column; }
.stats dt { font-size: clamp(1.4rem, 4vw, 1.9rem); font-weight: 700; line-height: 1.1; }
.stats dd { margin: 0; color: var(--muted); font-size: .82rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .6rem 1.15rem; border-radius: 999px; font-size: .92rem; font-weight: 600;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {
  .btn:hover { border-color: var(--brand); }
}
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border-color: transparent; color: #fff; }
.btn.ghost { background: transparent; }
.btn.tiny { padding: .3rem .8rem; font-size: .8rem; }
.btn[disabled] { opacity: .55; cursor: progress; }

/* ---------------- chips & badges ---------------- */

.chip-row { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .25rem; scrollbar-width: none; -ms-overflow-style: none; }
.chip-row::-webkit-scrollbar { display: none; height: 0; }
.chip {
  flex: 0 0 auto; padding: .4rem .9rem; border-radius: 999px; font-size: .85rem;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.chip.active { color: var(--text); border-color: var(--brand); }
@media (hover: hover) and (pointer: fine) {
  .chip:hover { color: var(--text); border-color: var(--brand); }
  .chip-row { flex-wrap: wrap; overflow-x: visible; }
}

.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .6rem; border-radius: 999px; font-size: .75rem;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
}
.badge-icon { font-size: .85em; }
@media (hover: hover) and (pointer: fine) {
  .genre-badge:hover { color: var(--text); border-color: var(--brand); }
}
.badge.subtle { background: transparent; }

/* ---------------- grids & cards ---------------- */

.grid { display: grid; gap: clamp(.85rem, 2.2vw, 1.25rem); }
.video-grid { grid-template-columns: 1fr; }
.video-grid.single { grid-template-columns: minmax(0, 1fr) !important; max-width: 620px; }
.artist-grid { grid-template-columns: 1fr; }
.genre-grid { grid-template-columns: 1fr; }

@media (min-width: 560px) {
  .video-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .artist-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .genre-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 900px) {
  .video-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .artist-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .genre-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1240px) {
  .video-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .artist-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .genre-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.card {
  position: relative;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.card::before {
  content: "";
  position: absolute; inset: -1px; border-radius: inherit; padding: 1.5px;
  background: conic-gradient(from var(--card-glow-angle, 0deg),
    var(--brand), var(--brand-2), var(--brand-2), var(--brand), var(--brand));
  -webkit-mask-image: linear-gradient(#000 0 0), linear-gradient(#000 0 0);
  -webkit-mask-clip: content-box, border-box;
  -webkit-mask-composite: xor;
  mask-image: linear-gradient(#000 0 0), linear-gradient(#000 0 0);
  mask-clip: content-box, border-box;
  mask-composite: exclude;
  opacity: 0; transition: opacity .25s ease; pointer-events: none;
  animation: card-glow-spin 3.5s linear infinite paused;
}
@media (hover: hover) and (pointer: fine) {
  .card:hover::before, .card:focus-within::before { opacity: 1; animation-play-state: running; }
  .card:hover, .card:focus-within { transform: translateY(-2px); border-color: transparent; box-shadow: var(--shadow); }
}
.card.unavailable { opacity: .55; }

@property --card-glow-angle {
  syntax: "<angle>"; inherits: false; initial-value: 0deg;
}
@keyframes card-glow-spin { to { --card-glow-angle: 360deg; } }

.thumb {
  position: relative; aspect-ratio: 16 / 9; background: var(--thumb-bg); overflow: hidden;
  border-radius: var(--radius) var(--radius) 0 0;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb img.img-fallback { opacity: 0; }
.thumb .player { width: 100%; height: 100%; border: 0; }
.thumb.playing { aspect-ratio: 16 / 9; }

.play-btn {
  position: absolute; inset: 0; width: 100%; height: 100%;
  border: 0; background: transparent; cursor: pointer; display: grid; place-items: center;
}
.play-icon {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(10, 10, 18, .6); backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, .35);
  display: block; position: relative;
  transition: transform .18s ease, background .18s ease;
}
.play-icon::after {
  content: ""; position: absolute; top: 50%; left: 54%; transform: translate(-50%, -50%);
  border-style: solid; border-width: 9px 0 9px 15px; border-color: transparent transparent transparent #fff;
}
@media (hover: hover) and (pointer: fine) {
  .play-btn:hover .play-icon { transform: scale(1.08); background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
}

.duration {
  position: absolute; right: .5rem; bottom: .5rem;
  background: rgba(8, 8, 14, .8); color: #fff; font-size: .72rem;
  padding: .1rem .4rem; border-radius: 6px; letter-spacing: .02em;
}

.card-body { display: flex; flex-direction: column; gap: .55rem; padding: .85rem .9rem 1rem; flex: 1; }
.card-title {
  font-size: .96rem; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; flex-direction: column; gap: .2rem; }
.card-artist { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--muted); }
@media (hover: hover) and (pointer: fine) {
  .card-artist:hover { color: var(--text); }
}
.card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.yt-link { font-size: .78rem; color: var(--brand); }
@media (hover: hover) and (pointer: fine) {
  .yt-link:hover { text-decoration: underline; }
}

.video-card.featured .card-title { font-size: 1.08rem; -webkit-line-clamp: 3; }

.skeleton-text {
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  color: transparent;
  min-height: 1.2em;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ---------------- avatars & artists ---------------- */

.avatar {
  position: relative; overflow: hidden;
  display: inline-grid; place-items: center;
  width: 48px; height: 48px; border-radius: 50%; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-weight: 700; font-size: 1.05rem;
}
.avatar-xs { width: 22px; height: 22px; font-size: .65rem; }
.avatar-lg { width: 84px; height: 84px; font-size: 1.9rem; }
/* Photo sits on top of the initials fallback; it is removed if loading fails. */
.avatar img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover; border-radius: inherit;
  opacity: 0; transition: opacity .2s ease;
}
.avatar img.ready { opacity: 1; }

.artist-card { flex-direction: row; align-items: center; gap: .85rem; padding: .9rem; }
.artist-info { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.artist-name { font-size: 1rem; }
.artist-info .badge { align-self: flex-start; }

.genre-card { gap: .4rem; padding: 1rem; }
.genre-card .genre-icon { font-size: 1.6rem; }
.genre-card.empty { opacity: .6; }
.genre-card .badge { align-self: flex-start; margin-top: .35rem; }

/* ---------------- page heads ---------------- */

.page-head { display: flex; flex-direction: column; gap: .6rem; }
.page-head h1 { font-size: clamp(1.5rem, 5vw, 2.25rem); }
.back-link { color: var(--muted); font-size: .88rem; }
@media (hover: hover) and (pointer: fine) {
  .back-link:hover { color: var(--text); }
}

.artist-hero {
  display: flex; flex-direction: column; gap: 1rem;
  padding: clamp(1.1rem, 4vw, 2rem);
  border-radius: clamp(18px, 3vw, 24px);
  border: 1px solid var(--line);
  background:
    radial-gradient(100% 140% at 0% 0%, rgba(124, 92, 255, .28), transparent 60%),
    var(--surface);
}
.artist-hero-main { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.artist-hero h1 { font-size: clamp(1.4rem, 5vw, 2.1rem); margin-bottom: .5rem; }
.artist-tags { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .9rem; }
.artist-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.about .lede { max-width: 60rem; }

/* ---------------- masonry (瀑布流) ---------------- */

.masonry { display: flex; gap: clamp(.85rem, 2.2vw, 1.25rem); align-items: flex-start; }
.masonry-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: clamp(.85rem, 2.2vw, 1.25rem); }

.sentinel { height: 1px; }
.load-more { display: flex; flex-direction: column; align-items: center; gap: .6rem; padding: .5rem 0 0; }
.load-status { font-size: .85rem; }

/* ---------------- states ---------------- */

.loading { display: flex; align-items: center; gap: .6rem; color: var(--muted); padding: 1.5rem 0; grid-column: 1 / -1; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-box, .empty-state {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; align-items: flex-start; gap: .75rem;
  padding: 1.25rem; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted);
}

.scan { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; }
.scan .bar { flex: 1 1 200px; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.scan .bar-fill { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .25s ease; }
.hint code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 0 .3rem; font-size: .85em; }

/* ---------------- footer ---------------- */

.site-footer { border-top: 1px solid var(--line); background: var(--bg-soft); }
.footer-inner {
  max-width: var(--maxw); margin: 0 auto;
  padding: 1.5rem clamp(.9rem, 3vw, 1.5rem) 2.5rem;
  display: flex; flex-direction: column; gap: .35rem; color: var(--muted); font-size: .85rem;
}
.footer-brand { color: var(--text); }
.footer-meta a { color: var(--brand); }
@media (hover: hover) and (pointer: fine) {
  .footer-meta a:hover { text-decoration: underline; }
}
.dot { padding: 0 .35rem; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
