/* Live Q&A. Palette: #f50537, #000, #fff and --grisobscuro (#1a1a1a). Hierarchy comes from size, weight, width and fill. */

@font-face {
  font-family: "Audi Type";
  src: url("../fonts/AudiTypeVF_Lat.woff2") format("woff2");
  font-weight: 400 700;
  font-stretch: 100% 130%;
  font-style: normal;
  font-display: swap;
}

:root {
  --red: #f50537;
  --black: #000;
  --white: #fff;
  --grisobscuro: #1a1a1a;
  --font: "Audi Type", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --pad: clamp(1.25rem, 4vw, 3rem);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.45;
  background: var(--white);
  color: var(--black);
}
h1, h2, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }
.page-join :focus-visible, .page-login :focus-visible, .page-display :focus-visible,
.topbar :focus-visible, .admin-bar :focus-visible, .current :focus-visible { outline-color: var(--white); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 3.25rem; padding: 0 1.5rem;
  font-weight: 700; font-size: 1.2rem; line-height: 1.1;
  border: 2px solid var(--black); border-radius: 0;
  background: var(--white); color: var(--black);
  text-decoration: none; cursor: pointer;
}
.btn-block { width: 100%; }
.btn-sm { min-height: 2.75rem; padding: 0 1rem; font-size: 1.05rem; }
.btn-primary { background: var(--red); border-color: var(--red); color: var(--white); }
.btn-primary:hover { background: var(--black); border-color: var(--black); }
.btn-outline { background: transparent; }
.btn-outline:hover { background: var(--black); color: var(--white); }
.btn[disabled] { border-style: dashed; background: transparent; color: inherit; cursor: not-allowed; }
.page-join .btn-primary:hover, .page-login .btn-primary:hover { background: var(--white); border-color: var(--white); color: var(--black); }
.admin-bar .btn-outline { border-color: var(--white); color: var(--white); }
.admin-bar .btn-outline:hover { background: var(--white); color: var(--black); }
.admin-bar .btn-primary:hover { background: var(--white); border-color: var(--white); color: var(--black); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 1.25rem; }
.field { display: grid; gap: .4rem; }
.field label { font-weight: 700; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 3.25rem; padding: .75rem 1rem;
  border: 2px solid var(--black); border-radius: 0;
  background: var(--white); color: var(--black);
}
.field textarea { resize: vertical; min-height: 7rem; line-height: 1.4; }
.field select {
  appearance: none; padding-right: 3rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23000' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 1rem center; background-size: .8rem;
}
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { outline: 3px solid var(--red); outline-offset: 0; }
.page-join .field input, .page-join .field select, .page-login .field input { border-color: var(--white); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-error { padding: .75rem 1rem; border: 3px solid var(--red); font-weight: 700; }
.page-join .form-error, .page-login .form-error { background: var(--white); color: var(--black); }
.fine { font-size: .95rem; }
.counter { text-align: right; font-size: .95rem; }

.check { display: flex; gap: .75rem; align-items: flex-start; }
.check input { flex: none; width: 1.75rem; height: 1.75rem; margin: .1rem 0 0; accent-color: var(--red); }
.check label { font-weight: 700; display: grid; gap: .15rem; }
.check-hint { font-weight: 400; font-size: .95rem; }

.notice { border: 3px solid var(--red); padding: 1rem; display: grid; gap: .9rem; }
.row { display: flex; flex-wrap: wrap; gap: .6rem; }
.feedback { min-height: 1.5rem; font-weight: 700; }
.feedback.is-error { text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 3px; text-underline-offset: 4px; }

.section-title { font-size: 1.35rem; font-weight: 700; font-stretch: 115%; line-height: 1.15; }
.empty { padding: 1rem 0; }

/* ---------- Join ---------- */
.page-join, .page-login { background: var(--black); color: var(--white); }
.join-layout { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
.join-hero {
  background: var(--grisobscuro); color: var(--white); padding: var(--pad);
  display: grid; align-content: center; gap: 1rem; min-height: 46dvh;
}
.join-event { font-size: 1.2rem; font-weight: 700; }
.join-title {
  font-size: clamp(3rem, 14vw, 9rem); line-height: .95; font-weight: 700; font-stretch: 130%;
  letter-spacing: -.015em; overflow-wrap: anywhere;
}
.join-lead { font-size: 1.3rem; font-weight: 700; max-width: 30ch; line-height: 1.3; }
.join-panel { padding: var(--pad); display: grid; align-content: start; max-width: 36rem; width: 100%; }

@media (min-width: 56rem) {
  .join-layout { grid-template-rows: none; grid-template-columns: 1.2fr 1fr; }
  .join-hero { min-height: 100dvh; }
  .join-panel { align-content: center; max-width: none; }
  .join-panel .form { max-width: 28rem; }
}

/* ---------- Participant: ask ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .9rem var(--pad); background: var(--black); color: var(--white);
}
.who { display: flex; flex-wrap: wrap; gap: .1rem .75rem; }
.who span { font-weight: 400; }
.topbar-link { color: var(--white); font-weight: 700; padding: .5rem 0; }
.ask { max-width: 40rem; margin: 0 auto; padding: var(--pad); display: grid; gap: 2rem; }
.ask-title { font-size: clamp(2rem, 8vw, 3rem); font-weight: 700; font-stretch: 125%; line-height: 1; }
.mine-section { display: grid; gap: .75rem; }
.mine { display: grid; gap: .75rem; }
.mine-to { font-weight: 700; }
.mine-item { border: 2px solid var(--black); padding: 1rem; display: grid; gap: .6rem; justify-items: start; }
.chip {
  display: inline-block; padding: .1rem .7rem; font-size: 1rem; font-weight: 700; line-height: 1.5;
  border: 2px solid var(--black); background: var(--white); color: var(--black);
}
.chip-on_screen, .chip-approved { background: var(--red); border-color: var(--red); color: var(--black); }
.chip-answered { background: var(--black); color: var(--white); }
.chip-not_shown, .chip-rejected, .chip-duplicate { border-style: dashed; }
.chip-featured { background: var(--black); border-color: var(--black); color: var(--white); }

/* ---------- Public screen ---------- */
.page-display { background: var(--black); color: var(--white); overflow-x: hidden; }
.stage {
  min-height: 100dvh; height: 100dvh; display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(15rem, 24vw, 26rem);
  grid-template-rows: minmax(0, 5fr) minmax(0, 4fr);
}
.current {
  grid-column: 1; grid-row: 1; background: var(--grisobscuro); color: #0da20d;
  padding: var(--pad); display: flex; flex-direction: column; justify-content: flex-end; gap: 1rem; overflow: hidden;
  position: relative;
}
.current-label { font-size: clamp(1.25rem, 2vw, 2rem); font-weight: 700; }
.current-q {
  font-size: clamp(2.4rem, 5vw, 6.5rem); line-height: 1.02; font-weight: 700; font-stretch: 130%;
  letter-spacing: -.012em; overflow-wrap: anywhere;
}
.current-q.is-long { font-size: clamp(1.8rem, 3.4vw, 4.4rem); }
.current-q.is-xlong { font-size: clamp(1.45rem, 2.6vw, 3.4rem); font-stretch: 110%; }
.current-q.is-xxlong { font-size: clamp(1.25rem, 2.1vw, 2.7rem); font-stretch: 105%; }
.current-to { font-size: clamp(1.6rem, 3.2vw, 3.6rem); font-weight: 700; font-stretch: 115%; line-height: 1.05; }
.current-by { font-size: clamp(1.25rem, 2vw, 2.1rem); font-weight: 700; min-height: 1.2em; }

.queue { grid-column: 1; grid-row: 2; padding: var(--pad); padding-bottom: calc(var(--pad) / 2); min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: .5rem; }
.queue-title { font-size: clamp(1.2rem, 1.8vw, 1.8rem); font-weight: 700; font-stretch: 115%; }
/* The list scrolls, so the queue can hold many questions (the server sends up to 30). */
.queue-list {
  flex: 1 1 auto; min-height: 0; display: grid; align-content: start; gap: 0 2rem;
  overflow-y: auto; overscroll-behavior: contain; padding-right: .75rem;
  scrollbar-width: thin; scrollbar-color: var(--red) var(--black);
}
.queue-list::-webkit-scrollbar { width: .6rem; }
.queue-list::-webkit-scrollbar-track { background: var(--black); }
.queue-list::-webkit-scrollbar-thumb { background: var(--red); }
.queue-list li { border-top: 2px solid var(--white); padding: .55rem 0; display: grid; gap: .1rem; }
.queue-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .75rem; }
.queue-q {
  font-size: clamp(1rem, 1.5vw, 1.8rem); font-weight: 700; line-height: 1.15;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.queue-to { font-size: clamp(.9rem, 1.2vw, 1.3rem); font-weight: 700; }
.queue-by { font-size: clamp(.9rem, 1.1vw, 1.2rem); }
.queue-more { font-weight: 700; font-size: clamp(1rem, 1.3vw, 1.4rem); }
@media (min-width: 70rem) and (orientation: landscape) {
  .queue-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.join-tile {
  grid-column: 2; grid-row: 1 / span 2; background: var(--white); color: var(--black);
  padding: var(--pad); display: flex; flex-direction: column; justify-content: center; gap: 1rem;
}
.qr img { display: block; width: 100%; height: auto; }
.join-cta { font-size: clamp(1.25rem, 1.8vw, 2rem); font-weight: 700; font-stretch: 115%; line-height: 1.1; }
.join-url { font-size: clamp(1rem, 1.5vw, 1.6rem); font-weight: 700; overflow-wrap: anywhere; }
.conn { position: fixed; left: 1rem; bottom: 1rem; padding: .35rem .8rem; font-weight: 700; background: var(--white); color: var(--black); border: 2px solid var(--black); }

@media (max-width: 52rem), (orientation: portrait) {
  .stage { height: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; }
  .current { grid-column: 1; grid-row: 1; min-height: 52dvh; }
  .queue { grid-column: 1; grid-row: 2; }
  .queue-list { overflow: visible; max-height: none; }
  .join-tile { grid-column: 1; grid-row: 3; flex-direction: row; align-items: flex-end; flex-wrap: wrap; }
  .qr { width: min(12rem, 40vw); }
  .current-q { font-size: clamp(2rem, 9vw, 4rem); }
  .current-q.is-long { font-size: clamp(1.6rem, 6.5vw, 3rem); }
  .current-q.is-xlong, .current-q.is-xxlong { font-size: clamp(1.35rem, 5.2vw, 2.4rem); }
}

/* Entrance of the featured question: a red bar sweeps the panel, then the texts rise in order. */
.current > * { position: relative; }

@media (prefers-reduced-motion: no-preference) {
  .current.enter::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--red);
    pointer-events: none;
    animation: sweep .8s cubic-bezier(.65, 0, .35, 1) both;
  }
  .current.enter .current-label { animation: rise .6s .45s cubic-bezier(.2, .7, .2, 1) both; }
  .current.enter .current-to    { animation: rise .6s .55s cubic-bezier(.2, .7, .2, 1) both; }
  .current.enter .current-q     { animation: rise .7s .65s cubic-bezier(.2, .7, .2, 1) both; }
  .current.enter .current-by    { animation: rise .6s .8s  cubic-bezier(.2, .7, .2, 1) both; }
}

@keyframes sweep {
  0%   { transform: scaleX(0); transform-origin: left; }
  45%  { transform: scaleX(1); transform-origin: left; }
  55%  { transform: scaleX(1); transform-origin: right; }
  100% { transform: scaleX(0); transform-origin: right; }
}
@keyframes rise { from { transform: translateY(1.5rem); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Login ---------- */
.login { max-width: 28rem; margin: 0 auto; min-height: 100dvh; padding: var(--pad); display: grid; align-content: center; gap: 1.5rem; }
.login-title { font-size: clamp(2.5rem, 10vw, 4rem); font-weight: 700; font-stretch: 130%; line-height: 1; }

/* ---------- Moderator ---------- */
.admin-bar {
  background: var(--black); color: var(--white); padding: 1rem var(--pad);
  display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: center;
}
.admin-title { font-size: 2rem; font-weight: 700; font-stretch: 130%; line-height: 1; }
.admin-stats { margin-top: .35rem; }
.admin-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.admin { padding: var(--pad); display: grid; gap: 1.5rem; max-width: 80rem; margin: 0 auto; }
.toast { padding: .75rem 1rem; background: var(--black); color: var(--white); font-weight: 700; border: 3px solid var(--red); }

.tabs { display: flex; flex-wrap: wrap; border-bottom: 3px solid var(--black); }
.tab {
  min-height: 3rem; padding: 0 1.25rem; font-weight: 700; font-size: 1.05rem; cursor: pointer;
  border: 2px solid var(--black); border-bottom: 0; background: var(--white); color: var(--black);
}
.tab + .tab { border-left: 0; }
.tab[aria-pressed="true"] { background: var(--black); color: var(--white); }
.tab .count { display: inline-block; min-width: 1.6rem; margin-left: .4rem; padding: 0 .4rem; text-align: center; border: 2px solid currentColor; }
.tab.has-items .count { background: var(--red); border-color: var(--red); color: var(--black); }

.qlist { display: grid; gap: 1rem; }
.q { border: 2px solid var(--black); padding: 1.1rem; display: grid; gap: .8rem; }
.q.is-featured { background: var(--red); }
.q-body { font-size: 1.3rem; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.q-meta { display: flex; flex-wrap: wrap; gap: .4rem .6rem; align-items: center; font-size: .98rem; }
.q-note { padding: .6rem .8rem; border: 2px solid var(--black); white-space: pre-wrap; overflow-wrap: anywhere; background: var(--white); }
.q-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.q.is-featured .btn-outline { background: var(--white); }
.q.is-featured .btn-outline:hover { background: var(--black); }

.ai-panel { border: 3px solid var(--black); padding: 1.1rem; display: grid; gap: 1rem; }
.ai-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; }
.ai-status { font-weight: 700; }
.ai-group { border-top: 2px solid var(--black); padding-top: 1rem; display: grid; gap: .75rem; }
.ai-reason { font-weight: 700; }
.ai-options { border: 0; margin: 0; padding: 0; display: grid; gap: .5rem; }
.ai-options legend { padding: 0; margin-bottom: .4rem; }
.ai-option { display: flex; gap: .75rem; align-items: flex-start; padding: .6rem .75rem; border: 2px solid var(--black); cursor: pointer; }
.ai-option input { flex: none; width: 1.4rem; height: 1.4rem; margin-top: .15rem; accent-color: var(--red); }
.ai-option-text { display: grid; gap: .3rem; justify-items: start; overflow-wrap: anywhere; }

.dialog { border: 3px solid var(--black); padding: 1.5rem; width: calc(100% - 2rem); max-width: 34rem; background: var(--white); color: var(--black); }
.dialog::backdrop { background: var(--black); }
.dialog .field { margin: 1rem 0; }
