/* Rage Wars: a rage comic that got hold of a stock ticker. */

@font-face {
  font-family: "Bowlby One";
  src: url("assets/fonts/bowlby-one-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Comic Neue";
  src: url("assets/fonts/comic-neue-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Comic Neue";
  src: url("assets/fonts/comic-neue-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --paper: #ffffff;
  --ink: #000000;
  --bnb: #f0b90b;
  --sol: #9945ff;
  --rage: #e5322d;
  --wash: #f4f4f4;

  --display: "Bowlby One", "Arial Black", Impact, sans-serif;
  --body: "Comic Neue", "Comic Sans MS", "Chalkboard SE", sans-serif;

  --line: 4px solid var(--ink);
  /* Slightly lopsided corners, like a panel drawn by hand in MS Paint */
  --wobble: 14px 6px 12px 5px / 6px 12px 5px 14px;
  --gutter: clamp(14px, 3vw, 28px);
  --page: 1100px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.125rem;
  line-height: 1.55;
}

img { max-width: 100%; height: auto; display: block; }

a { color: inherit; }

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

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 12px;
  top: 12px;
  z-index: 10;
  background: var(--paper);
  padding: 8px 12px;
  border: var(--line);
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  max-width: var(--page);
  margin: 0 auto;
  padding: 14px var(--gutter);
}
.wordmark {
  font-family: var(--display);
  font-size: 1.6rem;
  text-decoration: none;
  letter-spacing: 0.02em;
}
.topbar nav {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-weight: 700;
}
.topbar nav a,
.social a { text-decoration: none; }
.topbar nav a:hover,
.social a:hover { text-decoration: underline; text-decoration-thickness: 3px; }
.social { margin-left: auto; display: flex; gap: 14px; font-weight: 700; }

/* ---------- The war (hero + live score) ---------- */

.war {
  max-width: var(--page);
  margin: 0 auto;
  padding: 8px var(--gutter) 28px;
}

.war h1 {
  font-family: var(--display);
  font-weight: 400;
  text-transform: uppercase;
  font-size: clamp(1.9rem, 5.6vw, 4rem);
  line-height: 1.02;
  letter-spacing: -0.01em;
  margin: 8px 0 22px;
  max-width: 17ch;
}
.scream-word { color: var(--rage); white-space: nowrap; }

.arena {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 0;
}

.side {
  border: var(--line);
  border-radius: var(--wobble);
  padding: clamp(12px, 2.5vw, 26px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 0;
}
.side-bnb { background: var(--bnb); }
.side-sol { background: var(--sol); color: var(--paper); }

.face-frame {
  width: min(100%, 220px);
  aspect-ratio: 400 / 440;
}
.face { width: 100%; height: 100%; }

.side-name {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.1rem, 2.6vw, 1.7rem);
  margin: 10px 0 2px;
}
.mcap {
  font-family: var(--display);
  font-size: clamp(1.5rem, 4.6vw, 3rem);
  line-height: 1.05;
  margin: 4px 0 0;
  font-variant-numeric: tabular-nums;
}
.change { margin: 2px 0 0; font-weight: 700; }
.verdict {
  margin: 10px 0 0;
  font-weight: 700;
  font-size: 1rem;
  border: 3px solid currentColor;
  border-radius: 999px;
  padding: 2px 14px;
}

.vs {
  align-self: center;
  font-family: var(--display);
  font-size: clamp(1.4rem, 4vw, 2.6rem);
  background: var(--paper);
  border: var(--line);
  border-radius: 50%;
  width: clamp(56px, 9vw, 96px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  margin: 0 -14px;
  position: relative;
  z-index: 1;
  transform: rotate(-8deg);
}

/* The losing side */
.side[data-result="losing"] .verdict {
  background: var(--rage);
  border-color: var(--ink);
  color: var(--paper);
}
.side[data-result="winning"] .verdict {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--ink);
}

/* The scream: giant red A's running under the losing side */
.scream-strip {
  font-family: var(--display);
  color: var(--rage);
  font-size: clamp(2.6rem, 10vw, 7.5rem);
  line-height: 1;
  margin: 14px 0 0;
  white-space: nowrap;
  overflow: hidden;
  min-height: 0.5em;
  -webkit-text-stroke: 2px var(--ink);
}
.scream-strip:empty { display: none; }
.scream-strip[data-loser="sol"] { text-align: right; }
.scream-strip[data-loser="both"] { text-align: center; }
.arena[data-state="prelaunch"] ~ .scream-strip {
  color: var(--ink);
  -webkit-text-stroke: 0;
  font-size: clamp(1.6rem, 5vw, 3.2rem);
  white-space: normal;
}

.lead-flash[hidden] { display: none; }
.lead-flash {
  font-family: var(--display);
  font-size: clamp(1.4rem, 4vw, 2.4rem);
  background: var(--ink);
  color: var(--paper);
  display: inline-block;
  padding: 6px 18px;
  margin: 12px 0 0;
  transform: rotate(-2deg);
}

.war-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 18px;
}
.war-status { margin: 0; font-weight: 700; max-width: 60ch; }
.war-actions { display: flex; gap: 12px; align-items: center; }

/* One deliberate motion: the loser shakes. */
@keyframes rage-shake {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  20% { transform: translate(-4px, 2px) rotate(-2deg); }
  40% { transform: translate(4px, -2px) rotate(2deg); }
  60% { transform: translate(-3px, -1px) rotate(-1deg); }
  80% { transform: translate(3px, 1px) rotate(1deg); }
}
.side[data-result="losing"] .face { animation: rage-shake 0.35s linear infinite; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .side[data-result="losing"] .face { animation: none; }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-block;
  font-family: var(--display);
  font-size: 1.05rem;
  text-decoration: none;
  border: var(--line);
  border-radius: 10px 4px 10px 4px;
  padding: 10px 20px;
  cursor: pointer;
  line-height: 1.1;
  color: var(--ink);
  background: var(--paper);
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(1px); }
.btn-bnb { background: var(--bnb); }
.btn-sol { background: var(--sol); color: var(--paper); }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
}

/* ---------- Sections ---------- */

.intro,
.fighters,
.howto,
.story,
.memes,
.faq {
  max-width: var(--page);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.intro {
  font-size: clamp(1.15rem, 2.2vw, 1.4rem);
  max-width: calc(46ch + 2 * var(--gutter));
  margin-top: 8px;
  margin-bottom: 40px;
}

.section-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  line-height: 1.1;
  margin: 0 0 16px;
}

.fighters,
.howto,
.memes,
.faq { margin-bottom: 56px; }

/* Fighters */
.fighter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gutter);
}
.fighter {
  border: var(--line);
  border-radius: var(--wobble);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.fighter-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: var(--line);
}
.fighter-bnb .fighter-head { background: var(--bnb); }
.fighter-sol .fighter-head { background: var(--sol); color: var(--paper); }
.fighter-head img { width: 52px; }
.fighter-head h3 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.6rem;
  margin: 0;
}
.fighter-bio { margin: 16px 18px 6px; font-size: 1.2rem; }
.fighter-facts { margin: 0 18px; display: grid; gap: 2px; }
.fighter-facts div { display: flex; gap: 8px; }
.fighter-facts dt { font-weight: 700; min-width: 7.5em; }
.fighter-facts dd { margin: 0; }

.address {
  margin: 16px 18px 0;
  display: flex;
  gap: 8px;
  align-items: stretch;
  flex-wrap: wrap;
}
.address code {
  flex: 1 1 14em;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.95rem;
  background: var(--wash);
  border: 3px dashed var(--ink);
  border-radius: 6px;
  padding: 8px 10px;
}
.copy {
  font-family: var(--body);
  font-weight: 700;
  font-size: 1rem;
  border: 3px solid var(--ink);
  border-radius: 6px;
  background: var(--paper);
  padding: 6px 12px;
  cursor: pointer;
}
.copy:disabled { opacity: 0.45; cursor: default; }
.fighter-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 18px 20px;
}
.only-these { font-weight: 700; margin-top: 16px; }

/* How to */
.steps {
  margin: 0;
  padding-left: 1.6em;
  display: grid;
  gap: 8px;
  max-width: 62ch;
}
.steps li::marker {
  font-family: var(--display);
}

/* Lore and rulebook */
.story {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: var(--gutter);
  margin-bottom: 56px;
}
.panel {
  border: var(--line);
  border-radius: var(--wobble);
  padding: 22px 24px;
}
.panel p { margin: 0 0 12px; max-width: 58ch; }
.rulebook { background: var(--ink); color: var(--paper); }
.rulebook ul {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  font-family: var(--display);
  font-size: clamp(1.15rem, 2.4vw, 1.5rem);
  line-height: 1.3;
}
.rulebook li:last-child { color: var(--rage); }
.rule-end { margin: 0; }

/* Meme maker */
.maker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: var(--gutter);
  align-items: start;
  margin-top: 8px;
}
#meme-canvas {
  width: 100%;
  height: auto;
  border: var(--line);
  border-radius: var(--wobble);
  background: var(--paper);
}
.maker-controls { display: grid; gap: 14px; }
.maker-controls fieldset {
  border: 3px solid var(--ink);
  border-radius: 8px;
  margin: 0;
  padding: 8px 14px 12px;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}
.maker-controls legend { font-weight: 700; padding: 0 4px; }
.maker-controls label { cursor: pointer; }
.field { display: grid; gap: 4px; font-weight: 700; }
.field input {
  font: inherit;
  font-weight: 400;
  border: 3px solid var(--ink);
  border-radius: 6px;
  padding: 8px 10px;
}

/* FAQ */
.faq details {
  border-top: 3px solid var(--ink);
  padding: 12px 0;
  max-width: 70ch;
}
.faq details:last-of-type { border-bottom: 3px solid var(--ink); }
.faq summary {
  font-weight: 700;
  font-size: 1.2rem;
  cursor: pointer;
}
.faq details p { margin: 8px 0 0; }

/* Footer */
.footer {
  background: var(--ink);
  color: var(--paper);
  padding: 36px var(--gutter) 48px;
}
.footer > * { max-width: var(--page); margin-left: auto; margin-right: auto; }
.footer-face { width: 56px; margin-bottom: 14px; }
.disclaimer { font-size: 1rem; max-width: 75ch; margin-top: 0; }
.footer-addresses { display: grid; gap: 6px; margin: 18px auto; }
.footer-addresses div { display: flex; gap: 10px; flex-wrap: wrap; }
.footer-addresses dt { font-weight: 700; min-width: 6.5em; }
.footer-addresses dd { margin: 0; overflow-wrap: anywhere; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.95rem; }
.footer-links { display: flex; gap: 18px; font-weight: 700; }

/* ---------- Phones ---------- */

@media (max-width: 720px) {
  .topbar nav { order: 3; width: 100%; gap: 14px; font-size: 1rem; }
  .side { padding: 10px 8px 14px; }
  .verdict { font-size: 0.85rem; padding: 2px 10px; }
  .change { font-size: 0.95rem; }
  .vs { margin: 0 -10px; }
  .war-foot { flex-direction: column; align-items: stretch; }
  .war-actions .btn { flex: 1; text-align: center; }
  .fighter-grid,
  .story,
  .maker { grid-template-columns: 1fr; }
}

/* ---------- Point at a face: rage ---------- */

.face-frame { cursor: pointer; border-radius: 50%; }
.side.raging .face { animation: rage-shake 0.3s linear infinite; }
@media (prefers-reduced-motion: reduce) {
  .side.raging .face { animation: none; }
}
.hover-hint {
  margin: 10px 0 0;
  font-weight: 700;
  font-size: 1rem;
}
.sound-toggle {
  font-family: var(--body);
  font-weight: 700;
  font-size: 1rem;
  border: 3px solid var(--ink);
  border-radius: 6px;
  background: var(--paper);
  padding: 8px 12px;
  cursor: pointer;
}
.sound-toggle[aria-pressed="false"] { text-decoration: line-through; }
@media (max-width: 720px) {
  .war-actions { flex-wrap: wrap; }
  .sound-toggle { flex-basis: 100%; }
}
