/* Find the Friend: the friend to look for at the top, the garden of pictures below. */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.5rem 1rem 0;
}

:root {
  --field-bg: #E4F1DC;
  --tile: #FFFFFF;
  --tile-border: #9DB8A3;
  --found: #1E7A3A;
  --hint-ring: #005A5E;
  --scan-ring: #7A3FB0;
}

:root[data-theme="contrast"] {
  --field-bg: #000000;
  --tile: #000000;
  --tile-border: #FFFFFF;
  --found: #00E676;
  --hint-ring: #FFE600;
  --scan-ring: #FF66FF;
}

.target-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.target-pic {
  width: 84px;
  height: 84px;
  padding: 6px;
  border: 4px solid var(--accent);
  border-radius: 18px;
  background: var(--tile);
}

.target-pic svg {
  display: block;
  width: 100%;
  height: 100%;
}

.target-text {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  font-weight: 800;
}

.found-count {
  margin: 0;
  padding: 0.25rem 0.9rem;
  border: 2px solid var(--panel-border);
  border-radius: 999px;
  font-weight: 700;
}

.field {
  position: relative;
  flex: 1;
  min-height: 340px;
  margin-top: 0.5rem;
  border: 3px solid var(--panel-border);
  border-radius: 20px;
  overflow: hidden;
  background: var(--field-bg);
}

/* Each picture is a button placed by the script */
.item {
  position: absolute;
  padding: 0;
  border: 3px solid var(--tile-border);
  border-radius: 18%;
  background: var(--tile);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

/* The picture fills the tile (leaving room for the name when names are shown) */
.item .pic {
  position: absolute;
  inset: 9%;
}

.item.named .pic {
  bottom: 27%;
}

.item .pic svg {
  display: block;
  width: 100%;
  height: 100%;
}

.item .name {
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 5%;
  font-size: clamp(0.75rem, 1.5vw, 1rem);
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
}

.item:focus-visible {
  outline: 5px solid var(--focus);
  outline-offset: 3px;
  z-index: 3;
}

/* Not the friend: a small, friendly wiggle (no failure) */
.item.nope {
  animation: wiggle 0.5s ease-in-out;
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-7deg); }
  75% { transform: rotate(7deg); }
}

/* Found it */
.item.found {
  z-index: 2;
  border-color: var(--found);
  box-shadow: 0 0 0 7px var(--found);
  animation: hooray 0.7s ease-out;
}

@keyframes hooray {
  0% { transform: scale(1); }
  45% { transform: scale(1.18); }
  100% { transform: scale(1.08); }
}

/* "Show me": a ring that grows and shrinks gently (steady with reduce motion) */
.item.hint {
  z-index: 2;
  box-shadow: 0 0 0 8px var(--hint-ring);
  animation: hint 1.6s ease-in-out infinite;
}

@keyframes hint {
  0%, 100% { box-shadow: 0 0 0 6px var(--hint-ring); }
  50% { box-shadow: 0 0 0 14px var(--hint-ring); }
}

/* Switch scanning: the picture whose turn it is */
.item.scan {
  z-index: 2;
  border-color: var(--scan-ring);
  box-shadow: 0 0 0 8px var(--scan-ring);
}

.field.paused .item {
  animation-play-state: paused;
}

/* Looking guide: a soft band of light that crosses the garden from left to right */
.guide {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 18%;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 246, 196, 0.75), rgba(255, 255, 255, 0));
  pointer-events: none;
  animation: sweep 9s linear infinite;
}

:root[data-theme="contrast"] .guide {
  background: linear-gradient(90deg, rgba(255, 230, 0, 0), rgba(255, 230, 0, 0.3), rgba(255, 230, 0, 0));
}

.field.paused .guide {
  animation-play-state: paused;
}

@keyframes sweep {
  0% { transform: translateX(-100%); }
  85%, 100% { transform: translateX(560%); }
}

/* With reduce motion the guide becomes a still "Start here" sign on the left */
.guide-start {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  margin: 0;
  padding: 0.2rem 0.7rem;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  z-index: 4;
}

.guide-start[hidden],
.guide[hidden] {
  display: none;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 0 0.25rem;
}
