/* ==========================================================================
   Party Builds — roster-select dossier.
   Motif: the P5R party / confidant status screen. The emblem wall is the
   loud frame; each opened dossier is calm, scannable build data.
   Shares system.css tokens; adds only what this page needs.
   ========================================================================== */

/* ---- Loading skeleton ---------------------------------------------------- */

.roster-skel {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: var(--space-4);
}
/* `display:grid` above beats the UA `[hidden]{display:none}`, so the loading
   skeleton would linger once hidden. Restore hiding explicitly. */
.roster-skel[hidden] { display: none; }
.roster-skel .skel {
  aspect-ratio: 3 / 4;
  background: linear-gradient(100deg, var(--panel) 30%, var(--panel-2) 50%, var(--panel) 70%);
  background-size: 220% 100%;
  animation: skel-slide 1.1s ease-in-out infinite;
}
@keyframes skel-slide { from { background-position: 180% 0; } to { background-position: -60% 0; } }

.load-error { padding: var(--space-6) 0; }
.load-error p { margin-bottom: var(--space-4); }

/* ==========================================================================
   ROSTER WALL
   ========================================================================== */

.roster-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}
.roster-grid > li { min-width: 0; }

.thief-tile {
  position: relative;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--paper);
  cursor: pointer;
  font: inherit;
  text-align: center;
  padding: var(--space-5) var(--space-3) var(--space-4);
  min-width: 0;
  overflow-wrap: anywhere;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  /* Angular P5R corner cut, bottom-right */
  clip-path: polygon(0 0, 100% 0, 100% 84%, 90% 100%, 0 100%);
  transition: border-color var(--t-med) var(--ease-out),
              background var(--t-med) var(--ease-out),
              transform var(--t-med) var(--ease-out);
  will-change: transform;
}
/* A staggered fan so eight tiles don't read as a flat grid */
.thief-tile:nth-child(even) { transform: translateY(0.7rem); }

.thief-tile::after {
  /* thin blood slash along the cut corner */
  content: "";
  position: absolute;
  right: -1px;
  bottom: 0;
  width: 22%;
  height: 3px;
  background: var(--blood);
  transform: skewX(-42deg);
  transform-origin: right;
  opacity: 0;
  transition: opacity var(--t-med) var(--ease-out);
}
.thief-tile:hover,
.thief-tile:focus-visible {
  border-color: var(--blood);
  background: var(--panel-2);
  transform: translateY(-0.35rem);
  outline: none;
}
.thief-tile:nth-child(even):hover,
.thief-tile:nth-child(even):focus-visible { transform: translateY(0.35rem); }
.thief-tile:hover::after,
.thief-tile:focus-visible::after { opacity: 1; }
.thief-tile:focus-visible { box-shadow: inset 0 0 0 2px var(--paper); }

.emblem {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  /* Melt the emblem's square red field into the panel — reads as a glowing
     medallion without a hard border (keeps the frame sharp-cornered). */
  -webkit-mask-image: radial-gradient(circle at 50% 48%, #000 54%, transparent 72%);
          mask-image: radial-gradient(circle at 50% 48%, #000 54%, transparent 72%);
  transition: transform var(--t-med) var(--ease-out), filter var(--t-med) var(--ease-out);
}
.thief-tile .emblem { width: 78%; }
.thief-tile:hover .emblem,
.thief-tile:focus-visible .emblem {
  transform: scale(1.07);
  filter: drop-shadow(0 0 14px rgba(217, 35, 35, 0.55));
}

.thief-tile .code {
  font-size: var(--text-lg);
  font-weight: 700;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.1;
}
.thief-tile .epithet {
  font-size: var(--text-xs);
  font-style: italic;
  color: var(--smoke-lift);
  line-height: 1.25;
  text-wrap: balance;
}
.thief-tile .role-tag {
  margin-top: var(--space-1);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--smoke);
}

/* ==========================================================================
   DOSSIER
   ========================================================================== */

.strip-roster {
  flex: none;
  border: none;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--paper);
  background: transparent;
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.strip-roster::before {
  content: "";
  width: 0.55em;
  height: 0.9em;
  background: var(--blood);
  clip-path: polygon(100% 0, 0 50%, 100% 100%);
  transition: transform var(--t-fast) var(--ease-out);
}
.strip-roster:hover { color: var(--blood); }
.strip-roster:hover::before { transform: translateX(-3px); }

/* ---- Thief rail: switch between builds without leaving the dossier ------- */

.thief-rail {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}
.rail-emblem {
  flex: none;
  border: 1px solid transparent;
  background: var(--panel);
  cursor: pointer;
  padding: var(--space-1);
  width: 3.25rem;
  height: 3.25rem;
  display: grid;
  place-items: center;
  transition: border-color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
}
.rail-emblem img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  -webkit-mask-image: radial-gradient(circle at 50% 48%, #000 55%, transparent 74%);
          mask-image: radial-gradient(circle at 50% 48%, #000 55%, transparent 74%);
  transition: transform var(--t-fast) var(--ease-out);
  filter: grayscale(0.35) brightness(0.85);
}
.rail-emblem:hover img { transform: scale(1.06); filter: none; }
.rail-emblem[aria-current="true"] {
  border-color: var(--blood);
  background: var(--panel-2);
}
.rail-emblem[aria-current="true"] img { filter: none; }
.rail-emblem:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }

/* ---- Dossier head: identity band ---------------------------------------- */

.dossier-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-3) var(--space-5);
  align-items: center;
  padding-bottom: var(--space-5);
  margin-bottom: var(--space-6);
  border-bottom: 3px solid var(--blood);
}
.dossier-head .emblem-lg {
  width: 7.5rem;
  height: 7.5rem;
  object-fit: contain;
  -webkit-mask-image: radial-gradient(circle at 50% 48%, #000 56%, transparent 74%);
          mask-image: radial-gradient(circle at 50% 48%, #000 56%, transparent 74%);
  filter: drop-shadow(0 0 16px rgba(217, 35, 35, 0.35));
  grid-row: span 2;
  transform-style: preserve-3d;
  backface-visibility: hidden;
}
.dossier-head .identity { align-self: end; min-width: 0; }
.dossier-head .code {
  font-size: var(--text-2xl);
  font-weight: 700;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1;
}
.dossier-head .epithet {
  font-size: var(--text-lg);
  font-style: italic;
  color: var(--blood);
  margin-top: var(--space-1);
}
.trait-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.2rem var(--space-2);
  align-items: baseline;
  max-width: 48ch;
  margin-top: var(--space-3);
  line-height: 1.3;
}
.trait-label {
  grid-column: 1 / -1;
  color: var(--blood);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.trait-line strong {
  color: var(--paper);
  font-size: var(--text-sm);
}
.trait-effect {
  min-width: 0;
  color: var(--smoke-lift);
  font-size: var(--text-sm);
}
.dossier-head .meta {
  grid-column: 2;
  align-self: start;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  align-items: center;
}
.role-line { color: var(--smoke-lift); font-style: italic; font-size: var(--text-sm); }

.weak-pill {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.25em 0.8em;
  transform: skewX(var(--slant));
  background: transparent;
  color: var(--smoke-lift);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.weak-pill > span { display: inline-block; transform: skewX(calc(-1 * var(--slant))); }
.weak-pill b { color: var(--paper); font-style: normal; }

.dossier-intro {
  grid-column: 1 / -1;
  color: var(--paper);
  max-width: 72ch;
}

/* ---- Dossier sections ---------------------------------------------------- */

.dossier-body .sec-h { margin-top: var(--space-7); }
.dossier-body > .dossier-head + .sec-h { margin-top: 0; }

/* ---- Skills list (two columns on wide screens) --------------------------- */

.skills-list { list-style: none; }
@media (min-width: 48rem) {
  .skills-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--space-6); align-items: start; }
}
.skills-list > * { min-width: 0; }
.skill {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--line);
}
.skill.skill--signature {
  /* signature skill: quiet blood emphasis */
  border-top: 2px solid var(--blood);
  padding-top: var(--space-3);
}
.skill-name {
  font-weight: 700;
  letter-spacing: 0.01em;
}
.skill.skill--signature .skill-name::after {
  content: "Signature";
  margin-left: var(--space-2);
  font-size: 0.62rem;
  font-weight: 700;
  font-style: normal;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--blood);
  vertical-align: 0.15em;
}
.skill-effect {
  grid-column: 1 / -1;
  color: var(--smoke-lift);
  font-size: var(--text-sm);
  margin-top: 0.15em;
  max-width: 60ch;
}
.learn-chip {
  align-self: start;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.2em 0.6em;
  white-space: nowrap;
  transform: skewX(var(--slant));
}
.learn-chip > span { display: inline-block; transform: skewX(calc(-1 * var(--slant))); }
.learn-chip[data-kind="native"] { background: transparent; color: var(--smoke-lift); box-shadow: inset 0 0 0 1px var(--line-strong); }
.learn-chip[data-kind="awaken"] { background: var(--maroon); color: var(--paper); }
.learn-chip[data-kind="jazz"] { background: var(--paper); color: var(--ink); }
.learn-chip[data-kind="initial"] { background: transparent; color: var(--smoke); box-shadow: inset 0 0 0 1px var(--line); }

/* ---- Loadout: one block per slot ----------------------------------------- */

.loadout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  align-items: start; /* blocks size to their content, not the tallest neighbour */
}
@media (min-width: 48rem) {
  .loadout { grid-template-columns: 1fr 1fr; gap: var(--space-5); }
}
.loadout > * { min-width: 0; }

/* Accessory is a single fixed item — keep its block compact */
.slot--accessory { padding: var(--space-3) var(--space-4); }

.slot {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: var(--space-4);
  /* angular P5R corner, matching the roster tiles */
  clip-path: polygon(0 0, 100% 0, 100% 91%, 95% 100%, 0 100%);
}
.slot-label {
  font-size: var(--text-xs);
  font-weight: 700;
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--blood);
  margin-bottom: var(--space-3);
}

.gear-name { font-weight: 700; letter-spacing: 0.01em; }
.gear-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.12em 0.55em;
  margin-left: 0.5em;
  vertical-align: 0.14em;
}
.gear-badge[data-pick="Preferred"] { background: var(--blood); color: var(--paper); }
.gear-badge[data-pick="Fixed"] { background: var(--paper); color: var(--ink); }

.gear-stats { display: flex; flex-wrap: wrap; gap: var(--space-1); margin: var(--space-2) 0; }
.stat-chip {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.16em 0.55em;
  background: var(--panel-2);
  color: var(--paper);
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
/* Bonus stats are the same neutral chip, marked by a blood underline rather
   than a red fill (which read as a warning). */
.stat-chip--bonus { background: var(--panel-2); color: var(--paper); box-shadow: inset 0 -2px 0 var(--blood); }

.gear-effect { font-size: var(--text-sm); color: var(--paper); margin-top: var(--space-1); }
.gear-where { font-size: var(--text-xs); color: var(--smoke-lift); margin-top: 0.15em; }

.slot-alts {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
  display: grid;
  gap: var(--space-3);
}
.gear--alt .gear-name { font-weight: 400; color: var(--smoke-lift); }
.gear--alt .gear-effect { color: var(--smoke-lift); }

/* ---- Prose blocks: synergy + plan --------------------------------------- */

.playbook {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6) var(--space-7);
  margin-top: var(--space-7);
}
@media (min-width: 48rem) { .playbook { grid-template-columns: 1fr 1fr; } }
.playbook p { color: var(--paper); max-width: 62ch; margin-top: var(--space-3); }

/* Highlighted skill / equipment names inside the two paragraphs. Paper text on
   a blood wash keeps contrast while reading clearly as an accent. */
.hl {
  color: var(--paper);
  font-weight: 700;
  background: rgba(217, 35, 35, 0.22);
  padding: 0 0.15em;
}

/* ==========================================================================
   MOTION HELPERS  (JS animates FROM these; content is visible without JS)
   ========================================================================== */

/* While a Flip transition runs, clip the x-axis so the absolutely-positioned
   emblems in flight can't briefly widen the page. `clip` doesn't create a
   scroll container, so the sticky tool-strip is unaffected. */
body.flip-active { overflow-x: clip; }

/* Blood "cut-in" flash behind the arriving emblem (JS-driven, transient).
   Full-viewport with center origin so scaling never overflows the page. */
.hit-flash {
  position: fixed;
  inset: 0;
  transform-origin: 50% 40%;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  background: radial-gradient(circle at 50% 40%, rgba(217, 35, 35, 0.5), rgba(217, 35, 35, 0.12) 32%, transparent 56%);
  mix-blend-mode: screen;
}
@media (prefers-reduced-motion: reduce) { .hit-flash { display: none; } }

/* ---- Responsive ---------------------------------------------------------- */

@media (max-width: 640px) {
  .roster-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
  .thief-tile:nth-child(even) { transform: none; }
  .thief-tile:nth-child(even):hover { transform: translateY(-0.35rem); }
  .dossier-head { grid-template-columns: auto 1fr; gap: var(--space-3); }
  .dossier-head .emblem-lg { width: 5rem; height: 5rem; }
  .dossier-head .code { font-size: var(--text-xl); }
  .dossier-head .epithet { font-size: var(--text-base); }
}

@media (pointer: coarse) {
  .rail-emblem { min-width: 44px; min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .thief-tile, .thief-tile:hover, .thief-tile:nth-child(even) { transform: none; }
  .roster-skel .skel { animation: none; }
}
