/* Spin the Wheel — Tool Styles */
/* Inherits brand tokens from /assets/css/site.css */

/* ── Tool Layout ──────────────────────────────────────────────────────────── */

.tool-main {
  width: 100%;
  max-width: var(--tool-max);
  margin: 0 auto;
  padding: 2rem 1rem 2.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.tool-header { text-align: center; }

.tool-header h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.tool-header p {
  margin-top: 0.3rem;
  color: var(--stone);
  font-size: 0.95rem;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Field Groups ─────────────────────────────────────────────────────────── */

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

label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.hint {
  font-weight: 400;
  color: var(--stone);
  font-size: 0.82rem;
}

/* ── Textarea ─────────────────────────────────────────────────────────────── */

textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  resize: vertical;
  min-height: 140px;
  transition: border-color 0.15s;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(55, 48, 163, 0.12);
  background: var(--surface);
}

textarea.drag-over {
  border-color: var(--accent);
  background: #EDEDFF;
}

/* ── File Upload ──────────────────────────────────────────────────────────── */

.upload-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}

.btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  background: var(--warm-bg);
  color: var(--warm-text);
  border: 1px solid var(--warm-border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  min-height: 44px;
}

.btn-upload:hover { background: #FDE68A; border-color: var(--warm); }
.btn-upload:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
}

.upload-hint {
  font-size: 0.82rem;
  color: #2d6a3f;
  font-weight: 600;
}

/* ── Toggle ───────────────────────────────────────────────────────────────── */

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  min-height: 44px;
  color: var(--ink);
}

.toggle-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn-primary {
  width: 100%;
  padding: 0.9rem 1.5rem;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  min-height: 52px;
  touch-action: manipulation;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 6px rgba(55, 48, 163, 0.3);
}

.btn-primary:hover        { background: var(--accent-hover); box-shadow: 0 3px 10px rgba(55, 48, 163, 0.35); }
.btn-primary:active       { transform: scale(0.98); }
.btn-primary:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  min-height: 44px;
  touch-action: manipulation;
}

.btn-secondary:hover        { background: var(--bg); border-color: #c8c0b0; }
.btn-secondary:active       { background: #EDEDFF; }
.btn-secondary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ── Cross-link Card ──────────────────────────────────────────────────────── */

.crosslink-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--warm-bg);
  border: 1px solid var(--warm-border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  font-size: 0.9rem;
  color: var(--ink);
}

.crosslink-icon {
  color: var(--warm);
  flex-shrink: 0;
}

.crosslink-card strong {
  display: block;
  font-weight: 700;
  margin-bottom: 0.1rem;
}

.crosslink-card a {
  color: var(--warm);
  font-weight: 600;
  text-decoration: none;
}

.crosslink-card a:hover { text-decoration: underline; }

/* ── Toast ────────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--surface);
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 1000;
  white-space: nowrap;
  animation: toast-in 0.2s ease-out;
  pointer-events: none;
}

.toast--hide { animation: toast-out 0.25s ease-in forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to   { opacity: 0; transform: translateX(-50%) translateY(8px); }
}


/* ── Shared bits (same as Secret Santa) ───────────────────────────────────── */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
[hidden] { display: none !important; }

.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; }
.count { font-size: 0.82rem; font-weight: 700; color: var(--stone); font-variant-numeric: tabular-nums; white-space: nowrap; }
::placeholder { color: var(--stone); opacity: 1; }
textarea { caret-color: var(--accent); }

.btn-text {
  background: none; border: none;
  padding: 0.45rem 0.25rem; min-height: 44px;
  font-family: var(--font); font-size: 0.85rem; font-weight: 600;
  color: var(--accent);
  text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}
.btn-text:hover { color: var(--accent-hover); }
.btn-text:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.btn-primary:disabled, .btn-secondary:disabled, .chip:disabled { opacity: 0.5; cursor: not-allowed; }

.form-error {
  font-size: 0.9rem; font-weight: 600; line-height: 1.5;
  color: var(--highlight);
  background: #FFF1F2; border: 1px solid #FECDD3;
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  width: 100%;
}

.confirm-box {
  display: flex; flex-direction: column; gap: 0.6rem;
  background: var(--warm-bg); border: 1px solid var(--warm-border);
  color: var(--warm-text);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  font-size: 0.9rem; line-height: 1.5;
}

.action-row { display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: center; }

.crosslink-banner {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  background: var(--warm-bg); border-top: 1px solid var(--warm-border);
  padding: 0.75rem 1.5rem;
  font-size: 0.9rem; color: var(--stone);
  flex-wrap: wrap; text-align: center;
}
.crosslink-banner a { color: var(--warm); font-weight: 700; text-decoration: none; }
.crosslink-banner a:hover { text-decoration: underline; }

/* ── Wheel stage ──────────────────────────────────────────────────────────── */

.wheel-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.stage-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.stage-title {
  font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--stone);
  font-variant-numeric: tabular-nums;
}
.stage-tools { display: flex; gap: 0.35rem; }

.icon-btn {
  display: inline-flex; align-items: center; gap: 0.35rem;
  min-height: 40px; padding: 0.4rem 0.7rem;
  background: var(--surface); color: var(--stone);
  border: 1px solid var(--border); border-radius: 999px;
  font-family: var(--font); font-size: 0.8rem; font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover { color: var(--ink); background: var(--bg); }
.icon-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.icon-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: #EDEDFF; }
.icon-btn .i-on, .icon-btn[aria-pressed="true"] .i-off { display: none; }
.icon-btn[aria-pressed="true"] .i-on { display: block; }
.icon-btn .i-exit { display: none; }
.is-present .icon-btn .i-exit { display: block; }
.is-present .icon-btn .i-enter { display: none; }

.wheel-wrap {
  position: relative;
  width: min(100%, 460px);
  aspect-ratio: 1;
  user-select: none;
  -webkit-user-select: none;
}

/* The round frame clips the turning square canvas so its corners never
   stick out of the page. */
.wheel-disc {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(28, 28, 28, 0.16), 0 1px 3px rgba(28, 28, 28, 0.12);
}

.wheel-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
  will-change: transform;
  touch-action: manipulation;
}
.is-spinning .wheel-canvas { cursor: progress; }

.wheel-pointer {
  position: absolute;
  top: -10px;
  left: 50%;
  width: 34px;
  height: 38px;
  transform: translateX(-50%);
  z-index: 2;
  filter: drop-shadow(0 2px 3px rgba(28, 28, 28, 0.3));
  pointer-events: none;
}

.wheel-hub {
  position: absolute;
  top: 50%; left: 50%;
  width: 19%;
  aspect-ratio: 1;
  min-width: 56px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 4px solid #FFFFFF;
  background: var(--ink);
  color: #FFFFFF;
  font-family: var(--font);
  font-weight: 800;
  font-size: clamp(0.8rem, 3.2vw, 1.05rem);
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(28, 28, 28, 0.35);
  z-index: 2;
  transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), background 0.15s;
}
.wheel-hub:hover { background: var(--accent); }
.wheel-hub:active { transform: translate(-50%, -50%) scale(0.94); }
.wheel-hub:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.wheel-hub:disabled { cursor: progress; background: var(--ink); }

/* Winner */
.winner {
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
  gap: 0.1rem;
  min-height: 4.2rem;
}
.winner-label {
  font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--stone);
}
.winner-name {
  font-size: clamp(1.7rem, 6vw, 2.5rem);
  font-weight: 800;
  color: var(--highlight);
  letter-spacing: -0.02em;
  line-height: 1.15;
  overflow-wrap: anywhere;
  max-width: 100%;
}
@keyframes winner-in {
  0%   { opacity: 0; transform: scale(0.88); filter: blur(4px); }
  100% { opacity: 1; transform: none; filter: none; }
}
.winner:not([hidden]) .winner-name { animation: winner-in 0.35s cubic-bezier(0.16, 1, 0.3, 1) both; }

#btn-spin { max-width: 460px; font-size: 1.1rem; min-height: 56px; }

/* ── Entries ──────────────────────────────────────────────────────────────── */

.entries {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
}

.presets { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.presets-label { font-size: 0.85rem; font-weight: 600; color: var(--stone); margin-right: 0.15rem; }
.chip {
  min-height: 40px;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.chip:hover { background: var(--bg); border-color: #c8c0b0; }
.chip:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.entries-tools { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

.history { display: flex; flex-direction: column; gap: 0.5rem; }
.history-head { display: flex; justify-content: space-between; align-items: center; }
.history-title {
  font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--stone);
}
.history-list {
  list-style: none;
  display: flex; flex-wrap: wrap; gap: 0.35rem;
  counter-reset: win;
}
.history-list li {
  counter-increment: win;
  font-size: 0.88rem; font-weight: 700;
  padding: 0.25rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow-wrap: anywhere;
}
.history-list li::before {
  content: counter(win) ".";
  color: var(--stone);
  font-weight: 600;
  margin-right: 0.35rem;
  font-variant-numeric: tabular-nums;
}

/* ── Page extras ──────────────────────────────────────────────────────────── */

.faq-inner > ul strong, .faq-inner > p strong { color: var(--ink); }

/* ── Present mode (fullscreen, or a full-window fallback on iPhone) ──────── */

.wheel-stage.is-present {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: var(--bg);
  padding: max(1rem, env(safe-area-inset-top)) 1.25rem max(1.25rem, env(safe-area-inset-bottom));
  justify-content: center;
  gap: 1.25rem;
  overflow: auto;
}
.wheel-stage.is-present .wheel-wrap { width: min(92vw, calc(100dvh - 15rem)); max-width: none; }
.wheel-stage.is-present .stage-bar { position: absolute; top: max(0.75rem, env(safe-area-inset-top)); left: 1.25rem; right: 1.25rem; width: auto; }
.wheel-stage.is-present .winner-name { font-size: clamp(2rem, 6vw, 3.5rem); }
.wheel-stage.is-present #btn-spin { max-width: 420px; }
.wheel-stage:fullscreen { background: var(--bg); }
body.has-present { overflow: hidden; }

@media (max-width: 480px) {
  .icon-label { display: none; }
  .icon-btn { padding: 0.4rem 0.6rem; min-width: 44px; justify-content: center; }
  .action-row .btn-secondary { flex: 1 1 auto; justify-content: center; }
}
