/* ═══════════════════════════════════════════════════════════════════════════
   Artle Australia — style.css
   ═══════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ochre:       #C8651A;
  --ochre-light: #F2DCC0;
  --ochre-dark:  #8A4210;
  --earth:       #2C1A0E;
  --cream:       #FAF5EE;
  --text:        #1A1109;
  --muted:       #7A6B5A;
  --border:      #DDD0BC;
  --correct:     #4A7A3A;
  --wrong:       #A33030;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
header {
  width: 100%;
  background: var(--earth);
  padding: 1rem 2rem;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  justify-content: center;
}
header h1 {
  font-family: 'Playfair Display', serif;
  color: var(--ochre-light);
  font-size: 2rem;
  letter-spacing: 0.04em;
}
header span {
  color: #8A7060;
  font-size: 0.85rem;
  font-weight: 300;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 740px;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Loading overlay ────────────────────────────────────────────────────── */
/* Shown while Wikimedia API resolves image URLs */
.img-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1009;
  border-radius: 2px;
  pointer-events: none;
  transition: opacity 0.3s;
}
.img-loading.hidden { opacity: 0; pointer-events: none; }
.img-loading-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ochre-light); opacity: 0.4;
  animation: pulse 1.2s ease-in-out infinite;
  margin: 0 3px;
}
.img-loading-dot:nth-child(2) { animation-delay: 0.2s; }
.img-loading-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 0.9; } }

/* ── Artwork frame ──────────────────────────────────────────────────────── */
/* Fixed height prevents layout shift when images load */
.artwork-frame {
  position: relative;
  background: var(--earth);
  border-radius: 4px;
  padding: 12px;
  box-shadow: 0 8px 32px rgba(44,26,14,0.18);
  height: 460px;
}
.artwork-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 2px;
  background: #1a1009;
  transition: opacity 0.3s;
}

/* ── Thumbnail strip ────────────────────────────────────────────────────── */
.thumb-strip {
  display: none;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.thumb-strip.visible { display: flex; }
.thumb {
  width: 80px; height: 60px;
  object-fit: cover;
  border-radius: 3px;
  cursor: pointer;
  opacity: 0.55;
  border: 2px solid transparent;
  transition: opacity 0.2s, border-color 0.2s, transform 0.15s;
  background: var(--earth);
}
.thumb:hover { opacity: 0.85; transform: translateY(-2px); }
.thumb.active { opacity: 1; border-color: var(--ochre); }
.thumb.locked {
  cursor: default;
  opacity: 0.18;
  filter: blur(3px);
  pointer-events: none;
}

/* ── Caption ────────────────────────────────────────────────────────────── */
/* Fixed min-height so layout doesn't jump when venue line appears */
.thumb-caption {
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
  min-height: 2.8em;
  line-height: 1.5;
}
.caption-venue {
  display: block;
  font-style: normal;
  font-size: 0.74rem;
  color: #9A8A7A;
  margin-top: 2px;
}

/* ── Attempt dots ───────────────────────────────────────────────────────── */
/* Count is set dynamically to match number of artworks (2–4) */
.attempts-row { display: flex; gap: 8px; justify-content: center; }
.dot {
  width: 36px; height: 8px;
  border-radius: 4px;
  background: var(--border);
  transition: background 0.3s;
}
.dot.wrong   { background: var(--wrong); }
.dot.correct { background: var(--correct); }
.dot.current { background: var(--ochre); }
.dot.skipped { background: #BBA88A; }

/* ── Guess input ────────────────────────────────────────────────────────── */
.guess-section { display: flex; flex-direction: column; gap: 0.75rem; }
.guess-label {
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.input-row { display: flex; gap: 8px; position: relative; }
#guess-input {
  flex: 1;
  padding: 0.75rem 1rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}
#guess-input:focus { border-color: var(--ochre); }
#guess-input:disabled { background: #f5f0ea; color: var(--muted); }

/* ── Autocomplete ───────────────────────────────────────────────────────── */
.ac-list {
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: #fff;
  border: 1.5px solid var(--border);
  border-top: none;
  border-radius: 0 0 4px 4px;
  z-index: 10;
  max-height: 220px;
  overflow-y: auto;
  display: none;
}
.ac-list.open { display: block; }
.ac-item {
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-size: 0.95rem;
  border-bottom: 0.5px solid var(--border);
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.hi { background: var(--ochre-light); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn-guess {
  padding: 0.75rem 1.5rem;
  background: var(--ochre); color: #fff;
  border: none; border-radius: 4px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem; font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}
.btn-guess:hover { background: var(--ochre-dark); }
.btn-guess:active { transform: scale(0.97); }
.btn-guess:disabled { background: var(--border); color: var(--muted); cursor: default; transform: none; }

.footer-row { display: flex; justify-content: space-between; align-items: center; }
.btn-skip {
  background: none;
  border: 1.5px solid var(--border); border-radius: 4px;
  padding: 0.55rem 1rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem; color: var(--muted);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.btn-skip:hover { border-color: var(--muted); color: var(--text); }
.btn-skip:disabled { opacity: 0.4; cursor: default; }
.progress-hint { font-size: 0.82rem; color: var(--muted); }

/* ── Guess history ──────────────────────────────────────────────────────── */
.guesses-history { display: flex; flex-direction: column; gap: 6px; }
.g-result {
  display: flex; align-items: center; gap: 10px;
  padding: 0.65rem 1rem;
  border-radius: 4px;
  font-size: 0.95rem; font-weight: 500;
  animation: slideIn 0.25s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}
.g-result.wrong   { background: #FDF0F0; border: 1px solid #F5C5C5; color: var(--wrong); }
.g-result.right   { background: #F0FAF0; border: 1px solid #B5D5B5; color: var(--correct); }
.g-result.skipped { background: #F5F2EE; border: 1px solid var(--border); color: var(--muted); }

/* ── Hint ───────────────────────────────────────────────────────────────── */
/* Appears after first guess/skip as a button; click reveals static text */
.hint-area { display: none; }
.hint-area.visible { display: block; }
.btn-reveal-hint {
  background: none;
  border: 1.5px solid var(--ochre-light); border-radius: 4px;
  padding: 0.5rem 1rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem; color: var(--ochre);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.btn-reveal-hint:hover { background: var(--ochre-light); border-color: var(--ochre); }
.hint-text {
  font-size: 0.85rem; color: var(--muted); font-style: italic;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--ochre-light);
  background: rgba(200,101,26,0.05);
  border-radius: 0 4px 4px 0;
  display: none;
}
.hint-text.revealed { display: block; }

/* ── Reveal panel ───────────────────────────────────────────────────────── */
.reveal-panel {
  background: var(--earth); color: var(--cream);
  border-radius: 6px;
  padding: 1.75rem;
  display: none; flex-direction: column; gap: 1.25rem;
  animation: fadeIn 0.4s ease;
}
.reveal-panel.show { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.reveal-outcome { font-size: 0.8rem; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 500; }
.reveal-outcome.won  { color: #7EC87E; }
.reveal-outcome.lost { color: #E07070; }
.reveal-artist {
  font-family: 'Playfair Display', serif;
  font-size: 1.8rem; color: var(--ochre-light); line-height: 1.2;
}
.reveal-meta { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.meta-item { display: flex; flex-direction: column; gap: 2px; }
.meta-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: #8A7A6A; }
.meta-value { font-size: 0.9rem; color: var(--ochre-light); font-weight: 500; }
.reveal-bio {
  font-size: 0.9rem; line-height: 1.75; color: #D4C4B0;
  border-top: 1px solid rgba(255,255,255,0.1); padding-top: 1rem;
}
.reveal-bio p + p { margin-top: 0.75em; }
.reveal-link a { color: #BBA88A; font-size: 0.85rem; }
.reveal-link a:hover { color: var(--ochre-light); }
.share-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.share-text { font-family: monospace; font-size: 0.85rem; color: #BBA88A; }
.btn-copy {
  padding: 0.4rem 0.9rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15); border-radius: 4px;
  color: var(--cream); font-size: 0.8rem;
  cursor: pointer; transition: background 0.2s;
}
.btn-copy:hover { background: rgba(255,255,255,0.15); }
.btn-next {
  align-self: flex-start;
  padding: 0.7rem 1.5rem;
  background: var(--ochre); color: #fff;
  border: none; border-radius: 4px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem; font-weight: 500;
  cursor: pointer; transition: background 0.2s;
}
.btn-next:hover { background: var(--ochre-dark); }

/* ── Artist list modal ──────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(44,26,14,0.6);
  z-index: 100;
  display: none; align-items: flex-end; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--cream);
  border-radius: 10px 10px 0 0;
  width: 100%; max-width: 740px; max-height: 80vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-header {
  background: var(--earth);
  padding: 1rem 1.5rem;
  display: flex; justify-content: space-between; align-items: center;
  flex-shrink: 0;
}
.modal-header h2 {
  font-family: 'Playfair Display', serif;
  color: var(--ochre-light); font-size: 1.2rem;
}
.modal-close {
  background: none; border: none;
  color: var(--ochre-light); font-size: 1.4rem;
  cursor: pointer; line-height: 1; padding: 0 4px;
}
.modal-body { padding: 1.25rem 1.5rem; overflow-y: auto; }
.artist-grid { columns: 2; column-gap: 1.5rem; }
@media (min-width: 500px) { .artist-grid { columns: 3; } }
.artist-entry {
  display: block; font-size: 0.88rem; color: var(--text);
  text-decoration: none; padding: 4px 0;
  border-bottom: 0.5px solid var(--border);
  break-inside: avoid; line-height: 1.3;
}
.artist-entry:hover { color: var(--ochre); }
.artist-entry .artist-name { display: block; }
.artist-entry .artist-years {
  display: block; font-size: 0.74rem;
  color: var(--muted); font-weight: 300; margin-top: 1px;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
footer {
  padding: 1.5rem 2rem;
  text-align: center; font-size: 0.8rem; color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: auto; width: 100%;
  display: flex; flex-direction: column; gap: 0.4rem; align-items: center;
}
footer a { color: var(--muted); }
footer button {
  background: none; border: none; color: var(--muted);
  font-size: 0.8rem; cursor: pointer; text-decoration: underline;
  font-family: 'DM Sans', sans-serif;
}
footer button:hover { color: var(--ochre); }
