/* ============================================================================
   SARA — COMPONENT KIT
   Buttons · presence · cards · stats · chat bubbles · iPhone frame · widget.
   Everything tokens-driven. Shared by index.html / hosts.html / contact.html.
   ========================================================================== */

/* --- Buttons ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  font-family: var(--font-sans); font-size: var(--text-lg); font-weight: var(--weight-bold);
  padding: 0.8em 1.6em; border-radius: var(--radius-full);
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: transform var(--dur-fast) var(--ease-spring),
              box-shadow var(--dur-base) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--color-primary); color: #FFFFFF; box-shadow: var(--shadow-glow-primary); }
.btn-primary:hover { background: var(--color-primary-strong); transform: translateY(-2px); }
.btn-secondary { background: transparent; color: var(--color-text); border-color: var(--color-border-strong); }
.btn-secondary:hover { border-color: var(--ink-500); transform: translateY(-2px); }
.btn-ghost { background: transparent; color: var(--color-primary-text); }
.btn-ghost:hover { background: var(--color-primary-wash); }
.btn-sm { font-size: var(--text-sm); padding: 0.65em 1.3em; }
.btn-lg { font-size: var(--text-xl); padding: 0.9em 1.9em; }
.section-dark .btn-secondary { color: var(--color-text-inverse); border-color: var(--ink-300); }
.section-dark .btn-secondary:hover { border-color: var(--color-text-inverse); }

/* --- Presence dot — the brand bug ------------------------------------------ */
.presence {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  color: var(--color-online-text);
}
.presence i {
  width: 0.55rem; height: 0.55rem; border-radius: var(--radius-full);
  background: var(--color-online); flex: none;
  animation: breathe 2.6s var(--ease-in-out) infinite;
}
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-online) 35%, transparent); }
  50%      { box-shadow: 0 0 0 6px color-mix(in srgb, var(--color-online) 0%, transparent); }
}
.section-dark .presence { color: #5BD693; }

/* --- Cards ------------------------------------------------------------------ */
.card {
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-base) var(--ease-spring), box-shadow var(--dur-base) var(--ease-out);
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.card .tag {
  display: inline-block; font-size: var(--text-xs); font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-caps); text-transform: uppercase;
  color: var(--color-secondary-text); background: var(--color-secondary-wash);
  padding: var(--space-1) var(--space-3); border-radius: var(--radius-full);
  margin-bottom: var(--space-4);
}
.card .tag.tag-primary { color: var(--color-primary-text); background: var(--color-primary-wash); }
.card .tag.tag-online  { color: var(--color-online-text);  background: var(--color-online-wash); }
.card h3, .card h4 {
  font-family: var(--font-display); font-weight: var(--weight-display);
  font-size: var(--text-2xl); letter-spacing: var(--tracking-display);
  margin-bottom: var(--space-2);
}
.card p { color: var(--color-text-secondary); }

.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
@media (max-width: 880px) { .card-grid { grid-template-columns: 1fr; } }

/* --- Stat blocks -------------------------------------------------------------- */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4);
}
@media (max-width: 880px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { text-align: center; padding: var(--space-5) var(--space-3); }
.stat .num {
  font-family: var(--font-display); font-weight: var(--weight-display);
  font-size: var(--text-5xl); letter-spacing: var(--tracking-display);
  line-height: 1.05; color: var(--color-primary-text);
  font-variant-numeric: tabular-nums;
}
.stat .label {
  margin-top: var(--space-2);
  font-size: var(--text-sm); color: var(--color-text-muted);
  font-weight: var(--weight-medium);
}
.section-dark .stat .num { color: var(--tang-400); }
.section-dark .stat .label { color: var(--ink-300); }

/* --- Chat bubbles -------------------------------------------------------------- */
.chat { display: flex; flex-direction: column; gap: var(--space-3); }
.bubble {
  position: relative; max-width: 85%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm); line-height: 1.5;
  box-shadow: var(--shadow-xs);
  overflow-wrap: break-word;
}
.bubble .time {
  display: block; margin-top: var(--space-1);
  font-size: 0.6875rem; color: var(--color-text-muted); text-align: right;
}
.bubble-guest {
  align-self: flex-end;
  background: var(--chat-bubble-guest); color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg);
}
.bubble-sara {
  align-self: flex-start;
  background: var(--chat-bubble-sara); color: var(--chat-bubble-sara-text);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-sm);
}
.bubble-sara .from {
  display: flex; align-items: center; gap: var(--space-2);
  font-weight: var(--weight-bold); font-size: var(--text-xs);
  color: var(--color-primary-text); margin-bottom: var(--space-1);
}
.bubble-sara .from i {
  width: 0.45rem; height: 0.45rem; border-radius: var(--radius-full);
  background: var(--color-online);
}
.bubble-sara a { color: var(--color-primary-text); font-weight: var(--weight-bold); }

.bubble.pop { animation: pop var(--dur-slow) var(--ease-spring) both; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.96); } to { opacity: 1; transform: none; } }

/* Typing indicator */
.typing {
  align-self: flex-start; display: inline-flex; gap: 4px;
  background: var(--chat-bubble-sara);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-sm);
}
.typing i {
  width: 6px; height: 6px; border-radius: var(--radius-full);
  background: var(--tang-400); animation: ty 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes ty { 0%, 60%, 100% { transform: none; opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }

/* --- iPhone frame ----------------------------------------------------------------
   <div class="phone"><div class="island"></div><div class="screen">…</div></div>
   ------------------------------------------------------------------------------- */
.phone {
  width: min(21rem, 100%); margin-inline: auto;
  background: var(--color-bg-dark);
  border-radius: var(--radius-2xl);
  padding: var(--space-3);
  box-shadow: var(--shadow-lg);
  position: relative;
}
.phone .island {
  position: absolute; top: calc(var(--space-3) + 8px); left: 50%;
  transform: translateX(-50%);
  width: 6.4rem; height: 1.5rem; border-radius: var(--radius-full);
  background: var(--color-bg-dark); z-index: 2;
}
.phone .screen {
  background: var(--grey-100);
  border-radius: calc(var(--radius-2xl) - var(--space-3));
  overflow: hidden; display: flex; flex-direction: column;
  min-height: 35rem; max-height: 35rem;
}
[data-theme="dark"] .phone .screen { background: var(--color-bg-sunken); }
.phone .chat-head {
  display: flex; align-items: center; gap: var(--space-3);
  background: var(--color-bg-raised);
  padding: calc(var(--space-5) + 0.9rem) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  flex: none;
}
.phone .chat-head img { width: 2.4rem; height: 2.4rem; border-radius: var(--radius-full); }
.phone .chat-head .who strong { display: block; font-size: var(--text-sm); font-weight: var(--weight-bold); }
.phone .chat-head .who .presence { font-size: var(--text-xs); }
.phone .convo {
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-4); flex: 1; overflow-y: auto;
  scrollbar-width: none;
}
.phone .convo::-webkit-scrollbar { display: none; }
.phone .bubble { max-width: 88%; }
.phone .inputbar {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-4) var(--space-5);
  flex: none;
}
.phone .inputbar .field {
  flex: 1; background: var(--color-bg-raised); border: 1px solid var(--color-border);
  border-radius: var(--radius-full); padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm); color: var(--color-text-muted);
  white-space: nowrap; overflow: hidden;
}
.phone .inputbar .send {
  width: 2.25rem; height: 2.25rem; flex: none; border-radius: var(--radius-full);
  background: var(--color-online); border: none; cursor: default;
  display: grid; place-items: center; color: #FFFFFF;
  font-size: var(--text-base); line-height: 1;
}

/* Floating glow behind the hero phone */
.phone-stage { position: relative; }
.phone-stage::before {
  content: ""; position: absolute; inset: 8% -6% -4% -6%;
  background:
    radial-gradient(42% 46% at 64% 36%, color-mix(in srgb, var(--tang-200) 55%, transparent), transparent 70%),
    radial-gradient(34% 38% at 30% 72%, color-mix(in srgb, var(--green-100) 80%, transparent), transparent 72%);
  filter: blur(8px);
  z-index: -1; border-radius: 50%;
}

/* --- Interactive chat widget ("Try Sara") --------------------------------------- */
.sara-widget {
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  display: flex; flex-direction: column;
  max-width: 34rem; margin-inline: auto;
  overflow: hidden;
}
.sara-widget .head {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}
.sara-widget .head img { width: 2.6rem; height: 2.6rem; border-radius: var(--radius-full); }
.sara-widget .head strong { display: block; font-size: var(--text-base); }
.sara-widget .log {
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-5);
  height: 21rem; overflow-y: auto;
  background: var(--color-bg-sunken);
}
.sara-widget form {
  display: flex; gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
}
.sara-widget input {
  flex: 1; border: 1px solid var(--color-border); background: var(--color-bg-sunken);
  border-radius: var(--radius-full); padding: var(--space-3) var(--space-4);
  font-family: var(--font-sans); font-size: var(--text-base); color: var(--color-text);
}
.sara-widget input:focus-visible { outline: 2px solid var(--color-focus-ring); outline-offset: 1px; }
.sara-widget button[type="submit"] {
  width: 3rem; height: 3rem; flex: none; border-radius: var(--radius-full);
  background: var(--color-primary); color: #fff; border: 0; cursor: pointer;
  font-size: var(--text-lg);
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-spring);
}
.sara-widget button[type="submit"]:hover { background: var(--color-primary-strong); }
.sara-widget button[type="submit"]:active { transform: scale(0.94); }
.sara-widget .hints {
  display: flex; gap: var(--space-2); flex-wrap: wrap;
  padding: 0 var(--space-5) var(--space-4);
  background: var(--color-bg-sunken);
}
.sara-widget .hints button {
  border: 1px solid var(--color-border); background: var(--color-bg-raised);
  border-radius: var(--radius-full); padding: var(--space-1) var(--space-3);
  font-family: var(--font-sans); font-size: var(--text-xs); font-weight: var(--weight-medium);
  color: var(--color-text-secondary); cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.sara-widget .hints button:hover { border-color: var(--tang-400); color: var(--color-primary-text); }

/* --- Channel pills (WhatsApp now · Airbnb/Booking coming) ----------------------- */
.channels { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }
.channel {
  display: inline-flex; align-items: center; gap: var(--space-2);
  border: 1px solid var(--color-border); border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm); font-weight: var(--weight-bold);
  background: var(--color-bg-raised);
}
.channel.live { border-color: color-mix(in srgb, var(--color-online) 45%, transparent); }
.channel .soon {
  font-size: var(--text-xs); font-weight: var(--weight-bold);
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--color-primary-text); background: var(--color-primary-wash);
  border-radius: var(--radius-full); padding: 2px 8px;
}

/* --- Steps (numbered onboarding) ------------------------------------------------ */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); counter-reset: step; }
@media (max-width: 880px) { .steps { grid-template-columns: 1fr; } }
.step { position: relative; padding: var(--space-6); border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-bg-raised); }
.step::before {
  counter-increment: step; content: counter(step, decimal-leading-zero);
  font-family: var(--font-display); font-weight: var(--weight-display);
  font-size: var(--text-3xl); color: var(--tang-400);
  display: block; margin-bottom: var(--space-3);
}
.step h3 { font-size: var(--text-xl); margin-bottom: var(--space-2); }
.step p { font-size: var(--text-sm); color: var(--color-text-secondary); }

/* ============================================================================
   RESPONSIVE REFINEMENTS — component layer (tablet + mobile)
   ========================================================================== */

/* Tablet portrait (3-up grids of 3 items read better as 1 column than a 2+1
   orphan, so we keep them single — but tighten the gap and cap card width). */
@media (max-width: 880px) {
  .card-grid, .tough-grid, .steps { gap: var(--space-3); }
}

/* Phones */
@media (max-width: 600px) {
  /* Primary CTA goes full-width for thumb reach; secondary sits below it */
  .hero .cta-row .btn,
  .final-cta .cta-row .btn { flex: 1 1 100%; }
  .hero .cta-row, .final-cta .cta-row { gap: var(--space-2); }

  /* Chat-demo hint chips: bigger tap area, allow horizontal scroll instead of
     crowding three rows of tiny pills */
  .sara-widget .hints {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .sara-widget .hints::-webkit-scrollbar { display: none; }
  .sara-widget .hints button { min-height: 2.2rem; white-space: nowrap; flex: none; }

  /* Phone mock fills the column nicely without crowding the edges */
  .phone { width: min(20rem, 100%); }
  .stat { padding: var(--space-4) var(--space-2); }
}

/* Very small phones (≤360): keep big gradient numerals from colliding */
@media (max-width: 360px) {
  .stats { gap: var(--space-2); }
  .stat .num { font-size: var(--text-4xl); }
}
