/* The house base (colours, font, page, masthead) comes from the jacob.gg kit, loaded first. This file adds the
   game's components, copied from Perceptle's site/css/style.css (the reference for jacob.gg games) plus Describle's own. */

/* --- cards --- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.card[aria-busy="true"] .prompt {
  opacity: 0.5;
}

.card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.eyebrow {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

#daynum {
  color: var(--accent);
}

.challenge-label {
  margin-bottom: 0.35rem;
}

.prompt {
  margin: 0;
  font-size: clamp(1.5rem, 5vw, 2rem);
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.hint {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.hint a {
  color: var(--accent);
}

/* --- form --- */

.play {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

input[type="text"],
textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  resize: vertical;
}

input[type="text"]:focus-visible,
textarea:focus-visible,
.submit:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.counter {
  align-self: flex-end;
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.counter.near {
  color: var(--bad);
}

.submit {
  padding: 0.85rem 1rem;
  font: inherit;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: filter 0.15s ease, opacity 0.15s ease;
}

.submit:hover:not(:disabled) {
  filter: brightness(1.08);
}

.submit:disabled {
  cursor: progress;
  opacity: 0.85;
}

.spinner {
  display: none;
  width: 0.95em;
  height: 0.95em;
  margin-left: 0.55em;
  vertical-align: -0.12em;
  border: 2px solid rgb(255 255 255 / 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.submit.busy .spinner {
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.fineprint {
  margin: 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.error {
  margin: 0;
  padding: 0.6rem 0.75rem;
  font-size: 0.88rem;
  color: var(--bad);
  background: color-mix(in srgb, var(--bad) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent);
  border-radius: 10px;
}

/* --- result --- */

.result {
  margin-top: 1.75rem;
  animation: rise 0.35s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .result {
    animation: none;
  }
  .spinner {
    animation-duration: 2s;
  }
}

.score {
  margin: 0.15rem 0 0;
  font-size: clamp(3.75rem, 18vw, 5.5rem);
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.score.good {
  color: var(--good);
}

.score.bad {
  color: var(--bad);
}

.answer-label {
  margin-top: 1.5rem;
}

.your-answer {
  margin: 0.4rem 0 0;
  padding: 0.75rem 1rem;
  font-size: 1.02rem;
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* --- leaderboard --- */

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.row {
  display: grid;
  grid-template-columns: 1.75rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.65rem;
  border-radius: 10px;
  border-top: 1px solid var(--border);
}

.row:first-child {
  border-top: 0;
}

.row.me {
  background: var(--accent-soft);
  border-top-color: transparent;
}

.row-rank {
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.row.me .row-rank {
  color: var(--accent);
}

.row-main {
  min-width: 0;
}

.row-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-answer {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-attempts {
  list-style: none;
  margin: 0.2rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.row-attempt {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.row-attempt-label {
  flex: none;
  font-variant-numeric: tabular-nums;
}

.row-attempt-answer {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-attempt-score {
  flex: none;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.row-score {
  font-weight: 680;
  font-variant-numeric: tabular-nums;
}

.row-gap {
  text-align: center;
  color: var(--muted);
  padding: 0.25rem 0;
  letter-spacing: 0.3em;
}

.board-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

/* --- footer --- */

.footer {
  text-align: center;
}

.footer p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

/* --- judge loading --------------------------------------------------------- */

.preparing {
  margin-top: 1.5rem;
}

.preparing-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.95rem;
  margin-bottom: 0.7rem;
}

.spinner-ring {
  width: 1rem;
  height: 1rem;
  flex: none;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.meter {
  height: 7px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.3s ease;
}

.preparing-note {
  margin: 0.6rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.board-note {
  margin: 0.9rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .spinner-ring {
    animation-duration: 2.4s;
  }
}

/* Belt-and-braces: guarantee [hidden] always wins regardless of any later
   rule's specificity tie in the cascade (observed: the native UA default for
   [hidden] can lose a same-specificity tie-break against an author class
   selector that comes later in the stylesheet). */
[hidden] {
  display: none !important;
}
/* --- attempts (3-per-day, scored as an average) --------------------------- */

.attempts-note {
  margin: 0.4rem 0 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
}

.attempts {
  margin-top: 1.5rem;
}

#daily-score-caption {
  margin-top: 0;
}

.attempt-list {
  list-style: none;
  margin: 1.3rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.attempt-row {
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.attempt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.attempt-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.attempt-score {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.05rem;
}

.attempt-score.good {
  color: var(--good);
}

.attempt-score.bad {
  color: var(--bad);
}

.attempt-answer {
  margin: 0.35rem 0 0;
  padding: 0;
  border: 0;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.attempts-done {
  margin: 1.1rem 0 0;
  padding: 0.7rem 0.9rem;
  font-size: 0.88rem;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 10px;
  text-align: center;
}

/* --- indeterminate progress (model initializing, no byte progress) ------- */

.meter-fill.indeterminate {
  width: 40% !important;
  animation: meter-sweep 1.1s ease-in-out infinite;
}

@keyframes meter-sweep {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(250%);
  }
}

/* --- archive (replay a past day) ----------------------------------------- */

.archive-note {
  margin: 0.5rem 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.archive-picker {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.archive-browse {
  background: var(--accent);
  color: var(--accent-contrast, #111);
  border: none;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.archive-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 16rem;
  overflow-y: auto;
}

.archive-list-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-align: left;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.6rem 0.8rem;
  font: inherit;
  cursor: pointer;
}

.archive-list-item:hover {
  border-color: var(--accent);
}

.archive-list-day {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
}

.archive-list-prompt {
  font-size: 0.9rem;
  color: var(--muted);
}

.archive-list-empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.archive-challenge {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.archive-boards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

@media (min-width: 640px) {
  .archive-boards {
    grid-template-columns: 1fr 1fr;
  }
}

.archive-board .rows {
  margin-top: 0.5rem;
}

.late-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.late-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  color: var(--warning, #c77b2b);
  background: color-mix(in srgb, var(--warning, #c77b2b) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--warning, #c77b2b) 40%, transparent);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
}

a { color: var(--accent); }
.out-of { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.9rem; }

.share { width: 100%; margin-top: 1.1rem; }

.row-emoji { font-size: 0.8rem; letter-spacing: 0.05em; }

.row-sub { font-size: 0.8rem; color: var(--muted); }

.footer p + p { margin-top: 0.35rem; }

.footer a { color: var(--muted); }

.archive-list-item { background: var(--surface-2); }

.chips {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.chip.done { opacity: 0.5; text-decoration: line-through; }
.chip.special { border-color: var(--accent); color: var(--accent); }

.bar-track { height: 0.8rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 99px; background: var(--accent); animation: grow 0.6s ease both; }
.bar-fill.good { background: var(--good); }
.bar-fill.ok { background: var(--ok); }
.bar-fill.bad { background: var(--bad); }

@keyframes grow { from { width: 0; } }
@media (prefers-reduced-motion: reduce) { .bar-fill { animation: none; } }

/* --- describle ---------------------------------------------------------------- */

.secret {
  display: inline-block;
  padding: 0 0.3em;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 8px;
  overflow-wrap: anywhere;
}

.pos-note { margin: 0.35rem 0 0; font-size: 0.85rem; color: var(--muted); }
.banned { margin-top: 1rem; }
.banned .chips { margin-top: 0.4rem; }
.banned-chip {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 40%, transparent);
  background: color-mix(in srgb, var(--bad) 10%, transparent);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}
.rule-note { margin: 0.6rem 0 0; font-size: 0.85rem; color: var(--muted); }

/* the description box: 16px so iOS doesn't zoom in */
textarea#text { font-size: 16px; min-height: 5.5rem; }
input#name { font-size: 16px; }
#guess { width: 100%; }
.counter { margin-top: -0.6rem; }

.link-button {
  padding: 0;
  font: inherit;
  color: var(--accent);
  background: none;
  border: 0;
  text-decoration: underline;
  cursor: pointer;
}

/* one attempt: its description and the AI's top 5 */
.attempt-list:empty { display: none; }
.attempt-verdict { font-weight: 700; font-size: 0.9rem; text-align: right; }
.attempt-head { gap: 0.6rem; }
.attempt-verdict.good { color: var(--good); }
.attempt-verdict.ok { color: var(--warn); }
.attempt-verdict.bad { color: var(--bad); }

.guess-bars {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.guess-bar {
  display: grid;
  grid-template-columns: 1.1rem minmax(5rem, 9rem) minmax(0, 1fr) 2rem;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.guess-rank { color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.guess-word { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guess-score { text-align: right; color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.guess-bar.hit .guess-word { color: var(--good); }
.guess-bar .bar-track { height: 0.6rem; }

/* results */
.squares { margin: 0.6rem 0 0; font-size: 1.4rem; letter-spacing: 0.15em; }

.reveal {
  margin-top: 1.25rem;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.reveal .label { display: block; }
.reveal .label + * { margin-top: 0.2rem; }
.reveal p { margin: 0; }
.reveal-word { font-size: 1.15rem; }
.reveal-def { margin-bottom: 0.7rem !important; color: var(--text); }
.reveal-banned { color: var(--muted); }

/* footer credits */
.credits { margin-top: 0.6rem; font-size: 0.8rem; color: var(--muted); text-align: left; }
.credits summary { cursor: pointer; text-align: center; }
.credits p { margin: 0.5rem 0 0 !important; }

@media (max-width: 420px) {
  .card { padding: 1.15rem; }
  .guess-bar { grid-template-columns: 1rem minmax(4.5rem, 7rem) minmax(0, 1fr) 1.8rem; gap: 0.4rem; }
}
.archive-browse { color: #fff; }

/* play again, and the board tabs (first goes / replays / played later) */
.again { margin-top: 1rem; display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }
.board-tabs { display: flex; gap: 0.4rem; margin: 0 0 0.6rem; }
.board-tabs:empty { display: none; }
.board-tab {
  padding: 0.3rem 0.75rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.board-tab.on { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
