/* War on Earth skirmish (js/sections/skirmish.js): a playable slice of the game on a 16:9 stage
   (4:5 on phones). The HUD follows the game's (TROOPS, FRENZY, the objective, the order in force)
   in the site's type; overlays are the front end's panels. */

.skirmish__stage { position: relative; margin-top: 4px; }

.sk {
  --cut: 16px; --ar: calc(16 / 9);
  position: relative; isolation: isolate; overflow: hidden;
  aspect-ratio: var(--ar); margin-inline: auto;
  /* never taller than the screen under the nav, so the HUD and the orders bar fit with it (phone landscape) */
  width: 100%; width: min(100%, calc((100svh - var(--nav-h) - 24px) * var(--ar)));
  background: #2a2018;
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
  container-type: inline-size;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
@media (max-width: 640px) { .sk { --ar: 0.8; --cut: 12px; } }

/* hairlines that follow the cut, diagonals too (like the co-op slots'): a frame --hw wide in --hc.
   No transition: WebKit can leave one stuck halfway when --hc changes, and a focus ring must not lag. */
.sk::before, .sk::after, .sk__ord::after, .sk__drop::after {
  --hw: 1px; --hd: calc(var(--hw) * 0.4142);
  content: ''; position: absolute; inset: 0; pointer-events: none; background: var(--hc, var(--line-2));
  clip-path: polygon(evenodd, 0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)), 0 0,
    var(--hw) var(--hw), calc(100% - var(--cut) - var(--hd)) var(--hw), calc(100% - var(--hw)) calc(var(--cut) + var(--hd)),
    calc(100% - var(--hw)) calc(100% - var(--hw)), calc(var(--cut) + var(--hd)) calc(100% - var(--hw)), var(--hw) calc(100% - var(--cut) - var(--hd)), var(--hw) var(--hw));
}

.sk__canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; outline: none; touch-action: pan-x pan-y pinch-zoom; }
.sk[data-state='attract'] .sk__canvas { cursor: url('../assets/cursors/select.png') 3 2, pointer; cursor: image-set(url('../assets/cursors/select.png') 1x, url('../assets/cursors/select@2x.png') 2x) 3 2, pointer; }
.sk[data-state='play'] .sk__canvas { touch-action: none; }
/* the stage holds the keys: its hairline lights up (a wash inside it); keyboard focus on the field rings it */
.sk::before, .sk::after { z-index: 7; }
.sk::before { --hw: 4px; --hc: transparent; }
.sk[data-state='play']:focus-within::before { --hc: rgba(255, 177, 46, 0.08); }
.sk[data-state='play']:focus-within::after { --hc: rgba(255, 177, 46, 0.45); }
.sk:has(.sk__canvas:focus-visible)::after { --hw: 2px; --hc: var(--amber); }

/* vignette always; a veil behind the panels */
.sk__veil {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.45) 100%);
}
.sk__veil::after {
  content: ''; position: absolute; inset: 0; opacity: 0; transition: opacity var(--d-slow) var(--ease-out);
  background:
    radial-gradient(60% 55% at 50% 50%, rgba(5, 6, 7, 0.62), rgba(5, 6, 7, 0.25) 70%, rgba(5, 6, 7, 0.1)),
    linear-gradient(180deg, rgba(5, 6, 7, 0.35), transparent 30%, transparent 70%, rgba(5, 6, 7, 0.55));
}
.sk[data-state='attract'] .sk__veil::after {
  opacity: 1;
  background: linear-gradient(90deg, rgba(5, 6, 7, 0.78), rgba(5, 6, 7, 0.45) 34%, rgba(5, 6, 7, 0.05) 62%, transparent), linear-gradient(0deg, rgba(5, 6, 7, 0.6), transparent 22%);
}
.sk[data-state='end'] .sk__veil::after, .sk[data-state='paused'] .sk__veil::after { opacity: 1; background-color: rgba(5, 6, 7, 0.35); }

/* ---------- HUD ---------- */
.sk__hud {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  font-family: var(--f-display); color: var(--bone); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
  opacity: 0; transition: opacity var(--d-med) var(--ease-out);
}
.sk[data-state='play'] .sk__hud, .sk[data-state='paused'] .sk__hud { opacity: 1; }
.sk__hud::before, .sk__hud::after { content: ''; position: absolute; left: 0; right: 0; height: 110px; pointer-events: none; z-index: -1; }
.sk__hud::before { top: 0; background: linear-gradient(180deg, rgba(5, 6, 7, 0.6), transparent); }
.sk__hud::after { bottom: 0; background: linear-gradient(0deg, rgba(5, 6, 7, 0.6), transparent); }

.sk__who { position: absolute; left: 16px; top: 14px; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 6px 10px; }
.sk__p1 { font-weight: 800; font-size: 1.05rem; letter-spacing: 0.04em; color: var(--p1); }
.sk__hp { width: clamp(70px, 12cqw, 130px); height: 5px; background: rgba(236, 230, 217, 0.18); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.sk__hp i { display: block; height: 100%; width: 100%; background: var(--amber); transition: width var(--d-fast) ease; }
.sk__who.is-down .sk__p1 { color: var(--flesh); }
.sk__who.is-down .sk__p1::after { content: ' down'; font-weight: 600; font-size: 0.8rem; letter-spacing: var(--track-prompt); text-transform: uppercase; }
.sk__state {
  grid-column: 1 / -1; display: inline-flex; align-items: center; gap: 6px; justify-self: start;
  font-weight: 700; font-size: 0.85rem; letter-spacing: var(--track-prompt); color: var(--ord, #9fd0ff);
}
.sk__state .sk__icon { width: 16px; height: 16px; }

.sk__obj { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); display: grid; justify-items: center; gap: 2px; }
.sk__obj-l { font-weight: 600; font-size: 0.75rem; letter-spacing: var(--track-eyebrow); text-transform: uppercase; color: var(--amber-hi); }
.sk__obj-v { font-weight: 800; font-size: clamp(1.4rem, 3.2cqw, 2.1rem); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
/* the game sets its FRENZY meter on a dark plate too: it sits below the HUD's shade, on the sand */
.sk__frenzy {
  --cut: 5px; display: inline-flex; align-items: center; gap: 8px; margin-top: 4px; padding: 3px 8px;
  font-weight: 600; font-size: 0.72rem; letter-spacing: var(--track-eyebrow); text-transform: uppercase; color: var(--flesh);
  background: rgba(5, 6, 7, 0.85); clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
}
.sk__frenzy i { width: clamp(80px, 14cqw, 160px); height: 4px; background: rgba(236, 230, 217, 0.16); }
.sk__frenzy b { display: block; height: 100%; width: 0; background: var(--flesh); box-shadow: 0 0 10px var(--flesh-glow); transition: width var(--d-med) linear; }

.sk__kills { position: absolute; right: 64px; top: 12px; display: grid; justify-items: end; gap: 0; }
.sk__kills span, .sk__troops span { font-weight: 600; font-size: 0.72rem; letter-spacing: var(--track-eyebrow); text-transform: uppercase; color: var(--bone-2); }
.sk__kills b { font-weight: 800; font-size: clamp(1.3rem, 2.6cqw, 1.8rem); line-height: 1; font-variant-numeric: tabular-nums; }
.sk__troops { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; align-items: baseline; gap: 8px; }
.sk__troops b { font-weight: 800; font-size: clamp(1.6rem, 3.4cqw, 2.4rem); line-height: 1; font-variant-numeric: tabular-nums; }

.sk__banner {
  position: absolute; left: 50%; top: 24%; z-index: 3; margin: 0; pointer-events: none; white-space: nowrap;
  font-family: var(--f-display); font-weight: 800; font-size: clamp(1.4rem, 4.4cqw, 3rem); letter-spacing: 0.04em; text-transform: uppercase;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.55), 0 0 24px rgba(0, 0, 0, 0.6);
  opacity: 0; transform: translate(-50%, 0) scale(0.96); transition: opacity var(--d-med) ease, transform var(--d-med) var(--ease-out);
}
.sk__banner.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- orders and support ---------- */
.sk__icon {
  display: inline-block; flex: none; width: 20px; height: 20px; background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
}
.sk__bar {
  position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 4; pointer-events: none;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 8px;
  opacity: 0; visibility: hidden; transition: opacity var(--d-med) var(--ease-out), visibility 0s linear var(--d-med);
}
.sk[data-state='play'] .sk__bar, .sk[data-state='paused'] .sk__bar { opacity: 1; visibility: visible; transition-delay: 0s; }
.sk__ords { display: flex; gap: 6px; }
.sk__ord, .sk__drop {
  --cut: 8px; position: relative; pointer-events: auto;
  display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 10px 0 9px;
  font-family: var(--f-display); font-weight: 700; font-size: 0.85rem; letter-spacing: var(--track-prompt); text-transform: uppercase;
  color: var(--ord); background: rgba(10, 12, 14, 0.86);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
  transition: background var(--d-fast) ease, box-shadow var(--d-fast) ease, transform var(--d-fast) var(--ease-out);
}
.sk__ord-l { color: var(--bone-2); transition: color var(--d-fast) ease; }
.sk__ord .key, .sk__drop .key { min-width: 22px; height: 22px; padding: 0 5px; font-size: 0.72rem; color: var(--bone-2); }
.sk__ord:hover, .sk__drop:hover { background: rgba(23, 27, 32, 0.9); }
.sk__ord:hover .sk__ord-l, .sk__drop:hover .sk__ord-l { color: var(--bone); }
.sk__ord:active, .sk__drop:active { transform: translateY(1px); }
/* the order in force: filled in its colour, a bar under it, the label lit */
.sk__ord[aria-pressed='true'] { background: color-mix(in srgb, var(--ord) 20%, rgba(10, 12, 14, 0.86)); box-shadow: inset 0 -3px 0 var(--ord); }
.sk__ord[aria-pressed='true']::after { --hc: color-mix(in srgb, var(--ord) 55%, transparent); }
.sk__ord[aria-pressed='true'] .sk__ord-l { color: var(--bone); }
/* one key switches the two orders: its chip sits on the one it would switch to */
.sk__ord[aria-pressed='true'] .key { visibility: hidden; }
/* focus: the hairline turns into a ring (the outline stays for forced colours) */
.sk__ord:focus-visible, .sk__drop:focus-visible { outline-color: transparent; outline-offset: -2px; }
.sk__ord:focus-visible::after, .sk__drop:focus-visible::after { --hw: 2px; --hc: var(--bone); }
.sk__drop { --ord: var(--amber); }
.sk__drop .sk__icon { width: 22px; height: 24px; }
.sk__cd { position: absolute; left: 0; bottom: 0; height: 3px; width: calc((1 - var(--cd, 0)) * 100%); background: var(--amber); transition: width 250ms linear; }
.sk__drop.is-cooling { color: var(--bone-4); }
.sk__drop.is-cooling .sk__ord-l { color: var(--bone-3); }
.sk__drop.is-cooling .sk__cd { background: var(--bone-3); }

.sk__pause {
  position: absolute; right: 12px; top: 12px; z-index: 6; display: grid; place-items: center; width: 40px; height: 40px;
  color: var(--bone-2); background: rgba(10, 12, 14, 0.6); box-shadow: inset 0 0 0 1px var(--line-2); border-radius: var(--r-2);
  opacity: 0; visibility: hidden; transition: opacity var(--d-med) var(--ease-out), visibility 0s linear var(--d-med), color var(--d-fast);
}
.sk__pause svg { width: 18px; height: 18px; }
.sk__pause:hover { color: var(--bone); }
.sk[data-state='play'] .sk__pause { opacity: 1; visibility: visible; transition-delay: 0s; }

/* ---------- panels: deploy, after-action, paused ---------- */
.sk__panel {
  position: absolute; inset: 0; z-index: 5; pointer-events: none;
  display: grid; place-content: center; justify-items: center; gap: 14px; padding: 56px 20px 64px; text-align: center;
}
.sk__panel[hidden] { display: none; }
.sk[data-state='loading'] .sk__panel, .sk[data-state='loading'] .sk__prompts { visibility: hidden; }
.sk__panel > * { pointer-events: auto; }
.sk__panel .eyebrow::after { display: none; }
.sk__panel .eyebrow { color: var(--bone-2); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8); }
.sk__panel .eyebrow b { margin-right: 4px; }
.sk__start > * { animation: sk-rise var(--d-slow) var(--ease-out) both; }
.sk__start > :nth-child(2) { animation-delay: 60ms; }
.sk__start > :nth-child(3) { animation-delay: 120ms; }
.sk__start > :nth-child(4) { animation-delay: 180ms; }
@keyframes sk-rise { from { opacity: 0; transform: translateY(12px); } }

.sk__deploy { min-height: 60px; padding: 0 22px 0 14px; font-size: clamp(1.15rem, 2.4cqw, 1.45rem); gap: 14px; filter: drop-shadow(0 0 1.2rem rgba(255, 177, 46, 0.28)); }
.sk__deploy:hover { filter: drop-shadow(0 0 1.4rem rgba(255, 177, 46, 0.45)); }
.sk__deploy::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.35) 50%, transparent 65%);
  transform: translateX(-120%); animation: sk-sheen 2.6s var(--ease-in-out) 1.2s infinite;
}
@keyframes sk-sheen { 0% { transform: translateX(-120%); } 45%, 100% { transform: translateX(120%); } }
.sk__enter { background: var(--amber-ink); color: var(--amber); border: 0; height: 24px; font-size: 0.72rem; }
.sk__goal { font-weight: 500; color: var(--bone); font-size: var(--t-body); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9); }

.sk__diff { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 4px; }
.sk__chip {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px;
  font-family: var(--f-display); font-weight: 700; font-size: 0.82rem; letter-spacing: var(--track-prompt); text-transform: uppercase;
  color: var(--bone-3); background: rgba(10, 12, 14, 0.72); box-shadow: inset 0 0 0 1px var(--line-2); border-radius: var(--r-1);
  transition: color var(--d-fast), background var(--d-fast), box-shadow var(--d-fast);
}
.sk__chip .meter { gap: 2px; }
.sk__chip .meter i { width: 6px; height: 3px; }
.sk__chip:hover { color: var(--bone); }
/* the pick: lit, with a bar under it like the order in force */
.sk__chip[aria-checked='true'] { color: var(--bone); background: rgba(255, 177, 46, 0.14); box-shadow: inset 0 0 0 1px rgba(255, 177, 46, 0.6), inset 0 -3px 0 var(--amber); }
/* the art did not load: Deploy retries, there is nothing to pick yet */
.sk[data-state='offline'] .sk__diff { visibility: hidden; }

.sk__prompts {
  position: absolute; left: 0; right: 0; bottom: 14px; z-index: 5; pointer-events: none;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; padding: 0 16px;
  opacity: 0; transition: opacity var(--d-med) var(--ease-out);
}
.sk[data-state='attract'] .sk__prompts { opacity: 1; }
.sk__prompts .prompt { color: var(--bone-2); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9); gap: 6px; }
.sk__prompts .key { background: rgba(10, 12, 14, 0.7); }
.key--pad { border-radius: 999px; min-width: 30px; }
.key--round { width: 26px; padding: 0; }
.sk__touch { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--bone-2); box-shadow: 0 0 0 4px rgba(236, 230, 217, 0.15); }

/* deploy: a column on the left like the game's title, the fight to its right */
.sk__start { place-content: center start; justify-items: start; text-align: left; padding-left: clamp(24px, 6cqw, 80px); gap: 16px; }
.sk__start .sk__diff { justify-content: flex-start; }
.sk__start .eyebrow { font-size: 0.8rem; }

/* after-action */
.sk__end { gap: 16px; }
.sk__stamp {
  --ink: var(--flesh);
  margin-bottom: 6px; padding: 2px 18px 0; color: var(--ink);
  font-family: var(--f-display); font-weight: 800; font-size: clamp(2.1rem, 7cqw, 4.4rem); line-height: 1; letter-spacing: 0.04em; text-transform: uppercase;
  border: 4px solid var(--ink); box-shadow: inset 0 0 0 2px rgba(5, 6, 7, 0.4), 0 0 0 2px rgba(5, 6, 7, 0.25);
  background: rgba(5, 6, 7, 0.35); text-shadow: 0 0 18px rgba(0, 0, 0, 0.4);
  transform: rotate(-8deg);
  animation: sk-stamp 520ms cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.sk__end.is-win .sk__stamp { --ink: var(--amber); }
@keyframes sk-stamp { from { opacity: 0; transform: scale(2.2) rotate(-30deg); } 40% { opacity: 1; } }
.sk__stats { display: flex; gap: clamp(16px, 4cqw, 44px); margin: 0; }
.sk__stats div { display: grid; gap: 2px; justify-items: center; }
.sk__stats dd { order: -1; margin: 0; font-family: var(--f-display); font-weight: 700; font-size: clamp(1.5rem, 3.4cqw, 2.2rem); line-height: 1; color: var(--bone); font-variant-numeric: tabular-nums; }
.sk__stats dt { font-size: var(--t-small); color: var(--bone-2); }
.sk__end-cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; }
.sk__end .sk__diff { margin-top: 0; }
.sk__end > * { animation: sk-rise var(--d-slow) var(--ease-out) both; }
.sk__end > .sk__stamp { animation: sk-stamp 520ms cubic-bezier(0.2, 1.4, 0.4, 1) both; }
.sk__end > :nth-child(2) { animation-delay: 260ms; }
.sk__end > :nth-child(3) { animation-delay: 340ms; }
.sk__end > :nth-child(4) { animation-delay: 420ms; }

.sk__paused-t { font-family: var(--f-display); font-weight: 800; font-size: clamp(1.8rem, 5cqw, 3rem); letter-spacing: 0.04em; text-transform: uppercase; line-height: 1; }

/* ---------- small stages (phones, narrow columns) ---------- */
@container (max-width: 760px) {
  .sk__ord-l { display: none; }
  .sk__ord, .sk__drop { padding: 0 8px; gap: 6px; }
  .sk__kills { right: 58px; }
  .sk__prompts { gap: 6px 14px; }
  .sk__prompts .prompt { font-size: 0.75rem; }
}
@container (max-width: 760px) {
  .sk[data-state='attract'] .sk__veil::after { background: linear-gradient(0deg, rgba(5, 6, 7, 0.82), rgba(5, 6, 7, 0.5) 42%, transparent 66%); }
  .sk__start { place-content: end center; justify-items: center; text-align: center; padding: 0 16px 76px; gap: 12px; }
  .sk__start .sk__diff { justify-content: center; }
  /* the mission name sits above the veil, on the fight: a plate under it */
  .sk__start .eyebrow { --cut: 6px; padding: 4px 10px; background: rgba(5, 6, 7, 0.7); clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut))); }
}
@container (max-width: 520px) {
  .sk__panel { gap: 10px; padding: 48px 14px 56px; }
  .sk__start { padding-bottom: 76px; }
  .sk__deploy { min-height: 54px; }
  .sk__who { left: 12px; top: 12px; gap: 4px 8px; }
  .sk__obj { top: 8px; }
  .sk__kills { right: 56px; top: 10px; }
  .sk__troops { bottom: 64px; }
  .sk__bar { left: 8px; right: 8px; bottom: 8px; gap: 6px; }
  .sk__ords { gap: 4px; flex: 1; }
  .sk__ord { flex: 1; justify-content: center; height: 46px; padding: 0 4px; }
  .sk__drop { height: 46px; padding: 0 10px; }
  .sk__ord .key { display: none; }
  .sk__diff { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: min(100%, 300px); }
  .sk__chip { height: 32px; padding: 0 9px; gap: 6px; font-size: 0.78rem; justify-content: center; }
  .sk__stats dt { font-size: 0.75rem; }
  .sk__stats { gap: 18px; }
}
.sk[data-input='touch'] .sk__ord .key, .sk[data-input='touch'] .sk__drop .key, .sk[data-input='touch'] .sk__enter { display: none; }
.sk[data-input='touch'] .sk__deploy { padding-left: 22px; }

@media (prefers-reduced-motion: reduce) {
  .sk__deploy::before { animation: none; display: none; }
  .sk__stamp, .sk__end > .sk__stamp { animation: none; }
}
/* the same when the visitor turns Motion off (lib/loop.js) */
:root[data-motion='off'] .sk__deploy::before { animation: none; display: none; }
:root[data-motion='off'] .sk__stamp, :root[data-motion='off'] .sk__end > .sk__stamp { animation: none; }
