/* Split landing page: two identities side by side on a sliding track. */

.identity {
  --math-bg: #f7f2e8;
  --math-ink: #2a2733;
  --math-muted: #6b6475;
  --math-accent: #9b2f3f;
  --math-on-accent: #fff;
  --math-rule: rgba(42, 39, 51, 0.14);

  --dev-bg: #0e1621;
  --dev-ink: #dbe3ec;
  --dev-muted: #8a99ab;
  --dev-accent: #3ddc97;
  --dev-on-accent: #0e1621;
  --dev-rule: rgba(219, 227, 236, 0.16);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.65, 0, 0.35, 1);
  --duration: 0.7s;

  /* Colors of whichever side is active, used by the shared header. */
  --a-ink: var(--math-ink);
  --a-muted: var(--math-muted);
  --a-accent: var(--math-accent);
  --a-on-accent: var(--math-on-accent);
  --a-rule: var(--math-rule);

  position: relative;
  overflow: hidden;
}

:root[data-identity="dev"] .identity {
  --a-ink: var(--dev-ink);
  --a-muted: var(--dev-muted);
  --a-accent: var(--dev-accent);
  --a-on-accent: var(--dev-on-accent);
  --a-rule: var(--dev-rule);
}

/* ---- Header: name + switch ------------------------------------------- */

.identity__header {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  padding: 2rem 1rem 0;
  pointer-events: none;
}

.identity__header > * {
  pointer-events: auto;
}

.identity__name {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--a-muted);
  transition: color var(--duration) var(--ease);
}

.identity__switch {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border: 1px solid var(--a-rule);
  border-radius: 999px;
  background: var(--a-rule);
  transition: border-color var(--duration) var(--ease), background-color var(--duration) var(--ease);
}

.identity__switch::before {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  border-radius: 999px;
  background: var(--a-accent);
  transform: translateX(calc(var(--identity-index, 0) * 100%));
  transition: transform var(--duration) var(--ease), background-color var(--duration) var(--ease);
}

.identity__switch button {
  position: relative;
  min-width: 9.5rem;
  margin: 0;
  padding: 0.55rem 1.1rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--a-muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--duration) var(--ease);
}

.identity__switch button:hover {
  color: var(--a-ink);
}

.identity__switch button[aria-selected="true"] {
  color: var(--a-on-accent);
}

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

.identity__switch-icon {
  display: inline-block;
  min-width: 1.4em;
  font-family: var(--mono);
}

/* ---- Track and panels ------------------------------------------------- */

.identity__track {
  display: flex;
}

/* Both panels share one grid cell. The incoming panel slides in over the
   outgoing one, which stays put until it is covered and only then moves
   off-screen (delayed, zero-length transition). */
.identity-js .identity__track {
  display: grid;
}

.identity-js .identity__panel {
  grid-area: 1 / 1;
  z-index: 1;
  visibility: hidden;
  transition: transform 0s linear var(--duration), visibility 0s linear var(--duration);
}

.identity-js .identity__panel--math {
  transform: translateX(-100%);
}

.identity-js .identity__panel--dev {
  transform: translateX(100%);
}

:root[data-identity="math"] .identity__panel--math,
:root[data-identity="dev"] .identity__panel--dev {
  z-index: 2;
  visibility: visible;
  transform: none;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.35);
  transition: transform var(--duration) var(--ease), visibility 0s;
}

/* Without JavaScript the panels simply stack and the switch is hidden. */
:root:not(.identity-js) .identity__track {
  flex-direction: column;
}

:root:not(.identity-js) .identity__switch,
:root:not(.identity-js) .identity__peek {
  display: none;
}

.identity__panel {
  position: relative;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  min-height: max(36rem, calc(100vh - 4rem));
  padding: 10rem clamp(1.25rem, 7vw, 7rem) 5rem;
  overflow: hidden;
}

.identity__body {
  position: relative;
  z-index: 1;
  max-width: 34rem;
}

.identity__heading {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2vw, 1.75rem);
  margin: 0 0 0.6rem;
}

.identity__portrait {
  flex: none;
  display: block;
  width: clamp(4.5rem, 7vw, 6rem);
  height: auto;
  aspect-ratio: 1;
  border-radius: 50%;
  object-fit: cover;
}

.identity__title {
  margin: 0;
  padding: 0;
  border: 0;
  line-height: 1.05;
}

.identity__tagline {
  margin: 0 0 1.2rem;
  font-size: 1.2rem;
}

.identity__blurb p {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  line-height: 1.45;
}

.identity__blurb > :last-child {
  margin-bottom: 1.5rem;
}

/* Lists in a blurb (Markdown "- item"): no bullets, a side-specific marker instead. */
.identity__blurb ul {
  margin: 0 0 0.35rem;
  padding: 0;
  list-style: none;
}

.identity__blurb li {
  position: relative;
  margin: 0 0 0.1rem;
  padding-left: 1.4em;
  font-size: 1rem;
  line-height: 1.45;
}

.identity__blurb li::before {
  position: absolute;
  left: 0.2em;
}

.identity__tags,
.identity__links {
  display: flex;
  flex-wrap: wrap;
  margin: 0 0 1.75rem;
  padding: 0;
  list-style: none;
}

.identity__tags li,
.identity__links li {
  margin: 0;
}

.identity__links {
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-bottom: 0;
}

.identity__link {
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
}

.identity__link:not(.identity__link--primary)::after {
  content: " \2192";
}

.identity__link--primary {
  display: inline-block;
  padding: 0.7rem 1.4rem;
  border-radius: 0.4rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.identity__link--primary:hover {
  transform: translateY(-1px);
}

.identity__deco {
  position: absolute;
  pointer-events: none;
}

/* ---- Peek tab: the edge of the other side, click to slide over --------- */

.identity__peek {
  position: absolute;
  z-index: 2;
  top: 50%;
  margin: 0;
  padding: 1.4rem 0.65rem;
  border: 0;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  writing-mode: vertical-rl;
  cursor: pointer;
  transition: padding 0.25s ease;
}

.identity__peek:hover {
  padding-left: 1rem;
  padding-right: 1rem;
}

.identity__peek span {
  display: inline-block;
  margin-bottom: 0.6em;
  font-family: var(--mono);
  letter-spacing: 0;
  text-transform: none;
}

/* ---- Mathematician ---------------------------------------------------- */

.identity__panel--math {
  background:
    radial-gradient(ellipse at 20% 30%, rgba(255, 255, 255, 0.7), transparent 60%),
    var(--math-bg);
  color: var(--math-ink);
  font-family: var(--serif);
}

.identity__panel--math .identity__title {
  font-family: var(--serif);
  font-size: clamp(2.6rem, 6vw, 4.6rem);
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--math-ink);
}

.identity__panel--math .identity__tagline {
  font-style: italic;
  color: var(--math-muted);
}

.identity__panel--math .identity__tags li {
  font-style: italic;
  color: var(--math-muted);
}

.identity__panel--math .identity__tags li + li::before {
  content: "\00b7";
  margin: 0 0.6em;
  font-style: normal;
}

.identity__panel--math .identity__blurb li::before {
  content: "\2013";
  color: var(--math-accent);
}

.identity__panel--math .identity__link {
  color: var(--math-accent);
}

.identity__panel--math .identity__link--primary {
  background: var(--math-accent);
  color: var(--math-on-accent);
  box-shadow: 0 6px 18px -8px rgba(155, 47, 63, 0.6);
}

.identity__panel--math .identity__portrait {
  border: 2px solid var(--math-bg);
  box-shadow: 0 0 0 2px var(--math-accent), 0 12px 30px -14px rgba(42, 39, 51, 0.6);
}

/* Spans the full panel width, anchored to the bottom; the panel clips any overflow at the top. */
.identity__deco--image {
  left: 0;
  bottom: 0;
  width: 100%;
  height: auto;
  opacity: 0.22;
}

.identity__panel--math .identity__peek {
  right: 0;
  transform: translateY(-50%);
  border-radius: 0.5rem 0 0 0.5rem;
  background: var(--dev-bg);
  color: var(--dev-accent);
}

/* ---- Developer -------------------------------------------------------- */

.identity__panel--dev {
  background:
    radial-gradient(circle, rgba(219, 227, 236, 0.07) 1px, transparent 1.5px) 0 0 / 22px 22px,
    var(--dev-bg);
  color: var(--dev-ink);
}

.identity__panel--dev .identity__title {
  font-family: var(--mono);
  font-size: clamp(2.1rem, 5vw, 3.8rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--dev-ink);
}

.identity__panel--dev .identity__title::before {
  content: "> ";
  color: var(--dev-accent);
}

.identity__panel--dev .identity__portrait {
  border: 2px solid var(--dev-bg);
  box-shadow: 0 0 0 2px var(--dev-accent), 0 12px 30px -12px rgba(0, 0, 0, 0.8);
}

.identity__panel--dev .identity__tagline {
  color: var(--dev-muted);
}

.identity__panel--dev .identity__tags {
  gap: 0.5rem;
}

.identity__panel--dev .identity__tags li {
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--dev-rule);
  border-radius: 0.3rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--dev-ink);
}

/* The developer blurb is longer: a little smaller, with more air between lines and paragraphs. */
.identity__panel--dev .identity__blurb p,
.identity__panel--dev .identity__blurb li {
  font-size: 0.92rem;
  line-height: 1.55;
}

.identity__panel--dev .identity__blurb p {
  margin-bottom: 0.8rem;
}

/* `Technology` names in the blurb: terminal font and accent colour, no code box. */
.identity__panel--dev .identity__blurb code {
  padding: 0;
  background: none;
  font-family: var(--mono);
  font-size: 0.95em;
  color: var(--dev-accent);
}

.identity__panel--dev .identity__blurb li::before {
  content: "\203A";
  font-family: var(--mono);
  font-weight: 600;
  color: var(--dev-accent);
}

.identity__panel--dev .identity__link {
  color: var(--dev-accent);
}

/* Links inside the blurb text: keep the text colour, underline in the accent colour. */
.identity__blurb a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.identity__panel--math .identity__blurb a {
  text-decoration-color: var(--math-accent);
}

.identity__panel--dev .identity__blurb a {
  text-decoration-color: var(--dev-accent);
}

.identity__blurb a:hover {
  text-decoration-thickness: 2px;
}

.identity__panel--dev .identity__link--primary {
  background: var(--dev-accent);
  color: var(--dev-on-accent);
  box-shadow: 0 6px 22px -8px rgba(61, 220, 151, 0.55);
}

.identity__deco--terminal {
  right: 6vw;
  top: 50%;
  width: min(32vw, 26rem);
  transform: translateY(-35%);
  border: 1px solid var(--dev-rule);
  border-radius: 0.6rem;
  background: rgba(6, 11, 17, 0.75);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}

.identity__terminal-bar {
  display: flex;
  gap: 6px;
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid var(--dev-rule);
}

.identity__terminal-bar span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dev-rule);
}

.identity__deco--terminal pre {
  margin: 0;
  padding: 1rem 1.1rem 1.2rem;
  border: 0;
  background: none;
  color: var(--dev-ink);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.7;
  white-space: pre-wrap;
}

.identity__prompt {
  color: var(--dev-accent);
}

.identity__output {
  color: var(--dev-muted);
}

.identity__reply {
  color: var(--dev-ink);
}

.identity__cursor {
  display: inline-block;
  width: 0.55em;
  height: 1.1em;
  vertical-align: text-bottom;
  background: var(--dev-accent);
  animation: identity-blink 1.1s steps(1) infinite;
}

@keyframes identity-blink {
  50% { opacity: 0; }
}

.identity__panel--dev .identity__peek {
  left: 0;
  transform: translateY(-50%) rotate(180deg);
  border-radius: 0.5rem 0 0 0.5rem;
  background: var(--math-bg);
  color: var(--math-accent);
  font-family: var(--serif);
}

/* ---- Smaller screens -------------------------------------------------- */

@media (max-width: 64em) {
  .identity__deco--terminal {
    display: none;
  }

  .identity__deco--image {
    opacity: 0.12;
  }
}

@media (max-width: 37.5em) {
  .identity__panel {
    align-items: flex-start;
    padding-top: 9rem;
  }

  .identity__portrait {
    width: 4rem;
  }

  .identity__panel--math .identity__title {
    font-size: 7.5vw;
  }

  .identity__switch button {
    min-width: 0;
    padding: 0.55rem 0.9rem;
  }

  .identity__peek {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .identity {
    --duration: 0s;
  }

  .identity__cursor {
    animation: none;
  }
}
