:root {
  --bg: #05060b;
  --surface: #11121a;
  --card: #0f1018;
  --card-glass: rgba(9, 10, 18, 0.86);
  --ink: #f5f5f7;
  --muted: #a0a2ad;
  --line: rgba(255, 255, 255, 0.09);
  --hover: rgba(255, 255, 255, 0.06);
  --shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8);
  --sig-ink: rgba(245, 245, 246, 0.14);
  --gold: rgba(255, 200, 80, 0.85);
  --gold-haze: rgba(255, 200, 80, 0.3);
  --glint: #fffbea;
  --scrim: rgba(5, 6, 11, 0.55);
  --font: "Montserrat", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}

button { font: inherit; color: inherit; }

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 48px);
}

/* ---------- First screen: name, education, and the signature behind both ---------- */

.screen {
  position: relative;
  z-index: 1;
  isolation: isolate;
  overflow-x: clip;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}
.screen > main { position: relative; z-index: 1; }

/* ---------- Hero ---------- */

.hero {
  position: relative;
  z-index: 1;
  height: clamp(300px, 50svh, 640px);
  display: grid;
  place-items: center;
  padding: 2rem clamp(20px, 5vw, 48px);
  isolation: isolate;
}

.hero-content {
  position: relative;
  z-index: 1;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: enter 1s var(--ease) 0.1s both;
}

/* A soft wash in the page colour sits under the name so the strokes never fight the letters. */
.hero-content::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -6% -4%;
  background: radial-gradient(closest-side, var(--scrim) 45%, transparent);
  pointer-events: none;
}

.name {
  margin: 0;
  font-size: clamp(2.9rem, 7.2vw, 7rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.045em;
  text-wrap: balance;
  text-shadow: 0 0 22px var(--bg), 0 0 44px var(--bg);
}

.contact {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: clamp(1.5rem, 4vh, 2.5rem);
  padding: 1rem 1.5rem 1rem 1.8rem;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.contact svg { transition: transform 0.35s var(--ease); }
.contact:hover { transform: translateY(-2px); }
.contact:hover svg { transform: translateX(4px); }
.contact:focus-visible,
.foot-link:focus-visible,
.email:focus-visible,
.modal-close:focus-visible{ outline: 2px solid var(--ink); outline-offset: 4px; }

/* ---------- Signature ---------- */

.signature {
  position: absolute;
  z-index: 0;
  left: 50%;
  top: 50%;
  height: min(92%, 980px);
  width: auto;
  max-width: 118vw;
  aspect-ratio: 730 / 530;
  translate: -50% -50%;
  overflow: visible;
  pointer-events: none;
}

.sig-stroke {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1 1.05; /* the gap is longer than the path, so no cap dot shows before the pen arrives */
  stroke-dashoffset: 1.02;
}
.sig-ink { stroke: var(--sig-ink); }

/* Written in pen order: A, then L and E in one stroke, a lift, then the heart. */
.ink-a { animation: write 1.6s cubic-bezier(0.55, 0.05, 0.45, 1) 0.4s forwards; }
.ink-le { animation: write 1.7s cubic-bezier(0.3, 0, 0.5, 1) 2s forwards; }
.ink-heart { animation: write 1.3s cubic-bezier(0.4, 0, 0.4, 1) 3.95s forwards; }

/* Then light runs back through every stroke in the same order and leaves it gold. */
.sig-gilt { stroke: url(#sig-gold); }
.gilt-a { animation: write 0.75s cubic-bezier(0.45, 0, 0.3, 1) 5.45s forwards; }
.gilt-le { animation: write 0.75s cubic-bezier(0.45, 0, 0.3, 1) 6.15s forwards; }
.gilt-heart { animation: write 0.55s cubic-bezier(0.45, 0, 0.3, 1) 6.85s forwards; }
.sig-lit { filter: drop-shadow(0 0 5px var(--gold-haze)); }
.is-lit .sig-lit { animation: bloom 2.4s ease-out forwards; }

/* the bright head of the light */
.sig-spark {
  fill: none;
  stroke: var(--glint);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 0.04 1.1;
  stroke-dashoffset: 0.04;
  opacity: 0;
  filter: drop-shadow(0 0 4px var(--gold)) drop-shadow(0 0 12px var(--gold));
}
.spark-a { animation: spark 0.75s cubic-bezier(0.45, 0, 0.3, 1) 5.45s; }
.spark-le { animation: spark 0.75s cubic-bezier(0.45, 0, 0.3, 1) 6.15s; }
.spark-heart { animation: spark 0.55s cubic-bezier(0.45, 0, 0.3, 1) 6.85s; }

@keyframes write { to { stroke-dashoffset: 0; } }
@keyframes spark {
  0% { stroke-dashoffset: 0.04; opacity: 1; }
  90% { opacity: 1; }
  100% { stroke-dashoffset: -0.96; opacity: 0; }
}
@keyframes bloom {
  0% { filter: drop-shadow(0 0 5px var(--gold-haze)); }
  30% { filter: drop-shadow(0 0 16px var(--gold)) drop-shadow(0 0 4px var(--gold)); }
  100% { filter: drop-shadow(0 0 7px var(--gold-haze)); }
}

/* ---------- Stars and cursor (shown once the signature is lit) ---------- */

/* The Milky Way photo (ESO/S. Brunier), slightly oversized so it can drift with the mouse. */
.sky {
  position: fixed;
  inset: -24px;
  z-index: 0;
  background: #030308 url("/sky/milky-way-2560.jpg") center / cover no-repeat;
  opacity: 0;
  scale: 1.06;
  transition: opacity 2.6s ease, scale 6s var(--ease), translate 1.2s var(--ease);
  pointer-events: none;
}
.sky::after {
  /* keeps the middle calm so the name and cards read cleanly */
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 45% at 50% 42%, rgba(3, 3, 8, 0.45), transparent 70%),
    linear-gradient(180deg, rgba(3, 3, 8, 0.25), rgba(3, 3, 8, 0) 30%, rgba(3, 3, 8, 0.35));
}
.is-lit .sky { opacity: 1; scale: 1; }
@media (min-width: 1700px), (min-width: 1200px) and (min-resolution: 1.5dppx) {
  .sky { background-image: url("/sky/milky-way-3840.jpg"); }
}
@media (max-width: 900px) {
  .sky { background-image: url("/sky/milky-way-1600.jpg"); }
}

.starfield,
.cursor-trail {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.starfield { z-index: 0; opacity: 0; transition: opacity 2.6s ease; }
.is-lit .starfield { opacity: 1; }
.cursor-trail { z-index: 1000; }

/* Cursor: a bright point exactly at the pointer and a fine ring that follows it. */
.cursor-dot,
.cursor-ring {
  position: fixed;
  z-index: 1001;
  left: 0;
  top: 0;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.cursor-dot {
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  background: #fffaf0;
  box-shadow: 0 0 6px 1px rgba(255, 236, 190, 0.95), 0 0 18px 4px rgba(255, 196, 90, 0.45);
}
.cursor-ring {
  width: 38px;
  height: 38px;
  margin: -19px 0 0 -19px;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 16px -4px rgba(255, 210, 120, 0.5), inset 0 0 12px -6px rgba(255, 210, 120, 0.5);
  transition: opacity 0.3s ease, width 0.35s var(--ease), height 0.35s var(--ease), margin 0.35s var(--ease),
    border-color 0.35s, background-color 0.35s;
}
.has-cursor .cursor-dot.is-visible,
.has-cursor .cursor-ring.is-visible { opacity: 1; }
.cursor-ring.is-hovering {
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  border-color: rgba(255, 205, 110, 0.9);
  background-color: rgba(255, 205, 110, 0.08);
}
.cursor-ring.is-pressed { width: 30px; height: 30px; margin: -15px 0 0 -15px; }
.has-cursor,
.has-cursor * { cursor: none !important; }


/* ---------- Education ---------- */

.education { padding: 0 0 clamp(3rem, 8vh, 5rem); }

.section-head { margin-bottom: 1rem; }

.section-kicker {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin: 0;
  font-size: clamp(1.15rem, 1.6vw, 1.45rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.9);
}
.section-title::after {
  /* a short gold rule after the heading */
  content: "";
  width: 56px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, #f2c04a, rgba(242, 192, 74, 0));
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1rem, 1.6vw, 1.5rem);
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0.75rem 1.4rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0) 40%),
    var(--card-glass);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: 0 28px 70px -24px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: transform 0.5s var(--ease), box-shadow 0.5s var(--ease), border-color 0.5s;
}
.card::after {
  /* a thread of the university's colour along the bottom edge */
  content: "";
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  opacity: 0.8;
}
.card:hover {
  transform: translateY(-5px);
  border-color: var(--brand-soft);
  box-shadow: 0 30px 70px -28px var(--brand-soft), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Each logo sits on a plate in its university's own colours. */
.plate {
  --plate-h: clamp(96px, 12vh, 124px);
  display: grid;
  place-items: center;
  height: var(--plate-h);
  padding: 0 1.5rem;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.plate img { display: block; width: auto; max-width: 100%; }
.plate-ul { background: #ffffff; }
.plate-ul img { height: calc(var(--plate-h) * 0.6); }
.plate-ed { background: linear-gradient(135deg, #0a2a5c, #041e42); }
.plate-ed img { width: min(88%, 260px); height: auto; filter: brightness(0) invert(1); }
.plate-ucc { background: linear-gradient(135deg, #ffc21f, #ffb000); }
.plate-ucc img { height: calc(var(--plate-h) * 0.66); filter: brightness(0); }

.card-body { padding: 1.25rem 0.75rem 0; }

.card-kicker {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  min-height: 24px;
  margin: 0 0 0.55rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #c3c6d3;
}
.card-kicker .dot {
  width: 7px;
  height: 7px;
  margin-right: 0.55rem;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 10px var(--brand);
}
.sep {
  display: inline-block;
  width: 3px;
  height: 3px;
  margin: 0 0.5rem;
  border-radius: 50%;
  background: currentColor;
}

.card-title {
  margin: 0;
  color: #fff;
  font-size: clamp(1.1rem, 1.45vw, 1.32rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.card-school {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  margin: 0.45rem 0 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: #d6d8e2;
}

.card-dates {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  color: #aeb1bf;
}

.card-kicker .badge { margin-left: auto; letter-spacing: 0.02em; text-transform: none; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.24rem 0.65rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffe3a1, #f2b73a);
  color: #2a1c02;
  font-size: 0.7rem;
  font-weight: 700;
  box-shadow: 0 0 18px -4px rgba(255, 190, 60, 0.7);
}

.js .reveal {
  opacity: 0;
  translate: 0 24px;
  transition: opacity 0.9s var(--ease), translate 0.9s var(--ease);
}
.js .reveal.is-in { opacity: 1; translate: 0 0; }
.cards .reveal:nth-child(2) { transition-delay: 0.08s; }
.cards .reveal:nth-child(3) { transition-delay: 0.16s; }

/* ---------- Footer ---------- */

.foot {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--line);
  background: rgba(3, 3, 8, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.foot-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: space-between;
  align-items: center;
  padding-top: 1.75rem;
  padding-bottom: 1.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.credit { font-size: 0.75rem; opacity: 0.75; }
.credit a { color: inherit; }

.foot-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}
.foot-link:hover { text-decoration: underline; text-underline-offset: 4px; }

/* ---------- Dialog ---------- */

.modal {
  width: min(460px, calc(100vw - 32px));
  padding: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.35);
}
.modal::backdrop {
  background: rgba(10, 10, 12, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal[open] { animation: enter 0.4s var(--ease); }

.modal-close {
  position: absolute;
  top: 1.1rem;
  right: 1.1rem;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.modal-close:hover { background: var(--hover); color: var(--ink); }

.modal-kicker {
  margin: 0 0 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.modal-title {
  margin: 0 0 0.6rem;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.modal-text {
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.turnstile { min-height: 65px; }

.modal-status {
  min-height: 1.4em;
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.modal-status.is-error { color: #d93636; }

.email {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 1.1rem 1.1rem 1.1rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s;
}
.email:hover { border-color: var(--muted); }

.email-address {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.email-action {
  flex: none;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.8rem;
  font-weight: 600;
  transition: background 0.25s;
}
.email.is-copied .email-action { background: #1f9d55; color: #fff; }

.mail-link {
  display: inline-block;
  margin-top: 1.1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 4px;
}
.mail-link:hover { color: var(--ink); }

@keyframes enter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes nudge {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
  .cards { grid-template-columns: 1fr; gap: 0.8rem; }
  .card { flex-direction: row; align-items: center; gap: 1rem; padding: 0.6rem 1rem 0.6rem 0.6rem; border-radius: 22px; }
  .card::after { left: 18px; right: 18px; }
  .plate { --plate-h: 92px; flex: 0 0 172px; padding: 0 1rem; border-radius: 16px; }
  .card-body { padding: 0; }
}

@media (max-width: 640px) {
  .hero { height: clamp(300px, 46svh, 440px); padding: 1.5rem 16px; }
  .name { font-size: 13.5vw; }
  .signature { top: 34%; height: auto; width: 112vw; max-width: none; }
  .sig-stroke { stroke-width: 6; }
  .card { gap: 0.85rem; padding: 0.5rem 0.8rem 0.5rem 0.5rem; border-radius: 18px; }
  .plate { --plate-h: 76px; flex-basis: 128px; padding: 0 0.5rem; border-radius: 13px; }
  .plate-ed img { width: 100%; }
  .card-kicker { min-height: 18px; font-size: 0.6rem; letter-spacing: 0.08em; margin-bottom: 0.3rem; }
  .card-kicker .dot { width: 5px; height: 5px; margin-right: 0.4rem; }
  .card-title { font-size: 0.95rem; }
  .card-school { font-size: 0.8rem; margin-top: 0.2rem; }
  .badge { font-size: 0.6rem; padding: 0.16rem 0.45rem; }
  .card-dates { font-size: 0.74rem; margin-top: 0.1rem; }
  .modal { padding: 2rem 1.5rem 1.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .sig-stroke { stroke-dashoffset: 0; }
  .sig-ink { opacity: 0; }
  .js .reveal { opacity: 1; translate: 0 0; }
}
