/* Motion choreography. Layout and typography stay in styles.css. */
.hero { position: relative; isolation: isolate; --hero-progress: 0; padding-bottom: 36px; }
.hero-copy { position: sticky; top: calc(var(--site-header-height) + 30px); z-index: 1; animation: none; opacity: calc(1 - var(--hero-progress) * .8); transform: translate3d(0, calc(var(--hero-progress) * -16px), 0); }
.product-composition { z-index: 3; margin-top: 88px; animation: none; transform: translate3d(0, calc(var(--hero-progress) * -30px), 0); }
.product-composition::before { content: ''; position: absolute; inset: -30px -30px -25px; z-index: -2; background: linear-gradient(180deg, transparent, var(--page) 130px); pointer-events: none; }
.hero-mac { transform: perspective(1800px) rotateY(calc(4deg - var(--hero-progress) * 4deg)) rotateX(calc(2deg - var(--hero-progress) * 2deg)); }
.hero-phone { transform: translateY(calc(var(--hero-progress) * -26px)) rotate(calc(5deg - var(--hero-progress) * 4deg)); }

/* Cursor shares the card's coordinate system and all of its movement. */
.flying-link .save-cursor { left: 72%; top: calc(100% - 12px); right: auto; animation: none; transform: none; }
.demo-stage { --demo-duration: 3.6s; }
.demo-stage.is-paused *, .demo-stage.is-paused *::before, .demo-stage.is-paused *::after { animation-play-state: paused !important; }
.demo-stage[data-scene="0"] { --demo-duration: 2.6s; }
.demo-stage[data-scene="1"] { --demo-duration: 1.3s; }
.demo-stage[data-scene="3"] { --demo-duration: 3.2s; }
.demo-stage[data-scene="4"] { --demo-duration: 1.6s; }
.demo-stage[data-scene="5"] { --demo-duration: 1.05s; }
.play .demo-toast, .play .flying-link, .play .saved-entry { animation-duration: var(--demo-duration); }

/* The hidden measurement layer reserves the final wrapped height. JS reveals a
   single text prefix, including its newline, so lines never type in parallel. */
.typewriter { display: grid; white-space: pre-wrap; }
.typewriter > span { grid-area: 1 / 1; }
.typing-measure { visibility: hidden; }
.typing-text { min-width: 0; }
.typing-text.is-typing::after { content: ''; display: inline-block; height: 1em; width: 1px; margin-left: 2px; vertical-align: -.1em; background: var(--accent); }
.play .quick-scene .demo-window { animation-duration: .3s; }
.play .shortcut-keys { animation-duration: .3s; }
.play .search-query { animation: none; }
.play .search-results { animation: search-found .22s .38s both; }
@keyframes search-found { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.play .lock-before, .play .lock-after, .play .lock-symbol { animation-duration: var(--demo-duration); }
.play .password-dots { animation-duration: .35s; }

/* Hide a topic in context. The menu extends into the content pane and stays
   within the stage, with no clipping on the window or sidebar. */
.hidden-scene { max-width: 610px; overflow: visible; }
.hidden-scene .mac-toolbar { border-radius: 11px 11px 0 0; }
.hide-library { display: grid; grid-template-columns: 190px 1fr; min-height: 245px; }
.hide-sidebar { background: #2c3226; padding: 18px 10px 24px; border-radius: 0 0 0 11px; position: relative; z-index: 2; }
.hide-sidebar-label { padding: 0 10px 10px; color: #a2ad94; font-size: var(--km-font-caption); line-height: var(--km-leading-caption); letter-spacing: .08em; }
.hidden-row { position: relative; gap: 8px; padding: 12px 10px; min-height: 44px; font-size: var(--km-font-secondary); line-height: var(--km-leading-secondary); }
.hidden-row > span:last-child { margin-left: 0; }
.hidden-row > [data-icon] { flex-shrink: 0; }
.hide-row-slot { position: relative; height: 50px; }
.hide-target { height: 50px; color: var(--accent); }
.hide-target > [data-icon] { color: var(--accent); }
.hide-trigger { margin-left: auto !important; position: relative; width: 20px; height: 20px; flex-shrink: 0; }
.hide-trigger > svg { width: 20px; height: 20px; }
.hide-click-ring { position: absolute; inset: -6px; border: 1px solid var(--accent); border-radius: 50%; opacity: 0; }
.hide-trigger-cursor { left: 13px; top: 12px; right: auto; width: 19px; height: 25px; }
.hide-menu { top: 46px; left: 25px; right: auto; width: 192px; padding: 6px; z-index: 5; }
.hide-menu > div { position: relative; gap: 9px; padding: 10px; font-size: var(--km-font-secondary); line-height: var(--km-leading-secondary); }
.hide-menu-cursor { left: 72%; top: 25px; right: auto; width: 19px; height: 25px; }
.hide-view { position: relative; min-width: 0; padding: 24px; }
.hide-view .demo-entry { padding: 13px; }
.hide-view .demo-entry-title { font-size: var(--km-font-compact); line-height: var(--km-leading-compact); }
.hide-after { position: absolute; inset: 24px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 12px; opacity: 0; }
.hide-after > [data-icon] { color: #c1d4a0; }
.hide-after p { font-size: var(--km-font-compact); line-height: var(--km-leading-compact); }
.hide-after > span:last-child { color: #b0bba3; font-size: var(--km-font-secondary); line-height: var(--km-leading-secondary); }
.play .hide-trigger-cursor { animation: hide-pointer var(--demo-duration) both; }
.play .hide-click-ring { animation: hide-click var(--demo-duration) both; }
.play .hide-menu { animation: topic-menu var(--demo-duration) both; }
.play .hide-menu-cursor { animation: menu-pointer var(--demo-duration) both; }
.play .hide-row-slot { animation: topic-collapse var(--demo-duration) both; }
.play .hide-target { animation: topic-away var(--demo-duration) both; }
.play .hide-before { animation: topic-away var(--demo-duration) both; }
.play .hide-after { animation: topic-empty var(--demo-duration) both; }
@keyframes hide-pointer { 0% { opacity: 0; transform: translate(15px,16px); } 12%,24% { opacity: 1; transform: none; } 30%,100% { opacity: 0; } }
@keyframes hide-click { 0%,16% { opacity: 0; transform: scale(.6); } 21% { opacity: .8; transform: scale(1); } 28%,100% { opacity: 0; transform: scale(1.3); } }
@keyframes topic-menu { 0%,23% { opacity: 0; transform: translateY(-5px) scale(.97); } 31%,60% { opacity: 1; transform: none; } 69%,100% { opacity: 0; transform: none; } }
@keyframes menu-pointer { 0%,32% { opacity: 0; transform: translate(8px,8px); } 41%,59% { opacity: 1; transform: none; } 64%,100% { opacity: 0; } }
@keyframes topic-away { 0%,66% { opacity: 1; transform: none; } 79%,100% { opacity: 0; transform: translateX(-5px); } }
@keyframes topic-collapse { 0%,74% { height: 50px; } 88%,100% { height: 0; } }
@keyframes topic-empty { 0%,74% { opacity: 0; transform: translateY(5px); } 90%,100% { opacity: 1; transform: none; } }

/* Four devices on shared circular tracks, with counter-rotation for upright
   labels. Motion pauses offscreen, in background tabs, or at user request. */
.cloud-visual { position: relative; min-width: 0; }
.cloud-art { --orbit-inner: 190px; --orbit-middle: 310px; --orbit-outer: 430px; height: 450px; }
.cloud-orbit.orbit-one, .track-inner { width: var(--orbit-inner); height: var(--orbit-inner); }
.cloud-orbit.orbit-two, .track-middle { width: var(--orbit-middle); height: var(--orbit-middle); }
.cloud-orbit.orbit-three, .track-outer { width: var(--orbit-outer); height: var(--orbit-outer); }
.orbit-track { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); pointer-events: none; }
.orbit-arm { position: absolute; inset: 0; --sweep: 10deg; --period: 26s; animation: orbit-sway var(--period) ease-in-out infinite alternate; animation-play-state: paused; }
.orbit-node { position: absolute; left: 50%; top: 0; animation: orbit-counter var(--period) ease-in-out infinite alternate; animation-play-state: paused; }
.arm-mac { --start: -60deg; }
.arm-phone { --start: 120deg; }
.arm-laptop { --start: 225deg; --period: 32s; --delay: 1.5s; }
.arm-phone-extra { --start: 45deg; --period: 32s; --delay: .8s; }
.arm-signal { --start: 25deg; --period: 18s; --sweep: 28deg; }
.orbit-device { position: relative; top: auto; left: auto; right: auto; bottom: auto; white-space: nowrap; padding: 12px 15px; }
.orbit-device-small { padding: 9px 12px; background: #242c1d; border-color: #536043; }
.orbit-device-small svg { width: 20px; height: 20px; }
.device-appear { transform-origin: center; }
.cloud-art.motion-ready:not(.has-entered) .device-appear { opacity: 0; }
.cloud-art.has-entered .device-appear { animation: device-arrive .6s var(--delay, 0s) both; }
.cloud-art:not(.is-running) .device-appear { animation-play-state: paused; }
.cloud-art.is-running .orbit-arm, .cloud-art.is-running .orbit-node { animation-play-state: running; }
.orbit-signal { position: absolute; left: 50%; top: 0; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 13px #d6fa4370; transform: translate(-50%,-50%); }
.icloud-label { z-index: 3; left: 50%; top: calc(50% - var(--orbit-outer) / 2); transform: translate(-50%, -50%); background: #191d15; padding: 5px 14px; border-radius: 999px; box-shadow: 0 0 0 4px #191d15; white-space: nowrap; }
@keyframes orbit-sway { from { transform: rotate(calc(var(--start) - var(--sweep))); } to { transform: rotate(calc(var(--start) + var(--sweep))); } }
@keyframes orbit-counter { from { transform: translate(-50%,-50%) rotate(calc(var(--start) * -1 + var(--sweep))); } to { transform: translate(-50%,-50%) rotate(calc(var(--start) * -1 - var(--sweep))); } }
@keyframes device-arrive { from { opacity: 0; transform: scale(.75); filter: blur(3px); } to { opacity: 1; transform: scale(1); filter: blur(0); } }

@media (max-width: 760px) {
  .hero-copy { top: calc(var(--site-header-height) + 20px); }
  .product-composition { margin-top: 60px; }
  .product-composition::before { inset-inline: -16px; }
  .hero-mac { transform: none; }
  .hero-phone { transform: translateY(calc(var(--hero-progress) * -16px)) rotate(calc(5deg - var(--hero-progress) * 3deg)); }
  .hide-library { grid-template-columns: 105px 1fr; min-height: 235px; }
  .hide-sidebar { padding: 14px 6px; }
  .hide-sidebar-label { padding-inline: 5px; }
  .hidden-row { padding-inline: 5px; gap: 5px; flex-wrap: wrap; }
  .hidden-row > [data-icon] svg { width: 14px; height: 14px; }
  .hide-target { flex-wrap: nowrap; gap: 4px; }
  .hide-target > [data-icon] { display: none; }
  .hide-trigger { width: 17px; }
  .hide-trigger > svg { width: 17px; }
  .hide-menu { left: 7px; top: 44px; width: 174px; }
  .hide-view { padding: 17px 12px; }
  .hide-view .demo-entry { padding: 10px; }
  .hide-view .demo-entry-title { font-size: var(--km-font-secondary); line-height: var(--km-leading-secondary); }
  .hide-after { inset: 17px 12px; }
  .cloud-art { --orbit-inner: 150px; --orbit-middle: min(245px, calc(100vw - 120px)); --orbit-outer: min(340px, calc(100vw - 52px)); height: 360px; }
  .orbit-device { padding: 9px 11px; }
  .orbit-device-small { padding: 7px 9px; }
  .orbit-device-small svg { width: 16px; height: 16px; }
}
@media (max-width: 360px) {
  .hero-phone { transform: translateY(calc(var(--hero-progress) * -16px)) rotate(calc(3deg - var(--hero-progress) * 2deg)); }
  .hide-library { grid-template-columns: 90px 1fr; }
  .hide-view { padding-inline: 9px; }
  .hide-target { padding-inline: 3px; }
  .hide-menu { width: 166px; left: 3px; }
  .hide-menu > div { padding-inline: 7px; gap: 7px; }
  .orbit-device { gap: 7px; padding: 8px; }
  .orbit-device-small { padding: 7px; gap: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-copy { position: relative; top: auto; opacity: 1; transform: none; }
  .product-composition, .hero-mac { transform: none; }
  .hero-phone { transform: rotate(3deg); }
  .hero .product-composition::before { display: none; }
  .typing-text.is-typing::after, .typing-measure { display: none; }
  .hide-target, .hide-before, .hide-menu, .hide-trigger-cursor { visibility: hidden; }
  .hide-row-slot { height: 0; }
  .hide-after { opacity: 1; transform: none; }
  .orbit-arm { transform: rotate(var(--start)); }
  .orbit-node { transform: translate(-50%,-50%) rotate(calc(var(--start) * -1)); }
  .cloud-art .device-appear { opacity: 1 !important; transform: none; filter: none; }
}
