@font-face {
  font-family: "Young Serif";
  src: url("/assets/fonts/YoungSerif-Regular.ttf") format("truetype");
  font-display: swap;
  font-style: normal;
  font-weight: 400;
}

/* B) Tokens */
:root {
  --gray-0: #ffffff;
  --gray-25: #fafafa;
  --gray-50: #f5f5f5;
  --gray-100: #eeeeee;
  --gray-200: #e0e0e0;
  --gray-300: #cfcfcf;
  --gray-400: #bdbdbd;
  --gray-500: #8a8a8a;
  --gray-600: #6a6a6a;
  --gray-700: #4a4a4a;
  --gray-800: #2b2b2b;
  --gray-900: #111111;
  --black: #000000;

  --success-600: #8fd6a2;
  --success-700: #6fcb8a;
  --success-100: #e6f4ea;
  --error-600: #f3a0a0;
  --error-700: #e78585;
  --error-100: #fdeaea;

  --background: var(--gray-25);
  --surface: var(--gray-50);
  --surface-elevated: var(--gray-100);
  --surface-pure: var(--gray-0);

  --border-subtle: var(--gray-200);
  --border-strong: var(--gray-300);
  --divider: var(--gray-300);

  --text-primary: var(--gray-900);
  --text-secondary: var(--gray-600);
  --text-tertiary: var(--gray-500);
  --text-disabled: var(--gray-500);
  --text-on-primary: var(--gray-0);

  --pressed-overlay: rgba(0, 0, 0, 0.1);
  --hover-overlay: rgba(0, 0, 0, 0.06);
  --focus-ring: var(--gray-900);
  --scrim: rgba(0, 0, 0, 0.4);
  --shadow: rgba(0, 0, 0, 0.12);

  --success: var(--success-600);
  --success-strong: var(--success-700);
  --success-surface: var(--success-100);
  --error: var(--error-600);
  --error-strong: var(--error-700);
  --error-surface: var(--error-100);

  --space-0: 0px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 16px;

  --content-max: 960px;
  --content-max-narrow: 720px;
  --header-max: 1100px;
  --container-max: 1200px;
  --container-padding: clamp(16px, 3vw, 28px);
  --section-gap: clamp(24px, 4vw, 48px);
  --hero-gap: clamp(20px, 4vw, 48px);

  --font-serif: "Young Serif", ui-serif, Georgia, serif;
  --font-sans:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

/* A) Reset and base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: clamp(16px, 1.2vw, 18px);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

body.modal-open {
  overflow: hidden;
}

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

h1,
h2,
h3,
h4,
p,
ul,
ol {
  margin: 0;
}

ul,
ol {
  padding-left: var(--space-4);
}

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

a:visited,
a:hover {
  color: var(--text-primary);
}

button {
  font-family: inherit;
}

/* C) Typography */
h1,
h2,
h3,
h4 {
  color: var(--text-primary);
  font-family: var(--font-serif);
}

h1 {
  font-size: clamp(28px, 2.8vw, 34px);
  line-height: 1.15;
}

h2 {
  font-size: clamp(22px, 2.2vw, 28px);
  line-height: 1.2;
}

h3 {
  font-size: clamp(18px, 1.8vw, 20px);
  line-height: 1.3;
}

/* D) Layout utilities */
main {
  display: flex;
  flex-direction: column;
  gap: var(--section-gap);
  padding: var(--section-gap) 0 clamp(40px, 6vw, 72px);
}

.container {
  width: min(var(--container-max), 100%);
  margin-inline: auto;
  padding-inline: var(--container-padding);
}

.container.narrow {
  --container-max: var(--content-max-narrow);
}

.section {
  display: flex;
  flex-direction: column;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.stack-lg {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.muted {
  color: var(--text-secondary);
}

/* E) Components */
.site-header {
  background: var(--surface-pure);
  border-bottom: 1px solid var(--divider);
}

.site-header .container {
  --container-max: var(--header-max);
}

.header-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-block: var(--space-4);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
}

.logo img {
  width: 96px;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
}

.site-nav a {
  font-size: 14px;
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.nav-toggle {
  display: none;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-m);
  background: var(--surface-pure);
  color: var(--text-primary);
  font-size: 14px;
  padding: 0 var(--space-3);
}

.nav-toggle:active {
  background: var(--gray-100);
}

.hero {
  padding: clamp(24px, 6vw, 72px) 0;
}

.hero-grid {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--hero-gap);
}

.hero-copy {
  flex: 1 1 0;
}

.hero-visual {
  display: flex;
  flex: 0.95 1 0;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  text-align: center;
}

.hero-visual img {
  width: clamp(180px, 24vw, 240px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-l);
  background: var(--surface-pure);
  box-shadow: 0 12px 28px var(--shadow);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius-m);
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  text-decoration: underline;
}

.btn-primary {
  background: var(--gray-900);
  color: var(--text-on-primary);
}

.btn-primary:hover,
.btn-primary:visited {
  color: var(--text-on-primary);
}

.btn-primary:active {
  background: var(--black);
}

.btn-secondary {
  border-color: var(--border-strong);
}

.btn-note {
  color: var(--text-secondary);
  font-size: 12px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-m);
  background: var(--surface);
  padding: var(--space-4);
}

.screenshots-grid {
  display: flex;
  flex-wrap: nowrap;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x mandatory;
  --shot-gap: 10px;
  --shot-gap-2: calc(var(--shot-gap) + var(--shot-gap));
  --shot-gap-3: calc(var(--shot-gap-2) + var(--shot-gap));
  --shot-gap-4: calc(var(--shot-gap-2) + var(--shot-gap-2));
  padding-inline: 0;
  gap: var(--shot-gap);
}

.screenshot-item {
  flex: 0 0 calc((100% - var(--shot-gap-2)) / 3);
  min-width: 0;
  scroll-snap-align: start;
}

.appshot {
  display: block;
  width: 100%;
  height: auto;
}

.screenshots-grid::-webkit-scrollbar {
  height: 0;
}

.cta {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-m);
  background: var(--surface);
  padding: var(--space-8);
  text-align: center;
}

.cta .button-row {
  justify-content: center;
}

.site-footer {
  border-top: 1px solid var(--divider);
  background: var(--surface-pure);
}

.site-footer .container {
  --container-max: var(--header-max);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  color: var(--text-secondary);
  font-size: 14px;
  padding-block: var(--space-4);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.footer-links a {
  text-decoration: none;
}

.footer-links a:hover,
.footer-links a:focus-visible {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus {
  position: static;
  width: auto;
  height: auto;
  margin: var(--space-4);
}

.faq details {
  border-top: 1px solid var(--divider);
  padding: var(--space-3) 0;
}

.faq details:last-child {
  border-bottom: 1px solid var(--divider);
}

.faq summary {
  cursor: pointer;
  list-style: none;
  font-weight: 600;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: "+";
  float: right;
}

.faq details[open] summary::after {
  content: "-";
}

.faq p {
  margin-top: var(--space-2);
  color: var(--text-secondary);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--scrim);
  padding: var(--space-4);
}

.modal-overlay.is-open {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 520px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-m);
  background: var(--surface-pure);
  box-shadow: 0 12px 30px var(--shadow);
  padding: var(--space-6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.modal-close {
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-m);
  background: var(--surface-pure);
  padding: 0 var(--space-3);
}

/* F) Page-specific rules */
body[data-current="home"] main > .section:has(.screenshots-grid) + .section {
  margin-top: calc(var(--section-gap) * -1);
}

body[data-current="home"] main > .section:has(.screenshots-grid) + .section .cta {
  --cta-expand: min(5%, max(0px, calc(var(--container-padding) - 6px)));
  width: calc(100% + (var(--cta-expand) * 2));
  margin-inline: calc(var(--cta-expand) * -1);
}

.legal {
  line-height: 1.7;
}

.legal h1 {
  margin-bottom: var(--space-2);
  font-size: 28px;
  line-height: 1.2;
}

.legal h2 {
  margin-top: var(--space-6);
  font-size: 24px;
  line-height: 1.25;
}

.legal h3 {
  margin-top: var(--space-5);
  font-size: 20px;
  line-height: 1.3;
}

.legal p,
.legal li {
  color: var(--text-secondary);
}

.legal p {
  margin-top: var(--space-3);
}

.legal ul {
  margin-top: var(--space-3);
  padding-left: var(--space-4);
}

.legal li + li {
  margin-top: var(--space-2);
}

/* G) Accessibility and media queries */
a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

@media (max-width: 639px) {
  body[data-current="home"] main > .section:has(.screenshots-grid) + .section .cta {
    --cta-expand: min(3%, max(0px, calc(var(--container-padding) - 10px)));
  }

  .hero-grid {
    align-items: center;
  }

  .hero-visual {
    order: -1;
  }

  .hero-copy {
    align-items: center;
    text-align: center;
  }

  .site-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    border-top: 1px solid var(--divider);
    padding: var(--space-4) 0 0;
  }

  .site-nav.is-open {
    display: flex;
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .button-row {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    width: 100%;
  }

  .hero-copy .button-row {
    width: 100%;
    max-width: 340px;
    align-items: center;
  }

  .hero-copy .btn {
    width: min(100%, 320px);
  }
}

@media (min-width: 640px) and (max-width: 899px) {
  .hero-grid {
    align-items: center;
  }

  .hero-visual {
    order: -1;
  }

  .hero-copy {
    align-items: center;
    text-align: center;
  }

  .hero-copy .button-row {
    justify-content: center;
  }

  .screenshot-item {
    flex: 0 0 calc((100% - var(--shot-gap-3)) / 4);
  }
}

@media (min-width: 900px) and (max-width: 1199px) {
  .hero-grid {
    flex-direction: row;
    align-items: center;
  }

  .hero-copy {
    flex: 1.05 1 0;
  }

  .hero-visual {
    flex: 0.95 1 0;
  }

  .screenshot-item {
    flex: 0 0 calc((100% - var(--shot-gap-3)) / 4);
  }
}

@media (min-width: 1200px) {
  .hero-grid {
    flex-direction: row;
    align-items: center;
  }

  .hero-copy {
    flex: 1.05 1 0;
  }

  .hero-visual {
    flex: 0.95 1 0;
  }

  .screenshots-grid {
    overflow-x: visible;
  }

  .screenshot-item {
    flex: 0 0 calc((100% - var(--shot-gap-4)) / 5);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
