/*
 * Tsuzuki: the home page is the book's cover (indigo, with 続き set vertically like a
 * light novel); privacy and support are pages inside it (paper, indigo ink). The gold
 * ribbon is the app icon's bookmark: it drops in once, then grows as you read down.
 */

@font-face {
  font-family: 'Shippori Mincho';
  src: url('/fonts/ShipporiMincho-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Shippori Mincho';
  src: url('/fonts/ShipporiMincho-ExtraBold.woff2') format('woff2');
  font-weight: 800;
  font-display: swap;
}
@font-face {
  font-family: 'Zen Kaku Gothic New';
  src: url('/fonts/ZenKakuGothicNew-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Zen Kaku Gothic New';
  src: url('/fonts/ZenKakuGothicNew-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  /* From the app icon */
  --indigo: #232e6e;
  --washi: #fbf8f1;
  --gold: #e5a93b;
  /* Pages */
  --paper: #fcfcfd;
  --ink: #1b2350;
  --ink-soft: #545b7e;
  --rule: #dfe1ec;
  --link: #2c3c9c;
  --on-indigo-soft: #c3c7e2;

  --serif: 'Shippori Mincho', 'Hiragino Mincho ProN', 'Yu Mincho', serif;
  --sans: 'Zen Kaku Gothic New', -apple-system, 'Hiragino Sans', 'Segoe UI', sans-serif;
  --measure: 36rem;
  --gutter: clamp(20px, 5vw, 48px);
  /* Room kept clear for the ribbon on the right */
  --ribbon-lane: 56px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141a42;
    --ink: #eceaf4;
    --ink-soft: #aeb2cf;
    --rule: #2b3367;
    --link: #f0bf63;
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.75 var(--sans);
  font-feature-settings: 'palt';
}

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

h1,
h2 {
  font-family: var(--serif);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.005em;
  margin: 0;
}
h2 {
  font-weight: 700;
  font-size: 1.5rem;
}
p {
  margin: 0 0 1em;
}

.skip {
  position: absolute;
  left: -999px;
}
.skip:focus {
  left: var(--gutter);
  top: 12px;
  z-index: 3;
  background: var(--washi);
  color: var(--indigo);
  padding: 6px 10px;
}

/* ---------- The ribbon ---------- */

.ribbon {
  position: fixed;
  top: 0;
  right: clamp(18px, 4vw, 44px);
  z-index: 2;
  width: 18px;
  height: 104px;
  background: var(--gold);
  /* A bookmark's notched end */
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 9px), 0 100%);
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  .ribbon {
    animation: ribbon-drop 900ms cubic-bezier(0.2, 1.3, 0.4, 1) 250ms both;
  }
  /* Where the browser can tie an animation to scrolling, the ribbon lengthens as you read. */
  @supports (animation-timeline: scroll()) {
    .ribbon {
      animation:
        ribbon-drop 900ms cubic-bezier(0.2, 1.3, 0.4, 1) 250ms both,
        ribbon-read linear both;
      animation-timeline: auto, scroll(root);
    }
  }
}

@keyframes ribbon-drop {
  from {
    transform: translateY(-104px);
  }
  to {
    transform: translateY(0);
  }
}
@keyframes ribbon-read {
  from {
    height: 104px;
  }
  to {
    height: 62vh;
  }
}

/* ---------- Home: the cover ---------- */

.cover {
  position: relative;
  min-height: 100svh;
  background: var(--indigo);
  color: var(--washi);
  padding: 28px calc(var(--gutter) + var(--ribbon-lane)) clamp(40px, 8vh, 72px) var(--gutter);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 1fr auto;
  /* Phone: the title stands at the top right, the words run full width below it. */
  grid-template-areas:
    'mark  title'
    '.     title'
    'text  text';
  column-gap: clamp(16px, 6vw, 96px);
  row-gap: 32px;
  overflow: hidden;
}
@media (min-width: 820px) {
  /* Wider: words at the bottom left, the title down the right like a spine. */
  .cover {
    grid-template-areas:
      'mark  .'
      '.     title'
      'text  title';
  }
}

.wordmark {
  grid-area: mark;
  font: 700 1.125rem/1 var(--serif);
  letter-spacing: 0.02em;
  color: inherit;
  text-decoration: none;
}

/* .cover .title, not .title: it must outrank `.cover p` below. */
.cover .title {
  grid-area: title;
  align-self: start;
  margin: 0;
  writing-mode: vertical-rl;
  font: 800 clamp(7.5rem, 30vw, 17rem) / 1 var(--serif);
  letter-spacing: 0.04em;
  color: var(--washi);
}
.cover .title ruby {
  ruby-align: center;
}
.cover .title rt {
  font: 700 0.13em/1 var(--serif);
  letter-spacing: 0.2em;
  color: var(--gold);
}

.cover-text {
  grid-area: text;
  align-self: end;
  max-width: 30rem;
}
.cover h1 {
  font-size: clamp(2.5rem, 6.4vw, 4.75rem);
  line-height: 1.04;
  margin-bottom: 0.45em;
  max-width: 11ch;
}
.cover p {
  color: var(--on-indigo-soft);
  font-size: 1.125rem;
  max-width: 28rem;
}
.cover .soon {
  color: var(--washi);
  margin: 1.4em 0 0;
}

/* ---------- Home: inside pages ---------- */

.inside {
  padding: clamp(56px, 10vw, 112px) calc(var(--gutter) + var(--ribbon-lane)) 0 var(--gutter);
  max-width: calc(68rem + var(--ribbon-lane));
  margin: 0 auto;
}

/* A working sample of the reader: its four themes and text size, as in the app */
.specimen {
  display: grid;
  gap: clamp(28px, 5vw, 72px);
  align-items: center;
}
@media (min-width: 860px) {
  .specimen {
    grid-template-columns: minmax(0, 1fr) minmax(0, 25rem);
  }
}
.specimen h2 {
  font-size: clamp(1.75rem, 3.6vw, 2.5rem);
  margin-bottom: 0.6em;
  max-width: 14ch;
}
.specimen-copy p {
  max-width: 30rem;
}
.specimen-note {
  color: var(--ink-soft);
  font-size: 0.9375rem;
}

.reader {
  margin: 0;
  /* Set per theme by the buttons; Sepia to start */
  --page: #f4ecd8;
  --page-text: #5b4636;
  --page-muted: #735e4a;
  --page-chrome: #e9dec3;
  --page-size: 18px;
  border-radius: 22px;
  overflow: hidden;
  background: var(--page);
  color: var(--page-text);
  box-shadow: 0 0 0 1px var(--rule);
}
.reader[data-theme='light'] {
  --page: #ffffff;
  --page-text: #1c1c1e;
  --page-muted: #6e6e73;
  --page-chrome: #f2f2f7;
}
.reader[data-theme='dark'] {
  --page: #121212;
  --page-text: #d8d8d8;
  --page-muted: #8e8e93;
  --page-chrome: #1f1f21;
}
.reader[data-theme='black'] {
  --page: #000000;
  --page-text: #c7c7c7;
  --page-muted: #7c7c80;
  --page-chrome: #141414;
}
@media (prefers-reduced-motion: no-preference) {
  .reader,
  .reader-page {
    transition:
      background-color 250ms ease,
      color 250ms ease,
      font-size 150ms ease;
  }
}

.reader-controls {
  display: none;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  padding: 12px;
  background: var(--page-chrome);
}
.js .reader-controls {
  display: flex;
}
.reader-controls button {
  font: 400 0.9375rem/1 var(--sans);
  color: var(--page-text);
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 9px 12px;
  min-height: 36px;
  cursor: pointer;
}
.reader-controls button[aria-pressed='true'] {
  background: var(--page);
  font-weight: 700;
}
.reader-controls .size {
  margin-left: auto;
}
.reader-controls .size + .size {
  margin-left: 0;
}
/* Phones: all six buttons on one row */
@media (max-width: 420px) {
  .reader-controls {
    gap: 0;
    padding: 10px 8px;
  }
  .reader-controls button {
    padding: 9px 6px;
    font-size: 0.875rem;
  }
}

.reader-page {
  font: 400 var(--page-size) / 1.6 ui-serif, 'New York', Georgia, 'Times New Roman', serif;
  padding: 24px 24px 8px;
  height: 21rem;
  overflow: hidden;
  /* The story carries on past the bottom of the page */
  -webkit-mask-image: linear-gradient(#000 70%, transparent);
  mask-image: linear-gradient(#000 70%, transparent);
}
.reader-page h3 {
  font: inherit;
  font-weight: 700;
  margin: 0 0 1em;
}
.reader-page p {
  margin: 0 0 0.8em;
}
.reader-bar {
  margin: 0;
  padding: 10px 16px 14px;
  text-align: center;
  font: 400 0.8125rem/1.3 var(--sans);
  color: var(--page-muted);
}

/* Two plain sections under the sample */
.more {
  display: grid;
  gap: clamp(32px, 5vw, 56px) clamp(32px, 6vw, 80px);
  margin-top: clamp(72px, 12vw, 136px);
}
@media (min-width: 720px) {
  .more {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.more h2 {
  font-size: 1.375rem;
  margin-bottom: 0.5em;
}
.more p {
  max-width: 32rem;
  margin: 0 0 0.9em;
}
.more .follow {
  margin-top: 1.6em;
}

.end {
  margin-top: clamp(72px, 12vw, 136px);
  padding: 28px 0 48px;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  font-size: 0.9375rem;
  color: var(--ink-soft);
}

/* ---------- Pages inside: privacy and support ---------- */

.page-head {
  padding: 28px calc(var(--gutter) + var(--ribbon-lane)) 0 var(--gutter);
  max-width: calc(var(--measure) + var(--gutter) * 2 + var(--ribbon-lane));
  margin: 0 auto;
}
.page-head a {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font: 700 1.125rem/1 var(--serif);
}
.page-head .seal {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--indigo);
  color: var(--washi);
  font: 800 1.3rem/1 var(--serif);
  /* Keeps its edge on the dark page, which is also indigo */
  box-shadow: inset 0 0 0 1px rgba(251, 248, 241, 0.18);
}

.page {
  padding: clamp(40px, 8vw, 72px) calc(var(--gutter) + var(--ribbon-lane)) 0 var(--gutter);
  max-width: calc(var(--measure) + var(--gutter) * 2 + var(--ribbon-lane));
  margin: 0 auto;
}
.page h1 {
  font-size: clamp(2.25rem, 6vw, 3.25rem);
  margin-bottom: 0.3em;
}
.page .updated,
.page .lead {
  color: var(--ink-soft);
}
.page .lead {
  font-size: 1.1875rem;
}
.page h2 {
  font-size: 1.3125rem;
  margin: 2.2em 0 0.5em;
}
.page .end {
  margin-top: 64px;
}
