/* darna.app, set like the reader's first page: ink on paper, the title and the text in a 600-px column
   whose first line sits at a fifth of the screen. Sizes are the app's at its default text size
   (ReaderType at 22 pt). Plan: docs/plans/landing-page.md. */

@font-face {
  font-family: "Darna Serif";
  src: url("/fonts/source-serif-4-f2ea9c12d2fe9bd3.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  /* Optional, not swap: a late font would rewrap the paragraph under the reader. If it misses the
     first paint, Georgia stands in for that visit (nearly the same width at 22 px). */
  font-display: optional;
}

:root {
  --ink: 20 20 20;
  --paper: 252 252 252;
  /* The band, as ListenHighlight draws it in light mode. */
  --band-fill: 0.08;
  --band-ring: 0.2;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: 252 252 252;
    --paper: 20 20 20;
    --band-fill: 0.14;
    --band-ring: 0.26;
  }
}

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

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: rgb(var(--paper));
  color: rgb(var(--ink));
  /* New York in Safari on Apple devices; elsewhere an open serif close to it. */
  font-family: ui-serif, "Darna Serif", Georgia, serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.column {
  flex: 1;
  box-sizing: border-box;
  width: min(600px, 100% - 56px);
  margin: 0 auto;
  padding-top: 20svh;
}

h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 600;
  line-height: 1.25;
}

p {
  margin: 0;
  font-size: 22px;
  line-height: 1.6;
}

h1 + p,
h1 + .voiced {
  margin-top: 26px;
}

/* The band is drawn under the text and never moves a word. */
.voiced {
  position: relative;
}

.voiced p {
  position: relative;
}

.band {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}

.band div {
  position: absolute;
  border-radius: 6px;
  background: rgb(var(--ink) / var(--band-fill));
  box-shadow: inset 0 0 0 0.5px rgb(var(--ink) / var(--band-ring));
}

/* The listen control: the grey headphones with "Listen", or the small dot while the voice speaks. */
.listen-row {
  display: flex;
  justify-content: center;
  min-height: 48px;
  padding-top: 40px;
}

.listen {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 48px;
  min-height: 48px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: rgb(var(--ink) / 0.62);
  font: 500 15px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
  isolation: isolate;
  user-select: none;
  -webkit-user-select: none;
}

.listen:focus-visible {
  outline: 2px solid rgb(var(--ink));
  outline-offset: 2px;
}

/* On first load, before anyone has listened: a soft wash swells behind the control twice and the ink
   rises with it, then it rests. */
.listen::before {
  content: "";
  position: absolute;
  inset: 4px 0;
  border-radius: inherit;
  background: rgb(var(--ink) / 0.07);
  opacity: 0;
  z-index: -1;
  pointer-events: none;
}

.listen.beckon {
  animation: beckon 1.8s ease-in-out 2;
}

.listen.beckon::before {
  animation: beckon-wash 1.8s ease-in-out 2;
}

@keyframes beckon {
  0%, 100% { color: rgb(var(--ink) / 0.62); }
  40% { color: rgb(var(--ink) / 0.9); }
}

@keyframes beckon-wash {
  0% { opacity: 0; transform: scale(0.92); }
  40% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.06); }
}

.listen > span {
  grid-area: 1 / 1;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.2s ease-out, transform 0.32s cubic-bezier(0.3, 1.3, 0.5, 1);
}

.listen svg {
  display: block;
}

.listen .dot {
  width: 36px;
  height: 36px;
  justify-content: center;
  border-radius: 50%;
  background: rgb(var(--ink) / 0.06);
  box-shadow: inset 0 0 0 0.5px rgb(var(--ink) / 0.12);
  opacity: 0;
  transform: scale(0.6);
}

.listen.speaking .glyph {
  opacity: 0;
  transform: scale(0.8);
}

.listen.speaking .dot {
  opacity: 1;
  transform: none;
}

/* The waveform lights up bar by bar while the voice plays, like the app's variable-colour symbol. */
.dot rect {
  opacity: 0.45;
}

.listen.playing .dot rect {
  animation: wave 1.2s ease-in-out infinite;
}

.dot rect:nth-child(2) { animation-delay: 0.15s; }
.dot rect:nth-child(3) { animation-delay: 0.3s; }
.dot rect:nth-child(4) { animation-delay: 0.45s; }
.dot rect:nth-child(5) { animation-delay: 0.6s; }

@keyframes wave {
  0%, 60%, 100% { opacity: 0.45; }
  25% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .listen > span {
    transition: opacity 0.16s ease-out;
    transform: none !important;
  }

  .listen.playing .dot rect {
    animation: none;
    opacity: 1;
  }
}

footer {
  padding: 28px 16px calc(16px + env(safe-area-inset-bottom));
  text-align: center;
  color: rgb(var(--ink) / 0.62);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

footer a {
  color: inherit;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid rgb(var(--ink));
  outline-offset: 2px;
  border-radius: 2px;
}

/* /privacy, /support and the 404: plain reading pages in the same type. */
.reading .column {
  padding-bottom: 24px;
}

.reading p + p,
.reading ul + p,
.reading p + ul {
  margin-top: 16px;
}

.reading h2 {
  margin: 36px 0 10px;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.3;
}

.reading p,
.reading li {
  font-size: 19px;
  line-height: 1.55;
}

.reading ul {
  margin: 0;
  padding-left: 1.1em;
}

.reading li + li {
  margin-top: 8px;
}

.reading a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: rgb(var(--ink) / 0.35);
}

.muted {
  color: rgb(var(--ink) / 0.62);
}
