/* ==========================================================================
   LinkIT — public unit page.

   Every colour, face and radius here comes from a custom property the server
   writes per unit (see app/theme.php). This file owns structure, rhythm and
   behaviour; the theme owns the material.
   ========================================================================== */

/* --- self-hosted house pairing -------------------------------------------
   Only the default typeset is self-hosted. Alternate pairings load from
   Google Fonts and are requested only when a unit picks one.
   -------------------------------------------------------------------------- */

@font-face {
  font-family: "Archivo Variable";
  src: url("../fonts/archivo-variable.woff2") format("woff2-variations");
  font-weight: 400 700;
  font-stretch: 75% 112%;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/plex-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

/* --- reset ---------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--rule-strong) transparent;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
  padding:
    env(safe-area-inset-top, 0px)
    env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px)
    env(safe-area-inset-left, 0px);
}

h1, h2, p, ul, figure { margin: 0; }
ul { padding: 0; list-style: none; }
img { max-width: 100%; height: auto; display: block; }
button { font: inherit; color: inherit; }

[hidden] { display: none !important; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ic {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  stroke: currentColor;
  fill: none;
  vertical-align: middle;
}

/* --- browser surfaces ------------------------------------------------------
   The parts we did not draw still belong to the palette.
   -------------------------------------------------------------------------- */

::selection { background: var(--selection); color: var(--ink); }
:root { accent-color: var(--accent); caret-color: var(--accent); }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--rule-strong);
  border: 3px solid var(--paper);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

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

a { color: inherit; text-decoration-color: var(--rule-strong); text-underline-offset: 3px; }

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10;
  padding: .7rem 1rem;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  border-radius: 0 0 var(--radius) 0;
}
.skip:focus { left: 0; }

/* --- motion ---------------------------------------------------------------- */

:root {
  --ease: cubic-bezier(.16, 1, .3, 1);   /* exponential ease-out */
  --sweep: .52s;
  --measure: 34rem;
}

/* --- surface treatments ---------------------------------------------------- */

[data-surface="ruled"] body {
  background-image: repeating-linear-gradient(
    to bottom, transparent 0 31px, var(--rule-soft) 31px 32px
  );
}

[data-surface="wash"] body {
  background-image: linear-gradient(to bottom, var(--accent-wash) 0, var(--paper) 62vh);
  background-repeat: no-repeat;
}

/* A fine tooth, drawn once as a tiny tiled SVG so it costs no request. */
[data-surface="grain"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.16'/%3E%3C/svg%3E");
}

/* --- shell ----------------------------------------------------------------- */

.page {
  position: relative;
  z-index: 1;
  max-width: 40rem;
  margin: 0 auto;
  padding: clamp(2.5rem, 9vw, 5rem) clamp(1.15rem, 5vw, 2rem) 3rem;
}

.preview-flag {
  display: flex;
  gap: .6rem;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: .7rem 1rem;
  background: var(--ink);
  color: var(--paper);
  font-size: .8125rem;
  text-align: left;
}

/* --- lede ------------------------------------------------------------------ */

.lede {
  display: flex;
  flex-direction: column;
  align-items: var(--align-items);
  text-align: var(--align);
  gap: .55rem;
  padding-bottom: clamp(1.75rem, 6vw, 2.5rem);
}

.avatar {
  width: clamp(76px, 22vw, 108px);
  height: clamp(76px, 22vw, 108px);
  object-fit: cover;
  border-radius: var(--avatar-radius);
  margin-bottom: .7rem;
  background: var(--sunk);
  box-shadow: 0 1px 0 var(--rule), 0 10px 24px -14px rgba(0, 0, 0, .5);
}

.name {
  font-size: clamp(2rem, 8.5vw, 3.1rem);
  font-weight: var(--display-weight);
  line-height: 1.02;
  letter-spacing: -.035em;
  text-wrap: balance;
  font-variation-settings: "wdth" 100;
}

.tagline {
  color: var(--ink-2);
  font-size: clamp(1rem, 3.6vw, 1.1rem);
  line-height: 1.4;
  text-wrap: balance;
}

.bio {
  color: var(--ink-3);
  font-size: .9375rem;
  line-height: 1.6;
  max-width: var(--measure);
  margin-top: .35rem;
}

/* --- social marks ---------------------------------------------------------- */

.socials {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-top: 1rem;
  justify-content: var(--align-items);
}

.socials a {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  color: var(--ink-2);
  transition: color .18s var(--ease), background-color .18s var(--ease);
}
.socials .ic { width: 20px; height: 20px; }

.socials a:hover,
.socials a:focus-visible {
  color: var(--accent);
  background: var(--accent-wash);
}

/* ==========================================================================
   Layout: index — hairline rows. The default.

   The authored moment lives here: on hover or keyboard focus the label widens
   along Archivo's width axis while an accent rule sweeps in beneath it. The
   row does not lift, scale, or change ground.
   ========================================================================== */

.links { border-top: 1px solid var(--rule); }

.row { position: relative; border-bottom: 1px solid var(--rule); }

.row > a {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.15rem .25rem;
  text-decoration: none;
  color: inherit;
}

.row__icon { color: var(--ink-3); display: flex; transition: color .22s var(--ease); }
.row__icon .ic { width: 21px; height: 21px; }

.row__text { flex: 1; min-width: 0; }

.row__label {
  display: block;
  font-size: clamp(1.1rem, 4.4vw, 1.32rem);
  font-weight: 600;
  line-height: 1.24;
  letter-spacing: -.018em;
  font-variation-settings: "wdth" 100;
  transition: font-variation-settings .42s var(--ease), color .22s var(--ease);
}

.row__sub {
  display: block;
  margin-top: .15rem;
  color: var(--ink-3);
  font-size: .8125rem;
  line-height: 1.4;
}

.row__go {
  color: var(--ink-4);
  display: flex;
  transition: transform .42s var(--ease), color .22s var(--ease);
}
.row__go .ic { width: 19px; height: 19px; }

/* the sweep */
.row::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--sweep) var(--ease);
}

.row:hover::after,
.row:focus-within::after { transform: scaleX(1); }

.row:hover .row__label,
.row:focus-within .row__label { font-variation-settings: "wdth" 108; }

.row:hover .row__go,
.row:focus-within .row__go { color: var(--accent); transform: translate(3px, -3px); }

.row:hover .row__icon,
.row:focus-within .row__icon { color: var(--accent); }

/* A featured row is promoted to a plate: the accent becomes the ground. */
.row--featured { border-bottom-color: transparent; }

.row--featured > a {
  background: var(--accent);
  color: var(--on-accent);
  border-radius: var(--radius);
  padding: 1.25rem 1.1rem;
  margin: .5rem 0;
}
.row--featured .row__sub,
.row--featured .row__icon,
.row--featured .row__go { color: inherit; opacity: .82; }
.row--featured::after { display: none; }

.row--featured > a:hover,
.row--featured > a:focus-visible { background: var(--accent-lift); }
.row--featured:hover .row__go { transform: translate(3px, -3px); opacity: 1; }

.row--quiet .row__label { font-weight: 500; font-size: 1rem; color: var(--ink-2); }

/* group headings and notes */

.group { border-bottom: 1px solid var(--rule); }
.group h2 {
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 1.9rem .25rem .6rem;
}
.links > .group:first-child h2 { padding-top: .9rem; }

.note {
  border-bottom: 1px solid var(--rule);
  padding: 1rem .25rem;
  color: var(--ink-3);
  font-size: .9375rem;
}

/* ==========================================================================
   Layout: plates — every row is a filled block with a drawn edge.
   ========================================================================== */

[data-layout="plates"] .links { border-top: 0; display: grid; gap: .6rem; }

[data-layout="plates"] .row { border-bottom: 0; }
[data-layout="plates"] .row::after { display: none; }

[data-layout="plates"] .row > a {
  background: var(--sunk);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.05rem 1.1rem;
  transition: border-color .22s var(--ease), background-color .22s var(--ease), transform .22s var(--ease);
}

[data-layout="plates"] .row > a:hover,
[data-layout="plates"] .row > a:focus-visible {
  border-color: var(--accent);
  background: var(--accent-wash);
}

[data-layout="plates"] .row--featured > a { background: var(--accent); border-color: var(--accent); }
[data-layout="plates"] .group h2 { padding: 1.4rem .1rem .3rem; }
[data-layout="plates"] .group, [data-layout="plates"] .note { border-bottom: 0; }

/* ==========================================================================
   Layout: tiles — two-up grid. Icons carry more weight, labels stay short.
   ========================================================================== */

[data-layout="tiles"] .links {
  border-top: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .6rem;
}

[data-layout="tiles"] .row { border-bottom: 0; }
[data-layout="tiles"] .row::after { display: none; }

[data-layout="tiles"] .row > a {
  flex-direction: column;
  align-items: flex-start;
  gap: .55rem;
  min-height: 7.5rem;
  padding: 1rem;
  background: var(--sunk);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  transition: border-color .22s var(--ease), background-color .22s var(--ease);
}

[data-layout="tiles"] .row > a:hover,
[data-layout="tiles"] .row > a:focus-visible {
  border-color: var(--accent);
  background: var(--accent-wash);
}

[data-layout="tiles"] .row__text { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; }
[data-layout="tiles"] .row__label { font-size: 1rem; }
[data-layout="tiles"] .row__icon .ic { width: 24px; height: 24px; }
[data-layout="tiles"] .row__go { position: absolute; top: 1rem; right: 1rem; }

[data-layout="tiles"] .group,
[data-layout="tiles"] .note,
[data-layout="tiles"] .row--featured { grid-column: 1 / -1; border-bottom: 0; }

/* The generic tile rule above is more specific than .row--featured > a, so a
   featured tile has to restate its ground here — without this it keeps the
   sunk background while the text stays on-accent white, which is unreadable. */
[data-layout="tiles"] .row--featured > a {
  flex-direction: row;
  align-items: center;
  min-height: 0;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
[data-layout="tiles"] .row--featured > a:hover,
[data-layout="tiles"] .row--featured > a:focus-visible {
  background: var(--accent-lift);
  border-color: var(--accent-lift);
}
[data-layout="tiles"] .row--featured .row__go { position: static; }

/* ==========================================================================
   Layout: marquee — display type, no furniture. For pages with few links.
   ========================================================================== */

[data-layout="marquee"] .links { border-top: 0; }
[data-layout="marquee"] .row { border-bottom: 0; }

[data-layout="marquee"] .links { display: grid; gap: clamp(.5rem, 2.5vw, 1rem); }
[data-layout="marquee"] .row > a { padding: .35rem .25rem .7rem; align-items: baseline; gap: 1.25rem; }

[data-layout="marquee"] .row__label {
  font-size: clamp(1.8rem, 9vw, 3rem);
  font-weight: var(--display-weight);
  letter-spacing: -.04em;
  line-height: 1.04;
  text-wrap: balance;
}

[data-layout="marquee"] .row__icon { display: none; }
[data-layout="marquee"] .row__go .ic { width: 24px; height: 24px; }
[data-layout="marquee"] .row::after { bottom: .3rem; }

[data-layout="marquee"] .row:hover .row__label,
[data-layout="marquee"] .row:focus-within .row__label { color: var(--accent); font-variation-settings: "wdth" 104; }

[data-layout="marquee"] .row--featured > a { padding: 1.1rem; }

/* --- footer ---------------------------------------------------------------- */

.foot {
  margin-top: clamp(2.25rem, 8vw, 3.25rem);
  padding-top: 1.35rem;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  align-items: var(--align-items);
  gap: 1rem;
}

.foot__tools { display: flex; flex-wrap: wrap; gap: .45rem; }

.tool {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem .8rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-3);
  font-size: .8125rem;
  text-decoration: none;
  cursor: pointer;
  transition: color .2s var(--ease), border-color .2s var(--ease);
}
.tool .ic { width: 16px; height: 16px; }
.tool:hover, .tool:focus-visible { color: var(--accent); border-color: var(--accent); }

.qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  padding: 1rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--sunk);
  align-self: var(--align-items);
}
.qr img { width: 180px; height: 180px; }

/* --ink-3 is forced to 4.5:1 against --paper, but this caption sits on the
   slightly darker --sunk panel, where the same tint falls to about 4.1:1.
   The caption is a real URL people read and check, so it takes the darker ink. */
.qr__url {
  font-family: var(--font-mono);
  font-size: .6875rem;
  color: var(--ink-2);
  letter-spacing: .02em;
  word-break: break-all;
  text-align: center;
}

.by { font-size: .75rem; color: var(--ink-4); }
.by a { text-decoration: none; transition: color .2s var(--ease); }
.by a:hover { color: var(--accent); }
.by strong { font-weight: 600; color: var(--ink-3); }

.empty { color: var(--ink-3); padding: 2rem 0; }

/* --- reduced motion --------------------------------------------------------
   The affordance survives; the animation does not.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .row:hover .row__label,
  .row:focus-within .row__label { font-variation-settings: "wdth" 100; }
  .row:hover .row__go,
  .row:focus-within .row__go { transform: none; }
}

[data-motion="calm"] .row__label { transition: color .2s var(--ease); }
[data-motion="calm"] .row:hover .row__label,
[data-motion="calm"] .row:focus-within .row__label { font-variation-settings: "wdth" 100; }
[data-motion="calm"] .row::after { transition-duration: .2s; }
[data-motion="calm"] .row:hover .row__go { transform: none; }

/* --- wide ------------------------------------------------------------------ */

@media (min-width: 46rem) {
  [data-layout="tiles"] .links { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 22rem) {
  [data-layout="tiles"] .links { grid-template-columns: minmax(0, 1fr); }
}

/* --- print ----------------------------------------------------------------- */

@media print {
  .foot__tools, .skip, .preview-flag { display: none; }
  .row::after { display: none; }
  body { background: #fff; color: #000; }
}

/* --- closing the list ------------------------------------------------------
   The footer draws its own rule, so the last row must not draw one too:
   two hairlines with the footer's margin between them read as an empty row.
   -------------------------------------------------------------------------- */

.links > li:last-child { border-bottom: 0; }

/* Notes and group headings follow the page's alignment; the rows themselves
   keep their icon/label/arrow structure and stay left whatever the setting. */
.note p, .group h2 { text-align: var(--align); }
