/* css/components.css
 *
 * Shared building blocks used across every card: the glass-card surface,
 * skeleton shimmer (replaces all spinners), ambient placeholders, pill
 * buttons/toggles, and the global tactile press state.
 */

/* ---- Glassmorphic card surface -----------------------------------------
 * Semi-transparent charcoal, backdrop-blur, rounded ~20px corners, and a
 * 1px top hairline highlight in the accent at low opacity.
 */
.glass-card {
  position: relative;
  padding: var(--space-lg);
  background: var(--color-surface);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-radius: var(--radius-card);
  border: 1px solid var(--color-hairline-faint);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.glass-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(180deg, var(--color-hairline), transparent 45%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* ---- Skeleton shimmer ---------------------------------------------------
 * Replaces every spinner. A soft amber sweep over a slightly-raised
 * charcoal block.
 */
.shimmer {
  position: relative;
  background: var(--color-surface-raised);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.shimmer::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, var(--color-accent-faint) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: shimmer-sweep 1.6s ease-in-out infinite;
}

/* ---- Ambient placeholder --------------------------------------------
 * Used whenever there's genuinely nothing to show (no destination, no
 * Spotify connection, nothing playing) — never a bare error string.
 */
.ambient-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  text-align: center;
  padding: var(--space-lg);
  min-height: 12rem;
}

.ambient-placeholder--compact {
  min-height: 8rem;
  padding: var(--space-md);
}

.ambient-placeholder__glow {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  background: radial-gradient(circle, var(--color-accent-soft), transparent 70%);
}

.ambient-placeholder__text {
  color: var(--color-text-secondary);
  font-size: var(--text-body);
}

/* ---- Segmented pill toggle -----------------------------------------------
 * Shared by every tab with a mode switch (Sky's Now/5-Day, Discover's
 * category pills, Tip's payment-method toggle) so the visual language
 * stays identical without each tab's stylesheet redefining it.
 */
.pill-toggle {
  display: inline-flex;
  align-self: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: var(--radius-pill);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-hairline-faint);
  margin-bottom: var(--space-md);
}

.pill-toggle__btn {
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
  background: none;
  border: none;
}

.pill-toggle__btn.is-active {
  background: var(--color-accent-faint);
  color: var(--color-accent);
}

/* ---- Pill buttons / toggles -------------------------------------------- */
.pill-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-hairline);
  color: var(--color-accent);
  font-size: var(--text-caption);
  letter-spacing: 0.02em;
  background: var(--color-accent-faint);
}

.facts-toggle,
.connect-spotify-btn {
  margin-top: var(--space-sm);
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-hairline);
  color: var(--color-accent);
  font-size: var(--text-caption);
  background: var(--color-accent-faint);
}

/* .facts-toggle sits under left-aligned destination text; pull it to the
 * same edge rather than letting it center under the column. */
.facts-toggle {
  align-self: flex-start;
}

/* ---- Global tactile press state ----------------------------------------
 * Every interactive element gets the same scale(0.97) + brief accent glow
 * on press, per the motion spec.
 */
button,
a[href],
.trivia-card,
.discover-tile,
.journey-fact-card {
  transition: transform var(--duration-press) var(--ease-standard),
    box-shadow var(--duration-press) var(--ease-standard);
}

button:active,
a[href]:active,
.trivia-card:active,
.discover-tile:active,
.journey-fact-card:active {
  transform: scale(0.97);
  box-shadow: 0 0 0 1px var(--color-accent-soft), 0 0 20px var(--color-accent-soft);
}

/* ---- Sleep overlay ------------------------------------------------------ */
.sleep-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #050506;
  opacity: 0;
  pointer-events: none;
  transition: opacity 420ms var(--ease-standard);
}

/* The [hidden] attribute is how JS fully removes the overlay from paint
 * and hit-testing between naps; .is-visible (added a frame later) is what
 * animates the fade-in. Author styles normally beat the UA [hidden] rule
 * on specificity ties, so this has to be explicit. */
.sleep-overlay[hidden] {
  display: none;
}

.sleep-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.sleep-overlay__text {
  font-family: var(--font-serif);
  font-size: var(--text-title);
  color: var(--color-text-secondary);
  letter-spacing: 0.02em;
}

/* ---- Feedback toast (js/feedback.js) ------------------------------------
 * A small anchored toast, deliberately NOT a full-screen overlay like
 * .sleep-overlay/.driver-info-overlay above — it must never feel modal or
 * blocking. Sits just above the bottom nav bar, same [hidden] + .is-visible
 * + rAF fade-in convention, but a rise+fade rather than a plain fade since
 * it's arriving from a specific edge rather than covering the whole screen.
 */
.feedback-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--space-md) + 4.5rem);
  transform: translate(-50%, 0.5rem);
  z-index: 60;

  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  width: max-content;
  max-width: min(90%, 420px);

  background: var(--color-surface);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-hairline-faint);
  box-shadow: var(--shadow-card);

  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms var(--ease-standard), transform 320ms var(--ease-standard);
}

.feedback-toast[hidden] {
  display: none;
}

.feedback-toast.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.feedback-toast__question {
  font-size: var(--text-caption);
  color: var(--color-text-primary);
}

.feedback-toast__actions {
  display: flex;
  gap: var(--space-xs);
  flex: none;
}

.feedback-toast__btn {
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--color-text-secondary);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-hairline-faint);
}

.feedback-toast__btn svg {
  width: 1.1rem;
  height: 1.1rem;
}

.feedback-toast__btn:active {
  color: var(--color-accent);
}

/* Phase 8 (docs/plan/00-implementation-plan.md §11.2): the thumbs-down
 * reason-chip sub-step (js/feedback.js's showReasonChips()) swaps the same
 * toast to a stacked layout — the base .feedback-toast row layout above has
 * no room for 3-4 chips beside the question. */
.feedback-toast--reasons {
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-sm);
  max-width: min(90%, 460px);
}

.feedback-toast--reasons .feedback-toast__question {
  text-align: center;
}

.feedback-toast__reasons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-xs);
}

.feedback-toast__chip {
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-caption);
  color: var(--color-text-secondary);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-hairline-faint);
}

.feedback-toast__chip:active {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

