/* ============================================================
   Skill Builder - a Disco Elysium flavoured skill card viewer
   Content is defined in data.js. The UI only assigns values.
   ============================================================ */

:root {
  --bg: #14171a;
  --bg-2: #1b2024;
  --panel: #20262b;
  --panel-2: #262d33;
  --ink: #e8e0cf;
  --ink-dim: #a49b86;
  --ink-faint: #6f6858;
  --line: #3a4249;
  --gold: #c8a45c;
  --gold-soft: #9c8144;

  /* Attribute palettes: [bright, deep] tint the portrait frame */
  --intellect: #4c9fd6;
  --intellect-deep: #23506e;
  --psyche: #a970c4;
  --psyche-deep: #533264;
  --physique: #d1483f;
  --physique-deep: #6e211c;
  --motorics: #e0b53c;
  --motorics-deep: #8a6a16;

  --portrait-w: 150px;
  --portrait-h: 200px;

  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Oswald", "Arial Narrow", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: radial-gradient(120% 120% at 50% -10%, #232a2f 0%, var(--bg) 55%, #0f1113 100%);
  color: var(--ink);
  font-family: var(--serif);
  min-height: 100vh;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- top bar ---------- */
.topbar {
  position: relative;
  z-index: 2;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(0,0,0,0.25), rgba(0,0,0,0));
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 24px 22px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "word actions";
  align-items: center;
  gap: 2px 18px;
}
.wordmark {
  grid-area: word;
  margin: 0;
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 1.7rem;
  color: var(--gold);
  text-shadow: 0 1px 0 #000;
}
.topbar-actions {
  grid-area: actions;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ---------- buttons ---------- */
.btn {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 9px 16px;
  border-radius: 2px;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .05s;
}
.btn:hover { border-color: var(--gold-soft); background: var(--panel); }
.btn:active { transform: translateY(1px); }

/* ---------- budget meters ---------- */
.budgets {
  position: relative;
  z-index: 2;
  max-width: 1180px;
  margin: 16px auto 0;
  padding: 0 24px;
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}
.meter {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 320px;
  min-width: 260px;
}
.meter-label {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 0.74rem;
  color: var(--ink-dim);
  white-space: nowrap;
}
.meter-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  background: var(--gold);
  transition: width .15s ease;
}
.meter.full .meter-fill { background: var(--physique); }
.meter-num {
  font-family: var(--sans);
  font-size: 0.74rem;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  white-space: nowrap;
}
.meter.full .meter-num { color: var(--physique); }

/* ---------- board / attribute rows ---------- */
.board {
  position: relative;
  z-index: 2;
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 24px 10px;
}
.attr-row {
  --accent: var(--gold);
  --accent-deep: #333;
  border-top: 1px solid var(--line);
  padding: 18px 0 26px;
}
.attr-row:first-child { border-top: none; }

.attr-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.attr-name {
  margin: 0;
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  font-size: 1.35rem;
  color: var(--accent);
}
.stepper {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 2px;
}
.stepper .step {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--sans); font-size: 1.2rem; line-height: 1;
  color: var(--ink); background: transparent; border: none; cursor: pointer;
  border-radius: 2px;
}
.stepper .step:hover:not(:disabled) { background: var(--panel-2); color: var(--accent); }
.stepper .step:disabled { color: var(--ink-faint); cursor: default; }
.stepper .val {
  min-width: 30px; text-align: center;
  font-family: var(--sans); font-size: 1.25rem; font-weight: 600;
  color: var(--accent);
}
.attr-head .caption {
  font-family: var(--sans); text-transform: uppercase;
  letter-spacing: 0.1em; font-size: 0.68rem; color: var(--ink-faint);
}

/* horizontal scroller of cards */
.row-cards {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  padding-bottom: 12px;
  scroll-snap-type: x proximity;
}
.row-cards::-webkit-scrollbar { height: 8px; }
.row-cards::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* ---------- skill card ---------- */
.card {
  flex: 0 0 auto;
  width: var(--portrait-w);
  scroll-snap-align: start;
  outline: none;
}
.card:focus-visible .frame { outline: 2px solid var(--accent); outline-offset: 2px; }
.frame {
  width: var(--portrait-w);
  height: var(--portrait-h);
  border: 5px solid #000;
  background: radial-gradient(120% 90% at 50% 0%, var(--accent) 0%, var(--accent-deep) 70%, #000 130%);
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0,0,0,0.5);
  transition: transform .12s ease;
}
.card:hover .frame { transform: translateY(-3px); }
.frame img { width: 100%; height: 100%; object-fit: cover; display: block; }

.card-meta { margin-top: 8px; text-align: center; }
.card-name {
  margin: 0;
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-weight: 500;
  font-size: 0.88rem;
  color: var(--accent);
  line-height: 1.12;
  overflow-wrap: anywhere;
}
.pips {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: center;
  align-items: center;
  margin: 7px 0 2px;
}
.pip {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
}
.pip.empty { background: transparent; box-shadow: inset 0 0 0 1.5px var(--accent); }
.pip-count {
  font-family: var(--sans); font-size: 0.7rem;
  color: var(--ink-faint); letter-spacing: 0.05em; margin-left: 2px;
}

/* per-card skill point assignment */
.assign {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}
.assign .step {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--sans); font-size: 1.05rem; line-height: 1;
  color: var(--ink); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 2px; cursor: pointer;
}
.assign .step:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.assign .step:disabled { color: var(--ink-faint); cursor: default; }
.assign-label {
  min-width: 44px; text-align: center;
  font-family: var(--sans); text-transform: uppercase;
  letter-spacing: 0.06em; font-size: 0.72rem; color: var(--ink-dim);
}

/* accent classes per attribute slot */
.attr-intellect { --accent: var(--intellect); --accent-deep: var(--intellect-deep); }
.attr-psyche    { --accent: var(--psyche);    --accent-deep: var(--psyche-deep); }
.attr-physique  { --accent: var(--physique);  --accent-deep: var(--physique-deep); }
.attr-motorics  { --accent: var(--motorics);  --accent-deep: var(--motorics-deep); }

/* ---------- hover tooltip ---------- */
.tooltip {
  position: fixed;
  z-index: 20;
  max-width: 240px;
  padding: 10px 13px;
  background: #0c0e10;
  border: 1px solid var(--gold-soft);
  border-radius: 3px;
  color: var(--ink);
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.3;
  box-shadow: 0 10px 26px rgba(0,0,0,0.6);
  pointer-events: none;
}

/* ---------- responsive ---------- */
@media (max-width: 560px) {
  .topbar-inner { grid-template-columns: 1fr; grid-template-areas: "word" "actions"; }
  .topbar-actions { justify-content: flex-start; margin-top: 12px; }
}
