/* Crate Chance Calculator (crate-calculator.html). Loaded after tools.css; uses the site tokens. */

.cc-tool {
  --cc-surface: var(--white);
  --cc-bar: #2a78d6;
  --cc-ink: var(--on-paper);
  --cc-grid: rgba(23, 18, 18, 0.12);
}
@media (prefers-color-scheme: dark) {
  .cc-tool { --cc-surface: #1d1718; --cc-bar: #3987e5; --cc-grid: rgba(245, 240, 236, 0.12); }
}

.cc-grow { flex: 3 1 220px !important; }
.cc-idf { flex: 1 1 130px !important; }
.cc-curf { flex: 0 1 110px !important; }
.cc-seedf { flex: 1 1 120px !important; }
.cc-nf { max-width: 240px; }
.cc-modef { margin-top: 14px; }
.cc-modef .thint { margin-top: 6px; }
.cc-actions { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--rule-paper); align-items: center; }
.tool .cc-tplf select { width: auto; padding: 6px 10px; font-size: 0.84rem; }
.cc-check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.88rem; font-weight: 600; cursor: pointer; padding: 6px 0; }
.cc-check input { width: 18px; height: 18px; accent-color: var(--red-500); }
.cc-namebox { margin: 8px 0 14px; }
.cc-tool .tf > .seg, .cc-modef > .seg { align-self: flex-start; max-width: 100%; }

/* coloured names (the game colours are exact; the font is ours) */
.cc-chip {
  display: inline-block; max-width: 100%;
  padding: 1px 6px; background: #1b1416; color: #fff;
  font-family: var(--mono); font-size: 0.8rem; font-weight: 600; line-height: 1.45;
  text-shadow: 0.1em 0.1em 0 rgba(0, 0, 0, 0.6);
  overflow: hidden; text-overflow: ellipsis; white-space: pre; vertical-align: middle;
}
.cc-chip.big { font-size: 1rem; padding: 4px 10px; }
.cc-chip .b, .cc-tip .b { font-weight: 800; }
.cc-chip .i, .cc-tip .i { font-style: italic; }
.cc-chip .u, .cc-tip .u { text-decoration: underline; }
.cc-chip .s, .cc-tip .s { text-decoration: line-through; }
.cc-chip .u.s, .cc-tip .u.s { text-decoration: underline line-through; }

/* rarities */
.cc-rars { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.cc-rar { display: flex; align-items: center; gap: 8px; }
.tool .cc-rar input[type="text"] { flex: 1 1 120px; min-width: 0; font-family: var(--mono); font-size: 0.86rem; }
.tool .cc-rar input.cc-num { flex: 0 1 90px; }
.cc-wlabel { font-size: 0.78rem; color: var(--on-paper-soft); }
.cc-rar .tbtn { flex: none; padding: 6px 10px; }

/* rewards */
.cc-rws { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
.cc-rw { padding: 12px; box-shadow: inset 0 0 0 1px var(--rule-paper); min-width: 0; }
.cc-rw-top { display: flex; align-items: flex-end; gap: 6px; }
.cc-rw-top .tf { margin-bottom: 0; }
.cc-rw-top .tbtn { flex: none; padding: 9px 10px; }
.tool .cc-rw input[type="text"], .tool .cc-rw input[type="number"], .tool .cc-rw select { padding: 7px 9px; font-size: 0.88rem; }
.cc-rw-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.cc-rw-grid > .tf { grid-column: span 2; }
.cc-rw-grid > .cc-mat { grid-column: span 4; }
.cc-rw-grid .tf { margin-bottom: 0; }
.cc-rw-grid .tf > span { font-size: 0.76rem; }
.cc-matnote { font-family: var(--mono); font-weight: 400; color: var(--on-paper-soft); }
.cc-matnote.warn { color: #b07800; }
@media (prefers-color-scheme: dark) { .cc-matnote.warn { color: #f0b429; } }
.cc-more { margin-top: 10px; }
.cc-more > summary { cursor: pointer; font-size: 0.86rem; font-weight: 700; padding: 4px 0; }
.cc-more > summary:focus-visible { outline: 2px solid var(--red-400); outline-offset: 2px; }
.cc-more-body { padding-top: 8px; }
.cc-more-body .trow { margin: 0 0 12px; align-items: center; }
.cc-iconhost { flex: none; align-self: flex-end; }

/* item icon: our own drawing */
.cc-ibox { position: relative; display: inline-block; flex: none; width: 38px; height: 38px; background: #8b8b8b; box-shadow: inset 1px 1px 0 #373737, inset -1px -1px 0 #fff; vertical-align: middle; }
.cc-ico {
  --c: #888;
  position: absolute; inset: 15%;
  display: grid; place-items: center;
  color: #fff; font-family: var(--mono); font-size: 10px; font-weight: 800; line-height: 1; letter-spacing: -0.04em;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.55);
  background: linear-gradient(145deg, color-mix(in srgb, var(--c) 70%, #fff), var(--c) 55%, color-mix(in srgb, var(--c) 70%, #000));
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}
.cc-ico.block { inset: 13%; background: var(--c); box-shadow: inset 3px 3px 0 rgba(255, 255, 255, 0.3), inset -3px -3px 0 rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.5); }
.cc-ico.gem { inset: 10%; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); box-shadow: none; }
.cc-ico.round { border-radius: 50%; }
.cc-ico.tool { clip-path: polygon(0 26%, 26% 0, 100% 0, 100% 74%, 74% 100%, 0 100%); box-shadow: none; }
.cc-ico.armor { clip-path: polygon(0 0, 100% 0, 100% 58%, 50% 100%, 0 58%); box-shadow: none; padding-bottom: 14%; }

/* tooltip like the game's (colours exact, font ours) */
.cc-tiphost { margin-top: 6px; }
.cc-tip {
  display: inline-block; max-width: 100%;
  padding: 5px 9px 6px;
  background: rgba(16, 0, 16, 0.96);
  border: 2px solid #3b0a8f;
  border-image: linear-gradient(#5b14e6, #28007f) 1;
  color: #fff; font-family: var(--mono); font-size: 0.84rem; font-weight: 600; line-height: 1.38;
  text-shadow: 0.12em 0.12em 0 rgba(0, 0, 0, 0.55);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.cc-tname { margin-bottom: 3px; }
.cc-tl { min-height: 1.38em; color: #aaa; }
.cc-tid { margin-top: 3px; color: #6c6c6c; font-size: 0.78em; }

/* results */
.cc-tiles { margin-top: 0; }
.cc-tiles .tile strong { font-size: 1.45rem; overflow-wrap: anywhere; }
.tile.good { box-shadow: inset 3px 0 0 #1d7a46, inset 0 0 0 1px var(--rule-paper); }
.tile.bad { box-shadow: inset 3px 0 0 var(--red-500), inset 0 0 0 1px var(--rule-paper); }
.cc-warn { margin-top: 12px; }
.cc-warn .note + .note { margin-top: 6px; }
.cc-warn:empty { display: none; }
.cc-h3 { margin: 18px 0 8px; font-size: 0.95rem; font-weight: 800; }
.cc-rbar { display: flex; gap: 2px; height: 28px; }
.cc-seg { position: relative; display: flex; align-items: center; min-width: 3px; border-radius: 4px; overflow: visible; cursor: default; }
.cc-seg:focus-visible { outline: 2px solid var(--on-paper); outline-offset: 2px; }
.cc-seglab { padding-left: 7px; font-family: var(--mono); font-size: 0.74rem; font-weight: 700; white-space: nowrap; }
.cc-legend { display: flex; flex-wrap: wrap; gap: 4px 0; margin: 8px 0 0; font-size: 0.84rem; color: var(--on-paper-soft); }
.cc-legend .key i { border-radius: 2px; }
.cc-scroll { overflow-x: auto; margin-top: 16px; }
.cc-scroll .ttable { min-width: 420px; }
.cc-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cc-cell .cc-ibox { width: 28px; height: 28px; }
.cc-cell .cc-ico { font-size: 8px; }
.cc-cell > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.cc-rlab { font-size: 0.74rem; }
#odds .meter { width: 80px; margin-left: auto; }
#odds .meter i { background: var(--cc-bar); }
#ntable td:first-child, #odds td:first-child { max-width: 220px; }

/* simulation chart: bar = simulated share, tick = expected share */
.cc-simout { margin-top: 14px; }
.cc-simout:empty { display: none; }
.cc-simout .tiles { margin-top: 0; }
.cc-chart { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.cc-crow { display: grid; grid-template-columns: minmax(0, 9rem) minmax(0, 1fr) 4.2rem; align-items: center; gap: 10px; padding: 3px 0; }
.cc-crow:focus-visible { outline: 2px solid var(--red-400); outline-offset: 2px; }
.cc-clab { font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-cval { font-family: var(--mono); font-size: 0.78rem; text-align: right; font-variant-numeric: tabular-nums; color: var(--on-paper-soft); }
.cc-track { position: relative; height: 16px; border-left: 1px solid var(--cc-grid); }
.cc-bar { position: absolute; left: 0; top: 0; bottom: 0; min-width: 1px; background: var(--cc-bar); border-radius: 0 4px 4px 0; }
.cc-tick { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--cc-ink); border-radius: 1px; box-shadow: 0 0 0 2px var(--cc-surface); }
.cc-kbar { width: 14px !important; height: 10px !important; background: var(--cc-bar); border-radius: 0 3px 3px 0; }
.cc-ktick { width: 2px !important; height: 14px !important; background: var(--cc-ink); }
.cc-simtable { margin-top: 8px; }
.cc-off { color: var(--accent); font-weight: 700; }

.cc-vtip {
  position: fixed; z-index: 70; max-width: min(300px, calc(100vw - 16px));
  padding: 7px 10px; background: var(--ink); color: #fff;
  font-size: 0.8rem; line-height: 1.4; white-space: pre-line; pointer-events: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.cc-vtip[hidden] { display: none; }
@media (prefers-color-scheme: dark) { .cc-vtip { background: #f5f0ec; color: #171212; } }

/* outputs and import */
.tgrid.cc-io { margin-top: clamp(16px, 2.5vw, 32px); grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr); }
#outtab { margin-bottom: 12px; }
.cc-outbody > .thint:first-child { margin-top: 0; }
.cc-outbody .note, .cc-outbody .out, .cc-outbody .thint { margin-top: 10px; }
.cc-outbody .trow { margin-top: 0; }
.tool textarea.cc-imp { min-height: 240px; white-space: pre; overflow: auto; tab-size: 2; }
.cc-impres { margin-top: 12px; }
.cc-impres .note + .note { margin-top: 6px; }

@media (max-width: 900px) {
  .tgrid.cc-io { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 620px) {
  .cc-rw-grid > .tf { grid-column: span 3; }
  .cc-rw-grid > .cc-mat { grid-column: 1 / -1; }
  .cc-rw-top { flex-wrap: wrap; }
  .cc-rw-top .cc-grow { flex: 1 1 100% !important; order: 2; }
  .cc-rw-top .cc-iconhost { margin-right: auto; }
  .cc-crow { grid-template-columns: minmax(0, 6rem) minmax(0, 1fr) 3.6rem; gap: 8px; }
  .cc-rar { flex-wrap: wrap; }
}
