/* ─────────────────────────────────────────────────────────────────────
   Builder device-mockup DEMO screen (2026-06-12, Luke)
   ---------------------------------------------------------------------
   Ports the home-page "tap-a-tile / ask-a-question" Speech Prosthetic
   demo INTO the builder's device mockup, so a guest landing on
   tinkyspeak.com (= the builder) immediately sees a live, usable AAC
   board in the device — then "enters" it (Start building →) to drop
   into the real builder.

   EVERYTHING here is scoped under #builderDemoScreen so it cannot leak
   into — or be clobbered by — the builder's own tile/board styles
   (board-builder.css). Palette + tile rules are copied verbatim from
   css/home-foundations.css so the look matches the screenshot exactly.
   ───────────────────────────────────────────────────────────────────── */

#builderDemoScreen {
  /* Full-bleed overlay over the .tablet-screen content (topbar/sb/grid).
     The mount JS sets .tablet-screen { position: relative }. */
  position: absolute;
  inset: 0;
  /* Above the device's own preview-topbar (z-index:100) + sentence bar so
     the demo fully covers the empty board chrome underneath. */
  z-index: 140;
  display: flex;
  flex-direction: column;
  gap: 0;
  /* Dark home-demo aesthetic (matches the screen Luke screenshotted). */
  background: radial-gradient(120% 120% at 70% 0%, #1a2030 0%, #13111a 70%);
  color: #fff;
  /* Local copies of the home palette tokens (so this file is portable). */
  --fk-verb: #f0862e;
  --fk-noun: #f2c624;
  --fk-adj: #8B5CF6;
  --fk-social: #ec5fa0;
  --fk-negation: #ef4444;
  --fk-help: #22c55e;
  --bd-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --bd-amber: #f4b740;
  --bd-green: #22c55e;
  overflow: hidden;
}
#builderDemoScreen[hidden] { display: none; }

/* ── Header strip ──────────────────────────────────────────────────── */
#builderDemoScreen .bd-demo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex: 0 0 auto;
}
#builderDemoScreen .bd-demo-title {
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}
#builderDemoScreen .bd-demo-title small {
  display: block;
  font-weight: 600;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.04em;
  margin-top: 2px;
}
#builderDemoScreen .bd-demo-enter {
  padding: 9px 16px;
  background: var(--bd-amber);
  color: #1a1208;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s var(--bd-ease-spring), filter 0.2s;
}
#builderDemoScreen .bd-demo-enter:hover { transform: scale(1.04); filter: brightness(1.06); }

/* ── Scroll body (grid + ask) ──────────────────────────────────────── */
#builderDemoScreen .bd-demo-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Tile grid (3-up, fills the device width) ──────────────────────── */
#builderDemoScreen .tablet-grid {
  display: grid;
  /* 2026-07-01 (Luke): was repeat(3) with big square tiles → demo board was
     huge + needed scrolling. 4-up + tighter gap shrinks tiles so the whole
     board fits on screen in one view. */
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
}
#builderDemoScreen .demo-tile {
  /* 2026-07-01 (Luke): square tiles at 4-up still overflowed on 3 rows. Make
     them SHORTER (wider-than-tall) + cap the height so the whole board fits on
     screen without scrolling. */
  aspect-ratio: 4 / 3;
  max-height: 116px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s var(--bd-ease-spring), opacity 0.25s ease;
}
#builderDemoScreen .demo-tile:hover { transform: scale(1.05); }
#builderDemoScreen .demo-tile-emoji {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.5rem, 4.5vw, 2.2rem);
  line-height: 1;
}
#builderDemoScreen .demo-tile-label {
  background: rgba(0,0,0,0.22);
  padding: 5px 4px;
  text-align: center;
  font-size: 0.66rem;
  font-weight: 800;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.1;
}
#builderDemoScreen .tile-verb { background: var(--fk-verb); }
#builderDemoScreen .tile-noun { background: var(--fk-noun); }
#builderDemoScreen .tile-adj { background: var(--fk-adj); }
#builderDemoScreen .tile-social { background: var(--fk-social); }
#builderDemoScreen .tile-help { background: var(--fk-help); }
#builderDemoScreen .tile-negation { background: var(--fk-negation); }
#builderDemoScreen .tile-nav { background: #4a5568; }
#builderDemoScreen .demo-tile.has-drill { position: relative; }
#builderDemoScreen .demo-tile.has-drill::after {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-right: 2px solid rgba(255,255,255,0.5);
  border-top: 2px solid rgba(255,255,255,0.5);
  transform: rotate(45deg);
}
#builderDemoScreen .tile-speak-flash { animation: bdTilePulse 0.3s ease; }
@keyframes bdTilePulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,255,255,0.4); }
  50% { transform: scale(0.92); box-shadow: 0 0 0 6px rgba(255,255,255,0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}

/* ── Spoken-sentence readout ───────────────────────────────────────── */
#builderDemoScreen .bd-demo-say {
  min-height: 1.4em;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--bd-amber);
}
#builderDemoScreen .bd-demo-say:empty::before {
  content: 'Tap a tile to speak \2014 or ask a question below';
  color: rgba(255,255,255,0.35);
  font-weight: 500;
}

/* ── Ask box ───────────────────────────────────────────────────────── */
#builderDemoScreen .hero-chat-label {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.45);
  margin-bottom: 4px;
  letter-spacing: 0.04em;
  text-align: center;
}
#builderDemoScreen .hero-chat {
  display: flex;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255,255,255,0.07);
  border: 2px solid rgba(255,255,255,0.22);
  transition: border-color 0.3s, background 0.3s;
}
#builderDemoScreen .hero-chat:focus-within {
  border-color: var(--bd-amber);
  background: rgba(255,255,255,0.11);
}
#builderDemoScreen .hero-chat input {
  flex: 1;
  padding: 0.85rem 1.1rem;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 0.95rem;
  cursor: text;
}
#builderDemoScreen .hero-chat input::placeholder { color: rgba(255,255,255,0.4); }
#builderDemoScreen .hero-chat-btn {
  padding: 0.85rem 1.4rem;
  background: var(--bd-green);
  color: #fff;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  transition: background 0.3s;
  white-space: nowrap;
}
#builderDemoScreen .hero-chat-btn:hover { background: #1aad4f; }
#builderDemoScreen .hero-chat-btn.loading {
  background: rgba(255,255,255,0.15);
  pointer-events: none;
  position: relative;
  color: transparent;
}
#builderDemoScreen .hero-chat-btn.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: bdBtnSpin 0.6s linear infinite;
}
@keyframes bdBtnSpin { to { transform: rotate(360deg); } }
#builderDemoScreen .hero-chat-hint {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.3);
  margin-top: 6px;
  line-height: 1.5;
  text-align: center;
}
#builderDemoScreen .hero-chat-hint span {
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  border-bottom: 1px dotted rgba(255,255,255,0.3);
  transition: color 0.2s;
}
#builderDemoScreen .hero-chat-hint span:hover { color: var(--bd-amber); }

/* ── Footer enter row (mirrors the header CTA for thumb reach) ──────── */
#builderDemoScreen .bd-demo-foot {
  flex: 0 0 auto;
  padding: 10px 16px 14px;
  text-align: center;
}
#builderDemoScreen .bd-demo-foot button {
  width: 100%;
  padding: 12px;
  background: transparent;
  color: rgba(255,255,255,0.65);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
#builderDemoScreen .bd-demo-foot button:hover {
  color: #fff;
  border-color: rgba(255,255,255,0.4);
}

/* ── Durable demo takeover (Luke 2026-06-14) ──────────────────────────
   While the welcome demo is active, the builder's empty-state card must NOT
   show — but a logged-in user's boot (login.js / cloud-sync) re-shows
   #emptyState with an inline display:flex AFTER the demo's ~3s JS guard
   stops re-asserting, so the demo silently lost on mobile for authed users.
   These !important rules beat those late inline styles, so the demo stays
   the empty-board start for everyone (guest + logged-in). The class is set
   in device-demo.js revealEditor() and removed in restoreEditor(). */
body.tb-demo-active #emptyState { display: none !important; }
/* :not(.panel-active) — when an in-place panel (Community/Library/etc.) opens,
   builder.css uses `body.panel-active #editorContent { display:flex !important }`
   to host it. Without this guard our block rule would fight that flex and break
   the panel layout if a panel ever opens while the demo class is still on.
   (Codex flagged this latent cascade conflict on the durable-demo PR.) */
body.tb-demo-active:not(.panel-active) #editorContent { display: block !important; }
body.tb-demo-active #firstRunGuideCard { display: none !important; }

/* ── Mobile: frameless, clean tiles (Luke 2026-06-14) ─────────────────
   "remove that fake devices look on mobile, just tile clean." The device
   bezel is flattened in responsive-topbar.css (#builderTabletFrame); here we
   drop the demo header's divider so the demo reads as one clean surface
   edge-to-edge rather than a boxed device screen. */
@media (max-width: 768px) {
  #builderDemoScreen .bd-demo-head { border-bottom: 0; }
}
