/* Reusable UI components — scaffolded per SPEC-modularization.md.
   No instances on the page yet; styles activate when Toast/Modal/Tooltip are used. */

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  max-width: 320px;
  padding: 0.75rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--color-text);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--transition-base), transform var(--transition-base);
  pointer-events: none;
  z-index: 1000;
}
.toast.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.toast--success { border-color: #2a6a2a; }
.toast--error { border-color: var(--color-red); box-shadow: 0 0 12px var(--color-red-glow); }
.toast--info { border-color: var(--color-border); }

/* Anchored variant — sits next to its trigger (positioned via JS) so it
   reads as feedback for that specific action rather than a global
   notification. Tighter padding and a subtle shadow to feel like a
   contextual badge. */
.toast--anchored {
  padding: 0.4rem 0.7rem;
  font-size: 0.65rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

/* ---------- Back-to-top button ----------
   Floating circular button bottom-right. Hidden by default, fades in
   once .is-visible is added (BackToTop.update() toggles it past a
   scroll threshold). Aesthetic mirrors the dock pill: translucent dark
   well, faint border, soft red halo on hover. On mobile we lift it
   above the bottom dock with a bit of clearance. */
.back-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  background: rgba(15, 12, 14, 0.72);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  color: var(--color-text-muted);
  cursor: pointer;
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 200ms ease,
    transform 200ms ease,
    color 180ms ease,
    background 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
  box-shadow:
    0 0 14px rgba(139, 0, 0, 0.1),
    0 6px 18px rgba(0, 0, 0, 0.35);
}
.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.back-to-top:hover {
  color: var(--color-text);
  background: rgba(30, 20, 24, 0.85);
  border-color: rgba(179, 0, 0, 0.4);
  box-shadow:
    0 0 18px rgba(139, 0, 0, 0.28),
    0 8px 22px rgba(0, 0, 0, 0.45);
}
.back-to-top svg { width: 18px; height: 18px; }

@media (max-width: 768px) {
  .back-to-top {
    /* Clears the bottom-anchored horizontal mobile dock (~3.75rem
       reach from the viewport edge) with a small breathing gap. */
    bottom: 4.5rem;
    right: 0.85rem;
    width: 36px;
    height: 36px;
  }
  .back-to-top svg { width: 16px; height: 16px; }
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}
.modal-overlay.visible { opacity: 1; pointer-events: auto; }
.modal {
  width: min(420px, calc(100% - 2rem));
  padding: 1.75rem;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: 6px;
}
.modal__title { font-family: var(--font-title); font-size: 1.2rem; font-weight: 500; margin-bottom: 0.5rem; letter-spacing: -0.005em; }
.modal__text { font-family: var(--font-body); font-size: 0.9rem; font-weight: 300; color: var(--color-text-secondary); line-height: 1.6; margin-bottom: 1.25rem; }
.modal__actions { display: flex; gap: 0.6rem; justify-content: flex-end; }
.modal__btn {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.55rem 1rem;
  border-radius: 3px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.modal__btn--confirm { background: var(--color-red); border: 1px solid var(--color-red); color: var(--color-text); }
.modal__btn--confirm:hover { background: var(--color-red-bright); box-shadow: 0 0 15px var(--color-red-glow); }
.modal__btn--cancel { background: transparent; border: 1px solid var(--color-border); color: var(--color-text-muted); }
.modal__btn--cancel:hover { color: var(--color-text); border-color: var(--color-text-muted); }

/* ---------- Tooltip ---------- */
.tooltip { position: relative; display: inline-block; }
.tooltip__content {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%) scale(0.85);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 0.3rem 0.55rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  color: var(--color-text);
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-fast);
}
.tooltip:hover .tooltip__content,
[data-tooltip]:hover > .tooltip__content { opacity: 1; transform: translateX(-50%) scale(1); }

/* ---------- Tag pill ---------- */
.tag-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--color-border);
  border-radius: 2px;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: all var(--transition-fast);
}
.tag-pill:hover {
  border-color: var(--color-red);
  color: var(--color-text);
}
.tag-pill-list { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; }

/* ---------- Empty / placeholder note ---------- */
.empty-note {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  padding: 0.75rem 0;
  text-align: center;
}

/* ---------- View loading bar (SPA router) ----------
   Top-of-page hairline progress bar, shown only when a route's mount()
   takes longer than 200ms (see js/router.js _showLoaderAfter). Pure
   visual signal — no spinner, no overlay, doesn't block input. */
#view-loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-red-bright);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease, opacity 0.2s ease;
  opacity: 0;
  z-index: 1000;
  pointer-events: none;
}
#view-loading.is-loading {
  transform: scaleX(0.7);
  opacity: 1;
}

/* ---------- View transitions (SPA router) ----------
   Native View Transitions API animates the swap between routes. The
   shell (hero/dock/footer/bg) is unchanged across routes, so the
   default root cross-fade is invisible on those pixels — the user
   only perceives the fade where #view's content actually differs.

   Note: we used to set view-transition-name: route-view on #view to
   animate it as a separate snapshot, but that property creates a
   permanent stacking context — trapping z-index:50 pin on the
   super-featured card under the sticky hero (z-index:40). Falling
   back to root transitions removes the trap; the pin's z-index now
   competes with the hero in the page's root SC, as intended.

   Chrome/Edge/Safari ship the API; Firefox falls back to an instant
   swap via the feature check in js/router.js _navigate. */
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root) {
    animation: rt-fade-out 300ms ease-out forwards;
  }
  ::view-transition-new(root) {
    animation: rt-fade-in 300ms ease forwards;
  }
  @keyframes rt-fade-out {
    to { opacity: 0; }
  }
  @keyframes rt-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
}


/* ---------- Ghost notes ----------
   Random handwritten notes (managed via admin > notes) that fade in
   after a delay. The .ghost-note element ships its own inline
   positioning per-note (the position pool lives in js/ghost-notes.js);
   everything else is styled here. */
.ghost-note {
  z-index: 80;
  max-width: 180px;
  padding: 0.6rem 0.8rem;
  background: rgba(20, 16, 14, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(139, 0, 0, 0.2);
  border-radius: 3px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 2s ease;
  pointer-events: auto;
}

.ghost-note.is-visible { opacity: 1; }

.ghost-note__text {
  font-family: var(--font-display);
  font-size: 0.78rem;
  color: var(--color-text-secondary);
  line-height: 1.4;
  display: block;
}

.ghost-note__sig {
  font-family: var(--font-display);
  font-size: 0.6rem;
  color: var(--color-text-muted);
  display: block;
  text-align: right;
  margin-top: 0.25rem;
}

/* Dismiss: scale-down + fade so the note feels lifted away rather
   than blinking out. Faster transition overrides the 2s fade-in. */
.ghost-note.is-dismissing {
  transition: opacity 0.4s ease, transform 0.4s ease;
  opacity: 0;
  transform: scale(0.8) rotate(8deg);
}

@media (prefers-reduced-motion: reduce) {
  .ghost-note { transition: opacity 0.3s ease; }
  .ghost-note.is-dismissing { transition: opacity 0.2s ease; transform: none; }
}
