/* Eccy Fred - Space Marine 2 perk explorer */

:root {
  --bg: #0b0f14;
  --panel: #121922;
  --panel-2: #18212c;
  --line: #263243;
  --text: #dfe6ee;
  --muted: #8d9aab;
  --blue: #2b8fd6;
  --blue-dim: #16405f;
  --gold: #c9973a;
  --gold-dim: #4d3a17;
  --up: #63d68f;
  --down: #ff7676;
  --minoris: #b8c2cc;
  --majoris: #e3c065;
  --extremis: #f08a4b;
  --terminus: #ff5d6c;
  --radius: 10px;
  --gutter: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -200px, #15202d 0%, var(--bg) 70%) var(--bg) no-repeat;
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}

/* The app, a class page's perk list and the footer are siblings (see index.html). */
#root, .class-guide, #site-footer {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}
#site-footer { padding-bottom: 32px; }

h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
p { margin: 0; }
a { color: var(--blue); }
img { display: block; }

button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.muted { color: var(--muted); }
.noscript { padding: 40px 0; text-align: center; }

/* --- header & tabs ------------------------------------------------------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 0 16px;
  flex-wrap: wrap;
}

.brand h1 {
  font-size: 22px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tagline { color: var(--muted); font-size: 13px; }

.kofi {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--gold-dim);
  border: 1px solid var(--gold);
  color: #f6e2b8;
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}
.kofi:hover { background: #63491a; }

.class-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

/* Links to the class pages, though a plain click switches class in place (app.js). */
.class-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
}
.class-tab:hover { border-color: #3a4a60; }
.class-tab.is-active {
  border-color: var(--gold);
  background: linear-gradient(180deg, #221b10, var(--panel));
}
.class-tab img { width: 28px; height: 28px; }

/* --- class heading ------------------------------------------------------- */

.class-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 20px 0 14px;
}
.class-emblem {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  margin: 6px;
  display: grid;
  place-items: center;
  border: 1px solid var(--gold);
  border-radius: 4px;
  background: #1a160f;
  transform: rotate(45deg);
}
.class-emblem img { width: 36px; height: 36px; transform: rotate(-45deg); }
.class-head > div { flex: 1; min-width: 0; }
.class-name {
  font-size: 26px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: #e9c98a;
}
.class-ability { color: var(--muted); }
.class-ability strong { color: #e9c98a; font-weight: 600; letter-spacing: 0.04em; }

/* --- buttons ------------------------------------------------------------- */

.btn {
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  cursor: pointer;
}
.btn:hover { border-color: #3a4a60; }
.btn-primary { background: var(--blue-dim); border-color: var(--blue); }
.btn-quiet { background: transparent; color: var(--muted); }

/* --- perk tree ----------------------------------------------------------- */

.planner {
  display: grid;
  gap: 16px;
  align-items: start;
}

@media (min-width: 1100px) {
  .planner { grid-template-columns: minmax(0, 1fr) 300px; }
  .detail { position: sticky; top: 16px; }
}

.tree {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* No min-width on the group itself: a flex item's automatic minimum is its content,
   so a one-column group never gets narrower than its label (STANDARD, SIGNATURE). */
.group {
  flex: var(--cols) 1 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 8px 12px;
}

.group-label {
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
  margin-bottom: 10px;
}

/* About 76px per column including the group's padding and border. */
.group-cols {
  display: flex;
  gap: 4px;
  min-width: calc(var(--cols) * 76px - 18px);
}

.col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 2px;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  min-width: 0;
}
.tile:hover { background: rgba(255, 255, 255, 0.04); }

.tile-frame {
  width: 56px;
  height: 52px;
  display: grid;
  place-items: center;
  background: #1c2735;
  transition: background-color 0.15s;
}
.tile-frame img { width: 40px; height: 40px; }
.tile-hex .tile-frame { clip-path: polygon(25% 3%, 75% 3%, 100% 50%, 75% 97%, 25% 97%, 0 50%); }
.tile-square .tile-frame { border-radius: 6px; width: 52px; }

.tile.is-selected.tile-hex .tile-frame { background: var(--blue); }
.tile.is-selected.tile-square .tile-frame { background: var(--gold); }
.tile.is-selected.tile-hex { filter: drop-shadow(0 0 8px rgba(43, 143, 214, 0.55)); }
.tile.is-selected.tile-square { filter: drop-shadow(0 0 8px rgba(201, 151, 58, 0.55)); }

.tile-name {
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  min-height: 2.5em;
}
.tile.is-selected .tile-name { color: #fff; font-weight: 600; }
.tile-level { font-size: 10px; color: var(--muted); letter-spacing: 0.05em; }

/* --- tooltip & detail ---------------------------------------------------- */

.tooltip {
  position: fixed;
  z-index: 50;
  width: min(280px, calc(100vw - 16px));
  padding: 10px 12px;
  background: #0f151d;
  border: 1px solid #3a4a60;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tooltip-name { font-size: 14px; }
.tooltip-meta, .tooltip-more { font-size: 11px; color: var(--muted); }
.tooltip-desc { font-size: 13px; }

.detail {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.detail-empty { color: var(--muted); }
.detail-head { display: flex; gap: 10px; align-items: center; }
.detail-head h3 { font-size: 16px; }
.detail-meta { font-size: 12px; color: var(--muted); }
.detail-notes {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  font-size: 13px;
  color: #c4ceda;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.detail-notes h4 {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

/* On narrower screens the detail panel sticks to the bottom of the viewport
   so a tapped perk's details are visible without scrolling. */
@media (max-width: 1099px) {
  .detail {
    position: sticky;
    bottom: 8px;
    z-index: 10;
    max-height: 45vh;
    overflow-y: auto;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45);
  }
}

/* Perk text highlights, matching the wiki's colours for values and enemy tiers. */
.hl { font-weight: 600; }
.hl-up { color: var(--up); }
.hl-down { color: var(--down); }
.hl-minoris { color: var(--minoris); }
.hl-majoris { color: var(--majoris); }
.hl-extremis { color: var(--extremis); }
.hl-terminus { color: var(--terminus); }

.detail-status {
  font-size: 13px;
  color: #f2c48a;
  border-left: 3px solid var(--extremis);
  padding-left: 8px;
}

/* Weapon perk icons the wiki doesn't have: the perk's initials. */
.icon-placeholder {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 6px;
  background: #2a3647;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* --- weapons ------------------------------------------------------------- */

.weapons { margin-top: 24px; }

.weapons-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-bottom: 12px;
}
.weapons-head h2 {
  font-size: 14px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.weapons-head p { font-size: 13px; }

.weapon-picks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.weapon-pick {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
}
.weapon-pick-label {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
/* Custom caret, so it sits inside the field with room on the right. */
.weapon-pick select {
  width: 100%;
  appearance: none;
  padding: 8px 36px 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238d9aab' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 14px center / 12px 8px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.weapon-pick select:hover { border-color: #3a4a60; }
.weapon-pick select:disabled { opacity: 0.55; cursor: default; }
.weapon-pick-note { color: #f2c48a; font-size: 12px; }

.weapon-list { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.weapon-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 10px;
}
.weapon-head > div { flex: 1 1 auto; min-width: 0; }
.weapon-slot-tag {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
.weapon-name {
  font-size: 18px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #e9c98a;
}
.badge {
  display: inline-block;
  vertical-align: middle;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}
.points { font-size: 13px; color: var(--muted); }
.points strong { color: var(--text); font-size: 15px; }
.points.is-spent strong { color: var(--muted); }
.btn:disabled { opacity: 0.4; cursor: default; }

/* Tier colours follow the game: Master-Crafted green, Artificer purple, Relic gold. */
.wtree .group-label { margin-bottom: 8px; }
.wtree .tier-master-crafted .group-label { color: #4fbf7a; }
.wtree .tier-artificer .group-label { color: #b06ad8; }
.wtree .tier-relic .group-label { color: var(--gold); }
.wtree .tier-heroic .group-label { color: #e06b5b; }

/* Rows are sized per tier (2 or 4) and each tier's tiles are centred vertically, so tiers
   side by side line up on their middle rows while a tier on its own line stays compact. */
.wtree .group { display: flex; flex-direction: column; }
.wtree .group-cols { flex: 1; align-items: center; }
.wcol {
  display: grid;
  grid-template-rows: repeat(var(--rows), 1fr);
}
.wcell { min-width: 0; display: flex; flex-direction: column; align-items: center; }
.heroic-version { font-size: 10px; color: var(--muted); text-align: center; margin-top: -2px; }

/* Weapon perk states, as on the game's Perk Tree screen: bought perks are filled,
   perks you can buy now are outlined, the rest are dimmed. The frame is the outline. */
.wtile .tile-frame { padding: 2px; background: #263243; }
.wtile .tile-core {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: #141c26;
}
.wtile.tile-hex .tile-core { clip-path: polygon(25% 3%, 75% 3%, 100% 50%, 75% 97%, 25% 97%, 0 50%); }
.wtile.tile-square .tile-core { border-radius: 4px; }
.wtile .tile-core img, .wtile .tile-core .icon-placeholder { width: 36px; height: 36px; }

.wtile.is-available .tile-frame { background: #cfd8e3; }
.wtile.is-unaffordable .tile-frame { background: #7d8a9a; }
.wtile.is-unaffordable { cursor: default; }
.wtile.is-owned .tile-frame, .wtile.is-owned .tile-core { background: var(--blue); }
.wtile.is-owned { filter: drop-shadow(0 0 8px rgba(43, 143, 214, 0.55)); }
.wtile.is-owned .tile-name { color: #fff; font-weight: 600; }
.wtile.is-locked .tile-core > * { opacity: 0.35; }
.wtile.is-locked .tile-name { color: var(--muted); }
.wtile.is-locked { cursor: default; }

/* --- panels: prestige, buffs, builds ------------------------------------- */

.panel {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.panel-head h2 {
  font-size: 14px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.count, .flash { font-size: 13px; color: var(--muted); }

/* Slots change column count with the panel's own width, not the viewport's. A filled
   slot needs about 160px: the longest word in a prestige perk name ("Reverberating",
   80px at 13px), its icon, padding and the ×. So four columns need ~664px, two ~328px. */
.prestige { container-type: inline-size; }
.prestige-slots {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
@container (min-width: 330px) {
  .prestige-slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container (min-width: 670px) {
  .prestige-slots { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.slot {
  min-height: 56px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  font-size: 13px;
}
.slot-empty {
  border: 1px dashed #3a4a60;
  color: var(--muted);
  justify-content: center;
}
.slot-filled {
  border: 1px solid var(--gold);
  background: var(--gold-dim);
  cursor: pointer;
  text-align: left;
}
/* Last resort: a name longer than the layout allows for wraps mid-word rather than running into the ×. */
.slot-filled span:nth-child(2) { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.slot-x { color: #f6e2b8; font-size: 18px; line-height: 1; }

.prestige-pool + .prestige-pool { margin-top: 10px; }
.prestige-pool h3 {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.pool {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
}
.pool-perk {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
  font-size: 13px;
}
.pool-perk:hover { border-color: #3a4a60; }
.pool-perk[aria-disabled="true"] { cursor: default; opacity: 0.45; }
.pool-perk.is-picked { opacity: 0.35; }

.buff-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.buff {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  column-gap: 12px;
  padding: 8px 10px;
  background: var(--panel-2);
  border-radius: 8px;
  border-left: 3px solid var(--blue);
}
.buff-tag {
  grid-row: span 2;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 2px;
}
.buff-name { font-weight: 600; }
.buff-desc { color: #c4ceda; font-size: 14px; }
.buff-team, .buff-signature, .buff-prestige { border-left-color: var(--gold); }
.buff-team .buff-name { text-decoration: underline; text-underline-offset: 3px; font-weight: 700; }
.buff-starting { border-left-color: var(--muted); }
.buff-weapon-perk { border-left-color: #4fbf7a; }
.buff-heroic { border-left-color: #e06b5b; }
.buff-weapon {
  display: block;
  text-transform: none;
  letter-spacing: 0;
  color: #c4ceda;
  font-size: 12px;
}

@media (max-width: 560px) {
  .buff { grid-template-columns: minmax(0, 1fr); }
  .buff-tag { grid-row: auto; }
}

.builds-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.save-form { display: flex; gap: 8px; flex: 1 1 280px; }
.save-form input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.saved-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.saved-list li {
  display: flex;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.saved-load {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
}
.saved-load span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-delete {
  padding: 0 12px;
  background: none;
  border: 0;
  border-left: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
}
.saved-delete:hover { color: var(--down); }

/* The saved build that matches what's on screen. */
.saved-list li.is-active {
  border-color: var(--gold);
  background: linear-gradient(180deg, #221b10, var(--panel-2));
}
.saved-list li.is-active .saved-load span { color: #f6e2b8; font-weight: 600; }
.saved-list li.is-active .saved-delete { border-left-color: var(--gold-dim); }

/* --- class pages: perk list ---------------------------------------------- */
/* Plain HTML from scripts/build-pages.mjs, outside the React roots, so it reads the
   same with or without JavaScript. */

.class-guide { margin-top: 32px; }
.class-guide > h2 {
  font-size: 14px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.guide-intro { color: var(--muted); max-width: 80ch; }

.guide-group > h3 {
  font-size: 14px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.guide-group > .muted { margin-bottom: 10px; font-size: 13px; }
.guide-group > h4 {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 12px 0 6px;
}

.guide-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
}
.guide-list li {
  padding: 8px 10px;
  background: var(--panel-2);
  border-radius: 8px;
  border-left: 3px solid var(--blue);
}
/* Gold for the gold perk slots, as in the planner. */
.guide-team li, .guide-signature li, .guide-prestige li { border-left-color: var(--gold); }
.guide-name { font-weight: 600; }
.guide-meta { color: var(--muted); font-size: 12px; }
.guide-desc { color: #c4ceda; font-size: 14px; }

.guide-weapon-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.guide-weapon-list li {
  padding: 4px 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
}

.guide-source { margin-top: 12px; font-size: 12px; }

/* --- footer -------------------------------------------------------------- */

.site-footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kofi-footer { color: #e9c98a; font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
