/* ==========================================================================
   Thinks — landing page
   Design tokens and motion language mirror the app (electron/renderer).
   ========================================================================== */

/* ---------- Fonts (same files the app ships) ---------- */
@font-face {
  font-family: "Playfair Display";
  src: url("./fonts/playfair-display-v40-latin_latin-ext-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Playfair Display";
  src: url("./fonts/playfair-display-v40-latin_latin-ext-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Playfair Display";
  src: url("./fonts/playfair-display-v40-latin_latin-ext-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --paper: #fffef8;
  --ink: #16130d;
  --ink-soft: #323232;
  --muted: #6b6557;
  --faint: #9a937f;
  --stroke: #deddd9;
  --hairline: #e9e6dc;
  --placeholder: #c4bcae;
  --card-a: #fbfbf9;
  --card-b: #efefef;
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Base ---------- */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

::selection {
  background: rgba(22, 19, 13, 0.14);
}

.wrap {
  width: min(1120px, 92vw);
  margin-inline: auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

main {
  position: relative;
  z-index: 1;
}

/* ---------- Texture & ambient light ---------- */
.grain {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
}

.blob-a {
  width: 56vw;
  height: 56vw;
  right: -18vw;
  top: -24vw;
  background: radial-gradient(circle at 30% 30%, #f4f2e9, transparent 62%);
  animation: drift-a 34s ease-in-out infinite alternate;
}

.blob-b {
  width: 48vw;
  height: 48vw;
  left: -16vw;
  top: 26vh;
  background: radial-gradient(circle at 60% 40%, #efeee7, transparent 60%);
  animation: drift-b 42s ease-in-out infinite alternate;
}

@keyframes drift-a {
  to {
    transform: translate(-6vw, 5vh) scale(1.08);
  }
}

@keyframes drift-b {
  to {
    transform: translate(5vw, -6vh) scale(1.05);
  }
}

/* ---------- Nav ---------- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  border-bottom: 1px solid transparent;
  transition: background 0.4s, border-color 0.4s;
}

.nav.scrolled {
  background: rgba(255, 254, 248, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-color: var(--hairline);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
}

.wordmark {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 26px;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 16px;
  line-height: 1.2;
  border-radius: 999px;
  padding: 15px 28px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  touch-action: manipulation;
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease), background 0.3s,
    color 0.3s, border-color 0.3s;
}

.btn-ink {
  background: var(--ink);
  color: var(--paper);
}

.btn-ink:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px -12px rgba(22, 19, 13, 0.45);
}

.btn-ink:active {
  transform: translateY(0);
}

.btn-ink:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.btn-ghost {
  border-color: var(--stroke);
  color: var(--ink);
  background: rgba(255, 254, 248, 0.6);
  padding: 10px 22px;
  font-size: 15px;
}

.btn-ghost:hover {
  border-color: var(--ink);
  transform: translateY(-1px);
}

.btn:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* ---------- Hero ---------- */
.hero {
  padding-top: clamp(100px, 13vh, 140px);
  text-align: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

.live-dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink);
}

.live-dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--ink);
  animation: ping 2.2s ease-out infinite;
}

@keyframes ping {
  0% {
    transform: scale(0.5);
    opacity: 0.8;
  }
  70%,
  100% {
    transform: scale(1.7);
    opacity: 0;
  }
}

h1 {
  margin: 22px 0 20px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(46px, 7.2vw, 86px);
  line-height: 1.04;
  letter-spacing: -0.02em;
}

h1 em {
  font-style: italic;
  font-weight: 500;
}

.lede {
  max-width: 620px;
  margin: 0 auto;
  color: var(--muted);
  font-size: clamp(17px, 1.6vw, 20px);
}

/* ---------- Signup form ---------- */
.signup {
  margin: 34px auto 0;
  max-width: 560px;
}

.signup-row {
  display: flex;
  gap: 10px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  box-shadow: 0 20px 45px -30px rgba(22, 19, 13, 0.25);
  transition: border-color 0.3s, box-shadow 0.3s;
}

.signup-row:focus-within {
  border-color: var(--ink);
  box-shadow: 0 24px 50px -28px rgba(22, 19, 13, 0.32);
}

.signup-row input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 0 8px 0 18px;
  font-family: var(--sans);
  font-size: 16px;
  color: var(--ink);
}

.signup-row input::placeholder {
  color: var(--placeholder);
}

.gdpr {
  max-width: 480px;
  margin: 14px auto 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--faint);
}

.form-status {
  min-height: 22px;
  margin: 10px 0 0;
  font-size: 14px;
}

.form-status.error {
  color: #8c2f21;
}

.signup-success {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--stroke);
  border-radius: 18px;
  box-shadow: 0 20px 45px -30px rgba(22, 19, 13, 0.25);
  animation: pop 0.55s var(--ease);
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
}

.signup-success .tick {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--ink);
}

.signup-success .tick svg {
  width: 15px;
  height: 12px;
  fill: none;
  stroke: var(--paper);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.signup-success p {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.signup-success strong {
  color: var(--ink);
}

/* ---------- Stage & live preview ---------- */
.stage {
  position: relative;
  width: 100%; /* explicit width: query containers can't size from contents */
  max-width: 900px;
  margin: clamp(28px, 4vh, 44px) auto 0;
  /* The demo interior scales with the stage's own width (container queries),
     so the fixed 3:2 window never overflows its content. */
  container-type: inline-size;
}

.stage::before {
  content: "";
  position: absolute;
  inset: -12% -18%;
  z-index: -1;
  background: radial-gradient(45% 45% at 50% 42%, rgba(243, 241, 232, 0.9), transparent 70%);
}

.floater {
  position: absolute;
  z-index: 2;
  max-width: 190px;
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  background: var(--paper);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  box-shadow: 0 24px 50px -30px rgba(22, 19, 13, 0.3);
  will-change: transform;
}

.f1 {
  left: -70px;
  top: -24px;
  transform: rotate(-5deg);
  animation: float-a 9s ease-in-out infinite alternate;
}

.f2 {
  right: -48px;
  top: 36%;
  transform: rotate(3.5deg);
  animation: float-b 11s ease-in-out infinite alternate;
}

.f3 {
  left: -44px;
  bottom: -30px;
  transform: rotate(-2deg);
  animation: float-a 12s ease-in-out infinite alternate-reverse;
}

@keyframes float-a {
  from {
    translate: 0 -8px;
  }
  to {
    translate: 0 10px;
  }
}

@keyframes float-b {
  from {
    translate: 0 10px;
  }
  to {
    translate: 0 -10px;
  }
}

.demo {
  position: relative;
  overflow: hidden;
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--stroke);
  border-radius: 20px;
  box-shadow: 0 60px 120px -50px rgba(22, 19, 13, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.6);
}

/* The preview mirrors the real app on a wide screen: a vast paper canvas
   with the writing column centered at 680px, one thought input, related
   thoughts underneath — same sizes, same motion. */
.demo-canvas {
  padding: clamp(48px, 8vh, 72px) clamp(24px, 6vw, 56px) clamp(32px, 5vh, 48px);
  padding: clamp(28px, 7cqw, 78px) clamp(24px, 6.8cqw, 56px) clamp(22px, 4.8cqw, 40px);
}

.demo-composer {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
  max-width: 680px; /* the app's real .composer max-width */
  margin-inline: auto;
}

.demo-editor {
  position: relative;
  min-height: 3em;
  font-family: var(--serif);
  font-size: clamp(24px, 3.4vw, 32px);
  font-size: clamp(20px, 5.2cqw, 32px);
  line-height: 1.5;
  color: var(--ink);
}

.demo-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.demo-placeholder {
  position: absolute;
  left: 0;
  top: 0;
  color: var(--placeholder);
  pointer-events: none;
  transition: opacity 0.3s;
}

.demo-placeholder.hidden {
  opacity: 0;
}

.caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 1px;
  vertical-align: -0.15em;
  background: var(--ink);
  animation: blink 1.15s steps(1) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* The signature save ritual, copied from the app. */
.demo-composer.flying .demo-editor {
  animation: fly-away 520ms ease forwards;
}

.demo-composer.flying .demo-suggestions {
  opacity: 0;
}

@keyframes fly-away {
  0% {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
  60% {
    opacity: 0.35;
  }
  100% {
    opacity: 0;
    transform: translateY(-42px);
    filter: blur(5px);
  }
}

.demo-suggestions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 178px;
  transition: opacity 0.3s;
}

.demo-sug-head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: clamp(28px, 5vh, 48px);
  margin-top: clamp(18px, 5cqw, 44px);
  font-family: var(--serif);
  font-size: 19px;
  font-size: clamp(15px, 2.4cqw, 19px);
  color: var(--ink-soft);
  opacity: 0;
  animation: sug-in 0.22s ease forwards;
}

.demo-sug-rule {
  flex: 1;
  height: 1px;
  background: var(--ink-soft);
}

.demo-sug-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  gap: clamp(8px, 1.7cqw, 14px);
}

.demo-sug {
  padding: 16px 20px;
  padding: clamp(10px, 1.9cqw, 16px) clamp(12px, 2.5cqw, 20px);
  font-family: var(--serif);
  font-weight: 500;
  font-size: 16px;
  font-size: clamp(13px, 2cqw, 16px);
  line-height: 1.35;
  color: var(--ink-soft);
  background: linear-gradient(180deg, var(--card-a) 0%, var(--card-b) 100%);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  opacity: 0;
  transform: translateY(6px);
  animation: sug-in 0.22s ease forwards;
}

@keyframes sug-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* On larger screens the preview window keeps a fixed 3:2 shape; the paper
   below the suggestions simply stretches, like the app's real canvas. */
@media (min-width: 721px) {
  .demo {
    aspect-ratio: 3 / 2;
  }

  .demo-canvas {
    display: flex;
    flex-direction: column;
    height: 100%;
  }

  .demo-composer {
    flex: 1;
    min-height: 0;
  }

  .demo-suggestions {
    flex: 1;
    min-height: 0;
  }
}

/* ---------- Features ---------- */
.features {
  padding-top: clamp(80px, 11vh, 130px);
}

.section-head {
  margin-bottom: clamp(48px, 7vh, 72px);
  text-align: center;
}

.section-head h2 {
  margin: 18px 0 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(32px, 4.4vw, 52px);
  line-height: 1.1;
  letter-spacing: -0.015em;
}

.cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.card {
  position: relative;
  overflow: hidden;
  padding: 34px 32px 30px;
  background: linear-gradient(180deg, #fffefb, #faf9f2);
  border: 1px solid var(--stroke);
  border-radius: 20px;
  transition: transform 0.5s var(--ease), box-shadow 0.5s var(--ease), border-color 0.4s;
}

.card:hover {
  transform: translateY(-5px);
  border-color: #cfccc4;
  box-shadow: 0 30px 60px -35px rgba(22, 19, 13, 0.35);
}

.card-num {
  position: absolute;
  top: 18px;
  right: 24px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 44px;
  line-height: 1;
  color: #ece5d3;
}

.card-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 22px;
  background: #fff;
  border: 1px solid var(--stroke);
  border-radius: 12px;
}

.card-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card h3 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 23px;
  letter-spacing: -0.01em;
}

.card p {
  margin: 0;
  max-width: 44ch;
  font-size: 16px;
  color: var(--muted);
}

/* ---------- Manifesto ---------- */
.manifesto {
  margin-top: clamp(80px, 11vh, 130px);
  padding: clamp(56px, 8vh, 90px) 0;
  text-align: center;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}

.manifesto-line {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(30px, 4.6vw, 54px);
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.manifesto-line em {
  font-style: italic;
}

/* ---------- The living map (semantic graph) ---------- */
.map {
  padding: clamp(64px, 9vh, 110px) 0;
}

.map-inner {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  align-items: center;
  gap: clamp(32px, 6vw, 80px);
}

.map-copy h2 {
  margin: 18px 0 16px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(30px, 3.8vw, 46px);
  line-height: 1.12;
  letter-spacing: -0.015em;
}

.map-copy p:last-child {
  margin: 0;
  max-width: 46ch;
  font-size: 17px;
  color: var(--muted);
}

.map-graph svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.edge {
  fill: none;
  stroke: var(--stroke);
  stroke-width: 1.2;
}

.edge.hot {
  stroke: #c6c0af;
  stroke-width: 1.4;
}

.node {
  fill: var(--ink);
  transform-box: fill-box;
  transform-origin: center;
  animation: node-pulse 3.2s ease-in-out infinite;
  animation-delay: var(--d, 0s);
}

@keyframes node-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.45);
    opacity: 0.55;
  }
}

/* Edges draw themselves in when the section scrolls into view. */
.js .reveal .edge {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1.1s var(--ease);
  transition-delay: calc(250ms + var(--e, 0) * 110ms);
}

.js .reveal.in .edge {
  stroke-dashoffset: 0;
}

/* ---------- Footer ---------- */
.footer {
  position: relative;
  z-index: 1; /* above the fixed ambient layer, like main */
  padding: 30px 0 calc(40px + env(safe-area-inset-bottom));
  font-size: 14px;
  color: var(--muted);
  border-top: 1px solid var(--hairline);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-note {
  font-family: var(--serif);
  font-style: italic;
}

/* ---------- Scroll reveal ---------- */
.js .reveal {
  opacity: 0;
  transform: translateY(26px);
  filter: blur(5px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease), filter 0.9s var(--ease);
  transition-delay: calc(var(--i, 0) * 95ms);
}

.js .reveal.in {
  opacity: 1;
  transform: none;
  filter: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 1060px) {
  .floater {
    display: none;
  }
}

@media (max-width: 860px) {
  .map-inner {
    grid-template-columns: 1fr;
  }

  .map-graph {
    max-width: 440px;
    margin-inline: auto;
    width: 100%;
  }
}

@media (max-width: 720px) {
  /* Comfortable 20 px gutters instead of the fluid 4 vw ones. */
  .wrap {
    width: calc(100% - 40px);
  }

  /* Keep both headline lines well inside the gutters so the hero
     reads as centered instead of stretched edge to edge. */
  h1 {
    margin: 16px 0 14px;
    font-size: clamp(36px, 10vw, 44px);
  }

  /* The stage glow must not stick out past the screen on narrow
     viewports — it fades out long before the edges anyway. */
  .stage::before {
    inset: -12% 0;
  }

  /* ---------- Compact vertical rhythm ----------
     Mobile is one long thumb-scroll: sections sit close together
     instead of being separated by desktop-sized breathing room. */
  .hero {
    padding-top: 88px;
  }

  .lede {
    font-size: 16px;
  }

  .signup {
    margin-top: 24px;
  }

  .signup-row {
    flex-direction: column;
    padding: 8px;
    border-radius: 22px;
  }

  .signup-row input {
    padding: 12px 14px;
  }

  .signup-row .btn {
    width: 100%;
  }

  .gdpr {
    margin-top: 10px;
    font-size: 12px;
  }

  .form-status {
    min-height: 18px;
    margin-top: 6px;
  }

  .stage {
    margin-top: 20px;
  }

  .demo-canvas {
    padding: 20px 18px 16px;
  }

  .demo-composer {
    gap: 14px;
  }

  .demo-sug-grid {
    grid-template-columns: 1fr;
  }

  /* Reserve just enough space for the incoming suggestions so the
     preview doesn't jump, without a tall empty block before them. */
  .demo-suggestions {
    min-height: 180px;
  }

  .features {
    padding-top: 64px;
  }

  .section-head {
    margin-bottom: 30px;
  }

  .section-head h2 {
    font-size: 30px;
  }

  /* Feature cards become compact rows: icon on the left, title and
     one line of copy on the right — no tall stacked cards. */
  .cards {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .card {
    display: grid;
    grid-template-columns: 38px 1fr;
    column-gap: 14px;
    align-items: start;
    padding: 16px 18px;
    border-radius: 16px;
  }

  .card:hover {
    transform: none;
  }

  .card-num {
    display: none;
  }

  .card-icon {
    grid-row: span 2;
    width: 38px;
    height: 38px;
    margin-bottom: 0;
  }

  .card h3 {
    margin: 0 0 3px;
    font-size: 18px;
  }

  .card p {
    font-size: 14.5px;
  }

  .manifesto {
    margin-top: 64px;
    padding: 42px 0;
  }

  .manifesto-line {
    font-size: 27px;
  }

  .map {
    padding: 56px 0 48px;
  }

  .map-copy h2 {
    margin: 12px 0 10px;
    font-size: 27px;
  }

  .map-copy p:last-child {
    font-size: 15.5px;
  }

  .footer {
    padding: 24px 0 calc(30px + env(safe-area-inset-bottom));
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }

  html {
    scroll-behavior: auto;
  }

  .js .reveal {
    opacity: 1;
    transform: none;
    filter: none;
  }
}
