/*
  PennyWings landing page.
  Tokens: docs/design/tokens.md. Plain CSS, no build step, no external requests.
  Order: tokens, base, layout, components, header, hero, demo, sections, form, faq, footer, utilities.
*/

/* ---------- Tokens ---------- */
:root {
  color-scheme: light dark;

  --color-bg: #FFFBF5;
  --color-bg-alt: #FFF1D6;
  --color-surface: #FFFFFF;
  --color-brand-soft: #DDF3F0;
  --color-text: #1B2B34;
  --color-text-muted: #475861;
  --color-link: #0B6665;
  --color-brand: #0E7C7B;
  --color-brand-hover: #0A6564;
  --color-on-brand: #FFFFFF;
  --color-border: #5F6F78;
  --color-border-subtle: #E6DFD1;
  --color-focus: #0B57D0;
  --color-success: #19633B;
  --color-success-bg: #E3F4EA;
  --color-warning: #7A4B00;
  --color-warning-bg: #FFF0CC;
  --color-danger: #B3261E;
  --color-danger-bg: #FDE7E5;

  --wallpaper: linear-gradient(135deg, #BFE8E2 0%, #F6E3B8 100%);
  --shadow-demo: 0 1px 2px rgb(27 43 52 / 8%), 0 12px 32px rgb(27 43 52 / 12%);

  --font-sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;

  --text-hero: clamp(2.25rem, 7vw, 4rem);
  --text-2xl: clamp(1.875rem, 5vw, 2.75rem);
  --text-xl: clamp(1.5rem, 3.5vw, 2rem);
  --text-lg: 1.25rem;
  --text-base: 1.0625rem;
  --text-sm: 0.9375rem;
  --text-xs: 0.8125rem;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --gutter: 16px;
  --content-max: 1120px;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --motion-fast: 120ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (min-width: 640px) { :root { --gutter: 24px; } }
@media (min-width: 1024px) { :root { --gutter: 32px; } }

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0F1A1F;
    --color-bg-alt: #14232A;
    --color-surface: #182A32;
    --color-brand-soft: #17393B;
    --color-text: #F1F5F6;
    --color-text-muted: #A8B9C1;
    --color-link: #6FE0D5;
    --color-brand: #4FD1C5;
    --color-brand-hover: #6FE0D5;
    --color-on-brand: #0F1A1F;
    --color-border: #7F959F;
    --color-border-subtle: #2A3E47;
    --color-focus: #FFD166;
    --color-success: #6FD39B;
    --color-success-bg: #14301F;
    --color-warning: #FFCB6B;
    --color-warning-bg: #3A2D0B;
    --color-danger: #FF8A80;
    --color-danger-bg: #3D1613;

    --wallpaper: linear-gradient(135deg, #1D4350 0%, #14232A 100%);
    --shadow-demo: none;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--color-text);
  background: var(--color-bg);
}

/* An author rule such as display: flex would otherwise beat the browser's [hidden] rule (the vote lists, the form). */
[hidden] { display: none !important; }

h1, h2, h3, p, ul, ol, figure, dl { margin: 0; }
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; }
img, svg { display: block; max-width: 100%; }

a { color: var(--color-link); text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 2px; }

code, kbd { font-family: var(--font-mono); font-size: 0.9em; overflow-wrap: anywhere; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ---------- Layout ---------- */
.container { width: min(100% - 2 * var(--gutter), var(--content-max)); margin-inline: auto; }

.section { padding-block: clamp(48px, 8vw, 96px); }
.section--alt { background: var(--color-bg-alt); }

.section__head { max-width: 42rem; margin-bottom: var(--space-6); }
.section__head h2 { font-size: var(--text-2xl); line-height: 1.15; font-weight: 800; letter-spacing: -0.01em; }
.section__head p { margin-top: var(--space-3); color: var(--color-text-muted); }

.grid { display: grid; gap: var(--space-4); }
@media (min-width: 640px) { .grid--2, .grid--4 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .grid--3 { grid-template-columns: repeat(3, 1fr); } .grid--4 { grid-template-columns: repeat(4, 1fr); } }

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  min-width: 0;
}
.card h3 { font-size: var(--text-lg); line-height: 1.3; font-weight: 700; margin-bottom: var(--space-2); }
.card p + p { margin-top: var(--space-3); }
.muted { color: var(--color-text-muted); }

/* ---------- Components ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  min-height: 48px; padding: 12px 24px;
  border: 2px solid var(--color-brand); border-radius: var(--radius-pill);
  background: var(--color-brand); color: var(--color-on-brand);
  font: inherit; font-weight: 700; line-height: 1.25; text-decoration: none; cursor: pointer;
  transition: background-color var(--motion-fast) var(--ease-out);
}
.button:hover { background: var(--color-brand-hover); border-color: var(--color-brand-hover); }
.button--ghost { background: transparent; color: var(--color-link); border-color: var(--color-border); }
.button--ghost:hover { background: var(--color-brand-soft); border-color: var(--color-brand); }
.button--small { min-height: 44px; padding: 8px 18px; font-size: var(--text-sm); }
.button--block { width: 100%; }
@media (prefers-reduced-motion: reduce) { .button { transition: none; } }

.cta__long { display: inline; }
.cta__short { display: none; }
@media (min-width: 641px) { .cta__long { display: none; } .cta__short { display: inline; } }

.chip-list { display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; padding: 0; margin-top: var(--space-4); }
.chip-list li {
  padding: 4px 12px; border: 1px solid var(--color-border-subtle); border-radius: var(--radius-pill);
  background: var(--color-bg); font-size: var(--text-sm); font-weight: 600;
}

.badge {
  display: inline-block; margin-bottom: var(--space-3); padding: 2px 10px;
  border-radius: var(--radius-pill); background: var(--color-brand-soft);
  font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.02em;
}

.notice { border-radius: var(--radius-sm); padding: var(--space-3) var(--space-4); font-weight: 600; }
.notice--success { background: var(--color-success-bg); color: var(--color-success); }
.notice--warning { background: var(--color-warning-bg); color: var(--color-warning); }
.notice:empty { display: none; }

.poll-status { margin-top: var(--space-3); font-size: var(--text-sm); font-weight: 400; }

/* ---------- Header ---------- */
.skip-link {
  position: absolute; left: var(--space-4); top: -100px; z-index: 10;
  padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--color-brand); color: var(--color-on-brand); font-weight: 700;
}
.skip-link:focus { top: var(--space-2); }

.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding-block: var(--space-4); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--color-text); font-family: var(--font-display); font-size: 1.25rem; font-weight: 800; text-decoration: none; }
.brand img { width: 32px; height: 32px; }
.site-nav { display: none; }
.site-nav ul { display: flex; gap: var(--space-5); list-style: none; padding: 0; margin: 0; }
.site-nav a { display: inline-block; padding: 10px 0; color: var(--color-text); font-weight: 600; text-decoration: none; }
.site-nav a:hover { text-decoration: underline; text-decoration-thickness: 2px; }
@media (min-width: 900px) { .site-nav { display: block; } }

/* ---------- Hero ---------- */
.hero { padding-block: clamp(24px, 5vw, 72px) clamp(48px, 8vw, 96px); }
.hero .container { display: grid; gap: var(--space-7); align-items: center; }
@media (min-width: 900px) { .hero .container { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: var(--space-8); } }

.eyebrow {
  display: inline-block; margin-bottom: var(--space-4); padding: 4px 14px;
  border-radius: var(--radius-pill); background: var(--color-brand-soft);
  font-size: var(--text-sm); font-weight: 700;
}
.hero h1 { font-size: var(--text-hero); line-height: 1.08; font-weight: 800; letter-spacing: -0.02em; }
.lead { margin-top: var(--space-4); max-width: 34rem; font-size: var(--text-lg); line-height: 1.5; color: var(--color-text-muted); }
.hero__cta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-5); margin-top: var(--space-5); }
.hero__cta .button { width: 100%; }
@media (min-width: 641px) { .hero__cta .button { width: auto; } }
.hero__note { margin-top: var(--space-4); font-size: var(--text-sm); color: var(--color-text-muted); }

/* ---------- Hero demo ---------- */
/* One design unit (--u) is 1 px of the 112 x 112 bird at 100%. The demo draws the bird smaller. */
.demo { --u: 0.64px; --ink: #1B2B34; }
@media (min-width: 640px) { .demo { --u: 0.8px; } }

.demo__screen {
  position: relative; overflow: hidden; aspect-ratio: 4 / 3.2;
  border: 1px solid var(--color-border-subtle); border-radius: var(--radius-lg);
  background: var(--wallpaper); box-shadow: var(--shadow-demo);
}

.demo__window {
  position: absolute; inset: 27% 7% 17%;
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-surface);
}
.demo__titlebar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  padding: 6px 12px; background: var(--color-brand); color: var(--color-on-brand);
  font-size: var(--text-xs); font-weight: 700;
}
.demo__controls { display: flex; gap: 6px; }
.demo__controls i { width: 10px; height: 10px; border: 2px solid currentColor; border-radius: 2px; }
.demo__body { padding: 10px 12px; font-family: var(--font-mono); font-size: 13px; line-height: 1.75; color: var(--color-text); }
.demo__meta { margin-bottom: 4px; font-family: var(--font-sans); font-size: var(--text-xs); color: var(--color-text-muted); }

.typed { display: block; }
.typed span {
  display: inline-block; overflow: hidden; white-space: nowrap; vertical-align: top;
  border-right: 2px solid transparent;
}
.typed--1 span { width: 30ch; }
.typed--2 span { width: 28ch; }
.typed--3 span { width: 31ch; }

.demo__taskbar {
  position: absolute; inset: auto 0 0; display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  height: 11%; min-height: 26px; padding-inline: 12px; background: #1E2A32; color: #F1F5F6; font-size: 11px;
}
.demo__taskbar img { width: 16px; height: 16px; }

.demo__bird {
  position: absolute; top: 3%; left: 40%; z-index: 2;
  width: calc(112 * var(--u)); height: calc(150 * var(--u));
}
.demo__sprite { position: relative; width: calc(112 * var(--u)); height: calc(112 * var(--u)); }
.demo__sprite img { position: absolute; inset: 0; width: 100%; height: 100%; visibility: hidden; }
.demo__sprite img.is-still { visibility: visible; }

.demo__pill {
  position: absolute; top: calc(96 * var(--u)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; height: calc(44 * var(--u)); padding-inline: calc(16 * var(--u));
  border: calc(3 * var(--u)) solid var(--ink); border-radius: var(--radius-pill);
  background: #FFFFFF; color: var(--ink);
  font-size: calc(20 * var(--u)); font-weight: 600; white-space: nowrap;
}
.demo__pill::before {
  content: ""; position: absolute; top: calc(-7 * var(--u)); left: 50%;
  width: calc(11 * var(--u)); height: calc(11 * var(--u)); margin-left: calc(-5.5 * var(--u));
  border-top: calc(3 * var(--u)) solid var(--ink); border-left: calc(3 * var(--u)) solid var(--ink);
  background: #FFFFFF; transform: rotate(45deg);
}

.demo figcaption {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3);
  margin-top: var(--space-3); font-size: var(--text-sm); color: var(--color-text-muted);
}
.demo figcaption span { flex: 1 1 16rem; }
.demo__toggle {
  min-height: 44px; padding: 8px 16px; border: 2px solid var(--color-border); border-radius: var(--radius-pill);
  background: var(--color-surface); color: var(--color-text); font: inherit; font-size: var(--text-sm); font-weight: 600; cursor: pointer;
}
.demo__toggle:hover { border-color: var(--color-brand); background: var(--color-brand-soft); }

/* Playing: the loop is 12 s. The typing never stops while the bird crosses (2.4 s to 8.0 s). */
.demo[data-playing="true"] .typed--1 span { animation: type-1 12s linear infinite; }
.demo[data-playing="true"] .typed--2 span { animation: type-2 12s linear infinite; }
.demo[data-playing="true"] .typed--3 span { animation: type-3 12s linear infinite; }
.demo[data-playing="true"] .demo__bird { animation: cross 12s linear infinite; }
.demo[data-playing="true"] .demo__arc { animation: arc 12s linear infinite; }
.demo[data-playing="true"] .demo__bob { animation: bob 250ms ease-in-out infinite alternate; }
.demo[data-playing="true"] .demo__sprite img { animation: flap 500ms steps(1, end) infinite; animation-delay: calc(var(--i) * 83.333ms - 500ms); }

.demo__arc, .demo__bob { position: relative; width: 100%; height: 100%; }

@keyframes flap { 0%, 16.66% { visibility: visible; } 16.67%, 100% { visibility: hidden; } }
@keyframes bob { from { transform: translateY(-3px); } to { transform: translateY(3px); } }
@keyframes cross {
  0%, 20% { left: -45%; }
  31.7% { left: 1.2%; }
  43.3% { left: 32.5%; }
  55% { left: 63.8%; }
  66.7%, 100% { left: 110%; }
}
@keyframes arc {
  0%, 20% { transform: translateY(calc(-20 * var(--u))); }
  31.7% { transform: translateY(calc(2.6 * var(--u))); }
  43.3% { transform: translateY(calc(12 * var(--u))); }
  55% { transform: translateY(calc(2.6 * var(--u))); }
  66.7%, 100% { transform: translateY(calc(-20 * var(--u))); }
}
@keyframes type-1 {
  0% { width: 0; border-right-color: transparent; }
  5% { width: 0; border-right-color: var(--color-text); animation-timing-function: steps(30, end); }
  30% { width: 30ch; border-right-color: var(--color-text); }
  31% { width: 30ch; border-right-color: transparent; }
  99.9% { width: 30ch; border-right-color: transparent; }
  100% { width: 0; }
}
@keyframes type-2 {
  0%, 32.4% { width: 0; border-right-color: transparent; }
  32.5% { width: 0; border-right-color: var(--color-text); animation-timing-function: steps(28, end); }
  55.8% { width: 28ch; border-right-color: var(--color-text); }
  56.8% { width: 28ch; border-right-color: transparent; }
  99.9% { width: 28ch; border-right-color: transparent; }
  100% { width: 0; }
}
@keyframes type-3 {
  0%, 58.2% { width: 0; border-right-color: transparent; }
  58.3% { width: 0; border-right-color: var(--color-text); animation-timing-function: steps(31, end); }
  83.3% { width: 31ch; border-right-color: var(--color-text); }
  99.9% { width: 31ch; border-right-color: var(--color-text); }
  100% { width: 0; border-right-color: transparent; }
}

/* ---------- Sections ---------- */
.steps { display: grid; gap: var(--space-4); list-style: none; padding: 0; counter-reset: step; }
@media (min-width: 900px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.steps > li { counter-increment: step; }
.steps > li::before {
  content: counter(step); content: counter(step) / "";
  display: grid; place-items: center; width: 36px; height: 36px; margin-bottom: var(--space-3);
  border-radius: var(--radius-pill); background: var(--color-brand); color: var(--color-on-brand);
  font-weight: 800;
}
.mini {
  margin-top: var(--space-4); padding: var(--space-3); border: 1px dashed var(--color-border-subtle); border-radius: var(--radius-sm);
  background: var(--color-bg); font-size: var(--text-sm); display: flex; align-items: center; gap: var(--space-2); min-width: 0;
}
.mini img { width: 20px; height: 20px; flex: none; }
.mini code { flex: 1; min-width: 0; }
.mini .mini__btn { flex: none; padding: 2px 10px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-weight: 600; }
.steps__result { margin-top: var(--space-5); font-size: var(--text-lg); font-weight: 700; }

.coming { margin-top: var(--space-6); }
.coming h3 { font-size: var(--text-lg); font-weight: 700; }
.coming__list { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-3); list-style: none; padding: 0; }
.vote {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: 44px; padding: 6px 16px;
  border: 2px solid var(--color-border); border-radius: var(--radius-pill);
  background: var(--color-surface); color: var(--color-text); font: inherit; font-weight: 600; cursor: pointer;
}
.vote:hover { border-color: var(--color-brand); background: var(--color-brand-soft); }
.vote[aria-pressed="true"] { border-color: var(--color-brand); background: var(--color-brand-soft); }
.vote__state { font-size: var(--text-sm); color: var(--color-link); }

.icon { width: 32px; height: 32px; margin-bottom: var(--space-3); color: var(--color-brand); fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.price { max-width: 40rem; }
.price__amount { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 800; }
.price__period { font-family: var(--font-sans); font-size: var(--text-base); font-weight: 500; }
.price--yearly { border: 2px solid var(--color-brand); }
.price__saving { color: var(--color-link); font-weight: 700; }
.pricing-plans { max-width: 54rem; }
.pricing-note { max-width: 54rem; margin-top: var(--space-4); color: var(--color-text-muted); font-size: var(--text-sm); }
.download-options { max-width: 48rem; }

/* ---------- Form ---------- */
.form-card { max-width: 40rem; }
.field { display: grid; gap: 6px; margin: 0 0 var(--space-4); padding: 0; border: 0; min-width: 0; }
.field > label, .field > legend { padding: 0; font-weight: 600; }
.hint { font-size: var(--text-sm); color: var(--color-text-muted); font-weight: 400; }

.input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 2px solid var(--color-border); border-radius: var(--radius-sm);
  background: var(--color-surface); color: var(--color-text); font: inherit;
}
.input[aria-invalid="true"] { border-color: var(--color-danger); }
.error { color: var(--color-danger); font-weight: 600; font-size: var(--text-sm); }
.error[hidden] { display: none; }

.chips { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-2); }
.chip { position: relative; display: block; }
.chip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.chip span {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 6px 12px;
  border: 2px solid var(--color-border); border-radius: var(--radius-pill);
  background: var(--color-surface); font-weight: 600; text-align: center;
}
.chip input:checked + span { border-color: var(--color-brand); background: var(--color-brand-soft); }
.chip input:checked + span::before { content: "\2713"; content: "\2713" / ""; font-weight: 800; }
.chip input:focus-visible + span { outline: 3px solid var(--color-focus); outline-offset: 2px; }

.check { display: flex; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-4); }
.check input { flex: none; width: 24px; height: 24px; margin: 2px 0 0; accent-color: var(--color-brand); }
.check label { font-weight: 400; }
.check .error { margin-top: 4px; }

.optional { margin: 0 0 var(--space-4); border: 1px solid var(--color-border-subtle); border-radius: var(--radius-sm); padding: 0 var(--space-4); }
.optional summary { display: flex; align-items: center; min-height: 48px; font-weight: 600; cursor: pointer; }
.optional[open] summary { margin-bottom: var(--space-2); }

.done:focus { outline: none; }
.done h3 { font-size: var(--text-xl); font-weight: 800; margin-bottom: var(--space-2); }

/* ---------- FAQ ---------- */
.faq { max-width: 46rem; }
.faq details { border-bottom: 1px solid var(--color-border-subtle); }
.faq summary { display: flex; align-items: center; min-height: 56px; padding-block: 8px; font-size: var(--text-lg); font-weight: 700; cursor: pointer; }
.faq details p { padding-bottom: var(--space-4); color: var(--color-text-muted); }

/* ---------- Footer and plain pages ---------- */
.site-footer { padding-block: var(--space-7); border-top: 1px solid var(--color-border-subtle); font-size: var(--text-sm); }
.site-footer ul { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); list-style: none; padding: 0; margin: 0 0 var(--space-4); }
.site-footer a { display: inline-block; padding-block: 8px; }
.site-footer p { max-width: 46rem; color: var(--color-text-muted); }
.site-footer p + p { margin-top: var(--space-2); }

.prose { max-width: 42rem; padding-block: var(--space-7) var(--space-8); }
.prose h1 { font-size: var(--text-2xl); font-weight: 800; line-height: 1.15; margin-bottom: var(--space-4); }
.prose h2 { font-size: var(--text-lg); font-weight: 700; margin: var(--space-5) 0 var(--space-2); }
.prose ul { padding-left: 1.25rem; }
.prose li + li { margin-top: var(--space-2); }

/* ---------- Utilities ---------- */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}
