/* --------------------------------------------------------------------------
   Hero demo: a live, scripted recreation of the ClipSafe window.
   Everything is sized in em against a container font-size so the whole mock
   scales with the hero column and stays crisp at any zoom or DPI.
   -------------------------------------------------------------------------- */

.cs-demo {
  position: relative;
  aspect-ratio: 16 / 9;
  font-size: clamp(4.6px, 1.1vw, 9.4px);
  font-family: var(--font-sans);
  background: #08080b;
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.cs-demo * {
  box-sizing: border-box;
}

/* --- title row ---------------------------------------------------------- */

.cs-head {
  display: flex;
  align-items: center;
  gap: 0.8em;
  height: 3.4em;
  padding: 0 1em;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.cs-logo {
  width: 1.5em;
  height: 1.5em;
  border-radius: 50%;
  background: conic-gradient(from 200deg, #8b5cf6, #a78bfa 45%, #fb923c 70%, #8b5cf6);
  flex: 0 0 auto;
}

.cs-brand {
  font-size: 1.15em;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.cs-head-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1em;
}

.cs-glyph {
  width: 1.1em;
  height: 1.1em;
  border-radius: 0.2em;
  border: 1px solid var(--text-tertiary);
  opacity: 0.5;
}

.cs-glyph--dot {
  border-radius: 50%;
  border-color: var(--text-tertiary);
}

/* --- tabs --------------------------------------------------------------- */

.cs-tabs {
  display: flex;
  align-items: center;
  gap: 1.5em;
  height: 3.1em;
  padding: 0 1em;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.cs-tab {
  position: relative;
  font-size: 0.95em;
  color: var(--text-tertiary);
  padding: 0.85em 0;
  transition: color 0.2s ease;
}

.cs-tab.is-active {
  color: var(--text);
}

.cs-tab.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.05em;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.cs-tabs-actions {
  margin-left: auto;
  display: flex;
  gap: 0.9em;
  align-items: center;
}

/* --- search row --------------------------------------------------------- */

.cs-search {
  display: flex;
  align-items: center;
  gap: 0.6em;
  height: 0;
  padding: 0 1em;
  border-bottom: 1px solid transparent;
  overflow: hidden;
  opacity: 0;
  transition: height 0.28s ease, opacity 0.28s ease, border-color 0.28s ease;
  flex: 0 0 auto;
}

.cs-search.is-open {
  height: 3.2em;
  opacity: 1;
  border-bottom-color: var(--border);
}

.cs-search-type {
  font-size: 0.82em;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  border-radius: 0.4em;
  padding: 0.3em 0.6em;
  background: var(--surface);
}

.cs-search-field {
  display: flex;
  align-items: center;
  gap: 0.25em;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.9em;
  color: var(--text);
}

.cs-search-text {
  white-space: nowrap;
  overflow: hidden;
}

.cs-caret {
  width: 1px;
  height: 1.15em;
  background: var(--text);
  animation: cs-blink 1s steps(2, start) infinite;
}

.cs-search-placeholder {
  color: var(--text-tertiary);
}

/* --- history list ------------------------------------------------------- */

.cs-list {
  flex: 1 1 auto;
  padding: 0.7em 0.9em;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  min-height: 0;
  /* A soft fade at the bottom edge reads as a scrolling list rather than a crop. */
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 1.4em), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 1.4em), transparent);
}

.cs-item {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 0.55em;
  background: var(--surface);
  padding: 0.4em 0.7em;
  display: flex;
  flex-direction: column;
  gap: 0.2em;
  opacity: 0;
  transform: translateY(0.5em);
  transition: opacity 0.45s ease, transform 0.45s ease, border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
  flex: 0 0 auto;
}

.cs-item.is-in {
  opacity: 1;
  transform: none;
}

.cs-item.is-out {
  opacity: 0;
  transform: translateY(-0.4em);
  height: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-top: -0.65em;
  border-width: 0;
  overflow: hidden;
  transition: all 0.35s ease;
}

.cs-item.is-hover {
  border-color: var(--accent-line);
  background: var(--surface-2);
}

.cs-item.is-copied {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-line), 0 0 1.4em rgba(139, 92, 246, 0.28);
}

.cs-item.is-pinned {
  border-color: var(--accent-line);
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.08);
}

/* Pin button, shown on hover and kept visible once the item is pinned. */
.cs-pin {
  position: absolute;
  top: 0.32em;
  right: 0.34em;
  width: 1.15em;
  height: 1.15em;
  background-color: var(--text-secondary);
  opacity: 0;
  transition: opacity 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M16 9V4h1c.55 0 1-.45 1-1s-.45-1-1-1H7c-.55 0-1 .45-1 1s.45 1 1 1h1v5c0 1.66-1.34 3-3 3v2h5.97v7l1 1 1-1v-7H19v-2c-1.66 0-3-1.34-3-3z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M16 9V4h1c.55 0 1-.45 1-1s-.45-1-1-1H7c-.55 0-1 .45-1 1s.45 1 1 1h1v5c0 1.66-1.34 3-3 3v2h5.97v7l1 1 1-1v-7H19v-2c-1.66 0-3-1.34-3-3z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.cs-item.is-hover .cs-pin,
.cs-item:hover .cs-pin {
  opacity: 1;
}

.cs-item.is-pinned .cs-pin {
  background-color: var(--accent-strong);
  opacity: 1;
  transform: rotate(-20deg);
}

.cs-item-body {
  font-size: 0.88em;
  line-height: 1.55;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cs-item-body--mono {
  font-family: var(--font-mono);
  font-size: 0.8em;
  color: var(--text);
}

.cs-item-title {
  font-size: 0.92em;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5em;
  min-width: 0;
}

.cs-item-title span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cs-favicon {
  width: 1em;
  height: 1em;
  border-radius: 0.2em;
  background: linear-gradient(140deg, #8b5cf6, #fb923c);
  flex: 0 0 auto;
}

.cs-meta {
  display: flex;
  align-items: center;
  gap: 0.5em;
  font-size: 0.72em;
  color: var(--text-tertiary);
}

.cs-meta-source {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.35em;
}

.cs-chips {
  display: flex;
  gap: 0.35em;
  flex-wrap: wrap;
}

.cs-chip {
  font-size: 0.72em;
  padding: 0.2em 0.55em;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
}

.cs-chip--accent {
  border-color: var(--accent-line);
  background: var(--accent-subtle);
  color: var(--accent-strong);
}

.cs-chip.is-new {
  animation: cs-chip 0.5s ease;
}

/* media previews */

.cs-thumb {
  height: 2.2em;
  border-radius: 0.4em;
  background:
    radial-gradient(circle at 30% 30%, rgba(139, 92, 246, 0.85), transparent 60%),
    radial-gradient(circle at 70% 70%, rgba(251, 146, 60, 0.8), transparent 55%),
    #14141b;
  border: 1px solid var(--border);
}

.cs-wave {
  display: flex;
  align-items: center;
  gap: 0.22em;
  height: 1.9em;
}

.cs-wave i {
  width: 0.22em;
  border-radius: 999px;
  background: var(--accent-strong);
  opacity: 0.75;
}

.cs-file {
  display: flex;
  align-items: center;
  gap: 0.55em;
  font-size: 0.85em;
  color: var(--text);
}

.cs-file-icon {
  width: 1.3em;
  height: 1.6em;
  border-radius: 0.2em;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  flex: 0 0 auto;
}

.cs-file-size {
  margin-left: auto;
  color: var(--text-tertiary);
  font-size: 0.85em;
}

/* --- overlay bits ------------------------------------------------------- */

.cs-toast {
  position: absolute;
  left: 50%;
  bottom: 2.6em;
  transform: translate(-50%, 0.6em);
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.6em 1em;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--accent-line);
  color: var(--text);
  font-size: 0.85em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  white-space: nowrap;
}

.cs-toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.cs-toast::before {
  content: "";
  width: 0.55em;
  height: 0.3em;
  border-left: 1.5px solid var(--accent-strong);
  border-bottom: 1.5px solid var(--accent-strong);
  transform: rotate(-45deg);
  margin-top: -0.15em;
}

.cs-hint {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35em;
  padding: 0.38em 0.9em;
  border-top: 1px solid var(--border);
  font-size: 0.74em;
  color: var(--text-tertiary);
}

.cs-key {
  padding: 0.15em 0.45em;
  border: 1px solid var(--border-strong);
  border-radius: 0.3em;
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.95em;
}

.cs-key.is-pressed {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--accent-subtle);
  transform: translateY(1px);
}

/* --- motion ------------------------------------------------------------- */

@keyframes cs-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes cs-chip {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Static state: no JavaScript, or the visitor asked for reduced motion. */
.cs-demo--static .cs-item {
  opacity: 1;
  transform: none;
}

.cs-demo--static .cs-caret {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .cs-demo * {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }

  .cs-caret {
    display: none;
  }
}

@media (max-width: 900px) {
  .cs-demo {
    font-size: clamp(4.2px, 1.72vw, 8.2px);
  }
}
