/* ============================================================
   L4D2 地图下载助手 — Apple-style glass redesign
   Dark, premium, glassmorphic, with calm ambient motion.
   All JS hooks (#inputs, .card, .btn, .progress, …) preserved.
   ============================================================ */

:root {
  --bg: #07070b;
  --text: #f5f5f7;
  --dim: rgba(235, 235, 245, 0.6);
  --dim-2: rgba(235, 235, 245, 0.35);

  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(255, 255, 255, 0.085);
  --hairline: rgba(255, 255, 255, 0.1);
  --hairline-strong: rgba(255, 255, 255, 0.16);

  --accent: #ff6a3d;
  --accent-2: #ff2d78;
  --accent-grad: linear-gradient(135deg, #ff7a45 0%, #ff2d78 100%);
  --accent-glow: rgba(255, 76, 97, 0.45);

  --radius: 22px;
  --radius-sm: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --maxw: 880px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  /* Rich fixed gradient so the background is unmistakably colourful, even if
     the animated orb layer is occluded on some browsers. */
  background:
    radial-gradient(1000px 720px at 12% -5%, rgba(255, 106, 61, 0.28), transparent 55%),
    radial-gradient(900px 720px at 88% 12%, rgba(255, 45, 120, 0.24), transparent 55%),
    radial-gradient(1100px 820px at 50% 108%, rgba(106, 92, 255, 0.22), transparent 55%),
    linear-gradient(180deg, #0c0c15 0%, #08080d 60%, #060609 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* ---------- Ambient backdrop ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
main { position: relative; z-index: 1; }
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.7;
  will-change: transform;
}
.orb-a {
  width: 46vw; height: 46vw; left: -8vw; top: -6vw;
  background: radial-gradient(circle, #ff6a3d, transparent 70%);
  animation: drift-a 26s var(--ease) infinite alternate;
}
.orb-b {
  width: 40vw; height: 40vw; right: -6vw; top: 10vh;
  background: radial-gradient(circle, #ff2d78, transparent 70%);
  animation: drift-b 32s var(--ease) infinite alternate;
}
.orb-c {
  width: 44vw; height: 44vw; left: 20vw; bottom: -18vw;
  background: radial-gradient(circle, #6a5cff, transparent 70%);
  opacity: 0.4;
  animation: drift-c 38s var(--ease) infinite alternate;
}
.grain {
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 3px 3px;
  mix-blend-mode: overlay;
}
@keyframes drift-a { to { transform: translate(8vw, 6vh) scale(1.15); } }
@keyframes drift-b { to { transform: translate(-6vw, 10vh) scale(1.1); } }
@keyframes drift-c { to { transform: translate(6vw, -8vh) scale(1.2); } }

/* ---------- Layout ---------- */
main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(40px, 8vh, 96px) 20px 100px;
}

/* ---------- Hero ---------- */
.hero { text-align: center; margin-bottom: 40px; }
.badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--hairline);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--dim);
  margin-bottom: 22px;
}
.hero h1 {
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.05;
  background: linear-gradient(180deg, #ffffff 30%, rgba(255, 255, 255, 0.7));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .sub {
  margin: 14px auto 0;
  max-width: 30ch;
  color: var(--dim);
  font-size: clamp(1rem, 2.4vw, 1.2rem);
}

/* ---------- Glass panels ---------- */
.panel {
  background: var(--glass);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 30px 60px -30px rgba(0, 0, 0, 0.7);
  padding: 26px;
  margin-bottom: 22px;
}

/* ---------- Tutorial ---------- */
.notice-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.notice-icon { font-size: 22px; }
.notice h2 { margin: 0; font-size: 1.15rem; font-weight: 650; letter-spacing: -0.02em; }
.notice ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.notice li { display: flex; gap: 14px; align-items: flex-start; }
.step-n {
  flex: 0 0 26px;
  height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent-grad);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 4px 14px -4px var(--accent-glow);
}
.notice li > div { flex: 1; font-size: 14.5px; color: rgba(245, 245, 247, 0.85); }
code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--hairline);
  padding: 2px 7px;
  border-radius: 7px;
  overflow-wrap: anywhere;
}
code.path { display: inline-block; margin-top: 6px; line-height: 1.9; }
.tut-img {
  display: block;
  margin-top: 12px;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline);
  box-shadow: 0 20px 40px -24px rgba(0, 0, 0, 0.8);
}

/* ---------- Search form ---------- */
.search-row { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
#inputs { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.input-row { animation: rise 0.5s var(--ease) both; }
.input-wrap { position: relative; display: flex; }
.link-input {
  flex: 1;
  min-width: 0;
  padding: 15px 44px 15px 16px; /* right room for the inline clear button */
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease), background 0.25s var(--ease);
}
.link-input::placeholder { color: var(--dim-2); }
.link-input:focus {
  outline: none;
  border-color: rgba(255, 106, 61, 0.7);
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 0 0 0 4px rgba(255, 106, 61, 0.14);
}
/* Inline clear button, sitting inside the input on the right (iOS-style) */
.input-row .remove {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--dim);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.15s var(--spring);
}
.input-row .remove:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }
.input-row .remove:active { transform: translateY(-50%) scale(0.85); }

.submit { flex: 0 0 auto; padding: 15px 30px; }

.form-actions { display: flex; }
#add-input {
  padding: 12px 18px;
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), transform 0.2s var(--spring);
}
#add-input:hover { border-color: var(--accent); background: rgba(255, 106, 61, 0.08); }
#add-input:active { transform: scale(0.97); }

/* ---------- Buttons ---------- */
.btn, .submit {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline);
  background: var(--glass-strong);
  color: var(--text);
  font-size: 14.5px;
  font-weight: 550;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.22s var(--spring), box-shadow 0.25s var(--ease),
    background 0.2s var(--ease), border-color 0.2s var(--ease), opacity 0.2s;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.btn:hover, .submit:hover { transform: translateY(-2px); border-color: var(--hairline-strong); }
.btn:active, .submit:active { transform: translateY(0) scale(0.97); }

.btn.primary, .submit {
  background: var(--accent-grad);
  border: none;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 10px 30px -10px var(--accent-glow);
}
.btn.primary:hover, .submit:hover {
  box-shadow: 0 16px 40px -10px var(--accent-glow);
}
.submit { padding: 12px 30px; }
.btn.ghost { background: transparent; color: var(--dim); }
.btn.ghost:hover { color: var(--text); }
.btn.disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled { opacity: 0.6; cursor: default; transform: none; }

/* ---------- Status ---------- */
#status {
  min-height: 1.4em;
  margin: 6px 4px 18px;
  color: var(--dim);
  font-size: 14px;
  transition: color 0.3s;
}

/* ---------- Collection / batch bars ---------- */
.collection {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 18px 20px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--hairline);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  box-shadow: 0 20px 50px -30px rgba(0, 0, 0, 0.7);
  animation: rise 0.5s var(--ease) both;
}
.collection > div:first-child { flex: 1; min-width: 200px; }
.collection strong { display: block; font-weight: 600; letter-spacing: -0.01em; }
.selall {
  display: flex; align-items: center; gap: 7px;
  font-size: 14px; color: var(--dim); white-space: nowrap; cursor: pointer;
  user-select: none;
}

/* ---------- Custom checkboxes ---------- */
.selall input, .sel {
  appearance: none; -webkit-appearance: none;
  width: 20px; height: 20px;
  border: 1.5px solid var(--hairline-strong);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.3);
  cursor: pointer;
  position: relative;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.15s var(--spring);
}
.selall input:checked, .sel:checked {
  background: var(--accent-grad);
  border-color: transparent;
}
.selall input:checked::after, .sel:checked::after {
  content: "";
  position: absolute;
  left: 6px; top: 2.5px;
  width: 5px; height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.selall input:active, .sel:active { transform: scale(0.85); }

/* ---------- Result cards ---------- */
#results { display: grid; gap: 16px; }
.card {
  display: flex;
  gap: 18px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--hairline);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  box-shadow: 0 20px 50px -30px rgba(0, 0, 0, 0.7);
  animation: rise 0.6s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 60ms);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), border-color 0.3s var(--ease);
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--hairline-strong);
  box-shadow: 0 30px 60px -28px rgba(0, 0, 0, 0.85);
}
.pick { display: flex; align-items: flex-start; padding-top: 4px; }
.thumb { flex: 0 0 168px; }
.thumb img {
  width: 168px; height: 94px; object-fit: cover;
  border-radius: var(--radius-sm);
  display: block;
  border: 1px solid var(--hairline);
  transition: transform 0.4s var(--ease);
}
.card:hover .thumb img { transform: scale(1.03); }
.noimg {
  width: 168px; height: 94px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  color: var(--dim-2);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--hairline);
  font-size: 13px;
}
.meta { flex: 1; min-width: 0; }
.meta h3 { margin: 0 0 4px; font-size: 1.08rem; font-weight: 600; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.dim { color: var(--dim); font-size: 13px; margin: 0 0 14px; }

.actions { display: flex; flex-wrap: wrap; gap: 9px; }
.actions .btn { padding: 9px 16px; font-size: 13.5px; }

/* ---------- Progress ---------- */
.progress { margin-top: 14px; width: 100%; }
.progress.hidden { display: none; }
.progress .bar {
  height: 8px;
  width: 0;
  border-radius: 999px;
  background: var(--accent-grad);
  box-shadow: 0 0 16px -2px var(--accent-glow);
  transition: width 0.2s var(--ease);
}
.progress .bar.indeterminate {
  width: 40% !important;
  animation: slide 1.1s var(--ease) infinite;
}
.progress .pct { display: block; margin-top: 7px; font-size: 12px; color: var(--dim); }

/* Per-file progress rows for batch download */
.dl-list { width: 100%; display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.dl-list:empty { display: none; }
.dl-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px;
  animation: rise 0.35s var(--ease) both;
}
.dl-name { flex: 0 0 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); }
.dl-track { flex: 1; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.dl-bar { height: 100%; width: 0; border-radius: 999px; background: var(--accent-grad); transition: width 0.2s var(--ease); }
.dl-bar.indeterminate { width: 40% !important; animation: slide 1.1s var(--ease) infinite; }
.dl-pct { flex: 0 0 52px; text-align: right; color: var(--dim); font-variant-numeric: tabular-nums; }
.dl-row.ok .dl-pct { color: #7fe0a3; }
.dl-row.err .dl-name, .dl-row.err .dl-pct { color: #ff8a8a; }
.dl-row.err .dl-bar { background: #ff5a5a; }

@media (max-width: 560px) {
  .dl-name { flex-basis: 90px; }
}

/* ---------- Keyframes ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes slide {
  0% { margin-left: 0; }
  50% { margin-left: 60%; }
  100% { margin-left: 0; }
}

/* Reveal-on-load for hero & panels */
.reveal { opacity: 0; transform: translateY(22px); animation: rise 0.7s var(--ease) forwards; }
.reveal[style*="--d: 1"] { animation-delay: 0.08s; }
.reveal[style*="--d: 2"] { animation-delay: 0.16s; }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .card { flex-direction: column; }
  .thumb, .thumb img, .noimg { width: 100%; }
  .thumb img, .noimg { height: 180px; }
  .submit { padding: 15px 20px; }
}

/* ---------- Accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}
