/* Plural site (moved from celestialsayuki.github.io/Camplus to celestialsayuki.com/plural). The page is the paper from the film 「海的尽头」: same tone, same graphite,
   the pencil's green as the only colour. Fonts and media come from promo/scripts/web_assets.py. */

@font-face { font-family: "Plural Serif SC"; src: url(fonts/serif-sc.woff2) format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Plural Garamond"; src: url(fonts/garamond.woff2) format("woff2"); font-weight: 400 600; font-display: swap; }
/* The home page's mark ("Celestial紗雪") uses the main site's own subsets, so it matches exactly. */
@font-face { font-family: "Sayuki Cormorant"; src: url(../assets/fonts/cormorant-italic.woff2) format("woff2"); font-weight: 300 700; font-style: italic; font-display: swap; }
@font-face { font-family: "Sayuki Mincho"; src: url(../assets/fonts/shippori.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plural Inter"; src: url(fonts/inter.woff2) format("woff2"); font-weight: 400 600; font-display: swap; }

:root {
  --paper: #f1ece1;          /* the film's paper */
  --ink: #282a30;            /* the film's wordmark */
  --ink-body: #383a40;
  --ink-2: #4e5056;          /* the film's tagline */
  --ink-3: #66676d;
  --rule: rgba(40, 42, 48, 0.16);
  --green: #2b5843;          /* the pencil */
  --green-deep: #1a3b2c;
  --en: "Plural Garamond", "Plural Serif SC", Georgia, serif;
  --zh: "Plural Serif SC", "Songti SC", "Noto Serif CJK SC", serif;
  --ja: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif CJK JP", serif;
  --zht: "Songti TC", "Noto Serif CJK TC", "PMingLiU", serif;
  --cjk: var(--zh);
  --sans: "Plural Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", sans-serif;
  --gutter: 16px;
  --bar: rgba(241, 236, 225, 0.72);
  --header: calc(env(safe-area-inset-top, 0px) + 64px);
  color-scheme: light;
}

/* Night: follows the system, or the choice made with the day/night button (shared with the home page). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1b1a16;          /* the same paper, at night under the lamp */
    --ink: #ece7dc;
    --ink-body: #d9d4c9;
    --ink-2: #bdb8ad;
    --ink-3: #8f8b82;
    --rule: rgba(236, 231, 220, 0.14);
    --green: #93c9ab;
    --green-deep: #b9e0c9;
    --bar: rgba(27, 26, 22, 0.72);
    color-scheme: dark;
    background-image: url(media/night/paper.jpg);   /* see the html rule below */
  }
}
:root[data-theme="dark"] {
  --paper: #1b1a16;          /* the same paper, at night under the lamp */
  --ink: #ece7dc;
  --ink-body: #d9d4c9;
  --ink-2: #bdb8ad;
  --ink-3: #8f8b82;
  --rule: rgba(236, 231, 220, 0.14);
  --green: #93c9ab;
  --green-deep: #b9e0c9;
  --bar: rgba(27, 26, 22, 0.72);
  color-scheme: dark;
  background-image: url(media/night/paper.jpg);   /* see the html rule below */
}

* { box-sizing: border-box; }
html {
  /* By day the paper is paper.jpg as it is, the tone the film was made on. At night it is media/night/paper.jpg:
     paper.jpg multiplied with the dark paper colour (#1b1a16), made ahead of time. It used to be
     background-blend-mode: multiply, but iOS 14.8's Safari doesn't paint that on the root (checked on a
     device), so the light paper showed through under light text. */
  background: var(--paper) url(media/paper.jpg) 0 0 / 512px repeat;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: var(--header);
  overscroll-behavior-y: none;   /* no rubber band past the top or bottom of the page */
  transition: background-color 0.6s;
}
body {
  margin: 0;
  color: var(--ink-body);
  transition: color 0.6s;
  font: 400 1.25rem/1.55 var(--en);
  -webkit-font-smoothing: antialiased;
  font-kerning: normal;
}
[lang="zh-Hans"] { --cjk: var(--zh); font-family: var(--cjk); }
[lang="ja"] { --cjk: var(--ja); font-family: var(--cjk); }
[lang="zh-Hant"] { --cjk: var(--zht); font-family: var(--cjk); }
img, video { max-width: 100%; }
picture { display: contents; }   /* wrappers for the night versions; layout is the img's */
.nw { white-space: nowrap; }
a { color: var(--green); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--green-deep); }
a:focus-visible, summary:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; border-radius: 4px; }
::selection { background: rgba(43, 88, 67, 0.18); }

/* ---- language: English unless the fragment is #zh, #ja or #zh-hant ---- */
.anchor { position: fixed; top: 0; left: 0; }   /* fixed: following a language link never scrolls the page */
.zh, .ja, .zht { display: none; }
body:has(:is(#zh, #ja, #zh-hant):target) .en { display: none; }
body:has(#zh:target) .zh, body:has(#ja:target) .ja, body:has(#zh-hant:target) .zht { display: revert; }
/* The same without :has() (Safari < 15.4): the inline script in <head> mirrors the fragment as a class on <html>. */
:root.no-has:is(.lang-zh, .lang-ja, .lang-zht) .en { display: none; }
:root.no-has.lang-zh .zh, :root.no-has.lang-ja .ja, :root.no-has.lang-zht .zht { display: revert; }

.top {
  /* Same place, size and behaviour as the home page's top bar: fixed, clear at the top,
     frosted once the page scrolls (site.js adds .solid). The mark doesn't move between pages. */
  position: fixed; inset: 0 0 auto 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) max(clamp(20px, 5vw, 56px), env(safe-area-inset-right)) 14px max(clamp(20px, 5vw, 56px), env(safe-area-inset-left));
}
/* The frosting fades in on its own layer: Safari can't animate backdrop-filter, it jumps from none to blurred. */
.top::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: var(--bar);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
  border-bottom: 1px solid var(--rule);
  opacity: 0; visibility: hidden;
  transition: opacity 0.5s var(--ease, ease), visibility 0s 0.5s;
}
.top.solid::before { opacity: 1; visibility: visible; transition: opacity 0.5s var(--ease, ease); }
.top-end { display: flex; align-items: center; gap: 6px; }
.theme {
  appearance: none; background: none; border: 0; cursor: pointer;
  display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border-radius: 999px;
  color: var(--ink-3); transition: color 0.3s, background-color 0.3s;
}
.theme:hover { color: var(--ink); background: var(--bar); }
.theme svg { grid-area: 1 / 1; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: opacity 0.5s, transform 0.6s cubic-bezier(0.2, 0.75, 0.15, 1); }
.theme .i-moon { opacity: 0; transform: rotate(-40deg) scale(0.7); }
:root[data-theme="dark"] .theme .i-sun { opacity: 0; transform: rotate(40deg) scale(0.7); }
:root[data-theme="dark"] .theme .i-moon { opacity: 1; transform: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme .i-sun { opacity: 0; transform: rotate(40deg) scale(0.7); }
  :root:not([data-theme="light"]) .theme .i-moon { opacity: 1; transform: none; }
}
.home {
  display: inline-flex; align-items: baseline; gap: 0;
  color: var(--ink); text-decoration: none; white-space: nowrap;
  view-transition-name: site-mark;
}
.home .mk-l { font: italic 400 1.22rem/1 "Sayuki Cormorant", var(--en); letter-spacing: 0.04em; }
.home .mk-k { font: 400 1.08rem/1 "Sayuki Mincho", var(--ja); letter-spacing: 0.16em; transition: color 0.4s; }
.home:hover { color: var(--ink); }
.home:hover .mk-k { color: var(--green); }
.langs { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px; font: 500 0.8rem/1 var(--sans); }
.langs [lang] { font-family: inherit; }
.langs a { color: var(--ink-3); text-decoration: none; padding: 8px 10px; }
.langs a:hover { color: var(--ink); }
.l-en, body:has(#zh:target) .l-zh, body:has(#ja:target) .l-ja, body:has(#zh-hant:target) .l-zht { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 6px; }
body:has(:is(#zh, #ja, #zh-hant):target) .l-en { color: var(--ink-3); text-decoration: none; }
/* the current language's link, without :has() */
:root.no-has.lang-zh .l-zh, :root.no-has.lang-ja .l-ja, :root.no-has.lang-zht .l-zht { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 6px; }
:root.no-has:is(.lang-zh, .lang-ja, .lang-zht) .l-en { color: var(--ink-3); text-decoration: none; }

/* ---- edges fade into the page, the way the film's frame has no edge ---- */
.feather {
  --fx: 5%; --fy: 7%;
  -webkit-mask-image:
    linear-gradient(90deg, transparent, #000 var(--fx), #000 calc(100% - var(--fx)), transparent),
    linear-gradient(transparent, #000 var(--fy), #000 calc(100% - var(--fy)), transparent);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(90deg, transparent, #000 var(--fx), #000 calc(100% - var(--fx)), transparent),
    linear-gradient(transparent, #000 var(--fy), #000 calc(100% - var(--fy)), transparent);
  mask-composite: intersect;
}

/* ---- hero ---- */
main { padding: calc(env(safe-area-inset-top, 0px) + 50px) max(var(--gutter), env(safe-area-inset-left)) 0; }
.hero { text-align: center; }
/* As wide as it can be while the name below still makes the first screen. */
.film {
  position: relative; aspect-ratio: 16 / 9; margin: 4px auto 0;
  width: min(100%, 1200px, max(640px, (100vh - 330px) * 16 / 9));
  width: min(100%, 1200px, max(640px, (100svh - 330px) * 16 / 9));
}
.film video, .film .still { display: block; width: 100%; height: 100%; object-fit: cover; }
.film .still { display: none; }
@media (prefers-reduced-motion: reduce) {
  .film video { display: none; }
  .film .still { display: block; }
}
.icon { display: block; width: 80px; height: 80px; margin: 20px auto 0; view-transition-name: plural-icon; }
.hero h1 { view-transition-name: plural-name; width: fit-content; margin-inline: auto; }
h1 {
  margin: 14px 0 0;
  font: 600 clamp(2.75rem, 6vw, 3.5rem)/1 var(--sans);
  letter-spacing: -0.01em;
  color: var(--ink);
}
.lede { max-width: 30rem; margin: 20px auto 0; font-size: 1.45rem; line-height: 1.45; color: var(--ink-2); }
.lede[lang] { max-width: 25em; font-size: 1.2rem; line-height: 1.85; letter-spacing: 0.03em; }
.get { margin: 30px 0 0; }
.store {
  display: inline-block;
  padding: 13px 24px;
  border: 1.5px solid var(--green);
  border-radius: 999px;
  color: var(--green);
  font: 500 1rem/1 var(--sans);
  text-decoration: none;
  transition: background-color 0.2s, color 0.2s;
}
.store [lang] { font-family: inherit; }
.store:hover { background: var(--green); color: var(--paper); }
.fine { margin: 16px 0 0; font: 400 0.85rem/1.7 var(--sans); color: var(--ink-3); }
.fine[lang] { font-family: var(--sans); letter-spacing: 0.02em; }

/* ---- sections ---- */
.part { max-width: 1040px; margin: clamp(104px, 14vw, 176px) auto 0; }
.sketch, .scene { position: relative; max-width: 960px; margin: 0 auto; }
.sketch { --fx: 2.2%; --fy: 4.5%; }
.scene { --fx: 9%; --fy: 11%; }
.sketch img, .scene img { display: block; width: 100%; height: auto; }
.sketch .ink { position: absolute; inset: 0; }
.words { max-width: 37rem; margin: 36px auto 0; }
.part > .words:first-child { margin-top: 0; }
h2 {
  margin: 0 0 16px;
  font: 500 2.125rem/1.15 var(--en);
  letter-spacing: -0.005em;
  color: var(--ink);
}
h2[lang] { font: 600 1.625rem/1.4 var(--cjk); letter-spacing: 0.04em; }
.words p { margin: 0 0 14px; }
p:is([lang="zh-Hans"], [lang="ja"], [lang="zh-Hant"]) { font-size: 1.0625rem; line-height: 1.95; letter-spacing: 0.02em; }
.more { margin-top: 20px; }

/* The film draws first and colours after; scrolling does the same where the browser can. */
@property --seep { syntax: "<percentage>"; inherits: false; initial-value: 150%; }
@keyframes seep { from { --seep: 0%; } to { --seep: 150%; } }
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .sketch .ink {
      mask-image: radial-gradient(ellipse 70% 90% at 50% 50%, #000 calc(var(--seep) - 40%), transparent var(--seep));
      animation: seep linear both;
      animation-timeline: view();
      animation-range: entry 70% cover 50%;
    }
  }
}

/* ---- formats ---- */
.specs dl { max-width: 37rem; margin: 28px auto 0; }
.row {
  display: grid; grid-template-columns: 8.5rem 1fr; gap: 0 20px;
  padding: 16px 0;
  border-top: 1px solid var(--rule);
}
.row:last-child { border-bottom: 1px solid var(--rule); }
dt { padding-top: 0.3em; font: 500 0.85rem/1.5 var(--sans); color: var(--ink-3); }
dt [lang] { font: 500 0.95rem/1.5 var(--cjk); letter-spacing: 0.06em; }
dd { margin: 0; }
dd p { margin: 0; font-size: 1.125rem; line-height: 1.5; }
dd p:is([lang="zh-Hans"], [lang="ja"], [lang="zh-Hant"]) { font-size: 1rem; line-height: 1.85; }

/* ---- questions ---- */
details { border-top: 1px solid var(--rule); }
details:last-of-type { border-bottom: 1px solid var(--rule); }
summary {
  position: relative;
  padding: 15px 36px 15px 0;
  list-style: none;
  cursor: pointer;
  font: 500 1.3rem/1.35 var(--en);
  color: var(--ink);
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "+";
  position: absolute; right: 6px; top: 50%; translate: 0 -50%;
  font: 400 1.4rem/1 var(--sans);
  color: var(--green);
}
details[open] summary::after { content: "−"; }
summary [lang] { font: 600 1.1rem/1.6 var(--cjk); letter-spacing: 0.03em; }
details p { margin: 0 0 18px; }

/* ---- contact, footer ---- */
.mail { margin-top: 22px; }
.mail a { font: 500 1.6rem/1.3 var(--en); text-decoration: none; border-bottom: 1px solid currentColor; }

.foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 24px;
  max-width: 1040px;
  margin: 128px auto 0;
  padding: 22px var(--gutter) max(32px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
  font: 400 0.85rem/1.6 var(--sans);
  color: var(--ink-3);
}
.foot p { margin: 0; }
.foot [lang] { font-family: var(--sans); }
.foot a { color: var(--ink-3); }
.foot a:hover { color: var(--ink); }

/* ---- privacy policy ---- */
.doc { max-width: 40rem; margin: 48px auto 0; }
.doc .back { font: 500 0.85rem/1 var(--sans); text-decoration: none; }
.doc .back [lang] { font-family: inherit; }
.doc h1 { margin: 28px 0 0; font: 500 2.75rem/1.1 var(--en); letter-spacing: -0.01em; text-align: left; }
.doc h1[lang] { font: 600 2.1rem/1.3 var(--cjk); letter-spacing: 0.04em; }
.doc .meta { margin: 12px 0 36px; font: 400 0.85rem/1.6 var(--sans); color: var(--ink-3); }
.doc .meta[lang] { font-family: var(--sans); }
.doc h2 { margin: 44px 0 12px; font-size: 1.6rem; }
.doc div[lang] { font-size: 1.0625rem; line-height: 1.95; letter-spacing: 0.02em; }
.doc div[lang] h2 { font: 600 1.3rem/1.5 var(--cjk); letter-spacing: 0.04em; margin-top: 44px; }
.doc p { margin: 0 0 14px; }
.doc ul { margin: 0 0 14px; padding-left: 1.1em; }
.doc li { margin: 0 0 12px; padding-left: 0.2em; }
.doc li::marker { color: var(--ink-3); }
.doc strong { color: var(--ink); font-weight: 600; }

@media (max-width: 640px) {
  .langs a { padding: 8px 7px; }
  body { font-size: 1.125rem; }
  .film { width: auto; margin-left: calc(-1 * var(--gutter)); margin-right: calc(-1 * var(--gutter)); }
  .lede { font-size: 1.25rem; }
  .lede[lang] { font-size: 1.075rem; }
  h2 { font-size: 1.75rem; }
  h2[lang] { font-size: 1.4rem; }
  .row { grid-template-columns: 1fr; padding: 14px 0; }
  dt { padding: 0 0 4px; }
  summary { font-size: 1.2rem; }
  .mail a { font-size: 1.35rem; }
  .doc h1 { font-size: 2.25rem; }
  .doc h1[lang] { font-size: 1.75rem; }
}

/* ---- moving between pages (see the home page's site.css; the two must agree) ---- */
@view-transition { navigation: auto; }
::view-transition-group(*) { animation-duration: 0.75s; animation-timing-function: cubic-bezier(0.2, 0.75, 0.15, 1); }
::view-transition-old(root) { animation: vt-leave 0.45s cubic-bezier(0.4, 0, 0.6, 1) both; }
::view-transition-new(root) { animation: vt-arrive 0.75s cubic-bezier(0.2, 0.75, 0.15, 1) 0.08s both; }
@keyframes vt-leave { to { opacity: 0; filter: blur(10px); transform: scale(0.985); } }
@keyframes vt-arrive { from { opacity: 0; filter: blur(10px); transform: scale(1.015); } }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
@media (max-width: 360px) {
  .home .mk-l { font-size: 1.08rem; }
  .home .mk-k { font-size: 0.96rem; letter-spacing: 0.1em; }
}

/* ---- night ----
   The drawings have night versions (media/night/, made by tools/night-media.py): light pencil on
   paper the colour of the night page, so they keep the same edgeless look as by day. */

/* ---------- switching language ----------
   The text swaps inside a view transition. The page behind stays put; each section is its own layer that glides to its new
   position and height while its words dissolve (the sections and pictures are named by script just for the moment, see lang.js). */
:root.lang-vt [data-vt] { view-transition-name: none; }
:root.lang-vt::view-transition-group(*) { animation-duration: 0.8s; animation-timing-function: cubic-bezier(0.22, 0.8, 0.2, 1); }
:root.lang-vt::view-transition-old(*), :root.lang-vt::view-transition-new(*) { height: 100%; object-fit: none; object-position: 0 0; } /* a section that changes height is moved, never stretched */
:root.lang-vt::view-transition-old(*) { animation: lang-out 0.5s linear both; }   /* same length, linear, added up (plus-lighter): what is the same in both stays solid, only the words dissolve */
:root.lang-vt::view-transition-new(*) { animation: lang-in 0.5s linear both; }
/* the words of a section: the old ones go first, then the new ones arrive (pictures are their own layers, so they stay solid) */
:root.lang-vt::view-transition-old(*.sec) { animation: lang-out 0.24s ease-in both; }
:root.lang-vt::view-transition-new(*.sec) { animation: lang-in 0.46s ease-out 0.2s both; }
:root.lang-vt::view-transition-old(root), :root.lang-vt::view-transition-new(root) { animation: none; }
/* the frosted header keeps its frosting: a layer in the transition can't see through to the sections moving under it by itself */
:root.lang-vt:has(header.solid)::view-transition-group(*.bar) { -webkit-backdrop-filter: blur(18px) saturate(150%); backdrop-filter: blur(18px) saturate(150%); }
@keyframes lang-out { to { opacity: 0; } }
@keyframes lang-in { from { opacity: 0; } }
