/* tessel·la home. Tokens and shared elements live in tokens.css. */

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 18px/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
a { color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3, p { margin: 0; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.wrap { width: min(1240px, calc(100% - 64px)); margin-inline: auto; }

/* ---------- Header: follows the ground under it, like the teaser's HUD bug ---------- */
.site-header {
  position: fixed; inset: 0 0 auto; z-index: 50;
  color: var(--night);
  background: rgba(255, 246, 213, .78);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  transition: background-color .3s, color .3s;
}
.site-header[data-tone="dark"] { color: var(--cream); background: rgba(18, 18, 18, .72); }
.site-header[data-tone="cobalt"] { color: var(--cream); background: rgba(42, 69, 184, .82); }
.nav {
  width: min(1240px, calc(100% - 64px)); height: 72px; margin-inline: auto;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.nav-links { display: flex; align-items: center; gap: 6px; list-style: none; margin: 0; padding: 0; }
.nav-links a {
  display: inline-block; padding: 9px 14px; border-radius: 999px;
  font: 700 15px/1 var(--mono); text-decoration: none; opacity: .8;
  transition: opacity .2s, background-color .2s;
}
.nav-links a:hover { opacity: 1; background: rgba(127, 127, 127, .14); }
@media (max-width: 760px) {
  .nav-links li:not(.always) { display: none; }
  .brand > span { font-size: 18px; }
}

/* ---------- Scenes: each section sits on one of the teaser's grounds ---------- */
.scene { position: relative; padding: clamp(96px, 13vw, 176px) 0; }
.scene--cream { background: var(--bg); color: var(--ink); }
.scene--night { background: var(--night); color: var(--cream); }
:root[data-theme="dark"] .scene--night { background: #1A1A18; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .scene--night { background: #1A1A18; } }
.scene--cobalt { background: var(--cobalt); color: var(--cream); }

.scene-head { display: grid; gap: 28px; max-width: 1100px; margin-bottom: clamp(56px, 7vw, 96px); }
.scene-label { color: var(--tangerine); }
.scene--cobalt .scene-label { color: var(--cream); opacity: .85; }

.kinetic {
  font: 800 clamp(58px, 9vw, 150px)/.86 var(--display);
  font-stretch: 75%;
  letter-spacing: -.012em;
  font-variation-settings: "opsz" 96;
  text-wrap: balance;
}
.scene--cream .kinetic { color: var(--brand); }
h3.kinetic { font-size: clamp(40px, 5vw, 76px); }
.lede { max-width: 58ch; font-size: clamp(18px, 1.5vw, 22px); line-height: 1.55; opacity: .86; }
.lede strong { font-family: var(--mono); font-weight: 700; }

/* Kinetic words: characters spring up out of a baseline mask when the heading scrolls in. */
.kinetic .w { display: inline-block; white-space: nowrap; overflow: clip; padding: .06em .02em .14em; margin: -.06em -.02em -.14em; vertical-align: top; }
.kinetic .ch { display: inline-block; transform: translateY(1.1em) rotate(7deg); opacity: 0; }
.kinetic.in .ch { animation: rise .62s cubic-bezier(.34, 1.56, .64, 1) calc(var(--i) * 24ms) both; }
@keyframes rise { from { transform: translateY(1.1em) rotate(7deg); opacity: 0; } 20% { opacity: 1; } to { transform: none; opacity: 1; } }

/* ---------- Hero: the hook ---------- */
.hero {
  min-height: 100svh; padding: 120px 0 96px;
  display: grid; place-items: center; overflow: hidden; text-align: center;
}
.hero-inner { display: grid; justify-items: center; gap: 36px; padding-inline: 24px; }
.wordmark {
  display: inline-flex; align-items: baseline;
  color: var(--brand);
  font: 700 clamp(52px, 16.5vw, 270px)/.92 var(--mono);
  letter-spacing: -.045em; white-space: nowrap;
}
/* The dot sits where the logo puts it: between the two l's, 43% of the way up their stems.
   The slot is as tall as Courier Prime's l (.641em) and pulls the l's in to .1em from each stem
   (the letter-spacing already trims the left l's cell, hence the uneven margins). */
.wm-dot { position: relative; flex: none; width: .22em; height: .641em; margin: 0 -.141em 0 -.093em; }
.wm-dot::before, .wm-dot::after {
  content: ""; position: absolute; left: 50%; top: 57%;
  width: .22em; height: .22em; border-radius: 50%;
  transform: translate(-50%, -50%);
}
.wm-dot::before {
  background: var(--tangerine);
  animation: dot-entry 1.3s cubic-bezier(.16, 1, .3, 1) .25s both, dot-idle 3.6s ease-in-out 3.4s infinite;
}
.wm-dot::after {
  border: .02em solid var(--tangerine); opacity: 0;
  animation: dot-ping 3.6s ease-out 3.4s infinite;
}
/* Once the dot sets off down the page (site.js), its seat in the name stays empty. */
.dot-detached .wm-dot::before, .dot-detached .wm-dot::after { visibility: hidden; }
.wm-l { display: inline-block; animation: wm-left .8s cubic-bezier(.16, 1, .3, 1) .95s both; }
.wm-r { display: inline-block; animation: wm-right .8s cubic-bezier(.16, 1, .3, 1) .95s both; }
@keyframes dot-entry {
  0% { transform: translate(-360%, -50%) scale(.2); opacity: 0; }
  40% { transform: translate(-50%, -50%) scale(1.7); opacity: 1; }
  60% { transform: translate(-50%, -140%) scale(.8); }
  78% { transform: translate(-50%, -50%) scale(1.2); }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
@keyframes dot-idle {
  0%, 32%, 100% { transform: translate(-50%, -50%) scale(1); }
  42% { transform: translate(-50%, -150%) scale(.75); }
  54% { transform: translate(-50%, -50%) scale(1.4); }
  66% { transform: translate(-50%, -35%) scale(.85); }
  82% { transform: translate(-50%, -50%) scale(1.1); }
}
@keyframes dot-ping {
  0%, 32%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
  42% { transform: translate(-50%, -50%) scale(1); opacity: .8; }
  82% { transform: translate(-50%, -50%) scale(3.2); opacity: 0; }
}
@keyframes wm-left { from { transform: translateX(.8em); clip-path: inset(-10% 100% -10% 0); } to { transform: none; clip-path: inset(-10% 0 -10% 0); } }
@keyframes wm-right { from { transform: translateX(-.8em); clip-path: inset(-10% 0 -10% 100%); } to { transform: none; clip-path: inset(-10% 0 -10% 0); } }

.hero-sub { max-width: 44ch; font-size: clamp(19px, 1.8vw, 25px); line-height: 1.45; opacity: .88; animation: fade-up .7s ease 1.5s both; }
.hero-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; list-style: none; margin: 0; padding: 0; animation: fade-up .7s ease 1.7s both; }
.hero-meta .chip { background: var(--night); color: var(--cream); }
:root[data-theme="dark"] .hero-meta .chip { background: var(--cream); color: var(--night); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero-meta .chip { background: var(--cream); color: var(--night); } }
.led { width: 9px; height: 9px; border-radius: 50%; background: var(--tangerine); animation: blink 2.4s ease-in-out infinite; }
@keyframes blink { 0%, 60%, 100% { opacity: 1; } 68%, 78% { opacity: .3; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

/* The thread: a dotted path from the wordmark's dot through each scene to the logo in the footer.
   It runs over the grounds and under the content; the travelling dot rides above both. */
.thread { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
.hero-inner, .scene > .wrap, .site-footer > .wrap { position: relative; z-index: 2; }
.traveler {
  position: fixed; left: 0; top: 0; z-index: 45;
  border-radius: 50%; background: var(--tangerine);
  pointer-events: none; visibility: hidden;
}
.dot-detached .traveler { visibility: visible; }
.traveler::after {
  content: ""; position: absolute; inset: -2px; border-radius: 50%;
  border: 2px solid var(--tangerine); opacity: 0;
  animation: travel-ping 3.6s ease-out 1s infinite;
}
@keyframes travel-ping { 0%, 60%, 100% { transform: scale(1); opacity: 0; } 64% { opacity: .7; } 92% { transform: scale(2.8); opacity: 0; } }

/* ---------- Robo·Boy ---------- */
.project { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: clamp(40px, 5vw, 80px); align-items: start; }
.teaser { margin: 0; display: grid; gap: 22px; }
.teaser-frame {
  position: relative; overflow: hidden;
  aspect-ratio: 16 / 9; border-radius: var(--radius-lg);
  background: #000; box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .8), 0 0 0 1px rgba(255, 246, 213, .08);
}
.teaser-frame video { width: 100%; height: 100%; display: block; object-fit: cover; }
.teaser-frame video:fullscreen {
  width: 100vw; height: 100vh; object-fit: contain; background: #000;
}
.teaser-frame video:-webkit-full-screen {
  width: 100vw; height: 100vh; object-fit: contain; background: #000;
}
.teaser-play {
  position: absolute; inset: 0; border: 0; padding: 0; cursor: pointer;
  display: grid; place-items: center; align-content: center; gap: 18px;
  color: var(--cream); background: linear-gradient(180deg, rgba(18, 18, 18, 0) 40%, rgba(18, 18, 18, .55));
}
.teaser-play__dot {
  width: clamp(84px, 9vw, 116px); aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center; color: var(--night); background: var(--tangerine);
  box-shadow: 0 0 0 0 rgba(255, 135, 34, .6);
  transition: transform .25s cubic-bezier(.34, 1.56, .64, 1);
  animation: ping 2.6s ease-out infinite;
}
.teaser-play__dot svg { width: 42%; height: 42%; margin-left: 6%; }
.teaser-play:hover .teaser-play__dot { transform: scale(1.08); }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(255, 135, 34, .55); } 70%, 100% { box-shadow: 0 0 0 26px rgba(255, 135, 34, 0); } }
.teaser.playing .teaser-play { display: none; }
.chapters-label { opacity: .7; }
.chapters { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 12px 0 0; padding: 0; }
.chapters button {
  display: inline-flex; align-items: baseline; gap: 10px;
  padding: 9px 14px 10px; border: 1.5px solid rgba(255, 246, 213, .22); border-radius: 999px;
  color: inherit; background: transparent; cursor: pointer;
  font: 700 15px/1 var(--mono);
  transition: border-color .2s, background-color .2s, color .2s;
}
.chapters button .label { font-size: 13px; color: var(--tangerine); }
.chapters button:hover, .chapters button.is-active { border-color: var(--tangerine); }
.chapters button.is-active { color: var(--night); background: var(--tangerine); }
.chapters button.is-active .label { color: var(--night); }

.project-copy { display: grid; gap: 26px; }
.project-id { display: flex; align-items: center; gap: 18px; }
.project-id img { width: 84px; height: 84px; border-radius: 20px; }
.project-name { font: 700 30px/1 var(--mono); letter-spacing: -.02em; }
.project-tag { margin-top: 8px; font-size: 13px; opacity: .7; }
.project-copy > p { font-size: 18px; opacity: .88; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.tags .chip { font-size: 13px; color: var(--cream); background: rgba(255, 246, 213, .09); }
.project-cta { display: flex; flex-wrap: wrap; gap: 12px; }
.downloads { display: grid; gap: 14px; padding-top: 6px; }
.downloads .label { font-size: 13px; opacity: .7; }
.downloads ul { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.downloads a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 12px;
  font: 700 14px/1 var(--mono); text-decoration: none;
  background: rgba(255, 246, 213, .07); border: 1px solid rgba(255, 246, 213, .12);
  transition: background-color .2s, border-color .2s;
}
.downloads a:hover { background: rgba(255, 135, 34, .16); border-color: var(--tangerine); }
.downloads svg { width: 15px; height: 15px; }

/* ---------- About ---------- */
.principles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; list-style: none; margin: 0 0 clamp(56px, 6vw, 88px); padding: 0; }
.principles li {
  display: grid; gap: 14px; align-content: start;
  padding: 30px 28px 32px; border-radius: var(--radius-lg);
  background: var(--paper); box-shadow: var(--shadow);
}
.principles .link-glyph { width: 38px; height: 38px; margin-bottom: 10px; }
.principles h3 { font: 800 clamp(30px, 2.8vw, 40px)/.95 var(--display); font-stretch: 75%; color: var(--brand); }
.principles p { opacity: .85; }
.story { display: grid; gap: 22px; max-width: 64ch; }
.story p { font-size: clamp(18px, 1.4vw, 21px); opacity: .88; }
.story .btn { justify-self: start; margin-top: 6px; }

/* ---------- Contact ---------- */
.contact { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(40px, 6vw, 96px); align-items: end; }
.contact .scene-head { margin-bottom: 0; }
.contact .kinetic { font-size: clamp(56px, 7vw, 116px); }
.contact-form { display: grid; gap: 16px; padding: 32px; border-radius: var(--radius-lg); background: var(--cobalt-deep); box-shadow: 0 40px 80px -34px rgba(0, 0, 0, .55); }
.contact-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.contact-form label { display: grid; gap: 9px; }
.contact-form label .label { font-size: 13px; opacity: .85; }
.contact-form input, .contact-form textarea {
  width: 100%; padding: 14px 16px; border: 2px solid transparent; border-radius: 14px;
  color: var(--night); background: var(--cream);
  font: 400 17px/1.4 var(--body); resize: vertical;
}
.contact-form input::placeholder, .contact-form textarea::placeholder { color: #8a8270; }
.contact-form input:focus, .contact-form textarea:focus { outline: none; border-color: var(--tangerine); }
.form-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.form-status { font: 700 15px/1.3 var(--mono); }

/* ---------- Footer ---------- */
.site-footer { padding: 56px 0 88px; color: var(--cream); background: var(--night); }
.footer-grid { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 32px; }
.footer-grid .label { font-size: 13px; opacity: .7; }
.footer-links { display: flex; flex-wrap: wrap; gap: 20px; }
.footer-links a { font: 700 15px/1 var(--mono); text-decoration: none; opacity: .8; }
.footer-links a:hover { opacity: 1; color: var(--tangerine); }

/* ---------- HUD: section label and a rail with a tick per section ---------- */
.hud {
  position: fixed; left: 32px; right: 32px; bottom: 16px; z-index: 40;
  display: grid; grid-template-columns: minmax(150px, auto) 1fr 64px; align-items: center; gap: 20px;
  color: var(--night); pointer-events: none;
  transition: color .3s, opacity .3s;
}
.hud[data-tone="dark"], .hud[data-tone="cobalt"] { color: var(--cream); }
.hud-label, .hud-time { font-size: 13px; }
.hud-time { text-align: right; }
.hud-rail { position: relative; height: 2px; background: color-mix(in srgb, currentColor 32%, transparent); }
.hud-rail .tick { position: absolute; top: -5px; width: 2px; height: 12px; margin-left: -1px; background: currentColor; opacity: .55; }
.hud-head { position: absolute; top: -6px; left: 0; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--tangerine); }
@media (max-width: 820px) { .hud { display: none; } }

/* ---------- Responsive ---------- */
@media (max-width: 1020px) {
  .project, .contact { grid-template-columns: 1fr; }
  .contact { align-items: start; }
}
@media (max-width: 760px) {
  .wrap, .nav { width: min(100% - 36px, 1240px); }
  .nav { height: 64px; }
  .principles { grid-template-columns: 1fr; }
  .contact-form { padding: 22px; }
  .contact-form .row { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; gap: 18px; }
  body { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  .wm-dot::before, .wm-dot::after, .wm-l, .wm-r, .hero-sub, .hero-meta { animation: none; }
  .kinetic .ch { transform: none; opacity: 1; }
  .kinetic.in .ch { animation: none; }
  .teaser-play__dot { animation: none; }
}
