/* Motion (11/26). Each idea is switched on by a class on <html> (set in base.njk), so any one can be dropped without touching the others.
   m-reveal: headings, text and photos glide in.   m-hover: buttons, links and cards respond.   m-pin: the "Where I start" section holds still while its points tick in.
   m-layer: dark bands slide over the section before them.   m-depth: photos and the home devices drift a little while scrolling.
   Everything is off for "reduce motion" (the classes are never added), and nothing here hides content when JavaScript is off. */

:root { --m-ease: cubic-bezier(.16, 1, .3, 1); }

/* ---------- 1. Reveal ---------- */
.m-up { opacity: 0; transform: translateY(26px); transition: opacity .9s ease var(--m-d, 0s), transform 1.1s var(--m-ease) var(--m-d, 0s); }
.m-up.in { opacity: 1; transform: none; }
.m-hh { opacity: 0; }

/* Headings: each line rises from behind an invisible edge. Words are wrapped by the script and unwrapped when it's done. */
.m-w { display: inline-block; vertical-align: top; overflow: hidden; padding: .1em .12em .2em; margin: -.1em -.12em -.2em; }
.m-w > span { display: inline-block; transform: translateY(118%); transition: transform 1.15s var(--m-ease) calc(var(--m-d, 0s) + var(--m-l, 0) * .09s); }
.in > .m-w > span, .in .m-w > span { transform: none; }

/* Photos: uncover from the top while the picture settles back. */
/* (The clip is on the picture, not its frame: a fully clipped frame can't be seen by the scroll watcher.) */
.m-img img { clip-path: inset(0 0 100% 0); scale: 1.16; transition: clip-path 1.3s var(--m-ease) var(--m-d, 0s), scale 1.7s var(--m-ease) var(--m-d, 0s); }
.m-img.in img { clip-path: inset(0 0 0 0); scale: var(--m-s, 1); }

/* Home page top: nothing is hidden (so the first paint is as fast as before). The wall settles back a touch, and the laptop and phone glide up in front of it. Plain CSS, no script. */
.m-reveal .home-hero .dv-wall img { animation: m-settle 2s var(--m-ease) both; }
.m-reveal .home-hero .dv-laptop { animation: m-rise 1.3s var(--m-ease) .12s both; }
.m-reveal .home-hero .dv-phone { animation: m-rise 1.4s var(--m-ease) .3s both; --m-y: 64px; }
@keyframes m-settle { from { transform: scale(1.09); } }
@keyframes m-rise { from { opacity: 0; transform: translateY(var(--m-y, 40px)); } }

/* Pages fade into each other instead of blinking (browsers that don't support it just load normally). */
@media (prefers-reduced-motion: no-preference) { @view-transition { navigation: auto; } }

/* ---------- 2. Hovers ---------- */
.m-hover .btn { background-image: linear-gradient(rgba(255, 255, 255, .13), rgba(255, 255, 255, .13)); background-repeat: no-repeat; background-size: 0% 100%; transition: background-size .5s var(--m-ease), transform .3s var(--m-ease), box-shadow .3s ease; }
.m-hover .cta .btn { background-image: linear-gradient(rgba(255, 255, 255, .22), rgba(255, 255, 255, .22)); }
.m-hover .btn:active { transform: scale(.98); }
.m-hover .site-header .nav a { padding-bottom: 3px; background: linear-gradient(var(--accent), var(--accent)) no-repeat 0 100% / 0% 2px; transition: background-size .4s var(--m-ease); }
.m-hover .site-header .nav a.on { background: none; }
.m-hover .pf-card, .m-hover .post-card { transition: box-shadow .5s ease, transform .5s var(--m-ease); }
.m-hover .pf-photo img, .m-hover .post-photo:not(.framed) img { transition: transform 1.4s var(--m-ease); }
.m-hover .pf-more span, .m-hover .post-more span { display: inline-block; transition: transform .4s var(--m-ease); }
.m-hover .home-svc .plan .more::after { display: inline-block; white-space: pre; transition: transform .4s var(--m-ease); }
.m-hover .jcard .go { transition: transform .4s var(--m-ease), opacity .15s; }
.m-hover .hi-link a, .m-hover .ci-call a, .m-hover a.consult { transition: color .25s ease, box-shadow .25s ease; }
.m-hover .foot-col a, .m-hover .foot-bottom a { background: linear-gradient(currentColor, currentColor) no-repeat 0 100% / 0% 1px; transition: background-size .35s var(--m-ease), color .2s; }
.m-hover .pf-card:active, .m-hover .post-card:active, .m-hover .home-svc a.plan:active, .m-hover .jcard:active { transform: scale(.99); }
@media (hover: hover) {
  .m-hover .btn:hover { background-size: 100% 100%; transform: translateY(-2px); box-shadow: 0 14px 26px -14px rgba(30, 51, 41, .6); }
  .m-hover .btn:active { transform: translateY(0) scale(.98); }
  .m-hover .site-header .nav a:not(.on):hover { background-size: 100% 2px; }
  .m-hover .pf-card:hover, .m-hover .post-card:hover { transform: translateY(-5px); box-shadow: 0 1px 0 var(--line), 0 30px 54px -18px rgba(30, 25, 15, .22); }
  .m-hover .pf-open:hover .pf-photo img, .m-hover .post-open:hover .post-photo:not(.framed) img { transform: scale(1.06); }
  .m-hover .pf-open:hover .pf-more, .m-hover .post-open:hover .post-more { text-decoration: none; }
  .m-hover .pf-open:hover .pf-more span, .m-hover .post-open:hover .post-more span { transform: translateX(6px); }
  .m-hover .home-svc a.plan:hover { transform: translateY(-5px); }
  .m-hover .home-svc a.plan:hover .more::after { transform: translateX(6px); }
  .m-hover .jcard:hover .go { transform: translateY(4px); }
  .m-hover .hi-link a:hover { color: var(--accent-ink); }
  .m-hover .foot-col a:hover, .m-hover .foot-bottom a:hover { text-decoration: none; background-size: 100% 1px; }
}
@media (prefers-reduced-motion: reduce) {
  .m-hover .btn, .m-hover .pf-card, .m-hover .post-card, .m-hover .pf-photo img, .m-hover .post-photo img, .m-hover .site-header .nav a { transition: none; }
  .m-hover .btn:hover, .m-hover .pf-card:hover, .m-hover .post-card:hover, .m-hover .home-svc a.plan:hover, .m-hover .pf-open:hover .pf-photo img { transform: none; }
}

/* ---------- 3. Pinned "Where I start" (services) ---------- */
.m-pin-on { padding: 0 !important; height: calc(100vh + 140vh); }
.m-pin-on > .wrap { position: sticky; top: 0; height: 100vh; align-content: center; }
.m-tick .tiles li { transition: opacity .5s ease; }
.m-tick .tiles li::before { transition: transform .6s var(--m-ease), opacity .3s ease; }
.m-tick .tiles li::after { content: ""; position: absolute; left: 0; top: 26px; width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .34); transition: opacity .3s ease; opacity: 0; }
.m-tick .tiles li:not(.on) { opacity: .34; }
.m-tick .tiles li:not(.on)::before { transform: scale(.3); opacity: 0; }
.m-tick .tiles li:not(.on)::after { opacity: 1; }
.m-tick .closing { transition: opacity .8s ease, transform 1s var(--m-ease); }
.m-tick .closing:not(.on) { opacity: 0; transform: translateY(18px); }
@media (max-width: 760px) { .m-tick .tiles li::after { top: 21px; width: 20px; height: 20px; } }

/* ---------- 4. Layers: a dark band slides up over the section before it ---------- */
.m-stack > :first-child { position: sticky; top: min(0px, calc(100lvh - var(--m-h, 0px))); }
.m-stack > :last-child { position: relative; z-index: 1; border-radius: 28px 28px 0 0; box-shadow: 0 -24px 60px -30px rgba(20, 30, 24, .45); }
@media (max-width: 760px) { .m-stack > :last-child { border-radius: 20px 20px 0 0; } }

/* ---------- 5. Depth ---------- */
.m-par { will-change: translate; }
.m-depth { --m-s: 1.1; }
.m-par-img { scale: 1.1; will-change: translate; }

/* 6. Grow: the business tree on phones (Mali 11/26). The dot sits on each card's heading; the short line hangs below each card. */
@media (max-width: 900px) {
  .tree .branches { gap: 22px; }
  .tree .branch::before { display: none; }
  .tree .branch::after { display: block; left: 50%; top: 100%; width: 1.5px; height: 22px; margin-left: -.75px; border-radius: 0; background: var(--ink); opacity: .4; box-shadow: none; }
  .tree .branch:last-child::after { display: none; }
  .tree .branch h3::before { content: ""; position: absolute; left: 50%; top: -5px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--bg); }
  .tree .branch.main h3::before { background: var(--accent); }
  .tree .branch li.hl { margin: -2px -8px; padding: 2px 8px 2px 24px; border-radius: 4px; background: linear-gradient(rgba(238, 133, 36, .16), rgba(238, 133, 36, .16)) left / 100% 100% no-repeat; }
  .tree .branch li.hl::before { left: 8px; top: calc(.5em + 2px); }  /* Mali 11/26: dot centered on the words (the pill adds 2px on top) */
  /* Play-once version (phones without scroll-linked animations) */
  .m-grow .stem, .m-grow .branch::after { transform: scaleY(0); transform-origin: top; transition: transform .5s cubic-bezier(.4, 0, .2, 1) .9s; }
  .m-grow .stem { transition-delay: 0s; }
  .m-grow .branch h3::before { transform: scale(0); transition: transform .45s cubic-bezier(.3, 1.5, .5, 1) .4s; }
  .m-grow .branch { opacity: 0; translate: 0 18px; transition: opacity .8s ease .2s, translate 1s var(--m-ease, ease) .2s; }
  .m-grow .branch li.hl { background-size: 0% 100%; transition: background-size .9s cubic-bezier(.4, 0, .2, 1) .9s; }
  .m-grow .g-on.stem, .m-grow .g-on.branch::after, .m-grow .g-on.branch h3::before { transform: none; }
  .m-grow .g-on.branch { opacity: 1; translate: none; }
  .m-grow .g-on.branch li.hl { background-size: 100% 100%; }
}

/* ---------- 7. Phones: animations follow the scroll (Mali 11/26: "controlled on how far down you're going") ----------
   Only where the browser supports scroll-linked animations (the script adds .m-sl). Scroll back up and they rewind.
   Mali 11/26: they play in the lower-middle of the screen, not at the very bottom: every timeline counts from 32% above the bottom edge.
   Mali 11/26 later: "still feels too subtle", so things travel farther (cards 100px, blocks 72px) over a longer stretch of scrolling. */
@supports (animation-timeline: view()) {
  .m-sl .sl-up { animation: sl-up linear both; animation-timeline: view(block 0 32%); animation-range: entry 0% entry 380px; }
  .m-sl .sl-img img { animation: sl-img linear both; animation-timeline: view(block 0 32%); animation-range: entry 0% entry 440px; }
  /* Mali 11/26: no fading on phones. Everything is always there and just slides up into place. */
  @keyframes sl-up { from { transform: translateY(72px); } to { transform: none; } }
  @keyframes sl-img { from { scale: 1.16; translate: 0 50px; } to { scale: var(--m-s, 1); translate: none; } }

  /* "Where I start": each point's orange check fills in as it scrolls up the screen */
  .m-slt .m-tick .tiles li { view-timeline-name: --tk; view-timeline-inset: 0 32%; opacity: 1; }  /* the words stay fully visible; only the orange check fills in */
  .m-slt .m-tick .tiles li::before { animation: sl-pop linear both; animation-timeline: --tk; animation-range: entry 80% cover 42%; }
  .m-slt .m-tick .tiles li::after { animation: sl-ring linear both; animation-timeline: --tk; animation-range: entry 80% cover 42%; }
  .m-slt .m-tick .closing { opacity: 1; transform: none; animation: sl-up linear both; animation-timeline: view(block 0 32%); animation-range: entry 0% entry 380px; }
  @keyframes sl-pop { from { transform: scale(.3); opacity: 0; } to { transform: none; opacity: 1; } }
  @keyframes sl-ring { from { opacity: 1; } to { opacity: 0; } }

  /* The business tree (Mali 11/26). Tied to the scroll, so it rewinds going up, and it all happens as things come up from the
     bottom of the screen (nothing is cut off or uncovered mid-screen, nothing fades):
     1. the line comes down from "Your business" and the first card pops up into place;
     2. "Your website" pops out first, then logo, email and business cards pop out one by one from their dots;
     3. then a line leads down to the next card, which pops into place, and so on.
     Each card names its own timeline (--b1 to --b6); timeline-scope lets the line above a card follow that card. */
  .m-grow-sl { timeline-scope: --b1, --b2, --b3, --b4, --b5, --b6; }
  .m-grow-sl .branch:nth-child(1) { view-timeline-name: --b1; view-timeline-inset: 0 32%; }
  .m-grow-sl .branch:nth-child(2) { view-timeline-name: --b2; view-timeline-inset: 0 32%; }
  .m-grow-sl .branch:nth-child(3) { view-timeline-name: --b3; view-timeline-inset: 0 32%; }
  .m-grow-sl .branch:nth-child(4) { view-timeline-name: --b4; view-timeline-inset: 0 32%; }
  .m-grow-sl .branch:nth-child(5) { view-timeline-name: --b5; view-timeline-inset: 0 32%; }
  .m-grow-sl .branch:nth-child(6) { view-timeline-name: --b6; view-timeline-inset: 0 32%; }
  .m-grow-sl .stem, .m-grow-sl .branch::after { transform-origin: top; animation: sl-draw linear both; animation-range: entry 0px entry 110px; }
  .m-grow-sl .stem { animation-timeline: --b1; }
  .m-grow-sl .branch:nth-child(1)::after { animation-timeline: --b2; }
  .m-grow-sl .branch:nth-child(2)::after { animation-timeline: --b3; }
  .m-grow-sl .branch:nth-child(3)::after { animation-timeline: --b4; }
  .m-grow-sl .branch:nth-child(4)::after { animation-timeline: --b5; }
  .m-grow-sl .branch:nth-child(5)::after { animation-timeline: --b6; }
  .m-grow-sl .branch { animation: sl-pop-card linear both; animation-range: entry 60px entry 260px; }
  .m-grow-sl .branch:nth-child(1) { animation-timeline: --b1; }
  .m-grow-sl .branch:nth-child(2) { animation-timeline: --b2; }
  .m-grow-sl .branch:nth-child(3) { animation-timeline: --b3; }
  .m-grow-sl .branch:nth-child(4) { animation-timeline: --b4; }
  .m-grow-sl .branch:nth-child(5) { animation-timeline: --b5; }
  .m-grow-sl .branch:nth-child(6) { animation-timeline: --b6; }
  .m-grow-sl .branch h3::before { animation: sl-dot linear both; animation-range: entry 120px entry 220px; }
  .m-grow-sl .branch:nth-child(1) h3::before { animation-timeline: --b1; }
  .m-grow-sl .branch:nth-child(2) h3::before { animation-timeline: --b2; }
  .m-grow-sl .branch:nth-child(3) h3::before { animation-timeline: --b3; }
  .m-grow-sl .branch:nth-child(4) h3::before { animation-timeline: --b4; }
  .m-grow-sl .branch:nth-child(5) h3::before { animation-timeline: --b5; }
  .m-grow-sl .branch:nth-child(6) h3::before { animation-timeline: --b6; }
  .m-grow-sl .branch:nth-child(1) li { transform-origin: 0 50%; animation: sl-item linear both; animation-timeline: --b1; }
  .m-grow-sl .branch:nth-child(1) li.hl { animation: sl-item linear both, sl-mark linear both; animation-timeline: --b1, --b1; animation-range: entry 140px entry 220px, entry 200px entry 290px; }
  .m-grow-sl .branch:nth-child(1) li:nth-child(2) { animation-range: entry 220px entry 270px; }
  .m-grow-sl .branch:nth-child(1) li:nth-child(3) { animation-range: entry 250px entry 300px; }
  .m-grow-sl .branch:nth-child(1) li:nth-child(4) { animation-range: entry 280px entry 330px; }
  @keyframes sl-draw { from { transform: scaleY(0); } to { transform: none; } }
  @keyframes sl-pop-card { from { translate: 0 100px; scale: .9; } 70% { translate: 0 -8px; scale: 1.02; } to { translate: none; scale: none; } }
  @keyframes sl-item { from { scale: 0; } 70% { scale: 1.12; } to { scale: none; } }
  @keyframes sl-dot { from { transform: scale(0); } 70% { transform: scale(1.3); } to { transform: none; } }
  @keyframes sl-mark { from { background-size: 0% 100%; } to { background-size: 100% 100%; } }
}
@media print { .sl-up, .sl-img img, .m-grow-sl *, .m-up, .m-hh, .m-img img, .m-w > span { opacity: 1 !important; transform: none !important; clip-path: none !important; } }
