/* Version history panel, older-version banner, duplicate buttons and the Share popover (modules/versions.js). */

/* ---------- History button in the preview tools ---------- */
.ptools .cv-hist-btn.on { color: var(--cta-a); background: var(--hover); }

/* ---------- History panel: glass card over the chat column (desktop), bottom sheet on phones ---------- */
.cv-hist { position: fixed; z-index: 45; left: 16px; top: 88px; bottom: 16px; width: 380px; max-width: calc(100vw - 32px);
  display: flex; flex-direction: column; border-radius: 28px; overflow: hidden;
  background: var(--card); border: 1px solid var(--glass-line); box-shadow: var(--glass-shadow), 0 30px 70px -30px rgba(60, 40, 20, .45); }
.cv-hist[hidden], .cv-hist-back[hidden] { display: none; }
.cv-grab { display: none; }
.cv-hist-head { display: flex; align-items: center; gap: 12px; padding: 18px 14px 12px 18px; }
.cv-hist-ic { width: 38px; height: 38px; flex-shrink: 0; display: grid; place-items: center; border-radius: 999px; color: #FFFFFF;
  background: linear-gradient(135deg, var(--cta-a), var(--cta-b)); box-shadow: 0 8px 18px -8px rgba(232, 101, 43, .7); }
.cv-hist-titles { flex: 1; min-width: 0; }
.cv-hist-titles h2 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.cv-hist-titles p { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-faint); }
.cv-hist .cv-close { border-radius: 999px; flex-shrink: 0; }
.cv-hist-tools { display: flex; gap: 8px; padding: 0 18px 12px; border-bottom: 1px solid var(--line); }
.cv-hist-tools .btn { border-radius: 999px; gap: 6px; }
.cv-hist-list { list-style: none; margin: 0; padding: 10px 10px 4px; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 2px; }
.cv-hist-empty { padding: 18px 10px; text-align: center; font-size: 13.5px; color: var(--ink-muted); }
.cv-hist-empty.small { padding: 10px; font-size: 12.5px; color: var(--ink-faint); }
.cv-hist-foot { margin: 0; padding: 10px 18px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-faint); }

/* one version: a dot on a timeline line, number, time, what made it, buttons */
.cv-v { position: relative; display: flex; gap: 12px; padding: 10px 10px 10px 12px; border-radius: 16px; border: 1px solid transparent; }
.cv-v::before { content: ""; position: absolute; left: 17px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.cv-v:first-child::before { top: 18px; }
.cv-v:last-child::before { bottom: calc(100% - 18px); }
.cv-v:only-child::before { display: none; }
.cv-v:hover { background: var(--hover); }
.cv-v.is-viewing { background: var(--card); border-color: var(--line); box-shadow: 0 1px 3px rgba(0, 0, 0, .06); }
.cv-v-dot { position: relative; z-index: 1; flex-shrink: 0; width: 12px; height: 12px; margin-top: 4px; border-radius: 50%; background: var(--card); border: 2px solid var(--ink-faint); }
.cv-v.is-current .cv-v-dot { border: 0; background: linear-gradient(135deg, var(--cta-a), var(--cta-b)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--cta-a) 20%, transparent); }
.cv-v.is-viewing:not(.is-current) .cv-v-dot { border-color: var(--select); background: var(--select); }
.cv-v-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.cv-v-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cv-v-num { font: 600 11.5px var(--mono); color: var(--ink-muted); padding: 1px 7px; border-radius: 999px; background: var(--chip-bg); }
.cv-v-time { font-size: 12.5px; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-v-tag { margin-left: auto; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; color: var(--cta-a); background: color-mix(in srgb, var(--cta-a) 12%, transparent); white-space: nowrap; }
.cv-v-tag.view { color: var(--accent-text); background: color-mix(in srgb, var(--select) 14%, transparent); }
.cv-v-label { margin: 0; font-size: 14px; font-weight: 500; color: var(--ink); line-height: 1.35; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cv-v-acts { display: flex; gap: 6px; margin-top: 4px; }
.cv-v-acts:empty { display: none; }
.cv-v-acts .btn { min-height: 30px; padding: 0 11px; border-radius: 999px; gap: 5px; font-size: 12.5px; }
.cv-v-acts .btn[aria-pressed="true"] { color: var(--accent-text); background: color-mix(in srgb, var(--select) 12%, transparent); }

/* ---------- Older version in the preview window ---------- */
.mac .cv-old-frame { position: absolute; left: 0; top: 40px; width: 100%; height: calc(100% - 40px); z-index: 2; }
.mac .cv-old-frame[hidden] { display: none; }
.mac.phone .cv-old-frame { top: 46px; height: calc(100% - 46px); border-radius: 0 0 36px 36px; }
.mac.tablet .cv-old-frame { top: 0; height: 100%; border-radius: 20px; }
.cv-old-banner { position: absolute; z-index: 4; left: 50%; bottom: 16px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 8px; padding: 6px 6px 6px 14px; border-radius: 999px;
  background: rgba(18, 19, 22, .86); color: #FFFFFF; font-size: 13px; font-weight: 600; box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .45);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.cv-old-banner[hidden] { display: none; }
.cv-old-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cta-b); flex-shrink: 0; }
.cv-old-text { white-space: nowrap; margin-right: 4px; }
.cv-old-btn { min-height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .08); color: #FFFFFF; font: inherit; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.cv-old-btn:hover { background: rgba(255, 255, 255, .16); }
.cv-old-btn.primary { border: 0; background: linear-gradient(135deg, var(--cta-a), var(--cta-b)); }
.cv-old-btn.primary:hover { background: linear-gradient(135deg, #F07436, #EDB414); }
.cv-old-btn[disabled] { opacity: .6; cursor: progress; }
.cv-old-btn:focus-visible { outline: 2px solid #FFFFFF; outline-offset: 2px; }
.mac.phone .cv-old-banner { bottom: 26px; border-radius: 22px; padding: 8px 10px; }
.mac.phone .cv-old-text { width: 100%; text-align: center; margin: 0; }
.mac.phone .cv-old-dot { display: none; }

/* ---------- Duplicate button on project cards (shows on hover, like star and delete) ---------- */
.pcard .cv-card-dup { position: static; flex-shrink: 0; }
@media (hover: hover) {
  .pcard .cv-card-dup { opacity: 0; transition: opacity .15s; }
  .pcard:hover .cv-card-dup, .pcard .cv-card-dup:focus-visible { opacity: 1; }
}

/* ---------- Share button and popover ---------- */
.share-wrap { position: relative; order: 5; }
.share-wrap[hidden] { display: none; }
.topbar .cv-share-btn { min-height: 38px; border-radius: 999px; gap: 6px; padding: 0 14px; background: var(--card); }
.topbar .cv-share-btn.on svg { color: var(--accent-text); }
.cv-share-pop { width: 380px; }
.cv-share-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--chip-bg); }
.cv-share-ic { width: 34px; height: 34px; flex-shrink: 0; display: grid; place-items: center; border-radius: 999px; background: var(--card); color: var(--ink-muted); }
.cv-share-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.cv-share-row-text b { font-size: 13.5px; }
.cv-share-row-text small { font-size: 12px; color: var(--ink-faint); }
.cv-switch { position: relative; flex-shrink: 0; width: 46px; height: 28px; padding: 0; border-radius: 999px; border: 1px solid var(--line); background: var(--field-line); cursor: pointer; transition: background-color .2s ease, border-color .2s ease; }
.cv-switch-knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #FFFFFF; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .22s cubic-bezier(.3, .7, .4, 1); }
.cv-switch[aria-checked="true"] { background: var(--select); border-color: var(--select); }
.cv-switch[aria-checked="true"] .cv-switch-knob { transform: translateX(18px); }
:root[data-mode="dark"] .cv-switch[aria-checked="true"] .cv-switch-knob { background: #121316; }
@media (prefers-color-scheme: dark) { :root:not([data-mode="light"]) .cv-switch[aria-checked="true"] .cv-switch-knob { background: #121316; } }
.cv-switch[disabled] { opacity: .6; cursor: progress; }
.cv-share-link { display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 12px; border: 1px solid var(--field-line); border-radius: 999px; background: var(--field); }
.cv-share-link[hidden], .cv-share-pop .pop-actions[hidden] { display: none; }
.cv-share-link:focus-within { border-color: var(--select); }
.cv-share-url { flex: 1; min-width: 0; height: 34px; border: 0; background: transparent; color: var(--ink); font: 12.5px var(--mono); text-overflow: ellipsis; }
.cv-share-url:focus { outline: none; }
.cv-share-link .icon-btn { width: 32px; height: 32px; border-radius: 999px; flex-shrink: 0; }
.cv-share-link .btn { border-radius: 999px; min-height: 32px; flex-shrink: 0; }

/* ---------- Phones: bottom sheet ---------- */
.cv-hist-back { position: fixed; inset: 0; z-index: 44; background: rgba(10, 11, 13, .38); }
@media (min-width: 901px) { .cv-hist-back { display: none; } }
@media (max-width: 900px) {
  .cv-hist { left: 0; right: 0; bottom: 0; top: auto !important; width: auto; max-width: none; max-height: min(78vh, 640px); border-radius: 26px 26px 0 0; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px); }
  .cv-grab { display: block; width: 40px; height: 5px; margin: 8px auto 0; border-radius: 999px; background: var(--line); flex-shrink: 0; }
  .cv-hist-head { padding-top: 10px; }
  .cv-hist-foot { padding-bottom: 12px; }
}
@media (max-width: 640px) {
  .topbar .cv-share-btn { width: 38px; padding: 0; }
  .cv-share-lbl { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cv-switch, .cv-switch-knob { transition: none; }
}
.cv-old-text .cv-short { display: none; }
@media (max-width: 480px) { .cv-old-text .cv-long { display: none; } .cv-old-text .cv-short { display: inline; } }
.mac.phone .cv-old-text .cv-long { display: none; }
.mac.phone .cv-old-text .cv-short { display: inline; }
.home .grid .pcard .cv-card-dup { width: 30px; }
