/* Tutorial page (howto.html). Loaded after style.css. */

/* One colour per lesson. White text passes WCAG AA on each. */
.c1 { --c: #0F7B53; }
.c2 { --c: #6D28D9; }
.c3 { --c: #C2410C; }
.c4 { --c: #BE185D; }
.c5 { --c: #0369A1; }
.c6 { --c: #1D4ED8; }
.c7 { --c: #0E7490; }
.c8 { --c: #B91C1C; }
.c9 { --c: #A16207; }
.c10 { --c: #15803D; }
.c11 { --c: #4338CA; }
.c12 { --c: #10231C; }
.c1, .c2, .c3, .c4, .c5, .c6, .c7, .c8, .c9, .c10, .c11, .c12 { --c-soft: color-mix(in srgb, var(--c, #0F7B53) 9%, #FFFFFF); --c-line: color-mix(in srgb, var(--c, #0F7B53) 28%, #FFFFFF); }

.btn-amber { background: var(--amber); color: var(--ink); }
.btn-amber:hover { color: var(--ink); background: #F5B357; }

/* ---------- Reading progress ---------- */
.read-progress { position: fixed; top: 0; left: 0; right: 0; height: 4px; z-index: 60; pointer-events: none; }
.read-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #0F7B53, #6D28D9, #C2410C, #BE185D, #0369A1, #1D4ED8, #0E7490, #B91C1C, #A16207, #15803D, #4338CA); transition: width .1s linear; }

.nav-links a[aria-current="page"] { color: var(--accent); font-weight: 700; box-shadow: inset 0 -2px 0 var(--accent); }

/* ---------- Hero ---------- */
.t-hero { background: var(--dark); color: var(--white); padding: clamp(56px, 8vw, 96px) 0; overflow: hidden; }
.t-hero-grid { display: flex; flex-wrap: wrap; align-items: center; gap: 48px; }
.t-hero-text { flex: 1 1 520px; min-width: 0; }
.t-pill { display: inline-flex; align-items: center; gap: 10px; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; padding: 8px 16px; font-size: 14px; font-weight: 600; color: var(--on-dark-muted); }
.t-pill-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 0 rgba(110,231,183,.6); animation: ping 2s ease-out infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(110,231,183,.6); } 100% { box-shadow: 0 0 0 12px rgba(110,231,183,0); } }
.t-hero h1 { margin-top: 22px; font-size: clamp(40px, 5.4vw, 66px); line-height: 1.04; }
.t-lead { margin-top: 22px; font-size: clamp(18px, 1.5vw, 20px); color: var(--on-dark-muted); max-width: 600px; }
.t-hero .btn-row { margin-top: 32px; }
.t-hero-meta { list-style: none; padding: 0; margin: 28px 0 0; display: flex; flex-wrap: wrap; gap: 8px 24px; font-size: 15px; color: var(--on-dark-muted); }
.t-hero-meta li::before { content: "✓"; color: var(--mint); font-weight: 800; margin-right: 8px; }

.t-hero-art { flex: 0 1 420px; position: relative; aspect-ratio: 1; max-width: 420px; width: 100%; margin: 0 auto; }
.t-path { position: absolute; inset: 0; width: 100%; height: 100%; }
.t-path-line { stroke-dasharray: 900; stroke-dashoffset: 900; animation: draw 2.4s .3s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.t-node { position: absolute; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; color: var(--white); background: var(--c); box-shadow: 0 0 0 6px rgba(255,255,255,.08), 0 12px 24px -8px rgba(0,0,0,.6); transform: scale(0); animation: pop .5s cubic-bezier(.2,1.6,.4,1) forwards, bob 5s ease-in-out infinite; }
.t-node.n1 { --c: #0F7B53; left: 14.3%; top: 85.7%; animation-delay: .4s, 1s; }
.t-node.n2 { --c: #6D28D9; left: 32%; top: 70%; animation-delay: .7s, 1.6s; }
.t-node.n3 { --c: #C2410C; left: 54%; top: 63%; animation-delay: 1s, 2.2s; }
.t-node.n4 { --c: #BE185D; left: 61%; top: 43%; animation-delay: 1.3s, 1.2s; }
.t-node.n5 { --c: #1D4ED8; left: 36%; top: 30%; animation-delay: 1.6s, 2.6s; }
.t-node.n6 { --c: #1D4ED8; left: 48%; top: 15.5%; animation-delay: 1.9s, 1.8s; }
.t-node.n5 { --c: #0369A1; }
.t-node.n7 { --c: #0E7490; left: 74%; top: 14%; animation-delay: 2.2s, 2.4s; }
.t-node.n8 { --c: #B91C1C; animation-delay: 2.4s, 1.4s; }
.t-node.n9 { --c: #A16207; animation-delay: 2.6s, 2s; }
.t-node.n10 { --c: #15803D; animation-delay: 2.8s, 2.8s; }
.t-node.n11 { --c: #4338CA; animation-delay: 3s, 1.6s; }
.t-flag { position: absolute; left: 87%; top: 14%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 14px; display: flex; align-items: center; justify-content: center; background: var(--amber); color: var(--ink); transform: scale(0); animation: pop .5s 3.2s cubic-bezier(.2,1.6,.4,1) forwards; }
@keyframes pop { to { transform: scale(1); } }
@keyframes bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -6px; } }

/* ---------- Lesson map ---------- */
.t-map-section { padding: 48px 0 8px; }
.t-map-title { font-size: 24px; margin: 0; }
.t-map { list-style: none; padding: 0; margin: 20px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.t-map a { position: relative; display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 18px; border-radius: 20px; background: var(--c-soft); border: 1px solid var(--c-line); text-decoration: none; color: var(--ink); transition: transform .2s ease, box-shadow .2s ease; }
.t-map a:hover { transform: translateY(-4px); box-shadow: 0 18px 30px -18px var(--c); color: var(--ink); }
.t-map b { width: 36px; height: 36px; border-radius: 12px; background: var(--c); color: var(--white); display: flex; align-items: center; justify-content: center; font-size: 16px; }
.t-map span { font-weight: 700; line-height: 1.25; }
.t-map small { color: var(--muted); font-size: 13px; }
.t-map li.is-done a::after { content: "✓"; position: absolute; top: 14px; right: 14px; width: 24px; height: 24px; border-radius: 50%; background: var(--c); color: var(--white); font-size: 13px; font-weight: 800; display: flex; align-items: center; justify-content: center; animation: pop .35s ease forwards; transform: scale(0); }

/* ---------- Layout ---------- */
.t-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 56px; align-items: start; padding-top: 48px; padding-bottom: var(--section-pad); }
.t-side { position: sticky; top: 96px; }
.t-side-card { border: 1px solid var(--line); border-radius: 24px; padding: 22px; background: var(--white); }
.t-ring { position: relative; width: 84px; height: 84px; }
.t-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.t-ring circle { fill: none; stroke-width: 5; }
.t-ring-bg { stroke: var(--soft); }
.t-ring-fg { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 119.4; stroke-dashoffset: 119.4; transition: stroke-dashoffset .6s ease; }
.t-ring span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; }
.t-side-status { margin-top: 10px; font-weight: 700; font-size: 15px; }
.t-side-list { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-direction: column; gap: 2px; }
.t-side-list a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; text-decoration: none; font-size: 14px; font-weight: 600; color: var(--muted); transition: background-color .2s ease, color .2s ease; }
.t-side-list a:hover { color: var(--ink); background: var(--c-soft); }
.t-side-list a.is-current { color: var(--ink); background: var(--c-soft); box-shadow: inset 3px 0 0 var(--c); }
.t-side-list i { flex: 0 0 auto; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--c); display: flex; align-items: center; justify-content: center; font-style: normal; font-size: 10px; color: var(--white); transition: background-color .25s ease; }
.t-side-list li.is-done i { background: var(--c); }
.t-side-list li.is-done i::before { content: "✓"; font-weight: 800; }
.t-reset { margin-top: 14px; background: none; border: 0; padding: 8px 0; min-height: 44px; color: var(--muted); font-size: 13px; text-decoration: underline; }

/* ---------- Lessons ---------- */
.lesson { margin-top: 104px; scroll-margin-top: 90px; }
.lesson:first-child { margin-top: 0; }
.lesson-head { display: flex; gap: 22px; align-items: flex-start; padding: clamp(22px, 3vw, 32px); border-radius: 28px; background: var(--c-soft); border: 1px solid var(--c-line); }
.lesson-badge { flex: 0 0 auto; width: 64px; height: 64px; border-radius: 20px; background: var(--c); color: var(--white); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 28px; box-shadow: 0 14px 28px -14px var(--c); }
.lesson.in-view .lesson-badge { animation: wiggle .8s ease; }
@keyframes wiggle { 0% { transform: rotate(0) scale(1); } 30% { transform: rotate(-8deg) scale(1.08); } 60% { transform: rotate(6deg) scale(1.04); } 100% { transform: rotate(0) scale(1); } }
.lesson-kicker { font-size: 14px; font-weight: 800; color: var(--c); text-transform: uppercase; letter-spacing: .06em; }
.lesson-head h2 { font-size: clamp(28px, 3.2vw, 40px); margin-top: 6px; }
.lesson-intro { margin-top: 12px; font-size: 18px; color: var(--muted); max-width: 720px; }
.learn-chips { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.learn-chips li { background: var(--white); border: 1px solid var(--c-line); color: var(--ink); border-radius: 999px; padding: 6px 14px; font-size: 14px; font-weight: 600; }
.learn-chips li::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-right: 8px; vertical-align: 1px; }

/* Steps timeline */
.tsteps { list-style: none; padding: 0; margin: 36px 0 0; counter-reset: tstep; position: relative; }
.tsteps::before { content: ""; position: absolute; left: 21px; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--c-line); }
.tstep { position: relative; padding: 0 0 40px 72px; counter-increment: tstep; }
.tstep::before { content: counter(tstep); position: absolute; left: 0; top: -4px; width: 44px; height: 44px; border-radius: 50%; background: var(--white); border: 3px solid var(--c); color: var(--c); font-weight: 800; font-size: 17px; display: flex; align-items: center; justify-content: center; transition: background-color .3s ease, color .3s ease; }
.tstep.is-visible::before { background: var(--c); color: var(--white); }
.tstep h3 { font-size: 22px; }
.tstep > p { margin-top: 10px; font-size: 17px; color: var(--muted); max-width: 720px; }
.tlist { margin: 12px 0 0; padding-left: 20px; color: var(--muted); font-size: 17px; display: flex; flex-direction: column; gap: 6px; }
.tlist b { color: var(--ink); }

/* Figures */
.tfig { margin: 22px 0 0; padding: clamp(18px, 3vw, 32px); border-radius: 28px; background: var(--c-soft); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 24px 36px; }
.tfig .channel-switch { flex-basis: 100%; }
.zoom { padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 24px; transition: transform .25s ease; position: relative; }
.zoom:hover { transform: scale(1.02) rotate(-.4deg); }
.zoom::after { content: ""; position: absolute; right: 10px; bottom: 26px; width: 36px; height: 36px; border-radius: 50%; background: rgba(16,35,28,.8) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6'/%3E%3Cpath d='M20 20l-4.5-4.5M11 8v6M8 11h6'/%3E%3C/svg%3E") center / 20px no-repeat; opacity: 0; transition: opacity .2s ease; }
.zoom:hover::after, .zoom:focus-visible::after { opacity: 1; }
.tfig img { width: 300px; max-width: 100%; }
.tfig-wide img { width: 680px; }
.tfig figcaption { flex: 1 1 260px; min-width: 0; max-width: 380px; }
.pin-legend { list-style: none; padding: 0; margin: 0; counter-reset: pin; display: flex; flex-direction: column; gap: 14px; }
.pin-legend li { counter-increment: pin; display: grid; grid-template-columns: 30px 1fr; column-gap: 12px; align-items: start; font-size: 16px; }
.pin-legend li::before { content: counter(pin); grid-row: span 2; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--white); font-weight: 800; font-size: 14px; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 3px var(--white); }
.pin-legend b { display: block; }
.pin-legend span { color: var(--muted); }

/* Callouts */
.callout { margin-top: 18px; border-radius: 18px; padding: 16px 20px 16px 56px; position: relative; max-width: 760px; }
.callout::before { position: absolute; left: 16px; top: 14px; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; }
.callout b { display: block; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.callout p { margin-top: 4px; font-size: 16px; }
.callout.tip { background: #FFF4E0; color: #5C3B00; }
.callout.tip::before { content: "★"; background: var(--amber); color: var(--ink); }
.callout.good { background: #E4F6EE; color: #0B4D34; }
.callout.good::before { content: "i"; background: var(--accent); color: var(--white); font-style: italic; font-family: Georgia, serif; }
.callout.warn { background: #FDE8EF; color: #7A1238; }
.callout.warn::before { content: "!"; background: #BE185D; color: var(--white); }
.callout-link { display: inline-block; margin-top: 8px; font-weight: 700; color: inherit; }

/* Formulas */
.formula-big { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 16px; padding: 14px 22px; border-radius: 999px; background: var(--white); border: 2px dashed var(--c-line); font-weight: 700; font-size: 18px; }
.formula-big i { font-style: normal; color: var(--c); font-weight: 800; }
.formula-big b { color: var(--c); }
.formula-grid { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.formula-grid p { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 18px; border-radius: 16px; background: var(--c-soft); font-size: 17px; font-weight: 600; width: fit-content; max-width: 100%; }
.formula-grid i { font-style: normal; color: var(--muted); }
.formula-grid b { color: var(--c); }

/* Flow chips */
.flow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
.flow span { background: var(--c); color: var(--white); font-weight: 700; padding: 8px 16px; border-radius: 999px; font-size: 15px; }
.flow i { font-style: normal; color: var(--muted); font-weight: 800; }

/* Lesson footer */
.lesson-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-left: 72px; padding: 18px 22px; border-radius: 20px; border: 1px dashed var(--c-line); }
.done-btn { display: inline-flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 20px 10px 12px; border-radius: 999px; border: 2px solid var(--c); background: var(--white); color: var(--c); font-weight: 700; font-size: 15px; transition: background-color .2s ease, color .2s ease, transform .15s ease; }
.done-btn:hover { transform: translateY(-1px); }
.done-check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid currentColor; display: flex; align-items: center; justify-content: center; }
.done-btn[aria-pressed="true"] { background: var(--c); color: var(--white); }
.done-btn[aria-pressed="true"] .done-check::before { content: "✓"; font-weight: 800; font-size: 14px; animation: pop .3s ease forwards; transform: scale(0); display: inline-block; }
.next-link { font-weight: 700; text-decoration: none; color: var(--c); }
.next-link:hover { color: var(--ink); }

/* Finish banner */
.t-finish { margin-top: 72px; padding: 36px; border-radius: 28px; text-align: center; background: linear-gradient(135deg, #0F7B53, #6D28D9 40%, #BE185D 70%, #A16207); color: var(--white); position: relative; overflow: hidden; }
.t-finish h2 { margin: 8px auto 0; font-size: clamp(28px, 3vw, 38px); }
.t-finish p { margin-top: 10px; font-size: 18px; color: rgba(255,255,255,.92); }
.t-finish-emoji { display: inline-flex; width: 72px; height: 72px; border-radius: 50%; align-items: center; justify-content: center; background: rgba(255,255,255,.18); animation: wiggle 1s ease 2; }

/* Glossary flip cards */
.gloss-grid { margin-top: 28px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.gloss { position: relative; min-height: 170px; border: 0; padding: 0; background: none; text-align: left; perspective: 900px; color: var(--ink); }
.gloss > span { position: absolute; inset: 0; border-radius: 20px; padding: 18px; backface-visibility: hidden; -webkit-backface-visibility: hidden; transition: transform .5s cubic-bezier(.4,.2,.2,1); display: flex; flex-direction: column; gap: 8px; }
.gloss-front { background: var(--white); border: 1px solid var(--line); box-shadow: 0 14px 30px -24px rgba(16,35,28,.5); }
.gloss-front b { font-size: 19px; }
.gloss-front span { color: var(--muted); font-size: 15px; }
.gloss-front::after { content: "↻"; position: absolute; right: 14px; bottom: 10px; color: var(--muted); font-size: 18px; }
.gloss-back { background: var(--ink); color: var(--white); transform: rotateY(180deg); justify-content: center; font-weight: 700; font-size: 17px; }
.gloss[aria-pressed="true"] .gloss-front { transform: rotateY(-180deg); }
.gloss[aria-pressed="true"] .gloss-back { transform: rotateY(0); }
.gloss:nth-child(5n+1) .gloss-back { background: #0F7B53; }
.gloss:nth-child(5n+2) .gloss-back { background: #6D28D9; }
.gloss:nth-child(5n+3) .gloss-back { background: #C2410C; }
.gloss:nth-child(5n+4) .gloss-back { background: #BE185D; }
.gloss:nth-child(5n+5) .gloss-back { background: #1D4ED8; }

/* Help */
.help-list { margin-top: 24px; }
.help-list details { border: 1px solid var(--line); border-radius: 18px; margin-top: 10px; padding: 0 20px; background: var(--white); transition: box-shadow .2s ease; }
.help-list details[open] { box-shadow: 0 16px 34px -26px rgba(16,35,28,.5); }
.help-list summary { list-style: none; cursor: pointer; padding: 18px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; font-weight: 700; font-size: 17px; }
.help-list summary::-webkit-details-marker { display: none; }
.help-list summary::after { content: "+"; font-size: 24px; line-height: 1; color: var(--muted); transition: transform .2s ease; }
.help-list details[open] summary::after { transform: rotate(45deg); }
.help-list p { padding-bottom: 18px; color: var(--muted); font-size: 16px; }

/* CTA */
.t-cta { margin-top: 104px; padding: clamp(36px, 5vw, 64px); border-radius: 32px; background: var(--dark); color: var(--white); position: relative; overflow: hidden; }
.t-cta::before, .t-cta::after { content: ""; position: absolute; border-radius: 50%; opacity: .9; }
.t-cta::before { width: 160px; height: 160px; right: -40px; top: -50px; background: #BE185D; }
.t-cta::after { width: 110px; height: 110px; right: 90px; bottom: -60px; background: var(--amber); }
.t-cta h2 { margin: 0; position: relative; }
.t-cta p { margin-top: 12px; font-size: 18px; color: var(--on-dark-muted); position: relative; max-width: 560px; }
.t-cta .btn-row { margin-top: 26px; position: relative; }

/* Lightbox */
.lightbox { border: 0; padding: 0; background: transparent; max-width: min(96vw, 1100px); max-height: 92vh; overflow: visible; }
.lightbox::backdrop { background: rgba(14,31,25,.82); backdrop-filter: blur(4px); }
.lightbox img { max-width: min(96vw, 1100px); max-height: 88vh; width: auto; height: auto; animation: zoomIn .25s ease; }
.lightbox-close { position: absolute; top: -8px; right: -8px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--white); color: var(--ink); display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 20px rgba(0,0,0,.3); z-index: 2; }
@keyframes zoomIn { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }

/* Confetti when every lesson is done */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate3d(var(--dx), 110vh, 0) rotate(var(--r)); } }

/* Stagger the reveal of steps */
.js .tstep.reveal { transition-delay: .05s; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .t-layout { grid-template-columns: 1fr; gap: 32px; }
  .t-side { position: static; }
  .t-side-card { display: grid; grid-template-columns: auto 1fr; gap: 0 16px; align-items: center; }
  .t-side-list { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .t-side-list a { border: 1px solid var(--line); }
  .t-reset { grid-column: 1 / -1; justify-self: start; }
}
@media (max-width: 640px) {
  .t-hero-art { max-width: 300px; }
  .t-node, .t-flag { width: 36px; height: 36px; margin: -18px 0 0 -18px; font-size: 15px; }
  .lesson-head { flex-direction: column; gap: 14px; }
  .lesson-badge { width: 52px; height: 52px; font-size: 22px; border-radius: 16px; }
  .tsteps::before { left: 17px; }
  .tstep { padding-left: 52px; }
  .tstep::before { width: 36px; height: 36px; font-size: 15px; }
  .tfig { padding: 16px 10px; }
  .tfig img { width: 100%; max-width: 280px; }
  .tfig-wide img { max-width: 100%; }
  .lesson-foot { margin-left: 0; }
  .formula-big { border-radius: 18px; font-size: 16px; }
  .zoom::after { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .t-path-line { stroke-dashoffset: 0; }
  .t-node, .t-flag { transform: none; }
  .t-map li.is-done a::after, .done-btn[aria-pressed="true"] .done-check::before { transform: none; }
  .gloss > span { transition: none; }
}
