/* ═══════════════════════════════════════════════════════════════
   HOMEPAGE DEMO - Chat UI Visualization Styles
   Used by: homepagev3.html and homepagev4.html
   Purpose: Interactive demo chat interface with Mac window frame
   Includes: Demo UI, animations, PDF modal, mouse cursor
═══════════════════════════════════════════════════════════════ */

:root {
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --color-background-primary: #fff;
  --color-background-secondary: #f9fafb;
  --color-border-secondary: #e5e7eb;
  --color-text-primary: #111827;
  --color-text-secondary: #6b7280;
  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-panel: #f4f4f4;
  --border-radius-lg: 12px;
  --border-radius-md: 8px;

  --app-bg: #ffffff;
  --app-border: #e0e0e0;
  --app-text: #222;
  --app-muted: #888;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-sans); background: var(--color-background-secondary); transition: background 0.3s ease; }

.wrap {
  background: var(--color-background-primary);
  border-radius: var(--border-radius-lg);
  padding: 16px;
  max-width: 1050px;
  margin: 0 auto;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  perspective: 1000px; /* Required for the 3D zoom effect */
}

/* The Frame - No zoom here anymore, mac-window handles it */
.frame {
  background: var(--app-bg); border-radius: 0 0 10px 10px; border: 1px solid var(--app-border);
  overflow: hidden; display: flex; flex-direction: column; color: var(--app-text);
  height: clamp(400px, 70vh, 800px); position: relative;
  transition: background 0.3s ease, border-color 0.3s ease;
  -webkit-font-smoothing: subpixel-antialiased;
}

/* The Focused State (subtle push-in) - now on mac-window */
.mac-window.focused {
  transform: scale(1.01) translateY(4px) translateZ(0);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}
.mac-window.focused .frame {
  border-color: transparent;
}

.topbar {
  display: flex; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--app-border);
  background: var(--app-bg); flex-shrink: 0;
}
.tab {
  font-size: 11px; font-weight: 500; padding: 6px 10px; border-radius: 6px;
  border: 1px solid transparent; color: var(--app-muted); cursor: default;
}
.tab.on { border-color: var(--app-border); color: var(--color-accent); }

.main { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.body { display: flex; flex-direction: column; padding: 16px; gap: 12px; flex: 1; overflow-y: auto; }

.bubble {
  background: var(--color-accent); color: #fff; border-radius: 14px 14px 4px 14px;
  padding: 10px 14px; font-size: 12px; line-height: 1.5; align-self: flex-end;
  max-width: 85%; opacity: 0; transform: translateY(12px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.chip {
  display: flex; align-items: center; gap: 8px; background: var(--color-panel);
  border-radius: 20px; padding: 8px 14px; font-size: 12px; width: fit-content;
  opacity: 0; transform: translateY(6px); transition: opacity 0.3s ease;
}
.spin {
  width: 14px; height: 14px; border: 2px solid #ddd; border-top-color: var(--color-accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

.ans-container {
  background: var(--app-bg); border: 1px solid var(--app-border); border-radius: 8px;
  padding: 14px; font-size: 12px; line-height: 1.6; opacity: 0; transform: translateY(12px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  position: relative;
}
.seq { opacity: 0; transform: translateY(4px); transition: opacity 0.4s ease, transform 0.4s ease; }
.seq.vis { opacity: 1; transform: translateY(0); }
.ans-container b { font-weight: 600; }
.ans-container .cite { color: var(--color-accent); font-style: italic; font-size: 11px; }

/* The Delayed Sources Panel */
.sources {
  width: 0; border-left: 1px solid transparent; background: var(--app-bg);
  flex-shrink: 0; opacity: 0; overflow-y: auto; overflow-x: hidden;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.5s ease, border-color 0.6s ease;
}
.sources.open { width: clamp(200px, 30vw, 400px); opacity: 1; border-color: var(--app-border); }
.src-inner { width: calc(100% - 32px); padding: 16px; }

.sp-head { font-size: 10px; font-weight: 600; letter-spacing: 1px; color: var(--app-muted); margin-bottom: 16px; display: flex; align-items: center; gap: 6px; }
.badge { background: var(--color-accent); color: #fff; border-radius: 10px; font-size: 9px; padding: 2px 6px; }

/* Expanded Source Card focusing on the PDF button */
.sc {
  border: 1px solid var(--app-border); border-radius: 6px; padding: 10px;
  margin-bottom: 10px; transition: border-color 0.2s ease, transform 0.4s ease, opacity 0.4s ease;
  transform: translateX(10px); opacity: 0; background: var(--app-bg);
}
.sc.vis { transform: translateX(0); opacity: 1; }
.sc.active {
  border-color: var(--color-accent);
  background: rgba(37, 99, 235, 0.03);
}
.sc .t { font-weight: 600; font-size: 11px; color: var(--app-text); }
.sc .snip {
  color: var(--app-text); font-size: 10.5px; line-height: 1.5;
  margin-top: 8px; opacity: 0.85; border-left: 2px solid var(--app-border); padding-left: 8px;
}
.vpdf {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--color-accent); color: #fff; border-radius: 4px;
  font-size: 11px; font-weight: 500; padding: 6px 12px; margin-top: 12px;
  cursor: pointer; width: 100%; border: none; transition: background 0.2s;
}
.vpdf:hover { background: var(--color-accent-hover); }

.bar {
  display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--app-border);
  background: var(--app-bg); flex-shrink: 0; align-items: center; z-index: 10;
}
.inp {
  flex: 1; border: 1px solid var(--app-border); border-radius: 8px; padding: 10px 14px;
  font-size: 13px; color: var(--app-text); min-width: 0; transition: border-color 0.2s ease;
}
.inp.on { border-color: var(--color-accent); box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.1); }
.sbtn {
  width: 36px; height: 36px; border-radius: 8px; background: #dbeafe; border: none;
  display: flex; align-items: center; justify-content: center; transition: background 0.2s ease;
}
.sbtn.on { background: var(--color-accent); }
.sbtn svg { width: 14px; height: 14px; fill: #fff; }

/* Mac Window Frame */
.mac-window {
  position: relative;
  border-radius: 12px;
  overflow: visible;
  box-shadow: 0 20px 60px -10px rgba(0,0,0,0.3), 0 8px 20px -5px rgba(0,0,0,0.15);
  transition: transform 0.9s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.9s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: bottom center;
  will-change: transform;
  backface-visibility: hidden;
  transform: translateZ(0);
}
.mac-titlebar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 14px;
  height: 32px;
  background: linear-gradient(180deg, #ebebeb 0%, #d6d6d6 100%);
  border-bottom: 1px solid #b0b0b0;
  border-radius: 12px 12px 0 0;
  position: relative;
  flex-shrink: 0;
}
.mac-titlebar .dots {
  display: flex;
  gap: 7px;
  align-items: center;
}
.mac-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: filter 0.15s ease;
}
.mac-dot:hover { filter: brightness(0.88); }
.mac-dot.close   { background: #ff5f57; border: 1px solid #e0443e; }
.mac-dot.min     { background: #febc2e; border: 1px solid #d4a017; }
.mac-dot.max     { background: #28c840; border: 1px solid #1faa33; }

/* Dot icons — hidden by default, show on hover over the dots group */
.dot-icon {
  width: 8px;
  height: 8px;
  fill: rgba(0,0,0,0);
  stroke: rgba(0,0,0,0);
  transition: fill 0.15s ease, stroke 0.15s ease;
  flex-shrink: 0;
}
.dots:hover .dot-icon {
  fill: rgba(0,0,0,0.45);
  stroke: rgba(0,0,0,0.45);
  stroke-width: 0.5;
}
/* pause icon rects need no stroke fill conflict */
.dots:hover .mac-dot.close .dot-icon rect { fill: rgba(0,0,0,0.45); }
.dots:hover .mac-dot.min   .dot-icon path,
.dots:hover .mac-dot.min   .dot-icon polyline { fill: none; stroke: rgba(0,0,0,0.5); stroke-width: 1.2; }
.dots:hover .mac-dot.max   .dot-icon polygon { fill: rgba(0,0,0,0.45); stroke: none; }

/* Sharpness — remove any blur on the frame, make text crisp */
.frame, .inp, #txt {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  filter: none !important;
}
.inp.on {
  filter: none !important;
}

.mac-titlebar .win-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 500;
  color: #555;
  letter-spacing: 0.01em;
  pointer-events: none;
  white-space: nowrap;
}
/* The frame inside mac window loses its top border-radius */
.mac-window .frame {
  border-radius: 0 0 10px 10px;
  border-top: none;
}

.vis { opacity: 1 !important; transform: none !important; }
.cur {
  display: inline-block; width: 2px; height: 13px; background: var(--app-text);
  vertical-align: -2px; animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0 } }

/* PDF POPUP STYLES */
.pdf-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.3s ease; z-index: 100;
}
.pdf-overlay.open { opacity: 1; pointer-events: auto; }

.pdf-modal {
  width: 90%; height: 90%; background: #f3f3f3; border-radius: 8px;
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(20px); transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.pdf-overlay.open .pdf-modal { transform: translateY(0); }

.pdf-header { background: #fff; padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #ddd; }
.pdf-title { font-size: 12px; font-weight: 600; color: #333; }
.pdf-close { background: none; border: none; font-size: 18px; cursor: pointer; color: #666; }

.pdf-toolbar { background: #323639; color: white; padding: 8px 16px; display: flex; align-items: center; gap: 12px; font-size: 11px; }
.pdf-btn-summarize { background: #4b5155; border: 1px solid #5f6368; color: white; padding: 4px 10px; border-radius: 4px; font-size: 10px; cursor: default; }

.pdf-content-area { display: flex; flex: 1; overflow: hidden; }
.pdf-sidebar { width: clamp(80px, 18vw, 220px); background: #525659; padding: 12px; display: flex; flex-direction: column; gap: 12px; border-right: 1px solid #333; }
.pdf-thumb { width: 100%; border: 2px solid transparent; }
.pdf-thumb.active { border-color: var(--color-accent); }

.pdf-main-view { flex: 1; background: #525659; overflow-y: auto; padding: 20px 0; display: flex; justify-content: center; }
.pdf-page-img { background: white; width: clamp(300px, 80vw, 600px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); padding: clamp(20px, 5vw, 40px); position: relative; height: fit-content; }

.pdf-text-line { background: #eee; height: 8px; margin-bottom: 8px; border-radius: 2px; }
.pdf-text-head { font-weight: bold; font-size: 14px; margin-bottom: 10px; }

/* Animated mouse cursor */
#mouseCursor {
  position: fixed; width: 32px; height: 32px; pointer-events: none; z-index: 9999;
  opacity: 0; transition: opacity 0.2s ease;
  left: -50px; top: -50px;
}
#mouseCursor.visible { opacity: 1; }
#cursorArrow {
  width: 22px; height: 22px;
  filter: drop-shadow(1px 2px 3px rgba(0,0,0,0.4));
  transition: transform 0.12s ease;
  transform-origin: 4px 2px;
}
#cursorHand {
  width: 28px; height: 28px;
  filter: drop-shadow(1px 2px 3px rgba(0,0,0,0.4));
  transition: transform 0.12s ease;
  transform-origin: 10px 2px;
}
#mouseCursor.clicking #cursorArrow { transform: scale(1.15); }
#mouseCursor.clicking #cursorHand { transform: scale(1.1); }

/* Translate / Export action buttons on answer - positioned outside at top */
.ans-actions {
  position: absolute; top: -30px; right: 0;
  display: flex; gap: 5px;
  opacity: 0; transition: opacity 0.4s ease;
}
.ans-actions.vis { opacity: 1; }
.ans-act-btn {
  display: flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 500;
  padding: 4px 9px; border-radius: 5px; border: 1px solid var(--app-border);
  background: var(--app-bg); color: var(--app-muted); cursor: default;
  white-space: nowrap;
}

/* Spotlight overlay — blurs everything except the input bar */
.spotlight-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.spotlight-overlay.active {
  opacity: 1;
}

/* Blur mask using backdrop for everything above the bar */
.spotlight-blur-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  bottom: 57px; /* height of .bar */
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  background: rgba(255,255,255,0.08);
}

/* Highlight ring around the input area */
.spotlight-highlight {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 57px;
  box-shadow: 0 0 0 2px rgba(37,99,235,0.18), inset 0 1px 0 rgba(255,255,255,0.9);
  pointer-events: none;
}

.pdf-thumb-content {
  height: 80px; background: white; padding: 6px; overflow: hidden;
}
.pdf-thumb-line { background: #ccc; height: 4px; margin-bottom: 3px; border-radius: 1px; }
.pdf-thumb-head { background: #999; height: 5px; margin-bottom: 5px; border-radius: 1px; width: 70%; }
