/* MJ Nodes Lab, landing page.
   Colours come from the brand kit (03 Colour/MJNL_Colours.css). */
:root {
  --spruce: #05493C;
  --deep-spruce: #003226;
  --night-spruce: #03241D;
  --lagoon: #1B5957;
  --eucalyptus: #ABC9BD;
  --mist: #E9F2EB;
  --cream: #F9F6EE;
  --terracotta: #D98159;

  --font-display: "Helvetica Now Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-text: "Helvetica Now Text", "Helvetica Neue", Helvetica, Arial, sans-serif;

  --gutter: clamp(20px, 4.5vw, 72px);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --start: 1.9s; /* when the headline starts, after the logo has landed */

  color-scheme: dark;
}

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

html { height: 100%; background: var(--night-spruce); }

body {
  margin: 0;
  min-height: 100%;
  color: var(--cream);
  font-family: var(--font-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  /* The brand field: three steps of spruce from the top right corner to the
     bottom left, with a faint bloom of light on top. */
  background:
    radial-gradient(110% 85% at 100% 0%, rgba(233, 242, 235, 0.10), rgba(233, 242, 235, 0) 60%),
    linear-gradient(225deg, var(--lagoon) 0%, var(--spruce) 42%, var(--deep-spruce) 100%) fixed,
    var(--night-spruce);
}

/* ---------- Ground layers ---------- */
.terraces {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Layout ---------- */
.stage {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding-block: var(--gutter) max(var(--gutter), env(safe-area-inset-bottom, 0px));
  padding-inline: max(var(--gutter), env(safe-area-inset-left, 0px)) max(var(--gutter), env(safe-area-inset-right, 0px));
}

.logo-area {
  display: grid;
  place-items: center;
  min-height: 0;
}

/* ---------- Links ---------- */
.links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem clamp(1.25rem, 2.5vw, 2.5rem);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(0.72rem, 0.85vw, 0.85rem);
  letter-spacing: 0.055em;
  text-transform: uppercase;
  animation: fade-in 0.9s ease calc(var(--start) + 0.9s) both;
}

.links a {
  position: relative;
  color: var(--cream);
  text-decoration: none;
  padding-block: 0.5em;
  opacity: 0.82;
  transition: opacity 0.25s ease;
}

.links a::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 0.2em;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s var(--ease-out);
}

.links a:hover,
.links a:focus-visible { opacity: 1; }
.links a:hover::after,
.links a:focus-visible::after { transform: scaleX(1); }

.links a:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 4px;
}

/* ---------- Logo ---------- */
.logo {
  display: block;
  width: min(78vw, 52vh, 560px);
  height: auto;
  overflow: visible;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  /* Without JavaScript the logo simply fades in. JavaScript replaces this
     with the assembly animation. */
  animation: fade-in 0.8s ease 0.3s both;
}

.logo path { fill: var(--cream); }

.logo-pieces { display: none; }

.logo.is-assembling { animation: none; }
.logo.is-assembling .logo-full { opacity: 0; }
.logo.is-assembling .logo-pieces { display: inline; }

.piece {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  will-change: transform, opacity;
}

/* ---------- Headline ---------- */
.copy {
  max-width: 100%;
  padding-top: clamp(16px, 3vh, 40px);
}

.headline {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.6rem, 8.2vw, 8.5rem);
  line-height: 0.92;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.word {
  display: inline-block;
  overflow: hidden;
  padding-block: 0.06em 0.04em;
  margin-block: -0.06em -0.04em;
  vertical-align: bottom;
}

/* Each word rises once out of its own line: one clean, even move. */
.word .in {
  display: inline-block;
  animation: rise 1.1s var(--ease-out) both;
  animation-delay: var(--start);
}
.w2 .in { animation-delay: calc(var(--start) + 0.12s); }

@keyframes rise {
  from { transform: translateY(105%); }
  to { transform: translateY(0); }
}

/* The terracotta square: appears once the words are in, then breathes
   slowly while the site is being built. */
.dot {
  display: inline-block;
  width: 0.2em;
  height: 0.2em;
  margin-inline-start: 0.08em;
  background: var(--terracotta);
  vertical-align: baseline;
  animation:
    fade-in 0.6s ease calc(var(--start) + 0.9s) both,
    breathe 2.8s ease-in-out calc(var(--start) + 1.5s) infinite;
}

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

.deck {
  margin: clamp(12px, 2vh, 22px) 0 0;
  font-family: var(--font-text);
  font-weight: 500;
  font-size: clamp(1rem, 1.35vw, 1.3rem);
  line-height: 1.38;
  color: rgba(233, 242, 235, 0.78);
  animation: fade-up 0.9s ease calc(var(--start) + 0.7s) both;
}

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

@keyframes fade-up {
  from { opacity: 0; transform: translateY(0.6em); }
  to { opacity: 1; transform: translateY(0); }
}

/* Short, wide screens (phones turned sideways): keep both parts visible. */
@media (max-height: 520px) and (orientation: landscape) {
  .stage { grid-template-columns: 1fr 1fr; grid-template-rows: auto 1fr; align-items: center; column-gap: var(--gutter); }
  .links { grid-column: 1 / -1; }
  .logo-area { grid-row: 2; }
  .copy { grid-row: 2; }
  .logo { width: min(42vw, 78vh); }
  .copy { padding-top: 0; }
  .headline { font-size: clamp(2.2rem, 6vw, 4rem); }
}

@media (prefers-reduced-motion: reduce) {
  .logo,
  .word .in,
  .dot,
  .links,
  .deck,
  .grain { animation: none !important; }
}
