/* Reset */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ───────────── Tokens ─────────────
   The page is the personal site's quiet editorial shell. The product's
   pieces (the window, the card visuals, the accent) read Nanquim, the app's
   theme — drawn from this same shell, so the two sit together. */

:root {
  --bg: #0a0a0a;
  --surface: #111;
  --text: #e0e0e0;
  --text-strong: #efedea;
  --muted: #d8d8d8;
  --link: #efedea;
  --link-hover: #fff;
  --hairline: #181818;
  --ring: rgba(255, 255, 255, 0.06);

  --font-heading: Georgia, 'Times New Roman', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* ── The grid ──
     One imaginary grid holds the whole page.
     Across: 12 columns of 80px with 16px gutters = 1136px. Every span is a
     multiple of 8 (n columns = 96n − 16), so edges never land on a half pixel.
     Down: an 8px rhythm. Boxes and spaces are multiples of 8; line boxes and
     the app's own small metrics snap to 4. Press G on the page to see it. */
  --page: 1136px;
  --gutter: 16px;
  --margin: 32px;
  --u: 8px;

  /* Section rhythm on the 8px grid: the essay gets long rests around it,
     the everyday list reads as an aside inside the features. */
  --rest-period: 272px;     /* horizon → essay */
  --rest-paragraph: 360px;  /* essay → features */
  --rest-aside: 168px;      /* feature cards → everyday list */
  --rest-page: 304px;       /* features → closing */
  --rest-sign: 200px;       /* closing → footer */

  /* Page accent: Nanquim's navy, in the steps it takes on a dark canvas. */
  --p-accent: #4b72bd;
  --p-accent-text: #a0bbeb;
  --p-accent-subtle: #14223d;
}

/* App tokens — mirror MoriTheme.nanquim. Dark is the default, as on the site. */
:root,
[data-appearance="dark"] {
  --m-canvas: #0c0b0a;
  --m-panel: #100f0d;
  --m-sidebar: #131210;
  --m-raised: #131210;
  --m-well: #1b1917;
  --m-text: #d6d3cf;
  --m-text-2: #908b85;
  --m-text-3: #7d7872;
  --m-sep: #1b1917;
  --m-border: #211f1c;
  --m-border-strong: #302d29;
  --m-accent: #4b72bd;
  --m-accent-text: #a0bbeb;
  --m-accent-subtle: #14223d;
  --m-selected: #14223d;
  --m-highlight: #183060;
  --m-hover: rgba(235, 233, 231, 0.05);
  --m-side-selected: rgba(235, 233, 231, 0.08);
  --m-edge: rgba(235, 233, 231, 0.09);
}

/* The light appearance — the same ink on warm paper. */
[data-appearance="light"] {
  --m-canvas: #f9f7f6;
  --m-panel: #f3f1f0;
  --m-sidebar: #edecea;
  --m-raised: #f9f7f6;
  --m-well: #edecea;
  --m-text: #2e2b27;
  --m-text-2: #69645e;
  --m-text-3: #807b74;
  --m-sep: #e8e6e4;
  --m-border: #dbd9d5;
  --m-border-strong: #c4c0bc;
  --m-accent: #224383;
  --m-accent-text: #224383;
  --m-accent-subtle: #e5ecf8;
  --m-selected: #e5ecf8;
  --m-highlight: #c8d8f6;
  --m-hover: rgba(16, 15, 13, 0.04);
  --m-side-selected: rgba(16, 15, 13, 0.075);
  --m-edge: rgba(16, 15, 13, 0.1);
}

/* ───────────── Base ───────────── */

html {
  scroll-padding-top: 96px;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  color-scheme: dark;
  overflow-x: clip;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 24px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}

/* The page's column. Nav, showcase, highlights and footer all sit in it, so
   their left and right edges are the same two lines. */
.wrap {
  width: min(100% - var(--margin) * 2, var(--page));
  margin-inline: auto;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
  a:hover { color: var(--link-hover); }
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--p-accent-text) 70%, transparent);
  outline-offset: 3px;
  border-radius: 8px;
}

kbd {
  font-family: var(--font-body);
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  font-size: 12px;
  color: #d6d6d6;
  background: linear-gradient(#1d1d1d, #151515);
  border-radius: 7px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -2px 0 rgba(0, 0, 0, 0.55),
    0 0 0 1px #2a2a2a,
    0 1px 2px rgba(0, 0, 0, 0.6);
  transition-property: transform, box-shadow, color;
  transition-duration: 0.16s;
  transition-timing-function: var(--ease-out);
}

/* ───────────── Buttons ───────────── */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition-property: transform, background-color, box-shadow, color;
  transition-duration: 0.16s;
  transition-timing-function: var(--ease-out);
}

.button:active { transform: scale(0.96); }

.button--primary {
  color: #141414;
  background: #efedea;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.5);
}

.button--quiet {
  color: var(--link);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.button--small {
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 0.85rem;
}

@media (hover: hover) and (pointer: fine) {
  .button--primary:hover { color: #141414; background: #fff; }
  .button--quiet:hover { color: var(--link-hover); background: rgba(255, 255, 255, 0.07); }
}

.apple {
  width: 13px;
  height: 16px;
  /* The glyph's leaf makes it read high; drop it a hair. */
  margin-top: -2px;
}

/* ───────────── Nav ───────────── */

.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  background: rgba(10, 10, 10, 0.72);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  box-shadow: inset 0 -1px 0 transparent;
  transition: box-shadow 0.3s ease;
}

.nav.is-scrolled { box-shadow: inset 0 -1px 0 var(--hairline); }

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.brand,
.nav-action {
  position: relative;
  transition-property: transform, color, background-color;
  transition-duration: 0.16s, 0.2s, 0.2s;
  transition-timing-function: var(--ease-out), ease, ease;
}

.brand {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  line-height: 32px;
  letter-spacing: -0.02em;
  color: var(--text-strong);
}

.brand::after {
  content: '';
  position: absolute;
  inset: -12px -10px;
}

/* A quiet pill; its hit area reaches 40px. */
.nav-action {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 16px;
  border-radius: 16px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-strong);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.nav-action::after {
  content: '';
  position: absolute;
  inset: -4px;
}

.brand:active,
.nav-action:active { transform: scale(0.96); }

@media (hover: hover) and (pointer: fine) {
  .brand:hover { color: var(--link-hover); }
  .nav-action:hover { color: var(--link-hover); background: rgba(255, 255, 255, 0.11); }
}

/* ───────────── Hero ───────────── */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 64px var(--margin) 0;
}

.hero-icon,
.closing-icon {
  width: 80px;
  height: 80px;
  /* The entrance blur composes with this shadow instead of replacing it. */
  --rest-filter: drop-shadow(0 16px 24px rgba(0, 0, 0, 0.55));
  filter: var(--rest-filter);
  transition: transform 0.5s var(--ease-spring);
}

.hero-icon { margin-bottom: 24px; }

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .hero-icon:hover,
  .closing-icon:hover { transform: rotate(-6deg) scale(1.04); }
}

.hero h1 {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: clamp(2.3rem, 1.2rem + 3.8vw, 3.75rem);
  line-height: 1.06;
  line-height: round(up, 1.06em, 4px); /* lines land on the 4px rhythm */
  letter-spacing: -0.028em;
  color: var(--text-strong);
  text-wrap: balance;
}

/* A tag, the way the editor draws one. */
.tag-chip {
  display: inline-block;
  padding: 0 0.14em 0.04em 0.1em;
  margin-bottom: -0.04em; /* the padding must not grow the line box */
  border-radius: 0.14em;
  line-height: 1;
  color: var(--p-accent-text);
  background: var(--p-accent-subtle);
}

.tag-chip span { opacity: 0.5; }

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 32px;
}

/* ───────────── Showcase ───────────── */

.showcase {
  position: relative;
  isolation: isolate;
  --crop: 120px; /* how much of the window's base sinks below the horizon */
  display: flow-root; /* keeps the window's negative margin inside, so the showcase ends at the horizon */
  margin-top: 64px;
  /* The window stands on the horizon: nothing (glow, shadow) spills below it. */
  clip-path: inset(-100vh -100vw 0 -100vw);
}

/* A field of dots that settles on a full-bleed line at the window's base,
   thinning out as it rises. script.js dithers it into the canvas. */
.horizon {
  position: absolute;
  z-index: -2;
  bottom: 0;
  left: 50%;
  width: 100vw;
  height: 520px;
  translate: -50% 0;
  pointer-events: none;
}

.horizon canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.horizon::after {
  content: '';
  position: absolute;
  inset: auto 0 0;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.09) 12%, rgba(255, 255, 255, 0.09) 88%, transparent);
}

.is-ready .horizon canvas {
  animation: horizon-rise 1.6s var(--ease-out) 0.35s both;
}

@keyframes horizon-rise {
  from { clip-path: inset(100% 0 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

.glow {
  position: absolute;
  z-index: -1;
  top: 24px;
  left: 50%;
  width: min(1000px, 100%);
  height: 528px;
  translate: -50% 0;
  background:
    radial-gradient(closest-side, color-mix(in srgb, var(--p-accent) 26%, transparent), transparent 100%);
  opacity: 0.75;
  pointer-events: none;
}

/* ───────────── The window ─────────────
   A 0.8× rendition of the real app in Nanquim; every color comes from the
   --m-* tokens. The app is as dark as the page, so the window is drawn by
   its hairline ring and the glow behind it rather than by contrast. */

/* The window spans all 12 columns. Its panes break on the page grid: the
   sidebar ends mid-gutter after column 2, the list mid-gutter after column 5.
   --unit is one column plus one gutter. */
.window {
  --unit: calc((100% + var(--gutter)) / 12);
  position: relative;
  display: grid;
  grid-template-columns:
    calc(var(--unit) * 2 - var(--gutter) / 2)
    calc(var(--unit) * 3)
    minmax(0, 1fr);
  height: 600px;
  margin-bottom: calc(var(--crop) * -1);
  border-radius: 12px 12px 0 0;
  overflow: hidden;
  background: var(--m-canvas);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.8),
    0 2px 4px rgba(0, 0, 0, 0.3),
    0 40px 100px -32px rgba(0, 0, 0, 0.9);
  font-size: 12px;
  line-height: 16px;
  color: var(--m-text);
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

.window::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--m-edge);
  /* The app darkens into the horizon rather than ending on an edge. */
  background: linear-gradient(to bottom, transparent calc(100% - var(--crop) - 200px), var(--bg) calc(100% - var(--crop)));
  pointer-events: none;
}

.window svg,
.card svg {
  width: 13px;
  height: 13px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.traffic {
  display: flex;
  gap: 8px;
}

.traffic i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff5f57;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.25);
}

.traffic i:nth-child(2) { background: #febc2e; }
.traffic i:nth-child(3) { background: #28c840; }

/* Sidebar */

.w-sidebar {
  padding: 0 8px;
  background: var(--m-sidebar);
  box-shadow: inset -1px 0 0 var(--m-sep);
}

/* Every pane keeps its first row at y=44 (a 40px bar, then 4) and its text
   at x=16, so the three columns read as one sheet. */
.w-sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 0 8px;
  margin-bottom: 4px;
  color: var(--m-text-3);
}

.w-row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
}

.w-row svg { color: var(--m-text-2); }

.w-nav .w-row + .w-row { margin-top: 4px; }

.w-row.is-selected {
  font-weight: 600;
  background: var(--m-side-selected);
}

.w-row.is-selected svg { color: var(--m-text); }

.w-overline {
  margin: 16px 8px 4px;
  font-size: 9.5px;
  font-weight: 600;
  line-height: 16px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--m-text-3);
}

.w-tag {
  gap: 4px;
  padding-left: calc(4px + var(--depth, 0) * 12px);
}

.w-tag .chev,
.chev-gap {
  width: 11px;
  height: 11px;
  flex: none;
  color: var(--m-text-3);
}

.w-tag svg:not(.chev) { width: 12px; height: 12px; }

/* Note list */

.w-list {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--m-panel);
  box-shadow: inset -1px 0 0 var(--m-sep);
  overflow: hidden;
}

.w-list-head {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 40px;
  padding: 0 16px;
  color: var(--m-text-2);
}

.w-list-head span {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--m-text);
}

.w-list-head .is-accent { color: var(--m-accent-text); }

.w-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 8px;
  margin: 4px 16px 8px;
  border-radius: 8px;
  color: var(--m-text-3);
  background: var(--m-canvas);
  box-shadow: inset 0 0 0 1px var(--m-border);
}

.w-note {
  padding: 8px 16px;
  box-shadow: inset 0 1px 0 var(--m-sep);
}

.w-note:first-of-type { box-shadow: inset 0 1px 0 var(--m-border); }

.w-note h4 {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 20px;
  color: var(--m-text);
  white-space: nowrap;
}

.w-note .t {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.w-note time {
  flex: none;
  margin-left: auto;
  padding-left: 8px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--m-text-3);
}

.w-note .pin {
  width: 11px;
  height: 11px;
  align-self: center;
  color: var(--m-accent-text);
}

.emoji { font-size: 11.5px; }

.w-note p {
  font-size: 11.5px;
  line-height: 16px;
  color: var(--m-text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.w-note.is-selected,
.w-note.is-selected + .w-note { box-shadow: none; }
.w-note.is-selected { background: var(--m-selected); }

/* Editor */

.w-editor {
  position: relative;
  min-width: 0;
  overflow: hidden;
}

.w-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 0 16px;
  color: var(--m-text-2);
  box-shadow: inset 0 -1px 0 var(--m-sep);
}

.w-tools {
  display: flex;
  align-items: center;
  gap: 16px;
}

.w-aa {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  color: var(--m-text);
}

.w-doc {
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 32px 0;
  font-size: 14px;
  line-height: 24px;
}

.w-title {
  font-size: 26px;
  font-weight: 600;
  line-height: 32px;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
}

.w-doc > p { margin-bottom: 12px; }

.w-chip {
  padding: 1px 4px 2px;
  border-radius: 4px;
  color: var(--m-accent-text);
  background: var(--m-accent-subtle);
}

.w-doc mark {
  padding: 0 1px;
  border-radius: 2px;
  color: inherit;
  background: var(--m-highlight);
}

.wikilink {
  color: var(--m-accent-text);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--m-accent-text) 40%, transparent);
  text-underline-offset: 3px;
}

.wikilink.is-new { animation: settle 0.6s var(--ease-out); }

@keyframes settle {
  from { background: var(--m-highlight); }
}

.caret {
  display: inline-block;
  width: 1.5px;
  height: 1.15em;
  margin-left: 1px;
  vertical-align: -0.2em;
  background: var(--m-accent);
  border-radius: 1px;
  /* Blinks for ~5s after each burst of typing, then rests solid. */
  animation: blink 1.06s steps(1) 5;
}

.caret.is-typing { animation: none; }

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

.tasks {
  list-style: none;
  margin: 4px 0 12px;
}

.task {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  text-align: left;
  color: var(--m-text);
  transition: color 0.3s ease;
}

.check {
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  flex: none;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1.25px var(--m-border-strong);
  transition: background-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}

.check svg {
  width: 10px;
  height: 10px;
  color: #f9f7f6;
  stroke-width: 1.8;
  opacity: 0;
  stroke-dasharray: 14;
  stroke-dashoffset: 14;
  transition: stroke-dashoffset 0.3s var(--ease-out) 0.05s, opacity 0.1s linear;
}

.task.is-done,
.md-task.is-checked { color: var(--m-text-3); }

.task.is-done .check,
.md-task.is-checked .check { background: var(--m-accent); box-shadow: inset 0 0 0 1.25px var(--m-accent); }

.task.is-done .check svg,
.md-task.is-checked .check svg { stroke-dashoffset: 0; opacity: 1; }

.w-doc blockquote {
  margin: 4px 0 16px;
  padding-left: 16px;
  box-shadow: inset 2px 0 0 var(--m-border-strong);
  color: var(--m-text-2);
}

/* The formatting bar floats over the bottom of the page. 10 outer = 4 + 6. */
.w-format {
  position: absolute;
  bottom: 16px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  translate: -50% 0;
  border-radius: 10px;
  color: var(--m-text-2);
  background: var(--m-raised);
  box-shadow: inset 0 0 0 1px var(--m-border), 0 8px 24px -8px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
}

.w-format > b,
.w-format > svg {
  display: grid;
  place-items: center;
  width: 28px;
  height: 24px;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  line-height: 16px;
}

.w-format > svg { width: 28px; }
.w-format .it { font-family: var(--font-heading); font-style: italic; font-weight: 400; }
.w-format .un { font-weight: 400; text-decoration: underline; text-underline-offset: 2px; }

.w-format > i {
  width: 1px;
  height: 14px;
  margin: 0 5px;
  background: var(--m-border-strong);
}

/* Wikilink suggestions: 10 outer = 4 padding + 6 row. */
.suggest {
  position: absolute;
  z-index: 2;
  width: 232px;
  padding: 4px;
  border-radius: 10px;
  background: var(--m-raised);
  box-shadow:
    inset 0 0 0 1px var(--m-border),
    0 12px 28px -6px rgba(0, 0, 0, 0.55),
    0 2px 6px rgba(0, 0, 0, 0.3);
  transform-origin: top left;
  animation: pop-in 0.18s var(--ease-out);
}

.suggest.is-leaving { animation: pop-out 0.12s var(--ease-out) forwards; }
.suggest .w-overline { margin: 4px 8px; }

.s-row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12.5px;
  transition: background-color 0.12s ease;
}

.s-row svg { color: var(--m-text-3); }
.s-row.is-active { background: var(--m-selected); }
.s-row.is-active svg { color: var(--m-accent-text); }
.s-row[hidden] { display: none; }

@keyframes pop-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
}

@keyframes pop-out {
  to { opacity: 0; transform: translateY(-2px); }
}

@media (max-width: 960px) {
  .window { grid-template-columns: calc(var(--unit) * 4) minmax(0, 1fr); }
  .w-sidebar { display: none; }
}

@media (max-width: 640px) {
  .window {
    grid-template-columns: minmax(0, 1fr);
    height: 520px;
  }

  .w-list { display: none; }
  .w-toolbar { padding-left: 72px; }

  .w-toolbar::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 16px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff5f57;
    box-shadow: 18px 0 #febc2e, 36px 0 #28c840;
  }

  .w-toolbar > svg { display: none; }
  .w-doc { padding: 24px 24px 0; font-size: 13.5px; }
  .w-title { font-size: 22px; line-height: 28px; }
  .w-format { gap: 0; }
  .w-format > :nth-child(n + 9) { display: none; }
}

/* ───────────── Headings ───────────── */

h2 {
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: clamp(2rem, 1.3rem + 2.6vw, 3rem);
  line-height: 1.08;
  line-height: round(up, 1.08em, 4px);
  letter-spacing: -0.025em;
  color: var(--text-strong);
  text-wrap: balance;
}


/* ───────────── Essay ─────────────
   The rests around it come from its neighbours: --rest-period above,
   the paragraph break that .highlights carries below. */

.essay {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  /* Empty space above, outside the section, so the picture and copy stay
     centred on each other. */
  margin-top: calc(var(--rest-period) * 0.4);
  min-height: clamp(520px, 76vh, 700px);
  --lead: calc(var(--rest-period) * 0.2);
  padding-top: var(--lead);
  /* Below the copy: a tail where the dots finish settling, then a short rest. */
  --tail: calc(var(--rest-paragraph) / 3);
  --after: calc(var(--tail) * 0.4);
  padding-bottom: calc(var(--tail) + var(--after));
  overflow-x: clip;
}

.essay-copy {
  position: relative;
  z-index: 2;
  top: -24px; /* a touch above the picture's centre reads as centred */
}

/* Like the app at the horizon, the section darkens into the page at its
   foot instead of ending on an edge: picture and dots both sink into it. */
.essay::after {
  content: '';
  position: absolute;
  z-index: 1;
  inset: auto 0 0;
  /* Tall enough to reach up over the picture, where the content actually is. */
  height: calc(var(--tail) * 2.8 + var(--after));
  /* Stops follow an ease-in-out curve, so the dark gathers gently and settles
     without a visible start or end. */
  background: linear-gradient(
    to bottom,
    transparent,
    color-mix(in srgb, var(--bg) 4%, transparent) 10%,
    color-mix(in srgb, var(--bg) 14%, transparent) 22%,
    color-mix(in srgb, var(--bg) 32%, transparent) 36%,
    color-mix(in srgb, var(--bg) 56%, transparent) 50%,
    color-mix(in srgb, var(--bg) 78%, transparent) 63%,
    color-mix(in srgb, var(--bg) 92%, transparent) 75%,
    color-mix(in srgb, var(--bg) 98%, transparent) 87%,
    var(--bg)
  );
  pointer-events: none;
}

/* One field of dots over the whole section, picture included: loose at the
   top, settled onto the page's lattice by the bottom. */
.essay-dots {
  position: absolute;
  z-index: 1;
  inset: 0 0 var(--after);
  pointer-events: none;
  user-select: none;
}

.essay-dots canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* The picture is the section's backdrop: light on a dark ground, anchored to
   the right and running off the page's edge, with the copy on the dark side. */
.essay-art {
  position: absolute;
  z-index: -1;
  /* Centred between the same two lines as the copy, so they share one axis. */
  inset-block: var(--lead) calc(var(--tail) + var(--after));
  right: -9vw;
  width: min(1100px, 78vw);
  height: fit-content;
  margin: auto 0;
  pointer-events: none;
  user-select: none;
  /* The bottom of the picture dissolves into the dots. */
  -webkit-mask-image: linear-gradient(to bottom, #000 62%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 62%, transparent 100%);
}

.essay-art img {
  display: block;
  width: 100%;
  height: auto;
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .essay-art img { animation: drift 9s ease-in-out infinite alternate; }
}

@keyframes drift {
  from { transform: translate3d(0, 4px, 0) rotate(0.4deg); }
  to { transform: translate3d(0, -10px, 0) rotate(-0.6deg); }
}

/* Narrow screens: the copy first, the picture rising out of the dark below it. */
@media (max-width: 900px) {
  .essay {
    display: block;
    min-height: 0;
  }

  .essay-art {
    position: relative;
    z-index: 0;
    right: auto;
    width: 130%;
    margin: 0 -15%;
  }
}

.essay-body {
  max-width: 36rem;
  margin-top: 16px;
  font-size: 1.05rem;
  line-height: 28px;
  color: var(--muted);
  text-wrap: pretty;
}

.essay-body p + p { margin-top: 16px; }

/* The last line is the conclusion, so it steps away from the paragraph. */
.essay-body .essay-end {
  margin-top: 32px;
  color: var(--text-strong);
}

/* ───────────── Highlights ───────────── */

.highlights { margin-top: 0; }

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

.section-head p {
  max-width: 36rem;
  margin-top: 16px;
  font-size: 1.05rem;
  line-height: 28px;
  color: var(--muted);
  text-wrap: pretty;
}

/* The bento is the grid made visible: 12 columns, 7 + 5 over 5 + 7.
   Each card is a subgrid three rows tall (title, description, visual), so
   every card in a row shares the same three row lines. Titles start together,
   descriptions start together, and the visuals start — and are cropped — at
   the same y, whatever the copy does. */
.bento {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: auto auto 360px;
  column-gap: var(--gutter);
}

.card {
  position: relative;
  display: grid;
  grid-row: span 3;
  grid-template-rows: subgrid;
  row-gap: 0;
  border-radius: 20px;
  /* Cool, not bright: the navy of the page's accent, faint at the top left,
     over a surface that only deepens toward the bottom right. Nothing is
     lighter than the flat surface was, so the cards stay in the page's hue. */
  background:
    radial-gradient(110% 80% at 0% 0%, color-mix(in srgb, var(--p-accent-subtle) 12%, transparent), transparent 60%),
    linear-gradient(160deg, var(--surface), color-mix(in srgb, #000 6%, var(--surface)));
  box-shadow: inset 0 0 0 1px var(--ring);
  overflow: hidden;
}

/* The gutter between rows is a margin, not a row-gap: a subgrid would
   otherwise fold half of it into its own rows. */
.card:nth-child(n + 3) { margin-top: var(--gutter); }

.card--markdown { grid-column: span 7; }
.card--links    { grid-column: span 5; }
.card--own      { grid-column: span 5; }
.card--themes   { grid-column: span 7; }

/* Card insets are 32 = two gutters. */
/* Title and description run the card's full width, so a wide card doesn't
   break its copy early and push the whole row's subgrid down. */
.card h3 {
  padding: 32px 32px 0;
  font-family: var(--font-heading);
  font-weight: 400;
  font-size: 1.45rem;
  line-height: 32px;
  letter-spacing: -0.015em;
  color: var(--text-strong);
  text-wrap: balance;
}

.card-desc {
  padding: 8px 32px 0;
  font-size: 0.95rem;
  line-height: 24px;
  color: var(--muted);
  text-wrap: pretty;
}

/* 24 between the copy and the visual everywhere; the card's edge crops the
   rest. The padding is inside the overflow, so the visual's 1px ring shows. */
.card-visual {
  position: relative;
  min-height: 0;
  padding: 24px 32px 0;
  overflow: hidden;
}

.card .w-overline {
  margin: 12px 8px 4px;
  font-size: 9.5px;
  font-weight: 600;
  line-height: 16px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--m-text-3);
}

/* Links: the scene floats complete, with air under it — the other cards
   crop at the card's edge. */

.card--links .card-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 32px;
}

.link-stage {
  position: relative;
  width: min(100%, 400px);
  margin-inline: auto;
  font-size: 12.5px;
  line-height: 20px;
  color: var(--m-text);
}

.link-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

/* The row of the hub itself reaches into the card's inset, so the notes on
   its sides have room to be named. */
.n-hub-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin: 56px -24px;
}

/* A hub and its spokes: the note in the middle is the one everything links to. */
.n-hub,
.n-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  border-radius: 10px;
  background: var(--m-canvas);
  box-shadow: 0 0 0 1px var(--m-edge), 0 12px 30px -10px rgba(0, 0, 0, 0.5);
  transition: box-shadow 0.3s ease;
}

.n-chip {
  padding: 6px 12px;
  color: var(--m-text-2);
  white-space: nowrap;
}

.link-row .n-chip { max-width: calc(50% - 8px); }

.n-chip > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.n-hub {
  flex: none;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--m-text);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--m-accent) 35%, var(--m-edge)), 0 12px 30px -10px rgba(0, 0, 0, 0.5);
}

.n-chip svg,
.n-hub svg {
  flex: none;
  width: 14px;
  height: 14px;
  color: var(--m-text-3);
}

.n-hub svg { color: var(--m-accent-text); }

.thread {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.thread path {
  fill: none;
  stroke-linecap: round;
}

/* The lines always rest on screen; a gradient pulse (see script.js) travels over them on hover. */
.thread-base {
  stroke: var(--m-accent);
  stroke-opacity: 0.3;
  stroke-width: 1.5;
}

.thread-pulse {
  stroke-width: 2;
}

.thread stop { stop-color: var(--m-accent); }

/* The spokes light up as the pulse leaves them, the hub once it arrives;
   letting go clears both at once. */
.card--links.is-playing .n-chip {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--m-accent) 40%, var(--m-edge)), 0 12px 30px -10px rgba(0, 0, 0, 0.5);
}

.card--links.is-playing .n-hub {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--m-accent) 75%, var(--m-edge)), 0 0 32px -6px color-mix(in srgb, var(--m-accent) 45%, transparent);
  transition: box-shadow 0.4s ease 0.55s;
}

/* Own — the notes are plain files, shown in a Finder window. */

.finder {
  min-height: calc(100% + 16px);
  padding-bottom: 8px;
  font-size: 12.5px;
  color: var(--m-text);
  background: var(--m-canvas);
  border-radius: 12px 12px 0 0;
  box-shadow: 0 0 0 1px var(--m-edge);
}

.finder svg {
  width: 13px;
  height: 13px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.f-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  margin-bottom: 8px;
  background: var(--m-sidebar);
  border-radius: 12px 12px 0 0;
  box-shadow: inset 0 -1px 0 var(--m-sep);
}

.f-bar i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff5f57;
}

.f-bar i:nth-child(2) { background: #febc2e; }
.f-bar i:nth-child(3) { background: #28c840; }

.f-bar span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 600;
  color: var(--m-text-2);
}

.f-row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  margin: 0 8px;
  padding: 0 8px;
  border-radius: 6px;
  white-space: nowrap;
  transition: background-color 0.15s ease;
}

.f-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.f-row:nth-of-type(even) { background: var(--m-hover); }
.f-row svg { color: var(--m-text-3); }

@media (hover: hover) and (pointer: fine) {
  .f-row:hover { background: var(--m-selected); }
}

.f-row time {
  flex: none;
  margin-left: auto;
  padding-left: 8px;
  color: var(--m-text-3);
  font-variant-numeric: tabular-nums;
}

/* Markdown — a note writes itself. Each piece of syntax ([data-md]) shows
   while the caret is inside it and folds away once the caret moves on. */

.md-page {
  height: 360px;
  overflow: hidden;
  border-radius: 12px 12px 0 0;
  color: var(--m-text);
  background: var(--m-canvas);
  box-shadow: 0 0 0 1px var(--m-edge);
}

.md-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 40px;
  padding: 0 16px;
  box-shadow: inset 0 -1px 0 var(--m-sep);
}

.md-bar .t-lights { left: 16px; }

.md-doc {
  max-width: 440px;
  margin: 0 auto;
  padding: 32px 32px 0;
  font-size: 13.5px;
  line-height: 24px;
}

.md-doc > * + * { margin-top: 8px; }
.md-doc > .is-pending { display: none; }

.md-h {
  margin-bottom: 4px;
  font-size: 22px;
  font-weight: 600;
  line-height: 32px;
  letter-spacing: -0.01em;
}

/* Folded, a mark takes no room; open, it pushes the line apart for itself. */
.md-mark {
  display: inline-block;
  max-width: 0;
  overflow: hidden;
  vertical-align: bottom;
  white-space: pre;
  font-weight: 400;
  color: var(--m-text-3);
  opacity: 0;
  transition: max-width 0.4s var(--ease-out), opacity 0.25s ease;
}

.is-raw .md-mark {
  max-width: 3em;
  opacity: 1;
  transition-duration: 0.12s;
}

/* Kept on one line: a folded mark left at a line's end would wrap away from
   its words and leave a sliver of highlight behind. */
.md-hl {
  white-space: nowrap;
  border-radius: 2px;
  transition: background-color 0.3s ease;
}

.md-hl.is-done {
  padding: 0 1px;
  background: var(--m-highlight);
}

.md-b.is-done { font-weight: 600; }

/* The list marker turns into a checkbox once it's written and left behind. */
.md-taskmark .check {
  display: none;
  margin-right: 8px;
  vertical-align: -2px;
}

.md-taskmark.is-done:not(.is-raw) .check {
  display: inline-grid;
  animation: pop-in 0.25s var(--ease-out);
}

.md-task { transition: color 0.3s ease; }

/* Themes — three notes, each in its theme's dark appearance, fanned across
   the card. --k is a note's depth, 0 at the front, on the right. Each step
   back slides left, sits lower and dims. Colors come from MoriTheme+*.swift. */

[data-theme="nanquim"] {
  --canvas: #0c0b0a; --bar: #131210; --text: #d6d3cf; --text-2: #908b85; --text-3: #7d7872;
  --border: #211f1c; --accent: #4b72bd; --accent-text: #a0bbeb; --subtle: #14223d; --highlight: #183060;
}

[data-theme="pergaminho"] {
  --canvas: #211a14; --bar: #251f18; --text: #dad2c3; --text-2: #9c9587; --text-3: #847d6f;
  --border: #302921; --accent: #ae6509; --accent-text: #e9aa71; --subtle: #402710; --highlight: #5a3207;
}

[data-theme="floresta"] {
  --canvas: #1d2728; --bar: #202b2b; --text: #d9cfb6; --text-2: #a99f87; --text-3: #8a8770;
  --border: #283531; --accent: #587f34; --accent-text: #9eba88; --subtle: #2e3827; --highlight: #3d4934;
}

.deck {
  position: relative;
  height: 100%;
}

.t-page {
  --step: 39%; /* of the note's own width: three notes at 56% then span the card */
  position: absolute;
  top: 0;
  right: 0;
  z-index: calc(10 - var(--k));
  width: 56%;
  height: 400px;
  overflow: hidden;
  border-radius: 12px;
  color: var(--text);
  background: var(--canvas);
  box-shadow:
    0 0 0 1px rgba(235, 233, 231, 0.09),
    -16px 0 32px -12px rgba(0, 0, 0, 0.7);
  font-size: 12.5px;
  line-height: 20px;
  translate: calc(var(--k) * var(--step) * -1) calc(var(--k) * 24px);
}

/* The further back, the more of the card's dark it takes on. */
.t-page::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--surface);
  opacity: calc(var(--k) * 0.28);
  pointer-events: none;
}

.t-bar {
  position: relative;
  display: flex;
  align-items: center;
  height: 32px;
  background: var(--bar);
  box-shadow: inset 0 -1px 0 var(--border);
}

.t-lights {
  position: absolute;
  left: 12px;
  display: flex;
  gap: 6px;
}

.t-lights i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ff5f57;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.25);
}

.t-lights i:nth-child(2) { background: #febc2e; }
.t-lights i:nth-child(3) { background: #28c840; }

.t-doc { padding: 24px; }
.t-doc > * + * { margin-top: 8px; }

.t-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 24px;
  letter-spacing: -0.01em;
}

.t-chip {
  padding: 1px 4px 2px;
  border-radius: 4px;
  color: var(--accent-text);
  background: var(--subtle);
}

.t-doc mark {
  padding: 0 1px;
  border-radius: 2px;
  color: inherit;
  background: var(--highlight);
}

.t-doc blockquote {
  padding-left: 14px;
  color: var(--text-2);
  box-shadow: inset 2px 0 0 var(--border);
}

.t-task {
  display: flex;
  align-items: center;
  gap: 8px;
}

.t-task + .t-task { margin-top: 4px; }

.t-task i {
  width: 13px;
  height: 13px;
  flex: none;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1.25px var(--text-3);
}

.t-task.is-done { color: var(--text-3); }

.t-task.is-done i {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-5'/%3E%3C/svg%3E") center / 10px no-repeat,
    var(--accent);
  box-shadow: none;
}

@media (max-width: 640px) {
  .t-page { --step: 21%; width: 70%; }
}

/* App pictures are not interactive: no pointer cursor, nothing selectable. */
.window,
.card-visual,
.mc-icon,
.hero-icon,
.closing-icon,
.footer-leaf {
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
}

/* ───────────── Everyday features ───────────── */

/* A quiet list, not a wall of cards: the full twelve columns, three items
   of four columns each, so every item lands on the grid. The label and the
   list share the page's left edge. */
.more-label {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-top: 80px;
  margin-bottom: 48px;
  font-family: var(--font-heading);
  font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2rem);
  line-height: 40px;
  letter-spacing: -0.02em;
  color: var(--text-strong);
}

/* Hairlines run out to the edges of the cards above, so the label reads as
   the next line of the same grid rather than a caption floating under it. */
.more-label::before,
.more-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--ring);
}

.more {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 56px var(--gutter);
  list-style: none;
}

/* Icon tile, then a title and a muted one-line-ish description. */
.mini-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  text-align: center;
  align-content: start; /* a taller neighbour in the row mustn't spread icon, title and text apart */
}

.mini-card .mc-icon { margin-bottom: 20px; }

.mini-card h3 {
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 24px;
  letter-spacing: -0.005em;
  color: var(--text-strong);
}

.mini-card p {
  margin-top: 4px;
  max-width: 32ch;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--muted);
  text-wrap: pretty;
}

.mc-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: #8f8f8f;
  background: #151515;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
  transition: color 0.2s ease, background-color 0.2s ease;
}

.mc-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
  transition: transform 0.5s var(--ease-spring);
}

.mc-icon path { transition: transform 0.45s var(--ease-spring); }

/* These items aren't links, so hover lifts the icon to the text color
   rather than the accent, which on this page means "clickable". */
@media (hover: hover) and (pointer: fine) {
  .mini-card:hover .mc-icon { color: var(--text); }
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .mini-card:hover .mc-icon--tag svg { transform: rotate(-14deg); }
  .mini-card:hover .mc-icon--offline svg { transform: scale(1.1); }
  .mini-card:hover .mc-icon--focus svg { transform: scale(1.12); }
  .mini-card:hover .mc-icon--keys svg { transform: translateY(-1.5px); }
  .mini-card:hover .mc-icon--code svg { transform: scale(1.1) rotate(-4deg); }
  .mini-card:hover .mc-icon--search svg { transform: translate(-1.5px, -1.5px) scale(1.12); }
}

/* ───────────── Responsive ───────────── */

@media (max-width: 960px) {
  :root {
    --margin: 24px;
    --rest-period: 200px;
    --rest-paragraph: 256px;
    --rest-aside: 128px;
    --rest-page: 224px;
    --rest-sign: 152px;
  }

  .bento > .card { grid-column: span 12; }
  .more { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card:nth-child(2) { margin-top: var(--gutter); }
  .card--links .link-stage { width: min(100%, 480px); }
}

@media (max-width: 640px) {
  :root {
    --margin: 16px;
    --rest-period: 144px;
    --rest-paragraph: 192px;
    --rest-aside: 96px;
    --rest-page: 168px;
    --rest-sign: 120px;
  }

  .hero { padding-top: 48px; }
  .showcase { --crop: 96px; margin-top: 48px; }
  .bento { grid-auto-rows: auto auto 344px; }
  .card h3 { padding: 24px 24px 0; }
  .card-desc { padding: 8px 24px 0; }
  .card-visual { padding: 24px 24px 0; }
  .card--links .card-visual { padding: 24px 24px 32px; }
  .more-label { margin-top: 64px; margin-bottom: 32px; }
  .more { grid-template-columns: minmax(0, 1fr); row-gap: 32px; }
  .mini-card { grid-template-columns: 40px minmax(0, 1fr); column-gap: 16px; justify-items: start; text-align: left; }
  .mini-card .mc-icon { grid-row: span 2; margin-bottom: 0; }
  .mini-card h3 { padding-top: 8px; }
  .section-head { margin-bottom: 32px; }
}

/* ───────────── Closing ───────────── */

.closing {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-top: var(--rest-page);
  padding: 0 var(--margin);
}

/* Dots along both sides of the page, thinning toward the middle; script.js
   draws them. They run a little past the section so its edges never show. */
.closing-dots {
  position: absolute;
  z-index: -1;
  inset: -96px 0;
  pointer-events: none;
  user-select: none;
}

.closing-dots canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.closing::before {
  content: '';
  position: absolute;
  z-index: -1;
  top: -80px;
  left: 50%;
  width: min(640px, 100%);
  height: 420px;
  translate: -50% 0;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--p-accent) 13%, transparent), transparent);
  pointer-events: none;
}

.closing h2 { margin-top: 24px; }

/* The editor's caret, waiting for the first word. */
.closing-caret {
  display: inline-block;
  width: 0.055em;
  height: 0.9em;
  margin-left: 0.08em;
  vertical-align: -0.1em;
  border-radius: 1px;
  background: var(--p-accent-text);
  animation: blink 1.06s steps(1) 5;
}

/* ───────────── Footer ───────────── */

.footer {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  margin-top: var(--rest-sign);
  padding: 32px 0 48px;
  font-size: 0.8rem;
  line-height: 24px;
  color: var(--muted);
}

.footer::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.07) 12%, rgba(255, 255, 255, 0.07) 88%, transparent);
}

.footer-heart {
  width: 13px;
  height: 13px;
  margin: 0 1px;
  vertical-align: -2px;
  fill: var(--p-accent-text);
}

.footer nav {
  display: flex;
  justify-content: flex-end;
  gap: 24px;
}

/* Links sit a clear step above the --muted text around them. */
.footer a {
  position: relative;
  color: var(--link);
}

.footer a::after {
  content: '';
  position: absolute;
  inset: -12px -8px;
}

.footer-leaf {
  width: auto;
  height: 16px;
  opacity: 0.35;
  transition: opacity 0.3s ease, transform 0.45s var(--ease-spring);
}

@media (hover: hover) and (pointer: fine) {
  .footer a:hover { color: var(--link-hover); }
  .footer-leaf:hover { opacity: 0.9; }
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .footer-leaf:hover { transform: rotate(-12deg); }
}

/* Oversized pixel wordmark: each square is a filled tile with a hairline ring,
   like the icon tiles above. Cropped by the page's edge and faded out. */
.footer-mark {
  overflow: hidden;
  aspect-ratio: 121 / 28;
  margin-top: 8px;
  pointer-events: none;
  user-select: none;
  -webkit-mask-image: linear-gradient(to bottom, #000 65%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 65%, transparent 100%);
}

.footer-mark img {
  display: block;
  width: 83%;
  /* The wordmark is 100.2 units wide: a width in whole multiples of that keeps
     every square a whole number of pixels, instead of alternating 9 and 10. */
  width: round(down, 83%, 100.2px);
  height: auto;
  margin-inline: auto;
}

@media (max-width: 520px) {
  .footer {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .footer-leaf { order: -1; }
  .footer nav { justify-content: center; }
}

/* ───────────── Grid overlay ─────────────
   Press G to show the 12 columns and the 8px rhythm; G again hides them. */

.grid-overlay {
  position: absolute;
  inset: 0 0 auto;
  z-index: 100;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255, 64, 110, 0.16) 0 1px, transparent 1px 8px);
}

.grid-overlay .wrap {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gutter);
  height: 100%;
}

.grid-overlay i {
  background: rgba(255, 64, 110, 0.09);
  box-shadow: inset 1px 0 0 rgba(255, 64, 110, 0.35), inset -1px 0 0 rgba(255, 64, 110, 0.35);
}

/* ───────────── Motion ───────────── */

/* script.js drops [data-enter] once the animation ends, so nothing keeps a
   filter (and its compositing layer) after the page has settled. */
.js [data-enter] {
  opacity: 0;
  translate: 0 10px;
  filter: blur(4px) var(--rest-filter,);
}

.is-ready [data-enter] {
  animation: enter 0.8s var(--ease-out) forwards;
  animation-delay: calc(var(--i, 0) * 90ms);
}

/* Blurring a surface this large is costly, and it's already out of focus
   behind the copy; it only rises and fades. */
.js .showcase[data-enter] { filter: none; }
.is-ready .showcase[data-enter] { animation-name: enter-rise; animation-duration: 1.1s; }

@keyframes enter {
  to { opacity: 1; translate: 0 0; filter: blur(0) var(--rest-filter,); }
}

@keyframes enter-rise {
  to { opacity: 1; translate: 0 0; }
}

@keyframes enter-fade {
  to { opacity: 1; }
}

.js [data-reveal] {
  opacity: 0;
  translate: 0 16px;
  transition: opacity 0.7s var(--ease-out), translate 0.7s var(--ease-out);
  transition-delay: var(--d, 0ms);
}

.js [data-reveal].is-visible {
  opacity: 1;
  translate: 0 0;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  /* Gentler, not gone: things still fade in, they just don't move. */
  .js [data-enter],
  .js [data-reveal] {
    translate: none;
    filter: var(--rest-filter, none);
  }

  .is-ready [data-enter],
  .is-ready .showcase[data-enter] {
    animation-name: enter-fade;
    animation-duration: 0.4s;
  }

  .js [data-reveal] { transition: opacity 0.4s ease; }

  .caret,
  .closing-caret,
  .is-ready .horizon canvas,
  .suggest,
  .wikilink.is-new,
  .md-taskmark .check {
    animation: none;
  }

  .md-mark,
  .t-page,
  .check svg { transition: none; }
}
