/*
 * Mugful: a pencil sketchbook. Same tokens as src/constants/theme.ts in the app:
 * oatmeal paper and graphite-brown ink by day, dark kraft and chalky pencil by lamplight.
 */

@font-face {
  font-family: 'Gaegu';
  font-weight: 700;
  font-display: swap;
  src: url('fonts/gaegu-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Shantell Sans';
  font-weight: 400 600;
  font-display: swap;
  src: url('fonts/shantell-sans-latin.woff2') format('woff2');
}

:root {
  color-scheme: light dark;
  --paper: #ece4d3;
  --paper-2: #e1d6c0;
  --paper-3: #d5c7ac;
  --card: rgba(255, 252, 244, 0.5);
  --text: #3b2e26;
  --muted: #6e5e51;
  --line: #c9b99d;
  --ink: #4a3a2e;
  --primary: #536e45;
  --on-primary: #f7f2e7;
  --coffee: #a4512f;
  --kcal: #8e671c;
  --water: #43709d;
  --sugar: #a2566f;
  --grain: url('paper-grain.png');

  --display: 'Gaegu', 'Shantell Sans', 'Comic Sans MS', cursive;
  --hand: 'Shantell Sans', ui-rounded, system-ui, sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --wrap: 1160px;
  --gutter: clamp(16px, 4vw, 40px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #2b241d;
    --paper-2: #3a3027;
    --paper-3: #4a3d31;
    --card: rgba(255, 240, 214, 0.05);
    --text: #efe5d2;
    --muted: #bbac96;
    --line: #56483a;
    --ink: #d9cbb1;
    --primary: #a2bd88;
    --on-primary: #1f2a17;
    --coffee: #e39a75;
    --kcal: #e2bf6c;
    --water: #93b6db;
    --sugar: #dea2b6;
    --grain: url('paper-grain-dark.png');
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  background: var(--paper) var(--grain);
  font: 400 1.125rem/1.6 var(--hand);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--coffee);
  overflow-x: hidden;
}

::selection {
  background: var(--primary);
  color: var(--on-primary);
}

html {
  scrollbar-color: var(--paper-3) var(--paper);
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--primary);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}
a:hover {
  text-decoration-style: wavy;
}

:focus-visible {
  outline: 2.5px dashed var(--primary);
  outline-offset: 4px;
  border-radius: 10px;
}

h1,
h2,
h3 {
  font-family: var(--display);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin: 0;
}

p {
  margin: 0;
  text-wrap: pretty;
}

.wrap {
  width: 100%;
  max-width: calc(var(--wrap) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 10;
  padding: 8px 14px;
  background: var(--primary);
  color: var(--on-primary);
  border-radius: 12px;
}
.skip:focus {
  top: 12px;
}

/* ---------- Pencil layers drawn by sketch.js ---------- */

[data-sketch],
[data-mark],
[data-scribble] {
  position: relative;
  isolation: isolate;
}

/* Without the script, plain outlines stand in for the drawn ones. */
html:not(.js) [data-sketch] {
  border: 1.6px solid var(--ink);
  border-radius: 18px 14px 20px 16px;
  background: var(--sk-fill, var(--card));
}

svg.sk {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: visible;
  pointer-events: none;
}
.sk-fill {
  fill: var(--sk-fill, var(--card));
}
.sk-hatch {
  fill: none;
  stroke: var(--sk-hatch, var(--coffee));
  stroke-width: 1.3;
  stroke-linecap: round;
  opacity: 0.5;
}
.sk-stroke,
.sk-ghost {
  fill: none;
  stroke: var(--sk-ink, var(--ink));
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sk-stroke {
  opacity: 0.9;
  stroke-dasharray: 1;
}
.sk-ghost {
  opacity: 0.35;
}

svg.mk {
  position: absolute;
  left: -6px;
  bottom: 2%;
  width: calc(100% + 12px);
  height: 56%;
  z-index: -1;
  overflow: visible;
  pointer-events: none;
}
.mk-tint {
  fill: var(--coffee);
  opacity: 0.14;
}
.mk-hatch {
  fill: none;
  stroke: var(--coffee);
  stroke-width: 2.4;
  stroke-linecap: round;
  opacity: 0.62;
}

svg.sc {
  position: absolute;
  left: 0;
  bottom: -14px;
  height: 10px;
  overflow: visible;
  pointer-events: none;
}
.sc-a,
.sc-b {
  fill: none;
  stroke: var(--primary);
  stroke-linecap: round;
  stroke-dasharray: 1;
}
.sc-a {
  stroke-width: 3.4;
}
.sc-b {
  stroke-width: 2.2;
  opacity: 0.55;
}

/* Arrival: the pencil draws the outline, then the shading goes in. */
@keyframes draw {
  from {
    stroke-dashoffset: 1;
  }
  to {
    stroke-dashoffset: 0;
  }
}
@keyframes shade {
  from {
    opacity: 0;
  }
}
@keyframes colour-in {
  from {
    clip-path: inset(0 100% 0 0);
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}

.wait:not(.in) :is(.sk-stroke, .sc-a, .sc-b, .ch-curve) {
  stroke-dashoffset: 1;
}
.wait:not(.in) :is(.sk-ghost, .sk-hatch, .sk-fill, .mk, .ch-hatch, .ch-tint, .ch-note) {
  opacity: 0;
}
.wait.in .sk-stroke {
  animation: draw 1.1s var(--ease) both;
}
.wait.in :is(.sk-fill, .sk-ghost) {
  animation: shade 0.6s var(--ease) both;
}
.wait.in .sk-hatch {
  animation: shade 0.9s 0.35s var(--ease) both;
}
.wait.in .sc-a {
  animation: draw 0.9s 0.15s var(--ease) both;
}
.wait.in .sc-b {
  animation: draw 0.9s 0.35s var(--ease) both;
}
.wait.in svg.mk {
  animation: colour-in 1.3s 0.45s var(--ease) both;
}

/* ---------- Header and footer ---------- */

.site-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding-block: 10px;
}
.brand {
  display: block;
  flex: none;
  border-radius: 12px;
}
.brand .logo {
  width: 150px;
  height: auto;
}
.site-head nav {
  display: flex;
  gap: clamp(14px, 3vw, 28px);
  font-size: 1rem;
}
.site-head nav a {
  color: var(--text);
  text-decoration: none;
  padding: 6px 2px;
}
.site-head nav a:hover,
.site-head nav a[aria-current='page'] {
  text-decoration: underline wavy var(--primary) 1.5px;
  text-underline-offset: 6px;
}

.site-foot {
  margin-top: clamp(64px, 10vw, 120px);
  padding-block: 28px 40px;
  color: var(--muted);
  font-size: 0.95rem;
}
.site-foot .rule {
  border-top: 1.5px dashed var(--line);
  margin-bottom: 26px;
}
.foot-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px 32px;
}
.foot-grid .symbol {
  width: 44px;
  height: 44px;
  flex: none;
}
.foot-who {
  display: flex;
  align-items: center;
  gap: 12px;
}
.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
}
.foot-links a {
  color: var(--text);
}

/* ---------- Buttons and the coming-soon badge ---------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 24px;
  font: 600 1.05rem/1 var(--hand);
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  border-radius: 16px;
  transition: transform 0.25s var(--ease);
  --sk-fill: var(--card);
}
.btn:hover {
  transform: translateY(-2px) rotate(-0.6deg);
  text-decoration: none;
}
.btn:active {
  transform: translateY(0) scale(0.98);
}
.btn--primary {
  color: var(--on-primary);
  --sk-fill: var(--primary);
}
.btn svg.icon {
  width: 22px;
  height: 22px;
}

.soon {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 7px 18px 7px 8px;
  border-radius: 16px;
  --sk-fill: transparent;
}
.soon img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}
.soon small {
  display: block;
  font-size: 0.78rem;
  line-height: 1.2;
  color: var(--muted);
}
.soon strong {
  display: block;
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.2;
}

/* ---------- Pencil icons (from the app) ---------- */

.icon {
  width: 24px;
  height: 24px;
  flex: none;
}
.icon .i-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon .i-fill {
  fill: currentColor;
  opacity: 0.28;
}

/* ---------- Phones ---------- */

.phone {
  --w: 300px;
  --tilt: 0deg;
  position: relative;
  width: var(--w);
  margin: 0;
  padding: 9px;
  border-radius: 46px;
  transform: rotate(var(--tilt));
  --sk-fill: var(--paper-2);
}
.phone picture,
.phone img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1320 / 2868;
  border-radius: 37px;
}
.phone img {
  box-shadow: 0 1px 0 rgba(74, 58, 46, 0.12);
}

/* ---------- Margin notes ---------- */

.note {
  position: absolute;
  font: 700 1.55rem/1 var(--display);
  color: var(--ink);
  white-space: nowrap;
  pointer-events: none;
}
.note svg {
  position: absolute;
  overflow: visible;
}
.note path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}
.wait:not(.in) .note {
  opacity: 0;
}
.wait.in .note {
  animation: shade 0.8s 0.9s var(--ease) both;
}
.wait.in .note:nth-of-type(2) {
  animation-delay: 1.15s;
}
@media (max-width: 1279px) {
  .note {
    display: none;
  }
}

/* ---------- Hero ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  align-items: center;
  gap: 40px;
  min-height: calc(100dvh - 96px);
  padding-block: clamp(24px, 4vw, 56px) clamp(40px, 6vw, 72px);
}
.hero h1 {
  font-size: clamp(3.2rem, 1.4rem + 4.6vw, 5.4rem);
  line-height: 0.95;
}
.hero h1 [data-mark] {
  white-space: nowrap;
}
.hero .lede {
  margin-top: 26px;
  max-width: 30ch;
  font-size: clamp(1.15rem, 1rem + 0.5vw, 1.35rem);
  line-height: 1.5;
  color: var(--muted);
}
.hero .actions {
  margin-top: 34px;
}
.hero-stage {
  position: relative;
  justify-self: center;
}
.hero-stage .phone {
  --w: clamp(236px, calc((100dvh - 190px) / 2.17), 316px);
  --tilt: 2deg;
}
.hero-stage .note--usual {
  right: calc(100% + 40px);
  bottom: 12%;
  transform: rotate(-4deg);
}
.hero-stage .note--usual svg {
  left: 98%;
  top: -40px;
  width: 92px;
  height: 46px;
}
.hero-stage .note--system {
  left: calc(100% + 34px);
  top: 37%;
  transform: rotate(3deg);
}
.hero-stage .note--system svg {
  right: 100%;
  top: 22px;
  width: 76px;
  height: 40px;
}

@media (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
    min-height: 0;
    gap: 44px;
    padding-top: 20px;
  }
  .hero-stage .phone {
    --w: min(78vw, 300px);
    --tilt: 1.5deg;
  }
}

/* ---------- Sections ---------- */

.section {
  padding-block: clamp(56px, 7vw, 104px);
}
.section h2 {
  font-size: clamp(2.6rem, 1.6rem + 3.4vw, 4.2rem);
  line-height: 0.95;
  max-width: 14ch;
}
.section h2[data-scribble] {
  padding-bottom: 6px;
}
.section .body {
  margin-top: 30px;
  max-width: 44ch;
  font-size: 1.2rem;
  line-height: 1.6;
}
.section .fine {
  margin-top: 14px;
  max-width: 52ch;
  font-size: 0.95rem;
  color: var(--muted);
}

/* Recipe: two phones overlapping, text and the app's own nutrition row. */
.recipe {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: clamp(40px, 6vw, 96px);
  align-items: center;
}
.recipe-stage {
  position: relative;
  min-height: 600px;
}
.recipe-stage .phone {
  position: absolute;
  --w: 268px;
}
.recipe-stage .phone--back {
  left: 0;
  top: 0;
  --tilt: -5deg;
}
.recipe-stage .phone--front {
  left: 42%;
  top: 70px;
  --tilt: 3deg;
}

.nutrition {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 36px;
  padding: 18px 8px 16px;
  max-width: 520px;
  border-radius: 18px;
  text-align: center;
}
.nutrition div {
  padding-inline: 6px;
}
.nutrition b {
  display: block;
  font: 700 2.1rem/1 var(--display);
  font-variant-numeric: tabular-nums;
}
.nutrition b small {
  font-size: 1.2rem;
  margin-left: 2px;
}
.nutrition span {
  display: block;
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}
.c-caffeine {
  color: var(--coffee);
}
.c-kcal {
  color: var(--kcal);
}
.c-water {
  color: var(--water);
}
.c-sugar {
  color: var(--sugar);
}
.nutrition-cap {
  margin-top: 12px;
  font-size: 0.95rem;
  color: var(--muted);
}

@media (max-width: 900px) {
  .recipe {
    grid-template-columns: 1fr;
  }
  .recipe-stage {
    order: 2;
    min-height: 0;
    display: flex;
    justify-content: center;
    padding-block: 10px 20px;
  }
  .recipe-stage .phone {
    position: relative;
    left: auto;
    top: auto;
    --w: min(46vw, 250px);
  }
  .recipe-stage .phone--front {
    margin-left: -12%;
    margin-top: 48px;
  }
}
@media (max-width: 520px) {
  .nutrition {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 18px;
  }
}

/* Half-life: a full-width sheet with the drawn chart. */
.sheet {
  padding: clamp(28px, 5vw, 64px);
  border-radius: 28px;
}
.sheet-head {
  max-width: 760px;
}
.chart-figure {
  margin: clamp(36px, 5vw, 56px) 0 0;
}
.chart {
  width: 100%;
  height: auto;
  overflow: visible;
}
.chart--compact {
  display: none;
}
@media (max-width: 640px) {
  .chart--wide {
    display: none;
  }
  .chart--compact {
    display: block;
  }
}
.ch-tint {
  fill: var(--coffee);
  opacity: 0.1;
}
.ch-hatch {
  fill: none;
  stroke: var(--coffee);
  stroke-width: 1.4;
  stroke-linecap: round;
  opacity: 0.45;
}
.ch-curve {
  fill: none;
  stroke: var(--coffee);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 1;
}
.ch-axis,
.ch-tick {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.8;
  stroke-linecap: round;
}
.ch-call {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-dasharray: 7 7;
}
.ch-bed {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.6;
  stroke-dasharray: 3 6;
  stroke-linecap: round;
  opacity: 0.7;
}
.ch-moon {
  fill: var(--kcal);
  fill-opacity: 0.3;
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-linejoin: round;
}
.ch-mug-fill {
  fill: var(--coffee);
  opacity: 0.35;
}
.ch-mug-line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ch-time {
  font: 400 13px var(--hand);
  fill: var(--muted);
}
.ch-note {
  font: 700 21px var(--display);
  fill: var(--ink);
}
.ch-note--call {
  fill: var(--primary);
}
.ch-note--soft {
  fill: var(--coffee);
}
.chart--compact .ch-note {
  font-size: 17px;
}
.chart--compact .ch-time {
  font-size: 12px;
}
.wait.in .ch-curve {
  animation: draw 1.8s 0.2s var(--ease) both;
}
.wait.in :is(.ch-hatch, .ch-tint) {
  animation: shade 1s 0.9s var(--ease) both;
}
.wait.in .ch-note {
  animation: shade 0.8s 1.3s var(--ease) both;
}
.chart-figure figcaption {
  margin-top: 22px;
  font-size: 0.95rem;
  color: var(--muted);
  max-width: 64ch;
}

/* History: one phone in the middle, notes in the margins. */
.week {
  text-align: center;
}
.week h2,
.week .body {
  margin-inline: auto;
}
.week h2[data-scribble] svg.sc {
  left: 50%;
  transform: translateX(-50%);
}
.week-stage {
  position: relative;
  display: grid;
  justify-items: center;
  margin-top: clamp(48px, 6vw, 72px);
}
.week-stage .phone {
  --w: min(78vw, 320px);
  --tilt: -1.5deg;
}
.week-stage .note--bars {
  right: calc(50% + 190px);
  top: 15%;
  transform: rotate(-3deg);
}
.week-stage .note--bars svg {
  left: 100%;
  top: 14px;
  width: 96px;
  height: 50px;
}
.week-stage .note--limit {
  left: calc(50% + 200px);
  top: 11%;
  transform: rotate(3deg);
}
.week-stage .note--limit svg {
  right: 100%;
  top: 12px;
  width: 92px;
  height: 40px;
}
.week-stage .note--log {
  left: calc(50% + 196px);
  top: 50%;
  transform: rotate(-2deg);
}
.week-stage .note--log svg {
  right: 100%;
  top: 10px;
  width: 80px;
  height: 36px;
}

/* Promises: a pinned note beside the lamplight screen. */
.promises {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: clamp(40px, 6vw, 96px);
  align-items: center;
}
.pinned {
  padding: clamp(28px, 4vw, 48px);
  border-radius: 22px;
  transform: rotate(-1.2deg);
}
.checks {
  list-style: none;
  margin: 30px 0 0;
  padding: 0;
  display: grid;
  gap: 16px;
}
.checks li {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 12px;
  align-items: start;
  font-size: 1.15rem;
  line-height: 1.45;
}
.checks .icon {
  width: 30px;
  height: 30px;
  margin-top: -2px;
  color: var(--primary);
}
.checks .icon .i-line {
  stroke-width: 2.2;
}
.lamplight {
  display: grid;
  justify-items: center;
  gap: 22px;
}
.lamplight .phone {
  --w: min(70vw, 290px);
  --tilt: 2.5deg;
}
.lamplight p {
  font: 700 1.6rem/1.1 var(--display);
  text-align: center;
  max-width: 16ch;
}
@media (max-width: 900px) {
  .promises {
    grid-template-columns: 1fr;
  }
  .pinned {
    transform: none;
  }
}

/* Closing: the mark, coloured in. */
.closing {
  display: grid;
  justify-items: center;
  text-align: center;
  padding-block: clamp(72px, 10vw, 140px) 0;
}
.closing .symbol {
  width: clamp(150px, 20vw, 210px);
  height: auto;
}
.closing h2 {
  margin-top: 18px;
  font-size: clamp(2.8rem, 1.6rem + 4vw, 4.8rem);
  max-width: 13ch;
}
.closing .body {
  margin: 20px auto 0;
  max-width: 36ch;
  font-size: 1.2rem;
  color: var(--muted);
}
.closing .actions {
  justify-content: center;
  margin-top: 34px;
}
.wait:not(.in) .symbol :is(.mug-liquid, .mug-hatch) {
  clip-path: inset(100% 0 0 0);
}
.wait.in .symbol :is(.mug-liquid, .mug-hatch) {
  animation: fill-up 1.6s 0.3s var(--ease) both;
}
@keyframes fill-up {
  from {
    clip-path: inset(100% 0 0 0);
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}

/* ---------- Reading pages (privacy, support) ---------- */

.doc {
  max-width: 760px;
  margin-inline: auto;
  padding-block: clamp(24px, 5vw, 56px) 0;
}
.doc h1,
.doc h2 {
  position: relative;
}
.doc h1 {
  font-size: clamp(3rem, 2rem + 3.4vw, 4.4rem);
  padding-bottom: 8px;
  margin-bottom: 30px;
}
.doc h2 {
  font-size: 2.1rem;
  margin: 56px 0 18px;
}
.doc h3 {
  font-size: 1.6rem;
  margin: 36px 0 8px;
  color: var(--text);
}
.doc p,
.doc ul {
  margin: 0 0 16px;
}
.doc ul {
  padding-left: 1.3em;
}
.doc li {
  margin-bottom: 8px;
}
.doc li::marker {
  color: var(--coffee);
}
.doc .muted {
  color: var(--muted);
  margin-top: -14px;
}
.doc strong {
  font-weight: 600;
}
.doc-card {
  padding: clamp(24px, 4vw, 44px) clamp(20px, 4vw, 48px);
  border-radius: 24px;
}
.doc-card > :first-child {
  margin-top: 0;
}
.doc-card > :last-child {
  margin-bottom: 0;
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
