/* marrow.page
   The same paper, ink, gold and highlighter as the app (Theme.swift in the app).
   Dark is "night", light is warm paper. The switch at the top of the page picks one;
   until you use it, the page follows your system. */

:root {
  --paper: #1A1816;
  --ink: #E9E2D5;
  --ghost: rgba(233, 226, 213, 0.30);       /* words not yet typed */
  --slip: rgba(233, 226, 213, 0.64);        /* a letter you slipped on: the ink, a shade lighter */
  --gold: #D3A867;
  --quiet: rgba(233, 226, 213, 0.55);
  --hairline: rgba(233, 226, 213, 0.14);
  --mark: rgba(211, 168, 103, 0.30);        /* a marked passage, as a highlighter leaves it */
  --mark-deep: rgba(211, 168, 103, 0.50);
  --press: transparent;                     /* on paper only: a light edge under each letter */
  --grain: 0.22;                            /* how strongly the weave shows: barely there in the dark */
  --sheet: #23201D;                         /* the sheet the passage sits on: a shade lighter than the page */
  --sheet-grain: 0.24;
  --sheet-edge: rgba(233, 226, 213, 0.16);
  --sheet-shadow: inset 0 1px 0 rgba(233, 226, 213, 0.06), 0 30px 60px -28px rgba(0, 0, 0, 0.85), 0 3px 10px rgba(0, 0, 0, 0.35);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  color-scheme: dark;
}

:root[data-look="light"] {
  --paper: #EFE5D0;
  --ink: #2B2219;
  --ghost: rgba(43, 34, 25, 0.34);
  --slip: rgba(43, 34, 25, 0.70);
  --gold: #A9712C;
  --quiet: rgba(43, 34, 25, 0.58);
  --hairline: rgba(43, 34, 25, 0.14);
  --mark: rgba(224, 174, 69, 0.42);
  --mark-deep: rgba(217, 154, 43, 0.62);
  --press: rgba(255, 251, 242, 0.75);
  --grain: 0.86;                            /* Medium on paper, where the weave belongs */
  --sheet: #F7F0E0;
  --sheet-grain: 1;
  --sheet-edge: rgba(43, 34, 25, 0.16);
  --sheet-shadow: inset 0 1px 0 rgba(255, 251, 242, 0.9), 0 30px 60px -30px rgba(74, 52, 24, 0.5), 0 3px 10px rgba(74, 52, 24, 0.1);
  color-scheme: light;
}

/* Without JavaScript there is no switch, so follow the system. */
@media (prefers-color-scheme: light) {
  :root:not([data-look]) {
    --paper: #EFE5D0;
    --ink: #2B2219;
    --ghost: rgba(43, 34, 25, 0.34);
    --slip: rgba(43, 34, 25, 0.70);
    --gold: #A9712C;
    --quiet: rgba(43, 34, 25, 0.58);
    --hairline: rgba(43, 34, 25, 0.14);
    --mark: rgba(224, 174, 69, 0.42);
    --mark-deep: rgba(217, 154, 43, 0.62);
    --press: rgba(255, 251, 242, 0.75);
    --sheet: #F7F0E0;
    --sheet-edge: rgba(43, 34, 25, 0.16);
    --sheet-shadow: inset 0 1px 0 rgba(255, 251, 242, 0.9), 0 30px 60px -30px rgba(74, 52, 24, 0.5), 0 3px 10px rgba(74, 52, 24, 0.1);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html {
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.65;
  text-shadow: 0 1px 0 var(--press);        /* the type pressed into the paper */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- The grain ----------
   paper.js weaves the grain into a small picture of the paper (--weave-page) and of the sheet
   (--weave-sheet), and these rules tile them. Until the pictures are ready, and without
   JavaScript, the paper is its plain color. */

html {
  background-image: var(--weave-page, none);
  background-size: 256px 256px;
}
body { background: transparent; }

main {
  position: relative;
  z-index: 1;
  max-width: 38rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 6rem;
}

p { margin: 0 0 1.1em; }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--quiet);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover { text-decoration-color: var(--ink); }

/* ---------- Light or dark ----------
   One small button in the top-right corner of the page, apart from the centered column:
   a circle, half inked. Click it to turn the page over. */

.look {
  display: none;
  position: absolute;
  z-index: 2;
  top: calc(1.1rem + env(safe-area-inset-top, 0px));
  right: calc(1.1rem + env(safe-area-inset-right, 0px));
  padding: 0.5rem;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--quiet);
  line-height: 0;
  cursor: pointer;
  transition: color 0.15s ease, transform 0.35s ease;
}
.js .look { display: block; }
.look:hover { color: var(--ink); }
.look svg { display: block; }
:root[data-look="light"] .look { transform: rotate(180deg); }

/* ---------- The top ---------- */

/* The icon and the name side by side, centered, with the line under them. Kept short,
   so the sheet below is on screen when the page opens. */
.top {
  display: flex;
  flex-wrap: wrap;               /* icon and name on one line; the tagline takes a line of its own */
  justify-content: center;
  align-items: center;
  column-gap: 0.7rem;
  margin: 7vh 0 2.75rem;
  text-align: center;
}

.icon {
  display: block;
  width: 5rem;
  height: 5rem;
  margin: 0 0 0 -0.5rem;        /* the icon has clear space around it; this keeps icon and name looking centered together */
}

h1 {
  margin: 0;
  font-size: 3.1rem;
  font-weight: normal;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.lede {
  flex-basis: 100%;
  max-width: 32rem;
  margin: 1.1rem auto 0;
  text-wrap: balance;
  font-size: 1.4rem;
  line-height: 1.5;
  color: var(--quiet);
}

/* ---------- The line at the top ----------
   It sits on a sheet of its own: wider than the words around it, a shade lighter than the page,
   lifted a little, with its own grain. It types itself; nothing on it is clickable. */

.try { margin-bottom: 5.5rem; }

.sheet {
  position: relative;
  width: min(100vw - 2rem, 56rem);
  margin-left: 50%;
  transform: translateX(-50%);
  padding: 2.1rem 4rem 2.4rem;
  border: 1px solid var(--sheet-edge);
  border-radius: 18px;
  background: var(--sheet) var(--weave-sheet, none) 0 0 / 256px 256px;
  box-shadow: var(--sheet-shadow);
}

/* The book's name over the page, as the app has it. */
.sheet-title {
  position: relative;
  margin: 0 0 1.6rem;
  text-align: center;
  line-height: 1.35;
}
.sheet-title .book {
  display: block;
  font-size: 1.15rem;
  font-style: italic;
  color: var(--quiet);
}
.sheet-title .author {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--quiet);
  opacity: 0.8;
}

/* ", kinda" joins Thoreau's name once Rob's own words start to appear. */
.kinda { opacity: 0; transition: opacity 0.6s ease; }
.try.joking .kinda { opacity: 1; }

.page {
  margin: 0;
  font-size: 1.9rem;
  line-height: 1.75;
}

.inked { color: var(--ink); }
.slip  { color: var(--slip); }   /* a slipped letter, as in the Gatsby vignette */
.ghost { color: var(--ghost); text-shadow: none; }
.js .unsaid { opacity: 0; }   /* Rob's words take their room from the start, and appear only as they are typed */

/* The cursor: a thin bar before the next letter. It takes up no room. When the line is done it blinks. */
.caret { position: relative; }
.caret::after {
  content: "";
  position: absolute;
  left: -1px;
  top: 0.12em;
  width: 2px;
  height: 1.2em;
  background: var(--ink);
}
.try.done .caret::after { animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* The word the app is named for. Once it is typed, a highlighter is drawn across it,
   left to right, pressing a little harder at first and then easing off. */
.word {
  margin: 0 -0.16em;
  padding: 0.06em 0.16em;
  border-radius: 0.22em;
  background-image: linear-gradient(var(--mark), var(--mark));
  background-repeat: no-repeat;
  background-position: 0 55%;
  background-size: 0% 82%;
}
.word.lit {
  background-size: 100% 82%;
  animation: highlighter 1.5s cubic-bezier(0.3, 0.1, 0.25, 1) both;
}
@keyframes highlighter {
  0%   { background-size: 0% 82%;   background-image: linear-gradient(var(--mark-deep), var(--mark-deep)); }
  55%  { background-size: 100% 82%; background-image: linear-gradient(var(--mark-deep), var(--mark-deep)); }
  100% { background-size: 100% 82%; background-image: linear-gradient(var(--mark), var(--mark)); }
}

/* ---------- The words ---------- */

.words { margin: 0 0 3.5rem; }
.price { text-align: center; }   /* the price and small print are centered; the why and the feature sections read best left-aligned */
.words p:last-child { margin-bottom: 0; }

.why { font-size: 1.4rem; line-height: 1.6; }

/* Rob's handwritten signature, centered under the why. images/signature.png holds only the ink
   (made by tools/signature.swift from a photo); the page paints it in its own ink color,
   so it is dark on paper and light at night. */
.signature {
  width: 12rem;
  max-width: 60%;
  aspect-ratio: 800 / 378;
  margin: 1.6rem auto 0;
  background-color: var(--ink);
  -webkit-mask: url(images/signature.png) no-repeat center / contain;
  mask: url(images/signature.png) no-repeat center / contain;
}

h2 {
  margin: 0 0 0.7rem;
  text-wrap: balance;
  font-size: 1.7rem;
  font-weight: normal;
  line-height: 1.25;
  letter-spacing: -0.005em;
}

.small {
  font-size: 1rem;
  color: var(--quiet);
}

/* ---------- The buttons ---------- */

.buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8rem;
  margin: 0 0 5rem;
}
.price .buttons { margin: 1.6rem 0 1.2rem; }

.button {
  display: inline-block;
  padding: 0.62em 1.35em 0.68em;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 1.1rem;
  line-height: 1.3;
  text-decoration: none;
  text-shadow: none;
  transition: opacity 0.15s ease;
}
.button:hover { opacity: 0.86; }
.button.plain {
  border-color: var(--quiet);
  background: transparent;
  color: var(--ink);
}
.button.plain:hover { opacity: 1; border-color: var(--ink); }

/* ---------- Pictures of the app ---------- */

figure {
  /* well wider than the text, lifted off the page like the sheet, never wider than the window */
  width: min(100vw - 2rem, 60rem);
  margin: 2.5rem 0 5.5rem 50%;
  transform: translateX(-50%);
}

.shot {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--sheet-edge);
  border-radius: 12px;
  box-shadow: var(--sheet-shadow);
}

/* Each picture comes in dark and in light; only the one that matches the page is shown. */
.only-light { display: none; }
:root[data-look="light"] .only-light { display: block; }
:root[data-look="light"] .only-dark { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-look]) .only-light { display: block; }
  :root:not([data-look]) .only-dark { display: none; }
}

figcaption {
  width: min(100% - 1rem, 38rem);
  margin: 1.4rem auto 0;
  font-size: 1.2rem;
  line-height: 1.45;
  font-style: italic;
  text-align: center;
  text-wrap: balance;
  color: var(--ink);
}

/* ---------- Vignettes ----------
   In place of screenshots: a few words on a small sheet of the same paper as the passage
   at the top, set the way the app sets them. One idea each. */

.vignette {
  width: min(100%, 46rem);
  margin: 0 auto;
  padding: 2.1rem 3.6rem 2.4rem;
  border: 1px solid var(--sheet-edge);
  border-radius: 18px;
  background: var(--sheet) var(--weave-sheet, none) 0 0 / 256px 256px;
  box-shadow: var(--sheet-shadow);
}
.vignette .sheet-title { margin-bottom: 1.5rem; }

.v-text {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.6;
}
.v-caret::after { opacity: 1; animation: v-blink 1.1s steps(1) infinite; }
@keyframes v-blink { 50% { opacity: 0; } }

.v-lines {
  display: grid;
  gap: 0.15rem;
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.5;
}
.v-fainter { opacity: 0.55; }
.v-prompt {
  margin: 2rem 0 0;
  font-size: 1.1rem;
  font-style: italic;
  text-align: center;
  color: var(--quiet);
}
.v-progress {
  position: relative;
  width: 9rem;
  height: 2px;
  margin: 0.8rem auto 0;
  background: var(--hairline);
}
.v-progress span {
  position: absolute;
  inset: 0 66% 0 0;
  background: var(--ink);
  opacity: 0.7;
}

.v-mark {
  white-space: nowrap;
  padding: 0.04em 0.12em;
  border-radius: 0.2em;
  background: var(--mark);
  -webkit-box-decoration-break: clone;
          box-decoration-break: clone;
}
.v-menu {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  width: fit-content;
  max-width: 100%;
  flex-wrap: wrap;
  margin: 2rem auto 0;
  padding: 0.55rem 1.4rem;
  border: 1px solid var(--sheet-edge);
  border-radius: 999px;
  font-size: 1.02rem;
  color: var(--quiet);
}
.v-menu .v-on { color: var(--ink); }

/* ---------- But wait, there's more ----------
   A small card on the sheet's paper. Each line starts with a short gold bar,
   the text cursor from the app. Two columns where there is room, one on phones. */

.more {
  margin: 4.5rem 0 3.5rem;
  padding: 1.9rem 2.2rem 1.7rem;
  background: var(--sheet);
  border: 1px solid var(--sheet-edge);
  border-radius: 16px;
}
.more h2 { margin-bottom: 1.3rem; text-align: center; }
.more ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.1rem 2.2rem;
}
.more li {
  position: relative;
  padding-left: 1.05rem;
  font-size: 1.1rem;
  line-height: 1.5;
}
.more li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.22em;
  width: 2px;
  height: 1.1em;
  border-radius: 1px;
  background: var(--gold);
}
.and-more {
  margin: 1.4rem 0 0;
  text-align: center;
  font-style: italic;
  color: var(--quiet);
}

/* ---------- The bottom ---------- */

.price { margin-top: 5rem; }

footer {
  margin-top: 5rem;
  text-align: center;
  padding-top: 2rem;
  border-top: 1px solid var(--hairline);
  font-size: 1rem;
  color: var(--quiet);
}
footer p { margin: 0; }

/* ---------- Middling screens: the sheet's type comes down a step ---------- */

@media (max-width: 60rem) {
  .sheet { padding: 1.9rem 2.5rem 2.1rem; }
  .page { font-size: 1.6rem; }
}

/* ---------- Small screens ---------- */

@media (max-width: 40rem) {
  body { font-size: 1.125rem; }
  main { padding-top: 1.25rem; }
  h1 { font-size: 2.6rem; }
  h2 { font-size: 1.45rem; }
  .icon { width: 4.25rem; height: 4.25rem; margin-left: -0.42rem; }
  .top { margin: 3.75rem 0 2.25rem; column-gap: 0.55rem; }
  .look { top: calc(0.75rem + env(safe-area-inset-top, 0px)); right: calc(0.75rem + env(safe-area-inset-right, 0px)); }
  figure { margin-top: 2rem; }
  figcaption { font-size: 1.08rem; }
  .lede, .why { font-size: 1.22rem; }
  .sheet { padding: 1.4rem 1.25rem 1.6rem; border-radius: 14px; }
  .joke-break { display: none; }   /* on phones the line wraps where it wants */
  .sheet-title { margin-bottom: 1.2rem; }
  .sheet-title .book { font-size: 1.05rem; }
  .page { font-size: 1.3rem; }
  .try { margin-bottom: 4rem; }
  .buttons { margin-bottom: 4rem; }
  .button { font-size: 1.05rem; }
  figure { margin-bottom: 4rem; }
  .shot { border-radius: 8px; }
  .more { padding: 1.4rem 1.25rem 1.3rem; border-radius: 14px; }
  .vignette { padding: 1.5rem 1.3rem 1.7rem; border-radius: 14px; }
  .v-text, .v-lines { font-size: 1.32rem; }
  .v-menu { gap: 1rem; padding: 0.5rem 1rem; font-size: 0.92rem; }
  .more ul { grid-template-columns: 1fr; gap: 0.9rem; }
  .more li { font-size: 1.05rem; }
}

@media (prefers-reduced-motion: reduce) {
  .word.lit { animation: none; }
  .kinda { transition: none; }
  .try.done .caret::after { animation: none; }
  .v-caret::after { animation: none; }
  .look { transition: none; }
}
