/* kettlekite.com: the sky, the index of games, one chapter per game, the studio. */

/* ——— The sky ——— */
.sky {
  position: relative; height: 100svh; min-height: 620px; overflow: hidden; isolation: isolate;
  background: linear-gradient(180deg, #090b1b 0%, #12163a 38%, #23255a 66%, #3a3060 100%);
}
.sky-glow {
  position: absolute; left: -20%; right: -20%; bottom: -10%; height: 70%; z-index: -1;
  background: radial-gradient(50% 50% at 55% 100%, rgba(240, 165, 108, 0.32), rgba(120, 96, 150, 0.14) 50%, transparent 76%);
}
.stars { position: absolute; inset: 0 0 42% 0; width: 100%; height: 58%; }
.stars circle { fill: var(--ivory); }
.stars .tw { animation: twinkle 4.5s ease-in-out infinite; }
@keyframes twinkle { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.85; } }

/* now and then a star falls: a short streak whose tail grows behind its head, then fades */
.meteors { position: absolute; inset: 0 0 35% 0; overflow: hidden; pointer-events: none; }
.meteor {
  position: absolute; left: var(--x); top: var(--y); width: var(--len); height: 1.5px; border-radius: 1px;
  background: linear-gradient(90deg, rgba(244, 235, 221, 0), rgba(244, 235, 221, 0.5) 65%, #fff8ee);
  transform-origin: 100% 50%; opacity: 0;
  animation: fall var(--t) cubic-bezier(0.35, 0, 0.65, 1) forwards;
}
.meteor::after { content: ""; position: absolute; right: -1.5px; top: -1.25px; width: 4px; height: 4px; border-radius: 50%; background: #fff8ee; box-shadow: 0 0 9px 2px rgba(255, 233, 196, 0.55); }
@keyframes fall {
  0% { opacity: 0; transform: rotate(var(--a)) translateX(0) scaleX(0.25); }
  14% { opacity: 1; }
  72% { opacity: 0.85; }
  100% { opacity: 0; transform: rotate(var(--a)) translateX(var(--d)) scaleX(1); }
}

.string { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.string path { fill: none; stroke: var(--ivory); stroke-opacity: 0.62; stroke-width: 1.2; stroke-linecap: round; }

/* the kite turns about its lower tip, where the string and the tail are tied */
.flyer { position: absolute; left: 71%; top: 11%; width: clamp(104px, 12.5vw, 200px); transform-origin: 50% 97%; transform: rotate(calc(var(--wx, 0) * 7deg)); transition: transform 1.6s var(--ease); }
.kite-big { width: 100%; height: auto; transform-origin: 50% 97%; animation: sway 7.5s ease-in-out infinite; filter: drop-shadow(0 18px 30px rgba(10, 8, 30, 0.45)); }
@keyframes sway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(5deg); } }

/* the kettle sits on the roof at the city's right edge (city.js puts that roof at 62% of its height) */
.kettle { position: absolute; z-index: 2; right: 4%; bottom: calc(var(--city) * 0.62); width: clamp(84px, 8vw, 140px); }
.kettle::before { content: ""; position: absolute; inset: 30% -40% -20% -40%; background: radial-gradient(closest-side, rgba(242, 196, 107, 0.32), transparent); z-index: -1; }
.kettle svg { width: 100%; height: auto; }
.steam path { animation: steam 3.2s linear infinite; stroke-opacity: 0.7; }
.steam path + path { animation-duration: 4.1s; }
@keyframes steam { to { stroke-dashoffset: -40; } }

/* the night city along the bottom of the sky; its billboards play the games */
.sky { --city: 46%; }
.city { position: absolute; left: 0; right: 0; bottom: 0; height: var(--city); z-index: 1; }
.city svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.city .front { pointer-events: none; }
/* each screen spills a little of its game's light into the night */
.board {
  position: absolute; display: block; background: #0b0d1f center / cover no-repeat; text-decoration: none;
  box-shadow: 0 0 34px 4px color-mix(in srgb, var(--hue, #f4ebdd) 20%, transparent);
  transition: filter 0.25s ease;
}
.board canvas { display: block; width: 100%; height: 100%; }
/* the videos play unseen; city.js draws their frames into the canvas (see there why) */
.board video { position: absolute; inset: 0; width: 100%; height: 100%; visibility: hidden; }
/* the game's name, lit on the building under its billboard (city.js keeps that band of wall dark) */
.board .sign {
  position: absolute; left: 50%; top: calc(100% + var(--drop, 30px)); transform: translateX(-50%);
  font: 400 var(--sign, 15px)/1 var(--display); font-variation-settings: "opsz" 24; letter-spacing: 0.01em; white-space: nowrap;
  color: color-mix(in srgb, var(--hue, #f4ebdd) 82%, #fff8ee);
  text-shadow: 0 0 10px color-mix(in srgb, var(--hue, #f4ebdd) 45%, transparent);
  opacity: 0.86; transition: opacity 0.25s ease;
}
@media (hover: hover) and (pointer: fine) {
  .board:hover { filter: brightness(1.1); }
  .board:hover .sign { opacity: 1; }
}
.board:active { filter: brightness(0.94); }
.beacon { animation: beacon 2.8s ease-in-out infinite; }
@keyframes beacon { 0%, 100% { opacity: 0.15; } 50% { opacity: 1; } }

.sky-copy { position: absolute; left: 0; right: 0; top: clamp(5.5rem, 17vh, 10rem); pointer-events: none; }
.wordmark { font-weight: 290; font-size: clamp(3.4rem, 11vw, 12.5rem); line-height: 0.82; letter-spacing: -0.048em; margin-left: -0.045em; white-space: nowrap; }
.wordmark span { display: inline-block; }
.lede { max-width: 31ch; margin: clamp(1rem, 2.4vh, 1.8rem) 0 0; font-size: clamp(1.1rem, 1.55vw, 1.38rem); line-height: 1.5; color: var(--ivory-2); }

/* the opening: the kite rises from the sill, the string pays out, the name stands up */
.js .sky .flyer { opacity: 0; transform: translate(-34vw, 52vh) rotate(-28deg) scale(0.55); }
.js .sky .wordmark span { opacity: 0; transform: translateY(42%); }
.js .sky .lede { opacity: 0; transform: translateY(1rem); }
.js .sky .string path { stroke-dasharray: var(--len, 2000); stroke-dashoffset: var(--len, 2000); }
.js .sky.ready .flyer { opacity: 1; transform: rotate(calc(var(--wx, 0) * 7deg)); transition: opacity 0.6s ease, transform 2s var(--ease); }
.js .sky.ready .wordmark span { opacity: 1; transform: none; transition: opacity 1s ease, transform 1.4s var(--ease); transition-delay: calc(0.35s + var(--i) * 0.055s); }
.js .sky.ready .lede { opacity: 1; transform: none; transition: opacity 1s ease 1.15s, transform 1.2s var(--ease) 1.15s; }
.js .sky.ready .string path { stroke-dashoffset: 0; transition: stroke-dashoffset 1.8s cubic-bezier(0.45, 0, 0.2, 1) 0.9s; }

/* ——— Index of games ——— */
.index { position: relative; padding-top: clamp(5rem, 12vw, 10rem); padding-bottom: clamp(5rem, 11vw, 9rem); }
.games { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.games a {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 24rem) minmax(0, 13rem); align-items: baseline; gap: 0.4rem 2rem;
  padding: clamp(1.1rem, 2.3vw, 1.9rem) 0; border-bottom: 1px solid var(--line); text-decoration: none;
  transition: opacity 0.5s var(--ease);
}
.g-name { font-family: var(--display); font-weight: 310; font-size: clamp(2.3rem, 5.8vw, 5.2rem); line-height: 1; letter-spacing: -0.035em; font-variation-settings: "opsz" 144; transition: transform 0.7s var(--ease); }
.g-what { color: var(--ivory-2); font-size: clamp(1rem, 1.25vw, 1.15rem); }
.g-where { color: var(--ivory-3); font-size: 0.95rem; text-align: right; white-space: nowrap; }
.games a:hover .g-name, .games a:focus-visible .g-name { transform: translateX(0.8rem); }
@media (hover: hover) { .games:hover a:not(:hover) { opacity: 0.38; } }
/* The index preview follows the pointer. Every game's frame is loaded and stacked inside it, so
   moving between a wide frame and a tall one is a crossfade of two ready images: only opacity and
   transform change, never the box's size, and nothing waits on a decode. */
.peek {
  position: fixed; left: 0; top: 0; z-index: 40; width: 0; height: 0; pointer-events: none;
  opacity: 0; transform: translate3d(var(--px, 0), var(--py, 0), 0) scale(0.86) rotate(-3deg);
  transition: opacity 0.35s ease, transform 0.6s var(--ease);
}
.peek.on { opacity: 1; transform: translate3d(var(--px, 0), var(--py, 0), 0) rotate(-2deg); }
.peek img {
  position: absolute; left: 0; top: 0; width: clamp(220px, 21vw, 340px); max-width: none; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 14px;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.6);
  opacity: 0; transform: translate(-50%, -50%) scale(0.9); transition: opacity 0.32s ease, transform 0.55s var(--ease);
}
.peek img.tall { width: clamp(130px, 11vw, 180px); aspect-ratio: 506 / 1100; }
.peek img.on { opacity: 1; transform: translate(-50%, -50%); }

/* ——— Chapters: one screen each. Its scene assembles as it rises into view (--p, 0 → 1) and
   is whole by the time it fills the screen; it drifts apart as it leaves (--leave, 0 → 1). ——— */
.chapter { position: relative; height: 100svh; }
.chapter .stage { position: relative; height: 100%; overflow: hidden; }

/* The page settles on a whole chapter: a flick moves one chapter, and no resting place leaves two
   of them half on screen. The index, studio and contact are snap points too, and scroll freely
   wherever they are taller than the screen. */
html:has(body.home) { scroll-snap-type: y mandatory; }
.sky, .index, .chapter, .studio { scroll-snap-align: start; }
.home .foot { scroll-snap-align: end; }
.chapter .title { font-weight: 290; letter-spacing: -0.045em; line-height: 0.86; font-variation-settings: "opsz" 144; }
.side .what { font-size: clamp(1.15rem, 1.45vw, 1.34rem); line-height: 1.5; margin-bottom: 1rem; }
.side .where { color: var(--ivory-2); font-size: 1.02rem; }
.actions { margin-top: 1.7rem; }
/* Apple's badge (shape in kk.css) presses like the buttons beside it */
.store-badge { transition: transform 0.16s var(--ease); }
.store-badge:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .store-badge:hover { transform: translateY(-1px); } }

/* film: the game itself, full bleed */
.film .stage { background: #08090f; }
.film .bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: translate3d(0, calc(var(--leave, 0) * 24vh), 0) scale(calc(1.2 - var(--p, 0) * 0.09)); }
.film .shade {
  position: absolute; inset: 0;
  background:
    linear-gradient(0deg, rgba(9, 10, 22, 0.94) 0%, rgba(9, 10, 22, 0.55) 34%, rgba(9, 10, 22, 0.06) 66%),
    linear-gradient(180deg, rgba(9, 10, 22, 0.55) 0%, transparent 22%);
}
.film .copy { position: absolute; left: 0; right: 0; bottom: 0; padding-bottom: clamp(2.4rem, 7vh, 5rem); display: grid; grid-template-columns: minmax(0, 1fr) minmax(18rem, 29rem); align-items: end; gap: 1.5rem 4rem; }
.film .title { font-size: clamp(4rem, 13.5vw, 15rem); transform: translateY(calc((1 - var(--p, 0)) * 9vh)); }
.film .side { transform: translateY(calc((1 - var(--p, 0)) * 5vh)); opacity: calc(0.25 + var(--p, 0) * 2); }
.lavaspin .copy { grid-template-columns: minmax(18rem, 29rem) minmax(0, 1fr); }
.lavaspin .title { order: 2; text-align: right; }
.lavaspin .shade {
  background:
    linear-gradient(0deg, rgba(14, 6, 4, 0.94) 0%, rgba(14, 6, 4, 0.5) 36%, rgba(14, 6, 4, 0.05) 66%),
    linear-gradient(180deg, rgba(14, 6, 4, 0.5) 0%, transparent 22%);
}
.streetball .stage { background: #170d1c; }
.lavaspin .stage { background: #120604; }

/* showcase: the phone game, its pieces floating out of the screen */
.vanity .stage { background: radial-gradient(70% 85% at 70% 48%, #6f3549 0%, #3e2030 48%, #1b1016 100%); }
.sundae .stage { background: radial-gradient(70% 85% at 30% 48%, #2b6a5f 0%, #15342f 50%, #0b1716 100%); }
.crab .stage { background: radial-gradient(70% 85% at 70% 48%, #1f5d70 0%, #123647 48%, #081620 100%); }
.scene { position: absolute; inset: 0; }
.float {
  position: absolute; left: var(--x); top: var(--y); width: var(--w); height: auto;
  transform: translate3d(calc(var(--mx, 0) * var(--d) * -22px), calc(((1 - var(--p, 0)) * 30vh - var(--leave, 0) * 18vh) * var(--d)), 0) rotate(calc(var(--r) + (1 - var(--p, 0)) * var(--d) * -16deg));
  filter: drop-shadow(0 26px 34px rgba(8, 4, 10, 0.4));
  will-change: transform;
}
.device { position: absolute; top: 50%; left: 69%; transform: translate(-50%, calc(-50% + (1 - var(--p, 0)) * 16vh)) rotate(calc((1 - var(--p, 0)) * 5deg)); }
.sundae .device { left: 25%; transform: translate(-50%, calc(-50% + (1 - var(--p, 0)) * 16vh)) rotate(calc((1 - var(--p, 0)) * -5deg)); }
.device .phone { width: clamp(220px, 19vw, 320px); }
.showcase .copy { position: absolute; inset: 0; display: flex; align-items: center; pointer-events: none; }
.showcase .side { max-width: 29rem; pointer-events: auto; transform: translateY(calc((1 - var(--p, 0)) * 6vh)); }
.sundae .side { margin-left: auto; }
.showcase .title { font-size: clamp(3.6rem, 8.2vw, 9rem); margin-bottom: clamp(1.2rem, 3vh, 2rem); }

/* ——— Studio and contact ——— */
.studio { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(18rem, 33rem); gap: 2rem 5rem; align-items: start; padding-top: clamp(7rem, 17vw, 15rem); padding-bottom: clamp(4rem, 9vw, 8rem); }
.studio-title { font-size: clamp(2.8rem, 6.4vw, 6.6rem); font-weight: 290; letter-spacing: -0.04em; line-height: 0.95; }
.studio-body p { color: var(--ivory-2); font-size: clamp(1.08rem, 1.3vw, 1.2rem); line-height: 1.65; }
.studio-body a { display: inline-block; padding-block: 0.65rem; margin-block: -0.65rem; color: var(--ivory); }
.contact { padding-bottom: clamp(5rem, 10vw, 9rem); }
.contact-title { font-size: clamp(1.6rem, 2.6vw, 2.2rem); font-weight: 340; margin-bottom: 1rem; color: var(--ivory-2); }
.mail {
  font-family: var(--display); font-weight: 290; font-size: clamp(2.1rem, 7.4vw, 7rem); letter-spacing: -0.04em; line-height: 1.1;
  text-decoration: none; font-variation-settings: "opsz" 144;
  background: linear-gradient(currentColor, currentColor) 0 96% / 0 1.5px no-repeat; transition: background-size 0.8s var(--ease);
  overflow-wrap: anywhere;
}
.mail:hover { background-size: 100% 1.5px; }

/* ——— The tail ——— */
.tail { position: absolute; left: 0; top: 0; width: 100%; z-index: 30; pointer-events: none; overflow: visible; }
.tail .ribbon { fill: none; stroke: var(--ivory); stroke-opacity: 0.55; stroke-width: 1.3; stroke-linecap: round; }
.tail .bow { transform-box: fill-box; transform-origin: center; transform: scale(0); transition: transform 0.9s cubic-bezier(0.34, 1.56, 0.64, 1); }
.tail .bow.on { transform: scale(1); }

::selection { background: rgba(240, 169, 46, 0.34); color: #fff8ee; }
.foot a { display: inline-block; padding-block: 0.3rem; }

/* ——— Narrow screens ——— */
/* phone taps: the bar's and the footer's links keep their look and get a 44 px target */
@media (max-width: 760px) {
  .nav a { display: inline-block; }
  .nav a { min-width: 44px; text-align: center; }
  .bar .brand, .nav a { padding-block: 0.65rem; margin-block: -0.65rem; }
  .foot ul { gap: 0 1.5rem; }
  .foot a { display: inline-block; padding-block: 0.7rem; }
  /* a game's buttons fill their row, beside the badge or stacked, so the row ends on one edge */
  .chapter .actions .btn { flex: 1 1 auto; }
}
/* the smallest phones: the bar keeps the kite mark and the links (the name stands just below it,
   in the sky), and the line wraps beside the kite instead of running under it */
.brand .kite { flex-shrink: 0; }
@media (max-width: 350px) {
  .bar .brand { font-size: 0; gap: 0; padding: 11px; margin: -11px; }
  .lede { max-width: 15ch; }
}
@media (max-width: 860px) {
  .flyer { left: 62%; top: 12%; }
  .sky { --city: 58%; } /* two rows of rooftops on an upright screen */
  .kettle { right: 2%; width: 58px; }
  .games a { grid-template-columns: 1fr; gap: 0.3rem; }
  .g-where { text-align: left; }
  .film .copy { grid-template-columns: 1fr; }
  .lavaspin .copy { grid-template-columns: 1fr; }
  .lavaspin .title { order: 0; text-align: left; }
  .film .title { font-size: clamp(3.6rem, 17vw, 6rem); }
  .wordmark { font-size: 15vw; }
  /* the handset's top clears the bar: its centre sits at least half its height (2.18 × its width) below it */
  .device { top: max(26%, calc(4.25rem + min(42.5vw, 191.6px))); left: 50%; }
  .sundae .device { left: 50%; }
  .device .phone { width: min(39vw, 176px); padding: 7px; border-radius: 34px; }
  .device .phone video { border-radius: 27px; }
  .device .phone::before { top: 13px; height: 14px; }
  .showcase .side .where { font-size: 0.95rem; }
  /* the pieces gather round the handset, clear of the words below it */
  .float { top: calc(var(--y) * 0.56); width: calc(var(--w) * 1.7); opacity: 0.85; }
  .showcase .copy { align-items: flex-end; padding-bottom: 2.4rem; background: linear-gradient(0deg, rgba(10, 6, 10, 0.9) 0%, rgba(10, 6, 10, 0.55) 30%, transparent 52%); }
  .sundae .copy { background: linear-gradient(0deg, rgba(5, 14, 13, 0.9) 0%, rgba(5, 14, 13, 0.55) 30%, transparent 52%); }
  .crab .copy { background: linear-gradient(0deg, rgba(4, 12, 18, 0.9) 0%, rgba(4, 12, 18, 0.55) 30%, transparent 52%); }
  .sundae .side { margin-left: 0; }
  .showcase .title { font-size: clamp(3rem, 13vw, 4.6rem); }
  .studio { grid-template-columns: 1fr; }
}
/* short phones: a smaller handset, so it clears the game's name below it */
@media (max-width: 860px) and (max-height: 740px) {
  .device { top: max(26%, calc(4.25rem + min(32.7vw, 16.4svh))); }
  .device .phone { width: min(30vw, 15svh); padding: 5px; border-radius: 24px; }
  .device .phone video { border-radius: 19px; }
  .device .phone::before { top: 9px; height: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .film .bg, .film .title, .film .side, .showcase .side { transform: none !important; }
  /* still, but the handset stays centred on its place and each piece keeps its tilt */
  .device { transform: translate(-50%, -50%) !important; }
  .float { transform: rotate(var(--r)) !important; }
  .film .side { opacity: 1; }
}
