:root {
  --bg: #07070a;
  --ink: #f4f3ef;
  --muted: rgba(244, 243, 239, 0.62);
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, sans-serif;
  /* pointer offset, set by main.js (-1..1) */
  --px: 0;
  --py: 0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }


body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  min-height: 100svh;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Light: three additive lamps ---------- */

.light {
  position: fixed;
  inset: -20vmax;
  /* No CSS blur here: a filter over moving children is re-drawn every frame, which is
     costly on large and Retina screens. The gradients below are soft enough on their own. */
  opacity: 0.3;
  transform: translate(calc(var(--px) * -2vmin), calc(var(--py) * -2vmin));
  transition: transform 1.2s cubic-bezier(.2, .7, .2, 1);
}

.lamp {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 62vmin;
  height: 62vmin;
  margin: -31vmin 0 0 -31vmin;
  border-radius: 50%;
  mix-blend-mode: screen;
  will-change: transform;
}
.lamp.r { background: radial-gradient(circle, #ff1e3c 0%, #ff1e3cb0 22%, #ff1e3c50 45%, #ff1e3c18 62%, #ff1e3c00 75%); animation: drift-r 23s ease-in-out infinite; }
.lamp.g { background: radial-gradient(circle, #19ff7a 0%, #19ff7ab0 22%, #19ff7a50 45%, #19ff7a18 62%, #19ff7a00 75%); animation: drift-g 29s ease-in-out infinite; }
.lamp.b { background: radial-gradient(circle, #2a5bff 0%, #2a5bffb0 22%, #2a5bff50 45%, #2a5bff18 62%, #2a5bff00 75%); animation: drift-b 19s ease-in-out infinite; }

@keyframes drift-r {
  0%, 100% { transform: translate(-28vmin, -12vmin) scale(1); }
  33%      { transform: translate(10vmin, -26vmin) scale(1.15); }
  66%      { transform: translate(-6vmin, 14vmin) scale(0.9); }
}
@keyframes drift-g {
  0%, 100% { transform: translate(26vmin, -8vmin) scale(0.95); }
  40%      { transform: translate(-14vmin, 20vmin) scale(1.2); }
  70%      { transform: translate(18vmin, 16vmin) scale(1); }
}
@keyframes drift-b {
  0%, 100% { transform: translate(2vmin, 24vmin) scale(1.1); }
  30%      { transform: translate(24vmin, 4vmin) scale(0.9); }
  65%      { transform: translate(-24vmin, -16vmin) scale(1.15); }
}

.grain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.09;
  mix-blend-mode: overlay;
  pointer-events: none;
}

/* ---------- Sand figures (sand.js) ---------- */

.sand {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- Layout ---------- */

main {
  position: relative;
  min-height: calc(100svh - 3.5rem); /* leave room for the footer */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 4vh, 2.5rem);
  padding: clamp(1rem, 4vw, 2rem);
  text-align: center;
}

.copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1.4rem, 4vh, 3rem);
  min-width: 0;
}

/* Empty box the sand figure is drawn over (the canvas itself covers the whole screen) */
.figure-slot {
  width: min(92vw, 50svh);
  aspect-ratio: 1;
  flex: none;
}

/* ---------- Logo: three channels out of register ---------- */

.logo {
  display: grid;
  isolation: isolate;
  font-weight: normal;
  line-height: 1;
  user-select: none;
}

.channel {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  mix-blend-mode: screen;
  will-change: transform;
}
.channel.r { color: #ff0000; animation: reg-r 11s ease-in-out infinite; }
.channel.g { color: #00ff00; animation: reg-g 13s ease-in-out infinite; }
.channel.b { color: #0000ff; animation: reg-b 9s ease-in-out infinite; }

/* Channels wander apart, then meet as white for a moment */
@keyframes reg-r {
  0%, 46%, 54%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-0.09em, 0.02em); }
  32% { transform: translate(0.04em, -0.05em); }
  75% { transform: translate(-0.05em, -0.03em); }
}
@keyframes reg-g {
  0%, 46%, 54%, 100% { transform: translate(0, 0); }
  20% { transform: translate(0.06em, 0.04em); }
  36% { transform: translate(-0.03em, 0.06em); }
  80% { transform: translate(0.07em, -0.02em); }
}
@keyframes reg-b {
  0%, 46%, 54%, 100% { transform: translate(0, 0); }
  12% { transform: translate(0.03em, -0.07em); }
  28% { transform: translate(-0.06em, -0.01em); }
  70% { transform: translate(0.02em, 0.05em); }
}

.creative {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 300;
  font-variation-settings: "opsz" 144;
  font-size: clamp(3rem, 19vw, 7rem);
  letter-spacing: -0.035em;
  line-height: 0.9;
  padding-right: 0.08em; /* keep the italic overhang inside the box */
}

.control {
  font-family: var(--sans);
  font-weight: 600;
  text-transform: uppercase;
  font-size: clamp(0.8rem, 5.3vw, 1.95rem);
  letter-spacing: 0.52em;
  margin-top: -0.35em;
  align-self: flex-end;
  margin-right: -0.52em; /* cancel trailing letter-spacing */
}

/* ---------- Text ---------- */

.mission {
  max-width: 44ch;
  text-wrap: balance;
  font-size: clamp(0.95rem, 1.6vw, 1.2rem);
  letter-spacing: 0.04em;
  color: var(--muted);
}

.contact {
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  color: var(--ink);
  text-decoration: none;
  padding: 0.7em 1.3em;
  border: 1px solid rgba(244, 243, 239, 0.25);
  border-radius: 999px;
  backdrop-filter: blur(6px);
  transition: border-color .3s, background-color .3s;
}
.contact:hover,
.contact:focus-visible {
  border-color: rgba(244, 243, 239, 0.7);
  background: rgba(244, 243, 239, 0.06);
  outline: none;
}

footer {
  position: relative;
  padding: 1.2rem 1rem 1.4rem;
  text-align: center;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(244, 243, 239, 0.35);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Entrance ---------- */

.logo, .mission, .contact {
  animation: rise 1.4s cubic-bezier(.2, .7, .2, 1) both;
}
.mission { animation-delay: .35s; }
.contact { animation-delay: .6s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); filter: blur(6px); }
  to   { opacity: 1; transform: none; filter: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .light { transform: none; }
}

/* ---------- Layout by screen size ---------- */

/* Phones and narrow windows: figure on top, text below (the default above). */

/* Short, wide screens (a phone on its side): figure and text side by side, smaller. */
@media (max-width: 899px) and (orientation: landscape) and (max-height: 560px) {
  main { flex-direction: row; gap: 4vw; }
  .figure-slot { width: min(44vw, 86svh); }
  .creative { font-size: clamp(2.6rem, 9vw, 5rem); }
  .control { font-size: clamp(0.75rem, 2.5vw, 1.4rem); }
}

/* Desktop: text on the left, figure on the right */
@media (min-width: 900px) {
  main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: 4vw;
    padding: 2rem 6vw;
    text-align: left;
  }
  .copy { align-items: flex-start; }
  .figure-slot {
    grid-column: 2;
    grid-row: 1;
    width: min(100%, 74svh);
    justify-self: center;
  }
  .copy { grid-column: 1; grid-row: 1; }
  .creative { font-size: clamp(4.6rem, 9.5vw, 10rem); }
  .control { font-size: clamp(1.3rem, 2.65vw, 2.8rem); }
}
