/* ---------------------------------------------------------------
   KinPiggy — warm editorial ledger
   Cream paper, navy ink, and the three brand colours used strictly:
   coral = attention/over, teal = structure/people, amber = money.
   --------------------------------------------------------------- */

:root {
  color-scheme: light;

  --paper:      #fbf7f0;
  --paper-2:    #f4ece0;
  --paper-3:    #efe5d6;
  --ink:        #21304e;
  --ink-soft:   #5d6b87;
  --ink-faint:  #8b95a9;
  --rule:       rgba(33, 48, 78, 0.13);
  --rule-firm:  rgba(33, 48, 78, 0.26);

  --coral: #f47966;
  --teal:  #3c9997;
  --amber: #eca337;

  --shell: min(1120px, 100% - 2.5rem);
  --gut: clamp(3.5rem, 9vw, 7.5rem);

  --serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --sans:  'Familjen Grotesk', 'Avenir Next', 'Segoe UI', sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: clamp(1.02rem, 0.97rem + 0.25vw, 1.14rem);
  line-height: 1.62;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Paper grain — a single inline SVG turbulence, no network cost. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.037;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

a { color: inherit; }

:focus-visible {
  outline: 2.5px solid var(--teal);
  outline-offset: 3px;
  border-radius: 3px;
}

.shell { width: var(--shell); margin-inline: auto; }

/* ---------------- type ---------------- */

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.022em; line-height: 1.06; }

h2 {
  font-size: clamp(2.1rem, 1.35rem + 3.1vw, 3.5rem);
  max-width: 17ch;
}

h3 {
  font-size: clamp(1.16rem, 1.08rem + 0.38vw, 1.4rem);
  letter-spacing: -0.012em;
  line-height: 1.28;
}

p { margin: 0 0 1.05em; }
p:last-child { margin-bottom: 0; }

.lede {
  font-size: clamp(1.16rem, 1.04rem + 0.55vw, 1.42rem);
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 46ch;
}

.serif { font-family: var(--serif); font-style: italic; font-weight: 400; letter-spacing: 0; }

.muted { color: var(--ink-soft); }

/* An editorial aside — the opinionated lines from the spec get room to breathe. */
.aside {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.28rem, 1.05rem + 1.05vw, 1.95rem);
  line-height: 1.32;
  letter-spacing: 0;
  color: var(--ink);
  max-width: 24ch;
  margin: 0;
  padding-left: 1.1rem;
  border-left: 2px solid var(--coral);
}
.aside.teal  { border-color: var(--teal); }
.aside.amber { border-color: var(--amber); }

/* ---------------- header ---------------- */

header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--rule);
}

.bar {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  min-height: 4.2rem;
}

.brand { display: flex; align-items: center; gap: 0.62rem; text-decoration: none; margin-right: auto; }
.brand img { width: 7.2rem; }
.brand b {
  font-size: 1.22rem;
  letter-spacing: -0.025em;
}
.brand b i { font-style: normal; color: var(--coral); }

nav { display: flex; gap: 1.5rem; font-size: 0.94rem; }
nav a {
  text-decoration: none;
  color: var(--ink-soft);
  padding-bottom: 2px;
  border-bottom: 1.5px solid transparent;
  transition: color 0.18s, border-color 0.18s;
}
nav a:hover { color: var(--ink); border-color: var(--coral); }
@media (max-width: 800px) { nav { display: none; } }
@media (max-width: 560px) { header .btn { display: none; } }
@media (max-width: 380px) { .lang { font-size: 0.8rem; } }

/* ---------------- language switch ---------------- */

.lang {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.lang a { color: var(--ink-faint); text-decoration: none; transition: color 0.18s; }
.lang a:hover { color: var(--ink); }
.lang .lang-on { color: var(--ink); }
.lang .lang-sep { color: var(--rule-firm); font-weight: 400; }
.lang-foot { margin-top: 1.4rem; }

/* skip link — visible only once focused */
.skip {
  position: absolute;
  left: 0.75rem;
  top: -4rem;
  z-index: 100;
  background: var(--ink);
  color: var(--paper);
  padding: 0.7rem 1.2rem;
  border-radius: 0 0 0.7rem 0.7rem;
  font-size: 0.94rem;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.18s;
}
.skip:focus { top: 0; }

/* ---------------- buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.82rem 1.5rem;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-weight: 600;
  font-size: 0.98rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.16s cubic-bezier(.2,.8,.3,1), box-shadow 0.16s, background 0.16s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 10px 22px -12px rgba(33,48,78,.6); }
.btn:active { transform: translateY(0); }

.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: rgba(33,48,78,.055); }

.btn[aria-disabled='true'] {
  background: transparent;
  color: var(--ink-soft);
  border-style: dashed;
  border-color: var(--rule-firm);
  cursor: default;
}
.btn[aria-disabled='true']:hover { transform: none; box-shadow: none; }

/* ---------------- hero ---------------- */

.hero { padding: clamp(3rem, 7vw, 6rem) 0 clamp(3rem, 6vw, 5rem); position: relative; }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(0, 0.94fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
}
/* The device is tall; centring it would push the headline below the fold, so
   the copy sits at the top and the phone hangs down beside it. */
.hero-grid > :first-child { padding-top: clamp(0.5rem, 2.5vw, 2.5rem); }
@media (max-width: 880px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-grid > :first-child { padding-top: 0; }
  .hero-shot { margin-top: 1rem; }
}

.hero h1 {
  font-size: clamp(3.1rem, 1.5rem + 6.6vw, 6.1rem);
  line-height: 0.94;
  letter-spacing: -0.042em;
}
.hero h1 em {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--coral);
}

.hero .lede { margin-top: 1.5rem; }

.hero-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.9rem; margin-top: 2rem; }

.req {
  font-size: 0.86rem;
  color: var(--ink-faint);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-top: 1.6rem;
}

/* three little piggies, scaled like the brand mark */
.piggies { display: flex; align-items: flex-end; gap: 0.45rem; margin-bottom: 1.6rem; }
.piggies span { display: block; border-radius: 999px; }
.piggies span:nth-child(1) { width: 0.52rem; height: 0.52rem; background: var(--coral); }
.piggies span:nth-child(2) { width: 0.78rem; height: 0.78rem; background: var(--teal); }
.piggies span:nth-child(3) { width: 1.08rem; height: 1.08rem; background: var(--amber); }

/* ---------------- phone frame ---------------- */

.phone {
  width: min(100%, 292px);
  padding: 0.5rem;
  background: linear-gradient(150deg, #2c3c5c, #17233a);
  border-radius: 2.7rem;
  box-shadow:
    0 1px 0 rgba(255,255,255,.22) inset,
    0 34px 60px -30px rgba(33,48,78,.62),
    0 8px 20px -14px rgba(33,48,78,.5);
  transition: transform 0.4s cubic-bezier(.2,.8,.3,1);
}
.phone img { border-radius: 2.25rem; width: 100%; }
.phone:hover { transform: translateY(-6px) rotate(-0.4deg); }

.phone.lean  { transform: rotate(-1.6deg); }
.phone.lean:hover { transform: translateY(-6px) rotate(-0.6deg); }
.phone.lean-r { transform: rotate(1.6deg); }
.phone.lean-r:hover { transform: translateY(-6px) rotate(0.6deg); }

.hero-shot { display: flex; justify-content: center; position: relative; }
/* a soft amber glow behind the hero device */
.hero-shot::before {
  content: '';
  position: absolute;
  width: 120%; aspect-ratio: 1;
  top: 50%; left: 50%;
  translate: -50% -50%;
  background: radial-gradient(circle, rgba(236,163,55,.19), transparent 62%);
  z-index: -1;
}

/* ---------------- ledger sections ---------------- */

section.rule { border-top: 1px solid var(--rule); }

.sec { padding: var(--gut) 0; }

.sec-head {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  gap: 0 1.5rem;
  align-items: start;
}
@media (max-width: 700px) { .sec-head { grid-template-columns: 1fr; gap: 0.4rem; } }

.num {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.5rem;
  color: var(--coral);
  line-height: 1.5;
  padding-top: 0.15rem;
}
.sec:nth-of-type(even) .num { color: var(--teal); }

.sec-body { margin-top: clamp(2rem, 4vw, 3.2rem); }

/* two-column feature block, image and prose */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: center;
}
.split.narrow-shot { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); }
@media (max-width: 880px) {
  /* minmax(0, 1fr), not 1fr: a bare 1fr track has a min-content floor, and the
     permissions table would push the whole document wider than the viewport
     instead of scrolling inside its own wrapper. */
  .split, .split.narrow-shot { grid-template-columns: minmax(0, 1fr); }
  .split .shot { order: -1; justify-self: center; }
}
.shot { display: flex; justify-content: center; }

/* Two devices side by side. The width is a percentage so the pair never wraps
   into a tall stack when it lands in the narrower of the two columns. */
.pair { display: flex; gap: 1.1rem; justify-content: center; }
.pair .phone { width: min(47%, 240px); flex: 0 1 auto; }
@media (max-width: 420px) {
  .pair { gap: 0.7rem; }
  .pair .phone { padding: 0.32rem; border-radius: 1.7rem; }
  .pair .phone img { border-radius: 1.45rem; }
}

/* ---------------- notes: small ledger cards ---------------- */

.notes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0;
  margin-top: clamp(2.2rem, 4vw, 3.4rem);
  border-top: 1px solid var(--rule-firm);
}
.note {
  padding: 1.6rem 1.5rem 1.7rem 0;
  border-bottom: 1px solid var(--rule);
}
.note + .note { padding-left: 1.5rem; border-left: 1px solid var(--rule); }
@media (max-width: 640px) {
  .note + .note { padding-left: 0; border-left: 0; }
}
.note h3 { margin-bottom: 0.5rem; }
.note p { font-size: 0.98rem; color: var(--ink-soft); }

.tick {
  display: inline-block;
  width: 1.6rem; height: 0.22rem;
  border-radius: 2px;
  margin-bottom: 1rem;
  background: var(--coral);
}
.tick.teal { background: var(--teal); }
.tick.amber { background: var(--amber); }

/* ---------------- the Fuel demo ---------------- */

.demo {
  border: 1px solid var(--rule-firm);
  border-radius: 1.15rem;
  background: var(--paper-2);
  padding: clamp(1.3rem, 3vw, 2rem);
  max-width: 30rem;
}
.demo-label {
  font-size: 0.76rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 0.9rem;
}
.chips { display: flex; gap: 0.5rem; margin-bottom: 1.4rem; }
.chip {
  font: inherit;
  font-size: 0.94rem;
  font-weight: 600;
  padding: 0.42rem 1.05rem;
  border-radius: 999px;
  border: 1.5px solid var(--rule-firm);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.18s;
}
.chip:hover { border-color: var(--ink-soft); color: var(--ink); }
.chip[aria-pressed='true'] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
  border-top: 1px solid var(--rule);
}
.row:first-of-type { border-top: 0; }
.row .k { font-weight: 600; }
.row .k small { display: block; font-weight: 400; font-size: 0.84rem; color: var(--ink-faint); letter-spacing: 0.01em; }
.row .v { font-size: 1.32rem; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; }

.swap { animation: swap 0.34s cubic-bezier(.2,.8,.3,1); }
@keyframes swap {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ---------------- arithmetic demo ---------------- */

.calc {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--rule-firm);
  border-radius: 0.9rem;
  background: var(--paper-2);
  padding: 0.55rem 0.6rem 0.55rem 1.05rem;
  max-width: 24rem;
}
.calc span { color: var(--ink-faint); font-weight: 600; }
.calc input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1.24rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0.3rem 0;
}
.calc input:focus { outline: none; }
.calc output {
  font-size: 1.24rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--teal);
  padding: 0.3rem 0.85rem;
  border-radius: 0.55rem;
  background: rgba(60,153,151,.12);
  white-space: nowrap;
}
.calc output[data-bad='1'] { color: var(--ink-faint); background: transparent; }

/* ---------------- permissions table ---------------- */

.split > * { min-width: 0; }
.tbl-wrap { overflow-x: auto; max-width: 100%; margin-top: 1.6rem; }
table { border-collapse: collapse; width: 100%; min-width: 33rem; font-size: 0.97rem; }
caption {
  text-align: left;
  font-size: 0.76rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-bottom: 0.85rem;
}
th, td { text-align: left; padding: 0.82rem 1rem 0.82rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
thead th { border-bottom: 1px solid var(--rule-firm); font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; }
tbody th { font-weight: 700; white-space: nowrap; }
tbody th i { display: block; font-style: normal; font-weight: 400; font-size: 0.85rem; color: var(--ink-faint); }
td.yes { color: var(--teal); font-weight: 600; }
td.no  { color: var(--ink-faint); }

/* ---------------- privacy trio ---------------- */

.slab {
  background: var(--ink);
  color: var(--paper);
  border-radius: clamp(1.2rem, 3vw, 2rem);
  padding: clamp(2.2rem, 5vw, 4rem);
}
.slab h2 { color: var(--paper); }
.slab .num { color: var(--amber); }
.slab .lede { color: rgba(251,247,240,.72); }
.slab .note { border-color: rgba(251,247,240,.16); }
.slab .notes { border-color: rgba(251,247,240,.32); }
.slab .note + .note { border-left-color: rgba(251,247,240,.16); }
.slab .note p { color: rgba(251,247,240,.72); }
.slab .aside { color: var(--paper); }

/* ---------------- footer ---------------- */

footer { border-top: 1px solid var(--rule); padding: clamp(2.5rem, 5vw, 4rem) 0 3rem; }
.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 3rem;
  align-items: flex-start;
  justify-content: space-between;
}
.foot img { width: 8.6rem; }
.foot p { font-size: 0.92rem; color: var(--ink-faint); max-width: 34ch; }
.foot nav { display: flex; flex-direction: column; gap: 0.5rem; font-size: 0.94rem; }

/* ---------------- reveal ---------------- */

.reveal { opacity: 0; transform: translateY(18px); }
.reveal.in { opacity: 1; transform: none; transition: opacity 0.62s ease, transform 0.62s cubic-bezier(.2,.8,.3,1); }

.stagger > * { opacity: 0; transform: translateY(14px); animation: rise 0.72s cubic-bezier(.2,.8,.3,1) forwards; }
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.14s; }
.stagger > *:nth-child(3) { animation-delay: 0.23s; }
.stagger > *:nth-child(4) { animation-delay: 0.32s; }
.stagger > *:nth-child(5) { animation-delay: 0.41s; }
@keyframes rise { to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .reveal, .reveal.in, .stagger > * { opacity: 1 !important; transform: none !important; animation: none !important; transition: none !important; }
  .phone, .phone:hover, .phone.lean, .phone.lean-r { transition: none; }
  .swap { animation: none; }
}
