@font-face {
  font-family: "Departure Mono";
  src: url("../fonts/departure-mono.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  isolation: isolate;
  background: #08080b;
  color: #aaa;
  font-family: system-ui, sans-serif;
}

.intro {
  --pixel-font: "Departure Mono", ui-monospace, monospace;

  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
}

.intro__visual {
  min-inline-size: 0;
}

@property --art-color-start {
  syntax: "<color>";
  inherits: true;
  initial-value: #888;
}

@property --art-color-end {
  syntax: "<color>";
  inherits: true;
  initial-value: #888;
}

.intro__art {
  position: relative;
  isolation: isolate;
  aspect-ratio: 4 / 3;
  margin: 4px;
  overflow: hidden;
  border-radius: 12px;
  background: #101010;
}

.intro__art img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(.76) grayscale(1);
  transition: filter 620ms ease;
}

.intro__art::before,
.intro__art::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  content: "";
}

.intro__art::before {
  background: linear-gradient(145deg, var(--art-color-start, #888), var(--art-color-end, #888));
  mix-blend-mode: color;
  opacity: 0;
  transition: opacity 620ms ease, --art-color-start 620ms ease, --art-color-end 620ms ease;
}

.intro__art::after {
  background: conic-gradient(#0004 25%, transparent 0 50%, #0004 0 75%, transparent 0) 0 0 / 4px 4px;
}

:root[data-discord-cached-online] .intro__visual:not([data-art-theme]) .intro__art img,
.intro__visual[data-art-theme="online"] .intro__art img {
  filter: brightness(.76) grayscale(0);
}

.intro__visual[data-art-theme="spotify"] .intro__art::before {
  opacity: .83;
}

.presence {
  display: grid;
  margin: .75rem .875rem 0;
  min-inline-size: 0;
}

.presence__spotify {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 460ms cubic-bezier(.25,.65,.35,1), opacity 400ms ease;
}

.presence__spotify:has(#spotify-card[href]) {
  grid-template-rows: 1fr;
  opacity: 1;
}

.presence__spotify-clip {
  min-block-size: 0;
  overflow: clip;
  overflow-clip-margin: 14px;
}

#spotify-card {
  --corner-star-color: #ff55ce;

  margin-block-end: .625rem;
}

#discord-card {
  --corner-star-color: #71d5ff;
}

:is(#spotify-song, #spotify-artist, #spotify-time) {
  transition: opacity 280ms ease;
}

#spotify-card[data-switching] :is(#spotify-song, #spotify-artist, #spotify-time) {
  opacity: 0;
  transition-delay: 140ms;
}

.presence-card {
  position: relative;
  display: grid;
  gap: .625rem;
  min-inline-size: 0;
  padding: .75rem;
  border: 1px solid #303036;
  border-radius: .875rem;
  background: #0e0e12;
  background-image:
    linear-gradient(140deg, transparent, #0e0e12 43%),
    radial-gradient(circle at 1px 1px, #76768050 1px, transparent 1.25px);
  background-size: 100% 100%, 4px 4px;
  color: #eee;
  line-height: 1.3;
  text-decoration: none;
  transition: border-color 180ms ease;
}

.presence-card::after,
.project__preview::after {
  --corner-star-outline: color-mix(in srgb, currentColor 45%, transparent);

  position: absolute;
  inset-block-start: -13px;
  inset-inline-end: -13px;
  inline-size: 30px;
  block-size: 30px;
  background:
    linear-gradient(#fff9 0 0) center / 6px 6px no-repeat,
    linear-gradient(currentColor 0 0) center / 18px 6px no-repeat,
    linear-gradient(currentColor 0 0) center / 6px 18px no-repeat,
    linear-gradient(var(--corner-star-outline) 0 0) center / 100% 6px no-repeat,
    linear-gradient(var(--corner-star-outline) 0 0) center / 18px 18px no-repeat,
    linear-gradient(var(--corner-star-outline) 0 0) center / 6px 100% no-repeat;
  color: var(--corner-star-color);
  pointer-events: none;
  content: "";
}

.presence-card::after {
  /* Account for the card's 1px border. */
  inset-block-start: -14px;
  inset-inline-end: -14px;
}

.presence-card:is(:hover, :focus-visible) {
  border-color: #777;
}

.presence-card:focus-visible {
  outline: 2px solid #ddd;
  outline-offset: 2px;
}

.presence-card__body {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr);
  align-items: center;
  gap: .75rem;
}

.presence-card__media {
  position: relative;
  display: block;
  inline-size: 3.5rem;
  aspect-ratio: 1;
  background: #28282e;
}

.presence-card__media img {
  inline-size: 100%;
  block-size: 100%;
  border-radius: inherit;
  object-fit: cover;
  vertical-align: top;
}

.presence-card__avatar {
  border-radius: 50%;
}

.presence-card__avatar::after {
  position: absolute;
  inset: auto 0 0 auto;
  inline-size: .625rem;
  block-size: .625rem;
  border: 3px solid #0e0e12;
  border-radius: 50%;
  background: var(--presence-color, #777780);
  content: "";
}

.presence-card[data-presence="online"] { --presence-color: #52c989; }
.presence-card[data-presence="idle"] { --presence-color: #f3b94f; }
.presence-card[data-presence="dnd"] { --presence-color: #ef6b70; }

.presence-card__cover {
  border-radius: .375rem;
}

.presence-card__cover > * {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: inherit;
}

.presence-card__details {
  display: grid;
  gap: .1875rem;
  min-inline-size: 0;
}

.presence-card__details > strong,
.presence-card__details > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.presence-card__details > span {
  color: #b9b9bd;
  font-size: .875rem;
}

.presence-card__details img {
  inline-size: 1em;
  block-size: 1em;
  margin-inline-end: .25em;
  vertical-align: -.125em;
}

.presence-card__track {
  position: relative;
  display: block;
  box-sizing: border-box;
  block-size: 8px;
  margin-block-start: .3125rem;
  padding: 1px;
  background: repeating-linear-gradient(90deg, #2a2a30 0 7px, #222228 7px 8px);
  box-shadow: inset 0 0 0 1px #48484f;
  clip-path: polygon(
    1px 0, calc(100% - 1px) 0, calc(100% - 1px) 1px, 100% 1px,
    100% calc(100% - 1px), calc(100% - 1px) calc(100% - 1px),
    calc(100% - 1px) 100%, 1px 100%, 1px calc(100% - 1px),
    0 calc(100% - 1px), 0 1px, 1px 1px
  );
}

.presence-card__track progress {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  opacity: 0;
}

.presence-card__fill {
  position: relative;
  display: block;
  width: 0;
  block-size: 100%;
  overflow: hidden;
  background:
    linear-gradient(#fff3 1px, transparent 1px calc(100% - 1px), #0004 0),
    repeating-linear-gradient(90deg, #afafb7 0 7px, #97979f 7px 8px);
}

.presence-card__fill::after {
  position: absolute;
  inset: 0 0 0 auto;
  inline-size: 2px;
  background: #f1f1f5;
  content: "";
}

.presence-card__footer {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  color: #aaaab0;
  font-size: .75rem;
  font-weight: 600;
}

.presence-card__time {
  font: .75rem / 1.3 var(--pixel-font);
}

.intro__content {
  --emphasis-color: #eee;

  display: flex;
  flex: 1;
  flex-direction: column;
  width: calc(100% - 2.5rem);
  max-width: 45rem;
  margin-inline: auto;
  padding-block: 2rem;
  font-size: clamp(1rem, 4vw, 1.25rem);
  line-height: 1.6;
}

.bio__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: .875rem 1.25rem;
  margin-block-end: 1.75rem;
}

.bio h1 {
  margin: 0;
  font: 400 clamp(1.375rem, 6.8vw, 2.0625rem) / 1.15 var(--pixel-font);
}

.bio h1 strong {
  color: var(--emphasis-color);
  font-weight: inherit;
}

.bio p {
  margin: 0;
}

.bio p + p {
  margin-block-start: 1em;
}

.bio p strong {
  display: inline-block;
  padding: .05em .25em;
  border-radius: 4px;
  background: #202020;
  color: #ccc;
  font-weight: 500;
}

.bio a {
  color: var(--emphasis-color);
  overflow-wrap: anywhere;
  text-decoration-color: #828282;
  text-underline-offset: .2em;
}

.bio a:hover {
  text-decoration-color: currentColor;
}

.bio a:focus-visible {
  outline: 2px solid #bfbfbf;
  outline-offset: 3px;
  border-radius: 2px;
}

.local-status {
  display: grid;
  justify-items: start;
  gap: .1875rem;
  inline-size: 11.75rem;
  max-inline-size: 100%;
  font-size: .875rem;
  line-height: 1.4;
}

.local-status__line,
.local-status__conditions {
  display: flex;
  align-items: center;
  gap: .375rem;
}

.local-status__number {
  --digit-height: 1.3em;

  display: inline-flex;
  color: var(--emphasis-color);
  font: 400 1rem / var(--digit-height) var(--pixel-font);
}

.local-status__digits {
  display: inline-flex;
}

.local-status__digit {
  inline-size: 1ch;
  block-size: var(--digit-height);
  overflow: hidden;
  white-space: pre;
}

.local-status__digit span {
  display: block;
}

.bio .local-status__conditions {
  color: inherit;
  text-decoration-color: transparent;
}

.local-status__icon {
  --icon-size: 1rem;

  flex: 0 0 var(--icon-size);
  block-size: var(--icon-size);
  background-image: url("../images/weather-icons.png");
  background-position: calc(-1 * var(--icon-size) * var(--weather-icon-frame, 0)) 0;
  background-size: auto 100%;
  background-repeat: no-repeat;
  image-rendering: pixelated;
}

.local-status__spoken {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (min-width: 48rem) {
  .intro {
    --intro-scale: 1;

    display: grid;
    grid-template-columns: minmax(0, 42fr) minmax(0, 58fr);
    /* Allow for fractional-pixel rounding when the layout is scaled. */
    min-height: calc((100svh - 1px) / var(--intro-scale));
    zoom: var(--intro-scale);
  }

  .intro__visual {
    display: grid;
    grid-template-areas: "visual";
  }

  .intro__art {
    grid-area: visual;
    aspect-ratio: auto;
  }

  .presence {
    grid-area: visual;
    align-self: end;
    z-index: 1;
    margin: 1rem clamp(1rem, 2vw, 2rem);
  }

  .intro__content {
    --page-gutter: clamp(3rem, 7svh, 6rem);

    width: calc(100% - clamp(3.5rem, 10vw, 12rem));
    padding-block: calc(min(var(--page-gutter), 14svh) / var(--intro-scale)) var(--page-gutter);
    font-size: clamp(1rem, .9rem + .4vw, 1.25rem);
  }

  .bio__header {
    margin-block-end: clamp(2rem, 5.5vh, 4.5rem);
  }

  .bio h1 {
    font-size: clamp(1.625rem, 2.6vw, 2.0625rem);
  }
}

@media (min-width: 68rem) {
  .local-status {
    justify-items: end;
  }
}

.projects,
.intro__content > .presence {
  margin-block-start: clamp(2.75rem, 5vw, 3.5rem);
}

.projects h2,
.presence__heading {
  margin: 0 0 .75rem;
  padding-block-end: .75rem;
  border-bottom: 1px solid #292929;
  color: #999;
  font-size: .875rem;
  font-weight: 600;
}

.presence__heading {
  display: none;
}

.intro__content > .presence {
  margin-inline: 0;
}

.intro__content .presence__heading {
  display: block;
  margin-block-end: .75rem;
}

.project {
  position: relative;
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr);
  gap: clamp(.75rem, 4vw, 1.5rem);
  align-items: start;
  padding-block: .75rem;
  border-radius: .75rem;
  color: inherit;
  font-size: clamp(.9375rem, .85rem + .45vw, 1.125rem);
  line-height: 1.45;
  text-decoration: none;
}

.project:focus-visible {
  outline: 2px solid #bfbfbf;
  outline-offset: 5px;
}

.project__icon {
  width: 2rem;
  height: auto;
  margin-block-start: .625rem;
  justify-self: center;
}

.project__heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .25rem .75rem;
}

.project__heading h3 {
  margin: 0;
  color: var(--emphasis-color);
  font-size: clamp(1rem, .9rem + .5vw, 1.25rem);
  font-weight: 600;
}

.project__heading span {
  color: #999;
  font-size: .875rem;
}

.project p {
  margin: .25rem 0 0;
}

.project__preview {
  --corner-star-color: #69e89b;

  position: relative;
  isolation: isolate;
  margin-block-start: 1rem;
  padding: .375rem;
}

.project__preview::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(circle at calc(100% - 2px) 2px, #242824 5px, #677168 18px, #eee 36px);
  /* Give the frame stepped corners. */
  clip-path: polygon(
    8px 0, calc(100% - 8px) 0,
    calc(100% - 8px) 2px, calc(100% - 4px) 2px, calc(100% - 4px) 4px,
    calc(100% - 2px) 4px, calc(100% - 2px) 8px, 100% 8px,
    100% calc(100% - 8px), calc(100% - 2px) calc(100% - 8px),
    calc(100% - 2px) calc(100% - 4px), calc(100% - 4px) calc(100% - 4px),
    calc(100% - 4px) calc(100% - 2px), calc(100% - 8px) calc(100% - 2px),
    calc(100% - 8px) 100%, 8px 100%,
    8px calc(100% - 2px), 4px calc(100% - 2px), 4px calc(100% - 4px),
    2px calc(100% - 4px), 2px calc(100% - 8px), 0 calc(100% - 8px),
    0 8px, 2px 8px, 2px 4px, 4px 4px, 4px 2px, 8px 2px
  );
  content: "";
}

.project__preview img {
  display: block;
  width: 100%;
  height: auto;
  background: #080808;
  object-fit: contain;
}

.project__caption {
  display: flex;
  justify-content: space-between;
  padding: .3125rem .125rem 0;
  color: #303030;
  font-size: .8125rem;
  font-weight: 600;
  line-height: 1.2;
}

.intro__footer {
  margin-block-start: auto;
  padding-block-start: clamp(2.5rem, 5vw, 4rem);
  color: #929292;
  font-size: .875rem;
}

@media (min-width: 48rem) and (max-height: 54rem) {
  .intro__content {
    width: calc(100% - clamp(2rem, 6vw, 6rem));
    padding-block-end: clamp(1rem, 3svh, 1.5rem);
    font-size: clamp(1rem, 2.5svh, 1.2rem);
    line-height: 1.45;
  }

  .bio__header {
    margin-block-end: clamp(1.25rem, 4svh, 2.25rem);
  }

  .bio p + p {
    margin-block-start: .7em;
  }

  .projects {
    margin-block-start: clamp(1.25rem, 4svh, 2.25rem);
  }

  .intro__footer {
    padding-block-start: clamp(1rem, 3svh, 1.625rem);
  }
}

@media (min-width: 48rem) and (hover: none) {
  .project__body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(6.5rem, 30%);
    grid-template-rows: auto 1fr;
    align-items: start;
    column-gap: .875rem;
  }

  .project__preview {
    grid-column: 2;
    grid-row: 1 / span 2;
    margin-block-start: 0;
  }
}

@media (min-width: 48rem) and (hover: hover) {
  .project {
    isolation: isolate;
  }

  .project__icon {
    align-self: center;
    margin-block-start: 0;
  }

  .project::before {
    position: absolute;
    inset: -.375rem -.625rem;
    z-index: -1;
    border-radius: inherit;
    background: #171717;
    opacity: 0;
    transition: opacity 145ms ease;
    pointer-events: none;
    content: "";
  }

  .project:is(:hover, :focus-visible)::before {
    opacity: 1;
  }

  .project__preview {
    position: fixed;
    z-index: 1;
    inset: 0 auto auto 0;
    box-sizing: border-box;
    width: min(24rem, calc(var(--preview-width, 36vw) / var(--intro-scale)));
    margin: 0;
    translate:
      calc(var(--preview-x, 0px) / var(--intro-scale))
      calc(var(--preview-y, 0px) / var(--intro-scale));
    rotate: var(--preview-tilt, -2deg);
    scale: .94;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
      scale 230ms cubic-bezier(.2, 1.35, .4, 1),
      opacity 145ms ease,
      visibility 0s linear 145ms;
  }

  .project:is(:hover, :focus-visible):not([data-preview-dismissed]) .project__preview {
    scale: 1;
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
  }

  .project__preview img {
    max-height: max(5rem, calc(50vh - 2.5rem));
  }
}

.starfield {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.star {
  --resting-opacity: .12;
  --bright-opacity: .36;

  position: absolute;
  top: var(--y);
  left: var(--x);
  width: var(--size);
  height: var(--size);
  background: currentColor;
  color: var(--color);
  opacity: var(--resting-opacity);
  animation: twinkle var(--cycle-duration) steps(4, end) var(--cycle-delay) infinite;
}

.star:not(.star--cross):nth-child(4n + 2) {
  --bright-opacity: .48;
}

.star--cross {
  --resting-opacity: .24;
  --bright-opacity: .64;
}

.star--cross::before,
.star--cross::after {
  position: absolute;
  inset: 0;
  background: currentColor;
  content: "";
  opacity: 0;
  animation: flare var(--cycle-duration) steps(1, end) var(--cycle-delay) infinite;
}

.star--cross::before {
  inset-inline: calc(-1 * var(--size));
}

.star--cross::after {
  inset-block: calc(-1 * var(--size));
}

/* The keyframe offsets are calibrated to CYCLE_SCALE in js/starfield.js. */
@keyframes twinkle {
  0%, 100% { opacity: var(--resting-opacity); }
  35.5872% { opacity: var(--bright-opacity); }
  71.1744% { opacity: var(--resting-opacity); }
}

@keyframes flare {
  0%, 55.605%, 100% { opacity: 0; }
  33.363% { opacity: .55; }
}

@media (max-width: 600px) {
  .star:nth-child(3n) {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .intro__art img,
  .intro__art::before,
  .presence__spotify,
  :is(#spotify-song, #spotify-artist, #spotify-time),
  .presence-card,
  .project::before,
  .project__preview {
    transition: none;
  }

  .star,
  .star--cross::before,
  .star--cross::after {
    animation: none;
  }
}
