/* NGOCSTUDIO · Trước và sau khi phối — "bàn nghe phòng thu"
   Mọi quy tắc gói trong .ab-studio nên không ảnh hưởng trình phát khác.
   Trạng thái bản A/B và đang phát đọc trực tiếp từ aria-pressed và biểu tượng nút phát. */

#comparison .split { grid-template-columns: minmax(0, .76fr) minmax(0, 1.24fr); }

.comparison.ab-studio {
  --tone: #ffd9a8;
  --tone-glow: rgb(255 176 104 / 30%);
  position: relative;
  padding: 0;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 28px;
  background:
    linear-gradient(180deg, #170d31, #0e0721) padding-box,
    linear-gradient(165deg, rgb(255 214 170 / 46%), rgb(255 255 255 / 8%) 32%, rgb(255 255 255 / 5%) 66%, rgb(125 92 255 / 48%)) border-box;
  box-shadow: 0 50px 100px -44px rgb(0 0 0 / 90%), 0 30px 90px -50px var(--tone-glow);
  transition: box-shadow .6s var(--ease);
}
.comparison.ab-studio:has([data-ab="1"][aria-pressed="true"]) { --tone: #ff9a86; --tone-glow: rgb(214 82 190 / 62%); }

/* ---------- Sân khấu ảnh ---------- */
.ab-stage { position: relative; isolation: isolate; aspect-ratio: 16 / 7.2; min-height: 210px; overflow: hidden; background: #0b0510; }
.ab-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity .75s var(--ease), transform 1.5s var(--ease-out), filter .75s var(--ease); }
.ab-art-a { object-position: 78% 38%; filter: grayscale(.5) sepia(.22) brightness(1.02) contrast(1.04); }
.ab-art-b { object-position: 50% 52%; filter: saturate(1.2) brightness(1.08); opacity: 0; transform: scale(1.1); }
.ab-studio:has([data-ab="1"][aria-pressed="true"]) .ab-art-a { opacity: 0; transform: scale(1.1); }
.ab-studio:has([data-ab="1"][aria-pressed="true"]) .ab-art-b { opacity: 1; transform: scale(1); }
.ab-stage::after {
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(180deg, rgb(10 4 24 / 28%) 0%, transparent 32%, rgb(18 10 40 / 74%) 76%, #170d31 100%), linear-gradient(90deg, rgb(12 5 28 / 66%), transparent 62%);
}
/* quầng màu thương hiệu chỉ bật ở bản đã phối */
.ab-stage::before {
  content: ""; position: absolute; inset: 0; z-index: 1; opacity: 0; mix-blend-mode: screen; transition: opacity .75s var(--ease);
  background: radial-gradient(60% 80% at 8% 100%, rgb(255 129 89 / 36%), transparent 70%), radial-gradient(60% 90% at 96% 6%, rgb(125 92 255 / 46%), transparent 70%);
}
.ab-studio:has([data-ab="1"][aria-pressed="true"]) .ab-stage::before { opacity: 1; }
.ab-grain {
  position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: .3; mix-blend-mode: overlay; transition: opacity .75s var(--ease);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
.ab-studio:has([data-ab="1"][aria-pressed="true"]) .ab-grain { opacity: .08; }

.ab-live {
  position: absolute; z-index: 3; top: 18px; left: 20px; display: inline-flex; align-items: center; gap: 10px; padding: 8px 15px 8px 13px;
  border: 1px solid rgb(255 255 255 / 16%); border-radius: 999px; background: rgb(12 6 28 / 48%);
  -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
  color: #fff; font: 500 .66rem/1 var(--font); letter-spacing: .16em; text-transform: uppercase;
}
.ab-live-on { display: none; }
.ab-studio:has(#ab-play .icon-pause) .ab-live-on { display: inline; }
.ab-studio:has(#ab-play .icon-pause) .ab-live-idle { display: none; }
.ab-eq { display: inline-flex; align-items: flex-end; gap: 2px; width: 14px; height: 12px; }
.ab-eq i { flex: 1; height: 100%; border-radius: 1px; background: var(--tone); transform-origin: bottom; transform: scaleY(.35); }
.ab-eq i:nth-child(2) { transform: scaleY(.75); }
.ab-eq i:nth-child(3) { transform: scaleY(.5); }
.ab-studio:has(#ab-play .icon-pause) .ab-eq i { animation: ab-eq .9s ease-in-out infinite alternate; }
.ab-studio .ab-eq i:nth-child(2) { animation-delay: -.6s; animation-duration: .7s; }
.ab-studio .ab-eq i:nth-child(3) { animation-delay: -.25s; animation-duration: 1.1s; }
.ab-studio .ab-eq i:nth-child(4) { animation-delay: -.45s; animation-duration: .8s; }
@keyframes ab-eq { from { transform: scaleY(.2); } to { transform: scaleY(1); } }

.ab-letter { position: absolute; z-index: 3; top: 0; right: 24px; display: grid; }
.ab-letter span {
  grid-area: 1 / 1; font: italic 400 clamp(5rem, 9vw, 8.5rem)/1.15 var(--serif); color: transparent;
  -webkit-text-stroke: 1px rgb(255 236 220 / 62%); transition: opacity .5s var(--ease), translate .7s var(--ease-out);
}
.ab-letter span:last-child { opacity: 0; translate: 0 18px; }
.ab-studio:has([data-ab="1"][aria-pressed="true"]) .ab-letter span:first-child { opacity: 0; translate: 0 -18px; }
.ab-studio:has([data-ab="1"][aria-pressed="true"]) .ab-letter span:last-child { opacity: 1; translate: 0 0; }

.ab-caption { position: absolute; z-index: 3; left: 28px; right: 28px; bottom: 8px; display: grid; }
.ab-caption > span { grid-area: 1 / 1; display: grid; gap: 4px; transition: opacity .45s var(--ease), translate .65s var(--ease-out); }
.ab-caption > span:last-child { opacity: 0; translate: 0 14px; }
.ab-studio:has([data-ab="1"][aria-pressed="true"]) .ab-caption > span:first-child { opacity: 0; translate: 0 -14px; }
.ab-studio:has([data-ab="1"][aria-pressed="true"]) .ab-caption > span:last-child { opacity: 1; translate: 0 0; }
.ab-caption small { display: flex; align-items: center; gap: 10px; color: var(--tone); font: 600 .66rem/1.4 var(--font); letter-spacing: .24em; text-transform: uppercase; }
.ab-caption small::before { content: ""; width: 22px; height: 1px; background: currentColor; }
.ab-caption strong { color: #fff; font: 300 clamp(1.5rem, 2.6vw, 2.35rem)/1.3 var(--font); letter-spacing: -.025em; text-shadow: 0 4px 24px rgb(0 0 0 / 55%); }
.ab-caption em { font-family: var(--serif); font-style: italic; color: var(--tone); }

/* ---------- Bàn điều khiển ---------- */
.ab-deck { padding: 18px clamp(16px, 2.6vw, 28px) clamp(20px, 2.6vw, 28px); }
.ab-switch {
  position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 6px;
  border: 1px solid rgb(255 255 255 / 8%); border-radius: 18px; background: rgb(4 1 14 / 55%); box-shadow: inset 0 2px 10px rgb(0 0 0 / 45%);
}
.ab-switch::before {
  content: ""; position: absolute; top: 6px; bottom: 6px; left: 6px; width: calc(50% - 9px);
  border-radius: 13px; border: 1px solid transparent;
  background: linear-gradient(180deg, #2c1e4d, #20143b) padding-box, linear-gradient(150deg, var(--tone), rgb(255 255 255 / 8%) 48%, rgb(125 92 255 / 70%)) border-box;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 9%), 0 12px 26px -12px var(--tone-glow), 0 8px 18px -8px rgb(0 0 0 / 70%);
  transition: transform .55s var(--ease-out);
}
.ab-studio:has([data-ab="1"][aria-pressed="true"]) .ab-switch::before { transform: translateX(calc(100% + 6px)); }
.ab-switch button {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 13px; min-width: 0; min-height: 68px; padding: 10px 14px;
  border: 0; border-radius: 13px; background: transparent; color: var(--soft); text-align: left; cursor: pointer; transition: color .3s var(--ease);
}
.ab-switch button:hover { color: var(--ink); }
.ab-switch button[aria-pressed="true"] { color: #fff; }
.ab-icon {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid rgb(255 255 255 / 11%); background: linear-gradient(180deg, rgb(255 255 255 / 7%), rgb(255 255 255 / 1.5%));
  transition: background-color .35s var(--ease), border-color .35s var(--ease), color .35s var(--ease);
}
.ab-icon svg { width: 23px; height: 23px; shape-rendering: geometricPrecision; }
.ab-switch button[aria-pressed="true"] .ab-icon { border-color: rgb(255 255 255 / 30%); background: var(--grad); box-shadow: inset 0 1px 0 rgb(255 255 255 / 34%), 0 8px 18px -8px rgb(226 72 156 / 80%); color: #fff; }
.ab-text { display: grid; gap: 3px; min-width: 0; }
.ab-text small { font: 600 .62rem/1.4 var(--font); letter-spacing: .22em; text-transform: uppercase; color: var(--faint); }
.ab-switch button[aria-pressed="true"] .ab-text small { color: var(--tone); }
.ab-text strong { font: 500 .93rem/1.35 var(--font); }

/* ---------- Sóng nhạc + điều khiển ---------- */
.ab-studio .transport {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-areas: "wave wave wave" "cur play dur";
  align-items: center; gap: 12px 16px; margin-top: 18px;
}
.ab-wave, .ab-studio #ab-seek { grid-area: wave; }
.ab-wave { position: relative; height: 96px; }
.ab-wave::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgb(255 255 255 / 9%); }
.ab-bars { position: absolute; inset: 0; display: flex; align-items: center; gap: 2px; }
.ab-bars i { flex: 1; min-width: 0; height: 100%; border-radius: 999px; transform: scaleY(var(--h, .05)); transition: transform .6s var(--ease-out) calc(var(--i) * 3ms); }
.ab-bars-base i { background: rgb(236 230 255 / 22%); }
/* lớp sáng: cùng hình sóng, cắt theo vị trí đang phát */
.ab-bars-lit { clip-path: inset(0 calc(100% - var(--played, 0%)) 0 0); -webkit-mask-image: linear-gradient(#000, #000); }
.ab-bars-lit i { background: linear-gradient(180deg, #fff1dd, #ffc58a 50%, #fff1dd); }
.ab-studio:has([data-ab="1"][aria-pressed="true"]) .ab-bars-base i { background: linear-gradient(180deg, rgb(255 154 134 / 42%), rgb(168 128 255 / 42%)); }
.ab-studio:has([data-ab="1"][aria-pressed="true"]) .ab-bars-lit i { background: linear-gradient(180deg, #ffb08a, #f0559f 50%, #9474ff); }
.ab-head { position: absolute; top: 4px; bottom: 4px; left: var(--played, 0%); width: 1.5px; margin-left: -.75px; background: #fff; box-shadow: 0 0 12px 2px var(--tone-glow), 0 0 4px #fff; }
.ab-head::before, .ab-head::after { content: ""; position: absolute; left: 50%; width: 7px; height: 7px; margin-left: -3.5px; border-radius: 50%; background: #fff; }
.ab-head::before { top: -4px; }
.ab-head::after { bottom: -4px; }
/* thanh tua trong suốt phủ lên sóng: bấm, kéo và dùng phím mũi tên đều được */
.ab-studio .transport #ab-seek { position: relative; z-index: 2; width: 100%; height: 96px; margin: 0; opacity: 0; cursor: pointer; -webkit-appearance: none; appearance: none; }
.ab-studio #ab-seek::-webkit-slider-thumb { -webkit-appearance: none; width: 2px; height: 96px; }
.ab-studio #ab-seek::-moz-range-thumb { width: 2px; height: 96px; border: 0; }
.ab-studio .transport:has(#ab-seek:focus-visible) .ab-wave { outline: 1.5px solid var(--accent); outline-offset: 6px; border-radius: 8px; }

.ab-studio .transport #ab-current, .ab-studio .transport #ab-duration { min-width: 0; font: 300 1.2rem/1 var(--font); letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.ab-studio .transport #ab-current { grid-area: cur; justify-self: start; color: var(--ink); }
.ab-studio .transport #ab-duration { grid-area: dur; justify-self: end; color: var(--soft); }

.ab-studio .transport #ab-play {
  grid-area: play; position: relative; display: grid; place-items: center; width: 72px; height: 72px; margin: 4px 0 0; padding: 0;
  border: 0; border-radius: 50%; color: #1a0d36; background: linear-gradient(180deg, #fff, #ece4fb);
  box-shadow: 0 0 0 5px #140b2b, 0 0 0 6px rgb(255 255 255 / 16%), 0 16px 34px -10px var(--tone-glow), inset 0 -3px 8px rgb(72 40 130 / 18%);
  transition: transform .25s var(--ease-out), box-shadow .4s var(--ease);
}
.ab-studio .transport #ab-play:hover { transform: scale(1.05); background: linear-gradient(180deg, #fff, #f6f1ff); box-shadow: 0 0 0 5px #140b2b, 0 0 0 6px var(--tone), 0 18px 40px -8px var(--tone-glow), inset 0 -3px 8px rgb(72 40 130 / 18%); }
.ab-studio .transport #ab-play:active { transform: scale(.96); }
.ab-studio #ab-play::after { content: ""; position: absolute; inset: -7px; border: 1px solid var(--tone); border-radius: 50%; opacity: 0; pointer-events: none; }
.ab-studio:has(#ab-play .icon-pause) #ab-play::after { animation: ab-pulse 1.9s ease-out infinite; }
@keyframes ab-pulse { from { opacity: .7; transform: scale(1); } to { opacity: 0; transform: scale(1.34); } }
/* biểu tượng vẽ bằng vector: sắc nét ở mọi mật độ điểm ảnh, căn giữa theo thị giác */
.ab-studio #ab-play .icon-play, .ab-studio #ab-play .icon-pause { width: 28px; height: 28px; margin: 0; border: 0; background: currentColor; -webkit-mask: var(--glyph) center / contain no-repeat; mask: var(--glyph) center / contain no-repeat; }
.ab-studio #ab-play .icon-play { --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 5.7c0-1.1 1.2-1.75 2.12-1.16l9.4 6.1a1.62 1.62 0 0 1 0 2.72l-9.4 6.1C9.2 20.05 8 19.4 8 18.3z'/%3E%3C/svg%3E"); }
.ab-studio #ab-play .icon-pause { --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='6' y='4.5' width='4.2' height='15' rx='1.5'/%3E%3Crect x='13.8' y='4.5' width='4.2' height='15' rx='1.5'/%3E%3C/svg%3E"); }

.ab-studio .demo-note:empty, .ab-studio .status:empty { display: none; }

@media (max-width: 960px) { #comparison .split { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 520px) {
  .comparison.ab-studio { border-radius: 22px; }
  .ab-stage { aspect-ratio: 4 / 3; min-height: 0; }
  .ab-caption { left: 20px; right: 20px; }
  .ab-live { top: 14px; left: 14px; }
  .ab-letter { right: 16px; }
  .ab-deck { padding-inline: 14px; }
  .ab-switch button { flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px; }
  .ab-icon { width: 40px; height: 40px; }
  .ab-text strong { font-size: .86rem; }
  .ab-bars { gap: 1px; }
}
@media (forced-colors: active) {
  .ab-studio .transport #ab-seek { opacity: 1; height: 44px; -webkit-appearance: auto; appearance: auto; }
  .ab-wave { display: none; }
  .ab-letter span { -webkit-text-stroke-color: CanvasText; }
}
