/* WorkFactory · m.AI Character Platform — kiosk
   Design language from the sales kit: editorial serif headlines, orange-dash
   eyebrows, the signature orange AI-hub constellation, soft lavender-grey
   surfaces, near-black navy stage, sparing orange. */
:root {
  --ink: #101B33;          /* deep navy — headings */
  --navy: #1E3A8A;         /* WF deep blue */
  --azure: #2E7FE0;        /* bright section blue (eyebrows, labels) */
  --sky: #0EA5E9;
  --orange: #F97316;
  --gradient: linear-gradient(135deg, #1E3A8A, #0EA5E9);
  --bg: #E9ECF5;           /* lavender-grey page */
  --card: #FFFFFF;
  --line: #DCE2EE;
  --slate: #5A6A85;        /* body text */
  --muted: #8A97AD;
  --stage-1: #0C1A38;      /* stage navy */
  --stage-2: #070E1F;
}
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html { height: 100%; }
body {
  font-family: "Inter", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh; /* dvh avoids the iOS 100vh browser-chrome overshoot */
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { -webkit-tap-highlight-color: transparent; }

/* Shared brand bits */
.dot { color: var(--orange); }
.eyebrow {
  display: inline-flex; align-items: center; gap: 12px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--azure);
}
.eyebrow::before { content: ""; width: 26px; height: 2px; background: var(--orange); border-radius: 2px; }

/* ---------- Header ---------- */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 34px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { height: 30px; }
.wordmark {
  font-family: "Cormorant Garamond", serif; font-weight: 600; font-size: 24px;
  letter-spacing: 0.01em; color: var(--ink);
}
.brand-divider { width: 1px; height: 22px; background: var(--line); }
.brand-sub { font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }

/* Co-brand lockup — WorkFactory × ACV Vision marks (a light, product-forward touch) */
.cobrand { display: inline-flex; align-items: center; gap: 9px; }
.cobrand-mark { height: 30px; width: auto; display: block; }
.cobrand-mark.acv { height: 36px; } /* ACV sun mark has built-in padding — size up to read equal to WF */
.cobrand-x { font-size: 13px; font-weight: 500; color: var(--muted); }

.header-actions { display: flex; align-items: center; gap: 16px; }
.status {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 500; letter-spacing: 0.04em;
  color: var(--slate);
}
.status::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted); box-shadow: 0 0 0 0 rgba(46,127,224,0.4);
}
body[data-state="ready"] .status::before,
body[data-state="listening"] .status::before,
body[data-state="thinking"] .status::before,
body[data-state="speaking"] .status::before {
  background: #16A34A; animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot { 0%,100% { box-shadow: 0 0 0 0 rgba(22,163,74,0.35); } 50% { box-shadow: 0 0 0 5px rgba(22,163,74,0); } }

/* ---------- Layout ---------- */
main {
  flex: 1; display: grid; grid-template-columns: 1.65fr 1fr;
  gap: 22px; padding: 22px 34px 30px; min-height: 0;
}

/* ---------- Stage (avatar / orb / idle constellation) ---------- */
.stage {
  position: relative; border-radius: 22px; overflow: hidden;
  background:
    radial-gradient(120% 90% at 72% 34%, rgba(30,58,138,0.55), transparent 60%),
    radial-gradient(60% 60% at 50% 46%, rgba(249,115,22,0.06), transparent 70%),
    linear-gradient(160deg, var(--stage-1), var(--stage-2));
  display: flex; align-items: center; justify-content: center;
  min-height: 62vh;
}
/* faint dotted grid, like the deck's dark slides */
.stage::before {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 26px 26px; opacity: 0.5; pointer-events: none;
}
.stage video { width: 100%; height: 100%; object-fit: cover; position: relative; z-index: 1; }
.stage video:not([hidden]) ~ .placeholder,
.stage video:not([hidden]) ~ .avatar-loading,
.stage video:not([hidden]) ~ .voice-orb { display: none; }
body[data-state="tapToStart"] .voice-orb { display: none; }

/* Idle constellation (the brand hero motif) */
.placeholder { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.constellation { width: min(46vh, 420px); height: auto; }
.constellation .links line {
  stroke: #3F8AD8; stroke-width: 1.4; stroke-dasharray: 3 7; opacity: 0.55;
  animation: drift 22s linear infinite;
}
.constellation .nodes circle { fill: #E7EEF8; opacity: 0.9; animation: twinkle 4s ease-in-out infinite; }
.constellation .nodes circle:nth-child(2n) { animation-delay: 1.3s; }
.constellation .nodes circle:nth-child(3n) { animation-delay: 2.1s; }
.constellation .hub-halo { fill: rgba(249,115,22,0.22); animation: halo 3.4s ease-in-out infinite; }
.constellation .hub { fill: var(--orange); }
.constellation .hub-label { font-family: "Cormorant Garamond", serif; font-weight: 700; font-size: 26px; fill: #fff; }
.placeholder-caption { color: #9FB0CE; font-size: 14px; letter-spacing: 0.02em; }
@keyframes drift { to { stroke-dashoffset: -100; } }
@keyframes twinkle { 0%,100% { opacity: 0.9; } 50% { opacity: 0.35; } }
@keyframes halo { 0%,100% { transform: scale(1); opacity: 0.22; transform-origin: 220px 190px; } 50% { transform: scale(1.18); opacity: 0.10; transform-origin: 220px 190px; } }

/* Avatar loading (Live Avatar mode, connecting) */
.avatar-loading { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 22px; color: #C4D2EA; }
.spinner {
  width: 88px; height: 88px; border-radius: 50%;
  border: 5px solid rgba(249, 115, 22, 0.20); border-top-color: var(--orange);
  animation: spin 0.9s linear infinite;
  box-shadow: 0 0 40px rgba(249, 115, 22, 0.18);
}
.avatar-loading p { font-size: 15px; letter-spacing: 0.02em; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Voice orb */
.voice-orb { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 20px; color: #C4D2EA; }
.orb {
  width: 130px; height: 130px; border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #FDBA74, var(--orange));
  display: flex; align-items: center; justify-content: center; gap: 7px;
  box-shadow: 0 12px 50px rgba(249,115,22,0.45);
  animation: orb-breathe 3.2s ease-in-out infinite;
}
.orb span { width: 9px; height: 18px; border-radius: 5px; background: rgba(255,255,255,0.92); }
body[data-state="listening"] .orb { animation: orb-listen 1s ease-in-out infinite; }
body[data-state="thinking"] .orb { animation: orb-breathe 0.9s ease-in-out infinite; }
body[data-state="speaking"] .orb span:nth-child(1) { animation: orb-bar 0.45s ease-in-out infinite; }
body[data-state="speaking"] .orb span:nth-child(2) { animation: orb-bar 0.45s ease-in-out 0.15s infinite; }
body[data-state="speaking"] .orb span:nth-child(3) { animation: orb-bar 0.45s ease-in-out 0.3s infinite; }
@keyframes orb-breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes orb-listen { 0%,100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(249,115,22,0.45); } 50% { transform: scale(1.1); box-shadow: 0 0 0 26px rgba(249,115,22,0); } }
@keyframes orb-bar { 0%,100% { height: 14px; } 50% { height: 46px; } }

/* Subtitle bar */
.subtitle-bar {
  position: absolute; left: 20px; right: 20px; bottom: 20px; z-index: 2;
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,0.95); border-radius: 16px; padding: 15px 22px;
  font-size: 16px; color: var(--ink);
  box-shadow: 0 10px 34px rgba(7,14,31,0.32);
}
.subtitle-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
body[data-state="listening"] .subtitle-dot { background: var(--orange); animation: pulse-dot 1s infinite; }
body[data-state="speaking"] .subtitle-dot, body[data-state="thinking"] .subtitle-dot { background: var(--azure); }
/* Doubles as the live-caption line: shows Gini's words as she speaks, else the
   status. Clamp to keep the overlay from growing without bound on long replies. */
.subtitle-bar #stateLine {
  flex: 1; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.latency { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Session-timeout overlay (covers the stage) */
.timeout-overlay {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(7, 14, 31, 0.82); backdrop-filter: blur(4px);
}
.timeout-card {
  background: var(--card); border-radius: 20px; padding: 34px 32px; max-width: 380px;
  text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.4);
}
.timeout-icon {
  width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 28px; background: #FFF1E6; color: var(--orange); margin-bottom: 4px;
}
.timeout-card h3 { font-family: "Cormorant Garamond", serif; font-weight: 600; font-size: 26px; color: var(--ink); }
.timeout-card p { font-size: 15px; color: var(--slate); line-height: 1.5; }
.timeout-card .primary { margin-top: 8px; align-self: stretch; }

/* ---------- Panel ---------- */
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 1px 3px rgba(16,27,51,0.04);
}
.panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 14px; padding: 34px 30px 20px; overflow: hidden; }
/* Intro (host) + action are semantic groupings only on desktop — display:contents
   makes their children flow directly in the panel, unchanged. On mobile they
   become two separate cards with the AI stage between them (see media query). */
.host-card, .action-card { display: contents; }
.panel h1 {
  font-family: "Cormorant Garamond", serif; font-weight: 600; font-size: 34px;
  line-height: 1.1; letter-spacing: 0.005em; color: var(--ink); margin-top: 4px;
}
.panel .lead { font-size: 16px; color: var(--slate); line-height: 1.5; }
.panel h2 { font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

/* Transcript */
.transcript { flex: 1 1 0; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 2px; }
.bubble { max-width: 88%; padding: 11px 15px; border-radius: 15px; font-size: 15px; line-height: 1.45; white-space: pre-wrap; }
.bubble.user { align-self: flex-end; background: var(--gradient); color: #fff; border-bottom-right-radius: 4px; }
.bubble.assistant { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); color: var(--ink); border-bottom-left-radius: 4px; }

/* In-session controls (transcript toggle + push-to-talk) */
.session-controls { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.ghost-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line); color: var(--navy);
  font-weight: 600; font-size: 15px; padding: 12px 16px; border-radius: 12px; position: relative;
}
.ghost-btn:hover { background: #EAF1FC; }
.unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--orange); position: absolute; top: 9px; right: 12px; }

/* Transcript bottom sheet (hidden until the Transcript button is tapped) */
.sheet { position: fixed; inset: 0; z-index: 30; display: flex; justify-content: center; align-items: flex-end; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(7,14,31,0.5); backdrop-filter: blur(2px); }
.sheet-panel {
  position: relative; width: min(560px, 100%); background: var(--card); border-radius: 22px 22px 0 0;
  max-height: 78dvh; display: flex; flex-direction: column;
  box-shadow: 0 -12px 40px rgba(7,14,31,0.25);
  padding: 10px 22px calc(22px + env(safe-area-inset-bottom));
  animation: sheet-up 0.25s ease;
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 6px 0 12px; position: relative; }
.sheet-handle { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 40px; height: 4px; border-radius: 2px; background: var(--line); }
.sheet-head h2 { flex: 1; font-family: "Cormorant Garamond", serif; font-weight: 600; font-size: 22px; color: var(--ink); text-transform: none; letter-spacing: 0; margin-top: 8px; }
.sheet-close { background: var(--bg); border: 1px solid var(--line); color: var(--slate); width: 36px; height: 36px; border-radius: 50%; font-size: 16px; margin-top: 6px; }
.sheet-panel .transcript { flex: 1 1 auto; min-height: 120px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* Access-code gate modal */
.access-modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 24px; }
.access-scrim { position: absolute; inset: 0; background: rgba(7,14,31,0.55); backdrop-filter: blur(3px); }
.access-card {
  position: relative; width: min(420px, 100%); background: var(--card); border: 1px solid var(--line);
  border-radius: 22px; padding: 30px 28px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 24px 70px rgba(7,14,31,0.35); animation: sheet-up 0.22s ease;
}
.access-card h2 { font-family: "Cormorant Garamond", serif; font-weight: 600; font-size: 28px; color: var(--ink); }
.access-card .access-sub { font-size: 15px; color: var(--slate); line-height: 1.5; }
.access-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.access-input {
  font: inherit; font-size: 20px; font-weight: 600; letter-spacing: 0.16em; text-align: center;
  text-transform: uppercase; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 14px; padding: 15px 16px; background: #F7F9FD;
}
.access-input:focus { outline: none; border-color: var(--sky); background: #fff; }
.access-error { color: #DC2626; font-size: 14px; font-weight: 500; }

/* Mode picker — two distinct visitor modes (Live Avatar / Live Voice) */
.mode-row { display: flex; flex-direction: column; gap: 10px; }
.mode-label { font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--orange); }
.mode-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 6px; }
.mode-picker button {
  background: transparent; color: var(--slate); padding: 14px; font-size: 15px;
  font-weight: 600; border-radius: 10px; transition: background .15s, color .15s;
}
.mode-picker button[aria-pressed="true"] { background: var(--card); color: var(--navy); box-shadow: 0 2px 8px rgba(16,27,51,0.10); }
.mode-picker button:disabled { opacity: 0.4; cursor: default; }

/* Chips */
.chips { display: flex; flex-direction: column; gap: 9px; }
.chip {
  text-align: left; background: #F4F7FC; border: 1px solid var(--line);
  border-radius: 13px; padding: 13px 16px; font-size: 15px; color: var(--ink);
  cursor: pointer; transition: border-color .15s, background .15s, transform .05s;
}
.chip:hover { background: #EAF1FC; border-color: var(--sky); }
.chip:active { transform: translateY(1px); }

/* Buttons */
button { font: inherit; cursor: pointer; border: none; border-radius: 13px; }
.primary { background: var(--gradient); color: #fff; font-weight: 600; padding: 16px; font-size: 17px; letter-spacing: 0.02em; box-shadow: 0 8px 24px rgba(30,58,138,0.28); }
.primary:hover { filter: brightness(1.04); }
/* Language dropdown */
.lang-label { font-size: 13px; font-weight: 500; color: var(--muted); }
.lang-select {
  appearance: none; -webkit-appearance: none;
  background-color: var(--card);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%231E3A8A' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 34px 9px 16px; font: inherit; font-size: 14px; font-weight: 600;
  color: var(--navy); cursor: pointer;
}
.lang-select:focus { outline: none; border-color: var(--sky); }
.lang-select:disabled { opacity: 0.55; cursor: default; }

/* In-session control row: Transcript + End side by side */
.control-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.danger-btn { color: #DC2626; border-color: #FECACA; background: #FEF2F2; }
.danger-btn:hover { background: #FEE2E2; }

/* Push-to-talk = the key action → Agent Orange */
.ptt {
  margin-top: auto; background: var(--orange); color: #fff; font-weight: 600;
  padding: 20px; font-size: 19px; border-radius: 16px; user-select: none;
  -webkit-user-select: none; touch-action: none; box-shadow: 0 8px 22px rgba(249,115,22,0.35);
}
body[data-state="listening"] .ptt { background: #C2410C; }

/* Panel footer (sales-kit signature) */
.panel-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 30px; border-top: 1px solid var(--line);
  font-size: 12px; letter-spacing: 0.04em; color: var(--muted);
}
.panel-footer .sep { color: var(--muted); margin: 0 3px; }
.panel-footer .powered { text-transform: uppercase; letter-spacing: 0.1em; font-size: 11px; }
.foot-cobrand { display: inline-flex; align-items: center; }

/* Page-bottom credit — "Presented by ACV · Powered by WorkFactory m.AI … · 2026" */
.site-footer {
  flex: none; text-align: center; line-height: 1.5;
  padding: 11px 34px; padding-bottom: calc(11px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: rgba(255,255,255,0.55);
  font-size: 12px; letter-spacing: 0.03em; color: var(--muted);
}
.site-footer a { color: var(--navy); font-weight: 600; text-decoration: none; }
.site-footer a:hover { color: var(--sky); text-decoration: underline; }
.site-footer .foot-platform { color: var(--slate); font-weight: 600; margin-left: 4px; }
.site-footer .foot-platform .dot { color: var(--orange); }
.site-footer .foot-sep { color: var(--line); margin: 0 5px; }

/* ---------- Mobile (phones, portrait) ---------- */
@media (max-width: 820px) {
  body { min-height: 100svh; }
  /* Compact header, clear of the status-bar notch */
  header { padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .brand img { height: 28px; }
  /* Keep BOTH co-brand marks on mobile (product name/divider drop) */
  .cobrand-mark { height: 26px; }
  .cobrand-mark.acv { height: 31px; }
  .cobrand-x { font-size: 11px; }
  .cobrand { gap: 7px; }
  .wordmark, .brand-divider, .brand-sub, .status { display: none; }
  .header-actions { gap: 8px; }
  .lang-select { padding: 8px 32px 8px 14px; font-size: 14px; }

  /* Single column, reorderable by session state (see order rules below). */
  main {
    display: flex; flex-direction: column;
    gap: 10px; padding: 10px; /* the page-bottom footer owns the safe-area inset */
    min-height: 0;
  }
  .site-footer { padding: 9px 14px; padding-bottom: calc(7px + env(safe-area-inset-bottom)); font-size: 11px; }
  .site-footer .foot-sep { margin: 0 4px; }
  /* Three stacked parts: intro card → AI stage → action card. The panel + its
     body dissolve (display:contents) so the two cards become siblings of the
     stage and can be ordered around it. */
  .panel, .panel-body { display: contents; }
  .host-card, .action-card {
    display: flex; flex-direction: column; gap: 12px;
    background: var(--card); border: 1px solid var(--line);
    border-radius: 18px; padding: 18px; overflow: visible;
  }
  .host-card { order: 1; }
  .stage { flex: 1 1 auto; min-height: 38vh; border-radius: 18px; order: 2; }
  .action-card { order: 3; }
  /* Greeting hides during a session — drop its (now empty) card so the AI box
     leads and the action card sits directly below it. */
  body.session-live .host-card { display: none; }
  .constellation { width: min(62vw, 300px); }
  .subtitle-bar { left: 12px; right: 12px; bottom: 12px; padding: 12px 16px; font-size: 15px; }

  /* Panel becomes a compact bottom control card */
  .panel { border-radius: 18px; }
  .panel-body { padding: 18px 18px 16px; gap: 12px; overflow: visible; }
  .panel h1 { font-size: 25px; }
  .panel .lead { font-size: 14px; }
  .panel-footer { display: none; }

  /* Suggested questions scroll horizontally to save height */
  #suggestions h2 { margin-bottom: 8px; }
  .chips { flex-direction: row; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 8px; padding-bottom: 2px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: 0 0 auto; max-width: 76vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .ptt { padding: 18px; font-size: 18px; }
  .mode-picker button { padding: 13px; }

  /* Bottom sheet hugs the bottom edge, above the home indicator */
  .sheet-panel { border-radius: 22px 22px 0 0; max-height: 82svh; }
}

/* Landscape phones: keep the two-pane look but tighter */
@media (max-width: 900px) and (min-width: 561px) and (orientation: landscape) {
  main { display: grid; grid-template-columns: 1.4fr 1fr; grid-template-rows: 1fr; }
  /* Undo the portrait 3-part split — one panel card, two panes side by side. */
  .panel, .panel-body { display: flex; }
  .host-card, .action-card { display: contents; }
  .stage, .panel { order: 0; }
  .panel-footer { display: flex; }
}
