/* ===== New Canada Guide — motion, new pages and visual upgrades ===== */

/* soft animated background */
.bg-orbs { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg-orbs span { position: absolute; width: 46vmax; height: 46vmax; border-radius: 50%; filter: blur(80px); opacity: .16; animation: orb 28s ease-in-out infinite alternate; }
.bg-orbs span:nth-child(1) { background: #d52b1e; top: -18vmax; inset-inline-start: -12vmax; }
.bg-orbs span:nth-child(2) { background: #ff9a5a; bottom: -22vmax; inset-inline-end: -14vmax; animation-delay: -9s; }
.bg-orbs span:nth-child(3) { background: #3f7be0; top: 40%; inset-inline-start: 40%; width: 30vmax; height: 30vmax; opacity: .08; animation-delay: -17s; }
@keyframes orb { to { transform: translate(6vmax, 4vmax) scale(1.12); } }

.logo svg { width: 42px; height: 42px; animation: spin-in 1.2s cubic-bezier(.2,.8,.2,1); }
@keyframes spin-in { from { transform: rotate(-120deg) scale(.6); opacity: 0; } }

/* nav: wrap on wide screens so all sections are visible */
@media (min-width: 761px) { .nav { flex-wrap: wrap; overflow: visible; row-gap: 2px; } .nav a { font-size: .86rem; padding: 6px 10px; } }
.nav a.nav-sos { color: var(--red); font-weight: 700; }

/* scroll reveal */
.js .rv { opacity: 0; transform: translateY(18px); transition: opacity .6s cubic-bezier(.2,.8,.2,1), transform .6s cubic-bezier(.2,.8,.2,1); }
.js .rv.in { opacity: 1; transform: none; }

/* 3D tilt + spotlight cards */
.tilt { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .25s ease, box-shadow .25s, border-color .25s, opacity .6s; will-change: transform; overflow: hidden; }
.js .tilt.rv:not(.in) { transform: translateY(18px); }
.tilt::before { content: ''; position: absolute; inset: 0; background: radial-gradient(240px circle at var(--mx, -200px) var(--my, -200px), color-mix(in srgb, var(--red) 14%, transparent), transparent 60%); pointer-events: none; }

/* hero */
.shine { background: linear-gradient(100deg, var(--text) 0%, var(--text) 40%, var(--red) 50%, var(--text) 60%, var(--text) 100%); background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shine 6s ease-in-out infinite; }
@keyframes shine { 0%, 30% { background-position: 100% 0; } 70%, 100% { background-position: 0 0; } }
.hero-art { min-height: 320px; }
.scene-hero { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 24px; box-shadow: 0 20px 50px rgba(16,24,40,.18); }
.scene-hero .sun { fill: #ffd76a; filter: drop-shadow(0 0 18px #ffd76a); animation: sunp 5s ease-in-out infinite; }
@keyframes sunp { 50% { transform: translateY(-4px); } }
.scene-hero .city rect, .scene-hero .city polygon { fill: color-mix(in srgb, var(--text) 22%, var(--sky)); }
.scene-hero .hill { fill: var(--grass); }
.scene-hero .road-h { fill: var(--road); }
.scene-hero .lane-dash { stroke: #f2c200; stroke-width: 3; stroke-dasharray: 18 14; animation: dash 1s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -32; } }
.hcar { animation: drive 7s linear infinite; }
.hcar2 { animation: drive2 9s linear infinite; }
@keyframes drive { from { transform: translateX(-80px); } to { transform: translateX(440px); } }
@keyframes drive2 { from { transform: translateX(440px) scaleX(-1); } to { transform: translateX(-80px) scaleX(-1); } }
.tl-r, .tl-y, .tl-g { fill: #3a3f47; }
.tl-r { animation: tlr 6s steps(1) infinite; } .tl-y { animation: tly 6s steps(1) infinite; } .tl-g { animation: tlg 6s steps(1) infinite; }
@keyframes tlg { 0% { fill: #1fd166; } 45% { fill: #3a3f47; } }
@keyframes tly { 0% { fill: #3a3f47; } 45% { fill: #ffc400; } 60% { fill: #3a3f47; } }
@keyframes tlr { 0% { fill: #3a3f47; } 60% { fill: #ff3b2f; } }
.hero-art .float { z-index: 2; }
.hero-art .s1 { top: -4%; inset-inline-start: -4%; width: 78px; }
.hero-art .s2 { top: 6%; inset-inline-end: -3%; width: 66px; }
.hero-art .s3 { bottom: -6%; inset-inline-start: 38%; width: 62px; }
.leaf { position: absolute; top: -10%; font-size: 22px; animation: fall 9s linear infinite; z-index: 3; opacity: .85; }
.l1 { inset-inline-start: 15%; } .l2 { inset-inline-start: 45%; animation-delay: -3s; font-size: 16px; } .l3 { inset-inline-start: 75%; animation-delay: -6s; } .l4 { inset-inline-start: 60%; animation-delay: -1.5s; font-size: 14px; }
@keyframes fall { 0% { transform: translate(0, 0) rotate(0); opacity: 0; } 10% { opacity: .9; } 50% { transform: translate(30px, 180px) rotate(180deg); } 100% { transform: translate(-20px, 380px) rotate(360deg); opacity: 0; } }
.btn.glow { position: relative; }
.btn.glow::after { content: ''; position: absolute; inset: -3px; border-radius: 14px; border: 2px solid var(--red); opacity: 0; animation: ring 2.4s ease-out infinite; }
@keyframes ring { 0% { opacity: .7; transform: scale(.96); } 100% { opacity: 0; transform: scale(1.12); } }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; text-align: center; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 2rem; font-weight: 800; color: var(--red); font-family: 'Inter', var(--font); }
.stat span { color: var(--muted); font-size: .9rem; }

/* progress ring */
.ring-row { display: flex; align-items: center; gap: 16px; }
.ring-row > div { flex: 1; }
.ring .ring-bg { fill: none; stroke: var(--line); stroke-width: 7; }
.ring .ring-fg { fill: none; stroke: var(--ok); stroke-width: 7; stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(.2,.8,.2,1); }
.ring text { fill: var(--text); font-size: 13px; font-weight: 800; font-family: 'Inter', sans-serif; }

/* flip-card road signs */
.sign { perspective: 900px; padding: 0; background: none; border: 0; box-shadow: none; min-height: 190px; }
.sign:hover { box-shadow: none; }
.sign-in { position: relative; display: block; width: 100%; height: 100%; min-height: 190px; transition: transform .6s cubic-bezier(.2,.8,.2,1); transform-style: preserve-3d; }
.sign.open .sign-in { transform: rotateY(180deg); }
.sign-front, .sign-back { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); backface-visibility: hidden; -webkit-backface-visibility: hidden; text-align: center; }
.sign-back { transform: rotateY(180deg); background: linear-gradient(160deg, var(--soft), var(--card)); border-color: var(--red); }
.sign-back span { color: var(--muted); font-size: .9rem; }
.sign:hover .sign-front .sign-img { transform: scale(1.08) rotate(-3deg); }
.sign-img { transition: transform .3s; }
.sign.open { background: none; }

/* who-to-call chips */
.calls { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 12px; border-top: 1px dashed var(--line); }
.calls-h { font-weight: 700; font-size: .88rem; }
.callchip { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px 4px 4px; font-size: .85rem; }
.callchip b { background: var(--text); color: var(--bg); border-radius: 999px; padding: 2px 10px; font-family: 'Inter', sans-serif; }
.callchip.red b { background: var(--red); color: #fff; }
.callchip.soft { padding: 5px 12px; color: var(--muted); }
.callchip:hover { border-color: var(--red); }

/* tests explained */
.facts { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 8px; }
.facts li { padding: 10px 14px; border-radius: 12px; background: var(--bg); border-inline-start: 4px solid var(--red); }
.okline { color: var(--ok); font-weight: 600; }
.warnline { color: #b26a00; font-weight: 600; }
:root[data-theme="dark"] .warnline { color: #ffb347; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .warnline { color: #ffb347; } }
.note-box { background: color-mix(in srgb, #3f7be0 10%, var(--card)); border: 1px solid color-mix(in srgb, #3f7be0 30%, var(--line)); border-radius: 14px; padding: 14px 16px; margin: 12px 0 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip.big { font-size: .92rem; padding: 7px 14px; }
.chip.okc { background: var(--ok-bg); color: var(--ok); }
.chip.noc { background: var(--no-bg); color: var(--no); }
.panel.danger { border-color: color-mix(in srgb, var(--no) 45%, var(--line)); background: linear-gradient(170deg, var(--no-bg), var(--card) 60%); }
.panel.callout { margin-top: 18px; background: linear-gradient(120deg, var(--soft), var(--card)); }
.check.mini { padding: 10px 12px; }
.center-t { text-align: center; }
.cards.two-col { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.exam-pick .btn { margin-top: 14px; }

/* readiness exam */
.exam-bar { position: sticky; top: 118px; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 12px 16px; }
.exam-clock { display: flex; flex-direction: column; min-width: 90px; }
.exam-clock b { font-size: 1.5rem; font-family: 'Inter', sans-serif; }
.exam-clock b.low { color: var(--no); animation: beat 1s ease-in-out infinite; }
@keyframes beat { 50% { transform: scale(1.08); } }
.exam-prog { flex: 1; }
.exam-main { display: grid; grid-template-columns: 1fr 260px; gap: 16px; align-items: start; }
.exam-main .quiz { max-width: none; margin: 0; }
.qgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; position: sticky; top: 200px; }
.qn { aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: .85rem; cursor: pointer; font-family: 'Inter', var(--font); }
.qn.ans { background: color-mix(in srgb, var(--red) 16%, var(--card)); border-color: color-mix(in srgb, var(--red) 40%, var(--line)); }
.qn.flg { box-shadow: inset 0 -4px 0 #f0a500; }
.qn.cur { outline: 3px solid var(--red); outline-offset: 1px; }
.opt.sel { border-color: var(--red); background: var(--soft); }
.opt.sel .opt-l { background: var(--red); color: #fff; border-color: var(--red); }
.cta.spread { justify-content: space-between; }
.link-btn.flagged { color: #c77d00; }
.btn[disabled] { opacity: .45; cursor: default; }
.pop { animation: pop .45s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { transform: scale(.6) rotate(-8deg); opacity: 0; } }
.opt.wrongp { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.opt.right { animation: okp .4s; }
@keyframes okp { 50% { transform: scale(1.02); } }

/* result */
.result-hero { text-align: center; padding: 28px 20px; position: relative; overflow: hidden; }
.result-hero::before { content: ''; position: absolute; inset: 0; opacity: .12; pointer-events: none; }
.result-hero.ready::before { background: radial-gradient(circle at 50% 0, var(--ok), transparent 60%); }
.result-hero.almost::before { background: radial-gradient(circle at 50% 0, #2f9e6b, transparent 60%); }
.result-hero.close::before { background: radial-gradient(circle at 50% 0, #f0a500, transparent 60%); }
.result-hero.notready::before { background: radial-gradient(circle at 50% 0, var(--no), transparent 60%); }
.gauge { width: min(320px, 90%); display: block; margin: 0 auto; }
.g-bg { fill: none; stroke: var(--line); stroke-width: 16; stroke-linecap: round; }
.g-fg { fill: none; stroke-width: 16; stroke-linecap: round; transition: stroke-dashoffset 1.6s cubic-bezier(.2,.8,.2,1); }
.gauge.ready .g-fg { stroke: var(--ok); } .gauge.almost .g-fg { stroke: #2f9e6b; } .gauge.close .g-fg { stroke: #f0a500; } .gauge.notready .g-fg { stroke: var(--no); }
.g-num { font-size: 34px; font-weight: 800; fill: var(--text); font-family: 'Inter', sans-serif; }
.verdict { display: inline-block; margin: 6px 0 10px; padding: 6px 16px; border-radius: 999px; font-weight: 800; letter-spacing: .02em; }
.verdict.pass { background: var(--ok-bg); color: var(--ok); }
.verdict.fail { background: var(--no-bg); color: var(--no); }
.lv-title { font-size: 1.8rem; margin: 6px 0; }
.parts { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.warnpanel { border-color: color-mix(in srgb, #f0a500 50%, var(--line)); background: linear-gradient(170deg, color-mix(in srgb, #f0a500 10%, var(--card)), var(--card) 60%); }
.tbar { margin: 12px 0; }
.tbar-h { display: flex; justify-content: space-between; margin-bottom: 4px; }
.progress.good span { background: var(--ok); } .progress.mid span { background: #f0a500; } .progress.bad span { background: var(--no); }
.rev { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.rev:last-child { border-bottom: 0; }
.rev-sign { width: 56px; flex: none; } .rev-sign svg { width: 100%; }
.rev-no { color: var(--no); margin-top: 4px; } .rev-ok { color: var(--ok); }
.hbars { position: relative; display: flex; gap: 8px; align-items: flex-end; height: 140px; padding-top: 10px; border-bottom: 1px solid var(--line); }
.passline { position: absolute; inset-inline: 0; border-top: 2px dashed color-mix(in srgb, var(--ok) 60%, transparent); }
.hbar { flex: 1; max-width: 46px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.hbar span { width: 100%; border-radius: 8px 8px 2px 2px; background: var(--no); animation: grow .8s cubic-bezier(.2,.8,.2,1); transform-origin: bottom; }
.hbar.ready span { background: var(--ok); } .hbar.almost span { background: #2f9e6b; } .hbar.close span { background: #f0a500; }
.hbar small { font-size: .7rem; }
@keyframes grow { from { transform: scaleY(0); } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 100; }

/* handbooks */
.panel.feature .card-ico { margin-bottom: 8px; }
.books { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.book { position: relative; display: flex; flex-direction: column; justify-content: flex-end; min-height: 150px; padding: 16px 16px 16px 26px; border-radius: 6px 14px 14px 6px; text-decoration: none; color: #fff; background: linear-gradient(150deg, #d52b1e, #8e1a12); box-shadow: 0 10px 24px rgba(0,0,0,.18); transition: transform .3s; overflow: hidden; }
.book:nth-child(3n+2) { background: linear-gradient(150deg, #2f6fde, #173b7a); }
.book:nth-child(3n+3) { background: linear-gradient(150deg, #16a085, #0b5747); }
.book::after { content: '📖'; position: absolute; top: 12px; inset-inline-end: 14px; font-size: 22px; opacity: .8; }
.book-spine { position: absolute; inset-block: 0; inset-inline-start: 0; width: 10px; background: rgba(0,0,0,.25); }
.book small { opacity: .8; }
.book:hover { transform: translateY(-6px) rotate(-1deg); }

/* emergency */
.sos-hero { display: grid; grid-template-columns: 260px 1fr; gap: 18px; align-items: stretch; margin-bottom: 8px; }
.sos-btn { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; color: #fff; border-radius: 28px; background: radial-gradient(circle at 30% 20%, #ff5a4a, #b31d12); box-shadow: 0 20px 40px rgba(213,43,30,.35); min-height: 220px; overflow: hidden; text-align: center; padding: 16px; }
.sos-btn b { font-size: 4.2rem; line-height: 1; font-family: 'Inter', sans-serif; position: relative; }
.sos-btn small { position: relative; opacity: .95; margin-top: 8px; }
.pulse { position: absolute; width: 160px; height: 160px; border-radius: 50%; border: 3px solid rgba(255,255,255,.6); animation: sosp 2s ease-out infinite; }
@keyframes sosp { from { transform: scale(.5); opacity: 1; } to { transform: scale(1.8); opacity: 0; } }
.sos-hero .panel { margin: 0; }
.scens { display: grid; gap: 10px; }
.scen { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.scen summary { display: flex; align-items: center; gap: 4px; padding: 14px 16px; cursor: pointer; list-style: none; }
.scen summary::-webkit-details-marker { display: none; }
.scen summary b { flex: 1; }
.scen summary::after { content: '+'; font-size: 1.4rem; color: var(--red); transition: transform .3s; margin-inline-start: 8px; }
.scen[open] summary::after { transform: rotate(45deg); }
.scen[open] { border-color: color-mix(in srgb, var(--red) 40%, var(--line)); }
.scen > ol, .scen > .calls { margin-inline: 16px; }
.scen > .calls { margin-bottom: 14px; }
.sum-nums { display: flex; gap: 4px; flex-wrap: wrap; }
.mini-num { font-size: .72rem; font-weight: 700; background: var(--soft); color: var(--red); border-radius: 999px; padding: 2px 8px; font-family: 'Inter', sans-serif; }
.nums.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }

/* new animated lessons */
.scene .island { fill: var(--island); }
.car.ring { transform-origin: 150px 150px; transition: transform 1.6s cubic-bezier(.45,.05,.35,1); }

/* responsive */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .exam-main { grid-template-columns: 1fr; }
  .qgrid { position: static; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); }
  .sos-hero { grid-template-columns: 1fr; }
  .sos-btn { min-height: 170px; }
}
@media (max-width: 760px) {
  .exam-bar { top: 104px; flex-wrap: wrap; gap: 10px; }
  .exam-bar .btn { width: 100%; }
  .hero-art { min-height: 220px; }
  .stat b { font-size: 1.6rem; }
  .sign, .sign-in { min-height: 170px; }
}
@media (prefers-reduced-motion: reduce) {
  .js .rv { opacity: 1; transform: none; }
  .hcar, .hcar2, .leaf, .bg-orbs span, .pulse, .shine { animation: none !important; }
  .shine { color: var(--text); background: none; }
}
@media print { .bg-orbs, .hero-art, .confetti { display: none; } .js .rv { opacity: 1; transform: none; } }
