/* The about page's motion (about.html, _gk_hero_demo.html, _gk_sections.html), on top of genko.css.

   - .mk-reveal: fades and rises in when it scrolls into view (marketing.js adds .is-in). Hidden only once the page
     has said it can show it again (.mk-ready on <html>), with a fallback in case the script never runs.
   - .mk-stagger: its children come in one after another (--i on each).
   - The pictures play while they're on screen (.is-visible, also from marketing.js) and pause when they aren't.
   - Everything stands still, fully shown, for people who asked their system for less motion. */

/* ---------- scroll-in ---------- */
.mk-ready .mk-reveal { opacity: 0; transform: translateY(22px); }
.mk-ready .mk-reveal.is-in {
    opacity: 1; transform: none;
    transition: opacity .7s ease var(--d, 0s), transform .8s cubic-bezier(.2, .7, .2, 1) var(--d, 0s);
}
.mk-ready:not(.mk-js) .mk-reveal { animation: mk-failsafe 0s 2.5s forwards; }
@keyframes mk-failsafe { to { opacity: 1; transform: none; } }

.mk-ready .mk-stagger > * { opacity: 0; transform: translateY(8px); }
.mk-ready .mk-stagger.is-in > *, .mk-ready .is-in .mk-stagger > * {
    opacity: 1; transform: none;
    transition: opacity .5s ease calc(.25s + var(--i, 0) * .08s), transform .5s ease calc(.25s + var(--i, 0) * .08s);
}

/* A picture that isn't on screen doesn't need to keep moving. */
.mk-hero:not(.is-visible) *, .mk-reveal:not(.is-visible) * { animation-play-state: paused !important; }

/* ---------- hero: a box is drawn, the popup opens, a subtitle types in (one 10 s loop) ---------- */
.mk-hero .mk-box { animation: mk-hero-box 10s ease-in-out infinite; }
.mk-hero .mk-box-tag { animation: mk-hero-tag 10s ease infinite; }
.mk-hero .mk-pop { animation: mk-hero-pop 10s cubic-bezier(.2, .7, .2, 1) infinite; }
.mk-hero .mk-sub { animation: mk-hero-sub 10s cubic-bezier(.2, .7, .2, 1) infinite; }
.mk-hero .mk-type { animation: mk-hero-type 10s steps(11, end) infinite; }
.mk-hero .mk-sub-en { animation: mk-hero-en 10s ease infinite; }
@keyframes mk-hero-box {
    0% { clip-path: inset(0 100% 100% 0); opacity: 1; }
    11% { clip-path: inset(0 0 0 0); }
    88% { opacity: 1; }
    96%, 100% { clip-path: inset(0 0 0 0); opacity: 0; }
}
@keyframes mk-hero-tag { 0%, 9% { opacity: 0; } 12%, 88% { opacity: 1; } 96%, 100% { opacity: 0; } }
@keyframes mk-hero-pop {
    0%, 12% { opacity: 0; transform: translateY(18px) scale(.97); }
    19%, 86% { opacity: 1; transform: none; }
    94%, 100% { opacity: 0; transform: translateY(8px); }
}
@keyframes mk-hero-sub {
    0%, 24% { opacity: 0; transform: translateY(-10px); }
    29%, 89% { opacity: 1; transform: none; }
    96%, 100% { opacity: 0; transform: translateY(-6px); }
}
@keyframes mk-hero-type { 0%, 29% { clip-path: inset(0 100% 0 0); } 44%, 100% { clip-path: inset(0 0 0 0); } }
@keyframes mk-hero-en { 0%, 45% { opacity: 0; } 51%, 100% { opacity: 1; } }

/* ---------- the gap: readings and glosses arrive once the card is in ---------- */
.mk-ready .mk-wild rt { opacity: 0; }
.mk-ready .mk-wild.is-in rt { opacity: 1; transition: opacity .5s ease .5s; }
.mk-ready .mk-wild.is-in ruby:nth-of-type(2) rt { transition-delay: .7s; }
.mk-ready .mk-wild.is-in ruby:nth-of-type(3) rt { transition-delay: .9s; }

/* ---------- OCR Capture card: the same box-and-popup, shorter loop ---------- */
.mk-ocr.is-visible .mk-box, .is-visible .mk-ocr .mk-box { animation: mk-ocr-box 6s ease-in-out infinite; }
.is-visible .mk-ocr .mk-pop { animation: mk-ocr-pop 6s cubic-bezier(.2, .7, .2, 1) infinite; }
@keyframes mk-ocr-box { 0% { clip-path: inset(0 100% 100% 0); opacity: 1; } 16%, 86% { clip-path: inset(0 0 0 0); opacity: 1; } 96%, 100% { opacity: 0; } }
@keyframes mk-ocr-pop { 0%, 18% { opacity: 0; transform: translateY(12px); } 26%, 86% { opacity: 1; transform: none; } 96%, 100% { opacity: 0; } }

/* ---------- Live Audio card: a video with the subtitle overlay at the bottom ---------- */
.mk-video {
    position: relative; height: 128px; border-radius: 14px; overflow: hidden;
    background: radial-gradient(120% 90% at 30% 20%, #3b3d63 0%, #23243a 45%, #14151f 100%);
    border: 1px solid var(--border);
}
.mk-video::before { /* a streamer's webcam corner, to read as "a stream" */
    content: ""; position: absolute; right: 10px; top: 10px; width: 46px; height: 34px; border-radius: 6px;
    background: linear-gradient(160deg, #6b5d8c, #2c2a40); opacity: .8;
}
.mk-video-bar { position: absolute; left: 10px; right: 10px; bottom: 8px; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .15); }
.mk-video-bar i { display: block; height: 100%; width: 40%; border-radius: 2px; background: var(--accent-2); animation: mk-progress 9s linear infinite; }
.mk-overlay { position: absolute; left: 0; right: 0; bottom: 18px; height: 52px; }
.mk-line {
    position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: max-content; max-width: 92%;
    padding: 6px 12px; border-radius: 8px; background: rgba(20, 20, 26, .86); text-align: center;
    display: flex; flex-direction: column; gap: 1px; opacity: 0;
    animation: mk-line 9s ease infinite;
}
.mk-line b { font-size: 14px; color: #fff; }
.mk-line span { font-size: 11px; color: #dcdce6; }
.mk-line:nth-child(2) { animation-delay: 3s; }
.mk-line:nth-child(3) { animation-delay: 6s; }
@keyframes mk-line { 0% { opacity: 0; transform: translate(-50%, 4px); } 4%, 30% { opacity: 1; transform: translate(-50%, 0); } 34%, 100% { opacity: 0; } }
@keyframes mk-progress { from { width: 18%; } to { width: 74%; } }

/* ---------- Batch Translate card: pages turn from Japanese to English ---------- */
.mk-batch { display: flex; flex-direction: column; gap: 8px; }
.mk-thumbs { display: flex; gap: 8px; }
.mk-thumb {
    position: relative; flex: 1 1 0; height: 54px; border-radius: 6px; background: var(--gk-paper, #f2efe7);
    border: 2px solid var(--gk-ink); overflow: hidden;
}
.mk-thumb b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--gk-ink); font-size: 12px; font-weight: 800; text-align: center; padding: 2px; }
.mk-thumb b:last-child { font-size: 9px; letter-spacing: .02em; opacity: 0; }
.is-visible .mk-thumb b:first-child { animation: mk-swap-out 6s ease infinite; animation-delay: calc(var(--n, 0) * .6s); }
.is-visible .mk-thumb b:last-child { animation: mk-swap-in 6s ease infinite; animation-delay: calc(var(--n, 0) * .6s); }
.mk-thumb:nth-child(2) { --n: 1; } .mk-thumb:nth-child(3) { --n: 2; }
/* One fades out before the other fades in, so the two never sit on top of each other half-visible. */
@keyframes mk-swap-out { 0%, 30% { opacity: 1; } 34%, 90% { opacity: 0; } 94%, 100% { opacity: 1; } }
@keyframes mk-swap-in { 0%, 34% { opacity: 0; } 38%, 86% { opacity: 1; } 90%, 100% { opacity: 0; } }
.mk-fill { width: 68%; }
.is-visible .mk-fill { animation: mk-fill 6s ease-in-out infinite; }
@keyframes mk-fill { 0% { width: 8%; } 80%, 100% { width: 100%; } }

/* ---------- Dictionary card: the word with its pitch, and a recording playing ---------- */
.mk-dict { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mk-dict-word { display: flex; flex-direction: column; gap: 2px; }
.mk-dict-word b { font-size: 26px; font-weight: 600; }
.mk-pitch { display: inline-flex; font-size: 14px; color: var(--gk-text-2); }
.mk-pitch span { position: relative; padding-top: 5px; border-top: 2px solid transparent; }
.mk-pitch .mk-hi { border-top-color: var(--gk-accent-text); }
.mk-pitch .mk-drop::after { content: ""; position: absolute; right: 0; top: -2px; width: 2px; height: 8px; background: var(--gk-accent-text); }
.mk-play { display: inline-flex; align-items: center; gap: 3px; height: 34px; padding: 0 12px; border-radius: 10px; background: var(--gk-accent-soft); color: var(--gk-accent-text); }
.mk-play i { display: block; width: 3px; height: 12px; border-radius: 2px; background: currentColor; transform-origin: center; }
.is-visible .mk-play i { animation: mk-eq 1.4s ease-in-out infinite; }
.mk-play i:nth-of-type(2) { animation-delay: -.4s; } .mk-play i:nth-of-type(3) { animation-delay: -.8s; }
@keyframes mk-eq { 0%, 100% { transform: scaleY(.4); } 50% { transform: scaleY(1.2); } }

/* ---------- Reading Assist card: readings come and go over the hard kanji ---------- */
.is-visible .mk-assist rt { animation: mk-rt 5s ease infinite; }
.mk-assist ruby:nth-of-type(2) rt { animation-delay: .5s; }
@keyframes mk-rt { 0%, 12% { opacity: 0; transform: translateY(4px); } 22%, 82% { opacity: 1; transform: none; } 94%, 100% { opacity: 0; } }

/* ---------- Song Lyrics card: the line being sung moves down the song ---------- */
.mk-lyrics { width: 400px; flex: none; display: flex; flex-direction: column; justify-content: center; gap: 12px; padding: 4px 0; }
.mk-ly { display: flex; flex-direction: column; gap: 2px; padding: 8px 14px; border-radius: 12px; opacity: .38; }
.mk-ly b { font-size: 19px; font-weight: 600; }
.mk-ly span { font-size: 13px; color: var(--text-muted); }
.is-visible .mk-ly { animation: mk-ly 9s ease infinite; }
.mk-ly:nth-child(2) { animation-delay: 3s; } .mk-ly:nth-child(3) { animation-delay: 6s; }
@keyframes mk-ly {
    0% { opacity: .38; background: transparent; }
    4%, 30% { opacity: 1; background: var(--gk-accent-soft); }
    35%, 100% { opacity: .38; background: transparent; }
}
.mk-ly-bar { height: 4px; border-radius: 2px; background: var(--gk-line); margin: 4px 14px 0; overflow: hidden; }
.mk-ly-bar i { display: block; height: 100%; width: 0; border-radius: 2px; background: var(--accent); }
.is-visible .mk-ly-bar i { animation: mk-fill 9s linear infinite; }

/* ---------- AI Conversation card: the messages arrive in turn ---------- */
.mk-ready .mk-chat > * { opacity: 0; transform: translateY(8px); }
.mk-ready .is-in .mk-chat > * { opacity: 1; transform: none; transition: opacity .45s ease, transform .45s ease; }
.mk-ready .is-in .mk-chat > :nth-child(1) { transition-delay: .4s; }
.mk-ready .is-in .mk-chat > :nth-child(2) { transition-delay: 1.3s; }
.mk-ready .is-in .mk-chat > :nth-child(3) { transition-delay: 2.4s; }

/* ---------- Quick Translate card: Ctrl+C being pressed ---------- */
.is-visible .mk-keys .gk-key { animation: mk-key 3s ease infinite; }
.mk-keys .gk-key:last-child { animation-delay: .18s; }
@keyframes mk-key { 0%, 60%, 100% { transform: none; border-bottom-width: 3px; } 66%, 74% { transform: translateY(2px); border-bottom-width: 1px; } }
.is-visible .mk-saved .gk-dot { animation: mk-ping 2.4s ease infinite; }
@keyframes mk-ping { 0%, 100% { box-shadow: 0 0 0 0 rgba(52, 199, 123, .5); } 60% { box-shadow: 0 0 0 7px rgba(52, 199, 123, 0); } }

/* ---------- tray: the highlight moves down the menu ---------- */
.is-visible .mk-tray .gk-tray-item { animation: mk-tray 7s ease infinite; animation-delay: calc(var(--i, 0) * 1s); }
@keyframes mk-tray {
    0% { background: transparent; color: var(--gk-text-2); }
    3%, 12% { background: var(--gk-accent-soft); color: var(--text); }
    16%, 100% { background: transparent; color: var(--gk-text-2); }
}

/* ---------- Study: the ring fills, and a lesson shows how a verb changes ---------- */
@property --mk-p { syntax: "<number>"; inherits: false; initial-value: 74; }
.mk-ring { background: conic-gradient(var(--gk-accent-text) 0 calc(var(--mk-p) * 1%), var(--gk-accent-soft) 0 100%); }
.mk-ready .mk-ring { --mk-p: 0; }
.mk-ready .is-in .mk-ring, .mk-ready .is-in.mk-ring { --mk-p: 74; transition: --mk-p 1.6s cubic-bezier(.2, .7, .2, 1) .3s; }
.mk-lesson { grid-column: span 2; padding: 24px 26px; gap: 10px; }
.mk-lesson-num { font: 12px var(--gk-mono); color: var(--gk-text-3); }
.mk-lesson-title { font-size: 21px; font-weight: 600; }
.mk-lesson p { font-size: 15px; }
.mk-lesson p strong { color: var(--text); }
.mk-steps { display: flex; flex-direction: column; margin-top: 4px; }
.mk-step { display: grid; grid-template-columns: 96px 1fr; align-items: center; padding: 9px 0; border-top: 1px solid var(--border); font-size: 13px; color: var(--gk-text-3); }
.mk-step .gk-jp { font-size: 20px; color: var(--text); }
.mk-step s { color: var(--gk-text-3); text-decoration-thickness: 2px; }
.mk-step mark { background: none; color: var(--gk-accent-text); font-weight: 700; }
.mk-chg { color: var(--warn, #e8a33d); text-decoration: underline; text-underline-offset: 4px; }
.mk-ready .mk-step { opacity: 0; transform: translateX(-8px); }
.mk-ready .is-in .mk-step, .mk-ready .is-in.mk-lesson .mk-step { opacity: 1; transform: none; transition: opacity .5s ease calc(.5s + var(--i, 0) * .25s), transform .5s ease calc(.5s + var(--i, 0) * .25s); }

/* ---------- Library: the reader flips between the original and the English ---------- */
.mk-reader .mk-t-en { background: var(--accent); color: #fff; font-family: var(--font-body); font-weight: 600; }
.mk-swap .mk-en { transition: none; }
.mk-swap .mk-jp {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; opacity: 0;
    writing-mode: horizontal-tb; font-family: var(--gk-mincho); font-weight: 900; font-size: 11px; line-height: 1.2; text-align: center; padding: 4px;
}
.is-visible .mk-reader .mk-t-en { animation: mk-tog-on 8s ease infinite; }
.is-visible .mk-reader .mk-t-jp { animation: mk-tog-off 8s ease infinite; }
.is-visible .mk-reader .mk-en { animation: mk-swap-out 8s ease infinite; }
.is-visible .mk-reader .mk-jp { animation: mk-swap-in 8s ease infinite; }
@keyframes mk-tog-on {
    0%, 30% { background: var(--accent); color: #fff; }
    38%, 88% { background: transparent; color: var(--text-muted); }
    96%, 100% { background: var(--accent); color: #fff; }
}
@keyframes mk-tog-off {
    0%, 30% { background: transparent; color: var(--text-muted); }
    38%, 88% { background: var(--accent); color: #fff; }
    96%, 100% { background: transparent; color: var(--text-muted); }
}
.mk-shelf .gk-bar > i { width: var(--w, 0%); }
.mk-ready .mk-shelf .gk-bar > i { width: 0; }
.mk-ready .mk-shelf.is-in .gk-bar > i { width: var(--w, 0%); transition: width 1.1s cubic-bezier(.2, .7, .2, 1) .3s; }
.mk-ready .mk-shelf.is-in .gk-ch:nth-child(3) .gk-bar > i { transition-delay: .45s; }
.mk-ready .mk-shelf.is-in .gk-ch:nth-child(4) .gk-bar > i { transition-delay: .6s; }
.mk-ready .mk-shelf.is-in .gk-ch:nth-child(5) .gk-bar > i { transition-delay: .75s; }

/* ---------- narrow screens: the side-by-side pictures go under their text ---------- */
@media (max-width: 900px) {
    .mk-lyrics { width: 100%; }
    .mk-lesson { grid-column: auto; }
}

/* ---------- less motion: everything shown, nothing moving ---------- */
@media (prefers-reduced-motion: reduce) {
    .mk-ready .mk-reveal, .mk-ready .mk-stagger > *, .mk-ready .mk-chat > *, .mk-ready .mk-step, .mk-ready .mk-wild rt {
        opacity: 1 !important; transform: none !important; transition: none !important;
    }
    .mk-ready .mk-ring { --mk-p: 74; transition: none; }
    .mk-ready .mk-shelf .gk-bar > i { width: var(--w, 0%); transition: none; }
    .gk-marketing [class*="mk-"], .gk-marketing [class*="mk-"] * { animation: none !important; }
    .mk-line { opacity: 0; } .mk-line:last-child { opacity: 1; }
    .mk-ly:nth-child(2) { opacity: 1; background: var(--gk-accent-soft); }
}
