/* 1n1 site — direction A, "Two halves" (ADR 0003). docs/design/visual-system.md documents these
   tokens; every colour, size and font below comes from them. Dark is the default theme; light is
   chosen with the toggle and remembered. */

@font-face {
  font-family: 'Archivo';
  src: url('/assets/fonts/archivo-1n1.woff2') format('woff2');
  font-weight: 400 800;
  font-stretch: 100% 125%;
  font-display: swap;
}

:root {
  /* Brand colours (ADR 0002 in 1n1-studio). */
  --ink: #06302e;
  --paper: #f2faf8;
  --fuchsia: #ec3a86;

  /* Dark theme, the default. */
  --ground: var(--ink);
  --text: var(--paper);
  --muted: #a9c6c1;
  --line: #1e4e4a;
  --half-ground: var(--paper);
  --half-text: var(--ink);
  --accent: var(--fuchsia);

  --sans: 'Archivo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.75rem;
  --step-3: clamp(2rem, 1.4rem + 2.6vw, 3.5rem);
  --step-4: clamp(2.25rem, 1.2rem + 4vw, 4.25rem);
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --gutter: clamp(1rem, 0.6rem + 2vw, 3.5rem);
  --measure: 66ch;
  --radius: 22%;
  --cut: 8px;
  --ease: cubic-bezier(0.2, 0.7, 0.1, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration: 420ms;
  --card: 18px;

  color-scheme: dark;
}

:root[data-theme='light'] {
  --ground: var(--paper);
  --text: var(--ink);
  --muted: #3d5d59;
  --line: #c4dad5;
  --half-ground: var(--ink);
  --half-text: var(--paper);
  color-scheme: light;
}

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

html {
  scrollbar-gutter: stable;
  background: var(--ground);
  color: var(--text);
  font-family: var(--sans);
  font-size: 100%;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--muted) var(--ground);
}

body {
  margin: 0;
  background: var(--ground);
}

::selection {
  background: var(--text);
  color: var(--ground);
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.12;
  text-wrap: balance;
}

p,
ul,
dl {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 3px;
  text-underline-offset: 0.3em;
}

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

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: var(--space-4);
  top: -4rem;
  z-index: 3;
  padding: var(--space-2) var(--space-4);
  /* Text on fuchsia is under 4.5:1; fuchsia marks the outline only. */
  background: var(--text);
  color: var(--ground);
  outline: 3px solid var(--accent);
  font-weight: 700;
}

.skip:focus {
  top: var(--space-4);
}

/* The page: the half, the divider, the column. One column on a phone; side by side from 760 px. */
.page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto 1fr;
  min-height: 100vh;
}

.half {
  background: var(--half-ground);
  color: var(--half-text);
  padding: var(--space-6) var(--gutter) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  --a: var(--accent);
  --bg: var(--half-ground);
}

.half .top {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.32em;
  font-size: 1.625rem;
  text-decoration: none;
  align-self: flex-start;
}

.mkw {
  display: block;
  flex: none;
}

.mk {
  display: block;
  flex: none;
  height: 1.12em;
  width: calc(1.12em * 60 / 92);
  color: var(--half-text);
}

.wm {
  font-weight: 800;
  font-stretch: 125%;
  letter-spacing: -0.02em;
  line-height: 1;
  white-space: nowrap;
}

.wm i {
  display: inline-block;
  font-style: normal;
  color: var(--accent);
}

/* "clicks" in the line is a button: it presses the domino (domino.js). A row of the domino's pips
   underlines it. */
.clicks {
  display: inline-block;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: underline dotted var(--accent);
  text-decoration-thickness: 0.09em;
  text-underline-offset: 0.12em;
}

.clicks:hover {
  color: var(--accent);
}

.hl {
  font-size: var(--step-3);
  font-weight: 800;
  font-stretch: 125%;
  letter-spacing: -0.015em;
  line-height: 1.04;
  max-width: 14ch;
}

.half nav ul {
  list-style: none;
  padding: 0;
  display: flex;
  gap: var(--space-5);
  font-weight: 600;
}

/* Navigation, the address and the footer links are tap targets: at least 44 by 44 px. */
.half nav a,
.half .mail a,
.applinks a,
.ft a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
}

.half nav a[aria-current='page'] {
  text-decoration-thickness: 4px;
}

.half .mail {
  font-size: var(--step--1);
}

.half.inner .hl,
.half.inner .mail {
  display: none;
}

.half.inner {
  padding-block: var(--space-5);
  gap: var(--space-3);
}

.half.inner .top {
  gap: var(--space-3);
}

.divide {
  height: var(--cut);
  background: var(--ground);
}

.col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.body {
  padding: var(--space-6) var(--gutter) var(--space-7);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  flex: 1;
}

.body > h1,
.policy h1,
.apphero h1 {
  font-size: var(--step-3);
  font-weight: 800;
  font-stretch: 125%;
  letter-spacing: -0.015em;
}

.body h2 {
  font-size: var(--step--1);
  font-weight: 700;
  color: var(--muted);
  margin-bottom: var(--space-3);
}

.bio {
  max-width: var(--measure);
  font-size: var(--step-1);
}

.big {
  font-size: var(--step-2);
  font-weight: 700;
}

/* Apps */
.applist {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.app {
  position: relative;
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
  padding-block: var(--space-5);
  border-top: 2px solid var(--text);
}

/* The app's name is the row's link, and its hit area is the whole row. */
.app h3 a::after,
.app .h3 a::after {
  content: '';
  position: absolute;
  inset: 0;
}

.app:has(h3 a:focus-visible, .h3 a:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--card);
}

.app h3 a:focus-visible,
.app .h3 a:focus-visible {
  outline: none;
}

.applinks a {
  position: relative;
  z-index: 1;
}

.app h3,
.app .h3 {
  font-size: var(--step-2);
  font-weight: 800;
  font-stretch: 125%;
  color: var(--text);
  margin: 0 0 var(--space-1);
}

.app h3 a,
.app .h3 a {
  text-decoration: none;
}

.app h3 a:hover,
.app .h3 a:hover {
  text-decoration: underline;
  text-decoration-color: var(--accent);
}

.appicon {
  display: block;
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
}

.applinks {
  margin-top: var(--space-2);
}

.status {
  margin-top: var(--space-1);
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--muted);
}

/* The back arrow and breadcrumb at the top of every page but home. */
.trail {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 2px solid var(--line);
  border-radius: 50%;
  color: var(--text);
}

.back svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.back:hover {
  border-color: var(--accent);
}

/* App page */
.crumb {
  font-size: var(--step--1);
  color: var(--muted);
}

.apphero {
  display: flex;
  gap: var(--space-5);
  align-items: center;
}

.apphero .appicon {
  width: 88px;
  height: 88px;
}

.apphero .line {
  font-size: var(--step-1);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--space-5);
  border-radius: 999px;
  background: var(--text);
  color: var(--ground);
  font-weight: 700;
  text-decoration: none;
}

.cta .status {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  margin: 0;
  padding: 0 var(--space-4);
  border: 2px solid var(--line);
  border-radius: 999px;
}

/* Screenshots: a row that scrolls sideways and snaps to each phone. */
.shots {
  list-style: none;
  padding: 0 0 var(--space-3);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(160px, 220px);
  gap: var(--space-4);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
}

.shots li {
  scroll-snap-align: start;
}

.shots img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--card);
  border: 2px solid var(--line);
}

.feat {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: var(--space-4);
}

.card {
  position: relative;
  padding: var(--space-5);
  border: 2px solid var(--line);
  border-radius: var(--card);
}

.card::before {
  content: '';
  display: block;
  width: 10px;
  height: 10px;
  margin-bottom: var(--space-3);
  border-radius: 50%;
  background: var(--accent);
}

.feat h3,
.unlocks h3 {
  font-size: var(--step-1);
  font-weight: 700;
  margin-bottom: var(--space-1);
}

.feat p {
  color: var(--muted);
}

/* The paid tier: the half's colours, so it reads as the other side of the domino. */
.plus {
  padding: var(--space-6) var(--space-5);
  border-radius: calc(var(--card) + 6px);
  background: var(--half-ground);
  color: var(--half-text);
}

.plus h2 {
  font-size: var(--step-3);
  font-weight: 800;
  font-stretch: 125%;
  text-transform: none;
  letter-spacing: -0.02em;
  color: inherit;
  margin: 0 0 var(--space-2);
}

.plushead {
  margin-bottom: var(--space-5);
}

.terms {
  font-size: var(--step-1);
}

.unlocks {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
  gap: var(--space-5) var(--space-5);
}

.unlocks li {
  padding-left: var(--space-5);
  position: relative;
}

.unlocks li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.45em;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.trial {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 2px solid currentColor;
  font-weight: 600;
}

.meta {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-3) var(--space-5);
}

.meta dt {
  font-weight: 700;
}

.meta dd {
  margin: 0;
}

.plain {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  font-size: var(--step-1);
}

/* Privacy policy */
.policy {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.updated {
  font-size: var(--step--1);
  color: var(--muted);
}

.tablewrap {
  overflow-x: auto;
}

.policy table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
}

.policy th,
.policy td {
  text-align: left;
  vertical-align: top;
  padding: var(--space-3) var(--space-4) var(--space-3) 0;
  border-top: 1px solid var(--line);
}

.policy thead th {
  border-top: 0;
  color: var(--muted);
  font-weight: 600;
}

/* The permissions table. Its names are long and unbroken, so they may break anywhere; on a phone
   each row stacks, every cell under its own label, and the table becomes a table again at 760px. */
.permissions code {
  overflow-wrap: anywhere;
  word-break: break-all;
}

.permissions thead {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.permissions tr {
  display: block;
  border-top: 1px solid var(--line);
  padding: var(--space-3) 0;
}

.permissions td {
  display: block;
  border-top: 0;
  padding: var(--space-1) 0;
}

.permissions td::before {
  content: attr(data-label);
  display: block;
  color: var(--muted);
  font-weight: 600;
}

.versions {
  list-style: none;
  padding: 0;
}

.prose {
  max-width: var(--measure);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.prose h2 {
  font-size: var(--step-1);
  color: var(--text);
  margin: var(--space-4) 0 0;
}

.prose ul {
  padding-left: 1.2em;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Footer */
.ft {
  padding: var(--space-5) var(--gutter) var(--space-6);
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-5);
  font-size: var(--step--1);
  color: var(--muted);
}

/* The theme toggle: the top-right corner. The icon is a sun in light and a moon in dark: a cut
   circle slides over the disc and the rays draw in or out. */
.theme {
  position: fixed;
  top: max(var(--space-4), env(safe-area-inset-top, 0px));
  right: var(--space-4);
  z-index: 2;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--ground);
  color: var(--text);
  cursor: pointer;
  padding: 0;
}

.theme-icon {
  width: 24px;
  height: 24px;
  overflow: visible;
}

.theme-icon .disc {
  fill: currentColor;
  transform-origin: 12px 12px;
  transition: transform var(--duration) var(--ease);
}

.theme-icon .cut {
  transition: transform var(--duration) var(--ease);
}

.theme-icon .rays {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  transform-origin: 12px 12px;
  transition:
    transform var(--duration) var(--ease),
    opacity var(--duration) var(--ease);
}

/* Dark: the moon. The disc grows, the cut slides in, the rays fold away. */
:root:not([data-theme='light']) .theme-icon .disc {
  transform: scale(1.35);
}

:root:not([data-theme='light']) .theme-icon .cut {
  transform: translate(-7px, 3px);
}

:root:not([data-theme='light']) .theme-icon .rays {
  transform: rotate(-60deg) scale(0.4);
  opacity: 0;
}

/* Light: the sun. */
:root[data-theme='light'] .theme-icon .cut {
  transform: translate(6px, -6px);
}

.theme:hover {
  border-color: var(--accent);
}

/* The half stays in view only where all of it fits; on a short window it scrolls with the page, so
   the navigation is never held below the fold. */
@media (min-width: 760px) and (min-height: 720px) {
  .half,
  .half.inner {
    position: sticky;
    top: 0;
    align-self: start;
  }
}

@media (min-width: 760px) {
  .page {
    grid-template-columns: minmax(0, 5fr) var(--cut) minmax(0, 7fr);
    grid-template-rows: auto;
  }

  .half,
  .half.inner {
    /* At least the window's height, and taller when its content needs it: a fixed height clipped
       the navigation on short windows (a phone held sideways, a zoomed desktop). */
    min-height: 100vh;
    padding: var(--space-8) var(--space-7);
    justify-content: space-between;
  }

  .half .top,
  .half.inner .top {
    gap: var(--space-7);
  }

  .hl {
    font-size: var(--step-4);
  }

  /* The same size on every page, so the half doesn't change as you move between pages. */
  .half.inner .hl {
    display: block;
  }

  .half.inner .mail {
    display: block;
  }

  .divide {
    height: auto;
  }

  .body {
    padding: var(--space-8) var(--space-7) var(--space-8);
    gap: var(--space-7);
  }

  .ft {
    padding-inline: var(--space-7);
  }

  .plus {
    padding: var(--space-7) var(--space-6);
  }

  .permissions thead {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
    white-space: normal;
    display: table-header-group;
  }

  .permissions tr {
    display: table-row;
    padding: 0;
  }

  .permissions td {
    display: table-cell;
    border-top: 1px solid var(--line);
    padding: var(--space-3) var(--space-4) var(--space-3) 0;
  }

  .permissions td::before {
    content: none;
  }

  .permissions td:first-child {
    width: 40%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .theme-icon .disc,
  .theme-icon .cut,
  .theme-icon .rays {
    transition: none;
  }
}

/* Motion (ADR 0003, decision 6). Everything here is decoration: the page reads the same without it,
   and none of it runs for a visitor who asks for reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  /* Page to page: the half stays put, the content crossfades as it rises in. */
  @view-transition {
    navigation: auto;
  }

  .half {
    view-transition-name: half;
  }

  .theme {
    view-transition-name: toggle;
  }

  .body {
    view-transition-name: content;
  }

  ::view-transition-group(half),
  ::view-transition-old(half),
  ::view-transition-new(half),
  ::view-transition-group(toggle),
  ::view-transition-old(toggle),
  ::view-transition-new(toggle) {
    animation: none;
  }

  ::view-transition-old(half),
  ::view-transition-old(toggle) {
    opacity: 0;
  }

  ::view-transition-old(content) {
    animation: fade-out 180ms ease-in both;
  }

  ::view-transition-new(content) {
    animation: fade-in 260ms ease-out both;
  }

  /* The theme toggle: the new theme opens as a circle from the button (theme.js). */
  :root.theming .half,
  :root.theming .theme,
  :root.theming .body {
    view-transition-name: none;
  }

  :root.theming::view-transition-old(root) {
    animation: none;
  }

  :root.theming::view-transition-new(root) {
    animation: reveal 620ms var(--ease) both;
  }

  /* Arriving: each block rises into place in turn. The half only does this on a fresh visit; when a
     page is reached through a view transition (the inline head script marks it), it's already there. */
  .body > *,
  .half .top > *,
  .half .mail {
    animation: rise 640ms var(--ease) both;
  }

  .body > :nth-child(2),
  .half .top > :nth-child(2) {
    animation-delay: 70ms;
  }

  .body > :nth-child(3),
  .half .top > :nth-child(3) {
    animation-delay: 140ms;
  }

  .body > :nth-child(4),
  .half .mail {
    animation-delay: 210ms;
  }

  .body > :nth-child(n + 5) {
    animation-delay: 280ms;
  }

  :root.arrived .half .top > *,
  :root.arrived .half .mail,
  :root.arrived .mkw {
    animation: none;
  }

  /* The domino: it spins in on arrival, and turns over whenever the logo is pointed at. */
  .mkw {
    animation: domino-in 900ms var(--spring) 120ms both;
  }

  /* domino.js turns it (the `rotate` property); hover grows it quickly and lets go slowly, and a
     press squashes it before it pops back up. */
  .mkw {
    transition: scale 900ms var(--ease);
  }

  .brand:hover .mkw,
  .brand:focus-visible .mkw {
    scale: 1.14;
    transition: scale 260ms cubic-bezier(0.3, 1.3, 0.6, 1);
  }

  .brand.pressed .mkw {
    scale: 0.8;
    transition: scale 90ms ease-out;
  }

  /* The wordmark steps aside while the domino turns, and drifts back once it rests. */
  .wm {
    transition: translate 900ms var(--ease);
  }

  .brand:hover .wm,
  .brand.spinning .wm {
    translate: 0.28em 0;
    transition-duration: 300ms;
  }

  .brand {
    cursor: pointer;
  }

  .clicks {
    transition:
      transform 320ms var(--spring),
      color 200ms var(--ease);
  }

  .clicks:active {
    transform: scale(0.92);
    transition-duration: 90ms;
  }

  /* Cards and rows answer the pointer. */
  @supports (animation-timeline: view()) {
    .feat > li,
    .unlocks > li,
    .shots > li {
      animation: rise linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 60%;
    }
  }

  a {
    transition:
      text-decoration-thickness 180ms var(--ease),
      text-underline-offset 180ms var(--ease);
  }

  .card {
    transition: border-color 260ms var(--ease);
  }

  .card::before,
  .unlocks li::before {
    transition: transform 320ms var(--spring);
  }

  .card:hover {
    border-color: var(--accent);
  }

  .card:hover::before,
  .unlocks li:hover::before {
    transform: scale(1.6);
  }

  .appicon {
    transition: transform 360ms var(--spring);
  }

  .app:hover .appicon,
  .app:has(h3 a:focus-visible, .h3 a:focus-visible) .appicon {
    transform: rotate(-6deg) scale(1.06);
  }

  .back svg {
    transition: transform 240ms var(--spring);
  }

  .back:hover svg {
    transform: translateX(-3px);
  }

  .btn {
    transition:
      transform 220ms var(--ease),
      box-shadow 220ms var(--ease);
  }

  .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 0 var(--accent);
  }

  .theme {
    transition:
      border-color 200ms var(--ease),
      transform 300ms var(--spring);
  }

  .theme:hover {
    transform: rotate(-12deg) scale(1.06);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}

@keyframes fade-out {
  to {
    opacity: 0;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes reveal {
  from {
    clip-path: circle(0 at var(--tx, 100%) var(--ty, 0));
  }
  to {
    clip-path: circle(150vmax at var(--tx, 100%) var(--ty, 0));
  }
}

@keyframes domino-in {
  from {
    opacity: 0;
    transform: rotate(-180deg) scale(0.4);
  }
}
