/* ============================================================
   和紙繪本 · Washi picture book — the KITSUNE look, for the web.

   Tokens, the paper, the woodblock buttons and the brush mark are
   ported from the KITSUNE app (App/Kitsune/DesignSystem/KTokens.swift
   and Components/KControls.swift), so the site and the app share one
   palette. Two values are a step darker than the app on purpose, to
   pass WCAG AA on paper: --ink-2 and --kaki-text.

   The same file ships on opifex.software and kitsune.opifex.software.
   They deploy separately, so after any edit:
     cp public/assets/washi.css kitsune/assets/
   and bump ?v= on every page that links it.
   ============================================================ */

:root {
  color-scheme: light dark;

  /* paper */
  --paper: #F6EEDF;
  --paper-hi: #FFFBF3;
  --paper-lo: #EFE4D2;
  --paper-deep: #E6D7C0;
  --edge: #E3D2BA;
  --fibre: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='600'%3E%3Cpath fill='none' stroke='%23EADFCC' stroke-width='1.2' stroke-linecap='round' d='M38 529Q43 531 49 532M24 382Q30 381 35 379M483 533Q489 534 494 535M229 578Q235 577 240 576M211 514Q218 511 225 508M502 195Q512 196 520 200M250 379Q258 381 265 385M413 468Q423 465 431 461M39 413Q50 413 61 414M2 217Q5 216 9 216M315 409Q318 408 322 408M214 144Q223 142 231 139M588 439Q592 439 596 439M467 121Q478 122 488 124M46 294Q51 291 55 290M300 317Q308 317 315 319M258 30Q266 31 273 33M71 556Q80 558 88 560M108 266Q112 268 116 268M456 588Q461 589 467 589M47 477Q52 477 56 476M575 338Q585 338 594 338M244 299Q249 301 253 302M206 535Q210 538 213 539M366 530Q375 529 384 526M489 391Q492 393 495 393M104 559Q109 561 113 562M98 299Q104 300 109 302M97 124Q103 124 110 124M579 447Q584 445 588 444M513 140Q523 140 532 139M418 79Q425 77 431 76M209 599Q215 599 222 599M337 365Q346 366 355 368M64 355Q69 355 73 355M110 257Q116 259 121 261M553 321Q564 320 574 320M437 291Q440 291 444 291M94 445Q98 448 102 449M579 115Q584 116 590 116M324 524Q332 525 339 528M188 524Q192 522 197 521M307 510Q316 511 324 514M36 515Q44 517 50 520M67 26Q70 25 74 25M158 116Q169 116 180 116M101 392Q110 391 118 388M366 32Q370 32 374 32M44 373Q49 372 54 372M472 404Q483 405 494 406M14 123Q21 125 26 128M284 207Q292 208 301 209M512 103Q517 103 523 102M225 516Q231 515 237 514M184 153Q195 156 203 162'/%3E%3C/svg%3E");

  /* ink (sumi) */
  --ink: #3A2A1E;
  --ink-2: #735E4A;
  --ink-3: #A8957F;      /* decoration only: 2.6:1 on paper */

  /* kaki, persimmon */
  --kaki: #E3804A;
  --kaki-pressed: #C9683A;
  --kaki-edge: #B4572A;
  --kaki-soft: #FBE9DB;
  --kaki-muted: #F2C4A4;
  --kaki-text: #A34E24;
  --on-kaki: #FFFBF3;

  /* the other picture-book inks */
  --ai: #3E5C76;
  --ai-soft: rgb(143 170 196 / 0.2);
  --matcha: #6E9455;
  --matcha-text: #476A33;
  --matcha-soft: rgb(157 190 127 / 0.22);
  --beni: #C24E44;
  --beni-soft: rgb(224 122 110 / 0.16);
  --yamabuki: #D09A2E;
  --yamabuki-soft: rgb(232 182 74 / 0.22);
  --petal: #F0B8C4;

  --shadow-subtle: 0 2px 8px rgb(90 58 30 / 0.07);
  --shadow-lifted: 0 8px 22px rgb(90 58 30 / 0.12);

  /* type. Latin and Chinese stay in a rounded/system face; kana get
     Hiragino Maru Gothic, as in the app (it lacks many 繁體 glyphs, so
     it is never the face for Chinese text). */
  --font-ui: ui-rounded, "SF Pro Rounded", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  --font-kana: "Hiragino Maru Gothic ProN", "Hiragino Maru Gothic Pro", "Zen Maru Gothic", "M PLUS Rounded 1c", ui-rounded, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* space and shape: KSpacing / KRadius */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: clamp(56px, 2.5rem + 3vw, 88px);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;

  --wrap: 1120px;
  --narrow: 760px;
  --gutter: clamp(18px, 4vw, 40px);
  --measure: 34em;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #221C18;
    --paper-hi: #2D2520;
    --paper-lo: #372D27;
    --paper-deep: #40352D;
    --edge: #4D4036;
    --fibre: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='600'%3E%3Cpath fill='none' stroke='%232E2621' stroke-width='1.2' stroke-linecap='round' d='M38 529Q43 531 49 532M24 382Q30 381 35 379M483 533Q489 534 494 535M229 578Q235 577 240 576M211 514Q218 511 225 508M502 195Q512 196 520 200M250 379Q258 381 265 385M413 468Q423 465 431 461M39 413Q50 413 61 414M2 217Q5 216 9 216M315 409Q318 408 322 408M214 144Q223 142 231 139M588 439Q592 439 596 439M467 121Q478 122 488 124M46 294Q51 291 55 290M300 317Q308 317 315 319M258 30Q266 31 273 33M71 556Q80 558 88 560M108 266Q112 268 116 268M456 588Q461 589 467 589M47 477Q52 477 56 476M575 338Q585 338 594 338M244 299Q249 301 253 302M206 535Q210 538 213 539M366 530Q375 529 384 526M489 391Q492 393 495 393M104 559Q109 561 113 562M98 299Q104 300 109 302M97 124Q103 124 110 124M579 447Q584 445 588 444M513 140Q523 140 532 139M418 79Q425 77 431 76M209 599Q215 599 222 599M337 365Q346 366 355 368M64 355Q69 355 73 355M110 257Q116 259 121 261M553 321Q564 320 574 320M437 291Q440 291 444 291M94 445Q98 448 102 449M579 115Q584 116 590 116M324 524Q332 525 339 528M188 524Q192 522 197 521M307 510Q316 511 324 514M36 515Q44 517 50 520M67 26Q70 25 74 25M158 116Q169 116 180 116M101 392Q110 391 118 388M366 32Q370 32 374 32M44 373Q49 372 54 372M472 404Q483 405 494 406M14 123Q21 125 26 128M284 207Q292 208 301 209M512 103Q517 103 523 102M225 516Q231 515 237 514M184 153Q195 156 203 162'/%3E%3C/svg%3E");

    --ink: #F5ECDD;
    --ink-2: #C8B8A2;
    --ink-3: #8F7F6C;

    --kaki: #EC9050;
    --kaki-pressed: #E3804A;
    --kaki-edge: #C9683A;
    --kaki-soft: rgb(236 144 80 / 0.16);
    --kaki-muted: rgb(240 167 116 / 0.4);
    --kaki-text: #F0A774;
    --on-kaki: #221C18;

    --ai: #8FAAC4;
    --ai-soft: rgb(143 170 196 / 0.22);
    --matcha: #9DBE7F;
    --matcha-text: #9DBE7F;
    --beni: #E07A6E;
    --beni-soft: rgb(224 122 110 / 0.2);
    --yamabuki: #E8B64A;
    --yamabuki-soft: rgb(232 182 74 / 0.24);
    --petal: #C98C99;

    --shadow-subtle: 0 2px 8px rgb(0 0 0 / 0.22);
    --shadow-lifted: 0 10px 26px rgb(0 0 0 / 0.32);
  }
}

:root:lang(zh-Hans) { --font-ui: ui-rounded, "SF Pro Rounded", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif; }
:root:lang(en)      { --font-ui: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", system-ui, -apple-system, "PingFang TC", sans-serif; }

/* ---- 1. The sheet ---- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body.washi {
  margin: 0;
  min-height: 100vh;
  background-color: var(--paper);
  background-image: var(--fibre);
  background-size: 600px 600px;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "palt" 0;
}

.washi a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.washi img, .washi video { max-width: 100%; }
.washi :focus-visible { outline: 2.5px solid var(--kaki); outline-offset: 3px; border-radius: 6px; }
.washi ::selection { background: var(--kaki-muted); color: var(--ink); }

.wrap   { width: min(var(--wrap), calc(100% - 2 * var(--gutter))); margin-inline: auto; }
.narrow { width: min(var(--narrow), calc(100% - 2 * var(--gutter))); margin-inline: auto; }

.kana, :lang(ja) { font-family: var(--font-kana); }
.cn { font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif; font-style: normal; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 12px;
  z-index: 1000;
  padding: 10px 16px;
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--paper);
  font-size: 15px;
}
.skip-link:focus { left: 12px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- 2. Header and footer ---- */

.site-head {
  position: relative;
  z-index: 10;
  border-bottom: 1.2px solid var(--edge);
}
.site-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-5);
  min-height: 64px;
  padding-block: var(--s-2);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-decoration: none;
}
.brand img { display: block; width: 28px; height: 28px; }
.brand-sub { font-size: 14px; font-weight: 600; color: var(--ink-2); letter-spacing: 0; }

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 4px;
  margin-right: -10px;
}
.site-nav a {
  position: relative;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink-2);
  transition: color 0.15s ease, background-color 0.15s ease;
}
.site-nav a:hover { color: var(--ink); background: var(--kaki-soft); }
.site-nav a[aria-current="page"] { color: var(--ink); }
.site-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 3px;
  height: 5px;
  background: var(--kaki);
  opacity: 0.75;
  -webkit-mask: var(--brush) center / 100% 100% no-repeat;
          mask: var(--brush) center / 100% 100% no-repeat;
}
.nav-name { letter-spacing: 0.02em; }

/* A phone gets the brand on one row and four links on the next; the About
   anchor goes, since it is the home page's own section. */
@media (max-width: 480px) {
  .site-nav { gap: 0; margin-left: -8px; margin-right: 0; }
  .site-nav a { padding: 6px 8px; font-size: 14.5px; }
  .site-nav a[href$="#about"] { display: none; }
}

.site-foot {
  margin-top: var(--s-8);
  padding: var(--s-7) 0 var(--s-7);
  border-top: 1.2px solid var(--edge);
  font-size: 14.5px;
  color: var(--ink-2);
  text-align: center;
}
.foot-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px var(--s-5); margin-bottom: var(--s-4); }
.foot-links a { text-decoration: none; color: var(--ink-2); padding-block: 4px; }
.foot-links a:hover { color: var(--ink); text-decoration: underline; }
.site-foot p { margin: 0 0 var(--s-1); }
.site-foot p a { color: var(--ink-2); }

/* ---- 3. The brush mark ----
   BrushStroke from KControls.swift: thick in the middle, tapering at both
   ends, with a slight lift. Drawn as a mask so it takes any ink. */

:root {
  --brush: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 5' preserveAspectRatio='none'%3E%3Cpath d='M0 3.25C7 -0.5 19.6 0 28 1.5C19.6 5.5 7 5 0 3.25Z'/%3E%3C/svg%3E");
}

.brush {
  display: block;
  width: 36px;
  height: 6px;
  background: var(--kaki);
  opacity: 0.75;
  -webkit-mask: var(--brush) center / 100% 100% no-repeat;
          mask: var(--brush) center / 100% 100% no-repeat;
}

/* A section opens with a small title and a brush stroke under it. */
.section-mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 0 0 var(--s-4);
  text-align: center;
}
.section-mark > * {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.08em;
  color: var(--kaki-text);
}
.section-mark::after {
  content: "";
  display: block;
  width: 40px;
  height: 7px;
  background: var(--kaki);
  opacity: 0.75;
  -webkit-mask: var(--brush) center / 100% 100% no-repeat;
          mask: var(--brush) center / 100% 100% no-repeat;
}
.section-mark--start { align-items: flex-start; text-align: left; }
.section-mark--sub > * { font-size: 17px; letter-spacing: 0.02em; color: var(--ink); }

/* ---- 4. Type ---- */

/* Chinese headings break at punctuation and spaces, not inside a word
   (筆｜順). overflow-wrap still breaks a run that cannot fit. */
.washi :is(h1, h2, h3, h4, .headline, .display-2, .k-sub) {
  word-break: keep-all;
  overflow-wrap: anywhere;
  line-break: strict;
}

.kicker {
  margin: 0 0 var(--s-3);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--kaki-text);
  text-align: center;
}
.headline {
  max-width: 18em;
  margin: 0 auto;
  font-size: clamp(2rem, 1.3rem + 3vw, 3.4rem);
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -0.01em;
  text-align: center;
  text-wrap: balance;
}
.headline:lang(zh-Hant), .headline:lang(zh-Hans) { letter-spacing: 0.01em; line-height: 1.3; }
.deck {
  max-width: var(--measure);
  margin: var(--s-4) auto 0;
  font-size: 19px;
  line-height: 1.65;
  text-align: center;
  text-wrap: balance;
  color: var(--ink-2);
}
.display-2 {
  max-width: 20em;
  margin: 0 auto var(--s-6);
  font-size: clamp(1.6rem, 1.2rem + 1.7vw, 2.5rem);
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  text-wrap: balance;
}
.headline em, .display-2 em { font-style: normal; color: var(--kaki-text); }

.stamp {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
/* Live status: a matcha dot, and the words say it too. */
.stamp-live { color: var(--matcha-text); }
.stamp-live::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: 1px;
}
.stamp-soon { color: var(--kaki-text); }

/* A pill label, like KBadge. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--kaki-soft);
  color: var(--kaki-text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
}

/* ---- 5. Buttons ----
   Woodblock print: a darker edge below the face; pressing sinks the face
   onto it, like a stamp. The primary face keeps the app's cream-on-kaki,
   which is 3.1:1, so its label is set large and bold (WCAG large text). */

.btn-wood,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px 24px;
  border: 0;
  border-radius: var(--r-lg);
  font: inherit;
  font-weight: 700;
  line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease-out, box-shadow 0.15s ease-out, background-color 0.15s ease-out;
}
.washi .btn-wood {
  margin-bottom: 4px;
  background: var(--kaki);
  color: var(--on-kaki);
  font-size: 19px;
  box-shadow: 0 4px 0 var(--kaki-edge);
}
.washi .btn-wood:hover { background: var(--kaki-pressed); }
.washi .btn-wood:active { transform: translateY(4px); box-shadow: 0 0 0 var(--kaki-edge); }

.washi .btn {
  margin-bottom: 3px;
  background: var(--paper-hi);
  color: var(--kaki-text);
  font-size: 17px;
  box-shadow: inset 0 0 0 1.2px var(--edge), 0 3px 0 var(--edge);
}
.washi .btn:hover { background: var(--kaki-soft); }
.washi .btn:active { transform: translateY(3px); box-shadow: inset 0 0 0 1.2px var(--edge), 0 0 0 var(--edge); }

/* A woodblock that is not a link yet (e.g. before an App Store launch). */
.washi .btn-wood[aria-disabled="true"] { cursor: default; }
.washi .btn-wood[aria-disabled="true"]:hover { background: var(--kaki); }
.washi .btn-wood[aria-disabled="true"]:active { transform: none; box-shadow: 0 4px 0 var(--kaki-edge); }

.btn-icon { display: block; width: 34px; height: 34px; border-radius: 22.4%; }
.btn-text { display: block; text-align: left; }
.btn-lead { display: block; font-size: 12.5px; font-weight: 600; letter-spacing: 0.04em; opacity: 0.85; }

/* ---- 6. Paper cards ----
   kCard: lighter paper with a 1.2pt deckle edge. */

.paper-card {
  background: var(--paper-hi);
  border-radius: var(--r-lg);
  box-shadow: inset 0 0 0 1.2px var(--edge), var(--shadow-subtle);
}

/* A whole band of slightly deeper paper. */
.band {
  padding-block: var(--s-8);
  background-color: var(--paper-lo);
  background-image: var(--fibre);
  background-size: 600px 600px;
  border-block: 1.2px solid var(--edge);
}

.section { padding-block: var(--s-8); }
.section + .section { padding-top: 0; }

/* ---- 7. Motion ----
   The hidden state exists only under html.js, so a page with no script is
   complete; the whole set sits inside no-preference. */

@keyframes washi-rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
@keyframes petal-fall {
  0%   { transform: translate(0, -10vh) rotate(0deg); opacity: 0; }
  10%  { opacity: 0.9; }
  90%  { opacity: 0.9; }
  100% { transform: translate(-60px, 110vh) rotate(260deg); opacity: 0; }
}
@keyframes kitsu-breathe {
  0%, 100% { transform: scale(1, 1); }
  50%      { transform: scale(1.012, 0.99); }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  .js .reveal {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.7s cubic-bezier(0.16, 0.84, 0.3, 1),
                transform 0.7s cubic-bezier(0.16, 0.84, 0.3, 1);
    transition-delay: var(--reveal-delay, 0s);
  }
  .js .reveal.is-in { opacity: 1; transform: none; }
}

@media print {
  body.washi { background: #fff; color: #000; }
  .site-nav, .skip-link { display: none; }
}
