/* Observings - daily neighborhood game */

:root {
  --bg: #f5f0e8;
  --tile-bg: #e8e7e3;
  --text: #1a1a1a;
  --text-secondary: #5c5c5c;

  /* 8 unique earthy found colors */
  --color-0: #c67d5e; /* terracotta */
  --color-1: #87a878; /* sage */
  --color-2: #c9a9a6; /* dusty rose */
  --color-3: #d4a84b; /* ochre */
  --color-4: #7b9ea8; /* slate blue */
  --color-5: #a67c52; /* warm brown */
  --color-6: #8b7355; /* taupe */
  --color-7: #b8860b; /* dark goldenrod */
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

html {
  background: #87a878;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: transparent;
  color: var(--text);
  display: flex;
  flex-direction: column;
  padding: 0;
  margin: 0;
}

/* Sage frame that fills entire viewport including safe areas */
.frame {
  position: fixed;
  inset: 0;
  background: #87a878;
  z-index: -1;
}

/* App chrome sits inside the sage frame */
.app-chrome {
  position: fixed;
  top: 6px;
  bottom: 6px;
  left: 3px;
  right: 3px;
  max-width: 400px;
  margin: 0 auto;
  background: var(--bg);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  overflow: hidden;
  z-index: 1;
}

/* Header */
.header {
  text-align: center;
  padding: 0.5rem 0 1rem;
}

.header h1 {
  font-family: 'DM Serif Display', serif;
  font-size: 2rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.header .date {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

.header .prompt {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.35rem;
  font-style: italic;
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  flex: 1;
}

.tile {
  background: var(--tile-bg);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 0.5rem;
  cursor: pointer;
  transition: transform 0.1s ease-out, background-color 0.3s, box-shadow 0.15s;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  /* For FLIP animation */
  will-change: transform;
}

.tile * {
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
}

.tile img {
  -webkit-user-drag: none;
  user-drag: none;
}

.tile:active {
  transform: scale(0.97);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.06);
}

/* Pulse on find — z-index lift + glow, no scale */
.tile-found-pulse {
  position: relative;
  z-index: 10;
  animation: tile-pulse 0.3s ease-out;
}

@keyframes tile-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(135, 168, 120, 0);
    filter: brightness(1);
  }
  35% {
    box-shadow: 0 0 0 6px rgba(135, 168, 120, 0.35);
    filter: brightness(1.08);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(135, 168, 120, 0);
    filter: brightness(1);
  }
}

/* Found tile colors */
.tile.found {
  color: white;
}

.tile.found .tile-name {
  color: white;
}

.tile.color-0 { background: var(--color-0); }
.tile.color-1 { background: var(--color-1); }
.tile.color-2 { background: var(--color-2); }
.tile.color-3 { background: var(--color-3); }
.tile.color-4 { background: var(--color-4); }
.tile.color-5 { background: var(--color-5); }
.tile.color-6 { background: var(--color-6); }
.tile.color-7 { background: var(--color-7); }

/* Invert icon to white when found */
.tile.found .tile-icon img {
  filter: brightness(0) invert(1);
}

.tile-icon {
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.tile-icon img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: filter 0.3s;
}

.tile-icon-placeholder {
  width: 42px;
  height: 42px;
  border: 2px dashed rgba(0,0,0,0.2);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 1.2rem;
}

.tile.found .tile-icon-placeholder {
  border-color: rgba(255,255,255,0.4);
  color: white;
}

.tile-name {
  font-size: 0.95rem;
  color: var(--text);
  text-align: center;
  line-height: 1.2;
  transition: color 0.3s;
}

/* Photo tiles */
.tile.has-photo {
  padding: 0;
  overflow: hidden;
  position: relative;
}

.tile.has-photo .tile-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem 0.4rem 0.4rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.45));
  color: white;
  border-radius: 0 0 8px 8px;
}

.tile-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.tile.found .tile-photo {
  filter: none;
}

/* Undo confirmation overlay */
.tile.undo-confirm::after {
  content: 'Hold to undo';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: inherit;
  animation: fadeIn 0.15s ease;
  z-index: 10;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Nature celebration */
.celebration {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 150;
  overflow: visible;
}

.nature-piece {
  position: fixed;
  top: -30px;
  font-size: var(--piece-size, 18px);
  animation: nature-fall var(--fall-duration) var(--fall-delay) ease-out forwards;
  pointer-events: none;
  z-index: 150;
}

@keyframes nature-fall {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg);
  }
  85% {
    opacity: 0.8;
  }
  100% {
    opacity: 0;
    transform: translate(var(--drift-x), calc(100vh + 50px)) rotate(var(--spin));
  }
}

/* Completion */
.completion {
  display: none;
  text-align: center;
  padding: 2rem 1rem;
  flex: 1;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  background: var(--bg);
}

.completion.show {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

.completion h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.5rem;
  font-weight: normal;
  margin-bottom: 0.5rem;
}

.completion p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.completion-trail {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 0.75rem;
  margin-bottom: 1.5rem;
  gap: 0.4rem;
}

.trail-caption {
  font-size: 0.75rem;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.trail-dots {
  display: flex;
  align-items: center;
  justify-content: center;
}

.trail-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2.5px solid var(--text-secondary);
  background: transparent;
  flex-shrink: 0;
}

.trail-dot.day-full {
  background: var(--color-1);
  border-color: var(--color-1);
}

.trail-dot.day-partial {
  background: transparent;
  border-color: var(--color-1);
}

.trail-dot.day-none {
  background: transparent;
  border-color: var(--text-secondary);
  opacity: 0.3;
}

.trail-dot.today {
  width: 16px;
  height: 16px;
}

.trail-line {
  width: 18px;
  height: 2.5px;
  background: var(--text-secondary);
  opacity: 0.25;
}

.share-btn {
  padding: 0.75rem 2rem;
  background: var(--text);
  color: white;
  border: none;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
}

.share-btn:active {
  background: #333;
}

.view-card-btn {
  display: block;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.view-card-btn:active {
  color: var(--text);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--text);
  color: white;
  padding: 0.6rem 1.25rem;
  border-radius: 999px;
  font-size: 0.85rem;
  opacity: 0;
  transition: all 0.25s;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Footer */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  margin-top: 0.5rem;
}

.streak {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.print-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.print-btn svg {
  flex-shrink: 0;
  text-decoration: none;
}

.print-btn:active {
  color: var(--text);
}

.hidden {
  display: none !important;
}

/* Coaching tooltip */
.photo-hint {
  position: absolute;
  z-index: 50;
  background: var(--color-1);
  color: white;
  padding: 0.85rem 1.1rem;
  border-radius: 14px;
  font-family: 'DM Serif Display', serif;
  font-style: italic;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  line-height: 1.4;
  max-width: 220px;
  text-align: center;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

.photo-hint.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.photo-hint-arrow {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--color-1);
}

/* Camera overlay */
.camera-overlay {
  position: fixed;
  inset: 0;
  background: black;
  z-index: 300;
  display: none;
  flex-direction: column;
}

.camera-overlay.show {
  display: flex;
}

#camera-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.viewfinder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -55%);
  width: 280px;
  height: 280px;
  border: 3px solid rgba(255,255,255,0.8);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.55);
  z-index: 2;
  pointer-events: none;
}

.camera-controls {
  position: absolute;
  bottom: 50px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 50px;
  z-index: 3;
}

.camera-shutter-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: white;
  border: 4px solid rgba(255,255,255,0.3);
  cursor: pointer;
  box-shadow: 0 0 0 4px rgba(255,255,255,0.15);
}

.camera-shutter-btn:active {
  transform: scale(0.92);
}

.camera-cancel-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  cursor: pointer;
  padding: 0.5rem 1rem;
}

/* Camera fallback UI */
.camera-fallback {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  z-index: 5;
  background: black;
}

.camera-fallback.show {
  display: flex;
}

.camera-fallback-text {
  color: rgba(255,255,255,0.6);
  font-size: 0.95rem;
}

.camera-fallback-btn {
  padding: 0.85rem 2rem;
  background: white;
  color: black;
  border: none;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}

.camera-fallback-btn:active {
  background: #e0e0e0;
}

/* Splash screen */
.splash {
  position: fixed;
  inset: 0;
  background: #87a878;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 1;
  visibility: visible;
  transition: opacity 1s ease, visibility 1s ease;
}

.splash.fade-out {
  opacity: 0;
  visibility: hidden;
}

.splash-content {
  text-align: center;
  padding: 2rem;
}

.splash-title {
  font-family: 'DM Serif Display', serif;
  font-size: 3.2rem;
  font-weight: 400;
  color: #fdfcfa;
  letter-spacing: -0.02em;
  line-height: 1.15;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.splash-title.visible {
  opacity: 1;
  transform: translateY(0);
}

.splash-tagline {
  font-size: 1.2rem;
  color: rgba(253, 252, 250, 0.6);
  margin-top: 2rem;
  letter-spacing: 0.01em;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.splash-tagline.visible {
  opacity: 1;
  transform: translateY(0);
}

/* App wrapper (hidden during splash) */
.app {
  display: flex;
  flex-direction: column;
  flex: 1;
  opacity: 0;
  transition: opacity 0.4s ease;
  min-height: 0;
}

.app.visible {
  opacity: 1;
}

/* Responsive */
@media (max-height: 680px) {
  .tile {
    padding: 0.5rem;
  }
  .tile-icon {
    width: 56px;
    height: 56px;
  }
  .header {
    padding: 0.25rem 0 0.75rem;
  }
}
