/* The app's design tokens, restated for the web.
 *
 * Every value here has a counterpart in TunellyKit/Sources/Design: the palette
 * in Palette.swift, the spacing and radii in Metrics.swift, the type scale in
 * Typography.swift. When one moves, the other has to. */

@font-face {
  font-family: "JetBrains Mono NL";
  src: url("fonts/JetBrainsMonoNL-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono NL";
  src: url("fonts/JetBrainsMonoNL-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono NL";
  src: url("fonts/JetBrainsMonoNL-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono NL";
  src: url("fonts/JetBrainsMonoNL-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --background: #ffffff;
  --surface: #fafafa;
  --surface-active: #f0f0f0;
  --border: #e6e6e6;
  --border-strong: #d1d1d1;
  --text: #0a0a0a;
  --text-secondary: #6b6b6b;
  --text-tertiary: #a1a1a1;
  --accent: #0a0a0a;
  --on-accent: #ffffff;
  --success: #1a7f37;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-xxl: 32px;
  --space-xxxl: 48px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  --page: 20px;

  /* Two widths on purpose. The landing wants room to put four panels in a row;
   * a legal page wants a line short enough to read, and stretching one to the
   * other's width ruins whichever it was not written for. */
  --wide: 1040px;
  --measure: 720px;

  /* Metrics.Duration, and the same ease the app animates its rows with. */
  --fast: 150ms;
  --base: 220ms;
  --slow: 350ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #0a0a0a;
    --surface: #121212;
    --surface-active: #1c1c1c;
    --border: #262626;
    --border-strong: #3a3a3a;
    --text: #f5f5f5;
    --text-secondary: #9c9c9c;
    --text-tertiary: #5e5e5e;
    --accent: #f5f5f5;
    --on-accent: #0a0a0a;
    --success: #3fb950;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: "JetBrains Mono NL", ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border-strong);
  transition: border-color var(--fast) var(--ease), color var(--fast) var(--ease);
}

a:hover {
  border-bottom-color: var(--text);
}

/* MARK: Shell */

.wrap {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0 var(--page);
}

/* Prose inside a wide section, held to a readable line. */
.narrow {
  max-width: var(--measure);
}

header.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--background) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
}

header.bar .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

/* The wordmark, tracked wide the way the app draws it on the connect panel. */
.mark {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.18em;
  border: 0;
  position: relative;
  overflow: hidden;
}

/* A gradient sweep under a mask, so the letters catch light once on arrival
 * rather than blinking. transitions.dev calls this one "shimmer text". */
.mark {
  --sweep: -120%;
}

.mark::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 20%,
    var(--background) 45%,
    transparent 70%
  );
  transform: translateX(var(--sweep));
  pointer-events: none;
}

nav.links {
  display: flex;
  gap: var(--space-lg);
  font-size: 13px;
  color: var(--text-secondary);
}

nav.links a {
  border: 0;
  color: var(--text-secondary);
}

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

/* MARK: Type */

.eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: 0 0 var(--space-md);
}

h1 {
  font-size: clamp(30px, 5.6vw, 62px);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.035em;
  margin: 0;
}

h2 {
  font-size: clamp(21px, 2.6vw, 30px);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-md);
}

h3 {
  font-size: 16px;
  font-weight: 500;
  margin: 0 0 var(--space-xs);
}

p {
  margin: 0 0 var(--space-lg);
  color: var(--text-secondary);
  max-width: 62ch;
}

p.lead {
  font-size: 16px;
  color: var(--text-secondary);
  margin-top: var(--space-xl);
}

strong {
  color: var(--text);
  font-weight: 500;
}

/* Two lines that rise with an offset stagger. The clip is on a wrapper so the
 * line arrives from behind its own edge instead of fading in place. */
.rise {
  display: block;
  overflow: hidden;
}

.rise > span {
  display: block;
}

/* MARK: Sections */

section {
  padding: var(--space-xxxl) 0;
  border-top: 1px solid var(--border);
}

section:first-of-type {
  border-top: 0;
}

.hero {
  padding: clamp(48px, 12vh, 104px) 0 var(--space-xxxl);
}

/* MARK: Panels */

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: var(--space-xl);
}

/* One panel divided by hairlines rather than a row of separate cards, which is
 * how the app builds every list it has: the border belongs to the group, and
 * what separates the rows inside it is a single pixel. */
.rows {
  margin-top: var(--space-xxl);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr;
}

/* Two, not "as many as fit". Four items in three columns leaves one alone on a
 * row of its own, and a grid with a hole in it looks like a mistake. */
@media (min-width: 620px) {
  .rows {
    grid-template-columns: 1fr 1fr;
  }
}

.rows > * {
  padding: var(--space-xl);
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  margin: -1px 0 0 -1px;
}

.rows p {
  margin: 0;
  font-size: 13px;
  max-width: 40ch;
}

/* MARK: The switch

   The same control as the app's: a block that travels a track, with hatching
   that drifts while it is on. Here it does nothing but say what the app is. */

.demo {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-md);
  margin-top: var(--space-xxl);
}

.switch {
  position: relative;
  width: min(420px, 100%);
  height: 60px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.switch .hatch {
  position: absolute;
  inset: 0;
  opacity: 0;
  background-image: repeating-linear-gradient(
    -45deg,
    var(--border) 0 1px,
    transparent 1px 9px
  );
}

.switch .knob {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 92px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--accent);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--on-accent);
  will-change: transform;
}

/* The label lives on whichever end the block is not on. Pinned to one side it
 * would be underneath the block half the time, which is how it read before:
 * "on" and "connected" printed over each other. */
.switch .state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 var(--space-xl);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  pointer-events: none;
}

.switch[aria-pressed="true"] .state {
  justify-content: flex-start;
}

.hint {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* MARK: Lists */

dl.spec {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-sm) var(--space-xl);
  margin: var(--space-xl) 0 0;
  font-size: 13px;
}

dl.spec dt {
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
  font-weight: 500;
  padding-top: 3px;
}

dl.spec dd {
  margin: 0;
  color: var(--text-secondary);
}

ul.plain {
  margin: 0 0 var(--space-lg);
  padding-left: 1.2em;
  color: var(--text-secondary);
}

ul.plain li {
  margin-bottom: var(--space-xs);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-lg);
}

.tag {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px var(--space-sm);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: var(--background);
}

/* MARK: Tables, for the legal pages */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 var(--space-xl);
  font-size: 13px;
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

th {
  color: var(--text-tertiary);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

code {
  font-family: inherit;
  font-size: 0.95em;
  color: var(--text);
  overflow-wrap: anywhere;
}

/* A three-column table cannot be made narrow enough for a phone — one cell here
 * is an app group identifier, which does not wrap anywhere useful. So the rows
 * become blocks, and each cell carries the heading it lost. */
@media (max-width: 620px) {
  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tr {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
  }

  td {
    border: 0;
    padding: 0 0 var(--space-sm);
  }

  td:last-child {
    padding-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
  }

  td:first-child {
    color: var(--text);
  }
}

/* MARK: Legal pages */

.doc {
  padding: var(--space-xxxl) 0 var(--space-xxxl);
}

.doc .wrap {
  max-width: var(--measure);
}

.doc h2 {
  margin-top: var(--space-xxl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--border);
}

.doc h2:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.doc .meta {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: var(--space-xl);
}

/* MARK: Footer */

footer {
  border-top: 1px solid var(--border);
  padding: var(--space-xl) 0 var(--space-xxxl);
  font-size: 13px;
  color: var(--text-tertiary);
}

footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md) var(--space-xl);
  justify-content: space-between;
}

footer a {
  color: var(--text-tertiary);
  border: 0;
}

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

/* Nothing here needs motion to be understood, so anyone who asked for less
 * gets the finished state and no animation at all. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
