/* Fortnite Chest Counter: one stylesheet for / and /fr/ */

@font-face {
  font-family: "BS Stencil";
  src: url("/assets/fonts/stencil-900.woff2") format("woff2");
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "BS Display";
  src: url("/assets/fonts/display-800.woff2") format("woff2");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --abyss: #0b2230;     /* page */
  --deck: #0f2a38;      /* quiet panels */
  --hull: #12313f;      /* the counter card */
  --kelp: #2b5566;      /* lines, outlines, ghost marks */
  --sail: #f4ecdd;      /* text, tally strokes */
  --fog: #9db4bd;       /* secondary text */
  --gold: #f4b53f;      /* the +1 action, unlocked badges, the token */
  --gold-deep: #b9800f;
  --coral: #ff6a55;     /* every fifth tally stroke */
  --stencil: "BS Stencil", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  --display: "BS Display", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--abyss);
  color: var(--sail);
  font: 400 1rem/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--gold);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--sail);
}

button {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.vh {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.wrap {
  width: min(100% - 32px, 1060px);
  margin-inline: auto;
}

/* Header */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 4px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--fog);
  font-size: 0.9rem;
  text-decoration: none;
}

.brand:hover {
  color: var(--sail);
}

.brand svg {
  flex: none;
  width: 28px;
  height: 28px;
}

.lang {
  display: flex;
  flex: none;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--kelp);
  border-radius: 999px;
}

.lang a {
  min-width: 40px;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--fog);
  font: 800 0.85rem/1.2 var(--display);
  letter-spacing: 0.08em;
  text-align: center;
  text-decoration: none;
}

.lang a:hover {
  color: var(--sail);
}

.lang a[aria-current="page"] {
  background: var(--sail);
  color: var(--abyss);
}

/* Intro */

.intro {
  padding: 12px 0 16px;
}

.intro h1 {
  margin: 0;
  font: 900 clamp(2.6rem, 11.5vw, 4.4rem)/0.86 var(--stencil);
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.lede {
  max-width: 40ch;
  margin: 12px 0 0;
  color: var(--fog);
}

.noscript {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--coral);
  color: var(--abyss);
  font-weight: 700;
}

/* Layout */

.layout {
  display: grid;
  gap: 16px;
}

.side {
  display: grid;
  gap: 16px;
}

/* Counter card */

.counter {
  padding: 18px 16px 16px;
  border: 1px solid var(--kelp);
  border-radius: 24px;
  background: var(--hull);
  -webkit-user-select: none;
  user-select: none;
}

.counter-label {
  margin: 0;
  color: var(--fog);
  font: 800 0.8rem/1 var(--display);
  letter-spacing: 0.18em;
  text-align: center;
  text-transform: uppercase;
}

.count {
  display: block;
  margin: 8px 0 0;
  color: var(--sail);
  font: 900 clamp(7.5rem, 40vw, 11.5rem)/0.84 var(--stencil);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.count.bump {
  animation: bump 0.18s ease-out;
}

@keyframes bump {
  from {
    transform: scale(1.07);
  }
  to {
    transform: scale(1);
  }
}

.tally {
  height: 52px;
  margin: 12px 0 18px;
}

.tally svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.tally path {
  fill: none;
  stroke: var(--sail);
  stroke-width: 3.4;
  stroke-linecap: round;
}

.tally .slash {
  stroke: var(--coral);
}

.tally .ghost {
  stroke: var(--kelp);
}

.tally .new {
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
  animation: draw 0.24s ease-out forwards;
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

.plus {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  min-height: 120px;
  padding: 12px;
  border: 0;
  border-radius: 20px;
  background: var(--gold);
  box-shadow: 0 7px 0 var(--gold-deep);
  color: var(--abyss);
  cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}

.plus-main {
  font: 800 2.8rem/1 var(--display);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.plus-hint {
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 0.72;
}

.plus:active,
.plus.pressed {
  box-shadow: 0 2px 0 var(--gold-deep);
  transform: translateY(5px);
}

@media (hover: hover) {
  .plus:hover {
    filter: brightness(1.06);
  }
}

@media (hover: none), (pointer: coarse) {
  .plus-hint {
    display: none;
  }
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.btn {
  min-height: 52px;
  padding: 10px 12px;
  border: 1.5px solid var(--kelp);
  border-radius: 14px;
  background: transparent;
  color: var(--sail);
  font: 800 1.05rem/1.1 var(--display);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  border-color: var(--fog);
}

.btn:disabled {
  cursor: default;
  opacity: 0.38;
}

.btn-gold {
  border-color: var(--gold);
  background: var(--gold);
  color: var(--abyss);
}

.btn-gold:hover:not(:disabled) {
  border-color: var(--gold);
  filter: brightness(1.06);
}

/* Panels */

.panel {
  padding: 18px 16px;
  border-radius: 20px;
  background: var(--deck);
}

.panel h2 {
  margin: 0 0 12px;
  font: 800 1.15rem/1.1 var(--display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.panel p {
  margin: 0;
}

.muted {
  color: var(--fog);
}

.fine {
  margin-top: 10px;
  color: var(--fog);
  font-size: 0.88rem;
}

.panel .fine {
  margin-top: 10px;
}

/* Stats */

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.stats div {
  padding: 10px 6px 10px;
  border-radius: 14px;
  background: var(--abyss);
  text-align: center;
}

.stats dt {
  color: var(--fog);
  font: 800 0.72rem/1.2 var(--display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stats dd {
  margin: 6px 0 0;
  font: 900 2.3rem/1 var(--stencil);
  font-variant-numeric: tabular-nums;
}

.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin-top: 10px;
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--fog);
  font-size: 0.92rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.link:hover {
  color: var(--sail);
}

.wake::before {
  content: "";
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.wake[aria-pressed="true"] {
  color: var(--gold);
}

.wake[aria-pressed="true"]::before {
  background: currentColor;
}

/* Badges */

.badge-next {
  color: var(--fog);
}

.badge-next b {
  color: var(--sail);
  font-weight: 700;
}

.bar {
  height: 10px;
  margin: 10px 0 16px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--abyss);
}

.bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--gold);
  transition: width 0.35s ease;
}

.badges {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.badges li {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 6px;
  text-align: center;
}

.coin {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 46px;
  aspect-ratio: 1;
  border: 2px solid var(--kelp);
  border-radius: 50%;
  color: var(--fog);
  font: 800 0.92rem/1 var(--display);
}

.badges .got .coin {
  border-color: var(--gold-deep);
  background: var(--gold);
  color: var(--abyss);
}

.badges .fresh .coin {
  animation: pop 0.5s ease-out;
}

@keyframes pop {
  0% {
    transform: scale(0.6);
  }
  60% {
    transform: scale(1.18);
  }
  100% {
    transform: scale(1);
  }
}

.badge-name {
  color: var(--fog);
  font-size: 0.68rem;
  line-height: 1.2;
}

.badges .got .badge-name {
  color: var(--sail);
}

@media (max-width: 559px) {
  .badge-name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* Odds */

.odds-figure {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  margin-bottom: 10px;
}

.odds-figure strong {
  color: var(--gold);
  font: 900 2.7rem/1 var(--stencil);
  font-variant-numeric: tabular-nums;
}

.odds-figure span {
  color: var(--fog);
}

/* Guide + FAQ */

.guide {
  max-width: 760px;
  margin: 56px auto 0;
}

.guide h2 {
  margin: 0 0 16px;
  font: 800 clamp(1.5rem, 5vw, 1.9rem)/1.1 var(--display);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.steps {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  align-items: start;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid var(--kelp);
  border-radius: 50%;
  color: var(--gold);
  font: 800 1rem/1 var(--display);
}

.faq {
  margin-top: 48px;
}

.faq details {
  border-bottom: 1px solid var(--kelp);
}

.faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  cursor: pointer;
  list-style: none;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: "+";
  flex: none;
  color: var(--gold);
  font: 800 1.6rem/1 var(--display);
  transition: transform 0.2s ease;
}

.faq details[open] summary::after {
  transform: rotate(45deg);
}

.faq h3 {
  margin: 0;
  font: 650 1.05rem/1.4 var(--body);
}

.faq details p {
  max-width: 66ch;
  margin: 0 0 18px;
  color: var(--fog);
}

/* Footer */

.foot {
  margin-top: 64px;
  padding: 24px 0 36px;
  border-top: 1px solid var(--kelp);
  color: var(--fog);
  font-size: 0.88rem;
}

.foot p {
  margin: 0 0 8px;
}

.foot a {
  color: var(--sail);
}

/* Toast */

.toast {
  position: fixed;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--sail);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.35);
  color: var(--abyss);
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.toast button {
  flex: none;
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--abyss);
  font-weight: 800;
  text-decoration: underline;
  cursor: pointer;
}

/* Badge unlock sparks */

.spark {
  position: fixed;
  z-index: 30;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--gold);
  pointer-events: none;
  animation: spark 0.8s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

.spark.coral {
  background: var(--coral);
}

.spark.sail {
  border-radius: 2px;
  background: var(--sail);
}

@keyframes spark {
  to {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) rotate(var(--r));
  }
}

/* Edit dialog */

dialog {
  width: min(100% - 32px, 420px);
  padding: 22px 20px 16px;
  border: 1px solid var(--kelp);
  border-radius: 22px;
  background: var(--hull);
  color: var(--sail);
}

dialog::backdrop {
  background: rgb(4 14 20 / 0.72);
}

dialog h2 {
  margin: 0 0 8px;
  font: 800 1.3rem/1.1 var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

dialog p {
  margin: 0 0 16px;
  color: var(--fog);
  font-size: 0.92rem;
}

dialog label {
  display: block;
  margin-bottom: 6px;
  color: var(--fog);
  font: 800 0.8rem/1 var(--display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

dialog input {
  width: 100%;
  min-height: 56px;
  padding: 8px 14px;
  border: 1.5px solid var(--kelp);
  border-radius: 14px;
  background: var(--abyss);
  color: var(--sail);
  font: 900 2rem/1 var(--stencil);
}

dialog .pair {
  margin-top: 16px;
}

.danger {
  margin-top: 8px;
  color: var(--coral);
}

.danger:hover {
  color: var(--coral);
}

/* 404 */

.lost {
  max-width: 560px;
  padding: 48px 0 8px;
}

.lost .eyebrow {
  margin: 0;
  color: var(--coral);
  font: 800 1rem/1 var(--display);
  letter-spacing: 0.18em;
}

.lost h1 {
  margin: 10px 0 14px;
  font: 900 clamp(2.6rem, 11.5vw, 4.4rem)/0.86 var(--stencil);
  text-transform: uppercase;
}

.lost p {
  margin: 0 0 22px;
  color: var(--fog);
}

.lost .fine {
  margin-top: 20px;
}

a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

a.btn-gold:hover {
  color: var(--abyss);
}

/* Larger screens */

@media (min-width: 560px) {
  .counter {
    padding: 24px 24px 22px;
  }

  .panel {
    padding: 22px;
  }
}

@media (min-width: 920px) {
  .intro {
    padding: 28px 0 24px;
  }

  .lede {
    font-size: 1.08rem;
  }

  .layout {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: 24px;
    align-items: start;
  }

  .counter {
    position: sticky;
    top: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .tally .new {
    stroke-dasharray: none;
  }
}
