/* KeyPet site.
   The page is made of the device's own materials: a pale anodised-aluminium
   ground, true black (the AMOLED) for every control, and the pet's current
   mood colour (--pet) as the only accent, glowing on those black surfaces. */

:root {
  --ground: #e3e5e8;
  --ground-hi: #f3f4f6;
  --ground-lo: #d0d4d9;
  --ink: #000;
  --ink-2: #474c54;
  --ink-3: #7a7f88;
  --line: #c2c6cc;
  --amoled: #000;
  --on-amoled: #e9ebee;
  --pet: #5eead4;
  --card: rgba(243, 244, 246, 0.86);

  --f-display: "Unbounded", "Onest", system-ui, sans-serif;
  --f-text: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-code: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --gutter: clamp(16px, 4vw, 56px);
  --max: 1440px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html {
  scrollbar-gutter: stable;
  -webkit-text-size-adjust: 100%;
}
html.modules-open { overflow: hidden; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--ground);
  font: 400 17px/1.55 var(--f-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Studio light behind the device. Fixed so it never scrolls. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(70% 60% at 50% 40%, var(--ground-hi) 0%, rgba(243, 244, 246, 0) 70%),
    linear-gradient(180deg, var(--ground) 0%, var(--ground-lo) 100%);
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
}
#stage.over { cursor: grab; }
#stage.dragging { cursor: grabbing; }
html.modules-open #stage { touch-action: none; }
html.no-webgl #stage { display: none; }

#leader {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  overflow: visible;
  opacity: 0;
}
#leader path { fill: none; stroke: var(--ink); stroke-width: 1; }
#leader circle { fill: var(--ground-hi); stroke: var(--ink); stroke-width: 1.5; }

#tip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 30;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--amoled);
  color: var(--on-amoled);
  font: 500 14px/1.2 var(--f-text);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
}
#tip.show { opacity: 1; }

a { color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 6px; }

/* ---- type ---------------------------------------------------------------- */

h1, h2 {
  font-family: var(--f-display);
  font-weight: 500;
  margin: 0;
  text-wrap: balance;
}
h1 {
  font-size: clamp(36px, 4.7vw, 70px);
  line-height: 1.04;
  letter-spacing: -0.04em;
  margin-bottom: 28px;
}
h2 {
  font-size: clamp(27px, 2.9vw, 42px);
  line-height: 1.1;
  letter-spacing: -0.035em;
  margin-bottom: 20px;
}
h3 { margin: 0; font: 600 18px/1.3 var(--f-text); }
p { margin: 0 0 16px; }
.lead { font-size: clamp(17px, 1.3vw, 19px); color: var(--ink-2); max-width: 46ch; }
.caption { font-size: 15px; color: var(--ink-3); margin-top: 18px; }

/* ---- controls ------------------------------------------------------------ */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 0 24px 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--amoled);
  color: var(--pet);
  font: 500 16px/1 var(--f-text);
  text-decoration: none;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07), 0 14px 28px -16px rgba(0, 0, 0, 0.55);
  transition: color 0.6s, transform 0.15s;
}
.pill:hover { transform: translateY(-1px); }
.pill:active { transform: translateY(1px); }
.led {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--pet);
  box-shadow: 0 0 10px 1px var(--pet);
  transition: background 0.6s, box-shadow 0.6s;
}
.ghost {
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 6px;
}
.ghost:hover { text-decoration-thickness: 2px; }
.ghost-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  min-height: 40px;
  padding: 0 16px;
  font: 500 14px var(--f-text);
  cursor: pointer;
}
.ghost-btn:hover { border-color: var(--ink); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 18px 28px; margin-top: 32px; }

/* Keychain / watch switch. The chosen option is a black AMOLED segment. */
.variant { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 30px; }
.variant + .actions { margin-top: 26px; }
.variant-label { font-size: 15px; color: var(--ink-2); }
.seg {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 0 0 1px var(--line);
}
.seg button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px 0 13px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font: 500 15px/1 var(--f-text);
  cursor: pointer;
  transition: background 0.25s, color 0.25s;
}
.seg button:hover { color: var(--ink); }
.seg button svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.seg button[aria-pressed="true"] { background: var(--amoled); color: var(--pet); }
.seg-sm button { height: 30px; padding: 0 12px 0 9px; font-size: 13px; gap: 6px; }
.seg-sm button svg { width: 16px; height: 16px; }
.nav .seg-sm { margin-left: 4px; }

/* ---- nav ----------------------------------------------------------------- */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 16px var(--gutter);
  transition: background 0.3s, box-shadow 0.3s;
}
.nav.scrolled {
  background: rgba(227, 229, 232, 0.74);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  backdrop-filter: blur(16px) saturate(1.2);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}
html.modules-open .nav { opacity: 0; pointer-events: none; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font: 600 19px/1 var(--f-display);
  letter-spacing: -0.04em;
}
.brand svg { width: 28px; height: 28px; }
.brand svg circle { fill: var(--amoled); }
.brand svg .eye { fill: var(--pet); transition: fill 0.6s; }
.links { display: flex; align-items: center; gap: 26px; margin-left: auto; }
.links a, .links .link {
  color: var(--ink-2);
  text-decoration: none;
  font: 500 15px var(--f-text);
  background: none;
  border: 0;
  padding: 6px 0;
  cursor: pointer;
}
.links a:hover, .links .link:hover { color: var(--ink); }

/* ---- sections ------------------------------------------------------------ */

main {
  position: relative;
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.35s;
}
html.modules-open main { opacity: 0; visibility: hidden; }
.copy, .footer, .stage-note { pointer-events: auto; }
/* Grid children may shrink below their content (long code lines scroll inside). */
.copy, .modules > * { min-width: 0; }

.view {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  max-width: var(--max);
  margin: 0 auto;
  padding: 120px var(--gutter);
  display: grid;
  align-items: center;
}
.view .copy { width: min(540px, 42%); }
.text-left .copy { justify-self: start; }
.text-right .copy { justify-self: end; }

.hero .copy { width: min(600px, 46%); }
.stage-note {
  position: absolute;
  right: var(--gutter);
  bottom: 40px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--ink-3);
  transition: opacity 0.6s;
}
.stage-note .sep { width: 4px; height: 4px; border-radius: 50%; background: var(--line); }
.stage-note.used span:first-child, .stage-note.used .sep { display: none; }

/* states */
.states { list-style: none; margin: 28px 0 0; padding: 0; display: grid; gap: 2px; }
.states button {
  appearance: none;
  width: 100%;
  display: grid;
  grid-template-columns: 12px 1fr auto;
  column-gap: 14px;
  row-gap: 2px;
  align-items: baseline;
  padding: 13px 16px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: background 0.25s, color 0.25s;
}
.states button:hover { background: rgba(255, 255, 255, 0.55); }
.states button[aria-pressed="true"] { background: var(--amoled); color: var(--on-amoled); }
.swatch {
  grid-row: span 2;
  align-self: start;
  width: 10px;
  height: 10px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--c);
}
[aria-pressed="true"] .swatch { box-shadow: 0 0 10px 1px var(--c); }
.s-name { font-weight: 600; }
.s-desc { grid-column: 2 / -1; font-size: 15px; color: var(--ink-2); }
[aria-pressed="true"] .s-desc { color: #a3a8b0; }
.states code { font: 12px var(--f-code); color: var(--ink-3); }
[aria-pressed="true"] code { color: var(--c); }

.code {
  margin: 0;
  padding: 16px 18px;
  border-radius: 16px;
  background: var(--amoled);
  color: #cfd3d9;
  font: 13px/1.6 var(--f-code);
  overflow-x: auto;
  max-width: 100%;
}
.states + .caption { margin-top: 26px; margin-bottom: 10px; }
.status-line { line-height: 2; color: var(--ink-2); }
.status-line + .caption { margin-top: 6px; }

/* gestures */
.gestures { list-style: none; margin: 28px 0 0; padding: 0; display: grid; gap: 2px; }
.gestures button {
  appearance: none;
  width: 100%;
  display: grid;
  grid-template-columns: 44px auto 1fr;
  column-gap: 16px;
  row-gap: 2px;
  align-items: center;
  padding: 12px 14px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: background 0.25s;
}
.gestures button:hover { background: rgba(255, 255, 255, 0.55); }
.gestures button:active .g-icon { transform: scale(0.94); }
.g-icon { grid-row: span 2; width: 44px; height: 44px; transition: transform 0.12s; }
.g-icon > circle:first-child { fill: var(--amoled); }
.g-mark { fill: var(--pet); transition: fill 0.6s; }
.g-ring { fill: none; stroke: var(--pet); stroke-width: 2; opacity: 0.6; }
.g-line { fill: none; stroke: var(--pet); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.g-name { font-weight: 600; }
.g-desc { grid-column: 2 / -1; font-size: 15px; color: var(--ink-2); }

.status, .tbd {
  justify-self: start;
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
  vertical-align: 1px;
}
.status.ok { background: var(--amoled); color: #86efac; }
.status.dev { border: 1px solid var(--ink-3); color: var(--ink-2); padding: 1px 8px; }
.tbd { border: 1px dashed var(--ink-3); color: var(--ink-2); padding: 0 8px; }

/* open */
.assistants { list-style: none; margin: 28px 0 32px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.assistants li {
  padding: 8px 16px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  font: 500 16px var(--f-text);
}
.assistants li:last-child { border-style: dashed; border-color: var(--ink-3); color: var(--ink-2); }
.facts { margin: 0; display: grid; gap: 0; }
.facts div { padding: 14px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 11em 1fr; gap: 16px; }
.facts dt { font-weight: 600; }
.facts dd { margin: 0; color: var(--ink-2); }

/* specs: scroll-driven exploded view */
.specs { position: relative; height: 620vh; }
.specs .sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  max-width: var(--max);
  margin: 0 auto;
  padding: 84px var(--gutter) 32px;
  display: grid;
  align-items: center;
}
.specs .copy { justify-self: end; width: min(470px, 38%); }
.specs h2 { margin-bottom: 10px; }
.specs .lead { font-size: 16px; margin-bottom: 18px; }
.spec-count { display: none; }
.spec-list { list-style: none; margin: 0 0 18px; padding: 0; }
.spec-list > li {
  padding: 9px 0 9px 0;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  transition: color 0.3s;
}
.spec-list > li:last-child { border-bottom: 1px solid var(--line); }
.spec-list > li.active { color: var(--ink); }
.spec-list h3 { font-size: 16px; }
.spec-list ul { list-style: none; margin: 0; padding: 0; font-size: 14px; line-height: 1.5; }
.spec-list > li:not(.active) ul { display: none; }
.spec-list > li.active ul { margin-top: 4px; color: var(--ink-2); }
.specs .foot { font-size: 13px; color: var(--ink-3); margin-bottom: 18px; }

/* privacy */
.plain { list-style: none; margin: 8px 0 0; padding: 0; }
.plain li { padding: 14px 0; border-top: 1px solid var(--line); color: var(--ink-2); }
.plain li:last-child { border-bottom: 1px solid var(--line); }

/* footer */
.footer {
  position: relative;
  max-width: var(--max);
  margin: 0 auto;
  padding: 48px var(--gutter) 40px;
  color: var(--ink-3);
  font-size: 14px;
}

/* ---- module explorer ------------------------------------------------------ */

.modules {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  display: grid;
  grid-template-columns: minmax(200px, 250px) 1fr minmax(320px, 380px);
  grid-template-rows: auto 1fr;
  gap: 24px;
  padding: 24px var(--gutter) 32px;
}
.modules[hidden] { display: none; }
.modules > * { pointer-events: auto; }
.m-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}
.m-head h2 { margin-bottom: 6px; }
.m-hint { color: var(--ink-3); font-size: 15px; margin: 0; }

.m-list {
  grid-column: 1;
  grid-row: 2;
  align-self: center;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}
.m-list button {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink-2);
  font: 500 15px/1.3 var(--f-text);
  text-align: left;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.m-list button:hover { background: rgba(255, 255, 255, 0.6); color: var(--ink); }
.m-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); flex: none; transition: background 0.3s, box-shadow 0.3s; }
.m-list button[aria-selected="true"] { background: var(--amoled); color: var(--on-amoled); }
.m-list button[aria-selected="true"] .m-dot { background: var(--pet); box-shadow: 0 0 8px var(--pet); }

.m-card {
  grid-column: 3;
  grid-row: 2;
  align-self: center;
  max-height: 100%;
  overflow: auto;
  padding: 28px 28px 24px;
  border-radius: 26px;
  background: var(--card);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.05), 0 30px 60px -34px rgba(0, 0, 0, 0.45);
}
.m-index { margin: 0 0 14px; font-size: 13px; color: var(--ink-3); }
.m-name { font: 500 26px/1.15 var(--f-display); letter-spacing: -0.035em; margin-bottom: 6px; }
.m-part { color: var(--ink-3); font-size: 15px; margin-bottom: 16px; }
.m-text { color: var(--ink-2); font-size: 16px; }
.m-specs { margin: 18px 0 0; }
.m-specs div { display: grid; grid-template-columns: 9.5em 1fr; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.m-specs dt { color: var(--ink-3); }
.m-specs dd { margin: 0; }
.m-note {
  margin: 16px 0 0;
  padding: 12px 14px;
  border: 1px dashed var(--ink-3);
  border-radius: 14px;
  font-size: 14px;
  color: var(--ink-2);
}
.m-nav { display: flex; gap: 8px; margin-top: 22px; }

/* ---- small screens ------------------------------------------------------- */

@media (max-width: 1100px) and (min-width: 860px) {
  .links { gap: 18px; }
  .view .copy, .hero .copy { width: min(480px, 46%); }
  .specs .copy { width: min(420px, 42%); }
}

@media (max-width: 859px) {
  body { font-size: 16px; }
  .links { display: none; }
  .nav .seg-sm { margin-left: auto; }
  .nav .seg-sm button { padding: 0 9px; }
  .nav .seg-sm button span {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .variant { margin-top: 22px; }
  .nav { gap: 14px; padding-block: 12px; }

  .view { align-items: end; padding: 54vh 16px 40px; padding-top: 54svh; }
  .view .copy, .hero .copy {
    width: 100%;
    justify-self: stretch;
    padding: 22px 20px;
    border-radius: 24px;
    background: var(--card);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04);
  }
  .hero { padding-top: 58svh; }
  .hero .copy { background: transparent; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; padding: 0; }
  .stage-note { left: 16px; right: 16px; top: calc(54svh - 30px); bottom: auto; justify-content: center; font-size: 13px; }
  .actions { margin-top: 22px; gap: 14px 22px; }
  .facts div { grid-template-columns: 1fr; gap: 2px; }

  .specs { height: 560vh; }
  .specs .sticky { align-items: end; padding: 70px 16px 16px; }
  .specs .copy {
    width: 100%;
    justify-self: stretch;
    padding: 18px 18px 16px;
    border-radius: 22px;
    background: var(--card);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
  }
  .specs .lead, .specs .foot { display: none; }
  .specs h2 { font-size: 22px; margin-bottom: 4px; }
  .spec-count { display: block; font-size: 13px; color: var(--ink-3); margin: 0 0 6px; }
  .spec-list > li { display: none; border: 0; padding: 0; }
  .spec-list > li.active { display: block; border: 0; }
  .spec-list > li.active:last-child { border: 0; }
  .specs .pill { min-height: 44px; }

  .modules {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto;
    gap: 12px;
    padding: 14px 0 14px;
  }
  .m-head { padding: 0 16px; align-items: center; }
  .m-head h2 { font-size: 24px; margin: 0; }
  .m-hint { display: none; }
  .m-head .pill { min-height: 44px; padding: 0 16px 0 14px; font-size: 14px; }
  .m-list {
    grid-row: 2;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 2px 16px 6px;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }
  .m-list::-webkit-scrollbar { display: none; }
  .m-list li { flex: none; scroll-snap-align: center; }
  .m-list button { white-space: nowrap; background: rgba(255, 255, 255, 0.5); }
  .m-card {
    grid-column: 1;
    grid-row: 4;
    margin: 0 12px;
    max-height: 44svh;
    padding: 20px 20px 18px;
    border-radius: 22px;
  }
  .m-name { font-size: 22px; }
  .m-specs div { grid-template-columns: 8em 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

html.no-webgl .stage-note { display: none; }
html.no-webgl .view .copy { width: min(640px, 100%); }
