/* Maddlink — base: reset, type, controls, focus, motion states. Tokens: tokens.css; families: fonts.css. */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--step-0);
  line-height: 1.5;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote, fieldset { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
legend { padding: 0; }
:where(h1, h2, h3) {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking);
  line-height: 1.08;
  text-wrap: balance;
}
p { text-wrap: pretty; }
.tnum, time, [data-count], .fav-count { font-variant-numeric: tabular-nums; }
::selection { background: var(--cyan); color: var(--on-cyan); }

/* ---------------------------------------------------------------- accessibility */
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 16px; top: 12px; z-index: calc(var(--z-cursor) + 1);
  padding: 10px 18px; border-radius: var(--r-pill); background: var(--cyan); color: var(--on-cyan); font-weight: 650;
  transform: translateY(-160%); transition: transform 0.35s var(--ease-out);
}
.skip-link:focus { transform: none; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--cyan-deep); outline-offset: 3px; }
[tabindex="-1"]:focus-visible { outline: none; }

/* ---------------------------------------------------------------- icons */
.icon { width: 20px; height: 20px; flex: none; }
.uicon { width: 18px; height: 18px; flex: none; overflow: visible; }

/* ---------------------------------------------------------------- buttons (solid, no gradient: design direction) */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 24px; border-radius: var(--r-pill); overflow: hidden; isolation: isolate;
  font-weight: 650; letter-spacing: -0.005em; white-space: nowrap; user-select: none;
  transition: color 0.4s var(--ease-out), border-color 0.4s var(--ease-out), box-shadow 0.4s var(--ease-out);
}
.btn > * { position: relative; z-index: 1; }
.btn > span { display: inline-flex; align-items: center; gap: 10px; }
.btn::before { /* the ink sweep */
  content: ""; position: absolute; inset: 0; z-index: 0; border-radius: inherit;
  transform: scaleX(0); transform-origin: left center; transition: transform 0.6s var(--ease-out);
}
.btn:hover::before { transform: scaleX(1); }
.btn--solid { background: var(--cyan); color: var(--on-cyan); }
.btn--solid::before { background: var(--ink); }
.btn--solid:hover { color: var(--paper); box-shadow: 0 0 0 1px var(--cyan-deep), 0 14px 40px -16px var(--cyan-glow); }
.btn--ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn--ghost::before { background: var(--raised); }
.btn--ghost:hover { box-shadow: inset 0 0 0 1px var(--ink-muted); }
.btn .icon { width: 18px; height: 18px; }
/* pressed: the shadow sinks with the scale (MOTION §4) */
.btn--solid.is-pressed { box-shadow: 0 0 0 1px var(--cyan-deep), 0 4px 12px -8px var(--cyan-glow); }
.btn--ghost.is-pressed, .chip.is-pressed, .icon-btn.is-pressed { box-shadow: inset 0 0 0 1px var(--line-strong), inset 0 2px 6px rgba(0, 0, 0, 0.08); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 1; color: var(--ink-muted); box-shadow: inset 0 0 0 1px var(--line); cursor: not-allowed; }

.icon-btn {
  display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); flex: none;
  border-radius: var(--r-pill); color: var(--ink); transition: background-color 0.3s var(--ease-out), color 0.3s;
}
.icon-btn:hover { background: var(--raised); }
.icon-btn:active { background: var(--line-strong); }

.chip {
  position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 13px; border-radius: var(--r-pill);
  background: var(--card); color: var(--ink-soft); box-shadow: inset 0 0 0 1px var(--line); font-size: var(--step--1);
  font-weight: 600; white-space: nowrap; transition: background-color 0.3s var(--ease-out), color 0.3s, box-shadow 0.3s;
}
.chip .icon { width: 15px; height: 15px; }
.chip::after { content: ""; position: absolute; inset: -5px -2px; border-radius: inherit; } /* a 44-px target around a 34-px chip */
.chip:hover { background: var(--raised); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.chip[aria-pressed="true"] { background: var(--cyan-soft); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--cyan-deep); }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: var(--r-pill);
  background: var(--card); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-soft);
  font-size: var(--step--1); font-weight: 600; letter-spacing: 0.01em;
}
.pending { color: var(--ink-muted); font-style: italic; }

/* touch: no square flash, but every control has its own rounded pressed state (skill pitfall) */
@media (pointer: coarse) {
  .chip:active, .pill:active { background: var(--line-strong); }
}

/* ---------------------------------------------------------------- the portrait (monogram until real photos) */
.portrait {
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  background: radial-gradient(120% 120% at 30% 25%, color-mix(in oklab, var(--u, var(--ink-muted)) 42%, var(--card)) 0%, var(--card) 72%);
  box-shadow: inset 0 0 0 1.5px color-mix(in oklab, var(--u, var(--ink-muted)) 70%, transparent);
}
.portrait img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
/* a business's logo, square on its own ground: shown whole, a hairline keeps a white ground off the white page */
.portrait--logo { background: var(--paper); box-shadow: inset 0 0 0 1px var(--line-strong); }
.portrait--logo img { object-fit: contain; }
.monogram {
  font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: 0.02em;
  font-size: 0.95em; color: var(--ink); line-height: 1;
}
.monogram::before { content: attr(data-initials); } /* drawn, not written: the portrait is a picture (aria-hidden) */
.portrait .orbit { /* works remotely: the orbital ring (IDENTITY §5) */
  position: absolute; inset: -5px; border-radius: 50%; border: 1.5px dashed color-mix(in oklab, var(--ink-muted) 70%, transparent);
  animation: orbit 14s linear infinite;
}
@keyframes orbit { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- words in masks */
.w { display: inline-block; overflow: hidden; vertical-align: top; padding: 0.06em 0.08em 0.16em; margin: -0.06em -0.08em -0.16em; }
.wi { display: inline-block; will-change: transform; }

/* ---------------------------------------------------------------- forms */
.switch { display: inline-flex; align-items: center; gap: 12px; min-height: var(--tap); cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { position: relative; width: 44px; height: 26px; border-radius: var(--r-pill); background: var(--line-strong); transition: background-color 0.3s; flex: none; }
.switch-track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); transition: transform 0.4s var(--ease-out); }
.switch input:checked + .switch-track { background: var(--cyan); }
.switch input:checked + .switch-track::after { transform: translateX(18px); background: var(--on-cyan); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--cyan-deep); outline-offset: 3px; }
.segs { display: flex; flex-wrap: wrap; gap: 8px; }
.segs--col { flex-direction: column; align-items: stretch; }
.seg { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: flex; align-items: center; min-height: var(--tap); padding: 0 14px; border-radius: var(--r-sm);
  background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-soft); font-size: var(--step--1); font-weight: 600;
  transition: box-shadow 0.3s, color 0.3s, background-color 0.3s;
}
.seg:hover span { color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.seg input:checked + span { color: var(--ink); background: var(--cyan-soft); box-shadow: inset 0 0 0 1.5px var(--cyan-deep); }
.seg input:focus-visible + span { outline: 2px solid var(--cyan-deep); outline-offset: 2px; }

/* ---------------------------------------------------------------- toast and live regions */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: var(--z-toast); transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 10px; padding: 12px 20px; border-radius: var(--r-pill);
  background: var(--ink); color: var(--on-cyan); font-weight: 650; box-shadow: var(--shadow-2); pointer-events: none;
}
.toast .icon { color: var(--on-cyan); }

/* ---------------------------------------------------------------- the cursor ring (desktop) */
.cursor-ring {
  position: fixed; left: 0; top: 0; z-index: var(--z-cursor); pointer-events: none;
  border-radius: 999px; border: 1.5px solid color-mix(in oklab, var(--ink) 70%, transparent);
  transition: border-color 0.3s, background-color 0.3s;
}
.cursor-ring.is-over { border-color: var(--cyan); border-width: 2px; background: color-mix(in oklab, var(--cyan) 7%, transparent); }

/* ---------------------------------------------------------------- motion states */
/* Pause (MOTION §6): every automatic CSS animation stops; GSAP's clock keeps running for gestures and scrolling. */
.is-paused *, .is-paused *::before, .is-paused *::after { animation-play-state: paused !important; }
.is-reduced *, .is-reduced *::before, .is-reduced *::after { animation: none !important; transition-duration: 0.2s !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.2s !important; scroll-behavior: auto !important; }
}
.is-reduced .btn::before { transition: none; }

/* A route in the hash (file://): the page's own view waits until the router shows the right one. */
.hash-route #view, .hash-route .panel--explore { visibility: hidden; }

/* ---------------------------------------------------------------- scrollbars, quiet */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* forced colours (Windows contrast themes): keep shapes visible */
@media (forced-colors: active) {
  .btn, .chip, .pill, .icon-btn, .card, .mode-tab { border: 1px solid CanvasText; }
  .chip[aria-pressed="true"], .mode-tab[aria-current] { outline: 2px solid Highlight; }
}

/* ---------------------------------------------------------------- the flight layer: a pro between two forms */
.token { position: absolute; left: 0; top: 0; width: 96px; height: 96px; transform-origin: 48px 48px; will-change: transform; pointer-events: none; }
.token .portrait { width: 96px; height: 96px; font-size: 1.9rem;
  box-shadow: inset 0 0 0 3px color-mix(in oklab, var(--u) 80%, transparent), 0 0 0 calc(4px * var(--glow, 0)) rgba(25, 240, 255, calc(var(--glow, 0) * 0.9)), 0 10px 24px -10px rgba(0, 0, 0, 0.25), 0 0 calc(40px * var(--glow, 0)) rgba(25, 240, 255, calc(var(--glow, 0) * 0.5)); }
/* the photo that grows from a card into a profile's cover: above the panel, under the flying portrait (flight layer) */
.grow-ghost { position: fixed; z-index: calc(var(--z-panel) + 1); overflow: hidden; border-radius: var(--r-md); pointer-events: none; box-shadow: var(--shadow-2); }
.grow-ghost img { display: block; width: 100%; height: 100%; object-fit: cover; }
.grow-shade { position: absolute; inset: auto 0 0 0; height: 38%; background: linear-gradient(to top, var(--paper), transparent); opacity: 0; }
@media (max-width: 767px) { .grow-ghost { z-index: calc(var(--z-header) + 2); } }

/* ---------------------------------------------------------------- photos arriving (MOTION §4: skeletons, then a fade)
   The reflection runs only while a photo is on its way: never where there is none (an abstract cover), and in a
   carousel only on the slide shown at rest — a background-position animation is redrawn every frame, and 313 of them
   left running (the 300 set) cost the map its smoothness (2026-10-16). */
.slide, .p-photo, .profile-cover, .nf-photo, .ba {
  background: linear-gradient(100deg, transparent 30%, rgba(0, 0, 0, 0.035) 50%, transparent 70%) var(--raised); background-size: 220% 100%;
}
.slide:first-child:has(> img:not(.is-in)), .p-photo:has(img:not(.is-in)), .profile-cover:has(img:not(.is-in)), .nf-photo:has(img:not(.is-in)), .ba:has(img:not(.is-in)) {
  animation: shimmer 1.4s linear infinite;
}
/* a photo loaded on demand fades in from its skeleton; one of the first screen (fetchpriority high) shows the moment it
   is decoded — fading it in would hold back the page's largest paint until the scripts have run */
.slide > img[loading="lazy"], .p-photo img[loading="lazy"], .profile-cover img[loading="lazy"], .nf-photo img[loading="lazy"], .ba img[loading="lazy"] { opacity: 0; transition: opacity 0.4s var(--ease-out); }
.slide > img[loading="lazy"].is-in, .p-photo img[loading="lazy"].is-in, .profile-cover img[loading="lazy"].is-in, .nf-photo img[loading="lazy"].is-in, .ba img[loading="lazy"].is-in { opacity: 1; }
@keyframes shimmer { to { background-position: -120% 0; } }
