/*
 * Homepage pixel style, matching the kittens' sprites: outlined bio card with
 * a hard shadow, stepped portrait frame, 12x12 toggle sprites. Loaded after
 * home-motion.css and scoped under the .pixel class that index.html sets on
 * <html>, so no other page is affected.
 */

.pixel {
  /* The cats' own outline colour and ginger, so the card matches the sprites. */
  --px-line: #33241f;
  --px-surface: #ffffff;
  --px-shadow: #c4884e;
  --px: 2px; /* one art pixel, same as the cats */
  --px-step: polygon(
    4px 0, calc(100% - 4px) 0,
    calc(100% - 4px) 2px, calc(100% - 2px) 2px,
    calc(100% - 2px) 4px, 100% 4px,
    100% calc(100% - 4px), calc(100% - 2px) calc(100% - 4px),
    calc(100% - 2px) calc(100% - 2px), calc(100% - 4px) calc(100% - 2px),
    calc(100% - 4px) 100%, 4px 100%,
    4px calc(100% - 2px), 2px calc(100% - 2px),
    2px calc(100% - 4px), 0 calc(100% - 4px),
    0 4px, 2px 4px,
    2px 2px, 4px 2px
  );
  --px-step-1: polygon(
    2px 0, calc(100% - 2px) 0,
    calc(100% - 2px) 2px, 100% 2px,
    100% calc(100% - 2px), calc(100% - 2px) calc(100% - 2px),
    calc(100% - 2px) 100%, 2px 100%,
    2px calc(100% - 2px), 0 calc(100% - 2px),
    0 2px, 2px 2px
  );
}

.pixel[data-theme="dark"] {
  --px-line: #8f887c;
  --px-surface: #282520;
  --px-shadow: #0f0e0c;
}

/* ---- Bio card: outlined, stepped corners, hard offset shadow ---- */

/* Where the card already spans the viewport, the 4px shadow must not add a scrollbar. */
html.pixel { overflow-x: clip; }

.pixel .intro::before {
  border: 2px solid transparent;
  border-radius: 0;
  box-shadow: none;
  clip-path: var(--px-step);
  background:
    linear-gradient(var(--px-line) 0 0) left top / 2px 2px no-repeat padding-box,
    linear-gradient(var(--px-line) 0 0) right top / 2px 2px no-repeat padding-box,
    linear-gradient(var(--px-line) 0 0) left bottom / 2px 2px no-repeat padding-box,
    linear-gradient(var(--px-line) 0 0) right bottom / 2px 2px no-repeat padding-box,
    linear-gradient(var(--px-surface) 0 0) padding-box,
    linear-gradient(var(--px-line) 0 0) border-box;
}

/* clip-path would cut off a box-shadow, so the shadow is its own layer. */
.pixel .intro::after {
  content: '';
  position: absolute;
  z-index: -2;
  inset: 12px calc(-1 * var(--section-outset)) -8px;
  background: var(--px-shadow);
  clip-path: var(--px-step);
  transform: translate(4px, 4px);
  pointer-events: none;
}

@media (max-width: 820px) {
  .pixel .intro::after { inset-block-start: 8px; }
}

/* The 3D tilt reads as "glass"; the pixel card stays still on hover. */
.pixel .intro.has-tilt,
.pixel .intro.has-tilt.is-tilted {
  transform: none;
  transition: none;
}
.pixel .intro.has-tilt::before,
.pixel .intro.has-tilt.is-tilted::before {
  box-shadow: none;
  transition: none;
}

/* ---- Card gaps: with a hard outline the corners show any mismatch, so the
   portrait and the name's cap line sit as far below the top edge as the
   portrait and text sit in from the sides. The photo's bottom margin shrinks
   by the same amount, so the text wraps and the icons sit as before. ---- */

.pixel .intro-photo { margin-top: 4px; margin-bottom: 33px; }
.pixel .intro-heading { margin-top: -3px; }

/* On narrow screens the page's 8px outset is too tight for a hard outline, so
   the card (outline and shadow) reaches 4px further out and every gap is 12px.
   The text keeps the page column. */
@media (max-width: 820px) {
  .pixel .intro { --section-outset: 12px; }
  .pixel .intro-photo { margin-top: 0; }
  .pixel .intro-heading { margin-top: -7px; }
}

/* ---- Portrait: the photo in a stepped frame ---- */

.pixel .avatar-frame { border-radius: 0; }
.pixel .avatar-visual {
  border: 2px solid var(--px-line);
  border-radius: 0;
  clip-path: var(--px-step-1);
}

/* ---- Icons: font glyphs with a stepped hover; 12x12 sprites on the toggle ---- */

.pixel .px-glyph {
  display: block;
  width: 24px;
  height: 24px;
  fill: currentColor;
}
.pixel .profile-icon i,
.pixel .profile-icon:hover i {
  transform: none;
  transition: none;
}
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .pixel .profile-icon:hover i { transform: translateY(-2px); }
}

/* The vector sun/moon stays until homePixel.js has added the sprites. */
.pixel .theme-toggle:has(.px-glyph) .theme-icon { display: none; }
.pixel .theme-toggle {
  border-radius: 0;
  clip-path: var(--px-step-1);
}
.pixel .px-dark,
.pixel[data-theme="dark"] .px-light { display: none; }
.pixel[data-theme="dark"] .px-dark { display: block; }
