/*
 * Daily Pet Log — the website.
 *
 * The same tokens as the app, copied by hand from apps/ios/AppCore/DesignSystem/Tokens.swift.
 * Copied rather than generated because two artefacts this small do not justify a build step
 * between them — but they must not drift: if a value here disagrees with Tokens.swift, this
 * file is wrong. The contrast ratios in the comments there are the measured ones.
 *
 * No JavaScript anywhere on this site. Nothing here needs it, and its absence is what lets
 * the Content-Security-Policy in the Caddyfile be as tight as it is.
 */

/* MARK: - Faces
 *
 * Two of the app's three. IBM Plex Mono is left out: it is for figures a person compares
 * down a column, and there are none on a marketing page — it would be 136K to style nothing.
 */
@font-face {
  font-family: 'Fraunces';
  src: url('/fonts/Fraunces-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Public Sans';
  src: url('/fonts/PublicSans-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Public Sans';
  src: url('/fonts/PublicSans-Medium.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Public Sans';
  src: url('/fonts/PublicSans-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Public Sans';
  src: url('/fonts/PublicSans-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

/* MARK: - Palette */

:root {
  color-scheme: light dark;

  --ground: #F4F6F3;
  --surface: #FFFFFF;
  --surface2: #EDF1EC;

  --ink: #12211C;
  --ink2: #4A5A53;
  --ink3: #64736B;

  --line: #DCE4DF;
  --line-strong: #C3CFC8;

  --primary: #0E7A57;
  --primary-deep: #0A5B41;
  --primary-tint: #C7E7D8;
  --on-primary: #FFFFFF;

  --accent: #E2853F;
  --accent-tint: #F5D9BF;

  /* Spacing scale, from DPLMetric. Use these, not literals. */
  --sm: 8px;
  --md: 12px;
  --lg: 16px;
  --xl: 24px;
  --xxl: 32px;

  --radius-card: 14px;
  --radius-chip: 999px;

  --measure: 34rem;   /* Reading width. Longer than this and the eye loses the line. */
  --page: 60rem;      /* The widest anything gets. */
}

/*
 * Dark is a designed surface, not an inversion — rule 6. Both value sets come from the app,
 * where each was chosen against its own ground rather than derived from the other.
 */
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #121815;
    --surface: #1A221E;
    --surface2: #212B26;

    --ink: #EAF0EC;
    --ink2: #A9B8B0;
    --ink3: #7E8D85;

    --line: #2C3832;
    --line-strong: #3D4C45;

    --primary: #2A9A70;
    --primary-deep: #38B384;
    --primary-tint: #17352A;
    --on-primary: #0B1410;

    --accent: #E9A46A;
    --accent-tint: #3A2A1B;
  }
}

/* MARK: - Base */

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  /* 16px floor — rule 4. Never smaller, anywhere. */
  font: 400 16px/1.6 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; margin: 0; }
/* A heading needs to be closer to what it introduces than to what came before, but not
 * touching it. With margin-bottom at zero the first line of the section read as part of
 * the heading. */
h2 { margin-bottom: var(--md); }
h3 { margin-bottom: var(--sm); }

/* Fraunces is display only — wordmark and page titles. Never body, never a UI label. */
h1 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: clamp(2rem, 1.4rem + 3vw, 2.75rem);
}
h2 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 1.625rem;
  margin-top: var(--xxl);
}
h3 {
  font-size: 1.1875rem;
  font-weight: 600;
  margin-top: var(--xl);
}

p, li { color: var(--ink2); }
p { margin: 0 0 var(--lg); }

a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--primary-deep); }

strong { color: var(--ink); font-weight: 600; }

hr { border: 0; border-top: 1px solid var(--line); margin: var(--xxl) 0; }

/* Rule 5: a focus ring must be visible on every ground it can land on. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* MARK: - Layout */

.page { max-width: var(--page); margin: 0 auto; padding: 0 var(--xl); }
/* A new section is a new subject. Without this the heading reads as part of the paragraph
 * above it, which is how the moments list ended up looking like part of the hero. */
main > section + section { margin-top: clamp(var(--xxl), 6vw, 4rem); }
.prose { max-width: var(--measure); }
.prose li { margin-bottom: var(--sm); }

header.site {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
header.site .page {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--lg);
  /* Rule 3: 44px minimum touch target, so the bar is tall enough to hold one. */
  min-height: 64px;
  flex-wrap: wrap;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: var(--md);
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--ink);
  text-decoration: none;
}
.wordmark img { width: 32px; height: 32px; display: block; }

nav.site { display: flex; gap: var(--sm); flex-wrap: wrap; }
nav.site a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--md);
  border-radius: var(--radius-chip);
  color: var(--ink2);
  font-size: 0.90625rem;
  font-weight: 500;
  text-decoration: none;
}
nav.site a:hover { background: var(--surface2); color: var(--ink); }
nav.site a[aria-current='page'] { background: var(--primary-tint); color: var(--primary-deep); }

/* MARK: - Hero */

.hero { padding: clamp(var(--xxl), 8vw, 5rem) 0 var(--xxl); }
.hero img.mark { width: 72px; height: 72px; display: block; margin-bottom: var(--xl); }
.hero h1 { max-width: 20ch; }
.hero .lede {
  font-size: 1.1875rem;
  color: var(--ink2);
  max-width: 42ch;
  margin-top: var(--lg);
}

/* Says where the product actually is. An honest state beats a download button that lies. */
.status {
  display: inline-flex;
  align-items: center;
  gap: var(--sm);
  padding: var(--sm) var(--lg);
  border-radius: var(--radius-chip);
  background: var(--accent-tint);
  color: var(--ink);
  font-size: 0.90625rem;
  font-weight: 500;
  margin-top: var(--xl);
}
.status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  /* Never colour alone — rule 1. The dot is decoration; the words carry it. */
}

/* MARK: - Cards
 *
 * Not everything is a card. These are: each one is a separate thing the app does, which is
 * what a border and a radius are for.
 */

.grid {
  display: grid;
  gap: var(--lg);
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  margin: var(--xl) 0;
  padding: 0;
  list-style: none;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: var(--xl);
}
.card h3 { margin-top: 0; color: var(--ink); }
.card p { margin-bottom: 0; }

/* One moment per row: the reason the app is shaped the way it is. */
.moments { margin: var(--xl) 0; padding: 0; list-style: none; max-width: 46rem; }
.moments li {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: var(--lg);
  padding: var(--lg) 0;
  border-top: 1px solid var(--line);
  align-items: baseline;
}
.moments li:last-child { border-bottom: 1px solid var(--line); }
.moments .when {
  color: var(--ink3);
  font-weight: 600;
  font-size: 0.90625rem;
}
.moments p { margin: 0; }
@media (max-width: 34rem) {
  .moments li { grid-template-columns: 1fr; gap: var(--sm); }
}

/* MARK: - Footer */

footer.site {
  border-top: 1px solid var(--line);
  margin-top: 4rem;
  padding: var(--xxl) 0;
  background: var(--surface);
}
footer.site .page {
  display: flex;
  flex-wrap: wrap;
  gap: var(--lg) var(--xl);
  justify-content: space-between;
  align-items: center;
}
footer.site nav { display: flex; gap: var(--xl); flex-wrap: wrap; }
footer.site a { color: var(--ink2); font-size: 0.90625rem; text-decoration: none; }
footer.site a:hover { color: var(--ink); text-decoration: underline; }
footer.site small { color: var(--ink3); font-size: 0.90625rem; }

/* MARK: - Legal pages */

.legal { padding: var(--xxl) 0; }
.legal .updated {
  color: var(--ink3);
  font-size: 0.90625rem;
  margin-bottom: var(--xxl);
}
.legal h2 { font-size: 1.375rem; }

/*
 * Anything still to be filled in. Deliberately loud: a placeholder that reads as prose is a
 * placeholder that ships.
 */
.todo {
  background: var(--accent-tint);
  color: var(--ink);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  margin: var(--lg) 0 var(--xl);
  font-size: 0.9375rem;
}
table.data th, table.data td {
  text-align: left;
  vertical-align: top;
  padding: var(--md) var(--lg) var(--md) 0;
  border-bottom: 1px solid var(--line);
}
table.data th { color: var(--ink); font-weight: 600; }
table.data td { color: var(--ink2); }
