/* ==========================================================================
   Mapwright Design System — Dice Widget & Dice Tray
   ========================================================================== */

/* Floating Dice Widget (Virtual TTG Style) */
.dicew {
  position: fixed;
  right: 64px;
  bottom: 12px;
  z-index: 11;
  width: 340px;
  max-width: calc(100vw - 84px);
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease;
}

.dicew .dicebox {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.dicetray {
  pointer-events: auto;
  position: relative;
  z-index: 12;
  width: 100%;
  max-height: min(44vh, 360px);
  overflow-y: auto;
  padding: 10px;
  border-radius: var(--r-panel, 10px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel2);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  box-shadow: var(--hud-shadow);
  animation: traySlide 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes traySlide {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.dice-chips-row {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.die-chip {
  flex: 1;
  height: 26px;
  padding: 0;
  border-radius: var(--r-sm, 5px);
  background: var(--panel);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.die-chip:hover {
  background: var(--panel2);
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.die-chip.d20 {
  color: var(--accent);
  font-weight: 800;
}

.die-chip.dm-secret-chip {
  flex: 0 0 auto;
  padding: 0 7px;
  background: color-mix(in srgb, var(--brass) 15%, transparent);
  border-color: color-mix(in srgb, var(--brass) 40%, transparent);
  color: var(--brass);
  font-weight: 800;
  letter-spacing: 0.3px;
}

.die-chip.dm-secret-chip:hover {
  background: var(--brass);
  color: #090d14;
  border-color: var(--brass);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px var(--brass-glow);
}

.die-chip.fold-btn {
  flex: 0 0 28px;
  font-size: 13px;
}

.die-chip.fold-btn.active {
  background: var(--brass);
  color: #090d14;
  border-color: var(--brass);
}

.dice-input-capsule {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel2);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: var(--r-panel, 10px);
  padding: 4px 6px;
  box-shadow: var(--hud-shadow);
}

.dice-expr-inp {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 4px 6px;
}

.dice-expr-inp::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.dice-adv-sel {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm, 5px);
  color: var(--fg);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 6px;
  outline: none;
  cursor: pointer;
}

.dice-send-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm, 5px);
  background: var(--brass);
  color: #090d14;
  border: 0;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 700;
}

.dice-send-btn:hover {
  filter: brightness(1.12);
  transform: scale(1.05);
}

.dicebar .dtoggle .car {
  font-style: normal;
  display: inline-block;
  transition: transform .15s;
}

.dicebar .dtoggle[aria-expanded="true"] .car {
  transform: rotate(180deg);
}

.dh {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dh .dt {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 21px;
  margin-right: auto;
  letter-spacing: .02em;
}

.dh .fold {
  margin-right: auto;
}

.dh .lastr {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.dice {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.die {
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: 8px;
  padding: 8px 0;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
}

.die:hover {
  border-color: var(--accent);
}

.die.d20 {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.dctl {
  display: flex;
  gap: 8px;
  align-items: center;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stepper output {
  min-width: 34px;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 600;
}

.dform {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
  gap: 6px;
}

.inp.sm {
  padding: 4px 7px;
  font-size: 13px;
}

.seg.sm button {
  padding: 3px 8px;
  font-size: 11px;
}

.big {
  display: flex;
  align-items: center;
  gap: 6px 12px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel2);
  min-height: 52px;
}

.big .tot {
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1;
}

.big.crit {
  border-color: var(--accent);
}

.big.crit .tot {
  color: var(--accent);
}

.big.fumble {
  border-color: var(--danger);
}

.big.fumble .tot {
  color: var(--danger);
}

.big .info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.rolls {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
}

.roll {
  border: 1px solid var(--line);
  border-radius: var(--r-sm, 5px);
  padding: 6px 8px;
  background: var(--panel2);
  font-size: 13px;
}

.roll.secret {
  border-style: dashed;
  border-color: var(--brass);
}

.roll .rh {
  display: flex;
  gap: 6px;
  align-items: baseline;
  flex-wrap: wrap;
}

.roll .rh time {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.roll .rb {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 3px;
}

.roll .tot {
  margin-left: auto;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 18px;
}

.vals {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.d {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  background: var(--bg);
}

.d.hi {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.d.lo {
  border-color: var(--danger);
  color: var(--danger);
  font-weight: 700;
}

.d.drop {
  text-decoration: line-through;
  opacity: .5;
}

.logh {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.logh .btn {
  margin-left: auto;
  text-transform: none;
  letter-spacing: 0;
}

.dicebox {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.rbadge {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 6px;
  padding: 1px 6px;
}

.rbadge.w {
  background: transparent;
  color: var(--brass);
  border: 1px dashed var(--brass);
}

.app.sideopen .dicew {
  transform: translateY(-110vh);
  opacity: 0;
  pointer-events: none;
}

/* Responsive Media Queries for Dice */
@media (max-width: 940px) {
  .dicew {
    right: 8px;
    bottom: 8px;
  }
  .dicetray {
    width: min(300px, calc(100vw - 16px));
  }
}
