/* ==========================================================================
   Align — web presence
   Editorial system lifted from the app: warm paper, soft ink, one terracotta
   accent, a serif display face. Two motifs from the app icon recur here — the
   thin "mat line" (ground rule) and the soft "sun" glow.
   Palette values are the exact tokens from Align/DesignSystem/Theme.swift.
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* Theme.swift tokens */
  --paper: #f7f3ec;
  --paper-deep: #efe8dc;
  --ink: #2b2620;
  --ink-soft: #655c51;
  --terracotta: #c4664a;
  --sand: #e5d9c6;
  --sage: #8a9b7d;

  /* Semantic roles (light) */
  --bg: var(--paper);
  --surface: #fffdf8;
  --text: var(--ink);
  --muted: var(--ink-soft);
  --border: #e3d9c8;
  --hairline: #d6cab6;
  --accent: var(--terracotta);
  --accent-ink: #a94d33;
  --glow: rgba(196, 102, 74, 0.14); /* terracotta sun, light */

  --maxw: 46rem;
  --radius: 16px;
  --serif: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype",
    Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Derived from the dark app icon: ink ground, terracotta sun, paper figure */
    --bg: #1b1815;
    --surface: #221f1a;
    --text: #efe7d9;
    --muted: #a99d8b;
    --border: #363029;
    --hairline: #3d362e;
    --accent: #d0785c;
    --accent-ink: #e08a6e;
    --glow: rgba(196, 102, 74, 0.22); /* terracotta sun, dark */
  }
}

/* Explicit theme overrides (viewer toggle stamps data-theme on :root) */
:root[data-theme="light"] {
  --bg: var(--paper);
  --surface: #fffdf8;
  --text: var(--ink);
  --muted: var(--ink-soft);
  --border: #e3d9c8;
  --hairline: #d6cab6;
  --accent: var(--terracotta);
  --accent-ink: #a94d33;
  --glow: rgba(196, 102, 74, 0.14);
}
:root[data-theme="dark"] {
  --bg: #1b1815;
  --surface: #221f1a;
  --text: #efe7d9;
  --muted: #a99d8b;
  --border: #363029;
  --hairline: #3d362e;
  --accent: #d0785c;
  --accent-ink: #e08a6e;
  --glow: rgba(196, 102, 74, 0.22);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background-color: var(--bg);
  /* Soft "sun" glow rising from behind the header, echoing the icon. */
  background-image: radial-gradient(
    120% 60% at 50% -8%,
    var(--glow) 0%,
    transparent 60%
  );
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--sans);
  font-size: 17.5px;
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1.15rem, 5vw, 2rem) 5rem;
}

/* Links: terracotta, with a warm underline that thickens on hover. */
a {
  color: var(--accent-ink);
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 3px;
}
a:hover { text-decoration-color: var(--accent); }

/* --- Header ------------------------------------------------------------ */
.site-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding-bottom: 1.4rem;
  margin-bottom: 2.4rem;
  border-bottom: 1px solid var(--hairline);
}
.site-head .mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: block;
  box-shadow: 0 1px 3px rgba(43, 38, 32, 0.16);
}
.brand {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.28rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--text);
}
.brand-dot { color: var(--accent); }
.site-head nav {
  margin-left: auto;
  display: flex;
  gap: 1.25rem;
  font-size: 0.95rem;
}
.site-head nav a { color: var(--muted); text-decoration: none; }
.site-head nav a:hover { color: var(--text); }

/* --- Typography -------------------------------------------------------- */
h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2rem, 6vw, 3rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 0 0.6rem;
}
h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 2.8rem 0 0.7rem;
  /* Each section opens with a short terracotta mat-line tick. */
  padding-top: 1.6rem;
  position: relative;
}
h2::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 2.2rem;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}
h3 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.1rem;
  margin: 1.6rem 0 0.35rem;
}

.meta {
  color: var(--muted);
  font-size: 0.94rem;
  letter-spacing: 0.01em;
  margin: 0 0 2rem;
}

p { margin: 0.75rem 0; }
ul { margin: 0.7rem 0; padding-left: 0; list-style: none; }
li {
  position: relative;
  margin: 0.5rem 0;
  padding-left: 1.35rem;
}
/* Hand-set terracotta marker instead of a default bullet. */
li::before {
  content: "";
  position: absolute;
  left: 0.1rem;
  top: 0.72em;
  width: 0.42rem;
  height: 0.42rem;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
}
strong { font-weight: 650; color: var(--text); }
code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.86em;
  background: var(--paper-deep);
  color: var(--accent-ink);
  padding: 0.1em 0.4em;
  border-radius: 5px;
}
@media (prefers-color-scheme: dark) {
  code { background: #2c271f; }
}

.lede {
  font-family: var(--serif);
  font-size: clamp(1.15rem, 2.4vw, 1.4rem);
  line-height: 1.5;
  color: var(--muted);
  font-weight: 400;
  margin: 0.4rem 0 0;
}

/* --- Callout / TL;DR --------------------------------------------------- */
.callout {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  margin: 1.6rem 0 0.5rem;
  box-shadow: 0 1px 2px rgba(43, 38, 32, 0.04);
}
.callout p:first-child { margin-top: 0; }
.callout p:last-child { margin-bottom: 0; }
.callout p:first-child strong {
  font-family: var(--serif);
  font-size: 1.05rem;
}

/* --- Hero (index) ------------------------------------------------------ */
.hero { padding: 1.5rem 0 0.5rem; }
.hero-mark {
  width: clamp(104px, 26vw, 148px);
  height: clamp(104px, 26vw, 148px);
  border-radius: 23%; /* iOS-style superellipse approximation */
  display: block;
  margin-bottom: 1.8rem;
  box-shadow: 0 10px 30px -8px rgba(43, 38, 32, 0.28),
    0 2px 6px rgba(43, 38, 32, 0.12);
}
.pill {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent-ink);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  margin-bottom: 1.4rem;
}
.actions { display: flex; flex-wrap: wrap; gap: 0.8rem; margin: 2rem 0 1.6rem; }
.btn {
  display: inline-block;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.98rem;
  padding: 0.68rem 1.3rem;
  border-radius: 11px;
  border: 1px solid var(--border);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 16px -6px rgba(196, 102, 74, 0.55);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 9px 20px -6px rgba(196, 102, 74, 0.6); }
.btn-ghost { color: var(--text); background: var(--surface); }
.btn-ghost:hover { transform: translateY(-1px); border-color: var(--accent); }

/* Thin "mat line" divider, matching the ground line in the icon. */
.matline {
  border: 0;
  height: 1px;
  background: var(--hairline);
  margin: 2.4rem 0;
}

/* --- Footer ------------------------------------------------------------ */
footer {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--hairline);
  color: var(--muted);
  font-size: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.2rem;
  align-items: center;
}
.footer-links { margin-left: auto; display: flex; gap: 1.2rem; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--text); }

.disclaimer {
  font-family: var(--serif);
  font-size: 0.98rem;
  color: var(--muted);
  font-style: italic;
  line-height: 1.55;
}

/* --- Entrance motion: one calm, staggered settle on load --------------- */
@media (prefers-reduced-motion: no-preference) {
  .reveal > * {
    opacity: 0;
    transform: translateY(10px);
    animation: settle 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
  }
  .reveal > *:nth-child(1) { animation-delay: 0.02s; }
  .reveal > *:nth-child(2) { animation-delay: 0.09s; }
  .reveal > *:nth-child(3) { animation-delay: 0.16s; }
  .reveal > *:nth-child(4) { animation-delay: 0.23s; }
  .reveal > *:nth-child(5) { animation-delay: 0.30s; }
  .reveal > *:nth-child(6) { animation-delay: 0.37s; }
  @keyframes settle {
    to { opacity: 1; transform: none; }
  }
}
