/* Liike X · kierros 5: shared base for the notebook-page versions.
   Hero (logo video + slogan) → one notebook page (A4 on desktop) with the manifesto → the signature, four ways. */
:root { --ground: #0b0b0b; --bone: #ecebe7; }
body { background: var(--ground); color: var(--bone); overflow-x: hidden; }

/* 1 · hero, as in kierros 3 */
.hero { min-height: 100svh; display: grid; place-content: center; justify-items: center; gap: clamp(8px, 2vh, 24px); padding: 40px var(--gutter) 18vh; text-align: center; }
/* the video's pure-black ground is lightened into the page ground so no square shows */
.hero .logo-wrap { background: var(--ground); isolation: isolate; }
.hero .logo { width: clamp(150px, 14vw, 210px); aspect-ratio: 1; display: block; object-fit: cover; mix-blend-mode: lighten;
  -webkit-mask-image: radial-gradient(closest-side, #000 72%, transparent 100%); mask-image: radial-gradient(closest-side, #000 72%, transparent 100%); }
.hero p { margin: 0; max-width: 23ch; font: 400 clamp(1.55rem, 3.1vw, 2.5rem)/1.5 var(--f-display); letter-spacing: -0.02em; color: rgba(124,124,124, calc(1 - var(--dim, 0) * 0.72)); text-wrap: balance; }
.hero p b { color: var(--bone); font-weight: 500; }
.hero p b.hand { font-family: var(--f-sign); font-weight: 400; font-size: 0.8em; letter-spacing: 0; padding-inline: 0.1em; }

/* 2 · the desk the page lies on; the shadow lives here because the page itself is masked */
.desk { position: relative; padding: 0 var(--gutter) clamp(90px, 16vh, 170px); }
.desk .lift { position: relative; max-width: var(--page-w, 780px); margin: 0 auto; filter: drop-shadow(0 2px 2px rgba(0,0,0,.4)) drop-shadow(0 26px 28px rgba(0,0,0,.7)); }

.page {
  --lh: 2.1rem;                 /* one ruled line; every vertical measure on the page is a multiple of it */
  --head: calc(var(--lh) * 3);  /* blank band above the first rule */
  --ink: #1d3891; --rule: rgba(80,120,200,.5); --paper: #f5f4ef; --margin-x: 0px;
  position: relative; color: var(--ink); background: var(--paper);
  font-family: var(--f-page); font-size: var(--fs, 1.45rem); line-height: var(--lh);
  padding: var(--head) var(--pad-r, clamp(22px, 6vw, 64px)) calc(var(--lh) * 2) var(--pad-l, clamp(52px, 11vw, 112px));
  -webkit-mask-size: 100% 100%; mask-size: 100% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}
.page > * { position: relative; z-index: 1; }
/* paper: soft mottling and fine grain, procedural so it never repeats visibly */
.page::after { content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none; mix-blend-mode: multiply;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='900'%3E%3Cfilter id='m'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.004 .006' numOctaves='4' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 .55  0 0 0 0 .52  0 0 0 0 .46  0 0 0 -2.2 1.25'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23m)'/%3E%3C/svg%3E") 0 0 / 900px 900px,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch' seed='8'/%3E%3CfeColorMatrix values='0 0 0 0 .3  0 0 0 0 .3  0 0 0 0 .28  0 0 0 .8 -.32'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E") 0 0 / 220px;
  opacity: var(--grain, .45); }

/* ruled lines: vihko.js shifts them (--ry) so each one sits just under the written baseline */
.rules { position: absolute; z-index: 0; inset: var(--head) 0 calc(var(--lh) * .5) 0; pointer-events: none;
  background: linear-gradient(to bottom, transparent calc(var(--lh) - 1px), var(--rule) 0) 0 var(--ry, 0px) / 100% var(--lh); }
.rules.grid { top: 0; background:
  linear-gradient(to bottom, transparent calc(var(--lh) - 1px), var(--rule) 0) 0 var(--ry, 0px) / 100% var(--lh),
  linear-gradient(to right, transparent calc(var(--lh) - 1px), var(--rule) 0) var(--rx, 0px) 0 / var(--lh) 100%; }
/* the red margin, drawn twice like a cheap school pad */
.margin-line { position: absolute; z-index: 0; top: 0; bottom: 0; left: var(--margin-x); width: 1px; background: var(--margin, #d94a5a); box-shadow: 3px 0 0 var(--margin-2, transparent); pointer-events: none; }

.page-head { position: absolute; top: calc(var(--lh) * 1); right: var(--pad-r, clamp(22px, 6vw, 64px)); margin: 0; font-size: .82em; opacity: .9; }
/* the sheet's own margins set the measure; handwriting runs wide, so it stays readable at A4 width */
.text p { margin: 0 0 var(--lh); max-width: 72ch; }
.text .w { position: relative; }
.text s.slip { text-decoration: none; position: relative; }
.text s.slip::after { content: ""; position: absolute; left: -8%; right: -8%; top: 52%; height: 2px; background: currentColor; transform: rotate(-6deg); border-radius: 2px; }
.text em { font-style: normal; padding-bottom: 2px; -webkit-box-decoration-break: clone; box-decoration-break: clone; background: var(--em-bg, none) repeat-x 0 100% / 46px 7px; }

/* an A4 sheet on desktop: at least 1 : 1.414, and vihko.js shrinks the writing until it is no taller */
@media (min-width: 701px) { .page[data-a4] { aspect-ratio: 1 / 1.4142; } }

/* 3 · the signature, written on the same page and on the same rules */
.sign { margin-top: var(--lh); scroll-margin-top: 20vh; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 clamp(24px, 5vw, 56px); align-items: start; }
.sig-line { display: block; height: calc(var(--lh) * 2); position: relative; }
.sig-line::after { content: ""; position: absolute; left: 0; right: 0; bottom: calc(var(--lh) * .22); height: 1.5px; background: currentColor; opacity: .75; border-radius: 2px; transform: rotate(-.4deg); }
/* signatures are written by the same hand as the page, a size up; the box is tall enough for every descender */
.sig-name, .sig-input { position: absolute; left: 0; right: 0; bottom: calc(var(--lh) * .12); font-family: var(--f-page); font-size: 1.32em; line-height: calc(var(--lh) * 1.5); color: var(--sig-ink, var(--ink)); }
.sig-input { width: 100%; height: calc(var(--lh) * 1.5); border: 0; padding: 0; background: transparent; outline: none; caret-color: var(--ink); }
.mailrow input::placeholder, .blank input::placeholder { color: var(--hint, rgba(60,60,60,.85)); font-family: var(--f-page); font-size: .86em; }
.sig-input::placeholder { color: var(--hint, rgba(60,60,60,.85)); font-size: .66em; }
.sig-cap { display: flex; justify-content: space-between; gap: 8px; font-size: .78em; height: var(--lh); }
.more { position: relative; }
.mine.signed .more > div { visibility: hidden; }
.more [role=status] { position: absolute; inset: 0 0 auto; margin: 0; }
/* "sign with another name": a pencilled aside after the note, for a shared computer */
.more [role=status] .again { padding: 0; border: 0; background: none; color: var(--hint, inherit); font: inherit; font-size: .8em; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; white-space: nowrap; }
/* a blank to write on: dotted, like the line on a form you fill in by hand */
.mailrow input, .blank input { height: var(--lh); border: 0; padding: 0; color: var(--ink); font: inherit; line-height: var(--lh); outline: none; caret-color: var(--ink);
  background: radial-gradient(circle, currentColor 0.9px, transparent 1.3px) 0 calc(100% - var(--lh) * .18) / 6px 3px repeat-x; }
.mailrow { display: flex; align-items: baseline; gap: .5em; min-height: var(--lh); }
.mailrow span { flex: none; font-size: .86em; }
.mailrow input { flex: 1; min-width: 0; }
.mailrow input:focus-visible, .sig-input:focus-visible, .blank input:focus-visible { background-color: var(--focus, rgba(255,226,0,.32)); }
.err { margin: 0; font-size: .82em; color: var(--err, #b3121f); }
.err:empty { display: none; }
.err:not(:empty) ~ .fine { display: none; }
/* the checkbox is a box drawn by hand; the tick is drawn into it */
.tick { display: flex; gap: .45em; align-items: flex-start; min-height: var(--lh); font-size: .86em; cursor: pointer; }
.tick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
/* the box sits beside the first line when the label wraps */
.tick svg { flex: none; width: 1.1em; height: 1.1em; margin-top: calc((var(--lh) - 1.1em) / 2); overflow: visible; }
.tick svg path { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tick svg .t { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 380ms var(--ease-out); }
.tick input:checked + svg .t { stroke-dashoffset: 0; }
/* the tick is drawn in the same red as the circle round the button; the box stays in the page's ink */
.tick svg .t { stroke: var(--loop, currentColor); }
.tick input:focus-visible + svg { outline: 2px dashed currentColor; outline-offset: 3px; }
/* submit: the word circled in pen, so it reads as the thing to press; hovering draws the loop again */
.go { display: flex; align-items: baseline; gap: 4px 30px; flex-wrap: wrap; margin-top: calc(var(--lh) * .5); min-height: calc(var(--lh) * 2); }
.go button { position: relative; min-height: 48px; padding: 0 .55em; border: 0; background: none; color: var(--ink); font: inherit; font-size: 1.32em; line-height: var(--lh); cursor: pointer; }
.go button svg { position: absolute; inset: -18% -12% -20% -14%; width: 126%; height: 138%; overflow: visible; pointer-events: none; }
.go button svg path { fill: none; stroke: var(--loop, currentColor); stroke-width: 2.2; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 0; }
.go button:hover svg path, .go button:focus-visible svg path { animation: redraw 650ms var(--ease-out); }
@keyframes redraw { from { stroke-dashoffset: 1; } }
.go button:focus-visible { outline: none; }
.go button[disabled] { cursor: progress; opacity: .7; }
.fine { margin: 0; font-size: .74em; line-height: var(--lh); }
/* the field only bots fill in: out of sight and out of the tab order */
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.human:empty { display: none; }
.human { flex-basis: 100%; }
.fine a { color: inherit; }
::selection { background: rgba(255,226,0,.6); color: #111; }

/* b · lause: a sentence with blanks in it */
.fill { margin: 0; }
.blank { display: inline-block; vertical-align: baseline; }
.blank input { display: inline-block; vertical-align: baseline; width: 100%; }
.b-name { width: 11em; } .b-mail { width: 13em; }
.sign-b .ticks { margin-top: var(--lh); }
.sign-b .pair { margin-top: 0; }
.mirror:empty::before { content: ""; }

/* c · lipuke: ours closes the text; a perforated tear-off slip carries yours */
.closing { margin: 0; height: calc(var(--lh) * 2); position: relative; text-align: right; }
.closing .sig-name { position: absolute; left: auto; right: 0; bottom: calc(var(--lh) * .12); font-size: 1.45em; }
/* who the signature belongs to, written small under it like a caption */
.closing-cap { margin: 0; height: var(--lh); line-height: var(--lh); text-align: right; font-size: .78em; }
html[data-alle="d"] .closing-cap { text-align: left; }
.perf { position: relative; height: var(--lh); margin: var(--lh) calc(-1 * var(--pad-r, clamp(22px, 6vw, 64px))) 0 calc(-1 * var(--pad-l, clamp(52px, 11vw, 112px)));
  background: radial-gradient(circle, var(--ground) 1.6px, transparent 2.1px) 0 50% / 9px 9px repeat-x;
  /* the perforation stops for the scissors instead of running under them, with a little air either side */
  --cut-a: calc(var(--pad-l, 60px) - 46px); --cut-b: calc(var(--pad-l, 60px) + 6px);
  -webkit-mask: linear-gradient(to right, #000 var(--cut-a), transparent 0 var(--cut-b), #000 0); mask: linear-gradient(to right, #000 var(--cut-a), transparent 0 var(--cut-b), #000 0); }
/* the gap's edges fall between two holes (holes sit every 9px, centred on 4.5px), so no hole is cut in half */
@supports (width: round(down, 1px, 1px)) {
  .perf { --cut-a: round(down, calc(var(--pad-l, 60px) - 46px), 9px); --cut-b: round(up, calc(var(--pad-l, 60px) + 6px), 9px); }
}
.perf + .scissors { display: block; position: relative; height: 0; }
/* drawn in the page's pen, sitting in the gap the perforation leaves for it */
.scissors svg { position: absolute; left: -38px; top: calc(var(--lh) * -.5 - 10px); width: 36px; height: 20px; overflow: visible; transform: rotate(-7deg);
  fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.sign-c { margin-top: 0; }
/* the e-mail sits on the same line as the name, with its label as the caption underneath */
.sign-c .mailcol .mailrow { display: grid; grid-template-rows: calc(var(--lh) * 2) var(--lh); align-items: end; gap: 0; }
.sign-c .mailcol .mailrow input { grid-row: 1; margin-bottom: calc(var(--lh) * .12); }
.sign-c .mailcol .mailrow span { grid-row: 2; align-self: start; font-size: .78em; line-height: var(--lh); }
.sign-c .ticks { margin-top: 0; }

/* d · lappu: a note taped over the sheet's lower corner, off the edge onto the desk */
html[data-alle="d"] .desk { padding-bottom: clamp(240px, 30vh, 320px); }
/* hangs off the sheet's right edge by up to 150px, never past the window */
.note { position: absolute; z-index: 4; right: max(-150px, calc((min(var(--page-w, 780px), 100vw - 2 * var(--gutter)) - 100vw) / 2 + 12px)); bottom: -200px; width: 360px; padding: 30px 26px 16px;
  --lh: 1.7rem; font-family: var(--f-page); font-size: 1.12rem; line-height: var(--lh); color: var(--ink, #1d3891);
  background: var(--note-bg, #f7e46b); transform: rotate(2.6deg);
  box-shadow: 0 1px 1px rgba(0,0,0,.25), 0 14px 22px -6px rgba(0,0,0,.55); }
.note::after { content: ""; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: multiply; opacity: .35;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch' seed='8'/%3E%3CfeColorMatrix values='0 0 0 0 .3  0 0 0 0 .3  0 0 0 0 .28  0 0 0 .8 -.32'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E") 0 0 / 220px; }
.note .tape { position: absolute; z-index: 2; top: -13px; left: 50%; width: 112px; height: 28px; transform: translateX(-50%) rotate(-4deg); background: rgba(236,232,214,.62); box-shadow: 0 1px 2px rgba(0,0,0,.18); }
.note .sign { margin-top: 0; position: relative; z-index: 1; }
.note .sig-line { height: calc(var(--lh) * 1.6); }
.note .mailrow { margin-top: .5em; }
.note .ticks { margin: .5em 0 .2em; }
.note .tick { line-height: 1.3; min-height: 0; padding-block: .25em; }
/* the note takes the lower right corner, so our signature moves to the left under the text */
html[data-alle="d"] .closing .sig-name { left: 0; right: auto; }

/* the prototype switcher, only on a page opened by itself */
.proto-switch { position: fixed; right: 12px; bottom: 12px; z-index: 999; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; max-width: calc(100vw - 24px);
  padding: 6px 8px; background: #ffe600; color: #000; font: 600 12px/1.3 var(--f-display); }
.proto-switch a { color: #000; padding: 4px 7px; text-decoration: none; border: 1px solid transparent; }
.proto-switch a[aria-current] { border-color: #000; }
.proto-switch a:hover { text-decoration: underline; }

footer { position: relative; padding: 30px var(--gutter) 70px; color: #8a8a8a; font-size: .85rem; text-align: center; }
footer a { color: inherit; }

@media (max-width: 640px) {
  .page { --lh: 1.85rem; --fs: 1.2rem; }
  .pair { grid-template-columns: 1fr; }
  .b-name { width: 8.5em; } .b-mail { width: 100%; }
  html[data-alle="d"] .desk { padding-bottom: 90px; }
  .note { position: relative; right: auto; bottom: auto; width: min(94%, 380px); margin: -26px auto 0; transform: rotate(1.6deg); }
}
@media (prefers-reduced-motion: reduce) {
  .tick svg .t, .go button svg path { transition: none; }
}
