/* ==========================================================================
   components.css — reusable pieces of the dossier
   ========================================================================== */

/* --------------------------------------------------------------------------
   Card — the default dark "file" surface
   -------------------------------------------------------------------------- */
.card {
  position: relative;
  padding: var(--sp-4);
  background:
    linear-gradient(160deg, rgba(27, 66, 50, 0.28) 0%, transparent 46%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
}

/* Hairline gold corner brackets, like a stamped file cover. */
.card::before,
.card::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1px solid rgba(201, 162, 39, 0.45);
  pointer-events: none;
}

.card::before {
  top: 7px;
  left: 7px;
  border-right: 0;
  border-bottom: 0;
}

.card::after {
  right: 7px;
  bottom: 7px;
  border-top: 0;
  border-left: 0;
}

.card--plain::before,
.card--plain::after {
  display: none;
}

.card--pad-lg {
  padding: var(--sp-5);
}

.card__head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--line-soft);
}

.card__title {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-400);
}

.card--accent {
  border-color: rgba(201, 162, 39, 0.5);
  box-shadow: var(--shadow-md), inset 0 0 60px rgba(201, 162, 39, 0.07);
}

.card--danger {
  border-color: rgba(140, 36, 56, 0.5);
  background:
    linear-gradient(160deg, rgba(89, 26, 41, 0.35) 0%, transparent 50%),
    var(--surface);
}

/* --------------------------------------------------------------------------
   Paper — parchment surface for notes and documents
   -------------------------------------------------------------------------- */
.paper {
  position: relative;
  padding: var(--sp-4);
  color: var(--ink);
  background:
    linear-gradient(150deg, var(--parchment-100) 0%, var(--parchment-200) 58%, var(--parchment-400) 130%);
  border-radius: 2px;
  box-shadow: var(--shadow-deep), inset 0 0 46px rgba(120, 92, 46, 0.22);
}

.paper::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--grain);
  opacity: 0.09;
  border-radius: inherit;
  pointer-events: none;
}

.paper > * {
  position: relative;
  z-index: 1;
}

.paper h1,
.paper h2,
.paper h3 {
  color: var(--ink);
}

.paper .muted {
  color: var(--ink-soft);
}

.paper--tilt-l { transform: rotate(-1.1deg); }
.paper--tilt-r { transform: rotate(0.9deg); }

/* Push pin for anything pinned to the board */
.pin {
  position: absolute;
  top: -9px;
  left: 50%;
  width: 18px;
  height: 18px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #e2606f 0%, #a5253a 55%, #5c101f 100%);
  box-shadow: 0 3px 7px rgba(0, 0, 0, 0.55);
}

.pin--gold {
  background: radial-gradient(circle at 34% 30%, var(--gold-200) 0%, var(--gold-500) 55%, var(--gold-700) 100%);
}

/* Strip of tape across a corner */
.tape {
  position: absolute;
  top: -10px;
  left: 18px;
  width: 74px;
  height: 24px;
  background: rgba(228, 214, 178, 0.32);
  border-left: 1px solid rgba(255, 255, 255, 0.14);
  border-right: 1px solid rgba(255, 255, 255, 0.14);
  transform: rotate(-6deg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.tape--right {
  right: 18px;
  left: auto;
  transform: rotate(5deg);
}

/* Rubber stamp */
.stamp {
  display: inline-block;
  padding: 0.3rem 0.9rem;
  font-family: var(--font-display);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--burgundy-500);
  border: 2px solid var(--burgundy-500);
  border-radius: 3px;
  opacity: 0.72;
  transform: rotate(-7deg);
}

.stamp--gold {
  color: var(--gold-600);
  border-color: var(--gold-600);
}

.stamp--green {
  color: var(--emerald-500);
  border-color: var(--emerald-500);
}

/* Redacted text — hover or focus to peek */
.redacted {
  position: relative;
  padding: 0 0.3em;
  color: transparent;
  background: #14100c;
  border-radius: 2px;
  cursor: help;
  transition: color 0.25s ease, background 0.25s ease;
}

.redacted:hover,
.redacted:focus-visible {
  color: var(--text);
  background: rgba(20, 16, 12, 0.35);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  gap: 0.55rem;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0.7rem 1.4rem;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text);
  text-align: center;
  background: rgba(236, 230, 214, 0.05);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.btn:hover:not(:disabled) {
  color: var(--gold-200);
  background: rgba(201, 162, 39, 0.1);
  border-color: rgba(201, 162, 39, 0.5);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--primary {
  color: #1b1405;
  background: linear-gradient(180deg, var(--gold-400) 0%, var(--gold-600) 100%);
  border-color: var(--gold-400);
  box-shadow: 0 8px 26px rgba(168, 132, 44, 0.3);
}

.btn--primary:hover:not(:disabled) {
  color: #1b1405;
  background: linear-gradient(180deg, var(--gold-200) 0%, var(--gold-500) 100%);
  border-color: var(--gold-200);
  box-shadow: 0 10px 34px rgba(226, 194, 104, 0.42);
}

.btn--danger {
  color: var(--burgundy-300);
  border-color: rgba(140, 36, 56, 0.55);
}

.btn--danger:hover:not(:disabled) {
  color: #f6d6dc;
  background: rgba(140, 36, 56, 0.22);
  border-color: var(--burgundy-500);
}

.btn--ghost {
  background: transparent;
  border-color: var(--line-soft);
}

.btn--sm {
  min-height: 36px;
  padding: 0.35rem 0.85rem;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
}

.btn--lg {
  min-height: 58px;
  padding: 0.95rem 2.2rem;
  font-size: 0.88rem;
}

.btn--block {
  width: 100%;
}

.btn__icon {
  width: 17px;
  height: 17px;
  flex: none;
}

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

.field__label {
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold-500);
}

.field__hint {
  font-size: 0.78rem;
  color: var(--text-faint);
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 0.9rem;
  color: var(--text);
  background: rgba(5, 12, 9, 0.6);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: rgba(201, 162, 39, 0.32);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  background: rgba(5, 12, 9, 0.85);
  border-color: var(--gold-500);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.16);
}

.input::placeholder,
.textarea::placeholder {
  color: rgba(236, 230, 214, 0.3);
}

.select {
  appearance: none;
  padding-right: 2.4rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%23c9a227' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.95rem center;
  background-size: 10px;
}

.select option {
  color: var(--text);
  background: #0b1611;
}

/* PIN field — wide tracking, centred, like a safe dial */
.input--pin {
  font-family: var(--font-display);
  font-size: 1.4rem;
  letter-spacing: 0.7em;
  text-align: center;
  text-indent: 0.7em;
}

.checkline {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.6rem 0;
  cursor: pointer;
}

.checkline input[type="checkbox"] {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 0.15rem;
  accent-color: var(--gold-500);
  cursor: pointer;
}

.checkline__text {
  font-size: 0.92rem;
  color: var(--text-dim);
}

/* --------------------------------------------------------------------------
   Stat tiles
   -------------------------------------------------------------------------- */
.stat {
  position: relative;
  padding: var(--sp-4);
  text-align: center;
  background: linear-gradient(180deg, rgba(19, 38, 29, 0.7) 0%, rgba(8, 16, 12, 0.55) 100%);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
}

.stat--hero {
  border-color: rgba(201, 162, 39, 0.34);
  box-shadow: inset 0 0 50px rgba(201, 162, 39, 0.06);
}

.stat__value {
  display: block;
  margin: 0.2rem 0 0.15rem;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 5.5vw, 2.7rem);
  font-weight: 700;
  line-height: 1.05;
  color: var(--gold-400);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 26px rgba(201, 162, 39, 0.3);
}

.stat__value--sm {
  font-size: clamp(1.3rem, 4vw, 1.8rem);
}

.stat__value--plain {
  color: var(--text);
  text-shadow: none;
}

.stat__label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.63rem;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.stat__note {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-faint);
}

/* --------------------------------------------------------------------------
   Chips / badges
   -------------------------------------------------------------------------- */
.chip {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  padding: 0.24rem 0.7rem;
  font-family: var(--font-display);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: rgba(236, 230, 214, 0.06);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-pill);
  white-space: nowrap;
}

.chip--gold {
  color: var(--gold-200);
  background: rgba(201, 162, 39, 0.12);
  border-color: rgba(201, 162, 39, 0.42);
}

.chip--green {
  color: #9fe0bd;
  background: rgba(44, 107, 79, 0.18);
  border-color: rgba(44, 107, 79, 0.5);
}

.chip--red {
  color: var(--burgundy-300);
  background: rgba(140, 36, 56, 0.16);
  border-color: rgba(140, 36, 56, 0.45);
}

.chip__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.chip--live .chip__dot {
  animation: pulse-dot 2.4s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   Progress & meters
   -------------------------------------------------------------------------- */
.progress {
  height: 4px;
  overflow: hidden;
  background: rgba(236, 230, 214, 0.08);
  border-radius: var(--r-pill);
}

.progress__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-600), var(--gold-400));
  border-radius: inherit;
  box-shadow: 0 0 12px rgba(226, 194, 104, 0.5);
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Day-by-day score bars */
.bars {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.bar {
  display: grid;
  grid-template-columns: 4.6rem minmax(0, 1fr) 3.2rem;
  gap: 0.8rem;
  align-items: center;
}

.bar__label {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.bar__track {
  position: relative;
  height: 10px;
  overflow: hidden;
  background: rgba(236, 230, 214, 0.07);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-pill);
}

.bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--emerald-700), var(--gold-500));
  border-radius: inherit;
  box-shadow: 0 0 14px rgba(201, 162, 39, 0.35);
  transform-origin: left center;
  animation: bar-grow 0.8s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.bar__value {
  font-family: var(--font-display);
  font-size: 0.85rem;
  text-align: right;
  color: var(--gold-400);
  font-variant-numeric: tabular-nums;
}

.bar--empty .bar__value {
  font-size: 0.7rem;
  color: var(--text-faint);
}

/* --------------------------------------------------------------------------
   Avatars
   -------------------------------------------------------------------------- */
.avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--gold-200);
  background:
    radial-gradient(circle at 34% 28%, rgba(201, 162, 39, 0.28), transparent 62%),
    linear-gradient(160deg, var(--emerald-800), var(--forest-950));
  border: 1px solid var(--line);
  border-radius: 50%;
}

.avatar--lg {
  width: 62px;
  height: 62px;
  font-size: 1.1rem;
}

.avatar--sm {
  width: 32px;
  height: 32px;
  font-size: 0.68rem;
}

/* --------------------------------------------------------------------------
   Leaderboard / rank rows
   -------------------------------------------------------------------------- */
.rank {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.rank__row {
  display: grid;
  grid-template-columns: 2.6rem auto minmax(0, 1fr) auto;
  gap: var(--sp-3);
  align-items: center;
  padding: 0.75rem var(--sp-3);
  background: linear-gradient(90deg, rgba(19, 38, 29, 0.55), rgba(8, 16, 12, 0.3));
  border: 1px solid var(--line-soft);
  border-left: 3px solid rgba(201, 162, 39, 0.25);
  border-radius: var(--r-sm);
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.rank__row:hover {
  transform: translateX(3px);
  border-left-color: var(--gold-500);
  background: linear-gradient(90deg, rgba(27, 66, 50, 0.6), rgba(8, 16, 12, 0.3));
}

.rank__row--me {
  border-color: rgba(201, 162, 39, 0.45);
  border-left-color: var(--gold-400);
  box-shadow: inset 0 0 40px rgba(201, 162, 39, 0.08);
}

.rank__row--top {
  border-left-color: var(--gold-400);
}

.rank__pos {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gold-500);
  font-variant-numeric: tabular-nums;
}

.rank__body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.rank__name {
  min-width: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.05em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank__meta {
  font-size: 0.76rem;
  color: var(--text-faint);
}

.rank__score {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--gold-400);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 620px) {
  .rank__row {
    grid-template-columns: 2.1rem auto minmax(0, 1fr);
    grid-template-areas:
      "pos avatar name"
      "pos avatar score";
    row-gap: 0.15rem;
  }

  .rank__pos { grid-area: pos; }
  .rank__avatar { grid-area: avatar; }
  .rank__body { grid-area: name; }
  .rank__score {
    grid-area: score;
    font-size: 0.9rem;
    text-align: left;
  }
}

/* --------------------------------------------------------------------------
   Investigation board — pinned suspect cards linked by threads
   -------------------------------------------------------------------------- */
.board {
  position: relative;
  padding: var(--sp-5) var(--sp-4) var(--sp-4);
  background:
    radial-gradient(circle at 30% 20%, rgba(61, 20, 32, 0.28), transparent 55%),
    linear-gradient(155deg, rgba(43, 30, 18, 0.75), rgba(10, 16, 12, 0.85));
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-deep), inset 0 0 90px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.board::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--grain);
  opacity: 0.06;
  pointer-events: none;
}

.board__threads {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.board__grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: var(--sp-4);
}

.suspect {
  position: relative;
  padding: var(--sp-3) var(--sp-2) var(--sp-2);
  text-align: center;
  color: var(--ink);
  background: linear-gradient(160deg, var(--parchment-100), var(--parchment-400));
  border-radius: 2px;
  box-shadow: var(--shadow-md);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.suspect:nth-child(odd) { transform: rotate(-1.4deg); }
.suspect:nth-child(even) { transform: rotate(1.2deg); }

.suspect:hover {
  transform: rotate(0) scale(1.035);
  box-shadow: var(--shadow-deep), 0 0 24px rgba(201, 162, 39, 0.25);
  z-index: 2;
}

.suspect__photo {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  margin-bottom: 0.6rem;
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  color: rgba(246, 237, 216, 0.85);
  background:
    radial-gradient(circle at 40% 26%, rgba(90, 120, 100, 0.55), transparent 60%),
    linear-gradient(165deg, #2c3a31 0%, #151d18 100%);
  border: 1px solid rgba(42, 32, 21, 0.35);
  filter: grayscale(0.35) contrast(1.05);
}

.suspect__name {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.suspect__note {
  margin-top: 0.15rem;
  font-family: var(--font-hand);
  font-size: 1.02rem;
  line-height: 1.25;
  color: #6a2231;
}

.suspect__meta {
  margin-top: 0.45rem;
  padding-top: 0.4rem;
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-top: 1px solid rgba(42, 32, 21, 0.22);
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  white-space: nowrap;
}

.table th {
  padding: 0.75rem var(--sp-3);
  font-family: var(--font-display);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-align: left;
  text-transform: uppercase;
  color: var(--gold-500);
  background: rgba(5, 12, 9, 0.5);
  border-bottom: 1px solid var(--line);
}

.table td {
  padding: 0.7rem var(--sp-3);
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover td {
  background: rgba(201, 162, 39, 0.05);
}

.table__num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table__actions {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
}

/* --------------------------------------------------------------------------
   Notices, empty states, toasts
   -------------------------------------------------------------------------- */
.notice {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  padding: var(--sp-3) var(--sp-4);
  background: rgba(19, 38, 29, 0.5);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--gold-600);
  border-radius: var(--r-sm);
}

.notice--danger {
  background: rgba(61, 20, 32, 0.4);
  border-left-color: var(--burgundy-500);
}

.notice--info {
  border-left-color: var(--emerald-500);
}

.notice__icon {
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 0.15rem;
  color: var(--gold-500);
}

.notice--danger .notice__icon {
  color: var(--burgundy-300);
}

.notice__title {
  font-family: var(--font-display);
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.notice__text {
  margin-top: 0.2rem;
  font-size: 0.92rem;
  color: var(--text-dim);
}

.empty {
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
  border: 1px dashed var(--line-soft);
  border-radius: var(--r-md);
}

.empty__glyph {
  margin: 0 auto var(--sp-3);
  width: 46px;
  height: 46px;
  color: var(--gold-700);
  opacity: 0.7;
}

.empty__title {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.empty__text {
  margin: var(--sp-2) auto 0;
  max-width: 42ch;
  font-family: var(--font-hand);
  font-size: 1.2rem;
  color: var(--text-faint);
}

.toasts {
  position: fixed;
  right: clamp(0.75rem, 3vw, 1.5rem);
  bottom: clamp(0.75rem, 3vw, 1.5rem);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-width: min(360px, calc(100vw - 1.5rem));
}

.toast {
  padding: 0.8rem 1.1rem;
  font-size: 0.9rem;
  background: linear-gradient(160deg, rgba(27, 66, 50, 0.96), rgba(8, 16, 12, 0.96));
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold-500);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-deep);
  animation: toast-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.toast--error {
  border-left-color: var(--burgundy-500);
}

.toast--leaving {
  animation: toast-out 0.3s ease forwards;
}

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  background: rgba(3, 6, 5, 0.82);
  backdrop-filter: blur(5px);
  animation: fade-in 0.22s ease both;
}

.modal[hidden] {
  display: none;
}

.modal__panel {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  animation: rise-in 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* --------------------------------------------------------------------------
   Segmented control / tabs (admin)
   -------------------------------------------------------------------------- */
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0.3rem;
  background: rgba(5, 12, 9, 0.5);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
}

.segmented__item {
  padding: 0.5rem 0.9rem;
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: transparent;
  border: 0;
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.segmented__item:hover {
  color: var(--gold-200);
}

.segmented__item[aria-selected="true"] {
  color: var(--gold-200);
  background: rgba(201, 162, 39, 0.16);
}

/* --------------------------------------------------------------------------
   Toggle switch
   -------------------------------------------------------------------------- */
.switch {
  display: inline-flex;
  gap: 0.7rem;
  align-items: center;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch__track {
  position: relative;
  flex: none;
  width: 46px;
  height: 26px;
  background: rgba(236, 230, 214, 0.1);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-pill);
  transition: background 0.24s ease, border-color 0.24s ease;
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--text-faint);
  border-radius: 50%;
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), background 0.24s ease;
}

.switch input:checked + .switch__track {
  background: rgba(201, 162, 39, 0.28);
  border-color: var(--gold-500);
}

.switch input:checked + .switch__track::after {
  background: var(--gold-400);
  transform: translateX(20px);
}

.switch input:focus-visible + .switch__track {
  outline: 2px solid var(--gold-400);
  outline-offset: 3px;
}

.switch__label {
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* --------------------------------------------------------------------------
   Test runner
   -------------------------------------------------------------------------- */
.test-shell {
  max-width: 720px;
  margin-inline: auto;
}

.test-meter {
  display: flex;
  gap: 0.3rem;
  margin-bottom: var(--sp-3);
}

.test-meter__tick {
  flex: 1;
  height: 3px;
  background: rgba(236, 230, 214, 0.1);
  border-radius: var(--r-pill);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.test-meter__tick--done {
  background: var(--emerald-500);
}

.test-meter__tick--current {
  background: var(--gold-400);
  box-shadow: 0 0 10px rgba(226, 194, 104, 0.7);
}

.question {
  min-height: 4.5rem;
  margin-bottom: var(--sp-4);
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  font-weight: 600;
  line-height: 1.3;
  max-width: none;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.option {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  width: 100%;
  padding: 1rem 1.1rem;
  font-family: var(--font-body);
  font-size: 1.05rem;
  text-align: left;
  color: var(--text);
  background: rgba(8, 18, 13, 0.6);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: transform 0.16s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.option:hover {
  background: rgba(27, 66, 50, 0.4);
  border-color: rgba(201, 162, 39, 0.4);
  transform: translateX(3px);
}

.option__key {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gold-500);
  border: 1px solid var(--line);
  border-radius: 50%;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.option[aria-pressed="true"] {
  background: linear-gradient(120deg, rgba(201, 162, 39, 0.2), rgba(27, 66, 50, 0.35));
  border-color: var(--gold-400);
  box-shadow: inset 0 0 40px rgba(201, 162, 39, 0.1), 0 0 22px rgba(201, 162, 39, 0.16);
}

.option[aria-pressed="true"] .option__key {
  color: #1b1405;
  background: var(--gold-400);
  border-color: var(--gold-400);
}

.option--correct {
  border-color: rgba(44, 107, 79, 0.7);
  background: rgba(44, 107, 79, 0.18);
}

.option--wrong {
  border-color: rgba(140, 36, 56, 0.7);
  background: rgba(140, 36, 56, 0.16);
}

.option:disabled {
  cursor: default;
  transform: none;
}

/* Review list on the results page */
.review {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.review__item {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  gap: var(--sp-3);
  align-items: center;
  padding: 0.7rem var(--sp-3);
  background: rgba(8, 18, 13, 0.45);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
}

.review__num {
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: var(--text-faint);
}

.review__q {
  min-width: 0;
  font-size: 0.95rem;
}

.review__mark {
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.review__mark--ok { color: var(--emerald-300); }
.review__mark--no { color: var(--burgundy-300); }

/* --------------------------------------------------------------------------
   Suspicion meter — atmospheric progress dial
   -------------------------------------------------------------------------- */
.suspicion {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
}

.suspicion__track {
  position: relative;
  flex: 1;
  height: 8px;
  overflow: hidden;
  background: rgba(236, 230, 214, 0.08);
  border-radius: var(--r-pill);
}

.suspicion__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--emerald-700), var(--gold-500), var(--burgundy-500));
  border-radius: inherit;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.suspicion__label {
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Login screen
   -------------------------------------------------------------------------- */
.gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--sp-5) var(--sp-3);
}

.gate__inner {
  width: min(440px, 100%);
}

.gate__crest {
  width: 76px;
  height: 76px;
  margin: 0 auto var(--sp-3);
  color: var(--gold-500);
  filter: drop-shadow(0 0 22px rgba(201, 162, 39, 0.45));
  animation: flicker 5.5s ease-in-out infinite;
}

.gate__title {
  font-size: clamp(2rem, 8vw, 3rem);
  text-align: center;
  letter-spacing: 0.06em;
  text-shadow: 0 0 40px rgba(201, 162, 39, 0.28);
}

.gate__place {
  display: block;
  margin-top: 0.4rem;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.52em;
  text-align: center;
  text-indent: 0.52em;
  text-transform: uppercase;
  color: var(--gold-600);
}

.gate__motto {
  margin: var(--sp-4) 0 var(--sp-5);
  font-size: 0.72rem;
  font-family: var(--font-display);
  letter-spacing: 0.32em;
  text-align: center;
  text-indent: 0.32em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.gate__tabs {
  margin-bottom: var(--sp-4);
}

.gate__foot {
  margin-top: var(--sp-5);
  text-align: center;
}

/* --------------------------------------------------------------------------
   Misc listings
   -------------------------------------------------------------------------- */
.list {
  display: flex;
  flex-direction: column;
}

.list__item {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line-soft);
}

.list__item:last-child {
  border-bottom: 0;
}

.list__label {
  font-size: 0.92rem;
  color: var(--text-dim);
}

.list__value {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem var(--sp-3);
  font-size: 0.9rem;
}

.kv__k {
  color: var(--text-faint);
}

.kv__v {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Sticky action bar for admin editors on mobile */
.actionbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  justify-content: flex-end;
  padding-top: var(--sp-3);
  margin-top: var(--sp-3);
  border-top: 1px solid var(--line-soft);
}

@media (max-width: 560px) {
  .actionbar .btn {
    flex: 1 1 auto;
  }
}
