/*
 * Saunter — Application Styles
 * Custom styles that complement the Tailwind build.
 */

/* =========================================================
   Physical Card — Swipe, Flip, and Intent Overlays
   ========================================================= */

/* Backdrop: viewport-level blur that dims during drag */
.card-backdrop {
  position: fixed;
  inset: 0;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  background: rgba(0, 0, 0, 0.15);
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.08s ease-out;
}

/* Arena: card owns the full width, side hints float outside */
.card-arena {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template:
    "up"   auto
    "card" 1fr
    "down" auto
    / 1fr;
  justify-items: center;
  gap: 0.25rem;
  max-width: min(84vw, 40rem);
  margin: 0 auto;
  padding: 0.25rem 0;
}

/* Direction hint buttons — subtle labels that double as accessible actions */
.card-hint {
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #9ca3af;
  background: none;
  border: none;
  padding: 0.375rem 0.5rem;
  cursor: pointer;
  transition: color 0.2s ease, transform 0.15s ease;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.card-hint-up:hover,
.card-hint-down:hover {
  transform: scale(1.06);
}

.card-hint-up:active,
.card-hint-down:active {
  transform: scale(0.96);
}

.card-hint-up    { grid-area: up;   color: #93c5fd; }
.card-hint-down  { grid-area: down; color: #c4b5fd; }

/* Side hints: absolutely positioned, rotated to run along card edge */
.card-hint-left,
.card-hint-right {
  position: absolute;
  top: 50%;
  z-index: 0;
}

.card-hint-left  { right: calc(100% + 0.25rem); color: #d1d5db; transform: translateY(-50%) rotate(-90deg); }
.card-hint-right { left:  calc(100% + 0.25rem); color: #86efac; transform: translateY(-50%) rotate(90deg); }

.card-hint-up:hover    { color: #3b82f6; }
.card-hint-down:hover  { color: #8b5cf6; }
.card-hint-left:hover  { color: #6b7280; }
.card-hint-right:hover { color: #22c55e; }

/* Stage: the draggable card — aspect-ratio for a real card feel */
.card-stage {
  grid-area: card;
  position: relative;
  width: 100%;
  height: min(70vh, 36rem);
  perspective: 1200px;
  -webkit-perspective: 1200px;
  z-index: 1;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  border-radius: 0.75rem;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.06),
    0 4px 12px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.25s ease;
}

/* Mini card variant for grids (wander complete, etc.) */
.card-stage--mini {
  grid-area: unset;
  width: 100%;
  max-width: 20rem;
  height: auto;
  aspect-ratio: 3 / 4;
  touch-action: auto;
  cursor: pointer;
}

/* Standalone card — full-size for dedicated card page */
.card-stage--standalone {
  grid-area: unset;
  width: min(84vw, 40rem);
  height: min(70vh, 36rem);
  touch-action: auto;
  cursor: pointer;
}

.card-stage.card-grabbing {
  cursor: grabbing;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.10),
    0 16px 48px rgba(0, 0, 0, 0.06);
}

/* Deck edges — white card shapes that peek out from behind */
.card-deck-edge {
  grid-area: card;
  align-self: stretch;
  width: 100%;
  border-radius: 0.75rem;
  background: white;
  pointer-events: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.card-deck-edge--far {
  opacity: 0.3;
  transform: scale(0.96) rotate(3deg) translateY(6px);
}

.card-deck-edge--near {
  opacity: 0.5;
  transform: scale(0.97) rotate(-1.8deg) translateY(4px);
}

/* Shimmer — responsive gradient that shifts hue with drag direction */
.card-shimmer {
  grid-area: card;
  align-self: stretch;
  width: 100%;
  border-radius: 0.75rem;
  pointer-events: none;
  background: linear-gradient(
    135deg,
    hsl(220 30% 82%),
    hsl(260 35% 76%)
  );
  opacity: 0.55;
  transform: scale(0.97) translateY(4px);
  animation: shimmer-breathe 5s ease-in-out infinite;
}

@keyframes shimmer-breathe {
  0%, 100% { filter: hue-rotate(0deg)  saturate(1);   opacity: 0.45; }
  50%      { filter: hue-rotate(25deg) saturate(1.15); opacity: 0.55; }
}

/* Inner: flips on Y-axis when tapped — fills the card stage */
.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-inner.card-flipped {
  transform: rotateY(180deg);
}

/* Faces: fill the card, auto-size text via container queries */
.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 0.75rem;
  background: white;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  container-type: size;
}

.card-back {
  transform: rotateY(180deg);
}

/* Card content text — scales with the card face dimensions */
.card-content {
  font-size: clamp(0.9rem, 5.5cqi, 1.5rem);
  line-height: 1.35;
  text-wrap: balance;
}

/* Intent overlays — fill card with color tint + label during drag */
.card-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  opacity: 0;
  pointer-events: none;
  z-index: 10;
}

.card-overlay span {
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.375rem 0.875rem;
  border-radius: 0.375rem;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.card-overlay-keep {
  background: rgba(34, 197, 94, 0.14);
  border: 2px solid rgba(34, 197, 94, 0.45);
}
.card-overlay-keep span { color: #16a34a; }

.card-overlay-reject {
  background: rgba(156, 163, 175, 0.14);
  border: 2px solid rgba(156, 163, 175, 0.45);
}
.card-overlay-reject span { color: #6b7280; }

.card-overlay-more {
  background: rgba(59, 130, 246, 0.14);
  border: 2px solid rgba(59, 130, 246, 0.45);
}
.card-overlay-more span { color: #2563eb; }

.card-overlay-challenge {
  background: rgba(139, 92, 246, 0.14);
  border: 2px solid rgba(139, 92, 246, 0.45);
}
.card-overlay-challenge span { color: #7c3aed; }

/* Brand card front — logo contained, not cropped */
.card-front--brand {
  display: grid;
  grid-template-rows: 1fr auto auto;
  align-items: center;
  justify-items: center;
  padding: 1.5rem 1.5rem 4.5rem;
  background: #fff;
}

.card-brand-logo {
  grid-row: 1;
  max-width: 70%;
  max-height: 90%;
  object-fit: contain;
}

/* Tension card front — setup + kicker with gradient */
.card-front--tension {
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: linear-gradient(175deg, #fff 40%, #fef3ec 75%, #fde8d8 100%);
  container-type: size;
}

.card-tension-setup {
  font-size: clamp(0.875rem, 5cqi, 1.35rem);
  line-height: 1.45;
  color: #4b5563;
  text-wrap: balance;
  margin-bottom: 0.75em;
}

.card-tension-kicker {
  font-size: clamp(0.95rem, 5.5cqi, 1.45rem);
  line-height: 1.35;
  font-style: italic;
  font-weight: 500;
  color: #c2410c;
  text-wrap: balance;
  padding-top: 0.75em;
  border-top: 1px solid rgba(194, 65, 12, 0.15);
}

/* Keyword card front — big, bold, centered single word */
.card-front--keyword {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: #fff;
  container-type: size;
}

.card-keyword-text {
  font-size: clamp(1.75rem, 14cqi, 3.5rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: #0a0a0a;
  text-transform: uppercase;
  padding: 0 1.5rem;
}

/* Quote card front — magazine pull-quote feel */
.card-front--quote {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  background: linear-gradient(165deg, #fafafa 0%, #f3f0ed 100%);
  container-type: size;
}

.card-quote-mark {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3rem, 18cqi, 7rem);
  line-height: 0.7;
  color: rgba(0, 0, 0, 0.08);
  margin-bottom: 0.25rem;
  user-select: none;
}

.card-quote-text {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: clamp(1rem, 6cqi, 1.625rem);
  line-height: 1.4;
  color: #1a1a1a;
  text-wrap: balance;
}

/* Tap hint — subtle indicator, pushed to bottom of card */
.card-tap-hint {
  font-size: 0.6875rem;
  color: #9ca3af;
  text-align: center;
  padding-top: 0.75rem;
  letter-spacing: 0.02em;
  margin-top: auto;
}

/* Image card front — image fills the card with a small inset border */
.card-front--image {
  padding: 0.375rem;
  overflow: hidden;
}

.card-front-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0.5rem;
}

/* Caption — frosted glass overlay pinned to bottom-left */
.card-image-caption {
  position: absolute;
  bottom: 0.75rem;
  left: 0.75rem;
  right: 2.5rem;
  padding: 0.5rem 0.625rem;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border-radius: 0.5rem;
  font-size: 0.75rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.card-image-hint {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  font-size: 0.6875rem;
  color: rgba(255, 255, 255, 0.6);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.02em;
}

/* Hidden forms — no layout contribution */
.card-forms { display: none; }

/* =========================================================
   Narrative Markdown — lightweight prose styling
   ========================================================= */

.narrative-markdown p {
  margin-bottom: 0.5em;
}

.narrative-markdown p:last-child {
  margin-bottom: 0;
}

.narrative-markdown strong {
  font-weight: 600;
}

.narrative-markdown em {
  font-style: italic;
}

.narrative-markdown ul,
.narrative-markdown ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.narrative-markdown ul { list-style-type: disc; }
.narrative-markdown ol { list-style-type: decimal; }

.narrative-markdown li {
  margin-bottom: 0.25em;
}

.narrative-markdown code {
  font-size: 0.875em;
  background: rgba(0, 0, 0, 0.06);
  padding: 0.125em 0.375em;
  border-radius: 0.25rem;
}

.narrative-markdown blockquote {
  border-left: 3px solid #d1d5db;
  padding-left: 0.75em;
  margin: 0.5em 0;
  color: #6b7280;
  font-style: italic;
}

.narrative-markdown a {
  display: inline-flex;
  align-items: baseline;
  gap: 0.25em;
  padding: 0.125em 0.5em 0.125em 0.375em;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: 0.375rem;
  color: #7c3aed;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.narrative-markdown a:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.4);
}

.narrative-markdown a::before {
  content: "";
  display: inline-block;
  width: 0.875em;
  height: 0.875em;
  flex-shrink: 0;
  position: relative;
  top: 0.1em;
  background: currentColor;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Crect x='2' y='1' width='12' height='14' rx='1.5' stroke='currentColor' stroke-width='1.5'/%3E%3Cline x1='5' y1='5.5' x2='11' y2='5.5' stroke='currentColor' stroke-width='1.2' stroke-linecap='round'/%3E%3Cline x1='5' y1='8.5' x2='9' y2='8.5' stroke='currentColor' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E");
  mask-size: contain;
  mask-repeat: no-repeat;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Crect x='2' y='1' width='12' height='14' rx='1.5' stroke='currentColor' stroke-width='1.5'/%3E%3Cline x1='5' y1='5.5' x2='11' y2='5.5' stroke='currentColor' stroke-width='1.2' stroke-linecap='round'/%3E%3Cline x1='5' y1='8.5' x2='9' y2='8.5' stroke='currentColor' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
}
