/* Hostiles: the bestiary (js/sections/hostiles.js). Seven species cards, two titan feature cards and the
   tally. Grid: 4 columns with the titans 2x2, 3 columns with them full width, 2 columns on phones. A
   card is a cut-corner panel holding two canvases (the ground, the living layer), its text on a scrim
   and one transparent button over it all (hover, focus, poke). */

.hostiles__list {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-flow: row dense; gap: 14px;
}

.hz {
  position: relative; isolation: isolate; min-width: 0; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  aspect-ratio: 5 / 6;
}
.hz.panel::before { z-index: 4; }
.hz__floor, .hz__live { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.hz__floor { z-index: 0; }
.hz__live { z-index: 1; }

/* threat line on top, name and codex line at the foot over a scrim; clicks go through to the button */
.hz__top, .hz__txt { position: relative; z-index: 2; pointer-events: none; }
.hz__top { display: flex; align-items: center; gap: 10px; padding: 16px 18px 0; }
.hz__threat { font-size: var(--t-micro); font-weight: 500; line-height: 1; color: var(--bone-3); }
.hz__txt {
  padding: 44px 18px 18px;
  background: linear-gradient(180deg, rgba(5, 6, 7, 0) 0, rgba(5, 6, 7, 0.7) 46%, rgba(5, 6, 7, 0.9) 100%);
}
.hz__name {
  font-family: var(--f-display); font-weight: 800; font-size: clamp(1.3rem, 1.75vw, 1.65rem); line-height: 0.95;
  letter-spacing: 0.02em; text-transform: uppercase; color: var(--bone);
}
.hz__note { margin-top: 6px; font-size: var(--t-small); line-height: 1.35; color: var(--bone-2); text-wrap: pretty; }

.hz__hit { position: absolute; inset: 0; z-index: 3; width: 100%; height: 100%; -webkit-tap-highlight-color: transparent; }
/* focus shows as the ring below; the transparent outline stands in for it in forced colours */
.hz__hit:focus-visible { outline: 2px solid transparent; outline-offset: -2px; }

/* state ring, inside the edges and along the cut corners (the two gradients, like .panel's hairline):
   flesh while a creature is provoked, amber for keyboard focus. Registered, so its colours fade. */
@property --hz-ring { syntax: '<color>'; inherits: false; initial-value: transparent; }
@property --hz-glow { syntax: '<color>'; inherits: false; initial-value: transparent; }
.hz::after {
  --w: 1px;
  content: ''; position: absolute; inset: 0; z-index: 4; pointer-events: none;
  background: linear-gradient(to bottom left, transparent 50%, var(--hz-ring) 0 calc(50% + var(--w)), transparent 0) 100% 0 / var(--cut) var(--cut) no-repeat,
    linear-gradient(to top right, transparent 50%, var(--hz-ring) 0 calc(50% + var(--w)), transparent 0) 0 100% / var(--cut) var(--cut) no-repeat;
  box-shadow: inset 0 0 0 var(--w) var(--hz-ring), inset 0 0 64px var(--hz-glow);
  transition: --hz-ring var(--d-med) var(--ease-out), --hz-glow var(--d-med) var(--ease-out);
}
.hz.is-hot::after { --hz-ring: rgba(255, 63, 134, 0.5); --hz-glow: rgba(255, 63, 134, 0.1); }
.hz.is-focus::after { --w: 2px; --hz-ring: var(--amber); --hz-glow: rgba(255, 177, 46, 0.08); }
.hz .meter i { transition: box-shadow var(--d-med) var(--ease-out); }
.hz.is-hot .meter--flesh i.on { box-shadow: 0 0 8px var(--flesh-glow); }

/* ---------- titans ---------- */
.hz--boss { aspect-ratio: auto; min-height: 420px; }
.hz--titan { grid-column: 1 / span 2; grid-row: 1 / span 2; }
.hz--maw { grid-column: 3 / span 2; grid-row: 3 / span 2; }
.hz--boss .hz__top { padding: 22px 26px 26px; margin-bottom: -26px; background: linear-gradient(180deg, rgba(5, 6, 7, 0.78), rgba(5, 6, 7, 0)); }
.hz--boss .eyebrow { flex-wrap: wrap; row-gap: 6px; }
.hz--boss .eyebrow b { color: var(--flesh); }
.hz--boss .eyebrow span { white-space: nowrap; }
.hz--boss .hz__txt { padding: 96px 26px 26px; }
.hz--boss .hz__name { font-size: clamp(2.3rem, 4.2vw, 3.6rem); line-height: 0.9; }
.hz--boss .hz__note { margin-top: 10px; max-width: 34ch; font-size: var(--t-body); }
/* facts with a diamond between them; a fact that wraps to a new line hides its diamond off the left edge */
.hz__facts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; margin-top: 16px; overflow: hidden; font-size: var(--t-small); color: var(--bone-3); }
.hz__fact { position: relative; display: inline-flex; align-items: center; gap: 10px; }
.hz__fact b { color: var(--bone); font-weight: 600; }
.hz__fact + .hz__fact::before { content: ''; position: absolute; left: -13px; top: 50%; width: 4px; height: 4px; margin-top: -2px; background: var(--bone-4); transform: rotate(45deg); }

/* ---------- tally ---------- */
.hz--tally { justify-content: space-between; gap: 14px; padding: 20px 18px 18px; background: radial-gradient(120% 90% at 50% 40%, #111418, #07080a); }
.tally__count { display: flex; align-items: baseline; gap: 10px; }
.tally__count b {
  font-family: var(--f-display); font-weight: 800; font-size: clamp(2.8rem, 4.4vw, 4rem); line-height: 0.85;
  color: var(--bone); font-variant-numeric: tabular-nums;
}
.tally__count span { font-size: var(--t-small); color: var(--bone-3); }
.tally__count.is-bump b { animation: hz-tick 420ms var(--ease-out); }
.tally__list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 6px; }
.tally__list li { display: grid; justify-items: center; gap: 2px; }
.tally__list canvas { width: 56px; height: 56px; opacity: 0.3; filter: grayscale(1) brightness(1.5); transition: opacity var(--d-med) var(--ease-out), filter var(--d-med) var(--ease-out); }
.tally__list li.is-on canvas { opacity: 1; filter: none; }
.tally__list li.is-bump canvas { animation: hz-bump 480ms var(--ease-out); }
.tally__n { font-family: var(--f-display); font-weight: 700; font-size: var(--t-micro); line-height: 1; color: var(--bone-3); font-variant-numeric: tabular-nums; }
.tally__list li.is-on .tally__n { color: var(--bone-2); }
.tally__how { flex-wrap: wrap; row-gap: 6px; }
.tally__how .when-fine { display: inline-flex; gap: 6px; }
@media (hover: none) { .tally__how .when-fine { display: none; } }
@media (hover: hover) { .tally__how .when-touch { display: none; } }
@keyframes hz-bump { 0% { transform: scale(1.4) rotate(-8deg); } 100% { transform: none; } }
@keyframes hz-tick { 0% { transform: translateY(-6px); color: var(--flesh); } 100% { transform: none; } }

/* ---------- 3 columns: titans full width, the tally beside the womb ---------- */
@media (max-width: 1079px) {
  .hostiles__list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hz--boss { grid-column: 1 / -1; grid-row: auto; aspect-ratio: 16 / 10; min-height: 0; }
  .hz--tally { grid-column: span 2; aspect-ratio: auto; }
  .tally__list { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}

/* ---------- phones: 2 columns ---------- */
@media (max-width: 639px) {
  .hostiles__list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .hz { aspect-ratio: 3 / 4.3; }
  .hz__top { gap: 8px; padding: 12px 12px 0; }
  .hz .meter { gap: 2px; }
  .hz .meter i { width: 7px; }
  .hz__txt { padding: 30px 12px 12px; }
  .hz__name { font-size: 1.2rem; }
  .hz__note { margin-top: 4px; font-size: 0.8125rem; line-height: 1.3; }
  .hz--boss { aspect-ratio: 4 / 5; }
  .hz--boss .hz__top { padding: 16px 16px 22px; margin-bottom: -22px; }
  .hz--boss .eyebrow::after { display: none; }
  .hz--boss .hz__txt { padding: 56px 16px 16px; }
  .hz--boss .hz__name { font-size: 2.1rem; }
  .hz--boss .hz__note { font-size: var(--t-small); }
  .hz__facts { gap: 6px 22px; margin-top: 12px; }
  .hz--tally { grid-column: span 1; aspect-ratio: auto; gap: 8px; padding: 14px 12px 12px; }
  .tally__list { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px 2px; }
  .tally__list canvas { width: 36px; height: 36px; }
}
