/* Shared white paper canvas. Load last; apply only to body.paper-site.
   Texture is a static SVG, painted below content rather than over artwork. */
body.paper-site{
 min-height:100svh;
 --paper:#fff;
 --paper-base:#fefefe;
 --paper-surface-image:url("paper-grain.svg"),
  radial-gradient(ellipse at 22% 31%,rgb(115 115 115 / .018),transparent 59%),
  linear-gradient(118deg,transparent 0 34%,rgb(125 125 125 / .018) 46.8%,rgb(255 255 255 / .68) 49.3%,transparent 61%);
 --paper-surface-size:160px 160px,100vw 100svh,100vw 100svh;
}

/* Opaque UI canvases and their small sticky/covering surfaces share one grain.
   Physical book planes, scanned pages, photos and cover artwork are excluded. */
body.paper-site,
body.paper-site dialog:not(.material-cover),
body.paper-site #about-view,
body.paper-site #group-view,
body.paper-site #viewer,
body.paper-site #view,
body.paper-site .view-wash,
body.paper-site .site-header,
body.paper-site .page-head,
body.paper-site .sheet-header,
body.paper-site .selection,
body.paper-site .article-cover,
body.paper-site .extract,
body.paper-site #group-view form,
body.paper-site #article-reader .reader-head,
body.paper-site #close-spread,
body.paper-site #status,
body.paper-site .wb-index h2,
body.paper-site #about-view .map-node,
body.paper-site .map-controls select,
body.paper-site .index-tools select,
body.paper-site .book-tools select,
body.paper-site input[type="search"],
body.paper-site select,
body.paper-site #dates,
body.paper-site .skip,
body.paper-site .skip-link,
body.paper-site .writing-footer,
body.paper-site.profile-page .page-footer,
body.paper-site .site-global-footer,
body.paper-site .site-global-footer::before,
body.paper-site.writing-v3::after,
body.paper-site.demo-b::after,
body.paper-site #group-view::after,
body.paper-site #about-view::backdrop,
body.paper-site #book-reader::backdrop,
body.paper-site #article-reader::backdrop{
 background-color:var(--paper-base);
 background-image:var(--paper-surface-image);
 background-size:var(--paper-surface-size);
 background-position:0 0,center top,0 0;
 background-repeat:repeat,no-repeat,no-repeat;
 background-attachment:fixed,fixed,fixed;
}

/* Missing legacy sections may opt into the same fixed footer geometry.
   Existing writing/opening/CV footers keep their own positioning rules. */
.paper-site .site-global-footer{
 position:fixed;left:3.15vw;right:3.15vw;bottom:3.8svh;z-index:4;
 display:flex;justify-content:space-between;align-items:flex-end;gap:24px;
 pointer-events:none;font-size:clamp(11px,.833333vw,16px);line-height:1.38;
 letter-spacing:.045em;
}
.paper-site .site-global-footer p{margin:0;white-space:nowrap}
.paper-site .site-global-footer nav{display:flex;gap:clamp(16px,2.1vw,42px);white-space:nowrap}
.paper-site .site-global-footer a{pointer-events:auto;font-weight:700;text-decoration:underline;text-underline-offset:.13em}
.paper-site .site-global-footer::before{
 content:"";position:fixed;inset:auto 0 0;height:76px;z-index:-1;pointer-events:none;
}
body.paper-site:has(>.site-global-footer){padding-bottom:110px}
@media(max-width:760px){
 .paper-site .site-global-footer{left:5vw;right:5vw;bottom:max(16px,env(safe-area-inset-bottom));height:3.5em}
 .paper-site .site-global-footer p{position:absolute;left:0;bottom:2em;font-size:9px}
 .paper-site .site-global-footer nav{position:absolute;right:0;bottom:0;gap:15px;font-size:10.5px}
 .paper-site .site-global-footer::before{height:140px}
 body.paper-site:has(>.site-global-footer){padding-bottom:180px}
}
@media print{
 body.paper-site{--paper-surface-image:none;--paper-base:#fff;min-height:0}
 body.paper-site:has(>.site-global-footer){padding-bottom:0}
 .paper-site .site-global-footer{display:none}
}
@media(forced-colors:active){body.paper-site{--paper-surface-image:none}}

/* Blend the two paper pages during a same-origin navigation. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition { pointer-events: none; }
  ::view-transition-group(root),
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 240ms;
    animation-timing-function: ease-in-out;
  }
  .page-fade-in body { animation: paper-arrival 180ms ease-out both; }
}
@keyframes paper-arrival { from { opacity: .45; } to { opacity: 1; } }

.paper-site .copyright-link {
  position: relative;
  margin-inline-start: .55em;
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  text-decoration: underline;
  text-underline-offset: .19em;
  pointer-events: auto;
  cursor: pointer;
}
.copyright-link::after { content: ''; position: absolute; inset: -.35em 0; }
#copyright-notice {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(28rem, 88vw);
  height: fit-content;
  max-height: 85svh;
  overflow: auto;
  box-sizing: border-box;
  padding: clamp(22px, 3.4vw, 38px);
  border: 1px solid #aaa;
  color: #222;
  font: 15px/1.75 system-ui, sans-serif;
  text-align: start;
}
#copyright-notice::backdrop { background: rgb(0 0 0 / .2); }
#copyright-notice h2 { margin: 0 0 1em; font-size: 1.25em; font-weight: 550; }
#copyright-notice p { margin: 0 0 1em; }
#copyright-notice a, #copyright-notice button { color: inherit; text-decoration: underline; text-underline-offset: .2em; }
#copyright-notice form { margin: 1.25em 0 0; text-align: end; }
#copyright-notice button { border: 0; background: none; padding: .3em; font: inherit; cursor: pointer; }

/* On small tablets keep the notice in the copyright column, clear of the player. */
@media (min-width: 701px) and (max-width: 900px) {
  .paper-site .copyright-link { display: block; width: fit-content; margin: .2em 0 0; }
  #world-entry:not(.world) #copyright .copyright-link { margin-inline: auto; }
}
@media (min-width: 701px) and (max-width: 760px) {
  .paper-site :is(.writing-footer, .site-global-footer) .copyright-link {
    display: inline-block;
    margin: 0 0 0 .55em;
  }
  #world-entry #copyright { font-size: 10px; }
}
@media (max-width: 700px) {
  .profile-page .sound-range { top: -60px; }
}

/* Leave the music controls room alongside the full contact address. */
@media (max-width: 360px) {
  .paper-site :is(.writing-footer, .site-global-footer) nav { gap: 10px; }
}
@media (min-width: 701px) and (max-width: 800px) {
  .profile-page .page-footer nav { gap: 13px; }
}

/* The switch occupies the original footer link. Modal readers keep the same
   action in their own toolbar while the page behind them is inert. */
[data-language-switch] { color:inherit; text-underline-offset:.2em; }
[data-language-switch]:focus-visible { outline:1px solid currentColor; outline-offset:3px; }
dialog [data-language-switch] { font:inherit; margin-inline:1em; white-space:nowrap; }
.reader-head [data-language-switch] { margin-inline-start:auto; }
#language-status { position:fixed; z-index:100; bottom:4em; left:4vw; padding:.5em; background:#fff; font:13px/1.5 system-ui; }
html:lang(en) .parallel-line, html:lang(en) .cv-page h2 > span[lang=en],
html:lang(en) .cv-page .english-name { display:none; }
html:lang(en) :is(#section-title,#label,#credit,.page-head,.reader-top,.article-read,.entry-body) { letter-spacing:normal; }
html:lang(en) :is(.article-read,.entry-body,.reader-more,.graph-index,.wb-index,.wb-info,.view-title) { overflow-wrap:anywhere; }
html:lang(en) #photo-view .view-title { white-space:normal; line-height:1.15; }
html:lang(en) :is(.article-read,.entry-body) p { line-height:1.75; }
@media(max-width:760px) {
  html:lang(en) #caption { width:min(89vw,38em); }
  html:lang(en) #note { margin-top:1em; line-height:1.5; letter-spacing:normal; }
  html:lang(en) #credit { margin-top:.55em; }
  html:lang(en) .reader-head { gap:.4em; }
  html:lang(en) .reader-head h2 { min-width:0; overflow-wrap:anywhere; }
}

/* Scale the visible print. The orbit and the books own their positioning and
   hit areas, and the photograph already open in the reader stays still. */
@media (prefers-reduced-motion: no-preference) {
  .paper-site :where(a[href], button:enabled) > img {
    transition: scale 180ms cubic-bezier(.2,.7,.3,1);
  }
  .paper-site :where(a[href], button:enabled):focus-visible > img,
  #orbit:focus-visible .card[data-center] > img { scale: 1.035; }
}
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .paper-site :where(a[href], button:enabled):hover > img { scale: 1.035; }
}
@media (prefers-reduced-motion: no-preference) {
  .paper-site :where(a[href], button:enabled):not(.card):active > img,
  #orbit .card[data-pressed] > img {
    scale: .985;
    transition-duration: 70ms;
  }
}
@media (prefers-reduced-motion: reduce) {
  .paper-site :where(a[href], button:enabled):not(.card):is(:focus-visible,:active) > img,
  #orbit .card[data-pressed] > img,
  #orbit:focus-visible .card[data-center] > img {
    outline: 1px solid currentColor;
    outline-offset: 2px;
  }
}
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: reduce) {
  .paper-site :where(a[href], button:enabled):hover > img {
    outline: 1px solid currentColor;
    outline-offset: 2px;
  }
}

/* Text controls pick up a light tint. Graph nodes and the book stack have
   their own ring/tilt, and disabled controls should stay visually quiet. */
@media (hover: hover) and (pointer: fine) {
  .paper-site :where(a[href], button:enabled, select:enabled, summary):not(:where(.map-node, .wb-stack-book, :has(> img), [aria-disabled="true"])):hover {
    box-shadow: inset 0 0 0 100vmax rgb(60 58 54 / .065);
  }
}
.paper-site :where(a[href], button:enabled, select:enabled, summary):not(:where(.map-node, .wb-stack-book, :has(> img), [aria-disabled="true"])):active {
  box-shadow: inset 0 0 0 100vmax rgb(60 58 54 / .13);
}
.paper-site :where(a[href], button:enabled, summary, select:enabled, input:enabled):focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}
#question-map .map-node:active .node-ring { opacity: 1; }

/* Two lines on compact screens: ownership first, listening and links together. */
@media screen and (max-width: 850px) {
  body.paper-site > footer:has(#sound-control) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    justify-content: stretch;
    gap: 4px;
    height: auto;
    padding: 0;
    margin: 0;
    left: 4vw;
    right: 4vw;
    bottom: max(12px, env(safe-area-inset-bottom));
  }
  body.paper-site > footer:has(#sound-control) > :is(#copyright, p, small) {
    position: static;
    transform: none;
    margin: 0;
    width: auto;
  }
  body.paper-site > footer:has(#sound-control) .copyright-link {
    display: inline-block;
    margin: 0 0 0 .5em;
  }
  body.paper-site > footer:has(#sound-control) > nav {
    position: static;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: clamp(8px, 2.5vw, 22px);
    transform: none;
    width: 100%;
    min-height: 25px;
    margin: 0;
    white-space: nowrap;
  }
  body.paper-site > footer nav > #sound-control {
    position: relative;
    inset: auto;
    transform: none;
    width: auto;
    height: auto;
    margin-inline-end: auto;
    color: inherit;
  }
  body.paper-site > footer .sound-label {
    position: relative;
    inset: auto;
    translate: none;
    height: 25px;
    justify-content: flex-start;
  }
  body.paper-site > footer .sound-range {
    inset: auto auto 100% 0;
    translate: none;
  }
}
