/* Base + shared primitives. Components compose these classes; module CSS adds only layout specific to it. */
@import url("./tokens.css");

*,
*::before,
*::after { box-sizing: border-box; min-width: 0; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fw-regular) var(--fs-base) / 1.45 var(--font);
  font-feature-settings: "cv11" 1; /* Inter: single-storey a reads calmer at 12–14px */
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: var(--fw-medium); letter-spacing: -0.005em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

/* browser surfaces carry the palette */
::selection { background: var(--gold-soft); color: var(--text); }
:focus-visible { outline: 1px solid var(--gold); outline-offset: 2px; }
input, textarea { caret-color: var(--gold); }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); }
::-webkit-scrollbar-track { background: transparent; }
a { color: var(--text-2); text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
a:hover { color: var(--text); text-decoration-color: var(--gold-line); }

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.label { font-size: var(--fs-sm); color: var(--muted); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- panels: flat slate with one hairline; never nested cards ---- */
.panel { background: var(--panel); border: var(--hair); border-radius: var(--radius); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); padding: var(--s3) var(--s4); border-bottom: var(--hair); }
.panel-head h2 { font-size: var(--fs-lg); }
.panel-body { padding: var(--s3) var(--s4); }
.rule { height: 0; border-top: var(--hair); margin: var(--s3) 0; }

/* ---- controls ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: 30px; padding: 0 var(--s3);
  background: var(--panel-2); border: var(--hair-strong); border-radius: var(--radius);
  color: var(--text); font-size: var(--fs-md); cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.btn:hover { border-color: var(--muted); }
.btn:active { background: var(--panel-3); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { border-color: var(--gold-line); color: var(--gold); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--line); }
.btn.icon-only { width: 30px; padding: 0; }
.btn svg { width: 16px; height: 16px; }

.field {
  width: 100%; height: 34px; padding: 0 var(--s3);
  background: var(--bg); border: var(--hair-strong); border-radius: var(--radius);
  color: var(--text); font-size: var(--fs-base);
}
.field:hover { border-color: var(--muted); }
.field:focus { outline: none; border-color: var(--gold-line); }
.field::placeholder { color: var(--muted); }
.field.invalid { border-color: var(--bad); }
select.field {
  appearance: none; padding-right: 28px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.field-row { display: grid; gap: var(--s1); }

/* chips: stat tokens in the priority builder, toggles */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  background: var(--panel-2); border: var(--hair-strong); border-radius: var(--radius);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); letter-spacing: 0.02em; text-transform: uppercase;
  color: var(--text-2); cursor: pointer; user-select: none;
}
.chip:hover { border-color: var(--muted); color: var(--text); }
.chip[aria-pressed="true"], .chip.on { border-color: var(--gold-line); color: var(--gold); background: var(--gold-soft); }
.chip .rank { color: var(--dim); font-weight: var(--fw-regular); }

/* segmented / toggle */
.seg { display: inline-flex; gap: 2px; padding: 2px; border: var(--hair-strong); border-radius: var(--radius); }
.seg > button { height: 24px; padding: 0 10px; background: transparent; border: 0; border-radius: 1px; color: var(--muted); font-size: var(--fs-sm); cursor: pointer; }
.seg > button:hover { color: var(--text); background: var(--panel-3); }
.seg > button[aria-pressed="true"] { color: var(--gold); background: var(--gold-soft); }

/* ---- the item frame: icon in a 1px quality border ---- */
.q0 { --q: var(--q0); } .q1 { --q: var(--q1); } .q2 { --q: var(--q2); }
.q3 { --q: var(--q3); } .q4 { --q: var(--q4); } .q5 { --q: var(--q5); }
.qname { color: var(--q, var(--text)); }
.icon {
  position: relative; flex: none;
  width: var(--icon); height: var(--icon);
  border: 1px solid var(--q, var(--line-strong)); border-radius: var(--radius);
  background: var(--panel-3) center / cover no-repeat;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6);
}
.icon.sm { width: var(--icon-sm); height: var(--icon-sm); }
.icon img { width: 100%; height: 100%; object-fit: cover; }
.icon.empty { border-style: dashed; border-color: var(--line-strong); background: transparent; }
.icon .mark { position: absolute; right: -4px; top: -4px; width: 12px; height: 12px; }

/* ---- score bar: length is the exact score (direction raise) ---- */
.bar { position: relative; height: 4px; background: var(--panel-3); border-radius: 1px; overflow: hidden; }
.bar > i { position: absolute; inset: 0; background: var(--q, var(--muted)); clip-path: inset(0 calc(100% - var(--v, 0%)) 0 0); transition: clip-path var(--t-med) var(--ease); }

/* ---- meter: a budget that can never overflow (talent points) ---- */
.meter { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; height: 6px; }
.meter:has(> i:nth-child(21)) { gap: 1px; }
.meter > i { background: var(--panel-3); }
.meter > i.on { background: var(--gold); }

/* ---- WoW tooltip grammar ---- */
.tooltip {
  background: var(--ink); border: var(--hair-strong); border-radius: var(--radius);
  padding: var(--s3) var(--s4); font-size: var(--fs-md); line-height: 1.5;
}
.tooltip .tt-name { font-size: var(--fs-lg); font-weight: var(--fw-medium); }
.tooltip .tt-line { color: var(--text); }
.tooltip .tt-sub { color: var(--muted); }
.tooltip .tt-equip { color: var(--q2); }
.tooltip .tt-neg { color: var(--bad); }
.tooltip .tt-req { color: var(--text-2); }
.tooltip .tt-req.unmet { color: var(--bad); }

/* ---- overlay: a sheet that slides over the left column region, not a modal ---- */
.sheet {
  /* opens beside the planner frame, not at the far window edge on wide screens */
  position: fixed; top: 0; bottom: 0; left: max(0px, calc((100vw - var(--frame-max)) / 2)); width: min(560px, 92vw); z-index: 20;
  background: var(--panel); border-right: var(--hair-strong);
  box-shadow: 12px 0 32px rgba(0, 0, 0, 0.45);
  transform: translateX(-102%); transition: transform var(--t-med) var(--ease);
  display: grid; grid-template-rows: auto 1fr auto;
}
.sheet[data-open="true"] { transform: none; }
.sheet .sheet-body { overflow: auto; padding: var(--s4); }
.scrim { position: fixed; inset: 0; z-index: 19; background: rgba(5, 7, 10, 0.5); opacity: 0; pointer-events: none; transition: opacity var(--t-med) var(--ease); }
.scrim[data-open="true"] { opacity: 1; pointer-events: auto; }

/* ---- small status marks (states drawn as marks, direction raise) ---- */
.badge { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border: var(--hair); border-radius: var(--radius); font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.badge.warn { color: var(--warn); border-color: rgba(226, 177, 74, 0.4); }
.badge.bad { color: var(--bad); border-color: rgba(229, 83, 75, 0.4); }
.badge.gold { color: var(--gold); border-color: var(--gold-line); }

/* skeleton while the bundle loads */
.skeleton { background: linear-gradient(90deg, var(--panel-2), var(--panel-3), var(--panel-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
