/* doc-motion.css: two paper cards that tell the product story. A document is checked
 * line by line and flagged, then a reply draft writes itself and is marked ready.
 *
 * Plain CSS, no runtime: it mirrors the homepage Rive hero (same sizes, colours and
 * 11 s timeline as scripts/rivekit/src/recipes/doc-hero.js) but takes its texts per
 * page and also runs on phones. doc-motion.js builds the markup inside every
 * [data-doc-motion] placeholder. The texts sit in data-t attributes and are drawn with
 * CSS content, so the fictional amounts never count as page text.
 *
 * Layouts (classes on the placeholder):
 *   dm--pair      both cards side by side, scaled to the box (aspect ratio reserved)
 *   dm--strip     a pair in the page flow, with a "Fiktivt eksempel" caption
 *   dm--hero-col  a pair above the panel in the right column of a two-column hero
 *   dm--corner    a pair in the top right corner of a one-column hero
 *   dm--gutter    one card in each side gutter of a narrow article, like the homepage
 * Without motion (prefers-reduced-motion) the cards show their finished state. */
.dm {
  --dm-ink: #10221c; --dm-muted: #52645d; --dm-line: #dce5e0; --dm-ok: #19a875; --dm-mint: #9be8c9;
  --dm-soft: #e9f3ee; --dm-amber: #f2b84b; --dm-caution: #725021; --dm-caution-soft: #fbf4e6;
  --dm-out: cubic-bezier(.16, 1, .3, 1);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; font-weight: 500; line-height: 1; letter-spacing: 0; text-align: left; text-transform: none;
  color: var(--dm-ink); pointer-events: none; -webkit-user-select: none; user-select: none;
}
.dm *, .dm *::before, .dm *::after { box-sizing: border-box; margin: 0; padding: 0; }
.dm [data-t]::before { content: attr(data-t); }
.dm i, .dm b { font-style: normal; font-weight: inherit; }

/* ---------- the two cards (natural size; the stage is scaled as a whole) ---------- */
.dm-stage { position: absolute; left: 0; top: 0; width: 540px; height: 390px; transform-origin: 0 0; }
.dm-item { position: absolute; width: 250px; height: 300px; translate: calc(var(--dm-px, 0) * 9px) calc(var(--dm-py, 0) * 6px); transition: translate .9s var(--dm-out); }
.dm-doc { left: 6px; top: 52px; z-index: 2; }
.dm-draft { left: 276px; top: 74px; width: 260px; height: 290px; z-index: 1; }
.dm-float { position: absolute; inset: 0; }
/* soft mint light behind the cards. A pair keeps it inside the stage box (so it can never
 * widen the page) and fades it out toward the sides; the gutter cards carry their own. */
.dm-glows { position: absolute; left: 0; right: 0; top: -50px; bottom: -50px; overflow: hidden; -webkit-mask-image: linear-gradient(to right, transparent, #000 70px, #000 calc(100% - 70px), transparent); mask-image: linear-gradient(to right, transparent, #000 70px, #000 calc(100% - 70px), transparent); }
.dm-glows i, .dm-glow { position: absolute; width: 420px; height: 380px; border-radius: 50%; background: radial-gradient(closest-side, rgba(155, 232, 201, .34), rgba(155, 232, 201, 0)); }
.dm-glows i:nth-child(1) { left: -79px; top: 72px; }
.dm-glows i:nth-child(2) { left: 196px; top: 86px; }
.dm-glow { display: none; left: 50%; top: 50%; translate: -50% -46%; }
.dm-paper { position: absolute; inset: 0; background: #fff; border: 1px solid var(--dm-line); border-radius: 14px; box-shadow: 0 16px 26px rgba(16, 34, 28, .14); transition: transform .7s var(--dm-out), box-shadow .7s var(--dm-out); pointer-events: auto; }
.dm-doc .dm-paper { transform: rotate(-2deg); }
.dm-draft .dm-paper { transform: rotate(1.7deg); }
@media (hover: hover) {
  .dm-paper:hover { transform: translateY(-10px) scale(1.025) rotate(0deg); box-shadow: 0 28px 40px rgba(16, 34, 28, .17); transition-duration: .5s; }
}
.dm-clip { position: absolute; inset: 0; overflow: hidden; border-radius: 13px; }

/* the document */
.dm-title { position: absolute; left: 22px; right: 16px; top: 29px; overflow: hidden; white-space: nowrap; font-size: 10.5px; font-weight: 700; letter-spacing: 1.1px; color: var(--dm-muted); }
.dm-rule { position: absolute; left: 22px; right: 22px; height: 1px; background: var(--dm-line); }
.dm-rule.r1 { top: 56px; }
.dm-rule.r2 { top: 198px; }
.dm-row { position: absolute; left: 12px; right: 12px; height: 30px; padding: 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; white-space: nowrap; }
.dm-row.n1 { top: 77px; }
.dm-row.n2 { top: 115px; }
.dm-row.n3 { top: 153px; }
.dm-hi { position: absolute; inset: 0; border-radius: 6px; background: var(--dm-caution-soft); }
.dm-row.is-ok .dm-hi { background: var(--dm-soft); }
.dm-l, .dm-a { position: relative; }
.dm-a { font-weight: 650; }
.dm-total { position: absolute; left: 22px; right: 22px; top: 206px; height: 28px; display: flex; align-items: center; justify-content: space-between; gap: 8px; white-space: nowrap; font-weight: 750; }
.dm-total b { font-size: 16px; font-weight: 800; }
.dm-ln { position: absolute; left: 22px; height: 6px; border-radius: 3px; background: var(--dm-line); }
.dm-ln.l1 { top: 253px; width: 150px; }
.dm-ln.l2 { top: 267px; width: 96px; }
.dm-scan { position: absolute; left: 0; right: 0; top: -22px; height: 44px; opacity: 0; background: linear-gradient(to bottom, rgba(155, 232, 201, 0), rgba(155, 232, 201, .5) 47%, rgba(25, 168, 117, .75) 47%, rgba(25, 168, 117, .75) 53%, rgba(155, 232, 201, .5) 53%, rgba(155, 232, 201, 0)); }
.dm-badge { position: absolute; left: 239px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: #fff; }
.dm-badge.n1 { top: 79px; }
.dm-badge.n2 { top: 117px; }
.dm-badge.n3 { top: 155px; }
.dm-badge::before { content: ""; grid-area: 1 / 1; width: 22px; height: 22px; border-radius: 50%; background: var(--dm-amber); }
.dm-badge::after { content: "?"; grid-area: 1 / 1; font-size: 13px; font-weight: 800; color: var(--dm-ink); }
.dm-badge.is-ok::before { background: var(--dm-ok); }
.dm-badge.is-ok::after, .dm-ready b::after { content: ""; width: 9px; height: 5px; border-left: 2.2px solid #fff; border-bottom: 2.2px solid #fff; transform: translateY(-1px) rotate(-45deg); }

/* the chips above the cards */
.dm-chip { position: absolute; height: 30px; padding: 0 14px 0 12px; display: flex; align-items: center; gap: 6px; border-radius: 15px; font-size: 12px; white-space: nowrap; box-shadow: 0 6px 10px rgba(16, 34, 28, .1); }
.dm-chip i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dm-flag { left: 123px; top: -41px; rotate: 1.7deg; background: var(--dm-caution-soft); border: 1px solid rgba(242, 184, 75, .6); color: var(--dm-caution); font-weight: 650; }
.dm-flag i { background: var(--dm-amber); }
.dm-ref { left: 142px; top: -33px; rotate: -2.3deg; background: #fff; border: 1px solid var(--dm-line); font-weight: 700; }
.dm-ref i { background: var(--dm-mint); }

/* the reply draft */
.dm-pill { position: absolute; left: 22px; top: 19px; min-width: 120px; height: 26px; padding: 0 10px; display: flex; align-items: center; border-radius: 13px; background: var(--dm-soft); color: #0a4d3c; font-size: 12px; font-weight: 700; white-space: nowrap; }
.dm-to { position: absolute; left: 22px; top: 64px; font-size: 12px; color: var(--dm-muted); white-space: nowrap; }
.dm-bars { position: absolute; inset: 0; }
.dm-bars i { position: absolute; left: 22px; height: 7px; border-radius: 3.5px; background: var(--dm-line); transform-origin: 0 50%; }
.dm-bars i:nth-child(1) { top: 103.5px; width: 214px; }
.dm-bars i:nth-child(2) { top: 121.5px; width: 196px; }
.dm-bars i:nth-child(3) { top: 139.5px; width: 216px; background: var(--dm-mint); }
.dm-bars i:nth-child(4) { top: 157.5px; width: 140px; }
.dm-bars i:nth-child(5) { top: 187.5px; width: 210px; }
.dm-bars i:nth-child(6) { top: 205.5px; width: 178px; }
.dm-bars i:nth-child(7) { top: 223.5px; width: 112px; }
.dm-ready { position: absolute; left: 22px; top: 246px; height: 20px; display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.dm-ready b { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: var(--dm-ok); flex: none; }

/* ---------- layouts ---------- */
.dm--pair { position: relative; width: 100%; max-width: calc(540px * var(--dm-max, .8)); aspect-ratio: 540 / 390; margin-inline: auto; }

/* in the page flow; may be a little wider than a padded column on phones, never wider than the screen */
.dm--strip { --dm-max: .8; width: min(100vw - 20px, 432px); max-width: none; margin: 34px 0 46px 50%; transform: translateX(-50%); }
/* nothing was built (no script): leave no gap */
.dm--strip:empty { display: none; }
.dm--strip::after { content: "Fiktivt eksempel"; position: absolute; left: 0; right: 0; top: calc(100% + 6px); text-align: center; font-size: 11px; color: #6b7c75; }
@media (min-width: 1000px) { .dm--below-1000 { display: none; } }
@media (min-width: 1240px) { .dm--below-1240 { display: none; } }

/* right column of a two-column hero: cards in row 1, the existing panel in row 2 */
.dm--hero-col { display: none; }
@media (min-width: 1000px) {
  .hero.hero--motion { row-gap: 6px; }
  .hero.hero--motion > :first-child { grid-column: 1; grid-row: 1 / span 2; }
  .hero.hero--motion > .hero-panel { grid-column: 2; grid-row: 2; }
  /* the cards reach up into the hero's empty top padding, so the hero grows as little as possible */
  .hero.hero--motion > .dm--hero-col { display: block; grid-column: 2; grid-row: 1; align-self: end; --dm-max: .76; aspect-ratio: 540 / 366; margin-top: -50px; }
  .dm--hero-col .dm-draft { top: 62px; }
  .hero.hero--motion > .dm--hero-col.dm--top { align-self: start; margin-top: 22px; --dm-max: .78; }
}

/* top right corner of a one-column hero: the heading and lead make room for the cards */
.dm--corner { display: none; }
@media (min-width: 1140px) {
  .hero.hero--motion-side { position: relative; }
  .hero.hero--motion-side > h1, .hero.hero--motion-side > p { max-width: 600px; }
  .hero.hero--motion-side > .dm--corner { display: block; position: absolute; right: 20px; top: 62px; width: 432px; }
}

/* side gutters of a narrow article: --dm-half is half the article width */
.dm--gutter { display: none; }
@media (min-width: 1240px) {
  /* spans the page width with no height; clipping sideways keeps the glow from widening the page.
   * Only where the browser can scale the cards to the gutter (the scale property). */
  @supports (scale: 1) { .dm--gutter { display: block; position: absolute; left: 0; right: 0; height: 0; overflow-x: clip; } }
  .dm--gutter .dm-stage { left: 50%; width: 0; height: 0; }
  .dm--gutter .dm-glows { display: none; }
  @supports (overflow-x: clip) { .dm--gutter .dm-glow { display: block; } }
  .dm--gutter .dm-doc { left: calc(-290px - var(--dm-half, 366px)); top: 104px; scale: .8; transform-origin: 100% 0; }
  .dm--gutter .dm-draft { left: calc(var(--dm-half, 366px) + 36px); top: 168px; scale: .8; transform-origin: 0 0; }
}
@media (min-width: 1340px) {
  .dm--gutter .dm-doc, .dm--gutter .dm-draft { scale: 1; }
}

@media print { .dm { display: none !important; } }

/* ---------- motion: an 11 s story loop, a slow float and a short intro ---------- */
@media (prefers-reduced-motion: no-preference) {
  .dm:not(.is-in) .dm-item { opacity: 0; }
  .dm.is-in .dm-item { animation: dm-intro 1.1s var(--dm-out) both; }
  .dm.is-in .dm-draft { animation-delay: .15s; }
  .dm.is-in .dm-doc .dm-float { animation: dm-float-a 9s ease-in-out infinite; }
  .dm.is-in .dm-draft .dm-float { animation: dm-float-b 9s ease-in-out infinite; }
  .dm.is-in .dm-scan { animation: dm-scan 11s linear infinite; }
  .dm.is-in .dm-row.n1 .dm-hi { animation: dm-hi1 11s linear infinite; }
  .dm.is-in .dm-row.n2 .dm-hi { animation: dm-hi2 11s linear infinite; }
  .dm.is-in .dm-row.n3 .dm-hi { animation: dm-hi3 11s linear infinite; }
  .dm.is-in .dm-badge.n1 { animation: dm-badge1 11s linear infinite; }
  .dm.is-in .dm-badge.n2 { animation: dm-badge2 11s linear infinite; }
  .dm.is-in .dm-badge.n3 { animation: dm-badge3 11s linear infinite; }
  .dm.is-in .dm-flag { animation: dm-flag 11s linear infinite; }
  .dm.is-in .dm-ref { animation: dm-ref 11s linear infinite; }
  .dm.is-in .dm-bars { animation: dm-bars 11s linear infinite; }
  .dm.is-in .dm-bars i:nth-child(1) { animation: dm-bar1 11s linear infinite; }
  .dm.is-in .dm-bars i:nth-child(2) { animation: dm-bar2 11s linear infinite; }
  .dm.is-in .dm-bars i:nth-child(3) { animation: dm-bar3 11s linear infinite; }
  .dm.is-in .dm-bars i:nth-child(4) { animation: dm-bar4 11s linear infinite; }
  .dm.is-in .dm-bars i:nth-child(5) { animation: dm-bar5 11s linear infinite; }
  .dm.is-in .dm-bars i:nth-child(6) { animation: dm-bar6 11s linear infinite; }
  .dm.is-in .dm-bars i:nth-child(7) { animation: dm-bar7 11s linear infinite; }
  .dm.is-in .dm-ready { animation: dm-ready 11s linear infinite; }
  /* off screen: everything stops where it is */
  .dm.is-in:not(.is-on) * { animation-play-state: paused !important; }
}
@keyframes dm-intro { from { opacity: 0; transform: translateY(36px); } to { opacity: 1; transform: none; } }
@keyframes dm-float-a { 0%, 100% { transform: translateY(0) rotate(.23deg); } 50% { transform: translateY(-7px) rotate(-.23deg); } }
@keyframes dm-float-b { 0%, 100% { transform: translateY(-5px) rotate(-.23deg); } 44% { transform: translateY(4px) rotate(.23deg); } }
/* generated from the doc-hero timeline (lead 1.2 s, scan 1.9 s, reset at 9.9 s) */
@keyframes dm-scan{0%,9.09%{opacity:0;transform:translateY(50px)}10.91%{opacity:1;transform:translateY(50px);animation-timing-function:ease-in-out}28.18%{opacity:1;transform:translateY(226px)}31.36%,100%{opacity:0;transform:translateY(226px)}}
@keyframes dm-hi1{0%,15.03%{opacity:0}17.76%,90%{opacity:1}94.55%,100%{opacity:0}}
@keyframes dm-badge1{0%,15.49%{transform:scale(0);animation-timing-function:cubic-bezier(.34,1.56,.64,1)}19.58%,90%{transform:scale(1);animation-timing-function:ease-in}93.18%,100%{transform:scale(0)}}
@keyframes dm-hi2{0%,18.76%{opacity:0}21.49%,90%{opacity:1}94.55%,100%{opacity:0}}
@keyframes dm-badge2{0%,19.21%{transform:scale(0);animation-timing-function:cubic-bezier(.34,1.56,.64,1)}23.31%,90%{transform:scale(1);animation-timing-function:ease-in}93.18%,100%{transform:scale(0)}}
@keyframes dm-hi3{0%,22.49%{opacity:0}25.22%,90%{opacity:1}94.55%,100%{opacity:0}}
@keyframes dm-badge3{0%,22.94%{transform:scale(0);animation-timing-function:cubic-bezier(.34,1.56,.64,1)}27.04%,90%{transform:scale(1);animation-timing-function:ease-in}93.18%,100%{transform:scale(0)}}
@keyframes dm-flag{0%,19.09%{opacity:0;transform:translateY(10px);animation-timing-function:cubic-bezier(.16,1,.3,1)}22.73%{opacity:1}26.36%,90%{opacity:1;transform:translateY(0)}93.64%,100%{opacity:0;transform:translateY(0)}}
@keyframes dm-bar1{0%,23.86%{transform:scaleX(0);animation-timing-function:cubic-bezier(.25,1,.5,1)}27.5%,94.55%{transform:scaleX(1)}95%,100%{transform:scaleX(0)}}
@keyframes dm-bar2{0%,26.59%{transform:scaleX(0);animation-timing-function:cubic-bezier(.25,1,.5,1)}30.23%,94.55%{transform:scaleX(1)}95%,100%{transform:scaleX(0)}}
@keyframes dm-bar3{0%,29.32%{transform:scaleX(0);animation-timing-function:cubic-bezier(.25,1,.5,1)}32.95%,94.55%{transform:scaleX(1)}95%,100%{transform:scaleX(0)}}
@keyframes dm-bar4{0%,32.05%{transform:scaleX(0);animation-timing-function:cubic-bezier(.25,1,.5,1)}35.68%,94.55%{transform:scaleX(1)}95%,100%{transform:scaleX(0)}}
@keyframes dm-bar5{0%,37.05%{transform:scaleX(0);animation-timing-function:cubic-bezier(.25,1,.5,1)}40.68%,94.55%{transform:scaleX(1)}95%,100%{transform:scaleX(0)}}
@keyframes dm-bar6{0%,39.77%{transform:scaleX(0);animation-timing-function:cubic-bezier(.25,1,.5,1)}43.41%,94.55%{transform:scaleX(1)}95%,100%{transform:scaleX(0)}}
@keyframes dm-bar7{0%,42.5%{transform:scaleX(0);animation-timing-function:cubic-bezier(.25,1,.5,1)}46.14%,94.55%{transform:scaleX(1)}95%,100%{transform:scaleX(0)}}
@keyframes dm-bars{0%,90%{opacity:1}94.09%,95.09%{opacity:0}96.36%,100%{opacity:1}}
@keyframes dm-ref{0%,31.14%{opacity:0;transform:translateY(10px);animation-timing-function:cubic-bezier(.16,1,.3,1)}34.77%{opacity:1}38.41%,90%{opacity:1;transform:translateY(0)}93.64%,100%{opacity:0;transform:translateY(0)}}
@keyframes dm-ready{0%,47.05%{opacity:0;transform:translateX(-8px);animation-timing-function:cubic-bezier(.16,1,.3,1)}50.23%{opacity:1}53.41%,90%{opacity:1;transform:translateX(0)}93.64%,100%{opacity:0;transform:translateX(0)}}
