/* ============================================================
   OSDC Community Links

   Set like the index of a printed manual: a number, a name, a
   hairline. The type does the work, so there is nothing else on
   the page to look at.

   Rules:
     - names are big enough to read at a glance, and that wins
       over every other consideration
     - two type sizes carry the hierarchy: names large, meta small
     - mono is only for machine text (numbers, URLs, labels)
     - colour is near-monochrome; the accent belongs to interaction
   ============================================================ */

/* One variable file, wght 100-700. */
@font-face {
  font-family: "IBM Plex Sans";
  src: url("../assets/fonts/IBMPlexSans.woff2") format("woff2");
  font-weight: 100 700;
  font-display: swap;
}
@font-face { font-family: "IBM Plex Mono"; src: url("../assets/fonts/IBMPlexMono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --paper:  #faf9f6;
  --ink:    #14120f;
  --muted:  #6b655c;
  --rule:   #e4e0d7;
  --accent: #c62d1c;
  --particle-hot:  #ef4b36;
  --particle-soft: #e98a7c;

  --qr-paper:  #faf9f6;
  --qr-ink:    #14120f;
  --qr-accent: #c62d1c;

  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --page: 620px;
}

:root[data-theme="dark"] {
  --paper:  #100f0d;
  --ink:    #f4f2ed;
  --muted:  #9a938a;
  --rule:   #2a2825;
  --accent: #ff6a55;
  --particle-hot:  #ff9b8c;
  --particle-soft: #e84c33;

  --qr-paper:  #f4f2ed;
  --qr-ink:    #100f0d;
  --qr-accent: #e84c33;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}

a { color: inherit; text-decoration: none; }
::selection { background: var(--accent); color: var(--paper); }

.page {
  max-width: var(--page);
  margin: 0 auto;
  padding: clamp(28px, 7vw, 72px) clamp(20px, 6vw, 32px) 72px;
}

/* Small machine text: section labels, the meta line, numbers. */
.mono {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .04em;
}

/* ---------- Skip link ---------- */
.skip {
  position: absolute; left: 12px; top: -60px; z-index: 70;
  padding: 8px 14px;
  font-size: 14px; font-weight: 600;
  color: var(--paper); background: var(--ink);
  border-radius: 2px;
  transition: top .15s ease;
}
.skip:focus { top: 12px; }

/* ---------- Header ---------- */
.head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: clamp(28px, 6vw, 44px);
}
.head__mark {
  display: block;
  width: clamp(112px, 30vw, 168px);
  flex: 0 0 auto;
}
.logo-breaker {
  padding: 0;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 2px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.logo-breaker:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; }
.logo-breaker__art {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 2058 / 1079;
  transform-origin: center;
}
.logo-breaker__fallback,
.logo-breaker__pixel,
.logo-breaker__fragments,
.logo-fragment {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.logo-breaker__fallback,
.logo-breaker__pixel {
  display: block;
  object-fit: contain;
}
.logo-breaker__fallback { transition: opacity .08s linear; }
.logo-breaker__fragments {
  opacity: 0;
  transition: opacity .08s linear;
}
.logo-breaker.is-ready .logo-breaker__fallback { opacity: 0; }
.logo-breaker.is-ready .logo-breaker__fragments { opacity: 1; }
.logo-fragment {
  background: url("../assets/logo.svg") center / 100% 100% no-repeat;
  opacity: 1;
  transform: translate(0, 0) rotate(0);
  transform-origin: center;
  transition: transform .16s steps(2, end), opacity .14s steps(2, end);
  will-change: transform, opacity;
}
.logo-fragment.is-damaged {
  transform: translate(var(--damage-x), var(--damage-y)) rotate(var(--damage-r));
}
.logo-fragment.is-missing { opacity: .04; }
.logo-breaker__pixel {
  opacity: 0;
  transform: scale(.78);
  transition: opacity .12s steps(2, end), transform .32s steps(5, end);
}
.logo-breaker.is-hit .logo-breaker__art { animation: logo-hit .13s steps(2, end); }
.logo-breaker.is-revealed .logo-fragment {
  opacity: 0;
  transform: translate(var(--split-x), var(--split-y)) rotate(var(--split-r));
  transition: transform .38s cubic-bezier(.2, .75, .25, 1), opacity .34s steps(3, end);
}
.logo-breaker.is-revealed .logo-breaker__pixel {
  opacity: 1;
  transform: scale(1);
  transition-delay: .13s;
}
.logo-breaker.is-settled .logo-breaker__fragments { display: none; }
:root[data-theme="dark"] .logo-breaker__art { filter: invert(1); }

.logo-particles {
  position: fixed;
  inset: 0;
  z-index: 80;
  overflow: hidden;
  pointer-events: none;
}
.logo-particle {
  position: fixed;
  display: block;
  background: var(--accent);
  pointer-events: none;
  will-change: transform, opacity;
}
.logo-particle:nth-child(3n + 1) { background: var(--particle-hot); }
.logo-particle:nth-child(3n + 2) { background: var(--particle-soft); }

@keyframes logo-hit {
  0%, 100% { transform: translate(0, 0); }
  35% { transform: translate(-2px, 1px); }
  70% { transform: translate(2px, -1px); }
}
@keyframes logo-screen-shake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-7px, 3px); }
  20% { transform: translate(6px, -4px); }
  30% { transform: translate(-5px, -2px); }
  42% { transform: translate(5px, 4px); }
  55% { transform: translate(-3px, 2px); }
  70% { transform: translate(3px, -2px); }
  85% { transform: translate(-1px, 1px); }
}
body.logo-shake { overflow-x: clip; }
body.logo-shake .page { animation: logo-screen-shake .48s steps(2, end); }

.tools { display: flex; gap: 2px; flex: 0 0 auto; margin-top: 2px; }
.tool {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px;
  padding: 0;
  color: var(--muted);
  background: none; border: 0;
  border-radius: 2px;
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}
.tool:hover { color: var(--accent); }
.tool:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ico-moon { display: none; }
:root[data-theme="dark"] .ico-sun { display: none; }
:root[data-theme="dark"] .ico-moon { display: block; }

/* ---------- Intro ---------- */
.intro { margin: 0 0 clamp(36px, 8vw, 64px); }
.intro__who {
  margin: 0 0 14px;
  color: var(--muted);
}
.intro__lede {
  margin: 0;
  max-width: 34ch;
  font-size: clamp(19px, 4.6vw, 23px);
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: -.01em;
  color: var(--ink);
  text-wrap: balance;
}

/* ---------- Index ---------- */
.label {
  margin: 0 0 4px;
  color: var(--muted);
}
.list { margin: 0 0 clamp(32px, 6vw, 48px); border-top: 1px solid var(--rule); }

.entry {
  display: flex;
  align-items: baseline;
  gap: clamp(12px, 3vw, 20px);
  padding: clamp(14px, 3vw, 18px) 0;
  border-bottom: 1px solid var(--rule);
  transition: border-color .15s ease;
}
.entry__num {
  flex: 0 0 auto;
  width: 2ch;
  color: var(--muted);
  transition: color .15s ease;
}
.entry__body { flex: 1 1 auto; min-width: 0; }
.entry__name {
  display: block;
  font-size: clamp(21px, 5.2vw, 27px);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -.02em;
  color: var(--ink);
  transition: color .15s ease;
}
.entry__meta {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
/* The brand mark and the arrow are a pair at the right edge: the icon says
   which service, the arrow says it leaves the page. Keeping them together in
   one box leaves the left rail as just the number. */
.entry__end {
  flex: 0 0 auto;
  align-self: center;
  display: flex;
  align-items: center;
  gap: 11px;
}
.entry__ico {
  display: grid; place-items: center;
  width: 16px; height: 16px;
  color: var(--muted);
  transition: color .15s ease;
}
/* Fixed 24px so the arrow and the copy button occupy an identical slot. The
   brand marks then line up in a true column down the right edge, whichever
   trailing control a row happens to carry. */
.entry__go {
  display: grid; place-items: center;
  width: 24px; height: 24px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  transition: color .15s ease, transform .15s ease;
}

a.entry:hover { border-bottom-color: var(--accent); }
a.entry:hover .entry__name,
a.entry:hover .entry__num,
a.entry:hover .entry__ico,
a.entry:hover .entry__go { color: var(--accent); }
a.entry:hover .entry__go { transform: translate(3px, -3px); }
a.entry:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}

/* The featured entry: the only place a name is set in the accent by default. */
.entry--now .entry__name { color: var(--accent); }

/* An action, not a destination. Same slot and same size as the arrow it
   replaces, so the right edge of every row still lines up; the dotted box is
   what says this one does something instead of going somewhere. */
.entry__act {
  display: grid; place-items: center;
  width: 24px; height: 24px;
  padding: 0;
  color: var(--muted);
  background: none;
  border: 1px dotted var(--muted);
  border-radius: 2px;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}
.entry__act:hover { color: var(--accent); border-color: var(--accent); }
.entry__act:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Text button (modal) ---------- */
.btn {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  background: none;
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 5px 12px;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}
.btn:hover { color: var(--accent); border-color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Footer ---------- */
.foot {
  color: var(--muted);
  line-height: 1.7;
}
.foot p { margin: 0; }
.foot a { color: var(--ink); box-shadow: inset 0 -1px 0 var(--accent); }
.foot a:hover { color: var(--accent); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal__scrim { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.modal__card {
  position: relative;
  width: 100%; max-width: 296px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 20px;
  text-align: center;
}
.modal__x {
  position: absolute; top: 8px; right: 8px;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  padding: 0;
  color: var(--muted);
  background: none; border: 0;
  cursor: pointer;
}
.modal__x:hover { color: var(--accent); }
.modal__x:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.modal__title {
  margin: 0 0 14px;
  color: var(--muted);
}

/* The QR follows the theme, but it never inverts. Light modules on a dark
   ground fail zbarimg and OpenCV outright, so dark mode swaps the roles of its
   own palette instead: --ink becomes the paper, --paper becomes the modules,
   and the polarity stays legal.

   --qr-accent is not the page accent. It carries the finder and alignment
   patterns, so a binariser has to read it as dark; measured on this code,
   OpenCV fails at luminance .322 (the page's #ff6a55) and passes at .261, so
   dark mode uses #e84c33 at .226.

   225px = 45 modules x 5px exactly (37 data + 8 quiet zone), so every module
   lands on a whole pixel. If tools/qr.mjs picks another version, re-derive:
   (size + 8) * 5. */
svg.qr {
  display: block;
  width: 225px; height: 225px;
  margin: 0 auto 12px;
  border-radius: 2px;
}
.qr__paper  { fill: var(--qr-paper); }
.qr__ink    { fill: var(--qr-ink); }
.qr__accent { fill: var(--qr-accent); }
.modal__url { margin: 0 0 14px; color: var(--muted); word-break: break-all; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(6px);
  z-index: 60;
  background: var(--ink); color: var(--paper);
  font-size: 13px; font-weight: 500;
  padding: 9px 16px;
  border-radius: 2px;
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.toast[hidden] { display: block; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- a11y ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media (max-width: 380px) {
  .entry { gap: 10px; }
  .entry__num { display: none; }
}
