/* Decision Wheel — a flick-to-decide wheel with a ticking flapper.
 * One Page Toys tool family, self-contained, theme-aware (light/dark). */

@import url("https://fonts.googleapis.com/css2?family=Archivo:wght@500;600;700;800;900&family=Inter:wght@400;500;600;700&display=swap");

:root{
  --font-display: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --ink: #1e1b2e;
  --bg: #f8f7fc;
  --surface: #ffffff;
  --surface-2: #f1eefa;
  --muted: #6f6a84;
  --line: #e9e5f4;
  --line-strong: #d7d1e8;
  --radius: 18px;
  --radius-pill: 999px;
  --shadow: 0 2px 8px rgba(30, 24, 60, 0.06);
  --shadow-md: 0 8px 22px rgba(30, 24, 60, 0.10);
  --shadow-lg: 0 16px 40px rgba(30, 24, 60, 0.14);
  --accent: #6b5ce7;
  --accent-hi: #8b7cf5;
  --accent-lo: #4f3fd0;
  --accent-soft: rgba(107, 92, 231, 0.15);
}
:root[data-theme="dark"]{
  --ink: #ece9f7;
  --bg: #100e1a;
  --surface: #1a1728;
  --surface-2: #221e34;
  --muted: #9790b0;
  --line: #262138;
  --line-strong: #362f4c;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 10px 30px -6px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 18px 48px -10px rgba(0, 0, 0, 0.6);
  --accent: #8b7cf5;
  --accent-hi: #a99cff;
  --accent-lo: #6b5ce7;
  --accent-soft: rgba(139, 124, 245, 0.2);
}

*, *::before, *::after{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin: 0; min-height: 100%;
  display: flex; flex-direction: column;
  font-family: var(--font-sans); color: var(--ink);
  background: radial-gradient(62% 46% at 50% 22%, var(--accent-soft), transparent 70%), var(--bg);
  overflow-x: hidden; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Top bar (shared chrome) ---------- */
.topbar{
  position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; padding: 14px clamp(16px, 4vw, 30px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.brand{
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 800; font-size: 0.86rem;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink); text-decoration: none;
}
.brand__mark{
  width: 1.1em; height: 1.1em; border: 1.5px solid var(--ink); border-radius: 6px;
  background: linear-gradient(90deg, var(--ink) 0 50%, var(--surface) 50% 100%);
}
.topbar__right{ display: inline-flex; align-items: center; gap: 10px; }
.topbar__tag{
  font-family: var(--font-display); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
}
.iconbtn{
  appearance: none; display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; font-size: 1rem; line-height: 1;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-pill);
  background: var(--surface); color: var(--ink); cursor: pointer; box-shadow: var(--shadow);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease, color 140ms ease;
}
.iconbtn:hover{ transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--ink); }
.iconbtn:focus-visible{ outline: none; box-shadow: 0 0 0 2px var(--bg), 0 0 0 5px var(--accent-soft); }
#soundBtn[aria-pressed="false"]{ color: var(--muted); border-style: dashed; }
.theme-toggle__sun, .theme-toggle__moon, .theme-toggle__auto{ display: none; }
:root[data-theme-mode="system"] .theme-toggle__auto{ display: inline; }
:root[data-theme-mode="light"] .theme-toggle__sun{ display: inline; }
:root[data-theme-mode="dark"] .theme-toggle__moon{ display: inline; }

/* ---------- Stage ---------- */
.stage{
  position: relative; z-index: 2; flex: 1 0 auto;
  display: flex; flex-direction: column; align-items: center;
  gap: 26px; padding: clamp(18px, 3.4vw, 34px) 20px clamp(44px, 6vw, 66px);
}

.wheelwrap{
  width: 100%; max-width: 460px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.wheelbox{ position: relative; width: min(400px, 84vw); aspect-ratio: 1; }
#wheel{
  width: 100%; height: 100%; display: block; cursor: grab;
  touch-action: none;
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
#wheel:active{ cursor: grabbing; }

.verdict{
  margin: 0; min-height: 2.4rem;
  font-family: var(--font-display); font-weight: 900;
  font-size: clamp(1.5rem, 6.4vw, 2.3rem); line-height: 1.1; letter-spacing: -0.02em;
  color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  overflow-wrap: anywhere;
}
.verdict.is-idle{ font-size: 0.78rem; font-weight: 800; letter-spacing: 0.26em; text-transform: uppercase; color: var(--muted); }
.verdict.is-pop{ animation: pop 520ms cubic-bezier(0.2, 0.9, 0.3, 1.3); }
@keyframes pop{ 0%{ transform: scale(0.6); opacity: 0; } 60%{ transform: scale(1.12); opacity: 1; } 100%{ transform: scale(1); } }

/* ---------- Buttons ---------- */
.actions{ display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; }
.btn{
  appearance: none; font-family: var(--font-display); font-size: 1rem; font-weight: 700;
  padding: 14px 30px; border-radius: var(--radius-pill); border: 1.5px solid var(--ink);
  background: var(--surface); color: var(--ink); cursor: pointer; box-shadow: var(--shadow);
  transition: transform 160ms ease, box-shadow 160ms ease, background 200ms ease, color 200ms ease, border-color 200ms ease;
}
.btn:hover{ transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn:active{ transform: translateY(0); }
.btn:focus-visible{ outline: none; box-shadow: 0 0 0 2px var(--bg), 0 0 0 5px var(--accent-soft), var(--shadow); }
.btn[disabled]{ opacity: 0.45; cursor: not-allowed; transform: none; }
.btn--primary{
  min-width: 148px; font-size: 1.08rem; padding: 15px 38px;
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 8px 26px -6px var(--accent);
}
.btn--primary:hover{ background: var(--accent-lo); border-color: var(--accent-lo); }
.btn--ghost{ border-color: var(--line-strong); color: var(--muted); box-shadow: none; }
.btn--ghost:hover{ color: var(--ink); border-color: var(--ink); box-shadow: var(--shadow); }
.btn--add{ font-size: 0.86rem; padding: 10px 20px; border-color: var(--line-strong); color: var(--muted); box-shadow: none; }
.btn--add:hover{ color: var(--accent); border-color: var(--accent); }

/* ---------- Editor ---------- */
.editor{
  width: 100%; max-width: 460px;
  padding: 18px; border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
.editor__head{ display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.editor__title{
  margin: 0; font-family: var(--font-display); font-size: 0.74rem; font-weight: 800;
  letter-spacing: 0.24em; text-transform: uppercase; color: var(--muted);
}
.presets{ display: inline-flex; gap: 6px; flex-wrap: wrap; }
.preset{
  font-family: var(--font-display); font-size: 0.7rem; font-weight: 700;
  padding: 6px 12px; border: 1.5px solid var(--line-strong); border-radius: var(--radius-pill);
  background: transparent; color: var(--muted); cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}
.preset:hover{ color: #fff; background: var(--accent); border-color: var(--accent); }
.preset:focus-visible{ outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

.opts{ list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.opt{ display: flex; align-items: center; gap: 9px; }
.opt__dot{ flex: 0 0 auto; width: 13px; height: 13px; border-radius: 50%; box-shadow: inset 0 -2px 3px rgba(0,0,0,0.22); }
.opt__in{
  flex: 1 1 auto; min-width: 0;
  font-family: var(--font-sans); font-size: 0.95rem; color: var(--ink);
  padding: 10px 12px; border: 1.5px solid var(--line-strong); border-radius: 11px;
  background: var(--surface-2);
}
.opt__in:focus{ outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.opt__del{
  flex: 0 0 auto; width: 32px; height: 32px; display: grid; place-items: center;
  font-size: 1rem; line-height: 1; color: var(--muted);
  border: 1.5px solid transparent; border-radius: 50%; background: transparent; cursor: pointer;
  transition: color 140ms ease, background 140ms ease;
}
.opt__del:hover{ color: #d8433a; background: var(--surface-2); }
.opt__del:focus-visible{ outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.opt__del[disabled]{ opacity: 0.3; cursor: not-allowed; }

.editor__foot{ display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.count{
  font-family: var(--font-display); font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
}

.backlink{
  font-family: var(--font-display); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
  text-decoration: none; border-bottom: 1px solid transparent;
  transition: color 140ms ease, border-color 140ms ease;
}
.backlink:hover{ color: var(--ink); border-bottom-color: var(--accent); }

/* the tip jar's right-centre default lands on the wheel; tuck it low-right */
.opt-tipjar.opt-tipjar{ top: auto; bottom: max(14px, env(safe-area-inset-bottom)); transform: none; }
.opt-fs.opt-fs{ top: auto; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 54px); transform: none; }
.opt-tipjar.opt-tipjar.tj-nudge{ animation: none; }

@media (prefers-reduced-motion: reduce){
  .btn, .iconbtn, .preset{ transition: none; }
  .verdict.is-pop{ animation: none; }
}
