/* =====================================================================================================
   TEST DAY, ACT BY ACT (js/pages/home.js, journey()): the home page's exam section. Listening, Reading, Writing and
   Speaking follow each other as you scroll. A sticky exam clock on the left runs with the scroll; its rail is cut
   into segments as long as each paper. Each act has a giant outlined number, its own tone, and a preview of the
   test screen that comes alive while the act is in view.
   ===================================================================================================== */
.xd { --xp: 0; position: relative; padding: clamp(56px, 8vw, 110px) 0 clamp(40px, 6vw, 80px); isolation: isolate; }
/* the tone of the act in view washes over the whole section */
.xd::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: .9; transition: background 1s ease;
  background: radial-gradient(60% 50% at 85% 40%, color-mix(in srgb, var(--xd-tone, #c49563) 16%, transparent), transparent 70%); }
.xd[data-on="listening"] { --xd-tone: var(--c-listening); }
.xd[data-on="reading"] { --xd-tone: var(--c-reading); }
.xd[data-on="writing"] { --xd-tone: var(--c-writing); }
.xd[data-on="speaking"] { --xd-tone: var(--c-speaking); }

.xd-head { max-width: 860px; text-align: center; margin-bottom: clamp(28px, 5vw, 64px); }
.xd-head .cd-eyebrow { margin-inline: auto; }
.xd-head h2 { margin: 0; font-size: clamp(2.2rem, 5vw, 3.8rem); line-height: 1.02; letter-spacing: -.04em; }
.xd-head p { max-width: 620px; margin: 18px auto 0; color: var(--text-2); font-size: 1.08rem; }

.xd-stage { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: clamp(24px, 4vw, 56px); }

/* ---------- the exam clock and its rail ---------- */
.xd-rail { position: sticky; top: calc(var(--topbar-h, 72px) + 28px); align-self: start; height: calc(100svh - var(--topbar-h, 72px) - 56px); display: flex; flex-direction: column; gap: 18px; }
.xd-clock { padding: 14px 16px; border-radius: 18px; background: linear-gradient(180deg, #fff, #fbf4ea); border: 1px solid var(--border); box-shadow: var(--card-shadow); }
.xd-clock small { display: block; font: 500 .66rem/1.3 var(--font-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.xd-clock b { display: block; margin-top: 4px; font: 700 2.1rem/1 var(--font-mono); letter-spacing: -.04em; color: var(--text); font-variant-numeric: tabular-nums; }
.xd-line { flex: 1; min-height: 0; display: flex; flex-direction: column; margin: 0; padding: 0 0 0 22px; list-style: none; position: relative; }
/* the line itself, and how far the day has gone */
.xd-line::before, .xd-line::after { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 3px; border-radius: 3px; background: var(--surface-3); }
.xd-line::after { bottom: auto; height: calc((100% - 12px) * var(--xp)); background: linear-gradient(180deg, #c49563, #8a5a2b); box-shadow: 0 0 14px rgba(196, 149, 99, .6); transition: height .25s linear; }
.xd-line li { flex: var(--g) 1 0; position: relative; padding-top: 2px; min-height: 46px; }
.xd-line li i { position: absolute; left: -22px; top: 2px; z-index: 1; width: 15px; height: 15px; border-radius: 50%; background: #fff; border: 3px solid var(--surface-3); transition: border-color .4s, transform .5s var(--spring, ease), background .4s; }
.xd-line li b { display: block; font: 700 1rem/1.2 var(--font-display); color: var(--muted); transition: color .4s, transform .5s var(--spring, ease); transform-origin: 0 50%; }
.xd-line li small { font: 500 .7rem var(--font-mono); letter-spacing: .08em; color: var(--muted); }
.xd-line li.is-done i { border-color: #a06a3a; background: #a06a3a; }
.xd-line li.is-done b { color: var(--text-2); }
.xd-line li.is-on i { border-color: var(--tone); background: #fff; transform: scale(1.35); box-shadow: 0 0 0 6px color-mix(in srgb, var(--tone) 20%, transparent); }
.xd-line li.is-on b { color: var(--text); transform: scale(1.18); }
.xd-line li:nth-child(1) { --tone: var(--c-listening); }
.xd-line li:nth-child(2) { --tone: var(--c-reading); }
.xd-line li:nth-child(3) { --tone: var(--c-writing); }
.xd-line li:nth-child(4) { --tone: var(--c-speaking); }

/* ---------- the acts ---------- */
.xd-acts { display: grid; gap: clamp(20px, 3vw, 40px); }
.xd-act { --ap: 0; position: relative; min-height: min(86svh, 780px); display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: clamp(24px, 4vw, 56px); align-items: center;
  padding: clamp(28px, 4vw, 56px); border-radius: 32px; overflow: hidden; isolation: isolate;
  background: radial-gradient(70% 80% at 100% 0%, color-mix(in srgb, var(--tone) 14%, transparent), transparent 65%), linear-gradient(180deg, #fff, #fffaf4);
  border: 1px solid var(--border); box-shadow: var(--card-shadow); }
.xd-act:nth-child(even) .xd-copy { order: 2; }
.xd-act:nth-child(even) { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); }
.xd-visual .lp-window { width: 100%; }
/* the giant number, drifting against the scroll */
.xd-num { position: absolute; z-index: -1; right: -.04em; bottom: -.22em; font: 800 clamp(11rem, 26vw, 22rem)/1 var(--font-display); letter-spacing: -.08em;
  color: transparent; -webkit-text-stroke: 2px color-mix(in srgb, var(--tone) 32%, transparent); pointer-events: none; user-select: none;
  transform: translate3d(0, calc(var(--ap) * 70px), 0); }
.xd-act:nth-child(even) .xd-num { right: auto; left: -.04em; }

.xd-time { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 99px; font: 600 .72rem/1.3 var(--font-mono); letter-spacing: .08em;
  color: var(--tone); background: color-mix(in srgb, var(--tone) 11%, #fff); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 25%, transparent); }
.xd-time::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--tone); }
.xd-act.is-on .xd-time::before { animation: xdBlink 1.2s ease-in-out infinite; }
@keyframes xdBlink { 50% { opacity: .25; } }

/* the paper's name is drawn up out of a slot */
.xd-title { margin: 18px 0 0; font-size: clamp(3rem, 7vw, 5.6rem); line-height: .92; letter-spacing: -.055em; overflow: hidden; padding-bottom: .08em; }
.xd-title span { display: inline-block; background: linear-gradient(100deg, var(--text) 30%, var(--tone)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.xd-tag { margin: 14px 0 0; font: 600 1.2rem/1.35 var(--font-display); letter-spacing: -.015em; color: var(--text); }
.xd-lead { margin: 10px 0 0; color: var(--text-2); max-width: 440px; }
.xd-facts { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 26px; padding: 0; list-style: none; }
.xd-facts li { min-width: 92px; padding: 10px 14px; border-radius: 16px; background: #fff; border: 1px solid var(--border); box-shadow: 0 10px 24px -18px rgba(80, 50, 20, .4); }
.xd-facts b { display: block; font: 800 1.5rem/1 var(--font-display); letter-spacing: -.03em; color: var(--tone); }
.xd-facts span { display: block; margin-top: 4px; font-size: .76rem; color: var(--muted); }
.xd-copy .btn svg { width: 18px; height: 18px; margin-left: 6px; transition: transform .3s; }
.xd-copy .btn:hover svg { transform: translateX(4px); }

/* the test screen leans back, and stands up as the act reaches the middle */
.xd-visual { perspective: 1400px; }
.xd-visual .lp-window { transform: rotateY(calc(-14deg + (1 - max(var(--ap), calc(var(--ap) * -1))) * 10deg)) rotateX(calc(var(--ap) * 10deg)) translateZ(calc(max(var(--ap), calc(var(--ap) * -1)) * -80px));
  box-shadow: 30px 40px 70px -30px rgba(90, 55, 25, .35), 0 0 80px -30px color-mix(in srgb, var(--tone) 60%, transparent); transition: box-shadow .4s; }
.xd-act:nth-child(even) .xd-visual .lp-window { transform: rotateY(calc(14deg - (1 - max(var(--ap), calc(var(--ap) * -1))) * 10deg)) rotateX(calc(var(--ap) * 10deg)) translateZ(calc(max(var(--ap), calc(var(--ap) * -1)) * -80px)); }
.xd-visual .lp-window-bar { background: linear-gradient(180deg, color-mix(in srgb, var(--tone) 85%, #fff), var(--tone)); }

/* ---------- the previews come alive ---------- */
/* Listening: the recording plays and the answers fill in */
.xd-audio .lp-play { background: var(--tone); }
.xd-audio .lp-wave i { transform-origin: 50% 50%; }
.xd-act.is-on .xd-audio .lp-wave i { animation: xdWave 1.1s ease-in-out calc(var(--i) * -.07s) infinite alternate, xdPlayed 9s linear calc(var(--i) * .2s) infinite; }
@keyframes xdWave { from { transform: scaleY(.45); } to { transform: scaleY(1); } }
@keyframes xdPlayed { 0%, 2% { background: var(--border-strong); } 4%, 100% { background: var(--tone); } }
.xd-fill { min-width: 84px; color: transparent; transition: color .3s, border-color .3s, background .3s; }
.xd-act.is-on .xd-fill { animation: xdFill 9s steps(1) calc(var(--k) * 1.8s + .9s) infinite; }
@keyframes xdFill { 0% { color: var(--text); border-color: var(--success); background: #e6f7f0; } 88% { color: var(--text); border-color: var(--success); background: #e6f7f0; } 100% { color: transparent; } }
/* Reading: the highlighter sweeps, an answer is picked */
.xd-mark { background: linear-gradient(#fff0a8, #fff0a8) no-repeat 0 0 / 0% 100%; }
.xd-act.is-on .xd-mark { animation: xdMark 6s ease-in-out .6s infinite; }
@keyframes xdMark { 0% { background-size: 0% 100%; } 18%, 92% { background-size: 100% 100%; } 100% { background-size: 0% 100%; } }
.xd-act.is-on .xd-pick { animation: xdPick 6s steps(1) .6s infinite; }
@keyframes xdPick { 0%, 30% { background: transparent; color: inherit; } 31%, 100% { background: var(--primary); border-color: var(--primary); color: #fff; } }
/* Speaking: the talk clock runs round */
.xd-ring { --p: 0; --tone: var(--c-speaking); transition: background .25s linear; }

/* ---------- before and after the exam ---------- */
.xd-more { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(16px, 2.4vw, 28px); margin-top: clamp(28px, 4vw, 48px); }
.xd-extra { position: relative; display: grid; gap: 6px; padding: clamp(22px, 3vw, 34px); padding-right: 80px; border-radius: 26px; color: var(--text); text-decoration: none;
  background: linear-gradient(180deg, #fff, #fffaf4); border: 1px solid var(--border); box-shadow: var(--card-shadow); transition: transform .4s var(--spring, ease), box-shadow .3s; }
.xd-extra:hover { color: var(--text); text-decoration: none; transform: translateY(-4px); box-shadow: 0 1px 2px rgba(80, 50, 20, .06), 0 34px 60px -30px rgba(80, 50, 20, .4); }
.xd-extra-k { font: 500 .7rem/1.3 var(--font-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--primary); }
.xd-extra b { font: 700 clamp(1.5rem, 2.6vw, 2rem)/1.1 var(--font-display); letter-spacing: -.03em; }
.xd-extra > span:last-of-type { color: var(--text-2); }
.xd-extra i { position: absolute; right: 24px; top: 50%; translate: 0 -50%; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); transition: transform .4s var(--spring, ease); }
.xd-extra i svg { width: 20px; height: 20px; }
.xd-extra:hover i { transform: translateX(4px) rotate(-30deg); }
.xd-extra-dark { color: #fff; background: radial-gradient(70% 90% at 100% 0%, rgba(232, 200, 160, .35), transparent 70%), var(--grad-brown, linear-gradient(150deg, #4a2b14, #9a6535)); border-color: transparent; }
.xd-extra-dark:hover { color: #fff; }
.xd-extra-dark .xd-extra-k { color: #f3dcc0; }
.xd-extra-dark > span:last-of-type { color: rgba(255, 255, 255, .8); }
.xd-extra-dark i { background: rgba(255, 255, 255, .16); color: #fff; }

/* ---------- smaller screens: the rail becomes a bar along the top ---------- */
@media (max-width: 960px) {
  .xd-stage { grid-template-columns: 1fr; }
  .xd-rail { z-index: 4; top: var(--topbar-h, 64px); height: auto; flex-direction: row; align-items: center; gap: 12px; margin: 0 -16px; padding: 10px 16px;
    background: rgba(255, 250, 243, .92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); }
  .xd-clock { padding: 6px 10px; border-radius: 12px; box-shadow: none; }
  .xd-clock small { display: none; }
  .xd-clock b { margin: 0; font-size: 1.15rem; }
  .xd-line { flex-direction: row; padding: 16px 0 0; gap: 4px; }
  .xd-line::before, .xd-line::after { left: 0; right: 0; top: 0; bottom: auto; width: auto; height: 4px; }
  .xd-line::after { right: auto; width: calc(100% * var(--xp)); height: 4px; transition: width .25s linear; }
  .xd-line li { min-height: 0; padding: 0; }
  .xd-line li i { display: none; }
  .xd-line li b { font-size: .78rem; }
  .xd-line li.is-on b { transform: none; color: var(--tone); }
  .xd-line li small { display: none; }
  .xd-act, .xd-act:nth-child(even) { min-height: 0; grid-template-columns: 1fr; padding: 26px 20px; border-radius: 26px; }
  .xd-act:nth-child(even) .xd-copy { order: 0; }
  .xd-num { font-size: 9rem; }
  .xd-visual .lp-window, .xd-act:nth-child(even) .xd-visual .lp-window { transform: none; }
  .xd-more { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .xd-title { font-size: 3rem; }
  .xd-facts li { min-width: 0; flex: 1 1 0; padding: 9px 10px; }
  .xd-facts b { font-size: 1.2rem; }
  .xd-copy .btn { width: 100%; }
  .xd-line li b { font-size: .7rem; letter-spacing: -.01em; }
}
@media (prefers-reduced-motion: reduce) {
  .xd-act .xd-audio .lp-wave i, .xd-act .xd-fill, .xd-act .xd-mark, .xd-act .xd-pick, .xd-act .xd-time::before { animation: none !important; }
  .xd-fill { color: var(--text); border-color: var(--success); background: #e6f7f0; }
  .xd-mark { background-size: 100% 100%; }
  .xd-num, .xd-visual .lp-window { transform: none !important; }
}

/* ---------- "Moving to the next version" (js/app.js, showUpdate) ---------- */
.upd { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; padding: 16px; background: rgba(45, 32, 22, .38); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); opacity: 0; transition: opacity .35s ease; }
.upd.on { opacity: 1; }
.upd-card { width: min(420px, 100%); padding: 32px 28px 26px; border-radius: 26px; text-align: center; color: var(--text); background: linear-gradient(180deg, #fff, #fbf4ea); border: 1px solid var(--border);
  box-shadow: 0 40px 80px -30px rgba(60, 35, 15, .55); transform: translateY(18px) scale(.96); transition: transform .5s var(--spring, cubic-bezier(.34, 1.56, .64, 1)); }
.upd.on .upd-card { transform: none; }
.upd-card h2 { margin: 16px 0 8px; font-size: 1.5rem; letter-spacing: -.03em; }
.upd-card p { margin: 0 0 22px; color: var(--text-2); }
.upd-go { width: 100%; }
.upd-ic { position: relative; display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--grad-primary); box-shadow: 0 14px 30px -12px rgba(110, 68, 32, .7); }
.upd-ic i { width: 26px; height: 26px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: updSpin 1s linear infinite; }
@keyframes updSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .upd-ic i { animation: none; } .upd-card { transition: none; } }
