/* ---------- tokens ---------- */
:root {
  --blue: #004494;            /* Erasmus / EU Reflex Blue */
  --blue-deep: #002A66;
  --ink: #00163D;
  --paper: #F4F1E8;
  --paper-dim: rgba(244, 241, 232, .78);
  --gold: #FFCC00;            /* EU gold: blue + gold reads Erasmus without copying the flag */
  --gutter: 16px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-io: cubic-bezier(.7, 0, .2, 1);
  --display: "Bricolage Grotesque", "Arial Narrow", sans-serif;
  --mono: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --mx: 0;
  --my: 0;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--blue); color-scheme: dark; scrollbar-gutter: stable; }
body {
  margin: 0;
  min-height: 100svh;
  background: var(--blue);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; }
::selection { background: var(--paper); color: var(--blue); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- print grain ---------- */
.grain {
  position: fixed; inset: -10%;
  z-index: 50; pointer-events: none;
  opacity: .16; mix-blend-mode: overlay;
  background-image: url("../assets/grain.svg");
  animation: grain 1s steps(6) 6;
}
@keyframes grain {
  0%   { transform: translate(0, 0); }
  17%  { transform: translate(-3%, 2%); }
  33%  { transform: translate(2%, -4%); }
  50%  { transform: translate(-4%, -1%); }
  67%  { transform: translate(3%, 3%); }
  83%  { transform: translate(-1%, 4%); }
  100% { transform: translate(0, 0); }
}

/* ---------- layout ---------- */
.page {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 14px var(--gutter);
  overflow-x: clip;   /* the globe bleeds off the right edge on purpose */
}
.top, .bottom {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  font-size: 12.5px;
}
.mark { display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--display);
  font-variation-settings: "wdth" 100, "opsz" 24;
  font-weight: 800; font-size: 22px; letter-spacing: -.03em; text-transform: lowercase;
  text-decoration: none;
}
.appicon { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--gold); outline: 1.5px solid var(--gold); outline-offset: 3px; margin: 0 4px 0 3px; }
.bottom { color: var(--paper-dim); padding-top: 14px; border-top: 1px solid rgba(244, 241, 232, .22); margin-top: 24px; }
.bottom a { text-underline-offset: 3px; }
/* Emberlabs stamp: the SVG silhouette painted in the footer text colour */
.ember-stamp { display: block; flex: none; align-self: center; width: 76px; height: 76px; margin: -24px 0; opacity: .8; transition: opacity .25s; }
.ember-stamp span { display: block; width: 100%; height: 100%; background: currentColor; -webkit-mask: url("/emberlabs-stamp.svg") center / contain no-repeat; mask: url("/emberlabs-stamp.svg") center / contain no-repeat; }
.ember-stamp:hover { opacity: 1; }
@media (max-width: 899px) { .ember-stamp { margin: 6px 0 0 auto; } }
.indep { font-size: 12.5px; max-width: 58ch; text-align: left; }

.stage {
  position: relative; isolation: isolate;
  display: flex; flex-direction: column; justify-content: flex-start;
  gap: 28px; padding-top: 24px; min-width: 0;
  /* one size drives headline and globe */
  --hs: var(--fit-w, 20vw);
}

/* ---------- globe ---------- */
.globe {
  position: absolute; z-index: 0; pointer-events: none;
  width: 118vw; height: 118vw; right: -32vw; top: 4px;
  opacity: 1;
}

/* ---------- hero ---------- */
.hero {
  position: relative; z-index: 1;
  margin: 0;
  display: flex; flex-direction: column;  /* flex: negative margins on .hello/.roll must add, not collapse */
  min-width: 0;
  font-family: var(--display);
  font-variation-settings: "wdth" 78, "opsz" 96;
  font-weight: 800;
  font-kerning: normal;
  font-size: var(--hs);
  line-height: .88;
  letter-spacing: .002em;
  /* two-ink misprint: gold plate and deep-blue plate, both slightly off register */
  text-shadow:
    calc(max(-.011em, -1.6px) + var(--mx) * -.018em) calc(var(--my) * .01em) 0 rgba(255, 204, 0, .9),
    calc(max(.012em, 1.6px) + var(--mx) * -.014em) calc(max(.008em, 1.1px) + var(--my) * -.01em) 0 rgba(0, 22, 61, .85);
}
.hello, .roll { padding-inline: .03em; margin-inline: -.03em; }
.hello { display: flex; white-space: nowrap; padding-bottom: .22em; margin-bottom: -.22em; padding-top: .1em; margin-top: -.1em; overflow: hidden; }
.roll { display: grid; overflow: hidden; padding-top: .26em; margin-top: -.2em; }
.js:not(.ready) .hello, .js:not(.ready) .roll { visibility: hidden; }
.js:not(.ready) .w.is-on .c { transform: translateY(150%); }
.js .w:not(.is-on):not(.is-out) { visibility: hidden; }
.js .w.is-on, .js .w.is-out { visibility: visible; }
.w { grid-area: 1 / 1; align-self: end; white-space: nowrap; display: flex; }
.c { display: inline-block; transform: translateY(150%); transition: transform .65s var(--ease-io); transition-delay: calc(var(--i) * 20ms); }
.w.is-on .c { transform: none; }
.w.is-out .c { transform: translateY(-150%); }
.w.is-out { clip-path: inset(.09em -.06em -.1em); }
.w.no-t .c { transition: none; }

/* ---------- lower band: what it is + form ---------- */
.lower { position: relative; z-index: 2; display: grid; gap: 28px; margin-top: 4px; }

.pitch {
  margin: 0; max-width: 20ch;
  font: 800 clamp(26px, 2.5vw, 38px)/1.02 var(--display); font-variation-settings: "wdth" 80, "opsz" 48; letter-spacing: .002em; text-wrap: balance;
}

/* ---------- form ---------- */
.join { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 18px 16px; align-content: start; }
.f { display: grid; gap: 4px; position: relative; min-width: 0; }
.f-email { grid-column: 1 / -1; }
.f > span, .f > label { font-size: 12.5px; letter-spacing: .01em; color: var(--paper-dim); }
.f input, .f select {
  appearance: none; -webkit-appearance: none;
  background: transparent; border: 0; border-bottom: 1px solid rgba(244, 241, 232, .55);
  border-radius: 0; color: var(--paper);
  font: 500 16px/1.2 var(--mono);
  padding: 8px 0 9px; width: 100%; outline: none; text-overflow: ellipsis;
}
.f select { background-image: linear-gradient(45deg, transparent 50%, var(--paper) 50%), linear-gradient(135deg, var(--paper) 50%, transparent 50%); background-position: calc(100% - 9px) 55%, calc(100% - 4px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 20px; }
.f select option { background: var(--blue-deep); color: var(--paper); }
/* city combobox */
.f-city { z-index: 3; }
.f-city ul {
  position: absolute; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px 0; list-style: none; z-index: 5;
  background: var(--blue-deep); border: 1px solid rgba(244, 241, 232, .45); max-height: 264px; overflow-y: auto;
  box-shadow: 4px 4px 0 rgba(0, 22, 61, .85);
}
.f-city ul[hidden] { display: none; }
.f-city li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; font: 500 15px/1.2 var(--mono); color: var(--paper); cursor: pointer; }
.f-city li span { color: var(--paper-dim); font-size: 12px; white-space: nowrap; align-self: center; }
.f-city li[aria-selected="true"], .f-city li:hover { background: var(--gold); color: #00163D; }
.f-city li[aria-selected="true"] span, .f-city li:hover span { color: #00163D; }
/* honeypot: off-screen, not display:none (some bots skip hidden fields) */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.f input::placeholder { color: rgba(244, 241, 232, .74); }
.f::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--gold);
  transform: scaleX(0); transform-origin: left; transition: transform .5s var(--ease-out);
}
.f:focus-within::after { transform: scaleX(1); }
.f input:-webkit-autofill { -webkit-text-fill-color: var(--paper); transition: background-color 9999s; }

.ok { grid-column: 1 / -1; display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; color: var(--paper-dim); cursor: pointer; }
.ok input { appearance: none; flex: none; width: 16px; height: 16px; margin: 1px 0 0; border: 1px solid var(--paper); display: grid; place-content: center; cursor: pointer; }
.ok input::after {
  content: ""; width: 14px; height: 14px; transform: scale(0) rotate(-12deg); transition: transform .3s var(--ease-out);
  background: url("../assets/tick.svg") center / contain no-repeat;
}
.ok input:checked::after { transform: scale(1) rotate(0); }
.ok input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--paper); outline-offset: 3px; }

button {
  grid-column: 1 / -1; position: relative; overflow: hidden; isolation: isolate;
  appearance: none; border: 1px solid var(--paper); border-radius: 0;
  background: var(--paper); color: var(--blue);
  font: 500 14px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase;
  padding: 17px 20px; cursor: pointer; text-align: left;
  display: flex; justify-content: space-between; align-items: center;
  transition: color .45s var(--ease-out), transform .2s var(--ease-out);
}
button::before {
  content: ""; position: absolute; inset: 0; z-index: -1; background: var(--gold);
  transform: translateY(101%); transition: transform .5s var(--ease-out);
}
button::after { content: "→"; transition: transform .45s var(--ease-out); }
@media (hover: hover) {
  button:hover { color: var(--ink); }
  button:hover::before { transform: none; }
  button:hover::after { transform: translateX(6px); }
}
button:active { transform: translateY(1px); }
button[aria-busy="true"] { opacity: .6; cursor: progress; }

.note { grid-column: 1 / -1; display: grid; min-height: 20px; }
.note > * { grid-area: 1 / 1; margin: 0; }
.proof { font-size: 12.5px; color: var(--paper-dim); }
.note:has(.msg:not(:empty)) .proof { visibility: hidden; }

/* ---------- success ---------- */
.msg { font-size: 13px; }
.msg:empty { display: none; }
.msg.err { color: #FFC2AE; }
.msg .big {
  display: block; font-family: var(--display); font-variation-settings: "wdth" 75, "opsz" 72; font-weight: 800;
  font-size: clamp(40px, 5.2vw, 76px); line-height: .92; letter-spacing: .004em; text-transform: uppercase; margin-bottom: 10px;
}
.msg .small { display: block; font-size: 14px; max-width: 46ch; overflow-wrap: anywhere; }
.msg:focus { outline: none; }
.nojs { position: relative; z-index: 2; margin: 0; font-size: 14px; }
html:not(.js) .globe { display: none; }
html:not(.js) .join { display: none; }
.ok:has([aria-invalid]) { color: #FFC2AE; }
.f:has([aria-invalid])::after { background: #FFC2AE; transform: scaleX(1); }
.stamp {
  max-width: 100%; overflow-wrap: anywhere;
  display: inline-block; margin-top: 22px; padding: 9px 16px; border: 3px solid var(--gold); color: var(--gold);
  font-size: 16px; letter-spacing: .1em; text-transform: uppercase; transform: rotate(-5deg);
  animation: stamp .55s var(--ease-out) both .25s; background: rgba(0, 22, 61, .35);
}
@keyframes stamp { from { opacity: 0; transform: rotate(-12deg) scale(1.8); } to { opacity: 1; transform: rotate(-5deg) scale(1); } }
.join.done > :not(.note) { display: none; }
.join.done .proof { display: none; }
.join.done { gap: 0; }

/* ---------- intro choreography (only when JS is on) ---------- */
.js .top, .js .bottom, .js .what, .js .join > * { opacity: 0; transform: translateY(14px); }
.js.ready .top, .js.ready .bottom, .js.ready .what, .js.ready .join > * {
  opacity: 1; transform: none;
  transition: opacity .9s var(--ease-out), transform 1.1s var(--ease-out);
  transition-delay: calc(.9s + var(--d, 0) * 110ms);
}
.js.ready .top { --d: -7; }
.js.ready .what { --d: 0; }
.js.ready .join > :nth-child(1) { --d: 1; }
.js.ready .join > :nth-child(2) { --d: 2; }
.js.ready .join > :nth-child(3) { --d: 3; }
.js.ready .join > :nth-child(4) { --d: 4; }
.js.ready .join > :nth-child(5) { --d: 5; }
.js.ready .join > :nth-child(6) { --d: 6; }
.js.ready .bottom { --d: 8; }
.js .hello .c { transform: translateY(150%); }
.js.ready .hello .c { transform: none; transition: transform 1s var(--ease-out); transition-delay: calc(.1s + var(--i) * 45ms); }
/* first city waits for the greeting to land */
.js:not(.settled) .w.is-on .c { transition-delay: calc(.75s + var(--i) * 30ms); }
.js .globe { opacity: 0; }
.js.ready .globe { opacity: 1; transition: opacity 1.6s var(--ease-out) .2s; }
html:not(.js) .w:not(.is-on) { display: none; }

/* ---------- wide screens ---------- */
@media (min-width: 900px) {
  :root { --gutter: 32px; }
  .page { padding-top: 22px; padding-bottom: 22px; height: 100svh; min-height: 640px; }
  .stage { justify-content: space-between; padding-top: 26px; gap: 24px; --hs: min(var(--fit-w, 20vw), calc((100svh - 420px) / 1.78)); }
  .globe { width: calc(var(--hs) * 2.05); height: calc(var(--hs) * 2.05); right: calc(var(--hs) * -.082); top: calc(26px - var(--hs) * .12); opacity: 1; }
  .js.ready .globe { opacity: 1; }
  .lower { grid-template-columns: minmax(300px, 1.15fr) 2fr; gap: 48px; align-items: end; margin-top: 0; }
  .join { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 28px; align-items: end; }
  .f-email { grid-column: 1; }
  .ok { grid-column: 1 / 3; align-self: center; }
  button { grid-column: 3; grid-row: 2; }
  .note { grid-column: 1 / 3; grid-row: 3; margin-top: -4px; }
  .join.done .note { grid-column: 1 / -1; grid-row: 1; margin-top: 0; }
  .bottom { margin-top: 18px; }
}
@media (max-width: 899px) {
  .stage { --hs: var(--fit-w, 21vw); }
  .hero { order: 1; }
  .globe { --gw: min(100vw, 520px); order: 2; position: relative; right: auto; top: auto; width: var(--gw); height: var(--gw);
    margin: calc(var(--gw) * -.06) calc(var(--gutter) * -1) calc(var(--gw) * -.34) auto; clip-path: inset(0 0 34% 0);
    -webkit-mask-image: linear-gradient(#000 48%, transparent 64%); mask-image: linear-gradient(#000 48%, transparent 64%); }
  .lower { order: 3; }
  .join { max-width: 560px; }
  .indep { order: 3; flex-basis: 100%; text-align: left; }
  .bottom { flex-wrap: wrap; }
}
@media (max-width: 899px) and (max-height: 700px) {
  button { padding: 14px 18px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .stage { --hs: min(var(--fit-w, 20vw), calc((100svh - 120px) / 1.78)); }
}

@media (min-width: 641px) and (max-width: 899px) {
  /* tablet: headline, then the sentence beside the globe, then the form across the full width */
  .stage { display: grid; grid-template-columns: 1fr 1fr; column-gap: 24px; row-gap: 0; }
  .hero { grid-column: 1 / -1; grid-row: 1; }
  .globe { --gw: 460px; grid-column: 1 / -1; grid-row: 2; justify-self: end; margin-right: calc(var(--gutter) * -1); }
  .lower { display: contents; }
  .what { grid-column: 1 / -1; grid-row: 2; align-self: center; justify-self: start; z-index: 2; }
  .join { grid-column: 1 / -1; grid-row: 3; max-width: none; margin-top: 32px; position: relative; z-index: 2; }
}

/* ---------- sticky CTA on phones: only while the form is out of view ---------- */
.cta-bar { display: none; }
@media (max-width: 640px) {
  .cta-bar {
    display: flex; justify-content: space-between; align-items: center;
    position: fixed; z-index: 60; left: 0; right: 0; bottom: 0;
    padding: 14px var(--gutter) calc(14px + env(safe-area-inset-bottom));
    background: var(--gold); color: var(--ink); text-decoration: none; border-top: 2px solid var(--ink);
    font: 500 14px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase;
    transform: translateY(110%); transition: transform .5s var(--ease-out);
  }
  .cta-bar.show { transform: none; }
  .cta-bar:not(.show) { visibility: hidden; transition: transform .5s var(--ease-out), visibility 0s .5s; }
  .cta-bar:focus-visible { outline: 2px solid var(--ink); outline-offset: -7px; }
  html:not(.ready) .cta-bar { opacity: 0; }
  .page { padding-bottom: calc(14px + 52px); }
  html { scroll-padding-bottom: 96px; }
  .note { min-height: 39px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .grain, .stamp { animation: none; }
  *, *::before, *::after { transition-duration: .01ms !important; transition-delay: 0s !important; }
  .js .top, .js .bottom, .js .what, .js .join > * { opacity: 1; transform: none; }
  .js .hello .c { transform: none; }
}
