/* GoRoll web demo — values mirror ~/goroll/lib (see NOTES.md) */
@font-face { font-family: "Quicksand"; font-weight: 500; font-style: normal; font-display: swap; src: url("assets/fonts/Quicksand-500.ttf") format("truetype"); }
@font-face { font-family: "Quicksand"; font-weight: 700; font-style: normal; font-display: swap; src: url("assets/fonts/Quicksand-700.ttf") format("truetype"); }
@font-face { font-family: "Plus Jakarta Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("assets/fonts/PlusJakartaSans-400.ttf") format("truetype"); }
@font-face { font-family: "Plus Jakarta Sans"; font-weight: 500; font-style: normal; font-display: swap; src: url("assets/fonts/PlusJakartaSans-500.ttf") format("truetype"); }
@font-face { font-family: "Plus Jakarta Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url("assets/fonts/PlusJakartaSans-600.ttf") format("truetype"); }
@font-face { font-family: "Plus Jakarta Sans"; font-weight: 700; font-style: normal; font-display: swap; src: url("assets/fonts/PlusJakartaSans-700.ttf") format("truetype"); }
:root {
  --s: 1;                 /* chrome scale, set from JS (min 0.77 keeps 52px buttons >= 40px) */
  --hair: 1px;            /* 1 physical pixel */
  --p: 20px;              /* pip size  = max(5, tileMin * 0.085) */
  --min: 200px;           /* tile min dimension */
  --quick: "Quicksand", ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --jak: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease-io: cubic-bezier(0.42, 0, 0.58, 1); /* Curves.easeInOut */
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { background: #BCD9F2; font-family: var(--quick); }
button { font: inherit; color: inherit; border: 0; padding: 0; margin: 0; background: none; cursor: pointer; }

#app {
  position: relative; width: 100%; height: 100%; overflow: hidden;
  user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
#app * { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

:focus { outline: none; }
:focus-visible { outline: 2px solid #1A1A1A; outline-offset: 2px; }
#grid:focus-visible { outline-offset: -4px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ── Dice grid ─────────────────────────────────────────── */
#grid { position: absolute; inset: 0; display: flex; flex-direction: column; gap: var(--hair); cursor: pointer; }
.g-row { flex: 1 1 0; min-height: 0; display: flex; gap: var(--hair); }
.tile { flex: 1 1 0; min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.face { display: flex; align-items: center; justify-content: center; will-change: transform; }

.pipface { position: relative; width: calc(var(--p) * 4.6); height: calc(var(--p) * 4.6); }
.pip {
  position: absolute; width: var(--p); height: var(--p); border-radius: 50%;
  background: #0A0A0A;
}
/* faceSize 4.6p, gap .55p -> cell 1.16667p, offset .08333p, stride 1.71667p */
.pipface .pip {
  left: calc(var(--p) * (0.083333 + var(--c) * 1.716667));
  top:  calc(var(--p) * (0.083333 + var(--r) * 1.716667));
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}
.spin { position: relative; width: calc(var(--p) * 5); height: calc(var(--p) * 5); will-change: transform; }
.spin .pip {
  left: calc(var(--p) * var(--x));
  top:  calc(var(--p) * var(--y));
}
.num {
  font-family: var(--quick); font-weight: 700; color: #0A0A0A; line-height: 1;
  font-size: calc(var(--min) * var(--f)); letter-spacing: -0.04em; white-space: nowrap;
}

/* ── Glass surface (glass_surface.dart, light variant) ─── */
.glass {
  background: rgba(255, 255, 255, 0.42);
  border: 0.5px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 10px 28px rgba(0, 0, 0, 0.10);
  -webkit-backdrop-filter: blur(22px); backdrop-filter: blur(22px);
}

/* ── Total pill ────────────────────────────────────────── */
#total {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(132px * var(--s)); height: calc(36px * var(--s));
  border-radius: calc(20px * var(--s)); padding: 0 calc(16px * var(--s));
  display: flex; align-items: center; gap: calc(8px * var(--s));
  font-size: calc(14px * var(--s)); pointer-events: none; white-space: nowrap;
}
#total[hidden] { display: none; }
.t-label { font-weight: 500; color: rgba(26, 26, 26, 0.6); }
.t-val { font-weight: 700; color: #1A1A1A; }

/* ── Bottom bar ────────────────────────────────────────── */
#bar {
  position: absolute; left: calc(14px * var(--s)); right: calc(14px * var(--s));
  bottom: calc(46px * var(--s)); height: calc(70px * var(--s));
  border-radius: calc(36px * var(--s));
  display: flex; align-items: center; padding: 0 calc(14px * var(--s));
  color: #1A1A1A;
  transition: opacity 350ms var(--ease-io);
}
.bar-btn {
  flex: none; width: calc(52px * var(--s)); height: calc(52px * var(--s)); border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  box-shadow: 0 0.5px 0 rgba(255, 255, 255, 0.9), 0 1px 1px rgba(0, 0, 0, 0.04);
  display: flex; align-items: center; justify-content: center;
  transition: transform 120ms linear;
}
.bar-btn svg { width: calc(24px * var(--s)); height: calc(24px * var(--s)); }
.bar-btn-gear { margin-left: calc(8px * var(--s)); }
.bar-btn-gear svg { width: calc(22px * var(--s)); height: calc(22px * var(--s)); }
.bar-btn.pressed { transform: scale(0.92); }
.bar-btn[aria-disabled="true"] svg { opacity: 0.32; }
.bar-btn[aria-disabled="true"] { cursor: default; }
#count { flex: 1; text-align: center; font-weight: 700; font-size: calc(24px * var(--s)); color: #1A1A1A; }

/* ── Demo chrome (reset / mute / hint) ─────────────────── */
.chip-btn {
  position: absolute; top: 10px; width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: #1A1A1A;
  background: rgba(255, 255, 255, 0.42);
  border: 0.5px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 6px 16px rgba(0, 0, 0, 0.08);
  -webkit-backdrop-filter: blur(22px); backdrop-filter: blur(22px);
  transition: transform 120ms linear;
}
.chip-btn:active { transform: scale(0.92); }
#resetBtn { left: 10px; }
#muteBtn { right: 10px; }
#muteBtn .ic-off { display: none; }
#muteBtn[aria-pressed="true"] .ic-on { display: none; }
#muteBtn[aria-pressed="true"] .ic-off { display: block; }
#hint {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  max-width: calc(100% - 116px); height: 28px; padding: 0 10px; border-radius: 14px;
  display: flex; align-items: center; white-space: nowrap; overflow: hidden;
  font-weight: 700; font-size: clamp(10.5px, calc(13px * var(--s)), 13px); color: rgba(26, 26, 26, 0.7);
  background: rgba(255, 255, 255, 0.42);
  pointer-events: none; transition: opacity 300ms ease;
}
#hint.gone { opacity: 0; }

/* ── Settings drawer ───────────────────────────────────── */
#backdrop {
  position: absolute; inset: 0; background: rgba(0, 0, 0, 0.32);
  opacity: 0; pointer-events: none; transition: opacity 220ms linear;
}
#app.drawer-open #backdrop { opacity: 1; pointer-events: auto; }
#drawer {
  --surface: #FBFAF7; --head: rgba(0, 0, 0, 0.025); --div: rgba(0, 0, 0, 0.06);
  --fg: #1A1A1A; --sub: rgba(0, 0, 0, 0.5); --ctl: rgba(0, 0, 0, 0.045);
  --close: rgba(0, 0, 0, 0.06); --tog-off: rgba(120, 120, 128, 0.32);
  position: absolute; top: 0; bottom: 0; right: 0;
  width: min(100%, max(84%, 272px));
  background: var(--surface); color: var(--fg);
  border-radius: 28px 0 0 28px;
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.18);
  display: flex; flex-direction: column; overflow: hidden;
  font-family: var(--jak);
  transform: translateX(105%); visibility: hidden;
  transition: transform 320ms var(--ease-io), visibility 0s linear 320ms;
}
#app.drawer-open #drawer { transform: none; visibility: visible; transition: transform 320ms var(--ease-io), visibility 0s; }
#app.dark #drawer {
  --surface: #1A1A1C; --head: rgba(255, 255, 255, 0.04); --div: rgba(255, 255, 255, 0.08);
  --fg: #FFFFFF; --sub: rgba(255, 255, 255, 0.55); --ctl: rgba(255, 255, 255, 0.08);
  --close: rgba(255, 255, 255, 0.1); --tog-off: rgba(255, 255, 255, 0.18);
}
#app.dark #drawer :focus-visible { outline-color: #FFFFFF; }
.d-head {
  flex: none; display: flex; align-items: flex-end; gap: 8px;
  padding: 18px 20px; background: var(--head); border-bottom: 0.5px solid var(--div);
}
.d-head-text { flex: 1; min-width: 0; }
.d-head h1 { margin: 0; font-weight: 700; font-size: 26px; letter-spacing: -0.4px; line-height: 1.25; }
.d-head p { margin: 2px 0 0; font-weight: 500; font-size: 13px; color: var(--sub); line-height: 1.3; }
.d-close {
  position: relative; flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--close);
  display: flex; align-items: center; justify-content: center; color: var(--fg);
}
.d-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 24px; -webkit-overflow-scrolling: touch; }
#app #drawer .d-body, #app #drawer .d-body * { touch-action: pan-y; }
.row { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 0.5px solid var(--div); }
.row-text { flex: 1; min-width: 0; }
.row-label { font-weight: 600; font-size: 15px; line-height: 1.3; }
.row-sub { margin-top: 2px; font-weight: 400; font-size: 12px; color: var(--sub); line-height: 1.3; }
.stepper { flex: none; display: flex; align-items: center; }
.step {
  position: relative; width: 32px; height: 32px; border-radius: 50%; background: var(--ctl);
  display: flex; align-items: center; justify-content: center; color: var(--fg);
}
.step[aria-disabled="true"] { opacity: 0.35; cursor: default; }
.step-val { width: 44px; text-align: center; font-weight: 600; font-size: 16px; }
/* enlarge hit areas to >= 40px without changing the real visual sizes */
.step::before, .d-close::before, .toggle::before { content: ""; position: absolute; inset: -6px; border-radius: 999px; }
.appearance { padding: 14px 20px 20px; border-bottom: 0.5px solid var(--div); }
#swatches { margin-top: 14px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.swatch {
  aspect-ratio: 1; width: 100%; border-radius: 50%;
  border: 0.5px solid rgba(0, 0, 0, 0.06);
  transition: border-color 150ms linear, box-shadow 150ms linear;
}
.swatch[aria-pressed="true"] { border: 2px solid var(--fg); box-shadow: 0 0 0 2px var(--sw); }
.toggle {
  position: relative; flex: none; width: 46px; height: 28px; border-radius: 14px; padding: 2px;
  background: var(--tog-off); transition: background-color 180ms linear;
}
.toggle span {
  display: block; width: 24px; height: 24px; border-radius: 50%; background: #FFFFFF;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); transition: transform 180ms linear;
}
.toggle[aria-checked="true"] { background: #65B377; }
.toggle[aria-checked="true"] span { transform: translateX(18px); }

@media (prefers-reduced-motion: reduce) {
  #drawer, #app.drawer-open #drawer, #backdrop, #bar, .toggle, .toggle span, .bar-btn, .chip-btn, #hint { transition-duration: 0.01ms; }
}
