@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif&family=Inter:wght@400;500&display=swap');

:root {
  --dark: #111111;
  --light: #f5f5f0;
  --accent: #e35f00;

  --step: 90ms;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--dark);
  color: var(--dark);
  display: grid;
  place-items: center;
  margin: 0;
  min-height: 100dvh;
  padding: 2rem 1rem;
}

.container {
  width: 100%;
  max-width: 34rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  transition: opacity 400ms ease;
}

.container.loading {
  opacity: 0;
}

.title {
  margin: 0 0 -0.75rem;
  text-align: center;
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1;
  color: color-mix(in srgb, var(--light) 80%, transparent);
}

.email {
  position: relative;
  background-color: var(--light);
  border-radius: 14px;
  padding: 2.25rem 2.25rem 2rem;
  font-size: 1rem;
  line-height: 1.9;
}

.body {
  display: flex;
  flex-direction: column;
  margin-bottom: 1.5rem;
}

.line {
  display: flex;
  flex-shrink: 0;
  gap: 0.4em;
  height: 1.9em;
  align-items: center;
}

.line[hidden] {
  display: none;
}

.spacer {
  flex-grow: 1;
}

.word {
  flex-basis: 0;
  min-width: 0.6em;
  height: 0.7em;
  border-radius: 3px;
  background-color: color-mix(in srgb, var(--dark) 14%, transparent);
}

.signature,
.name {
  margin: 0;
}

.signature {
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 2.5rem;
  line-height: 1.15;
  color: var(--accent);
  margin-bottom: 0.4rem;
  overflow-wrap: anywhere;
}

.name {
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
  font-weight: 500;
  outline: none;
  border-bottom: 1px dashed transparent;
  cursor: text;
  min-width: 2ch;
}

@media (hover: hover) {
  .name:hover {
    border-bottom-color: color-mix(in srgb, var(--dark) 40%, transparent);
  }
}

.name:focus {
  border-bottom-style: solid;
  border-bottom-color: var(--accent);
  caret-color: var(--accent);
}

.name::selection {
  background-color: color-mix(in srgb, var(--accent) 25%, transparent);
}

.about-toggle {
  all: unset;
  width: 1.75rem;
  height: 1.75rem;
  margin: -0.25rem 0 -0.25rem 0.1rem;
  display: inline-grid;
  place-items: center;
  vertical-align: middle;
  border-radius: 50%;
  font-size: 1.1rem;
  color: color-mix(in srgb, var(--light) 60%, transparent);
  cursor: pointer;
  touch-action: manipulation;
  transition: color 120ms ease;
}

.about-toggle i {
  grid-area: 1 / 1;
  transition:
    opacity 450ms cubic-bezier(0.65, 0, 0.35, 1),
    transform 450ms cubic-bezier(0.65, 0, 0.35, 1);
}

.about-toggle .ph-x,
.about-toggle[aria-expanded='true'] .ph-info {
  opacity: 0;
  transform: rotate(-90deg);
}

.about-toggle[aria-expanded='true'] .ph-x {
  opacity: 1;
  transform: none;
}

.about-toggle[aria-expanded='true'] .ph-info {
  transform: rotate(90deg);
}

.about-toggle[aria-expanded='true'],
.about-toggle:focus-visible,
.about-toggle.pressed {
  color: var(--accent);
}

@media (hover: hover) {
  .about-toggle:hover {
    color: var(--accent);
  }
}

.about-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.about {
  /* set from script to sit under the toggle, so the panel grows out of it */
  --origin: 50% 0;

  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 2.25rem;
  border-radius: inherit;
  background-color: color-mix(in srgb, var(--accent) 5%, var(--light));
  font-size: 0.95rem;
  line-height: 1.6;
  clip-path: circle(0 at var(--origin));
  transition: clip-path 450ms cubic-bezier(0.65, 0, 0.35, 1);
}

.about.open {
  /* the origin sits above the card, so overshoot to reach the far corners */
  clip-path: circle(200% at var(--origin));
}

.about > * {
  opacity: 0;
  transition: opacity 150ms ease;
}

.about.open > * {
  opacity: 1;
  transition: opacity 300ms ease 200ms;
}

.about-title {
  margin: 0 0 0.75rem;
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 2rem;
  font-weight: 400;
  line-height: 1.15;
  color: var(--accent);
}

.about p {
  margin: 0 0 0.75rem;
}

.about kbd {
  font-family: inherit;
  font-size: 0.8em;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  border: 1px solid color-mix(in srgb, var(--dark) 25%, transparent);
}

.about p a {
  color: var(--accent);
  text-underline-offset: 2px;
  white-space: nowrap;
}

.about-source {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: color-mix(in srgb, var(--dark) 60%, transparent);
  text-decoration: none;
}

.about-source i {
  font-size: 1.1rem;
}

.about-source .ph-arrow-up-right {
  margin-left: auto;
}

.about-source:focus-visible {
  color: var(--accent);
}

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

@media (hover: hover) {
  .about-source:hover {
    color: var(--accent);
  }
}

.fade {
  opacity: 0;
  animation: fade-in 450ms ease-out forwards;
  animation-delay: calc(var(--i) * var(--step));
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.keys {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.key {
  all: unset;
  box-sizing: border-box;
  width: 8.25rem;
  height: 5.5rem;
  padding: 0.7rem 0.75rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 10px;
  color: var(--light);
  background-color: color-mix(in srgb, var(--light) 7%, var(--dark));
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--light) 12%, transparent),
    0 3px 0 color-mix(in srgb, var(--light) 4%, var(--dark)),
    0 4px 10px color-mix(in srgb, var(--dark) 80%, transparent);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  transition:
    color 120ms ease,
    transform 80ms ease,
    box-shadow 80ms ease;
}

.key .top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.key i {
  font-size: 1.5rem;
}

.key kbd {
  font-family: inherit;
  font-size: 0.7rem;
  line-height: 1;
  padding: 0.2rem 0.3rem;
  border-radius: 4px;
  border: 1px solid color-mix(in srgb, currentColor 30%, transparent);
  opacity: 0.6;
}

.key .label {
  font-size: 0.8rem;
  letter-spacing: 0.01em;
}

.key:focus-visible,
.key.pressed {
  color: var(--accent);
}

@media (hover: hover) {
  .key:hover {
    color: var(--accent);
  }
}

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

.key:active,
.key.pressed {
  transform: translateY(3px);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--light) 8%, transparent),
    0 0 0 color-mix(in srgb, var(--light) 4%, var(--dark)),
    0 1px 4px color-mix(in srgb, var(--dark) 80%, transparent);
}

.key.busy {
  pointer-events: none;
}

@media (max-width: 420px) {
  .email {
    padding: 1.75rem 1.5rem 1.5rem;
  }

  .about {
    padding: 1.75rem 1.5rem;
  }

  .signature {
    font-size: 2.1rem;
  }

  .key {
    width: 7.5rem;
    height: 5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fade {
    animation: none;
    opacity: 1;
  }

  .container,
  .key,
  .about,
  .about > *,
  .about-toggle i {
    transition: none;
  }
}
