/* Nicecard template preview — a modal over the gallery: the invitation plays at phone width inside a
   device frame, scrolling on its own while its music plays, beside 立即制作. Class prefix: ncp-. */

.ncp {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(24, 19, 15, 0.62);
  outline: none;
  animation: ncp-fade 180ms var(--ease);
}

/* ── Top strip: over the dimmed gallery, like the reference's darkened header. Blurred and darkened a
   step further, so the gallery's own logo and search do not show through under the template name. ── */
.ncp-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 10px 0 24px;
  background: rgba(20, 15, 12, 0.5);
  color: var(--cream);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.ncp-top-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
  margin: 0;
}

.ncp-top-kicker {
  flex: none;
  font-size: 12px;
  letter-spacing: 0.14em;
  opacity: 0.72;
}

.ncp-top-name {
  overflow: hidden;
  font-family: var(--f-serif);
  font-size: 19px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ncp-top-stats {
  display: none;
}

.ncp-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--cream);
  cursor: pointer;
  transition: background 160ms;
}

.ncp-close:hover {
  background: rgba(255, 252, 245, 0.14);
}

.ncp-close:focus-visible {
  outline: 2px solid var(--cream);
  outline-offset: 2px;
}

/* ── Sheet: stage on the left, details on the right ── */
.ncp-sheet {
  position: absolute;
  inset: 52px 0 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(300px, 25vw, 372px);
  grid-template-rows: minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  border-radius: 16px 16px 0 0;
  background: var(--cream);
  animation: ncp-rise 280ms var(--ease);
}

.ncp-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  padding: 22px 24px 16px;
  border-radius: var(--r-lg);
  background: radial-gradient(120% 80% at 50% 0%, #f7f3ec 0%, #efe9df 100%);
}

.ncp-device {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  width: 414px;
  max-width: 100%;
  min-height: 0;
  max-height: 868px;
  padding: 12px;
  border-radius: 52px;
  background: var(--device);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 36px 64px -32px rgba(34, 31, 28, 0.6);
}

/* The side key — the one detail that makes a dark rounded box read as a phone. */
.ncp-device::before {
  content: '';
  position: absolute;
  top: 168px;
  right: -3px;
  width: 3px;
  height: 64px;
  border-radius: 0 3px 3px 0;
  background: #36302a;
}

.ncp-screen {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 40px;
  background: #fff;
  outline: none;
  scrollbar-width: none;
}

.ncp-screen::-webkit-scrollbar {
  display: none;
}

.ncp-screen:focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 3px;
}

/* The falling effect and the wishes barrage (effects.js) lie over the phone's screen, inside its rounded corners,
   under the music disc. The screen is a stacking context of its own, so the couple's free elements stay below. */
.ncp-screen {
  isolation: isolate;
}

.ncp-device > .nci-fx {
  inset: 12px;
  z-index: 5;
  border-radius: 40px;
}

/* The preview shows the invitation as guests will see it: no editing hints under the text. */
.ncp-screen .nci-f--hint {
  border-bottom-color: transparent !important;
}

/* ── Music disc: NC.StudioMusic, placed at the page's top right ──
   Playing, it is a small spinning disc. Stopped — by the viewer, or by a browser that blocks autoplay —
   it opens into a pill that says 点击播放音乐. The label waits a beat before it opens, so the moment
   between mounting and the first note does not flash a pill. */
.ncp-device > .studio-music {
  position: absolute;
  top: 28px;
  right: 28px;
  z-index: 6;
}

.ncp-device > .studio-music button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 13px 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  background: rgba(38, 28, 22, 0.52);
  color: #fff;
  font: 500 15px/1 var(--f-sans);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  cursor: pointer;
}

.ncp-device > .studio-music button span {
  display: inline-block;
  overflow: hidden;
  max-width: 12em;
  margin-left: 6px;
  font-size: 12px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  animation: ncp-label 260ms 700ms var(--ease) both;
}

.ncp-device > .studio-music button[aria-pressed='false'] {
  animation: ncp-pulse 1.8s 1s ease-out 3;
}

.ncp-device > .studio-music button[aria-pressed='true'] {
  width: 36px;
  padding: 0;
  animation: ncp-spin 5s linear infinite;
}

.ncp-device > .studio-music button[aria-pressed='true'] span {
  display: none;
}

.ncp-device > .studio-music button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ── 向下滑动查看: a vertical pill beside the page ── */
.ncp-hint {
  position: absolute;
  top: 50%;
  left: calc(100% + 16px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px 10px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: #fffdf9;
  color: var(--mute-2);
  font-size: 13px;
  line-height: 1.2;
  box-shadow: 0 8px 18px -12px rgba(58, 49, 40, 0.4);
  cursor: pointer;
  transform: translateY(-50%);
  transition: color 160ms, border-color 160ms;
}

.ncp-hint:hover {
  border-color: rgba(58, 49, 40, 0.3);
  color: var(--ink);
}

.ncp-hint span {
  letter-spacing: 0.24em;
  writing-mode: vertical-rl;
}

.ncp-hint svg {
  animation: ncp-bob 1.6s ease-in-out infinite;
}

/* ── Playback: progress, pause / resume, 从头播放 ── */
.ncp-play {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 12px;
  width: 414px;
  max-width: 100%;
}

.ncp-progress {
  height: 3px;
  margin: 0 30px;
  overflow: hidden;
  border-radius: 3px;
  background: rgba(58, 49, 40, 0.12);
}

.ncp-progress > div {
  height: 100%;
  background: var(--action);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

.ncp-play-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 10px;
}

.ncp-pbtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px 0 11px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: #fffdf9;
  color: var(--ink);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  transition: background 160ms, border-color 160ms;
}

.ncp-pbtn:hover {
  border-color: rgba(58, 49, 40, 0.32);
}

.ncp-pbtn--main {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--cream);
}

.ncp-pbtn--main:hover {
  background: #2a231c;
}

.ncp-status {
  font-size: 12px;
  color: var(--mute);
}

/* ── Details ── */
.ncp-info {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 24px 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: #fffdf9;
}

.ncp-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0 14px;
  border-bottom: 1px solid var(--line);
}

.ncp-share,
.ncp-fav {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  color: var(--ink-2);
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  transition: color 160ms, background 160ms;
}

.ncp-share {
  padding: 8px 2px;
  background: transparent;
}

.ncp-share:hover {
  color: var(--brand);
}

.ncp-fav {
  padding: 8px 16px 8px 13px;
  border-radius: var(--r-sm);
  background: rgba(58, 49, 40, 0.05);
}

.ncp-fav:hover {
  background: rgba(58, 49, 40, 0.09);
}

.ncp-fav[aria-pressed='true'] {
  background: var(--blush);
  color: var(--action);
}

.ncp-name {
  margin: 28px 0 8px;
  font-family: var(--f-serif);
  font-size: 32px;
  font-weight: 500;
  line-height: 1.15;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.ncp-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 13px;
  color: var(--mute);
}

.ncp-sep {
  width: 1px;
  height: 12px;
  background: var(--line-2);
}

.ncp-make {
  display: block;
  width: 100%;
  height: 52px;
  margin: 30px 0 0;
  border: 0;
  border-radius: 999px;
  background: var(--action);
  color: var(--cream);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.08em;
  box-shadow: 0 14px 26px -16px rgba(166, 68, 58, 0.9);
  cursor: pointer;
  transition: background 160ms, transform 160ms;
}

.ncp-make:hover {
  background: #8f3a31;
}

.ncp-make:active {
  transform: translateY(1px);
}

.ncp-steps {
  margin-top: 34px;
}

.ncp-steps-title {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--mute);
}

.ncp-steps ol {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: ncp-step;
}

.ncp-steps li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink-2);
  counter-increment: ncp-step;
}

.ncp-steps li::before {
  content: counter(ncp-step);
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blush);
  color: var(--brand);
  font-size: 12px;
  line-height: 1;
}

/* The couple's own invitation (the editor's 预览分享): the guest link under 继续编辑. */
.ncp-link {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 28px;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--mute);
}

.ncp-link input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fff;
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  letter-spacing: 0;
}

.ncp-link input:focus-visible {
  outline: 2px solid var(--action);
  outline-offset: 1px;
}

.ncp-foot {
  margin: auto 0 0;
  padding-top: 22px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--mute);
}

/* ── Phones and small tablets: the page full-width, 立即制作 fixed along the bottom ── */
@media (max-width: 900px) {
  .ncp {
    display: flex;
    flex-direction: column;
    background: #efe9df;
  }

  .ncp-top {
    position: static;
    flex: none;
    height: auto;
    min-height: 52px;
    padding: 6px 4px 6px 16px;
    background: var(--device);
  }

  .ncp-top-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
  }

  .ncp-top-kicker {
    display: none;
  }

  .ncp-top-name {
    max-width: 100%;
    font-size: 17px;
    line-height: 1.25;
  }

  .ncp-top-stats {
    display: block;
    font-size: 11px;
    line-height: 1.3;
    opacity: 0.72;
  }

  .ncp-sheet {
    position: static;
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    padding: 0;
    gap: 0;
    border-radius: 0;
    background: transparent;
    animation: none;
  }

  .ncp-stage {
    flex: 1;
    gap: 0;
    padding: 0;
    border-radius: 0;
    background: transparent;
  }

  .ncp-device {
    width: 100%;
    max-width: 430px;
    max-height: none;
    padding: 0;
    border-radius: 0;
    background: #fff;
    box-shadow: none;
  }

  .ncp-device::before {
    display: none;
  }

  .ncp-screen {
    border-radius: 0;
  }

  .ncp-device > .nci-fx {
    inset: 0;
    border-radius: 0;
  }

  .ncp-screen:focus-visible {
    outline-offset: -2px;
  }

  .ncp-device > .studio-music {
    top: 12px;
    right: 12px;
  }

  .ncp-hint {
    left: auto;
    right: 10px;
    padding: 12px 7px 9px;
    border-color: transparent;
    background: rgba(38, 28, 22, 0.5);
    color: #fff;
    font-size: 12px;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
  }

  .ncp-hint:hover {
    border-color: transparent;
    color: #fff;
  }

  /* Playback floats over the foot of the page; the bar runs along its bottom edge. */
  .ncp-play {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: 430px;
    margin: 0 auto;
    gap: 0;
    pointer-events: none;
  }

  .ncp-play-row {
    order: 1;
    justify-content: flex-start;
    padding: 0 12px 12px;
  }

  .ncp-progress {
    order: 2;
    height: 2px;
    margin: 0;
    border-radius: 0;
  }

  .ncp-pbtn,
  .ncp-pbtn--main {
    height: 36px;
    padding: 0 11px;
    border-color: transparent;
    background: rgba(38, 28, 22, 0.55);
    color: #fff;
    pointer-events: auto;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
  }

  .ncp-pbtn:hover,
  .ncp-pbtn--main:hover {
    border-color: transparent;
    background: rgba(38, 28, 22, 0.7);
  }

  /* Running, the controls are two quiet icons; stopped, the way back in says what it does. */
  .ncp-pbtn .ncp-pbtn-label {
    display: none;
  }

  .ncp-pbtn--main {
    padding-right: 14px;
  }

  .ncp-pbtn--main .ncp-pbtn-label {
    display: inline;
  }

  .ncp-status {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .ncp-info {
    flex: none;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    overflow: visible;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
  }

  .ncp-info-row,
  .ncp-info-main {
    display: contents;
  }

  .ncp-share,
  .ncp-fav {
    flex-direction: column;
    gap: 2px;
    min-width: 52px;
    padding: 4px 6px;
    border-radius: var(--r-sm);
    background: transparent;
    font-size: 11px;
  }

  .ncp-fav[aria-pressed='true'] {
    background: transparent;
  }

  .ncp-name,
  .ncp-stats,
  .ncp-steps,
  .ncp-link,
  .ncp-foot {
    display: none;
  }

  .ncp-make {
    flex: 1;
    height: 46px;
    margin: 0 0 0 6px;
    font-size: 16px;
  }
}

@keyframes ncp-fade {
  from {
    opacity: 0;
  }
}

@keyframes ncp-rise {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
}

@keyframes ncp-spin {
  to {
    rotate: 360deg;
  }
}

@keyframes ncp-pulse {
  from {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.6);
  }
  to {
    box-shadow: 0 0 0 12px rgba(255, 255, 255, 0);
  }
}

@keyframes ncp-label {
  from {
    max-width: 0;
    margin-left: 0;
    opacity: 0;
  }
}

@keyframes ncp-bob {
  50% {
    transform: translateY(3px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ncp,
  .ncp-sheet,
  .ncp-hint svg,
  .ncp-device > .studio-music button span,
  .ncp-device > .studio-music button[aria-pressed='false'],
  .ncp-device > .studio-music button[aria-pressed='true'] {
    animation: none;
  }
}
