/* ─────────────────────────────────────────────────────────────────────
   A cover. One color, one name, a few small words.
   The colors live in js/home.js (PALETTES).
   ───────────────────────────────────────────────────────────────────── */

@font-face {
  font-family: "Inter Tight";
  src: url("../assets/fonts/InterTight.woff2") format("woff2");
  font-weight: 100 900;
  font-display: block;
}

:root { --m: clamp(20px, 4.2vw, 44px); --ds: 18px; --note: clamp(13px, 1.05vw + 8px, 18px); }
/* on a wide screen the small things grow, so they hold their own next to the name */
@media (min-width: 900px) and (orientation: landscape) {
  :root { --ds: 27px; --note: clamp(20px, 0.9vw + 10px, 28px); --m: clamp(56px, 6vw, 120px); }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { background: #f2541b; }

body {
  background: #f2541b;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

#stack { position: fixed; inset: 0; background-color: #f2541b; }

.cover {
  position: absolute;
  inset: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter Tight", "Helvetica Neue", Helvetica, Arial, sans-serif;
  overflow: hidden;
}

/* a new color spreading in like ink; its outline is drawn by js/home.js */
.cover.ink { will-change: clip-path; }

/* the small words */
.note {
  position: absolute;
  left: var(--m);
  top: var(--m);
  margin: 0;
  font-size: var(--note);
  line-height: 1.22;
  font-weight: 500;
  letter-spacing: -0.006em;
}

/* the name */
.name {
  position: absolute;
  font-size: var(--fs, 20vh);
  font-weight: 560;
  line-height: 0.8;
  letter-spacing: -0.055em;
  white-space: nowrap;
}
.name span {
  display: block;
  /* the tight line-height lets the letters spill outside their box; Safari
     clips a moving element to that box, so give it room the layout won't see */
  padding-block: 0.16em;
  margin-block: -0.16em;
  padding-inline: 0.04em 0.1em;
  margin-inline: -0.04em -0.1em;
}
[data-b] { will-change: translate, rotate; }

/* every word can be picked up — the box around the name lets touches through,
   so it never hides the small text when that lands underneath */
.name { pointer-events: none; }
[data-b] { cursor: grab; touch-action: none; pointer-events: auto; }
.grabbing, .grabbing [data-b] { cursor: grabbing; }

/* where a word belongs: a thin outline, shown while it's away */
.ghost { pointer-events: none; color: transparent; -webkit-text-stroke: 1.2px var(--ink); }
.ghost [data-g], .note.ghost { opacity: 0; transition: opacity 0.35s ease; }
.ghost [data-g].show, .note.ghost.show { opacity: 0.3; }
.ghost [data-g].near, .note.ghost.near { opacity: 0.65; }

/* a word in pieces: each letter on its own */
.glyph {
  position: absolute; left: 0; top: 0;
  font-weight: 560; line-height: normal; white-space: pre;
  cursor: grab; touch-action: none;
  will-change: translate, rotate;
}

/* portrait: on its side, reading upward, hugging the right edge */
.tall .name {
  display: flex;                    /* keeps the words' hidden margins from collapsing */
  flex-direction: column;
  align-items: flex-start;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  right: -0.075em;
  bottom: var(--m);
}
/* landscape: lying down along the bottom, cropped by the edge */
.wide .name {
  left: calc(var(--m) - 0.06em);
  bottom: -0.12em;
}
.wide .name span { display: inline-block; }

/* intro: the name slides in like a book pulled off a shelf */
.intro .name:not(.ghost) span {
  animation: pull 1.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.intro .name:not(.ghost) span + span { animation-delay: 0.09s; }
.intro .note:not(.ghost) { animation: fade 0.7s 0.55s ease both; }
@keyframes pull { from { transform: translateY(-110%); } }   /* vertical-rl + rotate: "up the spine" */
.wide.intro .name:not(.ghost) span { animation-name: rise; }
@keyframes rise { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* the door: a small dot, bottom left */
#egg {
  position: fixed;
  left: calc(var(--m) - 11px);
  bottom: calc(var(--m) - 11px);
  width: calc(var(--ds) + 22px); height: calc(var(--ds) + 22px);
  border-radius: 50%;
  z-index: 2;
}
#egg::after {
  content: "";
  position: absolute; left: 11px; top: 11px;
  width: var(--ds); height: var(--ds); border-radius: 50%;   /* the same size as the loose ball */
  background: var(--dot, #111);
  transition: transform 0.35s cubic-bezier(0.34, 1.8, 0.64, 1), background 0.2s;
}
#egg:hover::after, #egg:focus-visible::after { transform: scale(1.2); }
/* loose: the dot is a ball */
#egg.ball { cursor: grab; touch-action: none; will-change: translate; }
#egg.ball::after {
  /* a bouncy ball: squashed along the last hit (set from js/home.js) */
  transform: rotate(var(--sa, 0deg)) scale(var(--sx, 1), var(--sy, 1));
  transition: background 0.2s;
}
#egg:focus-visible { outline: none; }
.wide #egg { left: auto; bottom: auto; right: calc(var(--m) - 11px); top: calc(var(--m) - 11px); }

/* Safari 26+ colors its top and bottom bars from a fixed element at that edge:
   full width, a few pixels tall, above everything else. These carry the
   current color (set from js/home.js). */
.bar-tint {
  position: fixed; left: 0; right: 0;
  height: 12px;
  background-color: var(--tint, #f2541b);
  z-index: 50;
  pointer-events: none;
}
.bar-tint.top { top: 0; }
.bar-tint.bottom { bottom: -8px; }

/* going through the dot: a circle of its color swells over the page, the page
   leans in toward it, then the color sinks to black */
.portal {
  position: fixed; inset: 0; z-index: 60;
  pointer-events: none;
  transition: clip-path 0.7s cubic-bezier(0.55, 0, 0.75, 0.25),
              -webkit-clip-path 0.7s cubic-bezier(0.55, 0, 0.75, 0.25),
              background-color 0.42s ease-in;
}
.portal.dark { background-color: #000 !important; }
#stack { transition: transform 0.75s cubic-bezier(0.55, 0, 0.75, 0.25); }
#stack.leaning-in { transform: scale(1.08); }

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

@media (prefers-reduced-motion: reduce) {
  .intro .name:not(.ghost) span, .intro .note:not(.ghost) { animation: none; }
  .ghost [data-g], .note.ghost { transition: none; }
}
