/* Quillnest public pages: transitions and motion, kept apart from the layout in site.css.
   Content is visible by default. site.js adds .lp-js only when it can reveal things, and none of the
   hidden starting states below apply under reduced motion. Easing is the app's exponential ease-out. */

/* hover and focus: short, on everything you can press, as in the app */
.lp .btn, .lp-nav a, .lp-foot a, .lp-faq summary, .lp-rows li, .lp-plans tbody tr {
  transition: background-color .12s var(--ease), border-color .12s var(--ease), color .12s var(--ease),
              transform .18s var(--ease), box-shadow .18s var(--ease);
}
.lp .btn.primary:hover { transform: translateY(-2px); box-shadow: 0 8px 18px -8px rgb(242 176 30 / .7); }
.lp .btn:not(.primary):hover { transform: translateY(-2px); }
.lp .btn:active { transform: translateY(0); box-shadow: none; }
.lp-link { background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 2px no-repeat; text-decoration: none; padding-bottom: 3px; border-bottom: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); transition: background-size .3s var(--ease); }
.lp-link:hover, .lp-link:focus-visible { background-size: 100% 2px; }
.lp-rows li:hover, .lp-plans tbody tr:hover { background: var(--brand-soft); }
.lp-faq summary:hover { color: var(--accent-text); }
.lp-faq summary::after { transition: transform .25s var(--ease); }
.lp-faq details[open] summary::after { transform: rotate(180deg); }

/* the install button reads as a footer link, not a button */
.lp-install { background: none; border: 0; padding: 0; font: inherit; color: #c3cad0; text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 4px; cursor: pointer; box-shadow: none; }
.lp-install:hover { color: #fff; box-shadow: none; border: 0; }
.lp-install[hidden] { display: none; }

/* the header gains an edge once the page has moved under it */
.lp-head { transition: box-shadow .2s var(--ease); }
.lp-head.is-stuck { box-shadow: 0 10px 24px -14px rgb(0 0 0 / .6); }

/* FAQ answers open smoothly where the browser can animate to auto height */
@supports (interpolate-size: allow-keywords) {
  :root { interpolate-size: allow-keywords; }
  .lp-faq details::details-content { block-size: 0; overflow: clip; transition: block-size .3s var(--ease), content-visibility .3s allow-discrete; }
  .lp-faq details[open]::details-content { block-size: auto; }
}

/* moving between public pages cross-fades the page and leaves the header where it is */
@view-transition { navigation: auto; }
.lp-head { view-transition-name: lp-head; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .25s; }

@media (prefers-reduced-motion: no-preference) {
  /* the first screen settles in once: headline, sentence, buttons, then the sheet and its rows */
  .lp-hero-copy > * { animation: lp-rise .8s var(--ease) both; }
  .lp-hero-copy > :nth-child(2) { animation-delay: .1s; }
  .lp-hero-copy > :nth-child(3) { animation-delay: .2s; }
  .lp-hero-copy > :nth-child(4) { animation-delay: .3s; }
  .lp-hero .lp-sheet { animation: lp-sheet .9s var(--ease) .15s both; }
  .lp-hero .lp-rows li { animation: lp-slide .6s var(--ease) both; }
  .lp-hero .lp-rows li:nth-child(1) { animation-delay: .45s; }
  .lp-hero .lp-rows li:nth-child(2) { animation-delay: .53s; }
  .lp-hero .lp-rows li:nth-child(3) { animation-delay: .61s; }
  .lp-hero .lp-rows li:nth-child(4) { animation-delay: .69s; }
  .lp-hero .lp-rows li:nth-child(5) { animation-delay: .77s; }
  .lp-hero .lp-rows li .press i.on { animation: lp-ink .5s var(--ease) both; animation-delay: calc(.6s + var(--n, 0) * .08s); }
  .lp-pagehead .lp-wrap > * { animation: lp-rise .8s var(--ease) both; }
  .lp-pagehead .lp-wrap > :nth-child(2) { animation-delay: .1s; }

  /* scroll reveals. Each kind moves differently, so the page doesn't repeat one entrance. */
  .lp-js [data-r] { opacity: 0; transition: opacity .7s var(--ease) var(--d, 0s), transform .8s var(--ease) var(--d, 0s), clip-path .8s var(--ease) var(--d, 0s); }
  .lp-js [data-r].is-in { opacity: 1; transform: none; clip-path: none; }
  .lp-js [data-r="rise"] { transform: translateY(26px); }
  .lp-js [data-r="slide"] { transform: translateX(32px); }
  .lp-js [data-r="slide-l"] { transform: translateX(-32px); }
  .lp-js [data-r="fade"] { transition-duration: .6s; }

  /* the four inks print across the page, left to right, then their words arrive */
  .lp-js [data-r="ink"] { opacity: 1; clip-path: inset(0 100% 0 0); transition: clip-path .7s var(--ease) var(--d, 0s); }
  .lp-js [data-r="ink"].is-in { clip-path: inset(0); }
  .lp-js [data-r="ink"] > * { opacity: 0; transform: translateY(10px); transition: opacity .5s var(--ease) calc(var(--d, 0s) + .35s), transform .5s var(--ease) calc(var(--d, 0s) + .35s); }
  .lp-js [data-r="ink"].is-in > * { opacity: 1; transform: none; }

  /* a ruled definition draws its line, then its words follow */
  .lp-js [data-r="rule"] { opacity: 1; position: relative; border-top-color: transparent; }
  .lp-js [data-r="rule"]::before { content: ""; position: absolute; inset: -2px 0 auto; height: 2px; background: var(--ink); transform: scaleX(0); transform-origin: left; transition: transform .8s var(--ease) var(--d, 0s); }
  .lp-js [data-r="rule"].is-in::before { transform: scaleX(1); }
  .lp-js [data-r="rule"] > * { opacity: 0; transform: translateY(14px); transition: opacity .6s var(--ease) calc(var(--d, 0s) + .25s), transform .6s var(--ease) calc(var(--d, 0s) + .25s); }
  .lp-js [data-r="rule"].is-in > * { opacity: 1; transform: none; }

  /* the point of the wall: the client's version of the name is underlined once it arrives */
  .lp-view:nth-child(2) .lp-msg b { background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 3px no-repeat; width: fit-content; padding-bottom: 2px; }
  .lp-js .lp-view:nth-child(2).is-in .lp-msg b { background-size: 100% 3px; transition: background-size .7s var(--ease) calc(var(--d, 0s) + .5s); }

  /* hover on the four inks: the one you point at takes more of the band */
  @media (hover: hover) and (min-width: 901px) {
    .lp-inks { transition: grid-template-columns .5s var(--ease); }
    .lp-inks:has(.lp-ink-you:hover) { grid-template-columns: 1.5fr 1fr 1fr 1fr; }
    .lp-inks:has(.lp-ink-them:hover) { grid-template-columns: 1fr 1.5fr 1fr 1fr; }
    .lp-inks:has(.lp-ink-date:hover) { grid-template-columns: 1fr 1fr 1.5fr 1fr; }
    .lp-inks:has(.lp-ink-done:hover) { grid-template-columns: 1fr 1fr 1fr 1.5fr; }
  }
}
@keyframes lp-rise { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }
@keyframes lp-slide { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes lp-sheet { from { opacity: 0; transform: translateY(28px) rotate(.6deg); } to { opacity: 1; transform: none; } }
@keyframes lp-ink { from { transform: scaleY(0); transform-origin: bottom; } to { transform: scaleY(1); transform-origin: bottom; } }

/* ── main only: the story home page. Same rules as above: nothing is hidden unless site.js has run (.lp-js)
   and the visitor has not asked for less motion. ── */
@media (prefers-reduced-motion: no-preference) {
  html:has(.st-story) { scroll-behavior: smooth; }
  /* pieces waiting to slide in sit just off the edge: clip them so a phone never scrolls sideways
     (clip, not hidden, so the sticky chapter rail keeps working) */
  .lp main { overflow-x: clip; }

  /* the logo in the header draws itself on hover, as it does on the sign-in page (keyframes from app.css) */
  .lp-brand .qn-logo { overflow: visible; }
  .lp-brand:hover .qn-ring, .lp-brand:focus-visible .qn-ring { animation: qn-draw .7s var(--ease) both; }
  .lp-brand:hover .qn-feather, .lp-brand:focus-visible .qn-feather { animation: qn-quill .95s var(--ease) .12s both; }
  .st-progress i { transition: width .12s linear; }
  .st-chapters a span { transition: background-color .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease); }

  /* the hook: the scraps land on the desk one after another */
  .st-scrap { animation: st-drop .7s var(--ease) both; }
  .st-scrap:nth-child(1) { animation-delay: .25s; }
  .st-scrap:nth-child(2) { animation-delay: .35s; }
  .st-scrap:nth-child(3) { animation-delay: .45s; }
  .st-scrap:nth-child(4) { animation-delay: .55s; }
  .st-scrap:nth-child(5) { animation-delay: .65s; }

  /* a chapter's fragment plays its moment once it is on screen: messages arrive, ticks land, the name is typed */
  .lp-js .st-fig[data-r] :is(.st-chat li, .st-files li, .st-bell li, .st-approve li, .st-done li, .st-sign-done, .st-approve-by, .st-fake-btn) {
    opacity: 0; transform: translateY(10px); transition: opacity .5s var(--ease) var(--sd, .35s), transform .5s var(--ease) var(--sd, .35s); }
  .lp-js .st-fig.is-in :is(.st-chat li, .st-files li, .st-bell li, .st-approve li, .st-done li, .st-sign-done, .st-approve-by, .st-fake-btn) { opacity: 1; transform: none; }
  .lp-js .st-fig[data-r] li:nth-child(2) { --sd: .7s; }
  .lp-js .st-fig[data-r] li:nth-child(3) { --sd: 1.05s; }
  .lp-js .st-fig[data-r] li:nth-child(4) { --sd: 1.3s; }
  .lp-js .st-fig[data-r] :is(.st-sign-done, .st-approve-by) { --sd: 1.4s; }
  .lp-js .st-fig[data-r] .st-fake-btn { --sd: .6s; }
  .lp-js .st-fig[data-r] .st-sign-name span { clip-path: inset(0 100% 0 0); transition: clip-path 1s steps(12, end) .5s; }
  .lp-js .st-fig.is-in .st-sign-name span { clip-path: inset(0 -4px 0 0); }
  .lp-js .st-fig[data-r] .st-meter i { transform: scaleX(0); transition: transform 1.2s var(--ease) .5s; }
  .lp-js .st-fig.is-in .st-meter i { transform: none; }
  .lp-js .st-fig[data-r] .st-badge { opacity: 0; transition: opacity .4s var(--ease) 1.5s; }
  .lp-js .st-fig.is-in .st-badge { opacity: 1; }
}
@keyframes st-drop { from { opacity: 0; translate: 0 -18px; } to { opacity: 1; translate: 0 0; } }
