/* <sg-person-card>. Without JavaScript this is the quiet look: a hairline
   card with the initials disc at the left, the name, the role, the one line on
   what they are building, and a link. Warm softens the card and hands the
   disc to the hand. Playful colours the disc from a seed and tilts the card a
   little, once, when the pointer or the focus arrives. No photos by default:
   an img.sg-person-photo written by the author (consent recorded) takes the
   disc's place, and everything else holds. */

sg-person-card {
  display: block;
  container: person-card / inline-size;
  color: var(--sg-text);
  font: var(--sg-step-0) / var(--sg-leading-body) var(--sg-font-body);
}
sg-person-card[hidden], sg-person-card [hidden] { display: none !important; }
sg-person-card > article {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--sg-space-2) var(--sg-space-3);
  align-items: start;
  padding: var(--sg-space-4);
  background: var(--sg-surface-raised);
  border: var(--sg-hairline) solid var(--sg-rule-strong);
  border-top: var(--sg-stroke-bold) solid var(--sg-text);
  border-radius: var(--sg-radius-1);
}
sg-person-card > article > * { margin: 0; min-width: 0; }
sg-person-card > article > :is(.sg-person-initials, img.sg-person-photo) {
  grid-column: 1;
  grid-row: 1 / span 3;
}
sg-person-card > article > :is(h1, h2, h3, h4) {
  font: 400 var(--sg-step-1) / var(--sg-leading-tight) var(--sg-font-display);
  align-self: end;
}
sg-person-card .sg-person-role { color: var(--sg-text-soft); font-size: var(--sg-step--1); }
sg-person-card .sg-person-building { font-size: var(--sg-step-0); align-self: start; }
/* narrow: the link runs under the disc across the card, so a long link never
   widens the disc's column and pushes the words right */
sg-person-card .sg-person-link { grid-column: 1 / -1; }
@container person-card (min-width: 24rem) {
  sg-person-card .sg-person-building { grid-column: 2; }
  sg-person-card .sg-person-link { grid-column: 2; }
}
/* no disc and no photo (JavaScript off, or an author who left both out): one column, so the
   words never auto-place into an empty 0 px disc column and run out of the card */
sg-person-card > article:not(:has(> :is(.sg-person-initials, img.sg-person-photo))) { grid-template-columns: minmax(0, 1fr); }
sg-person-card > article:not(:has(> :is(.sg-person-initials, img.sg-person-photo))) > * { grid-column: 1; }
sg-person-card > article { overflow-wrap: anywhere; }
sg-person-card .sg-person-link { font-size: var(--sg-step--1); }
sg-person-card .sg-person-link a {
  color: var(--sg-accent-text);
  text-underline-offset: 0.2em;
}
sg-person-card .sg-person-link a:hover { text-decoration-thickness: 2px; }
sg-person-card .sg-person-link a:focus-visible {
  outline: var(--sg-focus-width) solid var(--sg-focus);
  outline-offset: var(--sg-focus-offset);
  border-radius: 2px;
}

/* the initials disc: the initials are cut from the heading by the element */
sg-person-card .sg-person-initials {
  display: grid;
  place-content: center;
  box-sizing: border-box;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--sg-surface-sunk);
  border: var(--sg-hairline) solid var(--sg-rule-strong);
  font: var(--sg-weight-medium) var(--sg-step-1) / 1 var(--sg-font-display);
  letter-spacing: 0.04em;
  color: var(--sg-text-soft);
  font-variant-caps: none;
}
/* a photo, only when the author wrote one: it takes the disc's slot exactly */
sg-person-card img.sg-person-photo {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  object-fit: cover;
  border: var(--sg-hairline) solid var(--sg-rule-strong);
}

/* ── warm: a soft card, the disc in the hand ── */
sg-person-card[data-skin="warm"] > article {
  border: 0;
  background:
    radial-gradient(120% 90% at 12% 0%, color-mix(in oklch, var(--sg-accent) 7%, transparent), transparent 55%),
    var(--sg-surface-raised);
  box-shadow: inset 0 0 0 var(--sg-hairline) var(--sg-rule),
    0 1px 0 color-mix(in oklch, var(--sg-shadow) 12%, transparent),
    0 10px 12px color-mix(in oklch, var(--sg-shadow) 20%, transparent);
  border-radius: var(--sg-radius-2);
  padding: var(--sg-space-4) var(--sg-space-5);
}
sg-person-card[data-skin="warm"] .sg-person-initials {
  font-family: var(--sg-font-hand);
  font-weight: 400;
  color: var(--sg-text);
  background: var(--sg-surface-raised);
  box-shadow: inset 0 0 0 calc(var(--sg-stroke-bold) + 1px) var(--sg-rule-strong), inset 0 0 0 calc(var(--sg-stroke-bold) + 3px) var(--sg-surface-raised);
  border: 0;
}
sg-person-card[data-skin="warm"] > article > :is(h1, h2, h3, h4) { font-size: var(--sg-step-2); }

/* ── playful: a colour disc from the seed, and a small seeded tilt ── */
sg-person-card[data-skin="playful"] > article {
  border: var(--sg-stroke-bold) solid var(--sg-text);
  border-radius: var(--sg-radius-2);
  background: var(--sg-surface-raised);
}
sg-person-card[data-skin="playful"] .sg-person-initials {
  background: oklch(0.85 0.11 var(--sg-person-hue, 40));
  color: oklch(0.32 0.08 var(--sg-person-hue, 40));
  border: var(--sg-stroke-bold) solid var(--sg-text);
  font-family: var(--sg-font-hand);
  font-weight: 400;
}
sg-person-card[data-skin="playful"] > article > :is(h1, h2, h3, h4) { font-size: var(--sg-step-2); }
sg-person-card[data-skin="playful"] .sg-person-link { font-size: var(--sg-step-0); }

/* the tilt: it arrives on the pointer or the focus, once, with the spring ease.
   Reduced motion and every other register keep the card at rest. */
@media (prefers-reduced-motion: no-preference) {
  sg-person-card[data-skin="playful"][data-motion="full"]:is(:hover, :focus-within) {
    rotate: var(--sg-person-tilt, 0deg);
    transition: rotate var(--sg-dur-slow) var(--sg-ease-spring);
  }
}

@media (forced-colors: active) {
  sg-person-card > article { border: 1px solid CanvasText; }
  sg-person-card .sg-person-initials { border: 1px solid CanvasText; color: CanvasText; background: Canvas; }
}

/* touch contract: press, release, keyboard-repeat and reduced motion (docs/contributing/touch-contract.md) */
sg-person-card a { transition: translate 120ms var(--sg-ease-out, ease-out), scale 150ms var(--sg-ease-spring, ease-out); }
sg-person-card a:active { translate: 0 1px; color: color-mix(in oklab, var(--sg-accent-text, currentColor), var(--sg-text, CanvasText) 25%); text-decoration-thickness: 2px; transition: none !important; }
sg-person-card[data-skin="warm"] .sg-person-link a:active { translate: none; }
sg-person-card[data-skin="playful"] .sg-person-link a:active { translate: none; scale: 0.97; }
@media (prefers-reduced-motion: reduce) {
  sg-person-card a { transition: none; }
  sg-person-card a:active { translate: none !important; scale: none !important; }
}
