/*
 * Aimsmith's public pages, built on IBM's Carbon Design System in its Gray 100 theme, as
 * the app is. Carbon's own stylesheet and the app's tokens (carbon/styles.min.css and
 * carbon/tokens.css, copied in by package.ps1) give every colour, size, space and
 * component; this file lays the pages out and draws what is Aimsmith's own: the drill
 * room, the readouts, the runs and the ladder. Blue 60 is the one accent, and it means
 * "this responds"; the room's colours and the ranks' are the game's own tokens.
 */

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url("fonts/IBMPlexSans-Light.ttf") format("truetype");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/IBMPlexSans-Regular.ttf") format("truetype");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/IBMPlexSans-SemiBold.ttf") format("truetype");
}

:root {
  /* Carbon's two largest spacing steps. tokens.css stops at spacing-10, which is all the
     app needs, and Carbon sets these only inside its own components. */
  --cds-spacing-11: 5rem;
  --cds-spacing-12: 6rem;
  /* The bar on top, which the first screen shares with the room. */
  --as-top: 3rem;
  /* Carbon's expressive entrance: the one movement on the page, as it opens. */
  --as-enter: cubic-bezier(0, 0, 0.3, 1);
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--cds-background);
  color: var(--cds-text-primary);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: var(--cds-body-02-font-size);
  line-height: var(--cds-body-02-line-height);
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-inline-size: 100%;
  block-size: auto;
}

p,
dl,
dd,
figure {
  margin: 0;
}

/* ------------------------------------------------------------------ The bar on top */

.as-top {
  position: relative;
  z-index: 2;
  background: var(--cds-background);
  border-block-end: 1px solid var(--cds-border-subtle-01);
}

.as-top__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  block-size: var(--as-top);
}

.as-brand {
  display: flex;
  align-items: center;
  gap: var(--cds-spacing-03);
  color: var(--cds-text-primary);
  font-size: var(--cds-body-compact-01-font-size);
  font-weight: 600;
  text-decoration: none;
}

.as-nav {
  display: flex;
  margin: 0;
  padding: 0;
  gap: var(--cds-spacing-06);
  list-style: none;
}

.as-nav a {
  color: var(--cds-text-secondary);
  font-size: var(--cds-body-compact-01-font-size);
  text-decoration: none;
}

.as-nav a:hover {
  color: var(--cds-text-primary);
}

.as-brand:focus-visible,
.as-nav a:focus-visible {
  outline: 2px solid var(--cds-focus);
  outline-offset: 2px;
}

/* The section links leave the bar on a phone; the brand and Privacy stay. */
@media (max-width: 41.98rem) {
  .as-nav__section {
    display: none;
  }
}

/* ------------------------------------------------------------------------ Type */

.as-eyebrow {
  color: var(--cds-text-secondary);
  font-size: var(--cds-body-compact-01-font-size);
}

.as-display {
  max-inline-size: 12em;
  margin: var(--cds-spacing-05) 0 var(--cds-spacing-06);
  font-size: clamp(2.625rem, 1.3rem + 3.6vw, 5rem);
  font-weight: 300;
  line-height: 1.05;
  letter-spacing: -0.015em;
}

.as-lead {
  max-inline-size: 32rem;
  color: var(--cds-text-secondary);
  font-size: 1.25rem;
  line-height: 1.45;
}

.as-heading {
  max-inline-size: 14em;
  margin: var(--cds-spacing-05) 0 var(--cds-spacing-06);
  font-size: clamp(2rem, 1.3rem + 2vw, var(--cds-heading-07-font-size));
  font-weight: 300;
  line-height: 1.15;
}

.as-body {
  max-inline-size: 34rem;
  color: var(--cds-text-secondary);
}

.as-body + .as-body {
  margin-block-start: var(--cds-spacing-05);
}

.as-body strong {
  color: var(--cds-text-primary);
  font-weight: 400;
}

/* Two Carbon buttons side by side, each as wide as its words (a ButtonSet would cap them
   at 12.25rem and break "Request early access" over two lines). */
.as-actions {
  display: flex;
  flex-wrap: wrap;
  margin-block-start: var(--cds-spacing-08);
  gap: 1px;
}

/* -------------------------------------------------------------- The drill room */

/*
 * The first screen is the room a drill is played in: the wall's two-metre grid, its
 * upright lines running on across the floor, figures, the game's readouts along the
 * top, and the game's green crosshair. The crosshair flicks onto a figure once as the
 * page opens, overshoots a little, settles, and the hit is marked: what Aimsmith
 * measures, played once. A crosshair is the pointer over the room.
 */
.as-hero {
  position: relative;
  display: grid;
  overflow: hidden;
  grid-template-rows: auto 1fr;
  min-block-size: calc(100svh - var(--as-top) - 1px);
  background: var(--as-arena-wall);
  cursor: url("cursor.png") 16 16, crosshair;
}

.as-hero a {
  cursor: pointer;
}

.as-room {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
}

.as-room__wall {
  fill: var(--as-arena-wall);
}

.as-room__floor {
  fill: var(--as-arena-floor);
}

.as-room__lines {
  fill: none;
  stroke: var(--as-arena-line);
  stroke-width: 1.5;
}

.as-room__bot {
  fill: var(--as-arena-bot);
}

.as-room__crosshair {
  fill: var(--as-arena-accurate);
  stroke: var(--as-arena-accurate);
  stroke-width: 3;
  animation: as-flick 900ms cubic-bezier(0.2, 0.8, 0.2, 1) 300ms both;
}

.as-room__hit {
  fill: none;
  stroke: var(--as-arena-hit-mark);
  stroke-width: 3;
  animation: as-hit 600ms ease-out 1100ms both;
}

/* From well off the figure, past it by a little, and back: a flick with its overshoot. */
@keyframes as-flick {
  0% {
    transform: translate(-260px, 150px);
  }

  70% {
    transform: translate(9px, -5px);
  }

  100% {
    transform: translate(0, 0);
  }
}

@keyframes as-hit {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }

  40% {
    opacity: 1;
    transform: scale(1);
  }

  100% {
    opacity: 0.85;
  }
}

/* The game's readouts: a small label over a larger value, along the top of the room. */
.as-hud {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  padding-block-start: var(--cds-spacing-06);
  gap: var(--cds-spacing-09);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.as-hud dt {
  color: var(--as-arena-readout-label);
  font-size: 0.75rem;
}

.as-hud dd {
  color: var(--as-arena-readout);
  font-size: 1.25rem;
  line-height: 1.3;
}

.as-hero__grid {
  position: relative;
  align-self: center;
  padding-block: var(--cds-spacing-09) var(--cds-spacing-12);
}

.as-hero__text {
  animation: as-enter 700ms var(--as-enter) both;
}

@keyframes as-enter {
  from {
    opacity: 0;
    transform: translateY(var(--cds-spacing-05));
  }
}

@media (max-width: 41.98rem) {
  .as-hud {
    gap: var(--cds-spacing-06);
  }
}

@media (prefers-reduced-motion: reduce) {
  .as-hero__text,
  .as-room__crosshair,
  .as-room__hit {
    animation: none;
  }
}

/* ---------------------------------------------------------------- The runs */

.as-section {
  padding-block: var(--cds-spacing-12) var(--cds-spacing-11);
  border-block-start: 1px solid var(--cds-border-subtle-01);
}

.as-split__text {
  align-self: center;
}

/* Below the large breakpoint the picture follows the words. */
@media (max-width: 65.98rem) {
  .as-split__visual {
    margin-block-start: var(--cds-spacing-08);
  }
}

/* A screenshot of the real app or game, with an edge where its dark meets the page's. */
.as-shot {
  inline-size: 100%;
  border: 1px solid var(--cds-border-subtle-01);
}

/* "Run 3 of 6": each section is a run of the page's session, as the game's brief says. */
.as-run {
  display: flex;
  align-items: center;
  gap: var(--cds-spacing-04);
  color: var(--cds-text-secondary);
  font-size: var(--cds-body-compact-01-font-size);
  font-variant-numeric: tabular-nums;
}

.as-run__steps {
  display: flex;
  gap: 2px;
}

.as-run__steps span {
  inline-size: 1rem;
  block-size: 0.25rem;
  background: var(--cds-border-subtle-01);
}

.as-run__steps--1 span:nth-child(-n + 1),
.as-run__steps--2 span:nth-child(-n + 2),
.as-run__steps--3 span:nth-child(-n + 3),
.as-run__steps--4 span:nth-child(-n + 4),
.as-run__steps--5 span:nth-child(-n + 5),
.as-run__steps--6 span:nth-child(-n + 6) {
  background: var(--cds-interactive);
}

/* ------------------------------------------------------------------ The ladder */

/*
 * Every score is a rating on one scale. The ruler runs from 0 to 2,300, the score of a
 * scripted player at the edge of what a person can do, so each rank stands at its
 * threshold over 2,300, in its own colour, with its name beside it.
 */
.as-ladder {
  margin-block-start: var(--cds-spacing-11);
}

.as-ladder__ruler {
  position: relative;
  block-size: var(--cds-spacing-07);
  border-block-end: 1px solid var(--cds-border-strong-01);
  /* A tick at every hundred. */
  background-image: linear-gradient(to right, var(--cds-border-subtle-01) 1px, transparent 1px);
  background-position: 0 100%;
  background-repeat: repeat-x;
  background-size: calc(100% / 23) 0.5rem;
}

.as-ladder__band {
  position: absolute;
  inset-block-end: 0;
  block-size: 0.375rem;
}

.as-ladder__band--bronze {
  inset-inline: calc(500 / 2300 * 100%) calc(100% - 700 / 2300 * 100%);
  background: var(--as-rank-bronze);
}

.as-ladder__band--silver {
  inset-inline: calc(700 / 2300 * 100%) calc(100% - 1000 / 2300 * 100%);
  background: var(--as-rank-silver);
}

.as-ladder__band--gold {
  inset-inline: calc(1000 / 2300 * 100%) calc(100% - 1250 / 2300 * 100%);
  background: var(--as-rank-gold);
}

.as-ladder__band--platinum {
  inset-inline: calc(1250 / 2300 * 100%) calc(100% - 1500 / 2300 * 100%);
  background: var(--as-rank-platinum);
}

.as-ladder__band--diamond {
  inset-inline: calc(1500 / 2300 * 100%) calc(100% - 1800 / 2300 * 100%);
  background: var(--as-rank-diamond);
}

.as-ladder__band--master {
  inset-inline: calc(1800 / 2300 * 100%) calc(100% - 2100 / 2300 * 100%);
  background: var(--as-rank-master);
}

.as-ladder__band--grandmaster {
  inset-inline: calc(2100 / 2300 * 100%) 0;
  background: var(--as-rank-grandmaster);
}

/* The drill's reference player, at 1,000. */
.as-ladder__reference {
  position: absolute;
  inset-block: 0;
  inset-inline-start: calc(1000 / 2300 * 100%);
  border-inline-start: 1px dashed var(--cds-text-secondary);
}

.as-ladder__ranks {
  position: relative;
  block-size: 3.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.as-ladder__rank {
  position: absolute;
  inset-block-start: var(--cds-spacing-03);
  color: var(--cds-text-secondary);
  font-size: var(--cds-body-compact-01-font-size);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.as-ladder__rank span {
  display: block;
  color: var(--cds-text-primary);
}

.as-ladder__rank--bronze {
  inset-inline-start: calc(500 / 2300 * 100%);
}

.as-ladder__rank--silver {
  inset-inline-start: calc(700 / 2300 * 100%);
}

.as-ladder__rank--gold {
  inset-inline-start: calc(1000 / 2300 * 100%);
}

.as-ladder__rank--platinum {
  inset-inline-start: calc(1250 / 2300 * 100%);
}

.as-ladder__rank--diamond {
  inset-inline-start: calc(1500 / 2300 * 100%);
}

.as-ladder__rank--master {
  inset-inline-start: calc(1800 / 2300 * 100%);
}

.as-ladder__rank--grandmaster {
  inset-inline-start: calc(2100 / 2300 * 100%);
}

.as-ladder__caption {
  max-inline-size: 40rem;
  margin-block-start: var(--cds-spacing-05);
  color: var(--cds-text-secondary);
  font-size: var(--cds-body-compact-01-font-size);
}

/* Too narrow for names along a ruler: the ranks become a list, each with its colour. */
@media (max-width: 65.98rem) {
  .as-ladder__ranks {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
    block-size: auto;
    margin-block-start: var(--cds-spacing-05);
    gap: var(--cds-spacing-04);
  }

  .as-ladder__rank {
    position: static;
    padding-inline-start: var(--cds-spacing-03);
    border-inline-start: 0.25rem solid;
  }

  .as-ladder__rank--bronze {
    border-color: var(--as-rank-bronze);
  }

  .as-ladder__rank--silver {
    border-color: var(--as-rank-silver);
  }

  .as-ladder__rank--gold {
    border-color: var(--as-rank-gold);
  }

  .as-ladder__rank--platinum {
    border-color: var(--as-rank-platinum);
  }

  .as-ladder__rank--diamond {
    border-color: var(--as-rank-diamond);
  }

  .as-ladder__rank--master {
    border-color: var(--as-rank-master);
  }

  .as-ladder__rank--grandmaster {
    border-color: var(--as-rank-grandmaster);
  }
}

/* ------------------------------------------------------------------ The layers */

.as-layers {
  margin-block-start: var(--cds-spacing-09);
}

.as-layer {
  block-size: 100%;
  padding: var(--cds-spacing-06);
}

.as-layer__index {
  margin-block-end: var(--cds-spacing-07);
  color: var(--cds-text-secondary);
  font-size: var(--cds-body-compact-01-font-size);
  font-variant-numeric: tabular-nums;
}

.as-layer__name {
  margin: 0 0 var(--cds-spacing-02);
  font-size: var(--cds-heading-05-font-size);
  font-weight: 300;
  line-height: var(--cds-heading-05-line-height);
}

.as-layer__adds {
  margin-block-end: var(--cds-spacing-06);
  color: var(--cds-text-secondary);
}

.as-layer__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.as-layer__list li {
  padding-block: var(--cds-spacing-03);
  border-block-start: 1px solid var(--cds-border-subtle-01);
  font-size: var(--cds-body-compact-01-font-size);
}

.as-layer__count {
  margin-block-start: var(--cds-spacing-06);
  color: var(--cds-text-secondary);
  font-size: var(--cds-body-compact-01-font-size);
}

/* ------------------------------------------------------------------- Your data */

.as-facts {
  margin: 0;
  padding: 0;
  list-style: none;
}

.as-facts li {
  padding-block: var(--cds-spacing-06);
  border-block-start: 1px solid var(--cds-border-subtle-01);
}

.as-facts li:last-child {
  border-block-end: 1px solid var(--cds-border-subtle-01);
}

.as-fact__title {
  margin-block-end: var(--cds-spacing-02);
  font-size: 1.25rem;
  line-height: 1.4;
}

.as-fact__text {
  color: var(--cds-text-secondary);
}

.as-more {
  display: inline-block;
  margin-block-start: var(--cds-spacing-07);
}

/* ----------------------------------------------------------------- The summary */

/* The page ends on the game's session summary: a Carbon dialog, with its tall buttons. */
.as-close {
  padding-block: var(--cds-spacing-12);
  background: var(--as-arena-floor);
  border-block-start: 1px solid var(--cds-border-subtle-01);
}

.as-summary {
  background: var(--cds-layer-01);
}

.as-summary__body {
  padding: var(--cds-spacing-07) var(--cds-spacing-07) var(--cds-spacing-09);
}

.as-summary__title {
  margin: var(--cds-spacing-02) 0 var(--cds-spacing-07);
  font-size: var(--cds-heading-05-font-size);
  font-weight: 400;
  line-height: var(--cds-heading-05-line-height);
}

.as-summary__rows div {
  display: flex;
  justify-content: space-between;
  padding-block: var(--cds-spacing-02);
  gap: var(--cds-spacing-07);
}

.as-summary__rows dt {
  color: var(--cds-text-secondary);
}

.as-summary__rows dd {
  text-align: end;
}

.as-summary__foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.as-summary__foot .cds--btn {
  max-inline-size: none;
  inline-size: 100%;
  align-items: flex-start;
}

@media (max-width: 41.98rem) {
  .as-summary__rows div {
    display: block;
  }

  .as-summary__rows dd {
    text-align: start;
  }
}

/* ---------------------------------------------------------------------- Footer */

.as-foot {
  padding-block: var(--cds-spacing-09) var(--cds-spacing-10);
  border-block-start: 1px solid var(--cds-border-subtle-01);
  color: var(--cds-text-secondary);
  font-size: var(--cds-body-compact-01-font-size);
}

.as-foot__links {
  display: flex;
  flex-wrap: wrap;
  margin: var(--cds-spacing-05) 0 var(--cds-spacing-07);
  padding: 0;
  gap: var(--cds-spacing-06);
  list-style: none;
}

.as-foot__legal {
  max-inline-size: 48rem;
}

.as-foot__legal + .as-foot__legal {
  margin-block-start: var(--cds-spacing-03);
}

/* ---------------------------------------------------------------- Privacy page */

.as-doc {
  padding-block: var(--cds-spacing-10) var(--cds-spacing-12);
}

.as-doc h2 {
  margin: var(--cds-spacing-10) 0 var(--cds-spacing-05);
  font-size: var(--cds-heading-04-font-size);
  font-weight: 400;
  line-height: var(--cds-heading-04-line-height);
}

.as-doc p,
.as-doc li {
  max-inline-size: 42rem;
  color: var(--cds-text-secondary);
}

.as-doc p + p {
  margin-block-start: var(--cds-spacing-05);
}

.as-doc ul {
  margin: 0;
  padding-inline-start: var(--cds-spacing-06);
}

.as-doc li + li {
  margin-block-start: var(--cds-spacing-03);
}

.as-doc code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.875em;
}

/* Carbon's structured list holds the rows of what leaves the computer; a phone reads each
   row as a block, with its column names above the values. */
.as-doc .cds--structured-list {
  margin-block: var(--cds-spacing-06);
}

@media (max-width: 41.98rem) {
  .as-doc .cds--structured-list,
  .as-doc .cds--structured-list-tbody,
  .as-doc .cds--structured-list-row,
  .as-doc .cds--structured-list-td {
    display: block;
  }

  .as-doc .cds--structured-list-thead {
    display: none;
  }

  .as-doc .cds--structured-list-row {
    padding-block: var(--cds-spacing-04);
  }

  /* As specific as Carbon's first-column padding, which a stacked row does not want. */
  .as-doc .cds--structured-list .cds--structured-list-row .cds--structured-list-td {
    padding: var(--cds-spacing-02) 0;
  }

  .as-doc .cds--structured-list-td::before {
    display: block;
    color: var(--cds-text-helper);
    content: attr(data-label);
    font-size: 0.75rem;
  }
}
