/* dev-card: one-page contact card. Grimoire dark palette, terminal look.
   Only the tokens below are used for colour; extra shades are these tokens with alpha.
   Pages must stay CSP-clean: no inline styles, everything lives here. */

:root {
  --bg: #131f24;
  --bg-subtle: #202f36;
  --bg-hover: #2a3b43;
  --border: #37464f;
  --border-strong: #52656f;
  --fg: #f1f7fb;
  --fg-body: #dce6ec;
  --fg-muted: #a3b4bf;
  --accent: #b48cff;
  --accent-deep: #8c62e0;
  --accent-fg: #1b1033;
  --spark: #ffc800;
  --green: #93d333;

  --font-head: "Nunito", ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius-lg: 20px;
  --radius: 14px;
  --pad: 20px; /* inner padding of the terminal window */

  color-scheme: dark;
}

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

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html:has(.qr[open]) {
  overflow: hidden; /* no page scroll behind the QR pop-up */
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding:
    max(20px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
  background-color: var(--bg);
  /* faint dotted grid, a --fg-body tint */
  background-image: radial-gradient(rgb(220 230 236 / 0.08) 1px, transparent 1.6px);
  background-size: 22px 22px;
  background-position: center top;
  color: var(--fg-body);
  font: 400 16px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- page + terminal window ---------- */

.page {
  width: 100%;
  max-width: 420px;
  margin-top: auto; /* with .foot's margin-bottom: auto, centres the card when there is room */
}

.term {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.term__bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: rgb(19 31 36 / 0.5);
}

.term__dots {
  display: flex;
  gap: 7px;
}

/* window buttons in the palette's own colours, a bit muted */
.term__dots i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.8;
}

.term__dots i:nth-child(2) {
  background: var(--spark);
}

.term__dots i:nth-child(3) {
  background: var(--green);
}

.term__title {
  font: 400 12px/1.2 var(--font-mono);
  color: var(--fg-muted);
  white-space: nowrap;
}

.term__body {
  padding: 18px var(--pad) var(--pad);
}

/* ---------- prompt lines ---------- */

.prompt {
  margin: 0;
  font: 400 13px/20px var(--font-mono);
  color: var(--fg-body);
}

.prompt__sign {
  color: var(--green);
  font-weight: 700;
}

.prompt__cmd--typed {
  display: inline-block;
  vertical-align: top;
  overflow: hidden;
  white-space: nowrap;
}

.caret {
  display: inline-block;
  width: 0.62em;
  height: 15px;
  margin-left: 3px;
  vertical-align: -2px;
  background: var(--fg-body);
  opacity: 0;
}

/* ---------- photo ---------- */

.avatar {
  position: relative;
  isolation: isolate;
  width: 176px;
  height: 176px;
  margin: 16px auto 16px;
  padding: 5px;
  border: 3px solid var(--accent);
  border-radius: 50%;
}

/* soft violet glow behind the photo */
.avatar::before {
  content: "";
  position: absolute;
  inset: -38px;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(
    closest-side,
    rgb(180 140 255 / 0.26),
    rgb(180 140 255 / 0.1) 62%,
    rgb(180 140 255 / 0)
  );
}

.avatar__img {
  display: block;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-hover);
}

.spark {
  position: absolute;
  fill: var(--spark);
}

.spark--big {
  top: 9px;
  right: 9px;
  width: 21px;
  height: 21px;
}

.spark--small {
  bottom: 22px;
  left: 14px;
  width: 9px;
  height: 9px;
}

/* ---------- name, role, tagline ---------- */

.name {
  margin: 0;
  font: 800 30px/1.15 var(--font-head);
  letter-spacing: -0.01em;
  color: var(--fg);
  text-align: center;
}

.role {
  margin: 6px 0 0;
  font: 500 16px/1.4 var(--font-body);
  color: var(--fg-body);
  text-align: center;
  text-wrap: balance;
}

.tagline {
  margin: 8px 0 0;
  font: 400 12px/1.5 var(--font-mono);
  color: var(--fg-muted);
  text-align: center;
  /* Two lines of similar length when it wraps; the items hold together with &nbsp;. */
  text-wrap: balance;
}

/* ---------- dino divider + mini-game ---------- */

.dino {
  margin: 22px calc(-1 * var(--pad)) 18px; /* full width of the window */
  border-block: 1px dashed var(--border);
  background: rgb(19 31 36 / 0.42);
}

.dino__strip {
  --ground: 30px; /* ground line, from the bottom of the strip; card.js reads it */
  position: relative;
  height: 140px;
  color: var(--fg-body);
  touch-action: manipulation; /* taps never zoom on iOS */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* card.js adds .has-game when the strip is a playable button */
.dino__strip.has-game {
  cursor: pointer;
}

.dino__strip:focus-visible {
  outline-offset: -3px; /* inside: the window clips anything outside the strip */
}

.dino__canvas {
  position: absolute;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
}

.dino__strip.is-live .dino__canvas {
  display: block;
}

/* static picture: no JS, or reduced motion until a tap; hidden while the canvas runs */
.dino__strip::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--ground);
  height: 1px;
  background: var(--border-strong);
}

.dino__rex,
.dino__cactus {
  position: absolute;
  bottom: var(--ground);
  display: block;
}

.dino__rex {
  left: 20px;
}

.dino__cactus {
  right: 22%;
  color: var(--green);
}

.dino__hint {
  position: absolute;
  top: 8px;
  right: 14px;
  display: none;
  font: 400 11px/1.2 var(--font-mono);
  color: var(--fg-muted);
}

.dino__strip.has-game:not(.is-live) .dino__hint {
  display: block;
}

.dino__strip.is-live::after,
.dino__strip.is-live .dino__rex,
.dino__strip.is-live .dino__cactus {
  display: none;
}

.dino__strip--static {
  --ground: 12px;
  height: 72px;
}

/* reduced motion: a compact still picture; it grows to full size only while a game runs */
@media (prefers-reduced-motion: reduce) {
  .dino__strip:not(.is-live):not(.dino__strip--static) {
    --ground: 14px;
    height: 96px;
  }
}

.dino__list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 12px var(--pad) 14px;
  list-style: none;
}

/* animated mode: the list is for screen readers only, the canvas shows the same words;
   with reduced motion the words are visible chips */
@media (prefers-reduced-motion: no-preference) {
  .dino__strip:not(.dino__strip--static) + .dino__list {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

.dino__list li {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-subtle);
  font: 400 12px/1.2 var(--font-mono);
  color: var(--fg-body);
}

/* ---------- buttons (Grimoire / Duolingo press feel) ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 48px;
  min-height: 48px;
  margin: 0;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-bottom: 4px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-hover);
  color: var(--fg);
  font: 800 16px/1.2 var(--font-head);
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease-out, filter 0.15s ease-out;
}

/* pressed: the face moves down onto its lower edge; the margin keeps the layout still */
.btn:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
  margin-bottom: 2px;
}

.btn--accent {
  border-color: var(--accent);
  border-bottom-color: var(--accent-deep);
  background: var(--accent);
  color: var(--accent-fg);
}

@media (hover: hover) {
  .btn:hover {
    filter: brightness(1.08);
  }
}

/* ---------- links ---------- */

.prompt--links {
  margin-top: 0;
}

.links {
  display: grid;
  gap: 12px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.links__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 10px;
}

.link {
  justify-content: flex-start;
  min-height: 64px;
  padding: 10px 14px 10px 16px;
  text-align: left;
}

.link__mark {
  flex: none;
  width: 26px;
  height: 26px;
}

.link__text {
  display: grid;
  flex: 1;
  gap: 3px;
  min-width: 0;
}

.link__label {
  font: 800 17px/1.15 var(--font-head);
}

.link__handle {
  overflow: hidden;
  font: 400 12px/1.3 var(--font-mono);
  color: var(--fg-muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.btn--accent .link__handle {
  color: var(--accent-fg);
}

.link__arrow {
  flex: none;
  width: 18px;
  height: 18px;
  opacity: 0.75;
}

.qr-btn {
  padding: 0;
}

.qr-btn__icon {
  width: 26px;
  height: 26px;
}

/* ---------- QR pop-up ---------- */

.qr {
  width: min(340px, calc(100vw - 24px));
  max-width: none;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
  color: var(--fg-body);
  overflow: auto;
  overscroll-behavior: contain;
}

.qr::backdrop {
  background: rgb(19 31 36 / 0.86); /* --bg with alpha; ::backdrop cannot read the tokens everywhere */
}

.qr__inner {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 16px 18px 18px;
  text-align: center;
}

.qr__cmd {
  justify-self: start;
  margin: 0;
  font: 400 12px/1.4 var(--font-mono);
  color: var(--fg-muted);
}

.qr__title {
  margin: -4px 0 0;
  font: 800 24px/1.2 var(--font-head);
  color: var(--fg);
}

/* the QR stays dark-on-white so every scanner reads it */
.qr__card {
  width: min(260px, 100%);
  padding: 8px;
  border-radius: 16px;
  background: #fff;
}

.qr__img {
  display: block;
  width: 100%;
  height: auto;
}

.qr__url {
  max-width: 100%;
  margin: 0;
  font: 400 12px/1.5 var(--font-mono);
  color: var(--fg-muted);
  overflow-wrap: anywhere;
}

.qr__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  margin-top: 4px;
}

.qr__close {
  grid-column: 1 / -1;
}

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

.foot {
  width: 100%;
  max-width: 420px;
  margin: 18px 0 auto;
  padding: 0 4px;
  font: 400 12px/1.7 var(--font-mono);
  color: var(--fg-muted);
  text-align: center;
}

.foot p {
  margin: 0;
}

.foot__cmd {
  color: var(--fg-body);
}

.foot__part {
  white-space: nowrap; /* on narrow phones the line breaks at the dot */
}

/* ---------- 404 ---------- */

.lost__title {
  margin: 14px 0 0;
  font: 800 28px/1.2 var(--font-head);
  color: var(--fg);
}

.lost__err {
  margin: 4px 0 0;
  font: 400 13px/20px var(--font-mono);
  color: var(--fg-muted);
  overflow-wrap: anywhere;
}

.lost .dino {
  margin-bottom: 20px;
}

.lost__back {
  width: 100%;
  min-height: 56px;
}

/* ---------- motion (all of it is optional) ---------- */

@media (prefers-reduced-motion: no-preference) {
  .prompt__cmd--typed {
    width: 6ch;
    animation: type 0.6s steps(6, end) 0.2s both;
  }

  .caret {
    animation: blink 1.1s step-end 0.8s 4;
  }

  .spark--big {
    animation: twinkle 3.2s ease-in-out infinite;
  }

  .spark--small {
    animation: twinkle 3.2s ease-in-out 1.6s infinite;
  }

  .qr[open] {
    animation: pop-in 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  .qr[open]::backdrop {
    animation: fade-in 0.2s ease-out;
  }
}

@keyframes type {
  from {
    width: 0;
  }
}

@keyframes blink {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

/* ---------- sizes ---------- */

@media (max-width: 359px) {
  :root {
    --pad: 16px;
  }

  .link {
    gap: 10px;
    padding-inline: 12px;
  }

  .link__arrow {
    display: none;
  }

  .links__row {
    grid-template-columns: minmax(0, 1fr) 56px;
  }
}

@media (min-width: 480px) {
  :root {
    --pad: 28px;
  }

  body {
    padding-top: max(40px, env(safe-area-inset-top));
    padding-bottom: max(32px, env(safe-area-inset-bottom));
  }

  .name {
    font-size: 34px;
  }
}
