/* Kristiina Junttu, mockup stylesheet. One file, no framework. */

:root {
  --bg: #eaeaea;
  --ink: #463c3c;        /* headings, active nav (from the current site) */
  --text: #3a3232;       /* body text, contrast ~10:1 on --bg */
  --muted: #6a5f5f;      /* secondary text, contrast ~5.6:1 on --bg */
  --rule: #cfc8c8;
  --focus: #463c3c;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --measure: 66ch;
  --col: 44rem;          /* about 700px, the old site's width */
  --gutter: clamp(1.25rem, 5vw, 3rem);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
}

::selection { background: var(--ink); color: var(--bg); }

a {
  color: var(--ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover { text-decoration-thickness: 2px; }
a:focus-visible,
.skip:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}

img { display: block; max-width: 100%; height: auto; }

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--ink);
  color: var(--bg);
  padding: 0.5rem 1rem;
}
.skip:focus { top: 1rem; }

/* Layout */

.wrap {
  max-width: var(--col);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.site-header {
  padding-top: 2.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--rule);
}

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 2rem;
}

.wordmark {
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.25rem 0;
  border-bottom: 1px solid transparent;
}
.nav a:hover { color: var(--ink); border-bottom-color: var(--ink); }
.nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

main { padding-top: 3rem; padding-bottom: 4rem; }

.back {
  display: inline-block;
  font-size: 0.9375rem;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 2rem;
}
.back:hover { color: var(--ink); }

/* Type */

h1,
h2 {
  font-family: var(--serif);
  font-weight: 400;
  color: var(--ink);
  line-height: 1.15;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.25rem, 6vw, 3.5rem);
  margin: 0 0 1.5rem;
}

h2 {
  font-size: clamp(1.65rem, 4vw, 2.25rem);
  margin: 0 0 0.75rem;
}

.lead {
  font-size: clamp(1.15rem, 2.4vw, 1.3rem);
  line-height: 1.55;
  color: var(--ink);
  max-width: var(--measure);
  margin: 0 0 2.5rem;
}

p { max-width: var(--measure); margin: 0 0 1rem; }

/* Sections: separated by a rule, no cards */

.section { padding: 0 0 2.5rem; }
.section:first-child { padding-top: 0; }

.news {
  font-size: 1rem;
  margin: 0 0 2.5rem;
  padding: 1rem 0;
  border-top: 1px solid var(--rule);
}
.news + .section { border-top: 0; }

/* Home: the four-frame photo strip */

.strip {
  margin: 0 0 2.5rem;
}
.strip img {
  width: 100%;
  height: auto;
}

/* Landing page: one screen. Top bar, photo strip, name, one line, four links, footer. */

body.landing {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.landing-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1.75rem var(--gutter) 0;
}
.landing-lang {
  color: var(--muted);
  font-size: 0.9375rem;
  text-decoration: none;
}
.landing-lang:hover { color: var(--ink); }

.landing-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2rem 0;
}

.landing-strip { margin: 0; width: 100%; }
.landing-strip img { width: 100%; height: auto; }

.landing-text { padding-top: clamp(2rem, 6vh, 4rem); }

.landing-text h1 {
  font-size: clamp(3rem, 9vw, 6.5rem);
  margin: 0 0 1rem;
  letter-spacing: -0.03em;
}

.landing-text .lead { margin: 0; }

.landing-nav { margin-top: clamp(2.5rem, 7vh, 4.5rem); }
.landing-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  max-width: var(--col);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.landing-nav a {
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1.25rem, 3vw, 1.6rem);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.15rem;
}
.landing-nav a:hover { border-bottom-color: var(--ink); }

.landing-foot {
  padding: 1.5rem var(--gutter) 2rem;
  text-align: center;
  font-size: 0.9375rem;
}
.landing-foot a { color: var(--muted); }
.landing-foot a:hover { color: var(--ink); }

/* Sub-page index lists (research, teaching) */

.index { list-style: none; margin: 0; padding: 0; }
.index li {
  padding: 1.5rem 0;
  border-top: 1px solid var(--rule);
}
.index li:last-child { border-bottom: 1px solid var(--rule); }
.index h2 { margin-bottom: 0.4rem; font-size: clamp(1.3rem, 3vw, 1.6rem); }
.index h2 a { color: var(--ink); text-decoration: none; }
.index h2 a:hover { text-decoration: underline; }
.index p { margin: 0; color: var(--muted); }

/* Photo grid */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.grid figure { margin: 0; }
.grid .frame {
  aspect-ratio: 4 / 5;
  background: #dcd7d7;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.875rem;
}
.grid figcaption {
  margin-top: 0.5rem;
  font-size: 0.9375rem;
  color: var(--muted);
}

/* Footer */

.site-footer {
  border-top: 1px solid var(--rule);
  padding: 2rem 0 3rem;
  font-size: 0.9375rem;
  color: var(--muted);
}
.site-footer ul {
  list-style: none;
  margin: 0 0 1.25rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}
.site-footer a { color: var(--ink); }

/* Small screens */

@media (max-width: 40rem) {
  body { font-size: 1rem; }
  .site-header { padding-top: 1.5rem; }
  main { padding-top: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Hero landing (index.html). Light stage in the site colours, name, four portrait frames. One entrance: the frames rise in. */

body.hero {
  --h-bg: var(--bg);
  --h-fg: var(--ink);
  --h-dim: var(--muted);
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--h-bg);
  color: var(--h-fg);
  overflow-x: hidden;
}
body.hero a { color: var(--h-fg); }
body.hero ::selection { background: var(--h-fg); color: var(--h-bg); }
body.hero a:focus-visible, body.hero .skip:focus-visible { outline-color: var(--h-fg); }
body.hero .skip { background: var(--h-fg); color: var(--h-bg); }

.hero-top { display: flex; justify-content: flex-end; padding: 1.75rem var(--gutter) 0; font-size: 0.9375rem; }
.hero-lang { color: var(--h-dim) !important; text-decoration: none; }
.hero-lang:hover { color: var(--h-fg) !important; }

.hero-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(1.25rem, 4vh, 2.5rem);
  max-width: 80rem;
  width: 100%;
  margin: 0 auto;
  padding: clamp(1.5rem, 5vh, 3rem) var(--gutter);
}

.hero-name {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(3.25rem, 12vw, 6rem);
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--h-fg);
}
.hero-name em { font-style: normal; color: var(--h-dim); }


/* Frames develop like a filmstrip: each one opens left to right, in reading order. */
.hero-frames { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(0.5rem, 1.4vw, 1rem); width: 100%; max-width: 34rem; }
.hero-frames i {
  display: block;
  aspect-ratio: 175 / 123;
  background: url(img/banner.jpg) 0 0 / 400% 100% no-repeat;
  animation: frame-in 0.9s cubic-bezier(.2,.7,.2,1) both;
}
.hero-frames i:nth-child(2) { background-position: 33.333% 0; animation-delay: 0.1s; }
.hero-frames i:nth-child(3) { background-position: 66.667% 0; animation-delay: 0.2s; }
.hero-frames i:nth-child(4) { background-position: 100% 0; animation-delay: 0.3s; }
@keyframes frame-in { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

.hero-nav { display: flex; flex-wrap: wrap; gap: 0.5rem 2.5rem; }
.hero-nav a { font-family: var(--serif); font-size: clamp(1.4rem, 3vw, 2rem); text-decoration: none; border-bottom: 1px solid transparent; }
.hero-nav a:hover { border-bottom-color: var(--h-fg); }

.hero-foot { max-width: 80rem; width: 100%; margin: 0 auto; padding: 0 var(--gutter) 2rem; font-size: 0.9375rem; }
.hero-foot a { color: var(--h-dim) !important; }
.hero-foot a:hover { color: var(--h-fg) !important; }


/* Research sub-navigation (Játékok, Improvisaatiot, Pianojumppa, Raportti) */

.subnav { margin: 0 0 2.5rem; }
.subnav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
}
.subnav a {
  color: var(--muted);
  font-size: 0.875rem;
  letter-spacing: 0.06em;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 0.1rem;
}
.subnav a:hover { color: var(--ink); }
.subnav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }

.exercise-group { margin: 0 0 1.5rem; }
.exercise-group h3 {
  font-family: var(--sans);
  font-weight: 500;
  font-size: var(--t-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.5rem;
}
.exercise-group ul { margin: 0; padding-left: 1.25rem; color: var(--muted); }

/* Table of contents (assets/toc.js). Narrow: collapsed list above the text. Wide: sticky column on the right. */

html { scroll-padding-top: 1.5rem; }

.has-toc { display: flex; flex-direction: column; }
.toc-aside { order: -1; margin-bottom: 2rem; }

.toc { font-size: 0.9375rem; }
.toc summary {
  cursor: pointer;
  color: var(--muted);
  list-style: none;
  padding: 0.25rem 0;
  letter-spacing: 0.06em;
  font-size: 0.875rem;
}
.toc summary::-webkit-details-marker { display: none; }
.toc summary:hover { color: var(--ink); }
.toc summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 2px; }

.toc-list { position: relative; margin-top: 0.5rem; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li a {
  display: block;
  color: var(--muted);
  text-decoration: none;
  padding: 0.3rem 0 0.3rem 1rem;
  line-height: 1.4;
  transition: color 0.3s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.toc li.toc-sub a { padding-left: 1.9rem; font-size: 0.875rem; }
.toc li a:hover { color: var(--ink); }
.toc li a[aria-current="true"] { color: var(--ink); }
.toc li a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

.toc-indicator {
  position: absolute;
  left: 0;
  top: 0;
  width: 2px;
  height: 0;
  background: var(--ink);
  opacity: 0;
  transform: translateY(0);
  transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1), height 0.45s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.3s ease;
  will-change: transform;
}

.toc-body h2:focus,
.toc-body h3:focus { outline: none; }

@media (min-width: 60rem) {
  .has-toc {
    display: grid;
    grid-template-columns: minmax(0, 44rem) 14rem;
    column-gap: 4rem;
    align-items: start;
    max-width: 66rem;
  }
  .toc-body { min-width: 0; }
  .toc-aside { order: 0; margin: 0; position: sticky; top: 2.5rem; }
  .toc summary { display: none; }
  .toc { padding-top: 0.25rem; }
  .toc-list { margin-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .toc li a,
  .toc-indicator { transition: none; }
  html { scroll-behavior: auto; }
}

/* Round 1 of the polish pass: type scale, serif running text, notation dividers, editorial hero. */

:root {
  --t-xs: 0.8125rem;   /* labels */
  --t-sm: 0.9375rem;   /* nav, footer, small print */
  --t-body: 1.1875rem; /* running text (serif) */
  --t-lead: clamp(1.25rem, 2.4vw, 1.45rem);
}

/* Running text is serif, like a printed book. Headings, nav and labels stay as they are. */
.section p,
.index p,
.lead { font-family: var(--serif); font-size: var(--t-body); line-height: 1.6; }
.lead { font-size: var(--t-lead); line-height: 1.5; }

/* Group headings in hubs are labels, not items. */
.section:has(> .index) > h2 {
  font-family: var(--sans);
  font-size: var(--t-xs);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1rem;
  line-height: 1.3;
}

/* Sections after the first are divided by a notation mark (cluster in the middle of a rule). */
/* Sections are separated by space alone. */
.section + .section { padding-top: 2.5rem; }

/* Landing: editorial layout on wide screens. Name top left, frames as a staggered pair on the right, nav under the name. */
@media (min-width: 52rem) {
  .hero-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    column-gap: clamp(3rem, 6vw, 6rem);
    align-items: center;
  }
  .hero-name { grid-column: 1; grid-row: 1; align-self: end; }
  .hero-frames { grid-column: 2; grid-row: 1 / span 2; justify-self: end; }
  .hero-frames i:nth-child(even) { margin-top: clamp(2rem, 5vw, 4rem); }
  .hero-nav { grid-column: 1; grid-row: 2; align-self: start; flex-direction: column; gap: 0.35rem; }
  .hero-nav a { font-size: clamp(1.8rem, 3.2vw, 2.6rem); }
}

@media (prefers-reduced-motion: reduce) {
  .hero-frames i { clip-path: none; }
}

/* Front page (index.html): one scroll. A pinned hero, with the chapters sliding up over it. */

body.front { background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 1.0625rem; line-height: 1.65; }
body.front .skip { position: absolute; left: 1rem; top: -4rem; background: var(--ink); color: var(--bg); padding: 0.5rem 1rem; z-index: 20; }
body.front .skip:focus { top: 1rem; }

.fp-hero {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem var(--gutter) 7svh;
  z-index: 0;
  overflow: hidden;
}
/* Scrolling: the hero drifts up, dims and shrinks a little, like a card pushed back. --e is eased from 0 to 1. */
.fp-hero-inner {
  width: 100%;
  max-width: 44rem;
  transform: translate3d(0, calc(var(--e, 0) * -4rem), 0) scale(calc(1 - var(--e, 0) * 0.05));
  opacity: calc(1 - var(--e, 0) * 0.9);
  transform-origin: 50% 40%;
  will-change: transform, opacity;
}

/* Scroll cue: a wide, semi-transparent chevron above the sheet. It bobs gently and fades out as you scroll. */
.fp-cue {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2.25rem;
  margin: 0 auto;
  width: 2.25rem;
  opacity: calc(1 - var(--e, 0) * 3);
  color: var(--ink);
  cursor: pointer;
}
.fp-cue:focus-visible { outline: 2px solid var(--focus); outline-offset: 6px; border-radius: 4px; }
.fp-cue svg {
  display: block;
  width: 100%;
  height: auto;
  animation: cue-bob 2.6s cubic-bezier(.45, 0, .55, 1) infinite;
}
@keyframes cue-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(6px); } }

.fp-name {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(3.25rem, 11vw, 6.5rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.fp-name em { font-style: normal; color: var(--muted); }
.fp-lead { font-family: var(--serif); font-size: var(--t-lead); line-height: 1.5; color: var(--ink); margin: 1.5rem 0 2rem; max-width: 26ch; }

.fp-frames { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(0.35rem, 1vw, 0.6rem); }
.fp-frames i {
  display: block;
  aspect-ratio: 175 / 123;
  background: url(img/banner.jpg) 0 0 / 400% 100% no-repeat;
  animation: frame-in 0.9s cubic-bezier(.2,.7,.2,1) both;
}
.fp-frames i:nth-child(2) { background-position: 33.333% 0; animation-delay: 0.1s; }
.fp-frames i:nth-child(3) { background-position: 66.667% 0; animation-delay: 0.2s; }
.fp-frames i:nth-child(4) { background-position: 100% 0; animation-delay: 0.3s; }
/* While scrolling, the frames separate a little, each by a different amount, so the strip seems to open up. */
.fp-frames i:nth-child(1) { transform: translate3d(0, calc(var(--e, 0) * -0.4rem), 0); }
.fp-frames i:nth-child(2) { transform: translate3d(0, calc(var(--e, 0) * -1rem), 0); }
.fp-frames i:nth-child(3) { transform: translate3d(0, calc(var(--e, 0) * -0.7rem), 0); }
.fp-frames i:nth-child(4) { transform: translate3d(0, calc(var(--e, 0) * -1.4rem), 0); }
@media (max-width: 40rem) { .fp-frames { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Fixed top bar: always on top, so the links stay clickable over the rising chapters. */
.fp-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: 1.6rem var(--gutter) 2.4rem;
  background: linear-gradient(to bottom, rgb(234 234 234 / 0.97) 55%, rgb(234 234 234 / 0));
}
.fp-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem 2.4rem; max-width: 44rem; margin: 0 auto; }
html:has(body.front) { scroll-padding-top: 4.5rem; }

.fp-nav a {
  position: relative;
  font-family: var(--serif);
  font-size: 1.1rem;
  color: var(--ink);
  text-decoration: none;
}
/* A hairline draws in from the left on hover and focus. Same font as the copies that travel, so nothing changes mid-trip. */
.fp-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 1px;
  background: var(--ink);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.45s cubic-bezier(.2,.7,.2,1);
}
.fp-nav a:hover::after,
.fp-nav a:focus-visible::after { transform: scaleX(1); }
.fp-nav a:focus-visible { outline: none; }

/* The content sits above the pinned hero and rises over it. */
/* At rest the sheet sits fully below the screen. The arrow is the only hint to scroll. */
.fp-content {
  position: relative;
  z-index: 1;
  margin-top: 0;
  background: var(--bg);
  border-radius: 28px 28px 0 0;
  padding: 0 var(--gutter) 1.5rem;
}
.fp-content > .fp-chapter:first-of-type { padding-top: clamp(3.5rem, 9vh, 5rem); }

.fp-chapter { max-width: 44rem; margin: 0 auto; padding: clamp(4rem, 12vh, 7rem) 0; }
.fp-chapter h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(2rem, 4vw, 2.75rem); line-height: 1.1; color: var(--ink); margin: 0 0 2rem; letter-spacing: -0.015em; }
.fp-chapter h3 { font-family: var(--sans); font-weight: 500; font-size: var(--t-xs); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 2.25rem 0 0.75rem; }
.fp-chapter h3:first-of-type { margin-top: 0; }
.fp-chapter p { font-family: var(--serif); font-size: var(--t-body); line-height: 1.6; max-width: 60ch; margin: 0 0 1rem; }
.fp-chapter a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }

.fp-links { list-style: none; margin: 1.5rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.6rem 1.5rem; }
.fp-links a { font-family: var(--serif); font-size: 1.125rem; border-bottom: 1px solid var(--rule); padding-bottom: 0.1rem; text-decoration: none; }
.fp-links a:hover { border-bottom-color: var(--ink); }

.fp-reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.8s cubic-bezier(.2,.7,.2,1), transform 0.8s cubic-bezier(.2,.7,.2,1); }
.fp-reveal.in { opacity: 1; transform: none; }

.fp-foot { max-width: 44rem; margin: 0 auto; border-top: 1px solid var(--rule); padding: 2rem 0 3rem; font-size: 0.9375rem; color: var(--muted); }
.fp-foot a { color: var(--ink); }
.fp-foot p { margin: 0.75rem 0 0; }

@media (prefers-reduced-motion: reduce) {
  .fp-hero-inner, .fp-reveal { transform: none; opacity: 1; transition: none; }
  .fp-frames i { animation: none; }
}

/* Top bar <-> contents list. The visible motion is the flying copies (see the script); the real links only appear when they land. */
.fp-bar { transition: none; }
body.fp-scrolled .fp-bar { visibility: hidden; pointer-events: none; }

.fp-fly {
  position: fixed;
  left: 0;
  top: 0;
  visibility: hidden;
  margin: 0;
  font-family: var(--serif);
  font-size: 1.1rem;
  line-height: 1.4;
  color: var(--ink);
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;
  transform-origin: 0 0;
}

.fp-side {
  position: fixed;
  top: 50%;
  right: clamp(1rem, 3.5vw, 2.5rem);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.85rem;
  padding: 0.75rem 0.25rem 0.75rem 1rem;
  background: rgb(234 234 234 / 0.88);
  border-radius: 14px;
  background: transparent;
  visibility: hidden;
  transform: translate3d(0, -50%, 0);
  transition: background 0.4s ease;
}
body.fp-landed .fp-side { background: rgb(234 234 234 / 0.88); }
body.fp-landed .fp-side { visibility: visible; }
body.fp-moving .fp-side { visibility: hidden; }
body.fp-moving .fp-fly { visibility: visible; }
.fp-side a {
  position: relative;
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.4;
  color: var(--muted);
  text-decoration: none;
  opacity: 0;
  transition: color 0.3s ease;
}
/* The active item's text slides out to the left, and the line grows into the space it leaves at the margin. */
.fp-side a span { display: inline-block; transition: transform 0.6s cubic-bezier(.2,.7,.2,1); }
.fp-side a[aria-current="true"] span { transform: translate3d(-1.6rem, 0, 0); }
body.fp-landed .fp-side a { opacity: 1; }
.fp-side a::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 1.1rem;
  height: 1px;
  background: var(--ink);
  transform: translateY(-50%) scaleX(0);
  transform-origin: right;
  transition: transform 0.3s cubic-bezier(.2,.7,.2,1);
}
/* The line appears only after the text has slid out of its way. */
.fp-side a[aria-current="true"]::after { transition-delay: 0.3s; }
.fp-side a:hover,
.fp-side a[aria-current="true"] { color: var(--ink); }
.fp-bar .fp-nav a { line-height: 1.4; }
.fp-side a[aria-current="true"]::after { transform: translateY(-50%) scaleX(1); }
.fp-side a:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 2px; }

/* A hairline draws in across the top of each chapter as it reveals. The first chapter has none. */
.fp-chapter { position: relative; }
.fp-chapter::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--rule);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 1.1s cubic-bezier(.2,.7,.2,1);
}
.fp-chapter.in::before { transform: scaleX(1); }
.fp-chapter:first-of-type::before { display: none; }
@media (prefers-reduced-motion: reduce) { .fp-chapter::before { transition: none; } }

/* "Etusivu" on every subpage: a small outlined button in the header nav, so the way home is always visible. */
.home-btn {
  display: inline-block;
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 0.2rem 0.85rem;
  color: var(--ink) !important;
  text-decoration: none;
  transition: background 0.25s ease, color 0.25s ease;
}
.home-btn:hover, .home-btn:focus-visible { background: var(--ink); color: var(--bg) !important; }

/* "Alkuun" on the landing page: back to the top, shown once the contents list is showing. */
.fp-top {
  position: fixed;
  right: clamp(1rem, 3.5vw, 2.5rem);
  bottom: 1.75rem;
  z-index: 10;
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 0.35rem 0.95rem;
  background: rgb(234 234 234 / 0.9);
  color: var(--ink);
  font-size: 0.9375rem;
  text-decoration: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s, background 0.25s ease, color 0.25s ease;
}
body.fp-landed .fp-top { opacity: 1; visibility: visible; }
.fp-top:hover, .fp-top:focus-visible { background: var(--ink); color: var(--bg); }
