/* Invitation to the new look (V2): a thin banner for V1 users and a full-screen tour that shows
 * their own app in both looks. See js/v2-tour.js. */

/* ── Banner: one quiet line at the very top, V1 only ── */
.v2-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 34px;
  margin: 0;
  padding: 6px 16px;
  border: none;
  border-bottom: 1px solid var(--card-border);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-secondary));
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  line-height: 1.3;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s ease;
}

.v2-banner:hover {
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-secondary));
}

.v2-banner:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.v2-banner strong {
  color: var(--text-primary);
  font-weight: 600;
}

.v2-banner-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

:root[data-ui="v2"] .v2-banner,
:root[data-preview] .v2-banner {
  display: none;
}

/* The preview copies inside the tour: no scrollbars. */
:root[data-preview] {
  scrollbar-width: none;
}

:root[data-preview]::-webkit-scrollbar {
  display: none;
}

/* ── Tour ── */
.v2t {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  opacity: 0;
  transition: opacity 0.22s ease;
}

.v2t:focus {
  outline: none;
}

.v2t.is-open {
  opacity: 1;
}

.v2t.is-leaving {
  opacity: 0;
  transition-duration: 0.3s;
}

.v2t-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 3vw, 36px);
}

.v2t-progress {
  display: flex;
  gap: 6px;
}

.v2t-seg {
  width: 34px;
  height: 20px;
  padding: 8px 0;
  border: none;
  background: none;
  cursor: pointer;
}

.v2t-seg::before {
  content: "";
  display: block;
  height: 4px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--text-primary) 14%, transparent);
  transition: background 0.2s ease;
}

.v2t-seg.is-done::before,
.v2t-seg.is-active::before {
  background: var(--accent);
}

.v2t-seg:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.v2t-main {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: clamp(20px, 3vw, 40px);
  min-height: 0;
  padding: 0 clamp(16px, 3vw, 36px) clamp(16px, 3vh, 32px);
}

/* ── Left: what changed ── */
.v2t-copy {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 2px 2px;
}

.v2t-title {
  margin: 0 0 10px;
  font-size: clamp(28px, 2.6vw, 38px);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.025em;
}

.v2t-body {
  margin: 0;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.5;
}

.v2t-changes {
  display: grid;
  gap: 4px;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
}

.v2t-change {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  padding: 10px 12px 10px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.v2t-change:hover {
  background: color-mix(in srgb, var(--text-primary) 5%, transparent);
}

.v2t-change.is-active {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--card-border));
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.v2t-change:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.v2t-change-num,
.v2t-marker {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text-on-accent, #fff);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.v2t-change-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.v2t-change-label {
  font-size: 15px;
  font-weight: 600;
}

.v2t-change-text {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.4;
}

.v2t-hint {
  margin: 14px 0 0;
  min-height: 18px;
  color: var(--text-tertiary);
  font-size: 13px;
}

.v2t-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 20px;
}

.v2t-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: none;
  color: var(--text-primary);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.v2t-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.v2t-btn--primary {
  flex: 1;
  background: var(--accent);
  color: var(--text-on-accent, #fff);
}

.v2t-btn--primary:hover {
  background: color-mix(in srgb, var(--accent) 88%, #000);
}

.v2t-btn--ghost {
  border-color: var(--card-border);
  color: var(--text-secondary);
}

.v2t-btn--ghost:hover {
  border-color: color-mix(in srgb, var(--text-primary) 22%, var(--card-border));
  color: var(--text-primary);
}

.v2t-btn--quiet {
  height: 34px;
  padding: 0 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.v2t-btn--quiet:hover {
  background: color-mix(in srgb, var(--text-primary) 6%, transparent);
  color: var(--text-primary);
}

.v2t-btn[disabled] {
  opacity: 0.6;
  cursor: default;
}

/* ── Right: the real app, old under new ── */
.v2t-stage {
  --pos: 100%;
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: var(--bg-secondary);
}

.v2t-frames {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  pointer-events: none;
}

.v2t-frame {
  position: absolute;
  inset: 0;
  display: block;
  border: 0;
  background: var(--bg-primary);
}

.v2t-frame--new {
  clip-path: inset(0 0 0 var(--pos));
}

.v2t-overlay {
  position: absolute;
  inset: 0;
}

.v2t-range {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
}

.v2t-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos);
  z-index: 2;
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.v2t-handle span {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}

.v2t-range:focus-visible ~ .v2t-handle span {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent), 0 0 0 7px var(--accent);
}

.v2t-side-tag {
  position: absolute;
  bottom: 12px;
  z-index: 2;
  padding: 4px 10px;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.v2t-side-tag--old {
  left: 12px;
}

.v2t-side-tag--new {
  right: 12px;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--card-border));
  color: var(--accent);
}

.v2t-stage.is-all-new .v2t-side-tag--old,
.v2t-stage.is-all-old .v2t-side-tag--new,
.v2t-stage.is-all-new .v2t-handle,
.v2t-stage.is-final .v2t-handle,
.v2t-stage.is-final .v2t-side-tag,
.v2t-stage.is-final .v2t-range {
  opacity: 0;
}

.v2t-stage.is-final .v2t-range {
  pointer-events: none;
}

/* Callouts sit on the new look; they hide while the old look covers it. */
.v2t-markers {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  clip-path: inset(0 0 0 var(--pos));
}

.v2t-marker {
  position: absolute;
  border: 2px solid var(--bg-secondary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  pointer-events: auto;
  animation: v2t-pop 0.25s cubic-bezier(0.3, 1.4, 0.5, 1) both;
}

.v2t-marker:nth-child(2) { animation-delay: 60ms; }
.v2t-marker:nth-child(3) { animation-delay: 120ms; }
.v2t-marker:nth-child(4) { animation-delay: 180ms; }

.v2t-marker.is-active,
.v2t-marker:hover {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent), 0 2px 8px rgba(0, 0, 0, 0.25);
}

.v2t-marker:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Zoomed-in change: everything else on the new side dims. Clipped like the callouts, so the
 * box and the dimming never cover the old look. */
.v2t-spot-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
  clip-path: inset(0 0 0 var(--pos));
}

.v2t-spot {
  position: absolute;
  z-index: 2;
  border-radius: 10px;
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 9999px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  animation: v2t-spot-in 0.15s ease both;
}

@keyframes v2t-spot-in {
  from {
    opacity: 0;
  }
}

.v2t-loading {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  background: var(--bg-secondary);
  color: var(--text-tertiary);
  font-size: 14px;
}

.v2t-loading[hidden] {
  display: none;
}

@keyframes v2t-pop {
  from {
    opacity: 0;
    transform: scale(0.4);
  }
}

/* ── Phones: the preview on top, what changed underneath ── */
@media (max-width: 820px) {
  .v2t {
    overflow-y: auto;
  }

  .v2t-main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 56vh auto;
    gap: 18px;
  }

  .v2t-stage {
    order: -1;
  }

  .v2t-copy {
    overflow: visible;
    padding-top: 0;
  }

  .v2t-title {
    font-size: 26px;
  }

  .v2t-changes {
    margin-top: 14px;
  }

  .v2t-actions {
    position: sticky;
    bottom: 0;
    padding: 14px 0 4px;
    background: var(--bg-primary);
  }
}

@media (prefers-reduced-motion: reduce) {
  .v2t,
  .v2t-spot,
  .v2t-seg::before {
    transition: none;
  }

  .v2t-marker {
    animation: none;
  }
}

/* ── The switch: a blueprint of the page rearranges itself (js/v2-morph.js) ── */
:root.is-morphing .layout {
  opacity: 0;
}

:root.is-morph-revealing .layout {
  animation: v2-morph-reveal 0.7s ease both;
}

.v2-morph {
  position: fixed;
  inset: 0;
  z-index: 190;
  overflow: hidden;
  pointer-events: none;
  background-image:
    linear-gradient(color-mix(in srgb, var(--accent) 9%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--accent) 9%, transparent) 1px, transparent 1px);
  background-size: 24px 24px;
  animation: v2-morph-grid 0.3s ease both;
}

.v2-morph.is-done {
  animation: v2-morph-out 0.7s ease both;
}

.v2-morph-box {
  position: absolute;
  box-sizing: border-box;
  border: 1.5px solid color-mix(in srgb, var(--accent) 70%, transparent);
  background: color-mix(in srgb, var(--accent) 7%, var(--bg-primary));
}

/* Corner ticks, like a layout guide. */
.v2-morph-box::before,
.v2-morph-box::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  border-color: var(--accent);
  border-style: solid;
}

.v2-morph-box::before {
  top: -3px;
  left: -3px;
  border-width: 2px 0 0 2px;
}

.v2-morph-box::after {
  right: -3px;
  bottom: -3px;
  border-width: 0 2px 2px 0;
}

.v2-morph-box.is-new {
  border-style: dashed;
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-primary));
}

.v2-morph-box.is-leaving {
  border-color: color-mix(in srgb, var(--text-tertiary) 60%, transparent);
  background: transparent;
}

.v2-morph-box.is-leaving::before,
.v2-morph-box.is-leaving::after {
  display: none;
}

@keyframes v2-morph-grid {
  from {
    opacity: 0;
  }
}

@keyframes v2-morph-out {
  to {
    opacity: 0;
  }
}

@keyframes v2-morph-reveal {
  from {
    opacity: 0;
  }
}
