/* SPDX-License-Identifier: LicenseRef-AGPL-3.0-only-OpenSSL */
/*
 * One controller as the app shows it on the game picture and in the OBS overlay: the PS5 skins
 * of CryptoPad (https://github.com/Crypto90/CryptoPad, MIT), the same pictures and the same
 * places as gui/res/overlay/cryptopad/static/custom.css + ps5-controller.css, here in one sheet.
 * js/pad.js builds the parts and says what is pressed.
 *
 * The drawing is 807 x 651. A box around it sets its size: --pad-w is the width in pixels,
 * without a unit, e.g.  .mine { --pad-w: 160; }
 *
 * The general design of the DualSense controller is the property of Sony Interactive Entertainment.
 * Vectorised DualSense design copyright (c) CrazyGrape 2021, Creative Commons Attribution 3.0
 * United States, https://creativecommons.org/licenses/by/3.0/us/
 */

.pad-box {
  --pad-w: 160;
  position: relative;
  width: calc(var(--pad-w) * 1px);
  height: calc(var(--pad-w) * 0.8067px); /* 651 / 807 */
  flex: none;
}

/*
 * Two pictures draw a controller: its look (img/pad/<look>.webp: the controller, 807 x 651, and
 * under it, from 653 down, its four buttons at rest and pressed) and the parts every look shares
 * (img/pad/parts.webp, one under the other: sticks 0, directions 102, triggers 235, bumpers 345,
 * touchpad 382, home button 561, Create and Options 603).
 */
.pad {
  --look: url("../img/pad/white.webp?v=e610b429bb");
  position: absolute;
  left: 0;
  top: 0;
  width: 807px;
  height: 651px;
  transform: scale(calc(var(--pad-w) / 807));
  transform-origin: 0 0;
  background: var(--look) no-repeat 0 0 / 807px 770px;
  pointer-events: none;
  user-select: none;
}

/* The looks of the film's four players, and the white one the app starts with */
.pad[data-skin="purple"] { --look: url("../img/pad/purple.webp?v=ae8c69164a"); }
.pad[data-skin="blue"] { --look: url("../img/pad/blue.webp?v=c1083fe268"); }
.pad[data-skin="teal"] { --look: url("../img/pad/teal.webp?v=207232e70f"); }
.pad[data-skin="pink"] { --look: url("../img/pad/pink.webp?v=2389598776"); }

.pad span {
  position: absolute;
  display: block;
  background: url("../img/pad/parts.webp?v=b2f6f65aa2") no-repeat 0 0 / 333px 662px;
}

/* The triggers fill with how far they are pulled */
.pad .trigger {
  top: 0;
  width: 111px;
  height: 108px;
  background-position: 0 -235px;
  opacity: 0;
}
.pad .trigger.left { left: 94px; }
.pad .trigger.right { left: 602px; background-position: -113px -235px; }

.pad .bumper {
  top: 114px;
  width: 110px;
  height: 35px;
  background-position: 0 -345px;
  opacity: 0;
}
.pad .bumper.left { left: 93px; }
.pad .bumper.right { left: 603px; transform: scaleX(-1); }
.pad .bumper.pressed { opacity: 1; }

.pad .touchpad {
  left: 237px;
  top: 118px;
  width: 333px;
  height: 177px;
  background-position: 0 -382px;
  opacity: 0;
}
.pad .touchpad.pressed { opacity: 1; }

.pad .meta {
  left: 382px;
  top: 355px;
  width: 42px;
  height: 42px;
  background-position: -4.5px -560px;
  opacity: 0;
}
.pad .meta.pressed { opacity: 1; }

/* Create and Options, left and right of the touchpad */
.pad .back,
.pad .start {
  top: 140px;
  width: 27px;
  height: 57px;
  background-position: 0 -603px;
  opacity: 0;
}
.pad .back { left: 195px; }
.pad .start { left: 584px; background-position: -28px -603px; }
.pad .back.pressed,
.pad .start.pressed { opacity: 1; }

/* The four face buttons come from the look's picture: at rest, and pressed in the row below */
.pad .button {
  width: 58px;
  height: 58px;
  background: var(--look) no-repeat 0 -653px / 807px 770px;
}
.pad .button.a { left: 634px; top: 301px; background-position: 0 -653px; }
.pad .button.b { left: 696px; top: 240px; background-position: -59px -653px; }
.pad .button.x { left: 573px; top: 239px; background-position: -118px -653px; }
.pad .button.y { left: 634px; top: 178px; background-position: -177px -653px; }
.pad .button.a.pressed { background-position: 0 -712px; }
.pad .button.b.pressed { background-position: -59px -712px; }
.pad .button.x.pressed { background-position: -118px -712px; }
.pad .button.y.pressed { background-position: -177px -712px; }

.pad .stick {
  top: 333px;
  width: 100px;
  height: 100px;
  background-position: 0 0;
  will-change: transform;
}
.pad .stick.left { left: 220px; }
.pad .stick.right { left: 487px; }
.pad .stick.pressed { background-position: -102px 0; }

/* The four directions: nothing at rest, a lit piece when pressed */
.pad .face {
  opacity: 0;
}
.pad .face.pressed { opacity: 1; }
.pad .face.up { left: 117px; top: 196px; width: 52px; height: 63px; background-position: 0 -170px; }
.pad .face.down { left: 117px; top: 277px; width: 52px; height: 63px; background-position: -54px -170px; }
.pad .face.left { left: 70px; top: 243px; width: 64px; height: 52px; background-position: -108px -170px; }
.pad .face.right { left: 152px; top: 242px; width: 63px; height: 52px; background-position: -175px -170px; }
