/* ===== COPILOT MODE ===== */
/* Activated via body.copilot-mode class */
/* Affects: NTP background, toolbar, menu, ZIP search */

/* =============================================
   COPILOT MODE — Exclusive Elements
   (hidden by default, shown only in CM)
   ============================================= */

/* --- CM NTP Layer: single container for all CM-exclusive elements --- */
.cm-ntp-layer {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

body.copilot-mode .cm-ntp-layer {
  display: block;
}

/* Allow clicks on interactive CM children */
.cm-ntp-layer .cm-card,
.cm-ntp-layer .cm-top-sites {
  pointer-events: auto;
}

/* Hide default NTP elements in Copilot Mode */
body.copilot-mode .top-sites {
  display: none !important;
}
body.copilot-mode .feed-panel {
  display: none !important;
}
body.copilot-mode .overlay-for-feed {
  display: none !important;
}

/* --- Video Background (behind phone frame) --- */
.cm-bg-video {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100dvh;
  height: 100vh; /* fallback */
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}

body.copilot-mode .cm-bg-video {
  opacity: 1;
}

body.copilot-mode {
  background: transparent;
}

/* --- Animated Glow (kept as fallback, hidden when video loads) --- */
.cm-glow {
  position: absolute;
  width: 340px;
  height: 280px;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(ellipse at center,
    rgba(220, 195, 170, 0.6) 0%,
    rgba(230, 210, 190, 0.35) 35%,
    rgba(248, 244, 241, 0) 70%
  );
  z-index: 1;
  pointer-events: none;
  animation: cm-glow-drift 12s linear infinite;
  filter: blur(20px);
}

@keyframes cm-glow-drift {
  0%, 100% {
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
    opacity: 0.7;
  }
  20% {
    transform: translate(-20%, -25%) scale(1.2) rotate(8deg);
    opacity: 0.9;
  }
  40% {
    transform: translate(-75%, -80%) scale(1.3) rotate(-6deg);
    opacity: 0.5;
  }
  60% {
    transform: translate(-25%, -20%) scale(1.15) rotate(10deg);
    opacity: 0.85;
  }
  80% {
    transform: translate(-80%, -70%) scale(0.85) rotate(-8deg);
    opacity: 0.65;
  }
}

/* --- Greeting Text --- */
.cm-greeting {
  position: absolute;
  top: 295px;
  left: 0;
  right: 0;
  z-index: 10;
  text-align: center;
  font-family: var(--font-ui-sans);
  font-size: 24px;
  font-weight: 500;
  color: #272320;
  letter-spacing: -0.26px;
  line-height: 28px;
  pointer-events: none;
}

/* --- AI Recommendation Card --- */
.cm-card {
  position: absolute;
  top: 514px;
  left: 16px;
  right: 16px;
  z-index: 10;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 36px;
  padding: 16px 16px 16px 20px;
  display: flex;
  gap: 12px;
  align-items: center;
  overflow: hidden;
  height: 164px;
}

.cm-card-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.cm-card-title {
  font-family: var(--font-ui-sans);
  font-size: 17px;
  font-weight: 600;
  color: #272320;
  letter-spacing: -0.43px;
  line-height: 22px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cm-card-desc {
  font-family: var(--font-ui-sans);
  font-size: 12px;
  font-weight: 400;
  color: #272320;
  line-height: 16px;
  height: 48px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cm-card-action {
  display: inline-flex;
  align-items: center;
  gap: 0px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  align-self: flex-start;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cm-card-action:active {
  opacity: 0.6;
}

.cm-card-action img {
  width: 16px;
  height: 16px;
}

.cm-card-action span {
  font-family: var(--font-ui-sans);
  font-size: 13px;
  font-weight: 400;
  color: #272320;
  letter-spacing: -0.08px;
  line-height: 18px;
  padding: 0 4px;
}

.cm-card-image {
  width: 93px;
  height: 132px;
  border-radius: 24px;
  overflow: hidden;
  flex-shrink: 0;
}

.cm-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* =============================================
   COPILOT MODE — NTP Layout Overrides
   ============================================= */

/* --- NTP Page Background --- */
body.copilot-mode .ntp-page {
  background: #f8f4f1;
}
/* Let cm-ntp-layer elements receive clicks above .content */
body.copilot-mode .cm-ntp-layer {
  z-index: 12;
}
body.copilot-mode .wallpaper {
  display: none;
}
body.copilot-mode .overlay1,
body.copilot-mode .overlay2 {
  display: none;
}

/* --- Hide elements not in CM design --- */
body.copilot-mode .weather {
  display: none !important;
}
body.copilot-mode .scroll-indicator {
  display: none !important;
}

/* --- Profile icon — CM uses its own avatar --- */
body.copilot-mode .profile-icon {
  width: 32px;
  height: 32px;
}
body.copilot-mode .profile-icon img {
  content: url('../assets/cm-profile.png');
}

/* --- Options icon — CM uses sliders icon --- */
body.copilot-mode .options-icon {
  width: 24px;
  height: 24px;
}
body.copilot-mode .options-icon img {
  content: url('../assets/cm-options-icon.svg');
  width: 24px;
  height: 24px;
  filter: none;
}
body.copilot-mode .top-row {
  justify-content: space-between;
  padding: 4px 16px 0 16px;
}

/* --- CM Top Sites (Figma-matched) --- */
.cm-top-sites {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 408px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  z-index: 10;
}

.cm-top-site {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cm-top-site:active .cm-top-site-logo {
  opacity: 0.6;
}

.cm-top-site-logo {
  width: 56px;
  height: 56px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.cm-top-site-logo img {
  width: 78%;
  height: 78%;
  object-fit: contain;
}

/* Facebook — fill entire logo area */
.cm-top-site:nth-child(3) .cm-top-site-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 24px;
}

/* Add button — outline style */
.cm-top-site-add .cm-top-site-logo {
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.cm-top-site-add .cm-top-site-logo img {
  width: 24px;
  height: 24px;
}

.cm-top-site-label {
  font-family: var(--font-ui-sans);
  font-size: 12px;
  font-weight: 400;
  color: #272320;
  text-align: center;
  line-height: 16px;
  height: 32px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 100%;
}

/* --- Omnibox text change --- */
body.copilot-mode .ntp-page .omni-center span {
  color: #272320;
  opacity: 0.9;
}

/* =============================================
   COPILOT MODE — Status Bar
   ============================================= */

body.copilot-mode .ntp-page .status-bar .time,
body.copilot-mode .ntp-page .status-bar .indicators svg {
  color: #33302e;
  fill: #33302e;
}
body.copilot-mode .ntp-page .cellular .bar {
  background: #33302e;
}
body.copilot-mode .ntp-page .battery-body {
  border-color: #33302e;
}
body.copilot-mode .ntp-page .battery-body::after {
  background: #33302e;
}
body.copilot-mode .ntp-page .battery-fill {
  background: #33302e;
}
body.copilot-mode .ntp-page .wifi-icon path[stroke] {
  stroke: #33302e;
}

/* =============================================
   COPILOT MODE — Bottom Bar
   ============================================= */

body.copilot-mode .ntp-bottom-bar {
  background: transparent;
}

/* --- Omnibox (Composer) — flyout shadow from Figma --- */
body.copilot-mode .ntp-page .omni-box {
  background: rgba(255, 255, 255, 0.8);
  border: none;
  border-radius: 28px;
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.08),
    0 0 1px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
}

/* --- Nav buttons (dark icons on warm bg) --- */
body.copilot-mode .ntp-page .nav-btn img {
  filter: brightness(0);
}
body.copilot-mode .ntp-page .nav-btn .tab-count {
  color: #272320;
}
body.copilot-mode .ntp-page .home-indicator-bar {
  background: #272320;
}

/* --- Omnibox mic icon (dark), Copilot stays colorful --- */
body.copilot-mode .ntp-page .omni-right img {
  filter: brightness(0);
}

/* =============================================
   COPILOT MODE — Feed transitions
   ============================================= */

body.copilot-mode .overlay-for-feed {
  background: #F3F3F3;
}
body.copilot-mode .ntp-bottom-bar.feed-mode {
  background: rgba(243, 243, 243, 0.95);
}
body.copilot-mode .ntp-status-bar.feed-colors {
  background: #F3F3F3;
}

/* =============================================
   COPILOT MODE — Other Pages
   ============================================= */

/* --- ZIP Search Page --- */
body.copilot-mode .zip-page {
  background: #f8f4f1;
}
body.copilot-mode .zip-search-fade {
  display: none;
}
body.copilot-mode .zip-top-sites-row {
  background: transparent;
}
body.copilot-mode .zip-composer-outer {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.08),
    0 0 1px rgba(0, 0, 0, 0.08);
}
body.copilot-mode .zip-input-text {
  color: #272320;
}
body.copilot-mode .zip-suggestions {
  background: #f8f4f1;
}

/* --- Menu Panel --- */
body.copilot-mode .menu-panel {
  background: #f8f4f1;
}

/* --- Browser Bottom Bar --- */
body.copilot-mode .browser-bottom-bar {
  background: rgba(248, 244, 241, 0.85);
}
/* When one-line composer is active, browser bar stays transparent (same as non-CM) */
body.copilot-mode.one-line-composer .browser-bottom-bar {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
body.copilot-mode .browser-bottom-bar .omni-box {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.08),
    0 0 1px rgba(0, 0, 0, 0.08);
}

/* --- One Line bar: force dark icons/text on warm NTP background --- */
body.copilot-mode .ntp-bottom-bar .one-line-bar {
  color: #272320;
}
body.copilot-mode .ntp-bottom-bar .one-line-bar .ol-back svg,
body.copilot-mode .ntp-bottom-bar .one-line-bar .ol-menu svg,
body.copilot-mode .ntp-bottom-bar .one-line-bar .ol-pill-text,
body.copilot-mode .ntp-bottom-bar .one-line-bar .ol-pill-right-icon svg {
  mix-blend-mode: normal;
  filter: none;
}
body.copilot-mode .ntp-bottom-bar .one-line-bar .ol-pill-text {
  color: rgba(76, 70, 66, 0.9);
}
/* Warm glass tint for copilot mode NTP */
body.copilot-mode .ntp-bottom-bar .one-line-bar .ol-back,
body.copilot-mode .ntp-bottom-bar .one-line-bar .ol-menu,
body.copilot-mode .ntp-bottom-bar .one-line-bar .ol-pill {
  --ol-glass-bg: rgba(248, 244, 241, 0.18);
  --ol-glass-border: rgba(200, 180, 160, 0.28);
  --ol-glass-edge-top: rgba(255, 255, 255, 0.42);
  --ol-glass-shadow-near: rgba(140, 120, 100, 0.06);
  --ol-glass-shadow-far: rgba(140, 120, 100, 0.10);
  --ol-glass-prism-left: transparent;
  --ol-glass-prism-right: transparent;
}
