/* ──────────────────────────────────────────────────────────────────────── */
/*  The Treasure Weaver — ecosystem-native loot calculator                  */
/* ──────────────────────────────────────────────────────────────────────── */

.tw-page { max-width: 1200px; margin: 0 auto; }

/* Header */
.tw-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1.5rem; flex-wrap: wrap;
  padding-bottom: 1.1rem; border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.tw-head-kicker {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .25rem .7rem; border-radius: 999px;
  border: 1px solid rgba(214,178,87,.25); background: rgba(214,178,87,.07);
  color: var(--gold); font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em; margin-bottom: .5rem;
}
.tw-head-title h1 {
  margin: 0 0 .4rem; font-size: clamp(1.7rem, 3vw, 2.4rem); line-height: 1.1;
  background: linear-gradient(135deg, #ffffff 10%, #e5daff 55%, #f0cf7d 95%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.tw-head-sub { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.55; max-width: 580px; }
.tw-head-actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }

/* Buttons */
.tw-btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .6rem 1.05rem; border-radius: 10px;
  font-size: .86rem; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: all .16s ease; white-space: nowrap;
  border: 1px solid transparent;
}
.tw-btn-primary {
  background: linear-gradient(135deg, #a589ff 0%, var(--violet) 55%, #6a4df4 100%);
  color: #fff; border-color: rgba(139,112,255,.55);
  box-shadow: 0 3px 14px rgba(139,112,255,.3);
}
.tw-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(139,112,255,.45); }
.tw-btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.tw-btn-ghost:hover { color: var(--text); border-color: var(--gold); background: rgba(214,178,87,.06); }
.tw-btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }

/* Panels (Encounter Setup / Loot Modifiers) */
.tw-panel {
  background: linear-gradient(180deg, var(--panel-top), var(--panel));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.25rem 1.25rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
  margin-bottom: 1.25rem;
}
.tw-panel-head {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: .55rem; margin-bottom: .9rem;
}
.tw-panel-title { font-family: var(--display); font-size: 1.15rem; letter-spacing: .02em; color: var(--gold-hi); }
.tw-panel-sub   { font-size: .72rem; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; }

.tw-grid {
  display: grid; gap: .9rem 1.2rem;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  align-items: end;
}

.tw-field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.tw-field-label {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted);
}
.tw-input, .tw-select {
  padding: .55rem .75rem;
  background: rgba(8,8,14,.65); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
  font-size: .88rem; font-family: inherit; outline: none;
  transition: border-color .15s ease; min-width: 0; width: 100%;
}
.tw-input:focus, .tw-select:focus { border-color: var(--gold); }

/* Input-suffix (percent sign, gp, etc.) */
.tw-inputwrap { position: relative; display: flex; align-items: stretch; }
.tw-inputwrap .tw-input { padding-right: 2.2rem; }
.tw-inputwrap .tw-input-suffix {
  position: absolute; right: .7rem; top: 50%; transform: translateY(-50%);
  color: var(--faint); font-size: .78rem; pointer-events: none;
}

/* Switch */
.tw-switch { display: inline-flex; align-items: center; gap: .55rem; font-size: .82rem; color: var(--muted); cursor: pointer; user-select: none; }
.tw-switch input { display: none; }
.tw-switch-track {
  width: 34px; height: 18px; border-radius: 999px;
  background: rgba(8,8,14,.6); border: 1px solid var(--border);
  position: relative; transition: background .2s, border-color .2s;
}
.tw-switch-track::after {
  content: ''; position: absolute; top: 1px; left: 1px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--muted); transition: transform .2s, background .2s;
}
.tw-switch input:checked + .tw-switch-track { background: rgba(139,112,255,.18); border-color: rgba(139,112,255,.55); }
.tw-switch input:checked + .tw-switch-track::after { transform: translateX(16px); background: var(--gold-hi); }

/* Result header */
.tw-result-head {
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: .55rem; margin-bottom: .9rem; flex-wrap: wrap; gap: .5rem;
}
.tw-result-title { font-family: var(--display); font-size: 1.35rem; color: var(--gold-hi); letter-spacing: .02em; }
.tw-result-tier  { font-size: .72rem; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; }
.tw-explain {
  font-size: .85rem; color: var(--muted); line-height: 1.5;
  padding: .25rem 0 .9rem;
}

/* KPI stats */
.tw-stats {
  display: grid; gap: .9rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 1rem;
}
.tw-stat {
  background: rgba(255,255,255,.02);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: .85rem 1rem;
  display: flex; flex-direction: column; gap: .25rem;
}
.tw-stat-lbl { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.tw-stat-val { font-family: var(--display); font-size: 1.5rem; color: var(--gold-hi); letter-spacing: .02em; }
.tw-stat-hint { font-size: .72rem; color: var(--faint); }

/* Coins table */
.tw-coins-box {
  border: 1px solid var(--border-soft); border-radius: 12px;
  background: rgba(255,255,255,.015);
  padding: .6rem .85rem;
}
.tw-coins-tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tw-coins-tbl th, .tw-coins-tbl td { padding: .55rem .4rem; text-align: left; }
.tw-coins-tbl th { color: var(--gold); font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; border-bottom: 1px solid var(--border-soft); }
.tw-coins-tbl td.is-right, .tw-coins-tbl th.is-right { text-align: right; }
.tw-coins-tbl tr:not(:last-child) td { border-bottom: 1px solid var(--border-soft); }
.tw-coins-tbl tr.is-total td { font-weight: 700; color: var(--gold-hi); border-top: 1px solid var(--border); border-bottom: none; }

/* Section header within result */
.tw-section-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 1.8rem 0 .6rem; gap: .5rem;
  border-bottom: 1px solid var(--border-soft); padding-bottom: .35rem;
}
.tw-section-title { font-family: var(--display); font-size: 1.05rem; color: var(--gold); letter-spacing: .02em; }
.tw-section-status { font-size: .75rem; color: var(--faint); }

/* Generic card grid */
.tw-card-grid {
  display: grid; gap: .9rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.tw-card {
  background: linear-gradient(180deg, var(--panel-top), var(--panel));
  border: 1px solid var(--border); border-radius: 12px;
  padding: .85rem 1rem 1rem;
  display: flex; flex-direction: column; gap: .45rem;
  transition: border-color .15s ease, transform .15s ease;
}
.tw-card:hover { border-color: rgba(214,178,87,.3); }
.tw-card-title { font-weight: 700; font-size: .95rem; color: var(--text); }
.tw-card-meta  { font-size: .78rem; color: var(--muted); }
.tw-card-desc  { font-size: .8rem; color: var(--muted); line-height: 1.5; }
.tw-badges { display: flex; flex-wrap: wrap; gap: .35rem; }
.tw-badge {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .18rem .55rem; border-radius: 6px;
  font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
}
.tw-badge-rarity { background: rgba(139,112,255,.12); color: #b29cff; border: 1px solid rgba(139,112,255,.38); }
.tw-badge-source { background: rgba(214,178,87,.08); color: var(--gold); border: 1px solid rgba(214,178,87,.3); }
.tw-badge-cat    { background: rgba(255,255,255,.04); color: var(--muted); border: 1px solid var(--border-soft); }
.tw-card-more {
  margin-top: .2rem; align-self: flex-start;
  padding: .35rem .75rem; border-radius: 8px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--border);
  font-size: .74rem; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: all .15s ease;
}
.tw-card-more:hover { color: var(--gold); border-color: var(--gold); background: rgba(214,178,87,.06); }

.tw-trinket-card {
  background: rgba(255,255,255,.015);
  border: 1px solid var(--border-soft); border-radius: 10px;
  padding: .6rem .8rem;
  font-size: .82rem; color: var(--muted); line-height: 1.5;
}

/* Empty / placeholder */
.tw-empty {
  font-size: .85rem; color: var(--faint); font-style: italic;
  padding: .4rem 0;
}

/* Modal */
.tw-modal-host { position: fixed; inset: 0; z-index: 9999; display: none; align-items: center; justify-content: center; padding: 1rem; }
.tw-modal-host.open { display: flex; }
.tw-modal-backdrop { position: absolute; inset: 0; background: rgba(4,4,8,.78); backdrop-filter: blur(4px); }
.tw-modal {
  position: relative; max-width: 640px; width: 100%;
  max-height: 85vh; overflow-y: auto;
  background: linear-gradient(180deg, var(--panel-top), var(--panel));
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0,0,0,.6);
  padding: 1.25rem 1.4rem 1.4rem;
}
.tw-modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; padding-bottom: .55rem; border-bottom: 1px solid var(--border-soft); margin-bottom: .9rem; }
.tw-modal-title { font-family: var(--display); font-size: 1.25rem; color: var(--gold-hi); letter-spacing: .02em; margin: 0; }
.tw-modal-meta  { font-size: .75rem; color: var(--muted); margin: .4rem 0 0; }
.tw-modal-body  { font-size: .9rem; color: var(--text); line-height: 1.65; }
.tw-modal-close {
  background: transparent; color: var(--muted);
  border: 1px solid var(--border); border-radius: 8px;
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-family: inherit; flex-shrink: 0;
  transition: color .15s, border-color .15s;
}
.tw-modal-close:hover { color: var(--gold); border-color: var(--gold); }

/* Skeleton for loading */
.tw-skeleton {
  height: 90px;
  background: linear-gradient(110deg, rgba(40,40,60,.4) 25%, rgba(70,70,90,.55) 50%, rgba(40,40,60,.4) 75%);
  background-size: 200% 100%;
  border-radius: 12px;
  animation: tw-shimmer 1.4s infinite;
  border: 1px solid var(--border);
}
@keyframes tw-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Toast */
.tw-toast-host {
  position: fixed; top: 84px; left: 50%; transform: translateX(-50%);
  z-index: 99999; display: flex; flex-direction: column; gap: .5rem;
  pointer-events: none; max-width: calc(100vw - 32px);
}
.tw-toast {
  display: flex; align-items: center; gap: .6rem;
  padding: .7rem 1.05rem; border-radius: 10px;
  background: linear-gradient(180deg, rgba(26,26,45,.97), rgba(19,19,33,.97));
  border: 1px solid var(--border); color: var(--text);
  font-size: .86rem; box-shadow: 0 10px 28px rgba(0,0,0,.5);
  pointer-events: auto; animation: tw-toast-in .22s ease-out;
  max-width: 440px;
}
.tw-toast i { font-size: .9rem; flex-shrink: 0; }
.tw-toast.is-info i  { color: var(--violet); }
.tw-toast.is-warn    { border-color: rgba(232,160,80,.5); }
.tw-toast.is-warn i  { color: #e8a050; }
.tw-toast.is-error   { border-color: rgba(233,69,96,.55); }
.tw-toast.is-error i { color: #e94560; }
.tw-toast.is-out { opacity: 0; transform: translateY(-6px); transition: all .2s ease-in; }
@keyframes tw-toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* Responsive */
@media (max-width: 720px) {
  .tw-head { align-items: stretch; }
  .tw-head-actions { justify-content: space-between; }
}
