/**
 * Shared styles for the social surfaces (guestbook now; gallery + comments
 * later). Linked, NOT inlined — only tokens/layout/components get inlined.
 * Also the new home of the celebration animations relocated from rsvp.css so
 * both the RSVP and guestbook pages share one definition.
 */

/* ------------------------------------------------------------------ *
 * Relocated celebration animations (shared by RSVP + guestbook)
 * ------------------------------------------------------------------ */
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}

.form-error-shake {
  animation: shake var(--duration-moderate) ease;
}

/* Confetti + sparkle motion (.confetti-piece / .mini-sparkle) moved to
   components.css so celebrate.js works on pages that don't load social.css
   (e.g. the home-page countdown milestone). */

/* ------------------------------------------------------------------ *
 * Shared status chip + field error (guestbook page lacks admin.css)
 * ------------------------------------------------------------------ */
.status-badge {
  display: inline-block;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  background: var(--_badge-bg);
  color: var(--_badge-text);
}

.status-pending {
  --_badge-bg: var(--color-status-pending-bg);
  --_badge-text: var(--color-status-pending-text);
}

.field-error {
  margin: var(--spacing-xs) 0 0;
  color: var(--color-error, #b91c1c);
  font-size: var(--text-sm);
}

/* ------------------------------------------------------------------ *
 * Auth sheet
 * ------------------------------------------------------------------ */
.auth-sheet {
  width: min(440px, calc(100vw - 2rem));
  max-width: 440px;
  padding: var(--spacing-xl);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-card-bg);
  color: var(--color-text);
  box-shadow: var(--shadow-lg);
}

.auth-sheet::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.auth-sheet h2 {
  font-family: var(--font-display);
  margin: 0 0 var(--spacing-sm);
}

.auth-sheet .modal-close {
  position: absolute;
  top: var(--spacing-sm);
  right: var(--spacing-sm);
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius-full);
}

.auth-help {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin: 0 0 var(--spacing-md);
}

.auth-panel .form-group {
  margin-bottom: var(--spacing-md);
}

.auth-panel input[type="text"] {
  width: 100%;
  min-height: 44px;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 1rem;
}

.auth-panel input[aria-invalid="true"] {
  border-color: var(--color-error, #b91c1c);
}

.auth-panel .btn-large {
  width: 100%;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin: var(--spacing-md) 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.auth-link {
  display: inline-block;
  min-height: 44px;
  padding: var(--spacing-xs) var(--spacing-sm);
  border: none;
  background: transparent;
  color: var(--color-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  text-decoration: underline;
  cursor: pointer;
}

.auth-welcome {
  padding: var(--spacing-xl) var(--spacing-md);
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--color-primary);
}

/* "Posting as {name} · Not you?" — signed-in identity + account switch. */
.guest-identity {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-xs);
  margin-bottom: var(--spacing-sm);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.guest-identity-label strong {
  color: var(--color-text);
}

.guest-identity-switch {
  min-height: 44px;
  padding: 2px var(--spacing-xs);
  font-size: var(--text-sm);
}

/* Mobile: dock the sheet to the bottom edge. */
@media (max-width: 767px) {
  .auth-sheet {
    margin: auto auto 0;
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}

/* ------------------------------------------------------------------ *
 * Guestbook composer + entries
 * ------------------------------------------------------------------ */
.gb-composer {
  margin-bottom: var(--spacing-lg);
}

.gb-textarea {
  width: 100%;
  min-height: 88px;
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 1rem;
  resize: vertical;
}

/* These textareas live outside .form-group, so they miss the shared input
   focus treatment — give them the same ring for consistency. */
.gb-textarea:focus,
.comment-input:focus {
  outline: 2px solid transparent;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 15%, transparent);
}

.gb-composer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--spacing-md); /* counter ↔ the full-size Sign button (#15) */
  margin-top: var(--spacing-sm);
}

/* Live "N/max" counter for capped textareas (guestbook + comments). Visual
   aid only (aria-hidden); the maxlength attribute does the real enforcing. */
.char-counter {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.gb-composer-actions .char-counter {
  margin-right: auto; /* counter left, submit stays right */
}

/* Hint for the ⌘↵ / Ctrl↵ post shortcut. Hidden by default: phone keyboards
   have no modifier row, so it would be a lie on touch. Revealed only on a real
   pointer + keyboard, and only while the composer has focus — it teaches the
   accelerator at the moment it's usable without cluttering the feed. */
.composer-hint {
  display: none;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .composer-hint {
    display: inline;
    margin-right: auto; /* hint left, counter + Post stay right */
    opacity: 0;
    transition: opacity var(--duration-fast) ease;
  }

  .comment-composer:focus-within .composer-hint,
  .gb-composer:focus-within .composer-hint {
    opacity: 1;
  }

  /* The hint has taken the left slot, so the counter tucks in beside the
     button it constrains. On touch the hint is gone and the rule above
     doesn't apply, so the counter keeps the far-left position it has today. */
  .gb-composer-actions .char-counter {
    margin-right: 0;
  }
}

/* Dismissible one-time note, shared by the guestbook pending note, the gallery
   pending note, and the cross-feature nudges. .gb-pending-note kept as an alias
   for the guestbook's existing markup. */
.pending-note,
.gb-pending-note {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
  background: var(--color-alert-warning-bg);
  color: var(--color-alert-warning-text);
  font-size: var(--text-sm);
}

/* A nudge (not a warning) reads friendlier in the brand accent. */
.pending-note.note-nudge {
  background: var(--color-primary-faint);
  color: var(--color-text);
}

.pending-note a {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
}

.note-dismiss,
.gb-note-dismiss {
  flex: none;
  min-width: 44px;
  min-height: 44px;
  margin: -0.5rem -0.5rem -0.5rem auto;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.gb-feed {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.gb-entry {
  padding: var(--spacing-md) var(--spacing-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-card-bg);
  box-shadow: var(--shadow-sm);
}

.gb-entry-pending {
  opacity: 0.85;
  border-left: 4px solid var(--color-status-pending-text);
}

.gb-entry-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-xs);
}

.gb-author {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--color-text);
}

.gb-time {
  flex: none;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.gb-message {
  margin: 0;
  white-space: pre-line;
  line-height: 1.6;
  color: var(--color-text);
}

.gb-pending-chip {
  margin-top: var(--spacing-sm);
}

.gb-entry-foot:empty {
  display: none;
}

/* Author-only self-delete on an own entry — quiet text button on its own row
   below the reaction bar / comment toggle, mirrors .comment-delete. */
.gb-delete {
  display: block;
  margin-top: var(--spacing-xs);
  border: none;
  background: none;
  padding: 0;
  color: var(--color-danger);
  font: inherit;
  font-size: var(--text-xs);
  cursor: pointer;
}

.gb-delete:hover {
  text-decoration: underline;
}

/* Share this note — quiet text button beside Delete, mirrors .gb-delete. */
.gb-share {
  display: inline-block;
  margin-top: var(--spacing-xs);
  margin-right: var(--spacing-md);
  border: none;
  background: none;
  padding: 0;
  color: var(--color-primary);
  font: inherit;
  font-size: var(--text-xs);
  cursor: pointer;
}

.gb-share:hover {
  text-decoration: underline;
}

/* Brief highlight when a ?entry= deep link scrolls to a note. */
.gb-entry-highlight {
  animation: gb-entry-flash 2.4s ease-out;
}

@keyframes gb-entry-flash {
  0%,
  30% {
    box-shadow: 0 0 0 3px var(--color-primary);
  }
  100% {
    box-shadow: var(--shadow-sm);
  }
}

@media (prefers-reduced-motion: reduce) {
  .gb-entry-highlight {
    animation: none;
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
  }
}

.gb-loadmore-wrap {
  margin-top: var(--spacing-lg);
}

/* ------------------------------------------------------------------ *
 * Admin moderation tab (admin page also links this sheet)
 * ------------------------------------------------------------------ */
.moderation-preview {
  max-width: 32ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.moderation-quote {
  margin: var(--spacing-md) 0;
  padding: var(--spacing-sm) var(--spacing-md);
  border-left: 3px solid var(--color-primary);
  background: var(--color-primary-faint);
  border-radius: var(--radius-sm);
  white-space: pre-line;
  line-height: 1.5;
}

/* ------------------------------------------------------------------ *
 * Reactions + comments (Phase 5) — shared by guestbook cards + gallery
 * lightbox panel. 44px touch targets; reduced-motion kills the bump.
 * ------------------------------------------------------------------ */
.reaction-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  align-items: center;
}

.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  min-height: 44px;
  padding: 0 var(--spacing-sm);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-card-bg);
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-sm);
  line-height: 1;
  cursor: pointer;
  transition: background var(--duration-fast), border-color var(--duration-fast);
}

.reaction-pill:hover {
  border-color: var(--color-primary);
}

.reaction-pill.reaction-mine {
  background: var(--color-primary-faint);
  border-color: var(--color-primary);
}

.reaction-glyph {
  font-size: 1.05em;
}

.reaction-count:empty {
  display: none;
}

.reaction-count {
  min-width: 1ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
}

.reaction-mine .reaction-count {
  color: var(--color-primary-dark);
}

@keyframes reaction-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

.reaction-bump {
  animation: reaction-bump var(--duration-fast) ease-out;
}

/* ---- comment thread ---- */
.comment-thread {
  margin-top: var(--spacing-xs);
}

/* Styled like a reaction pill so it reads as pressable, not as stray text. */
.comment-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  min-height: 44px;
  padding: 0 var(--spacing-sm);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-card-bg);
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-sm);
  line-height: 1;
  cursor: pointer;
  transition: background var(--duration-fast), border-color var(--duration-fast);
}

.comment-toggle:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.comment-toggle-glyph {
  font-size: 1.05em;
}

.comment-body {
  margin-top: var(--spacing-sm);
}

.comment-list {
  list-style: none;
  margin: 0 0 var(--spacing-sm);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.comment {
  padding: var(--spacing-sm);
  border-radius: var(--radius-sm);
  background: var(--color-primary-faint);
}

.comment-pending {
  opacity: 0.85;
  border-left: 3px solid var(--color-status-pending-text);
}

.comment-head {
  display: flex;
  justify-content: space-between;
  gap: var(--spacing-sm);
  align-items: baseline;
}

.comment-author {
  font-weight: 600;
  font-size: var(--text-sm);
}

.comment-time {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.comment-message {
  margin: var(--spacing-2xs) 0 0;
  white-space: pre-line;
  line-height: 1.5;
  font-size: var(--text-sm);
}

.comment-pending-chip {
  margin-top: var(--spacing-xs);
}

.comment-delete {
  margin-top: var(--spacing-2xs);
  border: none;
  background: none;
  padding: 0;
  color: var(--color-danger);
  font: inherit;
  font-size: var(--text-xs);
  cursor: pointer;
}

.comment-delete:hover {
  text-decoration: underline;
}

.comment-composer {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.comment-input {
  width: 100%;
  padding: var(--spacing-sm);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-card-bg);
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-sm);
  resize: vertical;
}

/* Row under the textarea: hint (left), counter + Post (right). Mirrors
   .gb-composer-actions so the two composers read as the same control. */
.comment-composer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--spacing-sm);
}

.comment-loading,
.comment-empty,
.comment-error {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.comment-error {
  color: var(--color-danger);
}

/* ---- lightbox panel social block (dark stage) ---- */
.lightbox-social {
  margin-top: var(--spacing-md);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

@media (prefers-reduced-motion: reduce) {
  .reaction-bump {
    animation: none;
  }
}

/* ── Wow pack: monogram avatars, host replies, Favorites, empty-state ── */

/* Deterministic monogram avatar (public/components/monogram.js). Colored circle
   whose hue is name-derived; white text stays legible on both themes. Decorative
   (aria-hidden) — the author name is always shown as text beside it. */
.monogram {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-full);
  background: hsl(var(--mono-hue, 210) 45% 42%);
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.85rem;
  line-height: 1;
  user-select: none;
}

/* Hue buckets for .monogram, set by renderMonogram (bucket centres, 30° apart).
   Classes rather than an inline custom property, because the CSP blocks style
   attributes. */
.mono-h0 {
  --mono-hue: 15;
}
.mono-h1 {
  --mono-hue: 45;
}
.mono-h2 {
  --mono-hue: 75;
}
.mono-h3 {
  --mono-hue: 105;
}
.mono-h4 {
  --mono-hue: 135;
}
.mono-h5 {
  --mono-hue: 165;
}
.mono-h6 {
  --mono-hue: 195;
}
.mono-h7 {
  --mono-hue: 225;
}
.mono-h8 {
  --mono-hue: 255;
}
.mono-h9 {
  --mono-hue: 285;
}
.mono-h10 {
  --mono-hue: 315;
}
.mono-h11 {
  --mono-hue: 345;
}

/* Author + monogram grouped so the timestamp can sit at the far edge. */
.gb-byline {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  min-width: 0;
}

.gb-entry-head {
  align-items: center;
}

.gb-byline .gb-author {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Smaller monogram inside comment threads. */
.comment-head .monogram {
  width: 1.5rem;
  height: 1.5rem;
  font-size: 0.7rem;
}

.comment-head {
  align-items: center;
}

.comment-head .comment-time {
  margin-left: auto;
}

/* Host / couple reply: a distinct badge chip + a warm accent border. */
.host-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.05rem 0.5rem;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--color-primary) 18%, transparent);
  color: var(--color-primary-dark);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
}

.comment-host {
  border-left: 3px solid var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 8%, var(--color-primary-faint));
}

.comment-host-hint {
  margin: 0 0 var(--spacing-2xs);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-primary-dark);
}

/* Admin-only pin/unpin — quiet text buttons, like .gb-share. */
.gb-pin,
.gb-unpin {
  display: inline-block;
  margin-top: var(--spacing-xs);
  margin-right: var(--spacing-md);
  border: none;
  background: none;
  padding: 0;
  color: var(--color-primary);
  font: inherit;
  font-size: var(--text-xs);
  cursor: pointer;
}

.gb-pin:hover,
.gb-unpin:hover {
  text-decoration: underline;
}

.gb-unpin {
  color: var(--color-text-muted);
}

/* Admin-pinned "Favorites" strip above the feed. Distinct card treatment with a
   sparkle-divider accent under the heading. */
.gb-favorites {
  margin-bottom: var(--spacing-lg);
  padding: var(--spacing-md) var(--spacing-lg);
  border: 1px solid color-mix(in srgb, var(--color-primary) 30%, var(--color-border));
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--color-primary) 5%, var(--color-card-bg));
  box-shadow: var(--shadow-sm);
}

.gb-favorites-title {
  margin: 0 0 var(--spacing-sm);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--color-text);
}

.gb-favorites-title::after {
  content: "";
  display: block;
  margin-top: var(--spacing-xs);
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    color-mix(in srgb, var(--color-primary) 55%, transparent),
    transparent
  );
}

.gb-favorites-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--spacing-sm);
}

.gb-fav {
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card-bg);
}

.gb-fav-message {
  margin: var(--spacing-2xs) 0 0;
  white-space: pre-line;
  line-height: 1.5;
  font-size: var(--text-sm);
  color: var(--color-text);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Empty state, and the ink-flourish divider under the guestbook title. */
.gb-empty {
  text-align: center;
}

.gb-flourish {
  position: relative;
  display: block;
  width: 140px;
  height: 12px;
  margin: 0 auto var(--spacing-sm);
}

.gb-flourish::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  transform: translateY(-50%);
  background: linear-gradient(
    90deg,
    transparent,
    color-mix(in srgb, var(--color-primary) 45%, transparent) 20%,
    color-mix(in srgb, var(--color-primary) 45%, transparent) 80%,
    transparent
  );
}

.gb-flourish::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  transform: translate(-50%, -50%) rotate(45deg);
  background: var(--color-primary);
}

.gb-empty-lead {
  margin: 0;
}
