/* live.css — the public /live/ page.
 *
 * Everything here is built on the --ot-* tokens from clean.css, so dark mode
 * comes for free: clean.css redefines the tokens under [data-theme="dark"] and
 * this file never hardcodes a surface or a text colour. The two exceptions are
 * the correct/incorrect greens and reds, which are semantic rather than
 * thematic and are pulled from --ot-success / --ot-danger.
 */

.live-page {
  padding: 1.5rem 0 3rem;
  background: var(--ot-bg-page);
  min-height: 70vh;
}

/* ---- header ---------------------------------------------------------- */

.live-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.live-head__title h1 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--ot-text);
  margin: .35rem 0 .2rem;
}

.live-head__title p {
  margin: 0;
  color: var(--ot-text-secondary);
  font-size: .9rem;
  max-width: 52ch;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: rgba(220, 38, 38, .1);
  color: var(--ot-danger);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
  padding: .25rem .6rem;
  border-radius: 999px;
}

.live-badge__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ot-danger);
  animation: live-pulse 1.6s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .35; transform: scale(.8); }
}

.live-head__stats {
  display: flex;
  gap: .6rem;
}

.live-stat {
  background: var(--ot-bg);
  border: 1px solid var(--ot-border);
  border-radius: var(--ot-radius);
  padding: .55rem .9rem;
  text-align: center;
  min-width: 92px;
  box-shadow: var(--ot-shadow-sm);
}

.live-stat__value {
  display: block;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--ot-primary);
  line-height: 1.1;
}

.live-stat__label {
  display: block;
  font-size: .68rem;
  color: var(--ot-text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ---- layout ---------------------------------------------------------- */

.live-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 991.98px) {
  .live-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---- question card --------------------------------------------------- */

.live-card {
  background: var(--ot-bg);
  border: 1px solid var(--ot-border);
  border-radius: var(--ot-radius-lg);
  box-shadow: var(--ot-shadow);
  padding: 1.1rem 1.15rem 1rem;
}

.live-card__top {
  display: flex;
  align-items: center;
  gap: .85rem;
  margin-bottom: .9rem;
}

.live-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.live-chip {
  font-size: .72rem;
  font-weight: 700;
  color: var(--ot-primary);
  background: var(--ot-primary-light);
  border-radius: 999px;
  padding: .22rem .65rem;
}

.live-chip--muted {
  color: var(--ot-text-secondary);
  background: var(--ot-bg-muted);
}

/* countdown ring */
.live-timer {
  position: relative;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
}

.live-timer svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.live-timer circle {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
}

.live-timer__track { stroke: var(--ot-border); }

.live-timer__bar {
  stroke: var(--ot-primary);
  stroke-dasharray: 119.38;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset .25s linear, stroke .3s ease;
}

.live-timer.is-urgent .live-timer__bar { stroke: var(--ot-danger); }
.live-timer.is-reveal .live-timer__bar { stroke: var(--ot-success); }

.live-timer__num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .95rem;
  font-weight: 800;
  color: var(--ot-text);
}

.live-timer.is-urgent .live-timer__num {
  color: var(--ot-danger);
  animation: live-tick .5s ease-in-out infinite;
}

@keyframes live-tick {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.12); }
}

.live-question {
  font-size: 1.12rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--ot-text);
  margin: 0 0 1rem;
  min-height: 3.2em;
}

/* ---- options --------------------------------------------------------- */

.live-options {
  display: grid;
  gap: .5rem;
}

.live-option {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: .7rem;
  width: 100%;
  text-align: start;
  padding: .7rem .85rem;
  border: 1.5px solid var(--ot-border);
  border-radius: var(--ot-radius);
  background: var(--ot-bg);
  color: var(--ot-text);
  font-size: .95rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
}

.live-option:hover:not(:disabled) {
  border-color: var(--ot-primary);
  background: var(--ot-primary-light);
}

.live-option:active:not(:disabled) { transform: scale(.995); }
.live-option:disabled { cursor: default; }

.live-option__letter {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--ot-bg-muted);
  color: var(--ot-text-secondary);
  font-size: .78rem;
  font-weight: 800;
}

.live-option__text { flex: 1 1 auto; position: relative; z-index: 1; }

.live-option__pct {
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
  font-size: .78rem;
  font-weight: 800;
  color: var(--ot-text-secondary);
  opacity: 0;
  transition: opacity .2s ease;
}

/* the share-of-votes bar, painted behind the label at reveal */
.live-option__bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--ot-bg-muted);
  transition: width .5s cubic-bezier(.22, .61, .36, 1);
  z-index: 0;
}

.live-option.is-revealed .live-option__pct { opacity: 1; }

.live-option.is-picked {
  border-color: var(--ot-primary);
  background: var(--ot-primary-light);
}

.live-option.is-correct {
  border-color: var(--ot-success);
  color: var(--ot-success);
}

.live-option.is-correct .live-option__bar { background: rgba(22, 163, 74, .14); }
.live-option.is-correct .live-option__letter { background: var(--ot-success); color: #fff; }

.live-option.is-wrong {
  border-color: var(--ot-danger);
  color: var(--ot-danger);
}

.live-option.is-wrong .live-option__bar { background: rgba(220, 38, 38, .12); }
.live-option.is-wrong .live-option__letter { background: var(--ot-danger); color: #fff; }

/* ---- feedback -------------------------------------------------------- */

.live-feedback {
  margin-top: .85rem;
  padding: .6rem .8rem;
  border-radius: var(--ot-radius);
  font-size: .88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.live-feedback--ok {
  background: rgba(22, 163, 74, .12);
  color: var(--ot-success);
}

.live-feedback--bad {
  background: rgba(220, 38, 38, .1);
  color: var(--ot-danger);
}

.live-feedback--info {
  background: var(--ot-bg-muted);
  color: var(--ot-text-secondary);
}

.live-feedback__extra {
  margin-inline-start: auto;
  font-weight: 500;
  font-size: .8rem;
  opacity: .85;
}

.live-card__foot { margin-top: .9rem; }

.live-source {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .82rem;
  color: var(--ot-text-secondary);
  text-decoration: none;
  padding-top: .7rem;
  border-top: 1px dashed var(--ot-border);
}

.live-source:hover { color: var(--ot-primary); }

.live-source__cta {
  margin-inline-start: auto;
  font-weight: 700;
  color: var(--ot-primary);
  white-space: nowrap;
}

/* ---- leaderboard ----------------------------------------------------- */

.live-board {
  margin-top: 1rem;
  background: var(--ot-bg);
  border: 1px solid var(--ot-border);
  border-radius: var(--ot-radius-lg);
  box-shadow: var(--ot-shadow-sm);
  padding: .9rem 1rem 1rem;
}

.live-board__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: .6rem;
}

.live-board__head h2 {
  font-size: .95rem;
  font-weight: 800;
  margin: 0;
  color: var(--ot-text);
}

.live-board__head span {
  font-size: .72rem;
  color: var(--ot-text-secondary);
}

.live-board__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: .3rem;
}

.live-board__list li {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-size: .86rem;
  color: var(--ot-text);
  padding: .3rem .45rem;
  border-radius: 8px;
}

.live-board__list li.is-me {
  background: var(--ot-primary-light);
  font-weight: 700;
}

.live-board__rank {
  width: 20px;
  font-weight: 800;
  color: var(--ot-text-secondary);
  font-size: .78rem;
}

.live-board__name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-board__score {
  font-weight: 800;
  color: var(--ot-primary);
}

.live-board__me {
  margin: .6rem 0 0;
  font-size: .8rem;
  color: var(--ot-text-secondary);
}

/* ---- chat ------------------------------------------------------------ */

.live-chat {
  background: var(--ot-bg);
  border: 1px solid var(--ot-border);
  border-radius: var(--ot-radius-lg);
  box-shadow: var(--ot-shadow-sm);
  display: flex;
  flex-direction: column;
  max-height: 70vh;
  position: sticky;
  top: 90px;
}

@media (max-width: 991.98px) {
  .live-chat { position: static; max-height: 60vh; }
}

.live-chat__head {
  padding: .8rem 1rem .55rem;
  border-bottom: 1px solid var(--ot-border);
}

.live-chat__head h2 {
  font-size: .95rem;
  font-weight: 800;
  margin: 0;
  color: var(--ot-text);
}

.live-chat__note {
  font-size: .72rem;
  color: var(--ot-text-secondary);
}

.live-chat__list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: .7rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .55rem;
  scrollbar-width: thin;
}

.live-chat__empty {
  margin: auto;
  font-size: .82rem;
  color: var(--ot-text-secondary);
}

.live-msg { font-size: .86rem; line-height: 1.45; }

.live-msg__head {
  display: flex;
  align-items: baseline;
  gap: .4rem;
  margin-bottom: .1rem;
}

.live-msg__name {
  font-weight: 700;
  color: var(--ot-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-msg.is-mine .live-msg__name { color: var(--ot-success); }

.live-msg__time {
  flex: 0 0 auto;
  font-size: .7rem;
  color: var(--ot-text-secondary);
  font-variant-numeric: tabular-nums;
}

.live-msg__text {
  color: var(--ot-text);
  word-break: break-word;
}

.live-msg.is-pending { opacity: .6; }

.live-msg__pending {
  flex: 0 0 auto;
  font-size: .7rem;
  color: var(--ot-text-secondary);
}

.live-chat__more {
  align-self: center;
  margin-bottom: .4rem;
  border: 1px solid var(--ot-border);
  border-radius: 999px;
  background: var(--ot-bg-muted);
  color: var(--ot-text-secondary);
  font-size: .76rem;
  font-weight: 600;
  padding: .25rem .7rem;
  cursor: pointer;
}

.live-chat__more:hover:not(:disabled) {
  color: var(--ot-primary);
  border-color: var(--ot-primary);
}

.live-chat__more:disabled { opacity: .5; cursor: default; }

#liveChatItems {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}

.live-chat__form {
  display: flex;
  gap: .4rem;
  padding: .7rem;
  border-top: 1px solid var(--ot-border);
}

.live-chat__form input {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid var(--ot-border);
  border-radius: var(--ot-radius);
  background: var(--ot-bg-muted);
  color: var(--ot-text);
  padding: .5rem .7rem;
  font-size: .88rem;
}

.live-chat__form input:focus {
  outline: none;
  border-color: var(--ot-primary);
  background: var(--ot-bg);
}

.live-chat__form button {
  flex: 0 0 auto;
  width: 38px;
  border: none;
  border-radius: var(--ot-radius);
  background: var(--ot-primary);
  color: #fff;
  cursor: pointer;
  transition: background .15s ease;
}

.live-chat__form button:hover:not(:disabled) { background: var(--ot-primary-hover); }
.live-chat__form button:disabled { opacity: .5; cursor: default; }

.live-chat__hint {
  margin: 0;
  padding: 0 .8rem .6rem;
  font-size: .74rem;
  color: var(--ot-danger);
  min-height: 1em;
}

.live-chat__locked {
  padding: .85rem 1rem 1rem;
  border-top: 1px solid var(--ot-border);
}

.live-chat__locked p {
  margin: 0 0 .6rem;
  font-size: .82rem;
  color: var(--ot-text-secondary);
}

.live-chat__locked-actions {
  display: flex;
  gap: .5rem;
  margin-bottom: .6rem;
}

.live-btn {
  flex: 1 1 auto;
  text-align: center;
  padding: .45rem .7rem;
  border-radius: var(--ot-radius);
  border: 1px solid var(--ot-border);
  background: var(--ot-bg);
  color: var(--ot-text);
  font-size: .84rem;
  font-weight: 600;
  text-decoration: none;
}

.live-btn--primary {
  background: var(--ot-primary);
  border-color: var(--ot-primary);
  color: #fff;
}

.live-chat__rename {
  display: flex;
  align-items: center;
  gap: .35rem;
  width: 100%;
  border: none;
  background: none;
  padding: 0;
  font-size: .78rem;
  color: var(--ot-text-secondary);
  cursor: pointer;
}

.live-chat__rename:hover { color: var(--ot-primary); }

.live-chat__rename-input {
  width: 100%;
  border: 1px solid var(--ot-primary);
  border-radius: 8px;
  background: var(--ot-bg);
  color: var(--ot-text);
  padding: .3rem .5rem;
  font-size: .8rem;
}

.live-chat__rename-input:focus { outline: none; }
