/* ═══════════════════════════════════════════════
   ProfGuess — style.css
   Design: Kellogg purple/cream, matching BidTrivia
   ═══════════════════════════════════════════════ */

/* ── Custom Properties ── */
:root {
  --bg:          #FAF6F1;
  --bg-2:        #F3EDE5;
  --bg-3:        #E8DFD4;
  --card-bg:     rgba(255, 255, 255, 0.75);
  --card-border: rgba(0, 0, 0, 0.09);
  --purple:      #4E2A84;
  --purple-mid:  #6B38B8;
  --purple-light:#9B6DDF;
  --purple-glow: rgba(107, 56, 184, 0.18);
  --gold:        #8B6914;
  --gold-light:  #6B5100;
  --correct:     #16A34A;
  --correct-bg:  rgba(22, 163, 74, 0.15);
  --correct-glow:rgba(22, 163, 74, 0.2);
  --close:       #CA8A04;
  --close-bg:    rgba(202, 138, 4, 0.15);
  --close-glow:  rgba(202, 138, 4, 0.2);
  --wrong:       #DC2626;
  --wrong-bg:    rgba(220, 38, 38, 0.08);
  --wrong-glow:  rgba(220, 38, 38, 0.2);
  --neutral-bg:  rgba(0, 0, 0, 0.04);
  --text-1:      #1A1A1A;
  --text-2:      #5C5C5C;
  --text-3:      #8C8C8C;
  --font:        'Inter', system-ui, sans-serif;
  --font-serif:  'Newsreader', Georgia, 'Times New Roman', serif;
  --radius:      14px;
  --radius-sm:   8px;
  --transition:  0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --tile-size:   110px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  min-height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Screens ── */
.screen {
  display: none;
  min-height: 100dvh;
}
.screen.active { display: flex; }

/* ══════════════════════════════════════
   START SCREEN
══════════════════════════════════════ */
#start-screen {
  position: relative;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  overflow: hidden;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(78,42,132,0.08) 0%, transparent 70%),
              var(--bg);
}

/* Star particles */
.stars { position: absolute; inset: 0; pointer-events: none; }
.star {
  position: absolute;
  width: 2px; height: 2px;
  background: var(--purple-mid);
  border-radius: 50%;
  opacity: 0;
  animation: twinkle 4s infinite;
}
.star:nth-child(1)  { top:  8%; left: 12%; animation-delay: 0s; }
.star:nth-child(2)  { top: 15%; left: 78%; animation-delay: 0.8s; }
.star:nth-child(3)  { top: 30%; left: 25%; animation-delay: 1.5s; }
.star:nth-child(4)  { top: 45%; left: 88%; animation-delay: 0.3s; }
.star:nth-child(5)  { top: 60%; left: 5%;  animation-delay: 2.1s; }
.star:nth-child(6)  { top: 72%; left: 60%; animation-delay: 1.1s; }
.star:nth-child(7)  { top: 85%; left: 40%; animation-delay: 0.6s; }
.star:nth-child(8)  { top: 20%; left: 50%; animation-delay: 1.8s; }
.star:nth-child(9)  { top: 55%; left: 35%; animation-delay: 2.5s; }

@keyframes twinkle {
  0%, 100% { opacity: 0; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.5); }
}

.start-content {
  position: relative;
  z-index: 1;
  max-width: 600px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
}

.start-logo { text-align: center; }
.logo-icon {
  font-size: 4rem;
  display: block;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 0 16px rgba(78,42,132,0.3));
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.start-logo h1 {
  font-size: clamp(2.5rem, 8vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--purple) 30%, var(--purple-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.tagline {
  margin-top: 0.5rem;
  color: var(--text-2);
  font-size: 1rem;
}

/* How to play box */
.how-to-play {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  backdrop-filter: blur(12px);
}
.how-to-play h2 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  margin-bottom: 1.2rem;
}
.steps { display: flex; flex-direction: column; gap: 1rem; }
.step { display: flex; gap: 1rem; align-items: flex-start; }
.step-num {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--purple-mid);
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.step-text {
  color: var(--text-2);
  font-size: 0.9rem;
  line-height: 1.5;
}
.step-text strong { color: var(--text-1); }

/* Legend colors in step text */
.legend-green {
  background: var(--correct);
  color: white;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.82rem;
}
.legend-yellow {
  background: var(--close);
  color: white;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.82rem;
}
.legend-arrow {
  background: var(--bg-3);
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-1);
}

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 2.4rem;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, var(--purple-mid), var(--purple));
  color: white;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--purple-glow);
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--purple-glow);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 2rem;
  border: 1px solid var(--card-border);
  border-radius: 50px;
  background: var(--card-bg);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: var(--transition);
}
.btn-secondary:hover {
  color: var(--text-1);
  border-color: rgba(0,0,0,0.18);
  transform: translateY(-1px);
}

/* ══════════════════════════════════════
   GAME SCREEN
══════════════════════════════════════ */
#game-screen {
  flex-direction: column;
  background: radial-gradient(ellipse 100% 40% at 50% 0%, rgba(78,42,132,0.06) 0%, transparent 60%),
              var(--bg);
}

/* Header */
.game-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--card-border);
  background: rgba(250,246,241,0.9);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 1rem;
}

.header-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 1.25rem;
  font-weight: 800;
}
.brand-name { letter-spacing: -0.5px; }

.guess-counter-inline {
  font-size: 0.85rem;
  color: var(--text-2);
  font-weight: 600;
  white-space: nowrap;
  margin: 0 0.75rem;
  flex-shrink: 0;
}

.header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.guess-pips {
  display: flex;
  gap: 4px;
}
.pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 1px solid var(--card-border);
  transition: var(--transition);
}
.pip.used { background: var(--wrong); border-color: var(--wrong); opacity: 0.6; }
.pip.correct { background: var(--correct); border-color: var(--correct); }

/* Main */
.game-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 1.5rem 0 2rem;
  gap: 1.5rem;
}

/* ── Search / Input ── */
.input-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 1rem;
  position: relative;
}
.search-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 520px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 50px;
  padding: 0.5rem 0.5rem 0.5rem 1.2rem;
  backdrop-filter: blur(12px);
  transition: var(--transition);
}
.search-wrap:focus-within {
  border-color: var(--purple-mid);
  box-shadow: 0 0 0 3px var(--purple-glow);
}
.search-icon { color: var(--text-3); flex-shrink: 0; }
.professor-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--text-1);
  outline: none;
}
.professor-input::placeholder { color: var(--text-3); }

.btn-guess {
  flex-shrink: 0;
  padding: 0.55rem 1.2rem;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, var(--purple-mid), var(--purple));
  color: white;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  opacity: 1;
}
.btn-guess:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-guess:not(:disabled):hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px var(--purple-glow);
}

/* ── Autocomplete ── */
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  max-height: 240px;
  overflow-y: auto;
  background: white;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  z-index: 200;
  display: none;
  scrollbar-width: thin;
}
.autocomplete-list.visible { display: block; }
.autocomplete-item {
  padding: 0.65rem 1.2rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-1);
  transition: background 0.15s;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.highlighted {
  background: rgba(78,42,132,0.06);
  color: var(--purple);
}
.autocomplete-item .match-highlight {
  font-weight: 700;
  color: var(--purple-mid);
}

/* ══════════════════════════════════════
   RESULTS GRID
══════════════════════════════════════ */
.results-section {
  padding: 0 1rem;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-3) transparent;
}

.results-header {
  display: grid;
  grid-template-columns: 60px 140px repeat(8, var(--tile-size));
  gap: 6px;
  padding-bottom: 0.5rem;
  width: max-content;
  margin: 0 auto;
}
.attr-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  text-align: center;
  padding: 0 0.25rem;
}
.attr-label.attr-name { text-align: left; }

.guesses-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: max-content;
  margin: 0 auto;
}

/* ── Guess Row ── */
.guess-row {
  display: grid;
  grid-template-columns: 60px 140px repeat(8, var(--tile-size));
  gap: 6px;
  animation: row-slide-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes row-slide-in {
  0% { opacity: 0; transform: translateY(-12px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ── Tile ── */
.tile {
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.4rem;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  backdrop-filter: blur(8px);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.tile-value {
  font-size: 0.78rem;
  line-height: 1.3;
  word-break: break-word;
}
.tile-arrow {
  font-size: 0.65rem;
  margin-top: 2px;
  font-weight: 700;
}

/* Name tile */
.tile-name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 0.85rem;
  text-align: left;
  justify-content: center;
  padding-left: 0.6rem;
}

/* Image tile */
.tile-image {
  padding: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--neutral-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.tile-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.tile-image .no-image {
  color: var(--text-3);
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
}

/* ── Tile states ── */
.tile.correct {
  background: var(--correct);
  border-color: var(--correct);
  color: white;
  animation: tile-flip 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.tile.close {
  background: var(--close);
  border-color: var(--close);
  color: white;
  animation: tile-flip 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.tile.wrong {
  background: var(--neutral-bg);
  border-color: var(--card-border);
  color: var(--text-2);
  animation: tile-flip 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes tile-flip {
  0% { transform: scaleY(0); opacity: 0; }
  50% { transform: scaleY(1.08); }
  100% { transform: scaleY(1); opacity: 1; }
}

/* Stagger animation per tile */
.guess-row .tile:nth-child(1) { animation-delay: 0ms; }
.guess-row .tile:nth-child(2) { animation-delay: 80ms; }
.guess-row .tile:nth-child(3) { animation-delay: 160ms; }
.guess-row .tile:nth-child(4) { animation-delay: 240ms; }
.guess-row .tile:nth-child(5) { animation-delay: 320ms; }
.guess-row .tile:nth-child(6) { animation-delay: 400ms; }
.guess-row .tile:nth-child(7) { animation-delay: 480ms; }
.guess-row .tile:nth-child(8) { animation-delay: 560ms; }
.guess-row .tile:nth-child(9) { animation-delay: 640ms; }
.guess-row .tile:nth-child(10) { animation-delay: 720ms; }

/* ══════════════════════════════════════
   RESULT / GAME OVER SCREEN
══════════════════════════════════════ */
#result-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: radial-gradient(ellipse 80% 50% at 50% 0%, rgba(78,42,132,0.08) 0%, transparent 70%),
              var(--bg);
}
.result-content {
  max-width: 480px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}
.result-emoji {
  font-size: 4rem;
  animation: float 3s ease-in-out infinite;
}
.result-title { font-size: 2rem; font-weight: 800; text-align: center; }
.result-sub { color: var(--text-2); text-align: center; font-size: 0.95rem; }

/* Professor reveal card */
.result-professor-card {
  width: 100%;
  background: var(--card-bg);
  border: 2px solid var(--correct);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  backdrop-filter: blur(12px);
  box-shadow: 0 0 24px var(--correct-glow);
}
.rpc-name {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 0.25rem;
}
.rpc-dept {
  font-size: 0.85rem;
  color: var(--purple-mid);
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.rpc-detail {
  font-size: 0.8rem;
  color: var(--text-2);
  line-height: 1.6;
}

/* Stats row */
.result-stats {
  display: flex;
  gap: 2.5rem;
}
.r-stat { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }
.r-stat-val { font-size: 2rem; font-weight: 800; color: var(--text-1); }
.r-stat-label { font-size: 0.75rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; }

/* Share grid */
.result-share-grid {
  font-family: monospace;
  font-size: 1.2rem;
  line-height: 1.6;
  text-align: center;
  user-select: all;
}

.result-actions { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }

/* ══════════════════════════════════════
   TOAST
══════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 999;
  backdrop-filter: blur(12px);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}
.toast.correct {
  background: rgba(22,163,74,0.1);
  border: 1px solid var(--correct);
  color: #15803D;
}
.toast.wrong {
  background: rgba(220,38,38,0.1);
  border: 1px solid var(--wrong);
  color: #B91C1C;
}
.toast.info {
  background: rgba(78,42,132,0.1);
  border: 1px solid var(--purple-light);
  color: var(--text-1);
}

/* ══════════════════════════════════════
   SHAKE ANIMATION
══════════════════════════════════════ */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-6px); }
  30% { transform: translateX(6px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}
.shake { animation: shake 0.4s ease; }

/* ══════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════ */
@media (max-width: 900px) {
  :root { --tile-size: 95px; }
}

@media (max-width: 700px) {
  :root { --tile-size: 85px; }
  .game-header { padding: 0.6rem 1rem; gap: 0.5rem; }
  .brand-name { display: none; }
  .results-header .attr-label { font-size: 0.6rem; }
}

@media (max-width: 480px) {
  :root { --tile-size: 75px; }
  .results-header { grid-template-columns: 50px 110px repeat(8, var(--tile-size)); }
  .guess-row { grid-template-columns: 50px 110px repeat(8, var(--tile-size)); }
  .search-wrap { padding: 0.4rem 0.4rem 0.4rem 0.8rem; }
  .professor-input { font-size: 0.85rem; }
}
