/* Grittle — grittle.app
   Warm paper and ink with an ember accent, taken from the app's palette
   (lib/shared/theme/app_colors.dart). */

@font-face {
  font-family: "Inter";
  src: url("/fonts/Inter-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/fonts/Inter-SemiBold.woff2") format("woff2");
  font-weight: 500 700;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("/fonts/Fraunces.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
/* The app's icon set (Phosphor, MIT), subset to the glyphs this site uses.
   Codepoints match lib/shared/theme/app_icons.dart. */
@font-face {
  font-family: "Phosphor";
  src: url("/fonts/Phosphor-Regular.woff2") format("woff2");
  font-display: block;
}
@font-face {
  font-family: "PhosphorFill";
  src: url("/fonts/Phosphor-Fill.woff2") format("woff2");
  font-display: block;
}

:root {
  --paper: #f6f3ee;
  --surface: #fffefb;
  --surface-2: #efebe4;
  --surface-3: #ebe6de;
  --ink: #1f1b16;
  --ink-2: #6b645b;
  --ink-3: #a39b90;
  --border: #e6e0d6;
  --ember: #cc4e27;
  --ember-ink: #b23f1b;
  --ember-soft: #fbe6dc;
  /* Ember deep enough for white text at 5:1, for filled buttons and badges. */
  --ember-fill: #bd4520;
  --habits: #3b8c6e;
  --habits-soft: #e1f3ea;
  --goals: #7b49b8;
  --goals-soft: #efe6f7;
  --tasks: #2f66c9;
  --tasks-soft: #e1e9f8;
  --notes: #d4950f;
  --notes-soft: #faefcf;
  --friends: #d24f78;
  --friends-soft: #fae3ea;
  --energy: #e9c24a;
  --shadow: 0 1px 2px rgb(31 27 22 / 0.04), 0 8px 24px rgb(31 27 22 / 0.06);
  --shadow-lg: 0 2px 6px rgb(31 27 22 / 0.05), 0 30px 80px -20px rgb(31 27 22 / 0.28);
  --glow: rgb(204 78 39 / 0.35);
  --radius: 22px;
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --max: 1180px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #13110e;
    --surface: #1d1a16;
    --surface-2: #27231e;
    --surface-3: #2e2a24;
    --ink: #f3eee6;
    --ink-2: #b3aa9d;
    --ink-3: #857d72;
    --border: #34302a;
    --ember: #e2673f;
    --ember-ink: #f08a63;
    --ember-soft: #3a1d12;
    --habits: #5cb592;
    --habits-soft: #16302a;
    --goals: #a77de0;
    --goals-soft: #2a1d3b;
    --tasks: #6e9cf0;
    --tasks-soft: #18233a;
    --notes: #e9b23c;
    --notes-soft: #33280e;
    --friends: #ec7aa0;
    --friends-soft: #3a1825;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 2px 6px rgb(0 0 0 / 0.3), 0 30px 80px -20px rgb(0 0 0 / 0.7);
    --glow: rgb(226 103 63 / 0.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #13110e;
  --surface: #1d1a16;
  --surface-2: #27231e;
  --surface-3: #2e2a24;
  --ink: #f3eee6;
  --ink-2: #b3aa9d;
  --ink-3: #857d72;
  --border: #34302a;
  --ember: #e2673f;
  --ember-ink: #f08a63;
  --ember-soft: #3a1d12;
  --habits: #5cb592;
  --habits-soft: #16302a;
  --goals: #a77de0;
  --goals-soft: #2a1d3b;
  --tasks: #6e9cf0;
  --tasks-soft: #18233a;
  --notes: #e9b23c;
  --notes-soft: #33280e;
  --friends: #ec7aa0;
  --friends-soft: #3a1825;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 2px 6px rgb(0 0 0 / 0.3), 0 30px 80px -20px rgb(0 0 0 / 0.7);
  --glow: rgb(226 103 63 / 0.4);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
body {
  margin: 0;
  font-synthesis: none;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img {
  max-width: 100%;
  display: block;
}
a {
  color: inherit;
}
button {
  font: inherit;
  color: inherit;
}
::selection {
  background: var(--ember);
  color: #fff;
}
:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 3px;
  border-radius: 8px;
}

/* Paper grain over everything, like the app's warm surfaces. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.wrap {
  width: min(var(--max), 100% - 32px);
  margin-inline: auto;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Type ---------- */
h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0;
  font-variation-settings: "SOFT" 50, "WONK" 0, "opsz" 144;
}
h1 {
  font-size: clamp(44px, 8vw, 104px);
}
h2 {
  font-size: clamp(34px, 5.4vw, 68px);
}
h3 {
  font-size: clamp(22px, 2.4vw, 28px);
  line-height: 1.15;
}
em.ember,
.ember {
  color: var(--ember);
}
/* The app ships Fraunces roman only: emphasis is ember, never a faux italic. */
h1 em,
h2 em {
  font-style: normal;
  color: var(--ember);
  font-variation-settings: "SOFT" 100, "WONK" 1, "opsz" 144;
}
.ph {
  font-family: "Phosphor";
  font-style: normal;
  font-weight: 400;
  line-height: 1;
  display: inline-block;
  vertical-align: -0.125em;
  -webkit-font-smoothing: antialiased;
  speak: never;
}
.ph.fill {
  font-family: "PhosphorFill";
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 600 13px/1 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ember-ink);
}
.eyebrow::before {
  content: "";
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}
.lead {
  font-size: clamp(18px, 1.6vw, 21px);
  color: var(--ink-2);
  max-width: 34em;
}
.muted {
  color: var(--ink-2);
}

/* ---------- Wordmark: the app's script, tinted with ink ---------- */
.wordmark {
  display: inline-block;
  aspect-ratio: 1454 / 688;
  height: 40px;
  background: var(--ink);
  -webkit-mask: url("/img/wordmark.png") center / contain no-repeat;
  mask: url("/img/wordmark.png") center / contain no-repeat;
}
.wordmark.write {
  background: linear-gradient(115deg, var(--ink) 0 45%, transparent 55%) 100% 0 / 260% 100% no-repeat;
  animation: write 1.8s var(--ease) 0.2s forwards;
}
@keyframes write {
  to {
    background-position: 0 0;
  }
}

/* ---------- Buttons ---------- */
.btn {
  --bg: var(--ink);
  --fg: var(--paper);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 22px;
  border-radius: 999px;
  border: 0;
  background: var(--bg);
  color: var(--fg);
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
  cursor: pointer;
  position: relative;
  transition: transform 0.4s var(--spring), box-shadow 0.4s var(--ease), background 0.3s;
  will-change: transform;
}
.btn:hover {
  box-shadow: 0 12px 30px -10px var(--glow);
}
.btn:active {
  transform: scale(0.97);
}
.btn.ember {
  --bg: var(--ember-fill);
  --fg: #fff;
}
.btn.ghost {
  --bg: transparent;
  --fg: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--border);
}
.btn.ghost:hover {
  box-shadow: inset 0 0 0 1.5px var(--ink-3);
}
.btn .ph {
  font-size: 20px;
}

/* Store badges: drawn here, so they follow the theme. */
.stores {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.store {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 20px 8px 16px;
  border-radius: 16px;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  position: relative;
  transition: transform 0.4s var(--spring);
  cursor: pointer;
  border: 0;
  text-align: left;
}
.store:hover {
  transform: translateY(-2px);
}
.store svg {
  width: 26px;
  height: 26px;
  flex: none;
}
.store .ph {
  font-size: 26px;
}
.store small {
  display: block;
  font-size: 11px;
  line-height: 1.2;
  opacity: 0.75;
  letter-spacing: 0.02em;
}
.store b {
  display: block;
  font-size: 18px;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.store .soon {
  position: absolute;
  top: -9px;
  right: -8px;
  background: var(--ember-fill);
  color: #fff;
  font: 600 10px/1 var(--sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 8px;
  border-radius: 999px;
  box-shadow: 0 4px 10px -2px var(--glow);
}
.store.web {
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--border);
}
.store.web .live {
  position: absolute;
  top: -9px;
  right: -8px;
  background: #30735a;
  color: #fff;
  font: 600 10px/1 var(--sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 8px;
  border-radius: 999px;
}

/* ---------- Nav ---------- */
.nav {
  position: fixed;
  inset: 12px 0 auto;
  z-index: 50;
  pointer-events: none;
}
.nav .bar {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(var(--max), 100% - 24px);
  margin-inline: auto;
  padding: 8px 8px 8px 20px;
  border-radius: 999px;
  transition: background 0.4s, box-shadow 0.4s, backdrop-filter 0.4s;
}
.nav.scrolled .bar {
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: var(--shadow), inset 0 0 0 1px var(--border);
}
.nav .brand {
  display: inline-flex;
  margin-right: auto;
}
.nav .brand .wordmark {
  height: 34px;
}
.nav .links {
  display: flex;
  gap: 2px;
}
.nav .links a {
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-2);
  padding: 8px 14px;
  border-radius: 999px;
  transition: color 0.2s, background 0.2s;
}
.nav .links a:hover {
  color: var(--ink);
  background: var(--surface-2);
}
.nav .btn {
  min-height: 42px;
  padding: 0 18px;
  font-size: 15px;
}
.icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--ink-2);
  transition: background 0.2s, color 0.2s, transform 0.5s var(--spring);
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.icon-btn:active {
  transform: rotate(40deg) scale(0.9);
}
.icon-btn .ph {
  font-size: 21px;
}
.theme-toggle .moon {
  display: none;
}
:root[data-theme="dark"] .theme-toggle .sun {
  display: none;
}
:root[data-theme="dark"] .theme-toggle .moon {
  display: block;
}
@media (max-width: 860px) {
  .nav .links {
    display: none;
  }
}

/* ---------- Reveal on scroll ---------- */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
  transition-delay: var(--d, 0s);
}
.reveal.in {
  opacity: 1;
  transform: none;
}

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border);
  padding: 56px 0 40px;
  margin-top: 40px;
  color: var(--ink-2);
  font-size: 15px;
}
.footer .cols {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  gap: 32px;
}
.footer h4 {
  margin: 0 0 12px;
  font: 600 13px/1 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}
.footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.footer a {
  text-decoration: none;
}
.footer a:hover {
  color: var(--ink);
}
.footer .fine {
  margin-top: 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  justify-content: space-between;
  font-size: 13px;
  color: var(--ink-2);
}
@media (max-width: 760px) {
  .footer .cols {
    grid-template-columns: 1fr 1fr;
  }
  .footer .cols > :first-child {
    grid-column: 1 / -1;
  }
}

/* ---------- Legal / support pages ---------- */
.doc {
  padding: 140px 0 40px;
}
.doc .wrap {
  width: min(760px, 100% - 32px);
}
.doc h1 {
  font-size: clamp(40px, 6vw, 64px);
  margin: 16px 0 12px;
}
.doc .updated {
  color: var(--ink-2);
  font-size: 15px;
  margin-bottom: 40px;
}
.doc h2 {
  font-size: clamp(24px, 3vw, 30px);
  margin: 48px 0 12px;
  scroll-margin-top: 100px;
}
.doc h3 {
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0;
  margin: 28px 0 8px;
}
.doc p,
.doc li {
  color: var(--ink-2);
}
.doc li {
  margin: 6px 0;
}
.doc strong {
  color: var(--ink);
  font-weight: 600;
}
.doc a {
  color: var(--ember-ink);
  text-underline-offset: 3px;
}
.doc .summary {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 28px;
  box-shadow: inset 0 0 0 1px var(--border);
}
.doc .summary ul {
  margin: 8px 0 0;
  padding-left: 20px;
}
.doc table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  margin: 16px 0;
}
.doc th,
.doc td {
  text-align: left;
  vertical-align: top;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--ink-2);
}
.doc th {
  color: var(--ink);
  font-weight: 600;
}
.doc .table-scroll {
  overflow-x: auto;
}
.doc .toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}
.doc .toc a {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  text-decoration: none;
  font-size: 14px;
}
.doc .toc a:hover {
  color: var(--ink);
}
.steps-list {
  counter-reset: s;
  list-style: none;
  padding: 0;
}
.steps-list li {
  counter-increment: s;
  position: relative;
  padding-left: 48px;
  margin: 16px 0;
}
.steps-list li::before {
  content: counter(s);
  position: absolute;
  left: 0;
  top: -2px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--ember-soft);
  color: var(--ember-ink);
  font-weight: 600;
  font-size: 15px;
}
.callout {
  border-radius: 16px;
  padding: 16px 20px;
  background: var(--ember-soft);
  color: var(--ink);
  margin: 20px 0;
}
.callout p {
  color: var(--ink);
  margin: 0;
}

.theme-switching *,
.theme-switching *::before,
.theme-switching *::after {
  transition: none !important;
}

/* Theme switch: a circle grows from the toggle. */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
::view-transition-new(root) {
  animation: themeWipe 0.75s var(--ease);
}
@keyframes themeWipe {
  from {
    clip-path: circle(0 at var(--vx, 50%) var(--vy, 0));
  }
  to {
    clip-path: circle(150vmax at var(--vx, 50%) var(--vy, 0));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .reveal {
    opacity: 1;
    transform: none;
  }
}
