/* ══ Motion, interactive demos and polish ══════════════════════════
   Everything here is progressive: without JavaScript, or with
   "reduce motion" switched on, every element is simply visible. */

/* page-to-page cross-fade (Chrome/Edge; others just navigate) */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .28s; }

/* ── reading progress ── */
.progress { position: fixed; top: 0; left: 0; height: 3px; width: 100%; z-index: 60; transform-origin: 0 50%; transform: scaleX(0);
            background: linear-gradient(90deg, var(--gold), var(--coral)); }

/* ── chapter tint behind the story ── */
.tint { position: fixed; inset: 0; z-index: -2; pointer-events: none; transition: background 1s ease;
        background: radial-gradient(900px 600px at 15% 55%, var(--tint, transparent), transparent 70%); opacity: .55; }

/* ── scene navigator ── */
.scenes { position: fixed; right: 18px; top: 50%; transform: translateY(-50%); z-index: 40; display: none; flex-direction: column; gap: 10px; }
@media (min-width: 1180px) { .scenes { display: flex; } }
.scenes a { position: relative; width: 12px; height: 12px; border-radius: 50%; background: var(--line); border: 2px solid var(--bg); transition: transform .2s, background .2s; }
.scenes a:hover, .scenes a.on { background: var(--gold); transform: scale(1.3); text-decoration: none; }
.scenes a span { position: absolute; right: 22px; top: 50%; transform: translateY(-50%); white-space: nowrap; background: var(--card2); color: var(--text);
                 font-size: 13px; font-weight: 700; padding: 5px 10px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .15s; }
.scenes a:hover span, .scenes a:focus-visible span { opacity: 1; }

/* ── beats: elements of a scene arriving one by one ── */
html.motion .beat { opacity: 0; transform: translateY(18px); }
html.motion .beat.in { opacity: 1; transform: none; transition: opacity .5s ease, transform .5s cubic-bezier(.2,.8,.2,1); }
html.motion .talk.beat { transform: translateY(14px) scale(.92); transform-origin: 0 0; }
html.motion .talk.me.beat { transform-origin: 100% 0; }
html.motion .talk.beat.in { transform: none; transition: opacity .35s ease, transform .45s cubic-bezier(.3,1.6,.5,1); }
html.motion .principle.beat { transform: translateY(22px) scale(.97); }
html.motion .principle.beat.in .ic { animation: wiggle .9s ease .2s; }
html.motion .twist { display: inline-block; }
html.motion .beat.in .twist { animation: shake .6s ease .15s; }
@keyframes wiggle { 0%,100% { transform: rotate(0) } 25% { transform: rotate(-14deg) scale(1.15) } 60% { transform: rotate(10deg) } }
@keyframes shake { 0%,100% { transform: translateX(0) } 20% { transform: translateX(-5px) } 40% { transform: translateX(5px) } 60% { transform: translateX(-3px) } 80% { transform: translateX(3px) } }

/* typing indicator inside a bubble, before its words appear */
.talk .dots { display: none; gap: 5px; padding: 6px 2px; }
.talk .dots i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .45; animation: blink 1s infinite; }
.talk .dots i:nth-child(2) { animation-delay: .15s; } .talk .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%,100% { opacity: .25; transform: translateY(0) } 40% { opacity: .9; transform: translateY(-3px) } }
.talk.typing .dots { display: flex; }
.talk.typing .b > :not(.who):not(.dots) { display: none; }
.talk .say-body { display: block; }
.talk.typing .b { min-width: 74px; }

/* device swap on the sticky stage */
.holder.swap { animation: swapIn .45s cubic-bezier(.2,.8,.2,1); }
@keyframes swapIn { from { opacity: 0; transform: translateY(26px) scale(.96) rotate(-1.2deg); } to { opacity: 1; transform: none; } }
.holder.fade { opacity: 1; }

/* ── try-it demos ── */
.demo { margin: 18px 0 4px; background: linear-gradient(160deg, #2a221b, #1f1a15); border: 1px solid #4a3d30; border-radius: 18px; padding: 18px; position: relative; }
.demo::before { content: "▶ Try it"; position: absolute; top: -12px; left: 16px; background: var(--gold); color: var(--gold-ink); font-size: 12px; font-weight: 800;
                letter-spacing: .06em; padding: 3px 10px; border-radius: 99px; }
.demo h4 { margin: 4px 0 10px; font-size: 17px; }
.demo .hint { color: var(--mut); font-size: 14px; margin: 0 0 12px; }
.demo button { font: inherit; cursor: pointer; }

/* bill splitter */
.bill { display: grid; gap: 7px; }
.bill .it { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.bill .it .nm { font-weight: 600; font-size: 15px; }
.bill .it .pr { color: var(--mut); font-size: 14px; }
.who-chip { border: 0; border-radius: 99px; padding: 5px 12px; font-weight: 800; font-size: 13px; color: #1d1712; min-width: 70px; transition: transform .15s; }
.who-chip:active { transform: scale(.94); }
.who-0 { background: #7cb8ff; } .who-1 { background: #ff8fa3; } .who-2 { background: #ffc23d; }
.shares { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.share { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.share b { display: block; font-size: 22px; }
.share small { color: var(--mut); font-size: 12.5px; display: block; }
.share .eq { color: var(--coral); font-weight: 700; }
.share .eq.ok { color: var(--mint); }
.sumcheck { margin-top: 10px; font-size: 14px; color: var(--mint); font-weight: 700; }

/* answer checker */
.checker .q { font-weight: 700; margin-bottom: 10px; }
.checker input { width: 100%; font: inherit; font-size: 18px; padding: 11px 14px; border-radius: 12px; border: 2px solid var(--line); background: #120f0c; color: var(--text); }
.checker input:focus { outline: none; border-color: var(--gold); }
.checker .try { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.checker .try button { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 99px; padding: 5px 12px; font-size: 14px; font-weight: 700; }
.verdicts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.verdicts div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.verdicts small { display: block; color: var(--mut); font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.verdicts b { font-size: 18px; }
.verdicts .v-yes { color: var(--mint); } .verdicts .v-no { color: #ff6b5b; } .verdicts .v-wait { color: var(--dim); }

/* KBS mini game */
.kbs-game .ladder-mini { display: flex; gap: 6px; margin-bottom: 12px; }
.kbs-game .ladder-mini span { flex: 1; text-align: center; padding: 6px 4px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); font-size: 13px; font-weight: 700; color: var(--mut); }
.kbs-game .ladder-mini span.done { background: rgba(79,209,165,.15); border-color: var(--mint); color: var(--mint); }
.kbs-game .ladder-mini span.now { border-color: var(--gold); color: var(--gold); }
.kbs-game .qq { font-weight: 700; font-size: 18px; margin: 4px 0 12px; }
.kbs-game .opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kbs-game .opts button { text-align: left; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 12px; padding: 10px 12px; font-size: 15.5px; transition: background .2s, opacity .2s; }
.kbs-game .opts button b { color: var(--gold); margin-right: 6px; }
.kbs-game .opts button:hover:not(:disabled) { background: var(--card2); }
.kbs-game .opts button.gone { opacity: .15; }
.kbs-game .opts button.right { background: rgba(79,209,165,.2); border-color: var(--mint); }
.kbs-game .opts button.wrong { background: rgba(255,107,91,.18); border-color: #ff6b5b; }
.kbs-game .row2 { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.kbs-game .ll { border: 1px solid var(--gold); background: transparent; color: var(--gold); border-radius: 99px; padding: 6px 14px; font-weight: 800; }
.kbs-game .ll:disabled { opacity: .35; }
.kbs-game .msg { font-weight: 700; color: var(--mut); min-height: 1.4em; }
@media (max-width: 560px) { .kbs-game .opts, .verdicts { grid-template-columns: 1fr; } .shares { grid-template-columns: 1fr; } }

/* ── home page wow ── */
.say .typed::after { content: "▍"; margin-left: 1px; animation: caret 1s steps(1) infinite; color: #b3a796; }
@keyframes caret { 50% { opacity: 0; } }
.card { transform-style: preserve-3d; will-change: transform; }
.card .art img { transition: transform .35s ease; }
.card:hover .art img { transform: rotate(1deg) translateY(-6px) scale(1.03); }
.hero-art .me { animation: float 6s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-8px) } }

@media (prefers-reduced-motion: reduce) {
  html.motion .beat { opacity: 1 !important; transform: none !important; }
  .hero-art .me { animation: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}
