/* ==========================================================================
   Wam's Gem Creation Tool
   All selectors scoped to .wam-gemtool-app
   ========================================================================== */

.wam-gemtool-app{
  --wam-gap: 24px;
  --wam-radius: 18px;
  --wam-top-panels-height: clamp(360px, 62vh, 560px);

  /* Panel colors */
  --wam-effects-head: #0b4f6b;
  --wam-effects-body: #0aa4ff;

  --wam-selected-head: #7b1a1a;
  --wam-selected-body: #b62a2a;

  --wam-details-head: #1a2aa7;
  --wam-details-body: #2b36c9;

  --wam-preview-head: #0b6d62;
  --wam-preview-body: #2bbfa7;

  --wam-summary-head: #8b6e00;
  --wam-summary-body: #b99600;

  --wam-panel-border: rgba(0,0,0,.18);
  --wam-shadow: 0 12px 28px rgba(0,0,0,.25);
  --wam-text: rgba(255,255,255,.95);
  --wam-text-soft: rgba(255,255,255,.78);

  --wam-yellow: #ffd44d;
  --wam-line: rgba(0,0,0,.16);

  --wam-add: #1b7d2b;
  --wam-check: #d49000;
  --wam-x: #7f8c8d;

  padding: 20px;
  background: #585858;
  border-radius: 22px;
}

.wam-gemtool-app *{ box-sizing:border-box; }
.wam-gemtool-app button{ font-family:inherit; }

/* Grid layout */
.wam-gemtool-grid{
  display:grid;
  grid-template-columns: 1.05fr 1.35fr 0.9fr;
  grid-template-areas:
    "effects selected summary"
    "details preview summary";
  gap: var(--wam-gap);
}

@media (max-width: 1100px){
  .wam-gemtool-grid{
    grid-template-columns: 1fr;
    grid-template-areas:
      "effects"
      "selected"
      "summary"
      "details"
      "preview";
  }

  .wam-panel--effects,
  .wam-panel--selected{
    height: auto;
    max-height: 520px;
  }
}

/* Panel shell */
.wam-panel{
  border-radius: var(--wam-radius);
  box-shadow: var(--wam-shadow);
  overflow:hidden;
  border: 1px solid var(--wam-panel-border);
  color: var(--wam-text);
  min-height: 280px;
}

.wam-panel__head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--wam-line);
}

.wam-panel__title{
  margin:0;
  font-size: 20px;
  line-height: 1.1;
  letter-spacing: .3px;
}

.wam-panel__body{ padding: 14px 18px 18px; }

.wam-panel__legend{
  display:flex;
  gap: 10px;
  flex-wrap:wrap;
  font-size: 12px;
  color: rgba(255,255,255,.85);
}

.wam-legend-item{ display:flex; align-items:center; gap: 6px; white-space:nowrap; }

.wam-gem-slots{
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.wam-gem-slotbar{
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.wam-gem-clear{
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 0;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: #7f8c8d;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,.2);
}

.wam-gem-slot{
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 6px;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.18), 0 4px 10px rgba(0,0,0,.25);
  background-size: 100% 100%;
}

.wam-gem-slot.is-active{
  transform: translateY(-1px);
  box-shadow: 0 0 0 2px rgba(255,255,255,.85), inset 0 0 0 1px rgba(0,0,0,.24), 0 6px 12px rgba(0,0,0,.3);
}

.wam-gem-slot--common{
  background: linear-gradient(135deg, #d7d7d7 0 35%, #969696 35% 70%, #575757 70% 100%);
}
.wam-gem-slot--uncommon{
  background: linear-gradient(135deg, #8de27e 0 35%, #4cbf46 35% 70%, #2f8f38 70% 100%);
}
.wam-gem-slot--rare{
  background: linear-gradient(135deg, #79d8ff 0 35%, #1d98e8 35% 70%, #0d68b8 70% 100%);
}
.wam-gem-slot--very_rare{
  background: linear-gradient(135deg, #ba98ff 0 35%, #7e4ee8 35% 70%, #5b2fbf 70% 100%);
}
.wam-gem-slot--legendary{
  background: linear-gradient(135deg, #ffd56f 0 35%, #ff9b2f 35% 70%, #db7014 70% 100%);
}
.wam-gem-slot--artifact{
  background: linear-gradient(135deg, #d9b284 0 35%, #b88855 35% 70%, #91643a 70% 100%);
}

.wam-legend-item[data-wam-tooltip],
.wam-gem-clear[data-wam-tooltip],
.wam-gem-slot[data-wam-tooltip],
.wam-override-icon[data-wam-tooltip],
.wam-activation-badge[data-wam-tooltip],
.wam-effect-type[data-wam-tooltip]{
  cursor: help;
}

.wam-icon{
  width: 16px;
  height: 16px;
  border-radius: 4px;
  display:inline-grid;
  place-items:center;
  font-weight: 800;
  line-height: 1;
  font-size: 12px;
  color: #fff;
}
.wam-icon--add{ background: var(--wam-add); }
.wam-icon--check{ background: var(--wam-check); }
.wam-icon--x{ background: var(--wam-x); }

/* Panel areas + colors */
.wam-panel--effects{ grid-area: effects; background: var(--wam-effects-body); }
.wam-panel--effects > .wam-panel__head{ background: var(--wam-effects-head); }

.wam-panel--selected{ grid-area: selected; background: var(--wam-selected-body); }
.wam-panel--selected > .wam-panel__head{ background: var(--wam-selected-head); }

.wam-panel--summary{ grid-area: summary; background: var(--wam-summary-body); }
.wam-panel--summary > .wam-panel__head{ background: var(--wam-summary-head); }

.wam-panel--details{ grid-area: details; background: var(--wam-details-body); }
.wam-panel--details > .wam-panel__head{ background: var(--wam-details-head); }

.wam-panel--preview{ grid-area: preview; background: var(--wam-preview-body); }
.wam-panel--preview > .wam-panel__head{ background: var(--wam-preview-head); }

/* Keep Effect Type height synced with Selected Effects (same grid row),
   while allowing Effect Type list to scroll inside the matched height. */
.wam-panel--effects,
.wam-panel--selected{
  display: flex;
  flex-direction: column;
  height: var(--wam-top-panels-height);
  max-height: var(--wam-top-panels-height);
}

.wam-panel--effects > .wam-panel__body{
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

.wam-panel--effects > .wam-panel__body > .wam-scrollarea{
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

.wam-panel--selected > .wam-panel__body{
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.wam-panel--selected > .wam-panel__body::-webkit-scrollbar{ width: 10px; }
.wam-panel--selected > .wam-panel__body::-webkit-scrollbar-thumb{ background: rgba(0,0,0,.28); border-radius: 999px; }
.wam-panel--selected > .wam-panel__body::-webkit-scrollbar-track{ background: rgba(0,0,0,.12); border-radius: 999px; }

/* Scrollable areas */
.wam-scrollarea{
  max-height: 360px;
  overflow:auto;
  padding-right: 6px;
}
.wam-scrollarea::-webkit-scrollbar{ width: 10px; }
.wam-scrollarea::-webkit-scrollbar-thumb{ background: rgba(0,0,0,.28); border-radius: 999px; }
.wam-scrollarea::-webkit-scrollbar-track{ background: rgba(0,0,0,.12); border-radius: 999px; }

/* Effect list */
.wam-effects{ display:flex; flex-direction:column; gap: 8px; }

.wam-effect{
  display:grid;
  grid-template-columns: 1fr auto;
  align-items:center;
  gap: 12px;
  padding: 10px 10px 10px 12px;
  background: rgba(0,0,0,.10);
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.10);
}

.wam-effect:hover{ background: rgba(0,0,0,.14); border-color: rgba(0,0,0,.16); }

.wam-effect__name{ min-width:0; cursor: default; }

.wam-effect__title{
  font-weight: 900;
  letter-spacing: .2px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  display:flex;
  align-items:center;
  gap: 8px;
}

.wam-activation-badge{
  display:inline-flex;
  align-items:center;
  border-radius: 999px;
  padding: 2px 10px 3px;
  font-size: 14px;
  line-height: 1;
  font-weight: 700;
  white-space:nowrap;
}

/* Badge colors are contextual by panel, not by Active/Passive state. */
.wam-panel--effects .wam-activation-badge{
  color: #1284df;
  background: #e6f4ff;
}
.wam-panel--selected .wam-activation-badge{
  color: #a7322c;
  background: #f7f4f4;
}

.wam-effect-type{
  font-weight: 800;
  font-size: 14px;
  margin-top: 2px;
  white-space:nowrap;
}

.wam-effect-type--martial{ color: #ff6b6b; }
.wam-effect-type--metaphysical{ color: #0d2b80; }
.wam-effect-type--synchronous{ color: #8a5de8; }
.wam-effect-type--override{ color: #ffd7a3; }

.wam-effect--override{
  background: #e77700;
  border-color: #f4a23f;
}
.wam-effect--override:hover{
  background: #f08300;
  border-color: #ffc46e;
}

.wam-override-icon{
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1;
  color: #fff;
  background: #ff9a2f;
  border: 1px solid rgba(255,255,255,.55);
}

.wam-effect-gp{
  font-weight: 900;
  color: var(--wam-yellow);
  white-space:nowrap;
  font-size: 12px;
  margin-top: 3px;
}

/* Small icon button */
.wam-iconbtn{
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 0;
  display:grid;
  place-items:center;
  color:#fff;
  font-weight: 900;
  line-height: 1;
  cursor:pointer;
  box-shadow: 0 6px 14px rgba(0,0,0,.18);
}
.wam-iconbtn:disabled{ cursor:not-allowed; opacity:.75; }
.wam-iconbtn:focus{ outline: 2px solid rgba(255,255,255,.7); outline-offset: 2px; }

/* Selected */
.wam-selected{ display:flex; flex-direction:column; gap: 10px; }
.wam-empty{ opacity:.9; padding: 8px 4px; font-weight: 600; }

.wam-sel{
  background: rgba(0,0,0,.10);
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 14px;
  padding: 12px;
}

.wam-sel--override{
  background: #e77700;
  border-color: #f4a23f;
}

.wam-sel__head{
  display:grid;
  grid-template-columns: 1fr auto;
  align-items:center;
  gap: 10px;
  margin-bottom: 10px;
}

.wam-sel__title{
  font-weight: 900;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  display:flex;
  align-items:center;
  gap: 8px;
}

.wam-sel__opts{ display:flex; flex-direction:column; gap: 10px; }
.wam-sel__footer{ display:flex; justify-content:flex-end; margin-top: 10px; }

/* Conditional option rows animate open/close for show_when logic. */
.wam-optrow{
  transition: max-height .22s ease, opacity .18s ease, transform .22s ease, margin .22s ease;
  max-height: 120px;
  opacity: 1;
  transform: translateY(0);
  overflow: hidden;
}
.wam-optrow--hidden{
  max-height: 0;
  opacity: 0;
  transform: translateY(-4px);
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  pointer-events: none;
}

/* Delayed hover help bubbles (driven by JS). */
.wam-hoverhint{
  position: fixed;
  z-index: 9999;
  max-width: 300px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid #1c4f74;
  background: #dce8ef;
  color: #11354e;
  font-weight: 700;
  line-height: 1.35;
  box-shadow: 0 10px 24px rgba(0,0,0,.28);
  pointer-events: none;
  animation: wam-tip-in .16s ease-out;
}

.wam-hoverhint::after{
  content: "";
  position: absolute;
  left: var(--wam-tip-arrow-left, 50%);
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-top: 12px solid #dce8ef;
  bottom: -11px;
  filter: drop-shadow(0 2px 0 #1c4f74);
}

.wam-hoverhint--below::after{
  top: -11px;
  bottom: auto;
  border-top: 0;
  border-bottom: 12px solid #dce8ef;
  filter: drop-shadow(0 -2px 0 #1c4f74);
}

@keyframes wam-tip-in{
  from{
    opacity: 0;
    transform: translateY(4px) scale(.98);
  }
  to{
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.wam-inline{ display:grid; grid-template-columns: 140px 1fr; gap: 10px; align-items:center; }
@media (max-width: 1100px){ .wam-inline{ grid-template-columns: 1fr; } }

.wam-inline__label{ font-size: 13px; font-weight: 800; color: rgba(255,255,255,.92); }

.wam-input, .wam-select{
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,.22);
  padding: 10px 12px;
  background: rgba(255,255,255,.92);
  color: #111;
  font-weight: 700;
}

.wam-input:focus, .wam-select:focus{ outline: 3px solid rgba(255,255,255,.55); outline-offset: 2px; }

.wam-check{ display:flex; align-items:center; gap: 10px; font-weight: 800; }
.wam-check input{ width: 18px; height: 18px; }

/* Details panel */
.wam-details__hint{ opacity:.9; font-weight: 650; }

.wam-details__title{ font-weight: 950; font-size: 18px; margin-bottom: 6px; }
.wam-details__meta{ font-weight: 800; opacity:.95; margin-bottom: 10px; }
.wam-details__desc{ opacity:.92; line-height: 1.4; }
.wam-details__subhead{ margin-top: 14px; font-weight: 900; }
.wam-details__list{ margin: 8px 0 0 18px; padding: 0; }
.wam-details__list li{ margin: 4px 0; }

/* Settings panel */
.wam-settings{ display:flex; flex-direction:column; gap: 14px; }

.wam-field{ display:flex; flex-direction:column; gap: 6px; }
.wam-field__label{ font-weight: 900; font-size: 13px; }
.wam-field__control{ width: 100%; }

.wam-field--toggle{ flex-direction:row; justify-content:space-between; align-items:center; padding: 8px 0; }
.wam-field--toggle input{ width: 18px; height: 18px; }

.wam-note{ font-size: 12px; opacity:.92; }

/* Summary */
.wam-summary{ display:flex; flex-direction:column; gap: 12px; }

.wam-summary__totalrow{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap: 10px;
  padding: 6px 0 2px;
}

.wam-summary__total{
  font-size: 38px;
  font-weight: 950;
  letter-spacing: .5px;
}

.wam-summary__unit{ font-size: 14px; font-weight: 900; opacity:.95; }

.wam-summary__subhead{ font-weight: 950; letter-spacing: .2px; }
.wam-summary__mults{ display:flex; flex-direction:column; gap: 8px; }

.wam-divider{ height: 1px; background: rgba(0,0,0,.18); margin: 8px 0; }

.wam-mult{ display:flex; justify-content:space-between; gap: 10px; padding: 6px 10px; background: rgba(0,0,0,.12); border-radius: 10px; border: 1px solid rgba(0,0,0,.12); }
.wam-mult__label{ font-weight: 900; }
.wam-mult__val{ font-weight: 950; text-align: right; font-size: 12px; }

/* Breakdown rows */
.wam-break{ background: rgba(0,0,0,.10); border: 1px solid rgba(0,0,0,.12); border-radius: 12px; padding: 10px; margin-bottom: 8px; }
.wam-break__head{ display:flex; justify-content:space-between; gap: 10px; font-weight: 950; cursor: default; }
.wam-break__name{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.wam-break__cost{ white-space:nowrap; }
.wam-break__lines{ margin: 8px 0 0 18px; padding: 0; font-size: 12px; opacity: .95; }
.wam-break__lines li{ margin: 3px 0; }

.wam-break-row--empty{ padding: 6px 4px; font-weight: 700; }

.wam-breakfoot{ margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(0,0,0,.18); }
.wam-breakfoot__row{ display:flex; justify-content:space-between; gap: 10px; font-weight: 950; padding: 6px 2px; }

.wam-override-note{
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 153, 47, 0.22);
  border: 1px solid rgba(255, 196, 110, 0.55);
  font-size: 12px;
  font-weight: 700;
}

/* Output */
.wam-output{ display:flex; flex-direction:column; gap: 10px; }
.wam-output__box{
  width: 100%;
  resize: vertical;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.22);
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: rgba(255,255,255,.92);
  color: #111;
}

.wam-btn{
  align-self:flex-start;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 950;
  cursor:pointer;
  background: rgba(0,0,0,.28);
  color: #fff;
  box-shadow: 0 10px 18px rgba(0,0,0,.18);
}

.wam-btn:hover{ background: rgba(0,0,0,.34); }
.wam-btn:focus{ outline: 2px solid rgba(255,255,255,.7); outline-offset: 2px; }

/* Small helper text */
.wgt-muted{
  padding: 10px;
  font-size: 13px;
  opacity: 0.9;
}
