/* ==========================================================================
   Trang Kết quả tải + các trạng thái (Figma: desktop 75:208, 77:272 · mobile 107:888)
   ========================================================================== */

/* ---- Lỗi nhập link (dùng cả ở trang chủ) ---- */
.download-bar__error { margin: 10px auto 0; max-width: 780px; color: #FDA4AF; font-size: .875rem; font-weight: 500; text-align: center; }
.download-bar.is-invalid { background: linear-gradient(rgb(10 7 24 / .72), rgb(10 7 24 / .72)) padding-box, linear-gradient(90deg, #FB7185, #F472B6) border-box; }

/* ---- Nút tải đang xử lý (vòng xoay thay cho icon) ---- */
.btn.is-loading { pointer-events: none; }
.btn.is-loading .icon { display: none; }
.btn.is-loading::before {
  content: ""; width: 18px; height: 18px; border-radius: 50%; flex: none;
  border: 2.5px solid rgb(255 255 255 / .35); border-top-color: #fff; animation: st-spin .7s linear infinite;
}

/* ---- Khu kết quả ngay dưới hero ---- */
.result-area { padding: clamp(32px, 4vw, 56px) 0 clamp(56px, 7vw, 100px); scroll-margin-top: 16px; }
.result-area[hidden] { display: none; }
.result-head { display: grid; justify-items: center; gap: 14px; text-align: center; margin-bottom: 28px; }
.badge--status { font-size: .75rem; padding: 6px 12px; }
.result-head__title { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.75rem); letter-spacing: -0.005em; }
.result-area[data-state="loading"] .result-head__new { display: none; }

/* ---- Vùng trạng thái ---- */
[data-state-panel] { display: none; }
.result-area[data-state="idle"] [data-state-panel="idle"],
.result-area[data-state="loading"] [data-state-panel="loading"],
.result-area[data-state="error"] [data-state-panel="error"],
.result-area[data-state="done"] [data-state-panel="done"] { display: grid; animation: st-rise .45s var(--ease-out) both; }

.state-card {
  justify-items: center; gap: 16px; text-align: center;
  width: min(100%, 560px); margin: 0 auto; padding: clamp(28px, 4vw, 44px);
  border-radius: 15px; background: var(--grad-card); border: 1px solid var(--glass-border-soft); box-shadow: var(--shadow-card);
}
.state-card :is(h2, h3) { font-size: 1.5rem; letter-spacing: -0.005em; }
.state-card > p { color: var(--text-secondary); line-height: 1.6; max-width: 42ch; }
.state-card__x { width: 110px; filter: drop-shadow(0 0 30px rgb(255 79 216 / .6)); }
.state-card__actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

.spinner { animation: st-spin 1s linear infinite; filter: drop-shadow(0 0 24px rgb(255 79 216 / .5)); }
@keyframes st-spin { to { transform: rotate(360deg); } }

.progress-steps { display: grid; gap: 10px; width: 100%; margin: 8px 0 0; padding: 0; list-style: none; counter-reset: s; text-align: left; }
.progress-steps li {
  counter-increment: s; display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px;
  background: rgb(255 255 255 / .03); color: var(--text-tertiary); font-weight: 500; font-size: .9375rem;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.progress-steps li::before {
  content: counter(s); display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; flex: none;
  background: rgb(255 255 255 / .08); font-size: .75rem; font-weight: 700;
}
.progress-steps li[data-s="active"] { color: var(--text-primary); font-weight: 600; background: rgb(255 255 255 / .08);
  box-shadow: inset 0 0 0 1px rgb(255 79 216 / .6); }
.progress-steps li[data-s="active"]::before { background: var(--grad-cta); color: #fff; box-shadow: 0 0 12px rgb(255 79 216 / .7); }
.progress-steps li[data-s="done"] { color: var(--text-primary); }
.progress-steps li[data-s="done"]::before { content: "✓"; background: linear-gradient(135deg, var(--cyan), var(--indigo)); color: #fff; }

.reasons { width: 100%; padding: 18px 20px; border-radius: 12px; text-align: left; background: rgb(255 79 216 / .06); border: 1px solid rgb(255 79 216 / .25); }
.reasons__title { font-weight: 700; color: #FF8AE6; font-size: .875rem; margin-bottom: 8px; }
.reasons ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; color: var(--text-secondary); font-size: .875rem; }
.reasons li::marker { color: #FF8AE6; }

/* ---- Thẻ kết quả ---- */
.result-card {
  display: grid; grid-template-columns: 320px 1fr; gap: 48px; padding: 32px; border-radius: 15px;
  background: var(--grad-card); border: 1px solid rgb(255 255 255 / .16);
  box-shadow: 0 30px 70px rgb(0 0 0 / .45), 0 0 80px rgb(168 85 247 / .18);
}
.result-card__preview {
  position: relative; align-self: start; aspect-ratio: 320 / 568; border-radius: 15px; overflow: hidden;
  border: 2px solid transparent; background: linear-gradient(var(--bg-raised), var(--bg-raised)) padding-box, linear-gradient(90deg, var(--pink), var(--cyan)) border-box;
  box-shadow: 0 20px 60px rgb(255 79 216 / .35);
}
.result-card__preview img { width: 100%; height: 100%; object-fit: cover; }
.result-card__preview::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgb(0 0 0 / .25), transparent 30%, transparent 70%, rgb(0 0 0 / .6)); pointer-events: none; }
.result-card__chips { position: absolute; left: 16px; top: 16px; display: flex; gap: 8px; z-index: 1; }
.mini-chip { padding: 4px 10px; border-radius: 8px; background: rgb(0 0 0 / .5); font-size: .75rem; font-weight: 700; }
.mini-chip--cyan { color: var(--cyan); }
.result-card__nologo { position: absolute; left: 16px; bottom: 16px; z-index: 1; display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 15px;
  background: var(--grad-cta); font-size: .75rem; font-weight: 700; box-shadow: 0 0 16px rgb(255 79 216 / .6); }

.result-card__info { display: grid; align-content: start; gap: 20px; min-width: 0; }
.avatar--lg { width: 52px; height: 52px; font-size: 1.0625rem; }
.result-card__info .author__name { font-size: 1.125rem; }
.result-card__caption { color: var(--text-body); line-height: 1.65; overflow-wrap: anywhere; }
.result-card__stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; padding: 0; list-style: none; }
.result-card__stats li { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 15px; background: rgb(255 255 255 / .06); border: 1px solid rgb(255 255 255 / .1); font-size: .8125rem; font-weight: 600; }
.result-card__stats .icon { color: #C9C3E6; }
.result-card hr { border: 0; height: 1px; background: rgb(255 255 255 / .1); margin: 0; }
.result-card__label { font-size: 1rem; letter-spacing: 0; }
.result-card__note { display: flex; align-items: center; gap: 8px; color: var(--text-tertiary); font-size: .8125rem; }
.result-card__note .icon { color: var(--cyan-soft); }

.formats { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.format { display: flex; align-items: center; gap: 16px; padding: 14px 16px; border-radius: 12px; background: rgb(255 255 255 / .04); border: 1px solid rgb(255 255 255 / .08); }
.format.is-recommended { border: 1.5px solid transparent; box-shadow: 0 10px 30px rgb(255 79 216 / .25);
  background: linear-gradient(90deg, rgb(255 79 216 / .16), rgb(168 85 247 / .08)) padding-box, linear-gradient(#150c2b, #150c2b) padding-box, var(--grad-cta) border-box; }
.format__ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; flex: none; background: rgb(255 255 255 / .08); }
.format.is-recommended .format__ic { background: linear-gradient(135deg, var(--pink), var(--violet)); box-shadow: inset 0 1px 1px rgb(255 255 255 / .35); }
.format__txt { flex: 1; min-width: 0; display: grid; gap: 3px; }
.format__label { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.format__label b { font-size: 1rem; }
.format__rec { font-size: .625rem; padding: 3px 8px; }
.format__txt small { color: var(--text-secondary); font-size: .8125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.format__size { color: var(--text-tertiary); font-weight: 600; font-size: .875rem; white-space: nowrap; }
.format.is-recommended .format__size { color: var(--text-primary); }
.format__btn { flex: none; }

.slides__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin: 12px 0 0; padding: 0; list-style: none; }
.slides__grid a { position: relative; display: block; border-radius: 14px; overflow: hidden; aspect-ratio: 3 / 4; border: 1px solid rgb(255 255 255 / .12); }
.slides__grid img { width: 100%; height: 100%; object-fit: cover; }
.slides__grid span { position: absolute; right: 8px; bottom: 8px; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--grad-cta); }

/* ---- Mobile: bố cục gọn – ảnh nhỏ + thông tin trên cùng một hàng, nút tải hiện ngay bên dưới ---- */
@media (max-width: 860px) {
  .result-area { padding-top: 24px; }

  /* Đầu khu kết quả: tiêu đề + "Tải video khác" trên một hàng */
  .result-head { grid-template-columns: 1fr auto; justify-items: start; align-items: center; text-align: left; gap: 10px; margin-bottom: 16px; }
  .result-head .badge--status { display: none; }
  .result-head__title { font-size: 1.25rem; letter-spacing: -0.005em; }
  .result-head__new { --_pad-x: 12px; --_pad-y: 9px; font-size: .8125rem; }

  /* Thẻ kết quả: lưới 2 cột, phần thông tin "trải" ra để định dạng tải chiếm trọn chiều ngang */
  .result-card {
    grid-template-columns: 96px 1fr; column-gap: 14px; row-gap: 6px; align-items: start;
    padding: 14px; border-radius: 14px;
  }
  .result-card__info { display: contents; }
  .result-card__preview { grid-column: 1; grid-row: 1 / span 3; aspect-ratio: 3 / 4; border-radius: 12px; border-width: 1.5px; box-shadow: 0 8px 24px rgb(255 79 216 / .3); }
  .result-card__chips { left: 6px; top: 6px; gap: 4px; }
  .result-card__chips .mini-chip { padding: 2px 6px; font-size: .625rem; border-radius: 6px; }
  .result-card__chips .mini-chip--cyan { display: none; }
  .result-card__nologo { left: 5px; right: 5px; bottom: 5px; justify-content: center; gap: 3px; padding: 3px 4px; font-size: .5625rem; white-space: nowrap; }
  .result-card__nologo .icon { width: 9px; height: 9px; flex: none; }

  .result-card .author { grid-column: 2; gap: 8px; }
  .result-card .avatar--lg { width: 32px; height: 32px; font-size: .75rem; border-width: 1.5px; }
  .result-card__info .author__name { font-size: .9375rem; }
  .result-card .author__role { font-size: .75rem; }
  .result-card .author br { display: none; }
  .result-card .author > span:last-child { display: grid; line-height: 1.3; min-width: 0; }
  .result-card__info .author__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .result-card__caption { grid-column: 2; font-size: .8125rem; line-height: 1.5;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .result-card__stats { grid-column: 2; gap: 6px; }
  .result-card__stats li { padding: 3px 9px; font-size: .75rem; }

  .result-card hr { grid-column: 1 / -1; margin: 10px 0 4px; }
  .result-card__label { grid-column: 1 / -1; font-size: .875rem; margin-bottom: 4px; }
  .formats, .slides, .result-card__note { grid-column: 1 / -1; }
  .result-card__note { font-size: .75rem; margin-top: 6px; }

  /* Dòng định dạng gọn */
  .formats { gap: 8px; }
  .format { gap: 10px; padding: 10px; border-radius: 12px; }
  .format__ic { width: 36px; height: 36px; border-radius: 11px; }
  .format__ic .icon { width: 18px; height: 18px; }
  .format__label b { font-size: .875rem; white-space: nowrap; }
  .format__rec { display: none; }
  .format__txt small { font-size: .6875rem; }
  .format__size { font-size: .75rem; }
  .format__btn { --_pad-x: 0; width: 40px; height: 40px; padding: 0; border-radius: 12px; }
  .format__btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  /* Định dạng khuyên dùng: nút to, có chữ – bấm một chạm là tải */
  .format.is-recommended .format__btn { width: auto; height: 42px; padding: 0 16px; border-radius: 14px; }
  .format.is-recommended .format__btn span { position: static; width: auto; height: auto; clip: auto; overflow: visible; }

  .slides__grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
}
/* Dòng khuyên dùng: chuyển dung lượng xuống dòng mô tả để nhường chỗ cho nút to */
@media (max-width: 860px) {
  .format.is-recommended .format__size { display: none; }
  .format.is-recommended small[data-size]::before { content: attr(data-size) " · "; color: var(--text-primary); font-weight: 600; }
}
