/* EXIMIA — /ai-systems (v3). Loaded after styles.css + v3.css.
   Concept: "una capa de inteligencia sobre tu operación real". Every scene is a
   black & white Higgsfield photo plus its digital twin (the same frame drawn as
   white lines on black); ai-systems.js wipes from one to the other as the scene
   crosses the viewport. The hero loop does the same with the corridor. Calm by
   design (owner, 2026-09-30): no pinned films, no HUDs, no flashes. */

.hx-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.ais-kicker {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.ais-kicker + .hx-h3 {
  margin-top: 0.6rem;
}

/* v3's .hx-tile p would otherwise size the tile kickers like body copy */
.hx-tile .ais-kicker {
  margin-top: 0;
  font-size: 0.7rem;
  line-height: 1.6;
}

/* quiet entrances (only when the script will reveal them) */
.hx-js:not(.hx-reduced) [data-ais-reveal] {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 1s var(--hx-ease), transform 1s var(--hx-ease);
}

.hx-js:not(.hx-reduced) [data-ais-reveal].is-in {
  opacity: 1;
  transform: none;
}

/* ═══════════════════════════════════════════════════════
   HERO — the corridor and its digital twin
   ═══════════════════════════════════════════════════════ */
.ais-hero {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: flex-end;
  min-height: 100vh;
  min-height: 100svh;
  padding-top: 7.5rem;
  /* clears the chat bubble fixed along the bottom edge */
  padding-bottom: calc(6.75rem + env(safe-area-inset-bottom, 0px));
  overflow: hidden;
  background: var(--bg-primary);
}

.ais-hero__media {
  position: absolute;
  inset: 0;
  z-index: -1;
}

.ais-hero__media img,
.ais-hero__video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ais-hero__video {
  opacity: 0;
  transition: opacity 1.2s;
}

.ais-hero__video.is-playing {
  opacity: 1;
}

.ais-hero__shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(var(--hx-ink), 0.55) 0%, rgba(var(--hx-ink), 0.15) 16%, rgba(var(--hx-ink), 0.6) 30%, rgba(var(--hx-ink), 0.9) 48%, var(--bg-primary) 100%);
}

.ais-hero__copy {
  position: relative;
}

.ais-hero .hx-h1 {
  max-width: 13ch;
}

.ais-hero .hx-lead {
  color: rgba(var(--hx-paper), 0.8);
}

/* the copy sits over light concrete: the grey half and the eyebrow a little brighter than elsewhere */
.ais-hero .hx-grad {
  color: rgba(var(--hx-paper), 0.66);
}

.ais-hero .hx-eyebrow {
  color: rgba(var(--hx-paper), 0.8);
}

.ais-hero .hx-actions {
  margin-top: 2rem;
}

@keyframes ais-in {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .ais-hero__copy > * {
    animation: ais-in 0.9s var(--hx-ease) both;
  }

  .ais-hero__copy > *:nth-child(2) { animation-delay: 0.08s; }
  .ais-hero__copy > *:nth-child(3) { animation-delay: 0.16s; }
  .ais-hero__copy > *:nth-child(4) { animation-delay: 0.24s; }
}

/* view label + pause button: under the nav on phones, above the chat bubble on wider screens */
.ais-hero__hud {
  position: absolute;
  top: calc(5.75rem + env(safe-area-inset-top, 0px));
  right: var(--hx-gutter);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ais-hero__view {
  min-width: 13.5em;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-secondary);
  text-shadow: 0 0 12px rgba(var(--hx-ink), 0.9);
  opacity: 0;
  transition: opacity 0.6s;
}

.ais-hero__view.is-on {
  opacity: 1;
}

.ais-motion {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(var(--hx-paper), 0.35);
  background: rgba(var(--hx-ink), 0.35);
  color: var(--text-primary);
  cursor: pointer;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: border-color 0.3s;
}

.ais-motion[hidden] {
  display: none;
}

.ais-motion:hover {
  border-color: var(--text-primary);
}

.ais-motion:focus-visible {
  outline: 2px solid var(--text-primary);
  outline-offset: 3px;
}

.ais-motion__icon {
  width: 10px;
  height: 12px;
  border-inline: 3px solid currentColor;
}

.ais-motion[aria-pressed="true"] .ais-motion__icon {
  width: 0;
  height: 0;
  border-inline: 0;
  border-left: 10px solid currentColor;
  border-block: 6px solid transparent;
}

/* ═══════════════════════════════════════════════════════
   MANIFESTO (white band)
   ═══════════════════════════════════════════════════════ */
.ais-manifesto .hx-h2 {
  max-width: 16ch;
  font-size: clamp(2.3rem, 9vw, 5.4rem);
}

.ais-manifesto .hx-lead {
  margin-top: 1.6rem;
  max-width: 44rem;
}

/* ═══════════════════════════════════════════════════════
   CONSOLE — an agent run drawn as product UI (illustrative)
   A dark panel on the white band: it resets the tokens the band flipped.
   ═══════════════════════════════════════════════════════ */
.ais-console {
  --hx-ink: 0, 0, 0;
  --hx-paper: 255, 255, 255;
  --text-primary: rgb(var(--hx-paper));
  --text-secondary: rgba(var(--hx-paper), 0.7);
  --hx-line: rgba(var(--hx-paper), 0.12);
  margin: clamp(2.75rem, 7vw, 4.5rem) 0 0;
  background: rgb(var(--hx-ink));
  color: var(--text-primary);
  border: 1px solid rgba(var(--hx-ink), 1);
  box-shadow: 0 30px 80px -40px rgba(var(--hx-ink), 0.55);
  font-size: 0.9rem;
}

.ais-console__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  min-height: 48px;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--hx-line);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.ais-console__dot {
  width: 7px;
  height: 7px;
  background: var(--text-primary);
}

.ais-console__tag {
  margin-left: auto;
  padding: 0.2rem 0.5rem;
  border: 1px solid rgba(var(--hx-paper), 0.25);
  color: var(--text-secondary);
}

.ais-console__replay {
  min-height: 32px;
  padding: 0 0.7rem;
  border: 1px solid rgba(var(--hx-paper), 0.4);
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.ais-console__replay[hidden] {
  display: none;
}

.ais-console__replay:hover {
  border-color: var(--text-primary);
}

.ais-console__replay:focus-visible {
  outline: 2px solid var(--text-primary);
  outline-offset: 2px;
}

.ais-console__body {
  display: grid;
}

.ais-console__pane {
  padding: 1.1rem 1rem 1.25rem;
  min-width: 0;
}

.ais-console__pane + .ais-console__pane {
  border-top: 1px solid var(--hx-line);
}

.ais-console__head {
  margin-bottom: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* objects: key / value rows */
.ais-console__objects dl {
  display: grid;
  gap: 0.5rem 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ais-console__objects dt {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.ais-console__objects dd {
  margin: 0.15rem 0 0;
  font-weight: 500;
}

/* run: one row per tool call */
.ais-console__run ol,
.ais-console__log ol {
  list-style: none;
}

.ais-console__run li {
  position: relative;
  padding: 0.6rem 0 0.6rem 1.6rem;
  border-top: 1px solid var(--hx-line);
}

.ais-console__run li:first-child {
  border-top: 0;
  padding-top: 0;
}

/* state glyph: a square that fills once the step is done */
.ais-console__run li::before {
  content: "";
  position: absolute;
  left: 0.1rem;
  top: 0.95rem;
  width: 8px;
  height: 8px;
  border: 1px solid var(--text-primary);
  background: var(--text-primary);
}

.ais-console__run li:first-child::before {
  top: 0.35rem;
}

.ais-console__run code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-primary);
}

.ais-console__run p {
  margin-top: 0.2rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.ais-console__run .is-gate code::after {
  content: "Requerida";
  margin-left: 0.6rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid rgba(var(--hx-paper), 0.4);
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  vertical-align: 1px;
}

/* log: timestamps */
.ais-console__log li {
  display: flex;
  gap: 0.75rem;
  padding: 0.3rem 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.ais-console__log li span {
  color: var(--text-primary);
}

.ais-console figcaption {
  padding: 0.9rem 1rem 1rem;
  border-top: 1px solid var(--hx-line);
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

/* live: pending steps wait dimmed, the current one is outlined, done ones are filled */
.hx-js:not(.hx-reduced) .ais-console.is-live [data-step] {
  transition: opacity 0.5s var(--hx-ease);
}

.hx-js:not(.hx-reduced) .ais-console.is-live [data-step]:not(.is-on) {
  opacity: 0.2;
}

.hx-js:not(.hx-reduced) .ais-console.is-live .ais-console__run li:not(.is-on)::before {
  background: transparent;
}

/* the step being worked on (e.g. waiting for the approval) is lit, its square still open */
.hx-js:not(.hx-reduced) .ais-console.is-live .ais-console__run li.is-current {
  opacity: 1;
}

/* ═══════════════════════════════════════════════════════
   SCENES — real photo / digital twin, wiped by scroll
   ═══════════════════════════════════════════════════════ */
.ais-scenes {
  display: grid;
  gap: clamp(3rem, 9vw, 6.5rem);
}

.ais-scene {
  display: grid;
  gap: 1.5rem;
  align-items: center;
}

.ais-lens {
  /* share of the frame showing the twin, from the right edge; 0.5 without JS / reduced motion */
  --wipe: 0.5;
  position: relative;
  margin: 0;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-secondary);
  border: 1px solid var(--hx-line-strong);
}

.ais-lens img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ais-lens__twin {
  clip-path: inset(0 0 0 calc((1 - var(--wipe)) * 100%));
}

.ais-lens__edge {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc((1 - var(--wipe)) * 100%);
  width: 1px;
  background: rgba(var(--hx-paper), 0.85);
  pointer-events: none;
}

.ais-lens.is-js .ais-lens__edge {
  left: 0;
  transform: translateX(var(--edge-x, 0px));
  will-change: transform;
}

.ais-lens__edge i {
  position: absolute;
  top: 0.75rem;
  left: 0.6rem;
  padding: 0.3rem 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-style: normal;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--text-primary);
  background: rgba(var(--hx-ink), 0.72);
}

.ais-lens__edge i {
  transition: opacity 0.4s;
}

/* the label names the twin side; it steps out while that side is too narrow to hold it */
.ais-lens.is-narrow .ais-lens__edge i {
  opacity: 0;
}

.ais-scene__title {
  margin-top: 0.6rem;
  font-family: var(--hx-display);
  font-size: clamp(1.7rem, 5.6vw, 2.6rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.04em;
  color: var(--text-primary);
  text-wrap: balance;
}

.ais-scene__copy > p:not(.ais-kicker) {
  margin-top: 0.9rem;
  max-width: 30rem;
  font-size: clamp(1rem, 2.6vw, 1.1rem);
  line-height: 1.65;
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════
   HOW TO START
   ═══════════════════════════════════════════════════════ */
.ais-start {
  display: flex;
  flex-direction: column;
}

.ais-start .hx-actions {
  margin-top: auto;
  padding-top: 1.6rem;
}

/* ═══════════════════════════════════════════════════════
   CLOSING — over the corridor's twin
   ═══════════════════════════════════════════════════════ */
.ais-closing {
  overflow: hidden;
  isolation: isolate;
}

.ais-closing__media {
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0.32;
}

.ais-closing__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ais-closing__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--bg-primary) 0%, rgba(var(--hx-ink), 0.6) 55%, rgba(var(--hx-ink), 0.2) 100%);
}

/* ═══════════════════════════════════════════════════════
   Phones
   ═══════════════════════════════════════════════════════ */
@media (max-width: 559px) {
  /* the two hero buttons share one row */
  .ais-hero .hx-actions .hx-btn {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: 0.9rem;
    gap: 0.5rem;
  }
}

/* short portrait phones (iPhone SE, foldable cover screens) */
@media (max-width: 767px) and (max-height: 700px) {
  .ais-hero {
    padding-top: 7rem;
  }

  .ais-hero .hx-eyebrow {
    display: none;
  }

  .ais-hero .hx-h1 {
    margin-top: 0;
    font-size: clamp(2.3rem, 10.5vw, 3rem);
  }

  .ais-hero .hx-lead {
    font-size: 0.95rem;
  }

  .ais-hero .hx-actions {
    margin-top: 1.4rem;
  }
}

/* ═══════════════════════════════════════════════════════
   ≥ 768px
   ═══════════════════════════════════════════════════════ */
@media (min-width: 768px) {
  .ais-hero {
    align-items: center;
    padding-top: 9rem;
  }

  .ais-hero__shade {
    background:
      linear-gradient(90deg, rgba(var(--hx-ink), 0.95) 0%, rgba(var(--hx-ink), 0.9) 40%, rgba(var(--hx-ink), 0.55) 60%, rgba(var(--hx-ink), 0.15) 76%, rgba(var(--hx-ink), 0) 88%),
      linear-gradient(180deg, rgba(var(--hx-ink), 0.5) 0%, rgba(var(--hx-ink), 0) 22%, rgba(var(--hx-ink), 0) 76%, var(--bg-primary) 100%);
  }

  /* the copy stays on the dark side of the shade, also on near-square screens */
  .ais-hero__copy > * {
    max-width: min(38rem, 54vw);
  }

  .ais-hero .hx-h1 {
    max-width: 12ch;
    font-size: clamp(3rem, 5.8vw, 5.6rem);
  }

  .ais-hero__hud {
    top: auto;
    bottom: calc(7.5rem + env(safe-area-inset-bottom, 0px));
  }
}

/* portrait tablets / unfolded foldables held upright: copy on the floor, like phones */
@media (min-width: 768px) and (max-aspect-ratio: 7/8) {
  .ais-hero {
    align-items: flex-end;
  }

  .ais-hero__shade {
    background:
      linear-gradient(180deg, rgba(var(--hx-ink), 0.55) 0%, rgba(var(--hx-ink), 0.12) 20%, rgba(var(--hx-ink), 0.5) 40%, rgba(var(--hx-ink), 0.9) 62%, var(--bg-primary) 100%);
  }
}

@media (min-width: 900px) {
  .ais-console__body {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.6fr) minmax(0, 1fr);
  }

  .ais-console__pane + .ais-console__pane {
    border-top: 0;
    border-left: 1px solid var(--hx-line);
  }

  .ais-console__objects dl {
    grid-template-columns: 1fr;
    gap: 0.9rem;
  }

  .ais-console__pane {
    padding: 1.4rem 1.4rem 1.6rem;
  }

  .ais-scene {
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
    gap: clamp(2.5rem, 5vw, 4.5rem);
  }

  .ais-scene:nth-child(even) {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr);
  }

  .ais-scene:nth-child(even) .ais-lens {
    order: 2;
  }
}

/* short screens from 768px wide (landscape tablets, small laptops): headline sized by height */
@media (min-width: 768px) and (max-height: 820px) {
  .ais-hero {
    padding-top: 8rem;
  }

  .ais-hero .hx-h1 {
    max-width: 14ch;
    font-size: clamp(2.6rem, min(7vw, 8.5vh), 5rem);
  }
}

/* short wide screens (unfolded foldables, landscape phones): the hero fits the viewport */
@media (orientation: landscape) and (max-height: 640px) {
  .ais-hero {
    align-items: flex-start;
    padding-top: 6.5rem;
    padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
  }

  .ais-hero__copy > * {
    max-width: min(34rem, 54vw);
  }

  .ais-hero .hx-eyebrow {
    display: none;
  }

  .ais-hero .hx-h1 {
    margin-top: 0;
    max-width: 20ch;
    font-size: clamp(2rem, 9vh, 3.4rem);
  }

  .ais-hero .hx-lead {
    margin-top: 0.8rem;
    font-size: 0.95rem;
  }

  .ais-hero .hx-actions {
    margin-top: 1.4rem;
  }

  /* the buttons keep one row even when the copy column is narrow */
  .ais-hero__copy > .hx-actions {
    max-width: none;
    flex-wrap: nowrap;
  }

  .ais-hero__hud {
    top: auto;
    bottom: 1.5rem;
    right: calc(var(--hx-gutter) + 4.75rem);
  }
}

/* the smallest landscape phones (568×320): tighter, so the buttons end above the chat bubble */
@media (orientation: landscape) and (max-height: 340px) {
  .ais-hero {
    padding-top: 5.5rem;
  }

  .ais-hero .hx-actions {
    margin-top: 0.9rem;
  }

  .ais-hero .hx-actions .hx-btn {
    min-height: 44px;
  }
}

/* landscape phones: headline + buttons only */
@media (orientation: landscape) and (max-height: 480px) {
  .ais-hero .hx-lead {
    display: none;
  }
}

/* ═══════════════════════════════════════════════════════
   Reduced motion — nothing moves (the lenses stay split in half)
   ═══════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .ais-hero__video,
  .ais-hero__view,
  [data-ais-reveal] {
    transition: none;
  }
}
