/* ==========================================================================
   Wheel of Names — stylesheet (marina blue & white)
   Sections: tokens · header · layout · wheel · result · buttons · inputs ·
             names list · winners list · misc · responsive · accessibility
   ========================================================================== */

/* ---- Design tokens: colours, radii, shadows, fonts ---------------------- */
:root {
  --navy: #0a3d62;
  --marina: #1b6ca8;
  --marina-dark: #155a8c;
  --marina-bright: #2e86c1;
  --sky: #e8f2f9;
  --sky-line: #d4e3ee;
  --ink: #16384f;
  --muted: #5a7891;
  --white: #ffffff;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 12px 34px rgba(10, 61, 98, 0.10);
  --shadow-sm: 0 4px 14px rgba(10, 61, 98, 0.08);
  --ring: 0 0 0 4px rgba(46, 134, 193, 0.28);

  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

/* Soft blue gradient background behind everything */
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 50% -8%, #dcebf8 0%, rgba(220, 235, 248, 0) 60%),
    linear-gradient(168deg, #eaf3fa 0%, #f6fbfd 55%, #ffffff 100%);
  background-attachment: fixed;
  padding: 0 20px 56px;
}

/* ---- Header ------------------------------------------------------------- */
.app-header {
  max-width: 1120px;
  margin: 0 auto;
  text-align: center;
  padding: 40px 0 24px;
}
.app-header h1 {
  margin: 0;
  font-size: clamp(2rem, 4.5vw, 2.9rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--navy);
}
.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
}

/* ---- Layout: wheel on the left, sidebar on the right -------------------- */
.layout {
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 28px;
  align-items: start;
}

/* Generic white card */
.card {
  background: var(--white);
  border: 1px solid rgba(27, 108, 168, 0.10);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card h2 {
  margin: 0 0 14px;
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--navy);
}

.sidebar { display: grid; gap: 28px; }

/* ---- Wheel -------------------------------------------------------------- */
.wheel-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Square stage that holds the canvas, pointer and centre button */
.wheel-stage {
  position: relative;
  width: min(440px, 84vw);
  aspect-ratio: 1 / 1;
  margin: 6px auto 4px;
}

#wheel {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  filter: drop-shadow(0 16px 28px rgba(10, 61, 98, 0.20));
}

/* The marina-blue pointer pinned to the top of the wheel */
.pointer {
  position: absolute;
  top: -34px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  filter: drop-shadow(0 3px 4px rgba(10, 61, 98, 0.35));
}

/* Round Spin button in the middle of the wheel */
.spin-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 94px;
  height: 94px;
  border-radius: 50%;
  border: 5px solid var(--white);
  background: radial-gradient(circle at 50% 32%, var(--marina-bright), var(--marina) 62%, var(--navy));
  color: var(--white);
  font: 700 1.05rem/1 var(--font);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(10, 61, 98, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}
.spin-center:hover { transform: translate(-50%, -50%) scale(1.06); }
.spin-center:active { transform: translate(-50%, -50%) scale(0.97); }
.spin-center:disabled {
  cursor: not-allowed;
  filter: grayscale(0.6) opacity(0.6);
  box-shadow: none;
}

/* ---- Result banner ------------------------------------------------------ */
.result {
  min-height: 64px;
  margin: 14px 0 4px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.result.show .result-name { animation: pop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.4); }
.result-name {
  font-size: clamp(1.5rem, 3.4vw, 2rem);
  font-weight: 800;
  color: var(--navy);
  line-height: 1.15;
  word-break: break-word;
}
.result.recorded .result-name { color: var(--marina); }
.result-sub {
  margin-top: 4px;
  font-size: 0.86rem;
  color: var(--muted);
}
@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Reset button sits under the result */
.reset-btn { margin-top: 2px; }

/* Dynamic guidance line */
.hint {
  margin: 10px 0 0;
  max-width: 420px;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
}

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font: 600 0.95rem var(--font);
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, transform 0.1s ease, box-shadow 0.14s ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--marina);
  color: var(--white);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--marina-dark); }

.btn-ghost {
  background: transparent;
  color: var(--marina);
  border: 1px solid var(--sky-line);
  padding: 7px 12px;
  font-size: 0.85rem;
}
.btn-ghost:hover { background: var(--sky); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ---- Inputs ------------------------------------------------------------- */
.add-row { display: flex; gap: 10px; margin-bottom: 14px; }

input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border: 1.5px solid var(--sky-line);
  border-radius: var(--radius-sm);
  font: 400 0.98rem var(--font);
  color: var(--ink);
  background: var(--white);
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
input[type="text"]::placeholder { color: #9fb3c4; }
input[type="text"]:focus {
  outline: none;
  border-color: var(--marina-bright);
  box-shadow: var(--ring);
}
input[type="text"]:disabled { background: #f4f7fa; color: var(--muted); }

/* ---- Names list --------------------------------------------------------- */
.name-list, .history-list { list-style: none; margin: 0; padding: 0; }

.name-list { max-height: 340px; overflow-y: auto; }

.name-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--sky);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
/* Switched off: dimmed, greyed name (score still shown) */
.name-item.off { opacity: 0.6; }
.name-item.off .name-text { color: var(--muted); }
/* Selected this round: struck through until the wheel is reset */
.name-item.eliminated { opacity: 0.6; }
.name-item.eliminated .name-text { text-decoration: line-through; }

.name-text {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Compact on/off switch in each name row */
.switch-mini {
  position: relative;
  display: inline-flex;
  flex: none;
  width: 34px;
  height: 20px;
  cursor: pointer;
}
.switch-mini input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-mini-track {
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--sky-line);
  position: relative;
  transition: background 0.18s ease;
}
.switch-mini-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s ease;
}
.switch-mini input:checked + .switch-mini-track { background: var(--marina); }
.switch-mini input:checked + .switch-mini-track::after { transform: translateX(14px); }
.switch-mini input:focus-visible + .switch-mini-track { box-shadow: var(--ring); }

/* Score stepper (− value +) */
.score-control {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1px solid var(--sky-line);
  border-radius: 999px;
  padding: 2px;
  flex: none;
}
.step {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--marina);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.step:hover { background: var(--sky); }
.step:active { background: var(--marina); color: var(--white); }
.score-value {
  min-width: 22px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--navy);
}

/* Delete (×) button */
.delete {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  flex: none;
  transition: background 0.12s ease, color 0.12s ease;
}
.delete:hover { background: #fdecea; color: #c0392b; }

/* ---- Winners list (dashboard) ------------------------------------------- */
.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid #eef4f8;
}
.history-item:last-child { border-bottom: none; }

/* Rank (#1 = most recent) */
.h-rank {
  flex: none;
  min-width: 26px;
  color: #9fb3c4;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}
.h-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Score pill — the winner's total when they won */
.h-score {
  flex: none;
  background: var(--sky);
  color: var(--marina-dark);
  font-weight: 700;
  font-size: 0.76rem;
  padding: 2px 9px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.h-score.empty-chip { background: transparent; color: #9fb3c4; padding: 0; }
.h-time {
  flex: none;
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Pager controls */
.history-footer { gap: 10px; flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: 6px; }
.pager-btn { padding: 6px 11px; font-size: 1rem; line-height: 1; }
.pager-text { min-width: 96px; text-align: center; font-variant-numeric: tabular-nums; }

/* ---- Misc --------------------------------------------------------------- */
.empty {
  padding: 14px 4px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}
.muted { color: var(--muted); font-size: 0.85rem; }
.list-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

/* Slim scrollbars for the lists */
.name-list::-webkit-scrollbar, .history-list::-webkit-scrollbar { width: 8px; }
.name-list::-webkit-scrollbar-thumb, .history-list::-webkit-scrollbar-thumb {
  background: var(--sky-line);
  border-radius: 99px;
}

/* ---- Responsive: stack the columns on narrow screens -------------------- */
@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .wheel-panel { order: 1; }
  .sidebar { order: 2; }
}

/* ---- Accessibility ------------------------------------------------------ */
:focus-visible { outline: 2px solid var(--marina-bright); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
