/* ==========================================================================
   PIPO - customer site stylesheet
   --------------------------------------------------------------------------
   One file, no framework, no CDN, no webfonts. That is not minimalism for its
   own sake: the site's Content-Security-Policy is `default-src 'none'` with
   only 'self' allowed for styles, so anything fetched from another origin
   simply would not load. Everything here is local or a system font.

   THE LOOK
   PIPO itself is a soft cream shell with a dark navy visor and cyan eyes, so
   the site is built from those three: warm off-white paper, deep navy ink,
   cyan for anything interactive. Generous rounding to match the hardware,
   which has no sharp corners anywhere on it.

   NOTE ON INLINE STYLES: there are none, anywhere, and there cannot be - the
   CSP has no 'unsafe-inline'. The progress bar's width therefore comes from
   the fixed .w-* classes at the bottom of this file rather than a style
   attribute. See web_bar_class() in app/web.php.
   ========================================================================== */

/* ------------------------------------------------------------- tokens ---- */

:root {
  /* Paper and ink */
  --cream:        #FBF7F0;
  --cream-warm:   #F4EDE1;
  --paper:        #FFFFFF;
  --navy:         #0E1626;   /* the visor colour - primary text */
  --navy-soft:    #1E2C44;
  --slate:        #5A6779;   /* secondary text */
  --slate-light:  #8A94A3;

  /* Cyan - eyes, links, anything you can act on */
  --cyan:         #22D3EE;
  --cyan-deep:    #0E7490;
  --cyan-ink:     #0B5A70;
  --cyan-wash:    #E8FBFF;

  /* Feedback */
  --green:        #0F8A5F;
  --green-wash:   #E7F7F0;
  --amber:        #B45309;
  --amber-wash:   #FEF4E6;
  --red:          #B42318;
  --red-wash:     #FDECEA;

  --line:         #E4DACB;   /* the shell's outline colour */
  --line-soft:    #EFE7DA;

  --radius:       18px;
  --radius-sm:    10px;
  --radius-pill:  999px;

  --shadow-sm:    0 1px 2px rgba(14, 22, 38, .06);
  --shadow:       0 4px 16px rgba(14, 22, 38, .07);
  --shadow-lg:    0 18px 48px rgba(14, 22, 38, .12);

  --wrap:         1080px;
  --wrap-narrow:  680px;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
}

/* --------------------------------------------------------------- reset --- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--navy);
  background: var(--cream);
  /* Stops iOS/Android bumping heading sizes around in landscape. */
  text-rendering: optimizeLegibility;
}

h1, h2, h3 {
  line-height: 1.2;
  margin: 0 0 .5em;
  letter-spacing: -0.02em;
  font-weight: 700;
}

h1 { font-size: clamp(1.85rem, 1.2rem + 2.4vw, 2.9rem); }
h2 { font-size: clamp(1.4rem, 1.1rem + 1.3vw, 2rem); }
h3 { font-size: 1.1rem; }

p { margin: 0 0 1em; }

a { color: var(--cyan-ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--cyan-deep); }

img, svg { max-width: 100%; }

/* One visible, consistent focus ring everywhere. Never remove this: keyboard
   users have no other way of knowing where they are on the page. */
:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ------------------------------------------------------------- layout ---- */

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 24px;
}

.wrap.narrow, .narrow { max-width: var(--wrap-narrow); }
.center { text-align: center; }

.band { padding: 72px 0; }
.band-tint { background: var(--cream-warm); }
.band-cta  { background: var(--navy); color: var(--cream); }
.band-cta .section-title,
.band-cta h2 { color: var(--cream); }
.band-cta .section-lede,
.band-cta .muted { color: rgba(251, 247, 240, .72); }
.band-cta a:not(.btn) { color: var(--cyan); }

.section-title { margin-bottom: .3em; }

.section-lede {
  font-size: 1.08rem;
  color: var(--slate);
  max-width: 62ch;
  margin-bottom: 2em;
}

.grid { display: grid; gap: 20px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(272px, 1fr)); }

.muted { color: var(--slate); }
.small { font-size: .9rem; }
.mono  { font-family: var(--mono); font-size: .93em; }
.text-warn { color: var(--amber); }

/* ------------------------------------------------------------- header ---- */

.site-header {
  background: rgba(251, 247, 240, .88);
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  z-index: 10;
  /* Progressive: browsers without backdrop-filter just get the solid-ish bg. */
  backdrop-filter: blur(8px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 66px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.12rem;
  letter-spacing: .04em;
  color: var(--navy);
  text-decoration: none;
}

.brand-mark { display: inline-flex; width: 32px; height: 32px; }
.brand-word { line-height: 1; }

.site-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: .95rem;
}

.site-nav a { color: var(--navy-soft); text-decoration: none; }
.site-nav a:hover { color: var(--cyan-deep); text-decoration: underline; }
.site-nav .btn { text-decoration: none; }

.nav-form { margin: 0; display: inline-flex; }

/* A submit button that reads as a link. Sign-out is a POST (a GET logout is
   triggerable by any third-party page), but it should not look like a button
   sitting in the navigation. */
.linkish {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--slate);
  cursor: pointer;
}
.linkish:hover { color: var(--cyan-deep); text-decoration: underline; }

/* --------------------------------------------------------------- hero ---- */

.hero {
  padding: 72px 0 84px;
  background:
    radial-gradient(1100px 460px at 78% -8%, var(--cyan-wash), transparent 62%),
    var(--cream);
}

.hero-inner {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  align-items: center;
  gap: 48px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: .13em;
  font-size: .76rem;
  font-weight: 700;
  color: var(--cyan-deep);
  margin-bottom: .9em;
}

.lede {
  font-size: 1.12rem;
  color: var(--slate);
  max-width: 54ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 28px 0 16px;
}

.hero-note { font-size: .9rem; color: var(--slate-light); margin: 0; }

.hero-art {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.hero-art-glow {
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(34, 211, 238, .22), transparent 68%);
}

.pipo-avatar { position: relative; display: block; }

/* ------------------------------------------------------------- buttons --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--navy);
  color: var(--cream);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--navy-soft); color: var(--cream); box-shadow: var(--shadow); }

.btn-ghost {
  background: transparent;
  color: var(--navy);
  border-color: var(--line);
}
.btn-ghost:hover { background: var(--paper); color: var(--navy); border-color: var(--slate-light); }

.btn-danger {
  background: var(--paper);
  color: var(--red);
  border-color: #E7B9B4;
}
.btn-danger:hover { background: var(--red-wash); color: var(--red); }

.btn-small { padding: 8px 15px; font-size: .9rem; }
.btn-large { padding: 15px 30px; font-size: 1.05rem; }
.btn-block { width: 100%; }

.band-cta .btn-primary { background: var(--cyan); color: var(--navy); }
.band-cta .btn-primary:hover { background: #67E3F7; color: var(--navy); }

/* --------------------------------------------------------------- cards --- */

.card {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow-sm);
}

.card h3 { margin-bottom: .4em; }
.card p:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------ personas --- */

.persona-grid { margin-top: 8px; }

.persona-card { text-align: center; }
.persona-art { display: flex; justify-content: center; margin-bottom: 10px; }
.persona-name { margin-bottom: .15em; }

.persona-tagline {
  color: var(--cyan-deep);
  font-weight: 600;
  font-size: .92rem;
  margin-bottom: .7em;
}

.persona-card p:last-child { color: var(--slate); font-size: .95rem; }

/* Chip used on the dashboard next to a unit's name. */
.persona-chip {
  display: inline-block;
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  background: var(--navy);
  color: var(--cream);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* ------------------------------------------------------------ callouts --- */

.callout {
  margin-top: 34px;
  padding: 22px 26px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--paper);
}

.callout-lock {
  border-left: 5px solid var(--cyan);
  color: var(--slate);
}
.callout-lock strong { color: var(--navy); }

.callout-gate {
  margin-top: 40px;
  background: var(--navy);
  color: rgba(251, 247, 240, .82);
  border-color: var(--navy);
}
.callout-gate h3 { color: var(--cream); }
.callout-actions { margin: 18px 0 0; }

/* --------------------------------------------------------------- steps --- */

.steps {
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 22px;
}

.step {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 24px;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--cyan-wash);
  color: var(--cyan-ink);
  font-weight: 800;
  margin-bottom: 12px;
}

.step h3 { margin-bottom: .35em; }
.step p { color: var(--slate); font-size: .95rem; margin: 0; }

.plain-list { padding-left: 20px; color: var(--slate); }
.plain-list li { margin-bottom: .6em; }
.plain-list strong { color: var(--navy); }

/* ---------------------------------------------------------------- auth --- */

.page-auth { background: var(--cream-warm); }

.auth-main { padding: 52px 0 72px; }

.auth-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 52px;
  align-items: start;
}

.auth-wrap-narrow {
  grid-template-columns: minmax(0, 460px);
  justify-content: center;
}

.auth-intro { padding-top: 12px; }
.auth-intro h1 { margin-top: .35em; }

.mini-steps { color: var(--slate); padding-left: 20px; margin: 0 0 1em; }
.mini-steps li { margin-bottom: .35em; }

.auth-card {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}

.auth-card-solo { margin: 0 auto; }

.auth-card-head { text-align: center; margin-bottom: 24px; }
.auth-card-head h1 { font-size: 1.7rem; margin: .3em 0 .2em; }
.auth-card-head .pipo-avatar { margin: 0 auto; }
.auth-card-head p { margin: 0; }

.auth-alt {
  margin: 18px 0 0;
  text-align: center;
  font-size: .95rem;
  color: var(--slate);
}

/* -------------------------------------------------------------- fields --- */

.field { margin-bottom: 20px; }

.field label {
  display: block;
  font-weight: 600;
  font-size: .93rem;
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field select {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  color: var(--navy);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color .12s ease, box-shadow .12s ease;
}

.field input:focus,
.field select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px var(--cyan-wash);
  outline: none;   /* replaced by the ring above, not removed */
}

.field input.has-error,
.field select.has-error { border-color: var(--red); }

/* The pairing code: wide tracking so six digits are easy to check against a
   240x240 screen from arm's length, which is exactly how they are read. */
.input-code {
  font-family: var(--mono);
  font-size: 1.6rem;
  letter-spacing: .34em;
  text-align: center;
  padding: 14px !important;
}

.field-help {
  margin: 6px 0 0;
  font-size: .85rem;
  color: var(--slate-light);
}

.field-error {
  margin: 6px 0 0;
  font-size: .88rem;
  color: var(--red);
  font-weight: 500;
}

.field-note {
  margin: 10px 0 0;
  padding: 10px 14px;
  font-size: .87rem;
  color: var(--amber);
  background: var(--amber-wash);
  border-radius: var(--radius-sm);
}

.field-check .check {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-weight: 400;
  font-size: .95rem;
  cursor: pointer;
}

.field-check .check input {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: var(--cyan-deep);
  flex-shrink: 0;
}

/* -------------------------------------------------------------- alerts --- */

.alert {
  padding: 13px 17px;
  border-radius: var(--radius-sm);
  font-size: .94rem;
  margin: 0 0 20px;
  border: 1px solid transparent;
}

.alert-error   { background: var(--red-wash);   color: var(--red);   border-color: #F3C9C4; }
.alert-success { background: var(--green-wash); color: var(--green); border-color: #BFE6D5; }
.alert-info    { background: var(--cyan-wash);  color: var(--cyan-ink); border-color: #BDEBF6; }

/* ----------------------------------------------------------- dashboard --- */

.page-dash { background: var(--cream-warm); }
.dash-main { padding: 40px 0 72px; }

.dash-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.dash-head h1 { margin-bottom: .1em; }
.dash-head p { margin: 0; }

.device-card {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 30px;
  margin-bottom: 26px;
  box-shadow: var(--shadow-sm);
}

.device-head {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.device-avatar {
  flex-shrink: 0;
  background: var(--cream);
  border-radius: var(--radius);
  padding: 8px;
}

.device-ident { min-width: 220px; flex: 1; }
.device-name { margin-bottom: .2em; }

.device-persona {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: .5em;
  font-size: .93rem;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: .93rem;
  color: var(--slate);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-on  { background: var(--green); box-shadow: 0 0 0 3px var(--green-wash); }
.dot-off { background: var(--slate-light); }

/* The personality lock notice. Deliberately prominent - it is the single most
   important thing on this page to communicate clearly, and the one people are
   most likely to go looking for a setting to change. */
.lock-note {
  margin: 22px 0;
  padding: 15px 18px;
  background: var(--cyan-wash);
  border-left: 4px solid var(--cyan);
  border-radius: var(--radius-sm);
  font-size: .92rem;
  color: var(--cyan-ink);
}
.lock-note strong { color: var(--navy); }

.stat-block { margin: 22px 0; }

.level-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 9px;
}

.level-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: var(--radius-pill);
  background: var(--navy);
  color: var(--cream);
  font-weight: 700;
  font-size: .88rem;
}

.bar {
  height: 10px;
  background: var(--cream-warm);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--cyan), var(--cyan-deep));
}

/* Hard facts: serial, firmware, hardware revision. */
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin: 22px 0 10px;
  padding: 20px;
  background: var(--cream);
  border-radius: var(--radius-sm);
}

.fact dt {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--slate-light);
  font-weight: 700;
  margin-bottom: 3px;
}

.fact dd { margin: 0; font-size: .95rem; }

.update-note { margin-bottom: 26px; }

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--cream-warm);
  color: var(--slate);
  font-size: .74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.tag-beta { background: var(--amber-wash); color: var(--amber); }
.tag-soon { background: var(--cyan-wash);  color: var(--cyan-ink); }

.settings-form {
  border-top: 1px solid var(--line-soft);
  padding-top: 24px;
}

.settings-title {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--slate-light);
  margin-bottom: 18px;
}

/* The unlink control, folded away by default. It is a legitimate action people
   need when they sell a unit, but it should take a deliberate click to reach. */
.danger-zone {
  margin-top: 24px;
  border-top: 1px solid var(--line-soft);
  padding-top: 16px;
}

.danger-zone summary {
  cursor: pointer;
  font-size: .9rem;
  color: var(--slate);
  font-weight: 500;
}
.danger-zone summary:hover { color: var(--navy); }

.danger-body {
  margin-top: 14px;
  padding: 18px;
  background: var(--red-wash);
  border-radius: var(--radius-sm);
  font-size: .93rem;
}
.danger-body p:last-of-type { margin-bottom: 14px; }

.empty-state { text-align: center; padding: 44px 26px; margin-bottom: 26px; }
.empty-state .pipo-avatar { margin: 0 auto 12px; }
.empty-state p { color: var(--slate); max-width: 46ch; margin: 0 auto; }

/* ---------------------------------------------------------------- shop --- */

.shop-card, .link-card { margin-bottom: 26px; }

.shop-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.shop-head h2 { margin: 0; }

.empty-line {
  padding: 18px;
  background: var(--cream);
  border-radius: var(--radius-sm);
  color: var(--slate);
  font-size: .93rem;
  margin: 0;
}

.ent-list { list-style: none; padding: 0; margin: 0; }

.ent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.ent-item:last-child { border-bottom: 0; }

.link-form { max-width: 340px; }

/* -------------------------------------------------------------- footer --- */

.site-footer {
  background: var(--navy);
  color: rgba(251, 247, 240, .68);
  padding: 40px 0;
  margin-top: 0;
  font-size: .92rem;
}

.site-footer.slim { padding: 26px 0; }
.site-footer a { color: var(--cyan); }
.site-footer strong { color: var(--cream); }
.footer-line { margin: 0 0 .45em; }
.footer-line:last-child { margin-bottom: 0; }

/* ---------------------------------------------------- progress bar sizes --

   Fixed width classes in 5% steps, because the CSP forbids inline styles and a
   style="width:63%" attribute would be silently dropped by the browser. 21
   rules is a small price for keeping `style-src 'self'` with no exceptions.
   ------------------------------------------------------------------------- */

.w-0   { width: 0; }
.w-5   { width: 5%; }
.w-10  { width: 10%; }
.w-15  { width: 15%; }
.w-20  { width: 20%; }
.w-25  { width: 25%; }
.w-30  { width: 30%; }
.w-35  { width: 35%; }
.w-40  { width: 40%; }
.w-45  { width: 45%; }
.w-50  { width: 50%; }
.w-55  { width: 55%; }
.w-60  { width: 60%; }
.w-65  { width: 65%; }
.w-70  { width: 70%; }
.w-75  { width: 75%; }
.w-80  { width: 80%; }
.w-85  { width: 85%; }
.w-90  { width: 90%; }
.w-95  { width: 95%; }
.w-100 { width: 100%; }

/* ---------------------------------------------------------- responsive --- */

@media (max-width: 860px) {
  .hero-inner { grid-template-columns: 1fr; gap: 28px; }
  .hero-art { order: -1; }          /* face first on a phone */
  .hero { padding: 40px 0 56px; }
  .auth-wrap { grid-template-columns: 1fr; gap: 30px; }
  .band { padding: 52px 0; }
}

@media (max-width: 560px) {
  .wrap { padding: 0 18px; }
  .site-nav { gap: 14px; font-size: .9rem; }
  .device-card, .auth-card, .card { padding: 22px; }
  .device-head { gap: 16px; }
  .facts { grid-template-columns: 1fr 1fr; padding: 16px; }
  .dash-head { align-items: flex-start; }
  .input-code { font-size: 1.35rem; letter-spacing: .24em; }
}

/* ------------------------------------------------------------ a11y prefs - */

/* Respect a system-level request for less motion: every transition here is
   decorative, so there is nothing lost by dropping them. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Windows high-contrast and forced-colours modes strip our palette; make sure
   the interactive surfaces still have real borders to be drawn from. */
@media (forced-colors: active) {
  .btn, .card, .device-card, .auth-card { border: 1px solid; }
  .dot-on, .dot-off { border: 1px solid; }
}

/* ------------------------------------------------------------- printing -- */

@media print {
  .site-header, .site-footer, .btn, .danger-zone, .link-card { display: none; }
  body { background: #fff; }
  .device-card { break-inside: avoid; border-color: #999; box-shadow: none; }
}


/* ===========================================================================
   PIPO - motion layer
   ---------------------------------------------------------------------------
   Every animation here is pure CSS. The site's Content-Security-Policy is
   default-src 'none' with no script-src at all, and that is worth keeping:
   a marketing page is exactly the sort of place a stray third-party script
   ends up. Scroll-driven reveals use animation-timeline: view(), so the
   browser does the work the usual IntersectionObserver would.

   Browsers without scroll-driven animations (Safari, older Firefox) simply
   see the finished state - the @supports guard means nothing starts hidden,
   so no one ever lands on a blank page.
   ======================================================================== */

/* --------------------------------------------------- ambient motion --- */
@keyframes pipo-float {
  0%, 100% { transform: translateY(0)      rotate(-1deg); }
  50%      { transform: translateY(-14px)  rotate(1deg); }
}
@keyframes pipo-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}
@keyframes pipo-glow {
  0%, 100% { opacity: .45; transform: scale(1); }
  50%      { opacity: .75; transform: scale(1.08); }
}
@keyframes pipo-hop {
  0%, 100% { transform: translateY(0); }
  30%      { transform: translateY(-9px); }
  60%      { transform: translateY(0); }
}

/* The hero robot drifts gently, like it is idling on your desk. */
.hero-art img.hero-robot {
  width: min(430px, 78vw);
  height: auto;
  display: block;
  animation: pipo-float 6s ease-in-out infinite;
  filter: drop-shadow(0 26px 34px rgba(16, 42, 80, .28));
}
.hero-art-glow {
  animation: pipo-glow 6s ease-in-out infinite;
}

/* -------------------------------------------------- scroll reveals --- */
@keyframes pipo-rise {
  from { opacity: 0; transform: translateY(34px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pipo-rise-left {
  from { opacity: 0; transform: translateX(-32px); }
  to   { opacity: 1; transform: translateX(0); }
}

@supports (animation-timeline: view()) {
  .reveal {
    animation: pipo-rise linear both;
    animation-timeline: view();
    animation-range: entry 5% cover 26%;
  }
  .reveal-left {
    animation: pipo-rise-left linear both;
    animation-timeline: view();
    animation-range: entry 5% cover 30%;
  }
  /* Cards in a row arrive one after another rather than all at once. */
  .reveal-stagger > * {
    animation: pipo-rise linear both;
    animation-timeline: view();
  }
  .reveal-stagger > *:nth-child(1) { animation-range: entry 2%  cover 22%; }
  .reveal-stagger > *:nth-child(2) { animation-range: entry 6%  cover 26%; }
  .reveal-stagger > *:nth-child(3) { animation-range: entry 10% cover 30%; }
  .reveal-stagger > *:nth-child(4) { animation-range: entry 14% cover 34%; }
  .reveal-stagger > *:nth-child(5) { animation-range: entry 18% cover 38%; }
  .reveal-stagger > *:nth-child(6) { animation-range: entry 22% cover 42%; }
}

/* ------------------------------------------------------ pose cards --- */
.pose-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1.1rem;
  margin-top: 1.6rem;
}
.pose-card {
  background: var(--card, #fff);
  border: 1px solid rgba(120, 150, 190, .22);
  border-radius: 18px;
  padding: 1.1rem .9rem 1rem;
  text-align: center;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.pose-card img {
  width: 78px;
  height: auto;
  image-rendering: auto;
  margin-bottom: .5rem;
  transition: transform .3s cubic-bezier(.34, 1.56, .64, 1);
}
.pose-card h3 {
  font-size: .98rem;
  margin: .2rem 0 .3rem;
}
.pose-card p {
  font-size: .85rem;
  line-height: 1.55;
  margin: 0;
  opacity: .82;
}
/* Hovering a card makes that PIPO hop - the page reacts the way the robot does. */
.pose-card:hover,
.pose-card:focus-within {
  transform: translateY(-6px);
  border-color: rgba(34, 211, 238, .55);
  box-shadow: 0 16px 30px rgba(20, 50, 90, .14);
}
.pose-card:hover img,
.pose-card:focus-within img {
  animation: pipo-hop .55s ease;
}

/* ------------------------------------------------- personality dots --- */
.persona-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}
.persona-card {
  --accent: #22d3ee;
  position: relative;
  background: var(--card, #fff);
  border: 1px solid rgba(120, 150, 190, .22);
  border-left: 4px solid var(--accent);
  border-radius: 14px;
  padding: .95rem 1rem;
  transition: transform .22s ease, box-shadow .22s ease;
}
.persona-card:hover { transform: translateY(-4px); box-shadow: 0 14px 26px rgba(20, 50, 90, .13); }
.persona-card .dot {
  display: inline-block;
  width: .7rem; height: .7rem;
  border-radius: 50%;
  background: var(--accent);
  margin-right: .45rem;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}
.persona-card strong { font-size: .96rem; }
.persona-card p { margin: .4rem 0 0; font-size: .84rem; opacity: .8; line-height: 1.5; }

/* --------------------------------------------------------- respect --- */
/* Someone who has asked their system for less motion gets none of this. */
@media (prefers-reduced-motion: reduce) {
  .hero-art img.hero-robot,
  .hero-art-glow,
  .pose-card:hover img,
  .reveal, .reveal-left, .reveal-stagger > * {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .pose-card, .persona-card { transition: none; }
}


/* ===========================================================================
   Persona idle sprites
   ---------------------------------------------------------------------------
   Each strip is 8 idle frames side by side (768x96). steps(8) walks the
   background across them, so the card shows the same little breathing loop
   the desktop companion does - with no JavaScript, which this site's CSP
   forbids outright.

   The colour difference IS the point of this section: every persona wears
   its own eye and mouth colour, and these are the same values the firmware
   and the desktop app use, so nothing here is a lookalike.
   ======================================================================== */
@keyframes pipo-idle-play { to { background-position-x: -768px; } }

.pipo-idle {
  display: block;
  width: 96px;
  height: 96px;
  margin: 0 auto .35rem;
  background-repeat: no-repeat;
  background-size: 768px 96px;
  background-position: 0 0;
  animation: pipo-idle-play 1.6s steps(8) infinite;
  image-rendering: auto;
}
/* Cards stagger their timing a touch so six robots do not breathe in lockstep. */
.pipo-idle-sunny   { background-image: url('/assets/img/idle_sunny.png');   animation-duration: 1.55s; }
.pipo-idle-gentle  { background-image: url('/assets/img/idle_gentle.png');  animation-duration: 2.10s; }
.pipo-idle-tricky  { background-image: url('/assets/img/idle_tricky.png');  animation-duration: 1.35s; }
.pipo-idle-bashful { background-image: url('/assets/img/idle_bashful.png'); animation-duration: 1.95s; }
.pipo-idle-clingy  { background-image: url('/assets/img/idle_clingy.png');  animation-duration: 1.70s; }
.pipo-idle-aloof   { background-image: url('/assets/img/idle_aloof.png');   animation-duration: 2.40s; }

/* Hovering a personality card makes that PIPO perk up. */
.persona-card:hover .pipo-idle,
.persona-card:focus-within .pipo-idle { animation-duration: .85s; }

@media (prefers-reduced-motion: reduce) {
  .pipo-idle { animation: none; background-position: 0 0; }
}

/* ===========================================================================
   Feature card sprites
   ---------------------------------------------------------------------------
   The same frames the desktop companion plays, laid out as horizontal strips
   and stepped with CSS. steps(n) must match the frame count exactly or the
   loop slides half a robot into view, so the counts are written next to each
   rule rather than left to be rediscovered.
   ======================================================================== */
@keyframes strip8 { to { background-position-x: -768px; } }
@keyframes strip7 { to { background-position-x: -672px; } }

.pipo-strip {
  display: block;
  width: 96px;
  height: 96px;
  margin: 0 auto .5rem;
  background-repeat: no-repeat;
  background-size: auto 96px;
  background-position: 0 0;
}
.strip-wave   { background-image:url('/assets/img/strip_wave.png');   animation:strip8 1.5s steps(8) infinite; }
.strip-talk   { background-image:url('/assets/img/strip_talk.png');   animation:strip8 1.2s steps(8) infinite; }
.strip-love   { background-image:url('/assets/img/strip_love.png');   animation:strip8 1.7s steps(8) infinite; }
.strip-sleep  { background-image:url('/assets/img/strip_sleep.png');  animation:strip8 3.2s steps(8) infinite; }
.strip-bright { background-image:url('/assets/img/strip_bright.png'); animation:strip8 1.4s steps(8) infinite; }
.strip-walk   { background-image:url('/assets/img/strip_walk.png');   animation:strip8 0.9s steps(8) infinite; }
.strip-run    { background-image:url('/assets/img/strip_run.png');    animation:strip7 0.6s steps(7) infinite; }
.strip-dizzy  { background-image:url('/assets/img/strip_dizzy.png');  animation:strip8 1.1s steps(8) infinite; }

/* Hovering a card wakes that PIPO up rather than just tilting the card. */
.pose-card:hover  .pipo-strip,
.pose-card:focus-within .pipo-strip { animation-duration: .55s; }
/* The sleeper is the joke: it stays asleep no matter how much you hover. */
.pose-card:hover  .strip-sleep,
.pose-card:focus-within .strip-sleep { animation-duration: 3.2s; }

@media (prefers-reduced-motion: reduce) {
  .pipo-strip { animation: none; background-position: 0 0; }
}