/* ==================== AI demo (hero animation) ====================
   Two stories, told in turn (the first is picked at random per load), each
   ~11s: the ask is typed, ModuleSnap snaps it together out of modules that
   already exist, and it is used for real. Story "book": a booking page with
   a deposit that lands in a back office with its invoice. Story "surf": a
   surf school's dashboard — waves, wind and tide per beach, on a map.

   Default (no JS / reduced motion): the finished scene, already built.
   The .ai-run class (added by JS) hides the pieces so the timeline can
   reveal them one by one. */

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

.ai-demo {
  position: relative;
}

/* A story's pieces (its console text, its url, its screen) share one
   data-story; only the running one is shown. */
.ai-story:not(.on) {
  display: none !important;
}

.ai-screen > .ai-story {
  position: absolute;
  inset: 0;
}

/* ---------- Browser mockup ---------- */
.ai-browser {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  background: white;
}

.ai-browser-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 34px;
  padding: 0 12px;
  background: #f4f6f1;
  border-bottom: 1px solid var(--border-light);
}

.ai-dots {
  display: inline-flex;
  gap: 5px;
}

.ai-dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d9ded4;
}

.ai-url {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-alt);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 3px 12px;
  transition: color 0.3s, border-color 0.3s;
}

.ai-url b {
  font-weight: 600;
  color: var(--text);
}

.ai-url.on {
  color: var(--primary);
  border-color: var(--primary);
}

.ai-url.on b { color: var(--primary); }

.ai-url .ai-url-admin { display: none; }

.ai-url.to-admin .ai-url-public { display: none; }

.ai-url.to-admin .ai-url-admin { display: inline; }

.ai-screen {
  position: relative;
  aspect-ratio: 1200 / 650;
  background: var(--bg);
  overflow: hidden;
}

.ai-scene {
  position: absolute;
  inset: 0;
}

/* ---------- Scene 1: the booking page the agent builds ---------- */
.ai-band {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 30%;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary-light));
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: opacity 0.45s, transform 0.45s;
}

.ai-band-mark {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}

.ai-band-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* The card lives to the right of the console's footprint, so the two never
   fight for the same pixels while the agent is working. */
.ai-card {
  position: absolute;
  top: 22%;
  left: 63%;
  transform: translateX(-50%);
  width: 52%;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  transition: opacity 0.45s, transform 0.45s, visibility 0.45s;
}

.ai-step {
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: opacity 0.4s, transform 0.4s;
}

.ai-step label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-light);
}

.ai-slots {
  display: flex;
  gap: 7px;
}

.ai-slots i {
  flex: 1;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 11px;
  font-weight: 600;
  font-style: normal;
  color: var(--text-muted);
  background: var(--bg);
  transition: all 0.2s;
}

.ai-slots i.picked {
  background: var(--primary-subtle);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.ai-input {
  display: flex;
  align-items: center;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0 10px;
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
}

.ai-paybtn {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: white;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  transition: opacity 0.4s, transform 0.15s, background 0.15s;
}

.ai-paybtn.press {
  transform: scale(0.96);
  background: var(--primary-dark);
}

/* The console is already out of the way when this shows, so it sits centred. */
.ai-done {
  position: absolute;
  top: 28%;
  left: 50%;
  transform: translateX(-50%) scale(0.94);
  width: 52%;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s, transform 0.4s, visibility 0.4s;
}

.ai-done.on {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) scale(1);
}

.ai-check {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--success-light);
  color: var(--success-dark);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 5px;
}

.ai-done strong {
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--secondary);
}

.ai-done span {
  font-size: 11px;
  color: var(--text-muted);
}

/* ---------- Scene 2: the back office it came with ---------- */
.ai-admin {
  display: flex;
  background: var(--bg);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s, visibility 0.5s;
}

.ai-admin.on {
  opacity: 1;
  visibility: visible;
}

.ai-admin-side {
  width: 25%;
  background: white;
  border-right: 1px solid var(--border-light);
  padding: 13px 7px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ai-admin-logo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  padding: 0 8px;
  margin-bottom: 11px;
}

.ai-admin-logo::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--primary);
  flex-shrink: 0;
}

.ai-admin-side i {
  font-size: 10px;
  font-style: normal;
  color: var(--text-muted);
  padding: 5px 8px;
  border-radius: 6px;
}

.ai-admin-side i.ai-side-on {
  background: var(--primary-subtle);
  color: var(--primary);
  font-weight: 600;
}

.ai-admin-main {
  flex: 1;
  padding: 14px 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.ai-admin-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-admin-top strong {
  font-family: var(--font-display);
  font-size: 13.5px;
  color: var(--secondary);
  letter-spacing: -0.01em;
}

.ai-chip {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--primary);
  background: var(--primary-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  transition: transform 0.2s;
}

.ai-chip.pop {
  transform: scale(1.12);
}

.ai-admin-rows {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.ai-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text);
  border-top: 1px solid var(--border-light);
}

.ai-row:first-child {
  border-top: none;
}

.ai-row .ai-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-light);
}

.ai-row .ai-doc {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-light);
}

.ai-row em {
  font-style: normal;
  font-size: 9px;
  font-weight: 600;
  color: var(--success-dark);
  background: var(--success-light);
  border-radius: 999px;
  padding: 1.5px 8px;
}

@keyframes aiRowSettle {
  from { background: var(--success-light); }
  to { background: white; }
}

.ai-row-new.on {
  animation: aiRowSettle 2.4s ease-out forwards;
}

.ai-admin-toast {
  position: absolute;
  top: 11px;
  right: 11px;
  display: flex;
  align-items: center;
  gap: 7px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  padding: 8px 11px;
  font-size: 10.5px;
  color: var(--text);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity 0.35s, transform 0.35s, visibility 0.35s;
}

.ai-admin-toast::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.ai-admin-toast.on {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}


/* ---------- Story "surf": the dashboard, waves and wind on a map ---------- */
.ai-sf {
  display: flex;
  background: var(--bg);
}

.ai-sf-side {
  width: 22%;
}

.ai-sf-main {
  padding: 11px 13px 12px;
  gap: 8px;
}

.ai-sf-top {
  justify-content: space-between;
}

.ai-sf-days {
  display: flex;
  gap: 4px;
}

.ai-sf-days i {
  font-size: 8.5px;
  font-style: normal;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  background: white;
  transition: all 0.2s;
}

.ai-sf-days i.ai-sf-day-on {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-subtle);
  font-weight: 600;
}

.ai-sf-best {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.ai-sf-spot {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  min-width: 0;
  transition: opacity 0.4s, transform 0.4s;
}

.ai-sf-spot b {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 400;
}

.ai-sf-spot span {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.ai-sf-spot strong {
  font-family: var(--font-display);
  font-size: 10.5px;
  color: var(--secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-sf-spot em {
  font-style: normal;
  font-size: 8px;
  font-weight: 600;
  color: var(--text-muted);
}

.ai-sf-spot small {
  font-size: 8px;
  color: var(--text-light);
  white-space: nowrap;
}

.ai-sf-blue { background: linear-gradient(135deg, #eaf2ff, white 70%); }
.ai-sf-blue b { background: #dbe8ff; color: #2f62d8; }
.ai-sf-green { background: linear-gradient(135deg, #e6f6eb, white 70%); }
.ai-sf-green b { background: #d5f0dd; color: #1f8f4a; }
.ai-sf-amber { background: linear-gradient(135deg, #fff5dd, white 70%); }
.ai-sf-amber b { background: #ffeab8; color: #c07a10; }

.ai-sf-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 8px;
}

.ai-sf-map,
.ai-sf-table {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 0;
  overflow: hidden;
  transition: opacity 0.45s, transform 0.45s;
}

.ai-sf-map {
  position: relative;
  padding: 6px;
}

.ai-sf-map svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ai-sf-land {
  fill: #eef4ee;
  stroke: #cfdccf;
  stroke-width: 0.6;
}

.ai-sf-pin {
  fill: white;
  stroke: var(--secondary);
  stroke-width: 1.4;
}

.ai-sf-pin-a,
.ai-sf-pin-b {
  stroke: #2f62d8;
}

.ai-sf-pin-go {
  stroke: var(--primary);
}

.ai-sf-pin.lit {
  fill: var(--primary);
  stroke: var(--primary);
}

.ai-sf-tip rect {
  fill: white;
  stroke: var(--primary);
  stroke-width: 0.6;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.12));
}

.ai-sf-tip text {
  font-family: var(--font-body);
  font-size: 4.6px;
  fill: var(--text-muted);
}

.ai-sf-tip text.ai-sf-tip-h {
  font-size: 5.4px;
  font-weight: 700;
  fill: var(--secondary);
}

/* Without JS the first tooltip is part of the finished frame. */
.ai-sf-tip {
  opacity: 0;
  transition: opacity 0.3s;
}

.ai-sf-tip.on {
  opacity: 1;
}

.ai-sf-table {
  padding: 4px 10px 0;
  font-size: 9px;
  color: var(--text);
}

.ai-sf-thead,
.ai-sf-row {
  display: grid;
  grid-template-columns: 1.9fr 0.8fr 1.1fr 0.85fr;
  gap: 6px;
  padding: 5px 0;
  border-top: 1px solid var(--border-light);
}

.ai-sf-thead {
  border-top: none;
  padding-bottom: 4px;
}

.ai-sf-thead b {
  font-size: 7.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-light);
}

.ai-sf-row span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-sf-row span:first-child {
  font-weight: 600;
  color: var(--secondary);
}

.ai-run .ai-sf-side,
.ai-run .ai-sf-top,
.ai-run .ai-sf-spot,
.ai-run .ai-sf-map,
.ai-run .ai-sf-table {
  opacity: 0;
  transform: translateY(7px);
}

.ai-run .ai-sf-side.on,
.ai-run .ai-sf-top.on,
.ai-run .ai-sf-spot.on,
.ai-run .ai-sf-map.on,
.ai-run .ai-sf-table.on {
  opacity: 1;
  transform: translateY(0);
}

.ai-run .ai-sf-side,
.ai-run .ai-sf-top {
  transition: opacity 0.4s, transform 0.4s;
}

/* ---------- The prompt console ---------- */
.ai-console {
  position: absolute;
  left: -22px;
  bottom: -22px;
  width: 252px;
  max-width: 92%;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(12, 18, 16, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-xl);
  z-index: 2;
}

.ai-console-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.ai-console-bar .ai-dots i {
  background: rgba(255, 255, 255, 0.18);
  width: 7px;
  height: 7px;
}

.ai-console-title {
  font-family: var(--font-mono);
  font-size: 10px;
  color: #8a9389;
}

.ai-console-done {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--volt);
  opacity: 0;
  transition: opacity 0.3s;
}

.ai-console-done.on {
  opacity: 1;
}

.ai-console-body {
  padding: 11px 12px 13px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  line-height: 1.6;
  color: #cfd6cf;
  max-height: 240px;
  transition: max-height 0.45s ease, padding 0.45s ease, opacity 0.45s ease;
}

.ai-console.min .ai-console-body {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
}

.ai-prompt {
  color: #f2f5f0;
  min-height: 2.1em;
}

.ai-prompt b {
  color: var(--volt);
  font-weight: 600;
  margin-right: 3px;
}

.ai-caret {
  display: none;
  width: 6px;
  height: 12px;
  background: var(--volt);
  vertical-align: -2px;
  margin-left: 1px;
}

@keyframes aiBlink {
  50% { opacity: 0; }
}

.ai-run .ai-caret {
  display: inline-block;
  animation: aiBlink 1s step-end infinite;
}

.ai-run .ai-caret.off {
  display: none;
}

.ai-lines {
  margin-top: 9px;
}

@keyframes aiLineIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-lines p {
  margin: 3px 0 0;
  color: #e6ebe4;
}

.ai-lines b {
  color: var(--volt);
  font-weight: 400;
  margin-right: 5px;
}

.ai-lines i {
  font-style: normal;
  color: #8a9389;
}

.ai-lines .ai-ok {
  color: var(--volt);
  margin-top: 8px;
}

/* ---------- Run state: hide everything the timeline reveals ---------- */
.ai-run .ai-band,
.ai-run .ai-step,
.ai-run .ai-paybtn {
  opacity: 0;
  transform: translateY(7px);
}

.ai-run .ai-band.on,
.ai-run .ai-step.on,
.ai-run .ai-paybtn.on {
  opacity: 1;
  transform: translateY(0);
}

.ai-run .ai-card {
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(7px);
}

.ai-run .ai-card.on {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%);
}

.ai-run .ai-card.off {
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(-6px);
}

.ai-run .ai-lines p {
  display: none;
}

.ai-run .ai-lines p.on {
  display: block;
  animation: aiLineIn 0.35s ease-out;
}

.ai-run .ai-row-new {
  opacity: 0;
}

.ai-run .ai-row-new.on {
  opacity: 1;
}

.ai-run .ai-console-done {
  opacity: 0;
}

.ai-run .ai-console-done.on {
  opacity: 1;
}

/* Whole-screen fade used when the loop resets */
.ai-screen-fade .ai-scene {
  transition: opacity 0.35s;
  opacity: 0 !important;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .ai-demo {
    max-width: 640px;
    margin: 0 auto;
  }
}

/* On a phone there is no room to float the console over the page, so it drops
   below the browser into space the demo reserves — no overlap, no layout jump
   when it collapses. */
@media (max-width: 768px) {
  .ai-console {
    position: static;
    width: auto;
    max-width: 100%;
    margin-top: 10px;
  }

  /* Down here it covers nothing, so it never gets out of the way either —
     collapsing it would only make the block below jump on every loop. */
  .ai-console.min .ai-console-body {
    max-height: 240px;
    padding-top: 11px;
    padding-bottom: 13px;
    opacity: 1;
  }

  .ai-console-body {
    font-size: 9px;
  }

  .ai-card {
    left: 50%;
    width: 78%;
  }

  .ai-done {
    width: 78%;
  }
}
