/* Codedly Labs — site styles.
   Apple-derived tokens: neutral triad + one action blue, SF Pro system stack,
   17px body baseline, pill CTAs, restrained depth. Mobile-first. */

:root {
  --bg: #ffffff;
  --surface: #f5f5f7;
  --surface-warm: #fbfbfd;
  --fg: #1d1d1f;
  --fg-2: #424245;
  --muted: #6e6e73;
  --meta: #6e6e73; /* small utility text — kept at muted contrast for WCAG AA */
  --border: #d2d2d7;
  --border-soft: #e8e8ed;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-active: #0066cc;
  --link: #0066cc;
  --link-bright: #2997ff;
  --success: #16a34a;
  --danger: #d23636;
  --on-dark: #f5f5f7;
  --on-dark-muted: #a1a1a6;
  --dark-border: #38383a;
  --font:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Icons",
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 17px;
  --text-lg: 21px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 980px;
  --section-y: 40px;
  --container-max: 1024px;
  --focus-ring: 0 0 0 4px rgba(0, 113, 227, 0.35);
  --ease: cubic-bezier(0.28, 0, 0.22, 1);
}

/* ---------- Base ---------- */

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

html {
  scroll-padding-top: 4.5rem; /* keep fragment targets clear of the sticky nav */
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.47;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.08;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.5rem, 7.5vw, 4.5rem); /* 40 → 72px */
  letter-spacing: -0.02em;
  line-height: 1.05;
}

h2 {
  font-size: clamp(1.75rem, 4.5vw, 3rem); /* 28 → 48px */
}

h3 {
  font-size: clamp(1.25rem, 3vw, 1.75rem); /* 20 → 28px */
  line-height: 1.15;
}

p {
  margin: 0 0 1em;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

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

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--bg);
  color: var(--accent);
  padding: 0.5rem 1rem;
  z-index: 100;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

/* ---------- Layout ---------- */

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.section {
  padding-top: var(--section-y);
  padding-bottom: var(--section-y);
}

.band-gray {
  background: var(--surface);
}

.band-dark {
  background: #000;
  color: var(--on-dark);
}

.band-dark h1,
.band-dark h2,
.band-dark h3 {
  color: var(--on-dark);
}

.band-dark a {
  color: var(--link-bright);
}

.narrow {
  max-width: 42rem;
}

.center {
  text-align: center;
}

.lede {
  font-size: var(--text-lg);
  line-height: 1.4;
  color: var(--muted);
  letter-spacing: 0;
}

.sublede {
  color: var(--muted);
}

.divider {
  border: 0;
  border-top: 1px solid var(--border-soft);
  margin: 2rem 0;
}

/* ---------- Nav ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(251, 251, 253, 0.85);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border-soft);
}

.nav-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 3.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--fg);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand:hover {
  text-decoration: none;
}


.nav-links {
  display: none;
  align-items: center;
  gap: 1.75rem;
  margin-left: auto;
}

.nav-links a {
  font-size: var(--text-sm);
  color: var(--fg-2);
}

.nav-links a:hover {
  color: var(--fg);
  text-decoration: none;
}

.nav-links a[aria-current="page"] {
  color: var(--fg);
  font-weight: 600;
}

.nav-cta {
  margin-left: auto;
}

/* Mobile menu (no JS: details/summary) */
.nav-menu {
  position: relative;
  margin-left: 0.25rem;
}

.nav-menu summary {
  list-style: none;
  cursor: pointer;
  height: 44px;
  width: 44px;
  justify-content: center;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
}

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

.nav-menu summary:hover {
  background: var(--surface);
}

.nav-menu-panel {
  position: absolute;
  right: -1.25rem;
  top: calc(100% + 0.5rem);
  min-width: 11rem;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  padding: 0.5rem;
}

.nav-menu-panel a {
  display: block;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  color: var(--fg);
}

.nav-menu-panel a:hover {
  background: var(--surface);
  text-decoration: none;
}

@media (min-width: 768px) {
  .nav-links {
    display: flex;
  }

  .nav-menu {
    display: none;
  }

  .nav-cta {
    margin-left: 1.75rem;
  }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-block;
  border: 0;
  border-radius: var(--radius-pill);
  padding: 0.75rem 1.375rem;
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.2;
  cursor: pointer;
  text-align: center;
  transition:
    background-color 220ms var(--ease),
    transform 150ms var(--ease);
}

.btn:hover {
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

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

.btn-dark {
  background: var(--fg);
  color: #fff;
}

.btn-dark:hover {
  background: #333336;
}

.btn-sm {
  padding: 0.5rem 1.0625rem;
  font-size: var(--text-sm);
}

.btn-block {
  width: 100%;
}

.btn-dark-band {
  background: var(--link-bright);
  color: #000;
}

.btn-dark-band:hover {
  background: #4da6ff;
}

.arrow-link {
  color: var(--link);
  font-size: var(--text-lg);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.arrow-link::after {
  content: "›";
  font-size: 1.3em;
  line-height: 1;
  transition: transform 220ms var(--ease);
}

.arrow-link:hover {
  text-decoration: none;
}

.arrow-link:hover::after {
  transform: translateX(2px);
}

.band-dark .arrow-link {
  color: var(--link-bright);
}

/* ---------- Hero ---------- */

.hero {
  padding-top: 3.5rem;
  padding-bottom: 3rem;
  text-align: center;
}

.hero .lede {
  max-width: 40rem;
  margin: 1.25rem auto 0;
}

.hero-actions {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.hero-note {
  font-size: var(--text-sm);
  color: var(--meta);
  margin: 0.875rem 0 0;
}

@media (min-width: 768px) {
  .hero {
    padding-top: 6rem;
    padding-bottom: 5rem;
  }

  .hero-actions {
    flex-direction: row;
    justify-content: center;
  }
}

/* ---------- Page header (inner pages) ---------- */

.page-head {
  padding-top: 3rem;
}

.page-head h1 {
  font-size: clamp(2.25rem, 6vw, 3.5rem);
}

.page-head .lede {
  margin-top: 1rem;
}

@media (min-width: 768px) {
  .page-head {
    padding-top: 4.5rem;
  }
}

/* ---------- Cards ---------- */

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
}

.band-gray .card {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.04);
}

.card h3 {
  margin-bottom: 0.5rem;
}

.card p {
  color: var(--fg-2);
  margin-bottom: 1.25rem;
}

.card .arrow-link {
  font-size: var(--text-base);
}

.card-plain {
  border: 0;
  background: transparent;
  padding: 0;
}

.grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 768px) {
  .grid {
    gap: 1.25rem;
  }

  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---------- Chips ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  padding: 0.25rem 0.75rem;
}

.chip-dev {
  color: var(--accent);
  background: rgba(0, 113, 227, 0.08);
  border-color: rgba(0, 113, 227, 0.2);
}

.band-dark .chip {
  color: var(--on-dark-muted);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--dark-border);
}

/* ---------- Waitlist form ---------- */

.waitlist {
  max-width: 30rem;
}

.waitlist-form {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.waitlist-form input[type="email"] {
  font-family: inherit;
  font-size: var(--text-base);
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.75rem 1.375rem;
  -webkit-appearance: none;
  appearance: none;
}

.waitlist-form input[type="email"]::placeholder {
  color: var(--meta);
}

.waitlist-form input[type="email"]:focus-visible {
  box-shadow: var(--focus-ring);
  border-color: var(--accent);
}

@media (min-width: 540px) {
  .waitlist-form {
    flex-direction: row;
    align-items: stretch;
  }

  .waitlist-form input[type="email"] {
    flex: 1;
    min-width: 0;
  }
}

/* Zero-JS confirmation: the endpoint redirects back with a fragment
   (#waitlist-ok / #waitlist-err) and :target reveals the message. */
.waitlist-msg {
  display: none;
  margin: 0.875rem 0 0;
  font-size: var(--text-base);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
}

.waitlist-msg:target {
  display: block;
}

.waitlist-msg.ok {
  color: #166534; /* darker than --success for 4.5:1 on the tinted background */
  background: rgba(22, 163, 74, 0.08);
}

.waitlist-msg.err {
  color: var(--danger);
  background: rgba(210, 54, 54, 0.08);
}

.hero .waitlist {
  margin: 2rem auto 0;
}

/* ---------- Products: featured (dark chapter) ---------- */

.feature {
  padding-top: var(--section-y);
  padding-bottom: var(--section-y);
}

.feature-tagline {
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  color: var(--on-dark-muted);
  line-height: 1.25;
  margin-top: 1rem;
}

.feature p {
  color: var(--on-dark-muted);
  max-width: 38rem;
}

.feature .waitlist-form input[type="email"] {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--dark-border);
  color: var(--on-dark);
}

.feature .waitlist-form input[type="email"]::placeholder {
  color: var(--on-dark-muted);
}

.feature .waitlist-msg {
  background: rgba(255, 255, 255, 0.06);
}

.feature .waitlist-msg.ok {
  color: #30d158;
}

.feature .waitlist-msg.err {
  color: #ff6961;
}

/* CSS illustration: conversation before profiles */
.convo {
  max-width: 24rem;
  margin: 2.5rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.convo-bubble {
  max-width: 78%;
  padding: 0.625rem 1rem;
  border-radius: 1.25rem;
  font-size: var(--text-sm);
  line-height: 1.35;
}

.convo-bubble.them {
  background: rgba(255, 255, 255, 0.1);
  color: var(--on-dark);
  border-bottom-left-radius: 0.3rem;
  align-self: flex-start;
}

.convo-bubble.you {
  background: var(--link-bright);
  color: #000;
  border-bottom-right-radius: 0.3rem;
  align-self: flex-end;
}

.convo-profile {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--dark-border);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
}

.convo-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: repeating-linear-gradient(
    45deg,
    #48484a,
    #48484a 4px,
    #3a3a3c 4px,
    #3a3a3c 8px
  );
  flex: none;
}

.convo-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.convo-lines span {
  display: block;
  height: 0.5rem;
  border-radius: 0.25rem;
  background: #48484a;
}

.convo-lines span:nth-child(2) {
  width: 60%;
}

.convo-lock {
  font-size: var(--text-xs);
  color: var(--on-dark-muted);
  margin-left: auto;
  white-space: nowrap;
}

/* ---------- Products: lab & open source ---------- */

.lab-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
}

.lab-row:last-child {
  border-bottom: 0;
}

.lab-row h3 {
  font-size: 1.25rem;
}

.lab-row p {
  color: var(--muted);
  margin: 0.25rem 0 0;
}

.oss-card h3 {
  font-size: 1.25rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0;
}

.oss-card p {
  color: var(--fg-2);
}

.oss-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1rem;
}

/* ---------- Services ---------- */

.service-num {
  font-size: var(--text-sm);
  color: var(--meta);
  margin-bottom: 0.375rem;
}

.steps {
  counter-reset: step;
}

.step {
  position: relative;
  padding: 1.5rem 0 1.5rem 3rem;
  border-bottom: 1px solid var(--border-soft);
}

.step:last-child {
  border-bottom: 0;
}

.step::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 1.4rem;
  width: 1.875rem;
  height: 1.875rem;
  border-radius: 50%;
  background: var(--fg);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step h3 {
  font-size: 1.25rem;
  margin-bottom: 0.375rem;
}

.step p {
  color: var(--muted);
  margin: 0;
}

/* ---------- Contact ---------- */

.contact-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}

.contact-card .contact-email {
  font-size: clamp(1.25rem, 3.5vw, 1.75rem);
  font-weight: 600;
  color: var(--link);
  letter-spacing: -0.01em;
}

.kv {
  margin: 0;
}

.kv dt {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--meta);
  margin-top: 1.125rem;
}

.kv dd {
  margin: 0.25rem 0 0;
  color: var(--fg-2);
}

/* ---------- Legal pages ---------- */

.legal {
  padding-top: 3rem;
  padding-bottom: 4rem;
}

.legal h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
}

.legal h2 {
  font-size: 1.25rem;
  margin: 2rem 0 0.5rem;
  letter-spacing: -0.01em;
}

.legal p,
.legal li {
  color: var(--fg-2);
  line-height: 1.55;
}

.legal ul {
  list-style: disc;
  padding-left: 1.25rem;
  margin-bottom: 1em;
}

.legal li {
  margin-bottom: 0.375rem;
}

.legal-date {
  color: var(--meta);
  font-size: var(--text-sm);
}

/* ---------- Footer ---------- */

.footer {
  background: var(--surface);
  border-top: 1px solid var(--border-soft);
  font-size: var(--text-sm);
  color: var(--muted);
  padding: 2.5rem 0 2rem;
}

.footer a {
  color: var(--fg-2);
}

.footer a:hover {
  color: var(--fg);
}

.footer-grid {
  display: grid;
  gap: 2rem;
  grid-template-columns: 1fr;
}

.footer-brand p {
  margin: 0.625rem 0 0;
  max-width: 22rem;
  line-height: 1.45;
}

.footer h3 {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--meta);
  margin-bottom: 0.625rem;
}

.footer-links li {
  margin-bottom: 0.5rem;
}

.footer-legal {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: var(--text-xs);
  color: var(--meta);
}

.footer-legal a {
  color: var(--muted);
  display: inline-block;
  padding: 0.375rem 0;
}
.footer-legal p {
  margin: 0;
}

.footer-legal-links {
  display: flex;
  gap: 1.25rem;
}

@media (min-width: 768px) {
  .footer-grid {
    grid-template-columns: 2fr 1fr 1fr;
  }

  .footer-legal {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

/* ---------- Section spacing at desktop ---------- */

@media (min-width: 768px) {
  :root {
    --section-y: 100px;
  }
}

/* ---------- Motion & print ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

@media print {
  .nav,
  .footer,
  .waitlist-form {
    display: none;
  }
}

/* ---------- Motion layer (progressive enhancement) ----------
   Hidden state applies only when the inline <head> snippet adds .js
   (script present) AND the user hasn't requested reduced motion.
   reveal.js adds .revealed as elements enter the viewport. */

@media (prefers-reduced-motion: no-preference) {
  .js main .section h2,
  .js main .section .lede,
  .js main .card,
  .js main .step,
  .js main .lab-row,
  .js main .kv,
  .js main .feature h2,
  .js main .feature .feature-tagline,
  .js main .feature p,
  .js main .feature .waitlist {
    opacity: 0;
    transform: translateY(16px);
    transition:
      opacity 0.6s var(--ease),
      transform 0.6s var(--ease);
  }

  .js main .section h2.revealed,
  .js main .section .lede.revealed,
  .js main .card.revealed,
  .js main .step.revealed,
  .js main .lab-row.revealed,
  .js main .kv.revealed,
  .js main .feature h2.revealed,
  .js main .feature .feature-tagline.revealed,
  .js main .feature p.revealed,
  .js main .feature .waitlist.revealed {
    opacity: 1;
    transform: none;
  }

  /* Chat illustration: bubbles and locked profile appear in sequence
     once the .convo container itself is revealed. */
  .js main .convo .convo-bubble,
  .js main .convo .convo-profile {
    opacity: 0;
    transform: translateY(10px);
    transition:
      opacity 0.5s var(--ease),
      transform 0.5s var(--ease);
  }

  .js main .convo.revealed .convo-bubble:nth-child(1) { transition-delay: 0.1s; }
  .js main .convo.revealed .convo-bubble:nth-child(2) { transition-delay: 0.5s; }
  .js main .convo.revealed .convo-bubble:nth-child(3) { transition-delay: 0.9s; }
  .js main .convo.revealed .convo-profile { transition-delay: 1.35s; }

  .js main .convo.revealed .convo-bubble,
  .js main .convo.revealed .convo-profile {
    opacity: 1;
    transform: none;
  }
}

/* Card hover lift — pointer devices only */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .card {
    transition:
      opacity 0.6s var(--ease),
      transform 0.22s var(--ease),
      box-shadow 0.22s var(--ease);
  }

  .card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.1);
  }
}

/* Gradient keyword accent — Apple blue family into system teal
   (no purple; both stops meet 3:1 on their surface for large text). */
.grad {
  background: linear-gradient(96deg, #0071e3, #0093b8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.band-dark .grad {
  background: linear-gradient(96deg, #2997ff, #40c8e0);
}
