/* SPDX-FileCopyrightText: 2024-2026 P2Poolv2 Developers
   SPDX-License-Identifier: MIT OR Apache-2.0

   The page is built on Bootstrap 5.3. This file does three things, in
   this order:

     1. maps the brand palette onto Bootstrap's own CSS variables, so
        Bootstrap components come out in the right colours rather than
        being overridden one rule at a time;
     2. sets the type scale, which is brand rather than framework;
     3. styles the handful of components Bootstrap has no equivalent
        for: the chain figure, the terminal blocks, the hairline lists.

   Anything a Bootstrap utility class can do, do in the markup instead
   of adding a rule here. */

/* ---------------------------------------------------------------
   1. the palette, mapped onto Bootstrap's variables
   --------------------------------------------------------------- */

:root,
[data-bs-theme="dark"] {
  /* The four colours specified in logos/p2poolv2-brand-pack/README.txt,
     taken from the logo in use. Nothing else on this page is a colour;
     every value below is one of these at reduced opacity. */
  --p2-orange: #f7931a;
  --p2-near-black: #121212;
  --p2-black: #0b0b0c;
  --p2-white: #ffffff;

  --p2-orange-rgb: 247, 147, 26;
  --p2-white-rgb: 255, 255, 255;
  --p2-black-rgb: 11, 11, 12;

  /* Bootstrap: colour */
  --bs-body-bg: var(--p2-black);
  --bs-body-color: rgba(var(--p2-white-rgb), 0.78);
  --bs-body-color-rgb: var(--p2-white-rgb);
  --bs-emphasis-color: var(--p2-white);
  --bs-emphasis-color-rgb: var(--p2-white-rgb);
  --bs-heading-color: var(--p2-white);
  --bs-secondary-color: rgba(var(--p2-white-rgb), 0.56);
  --bs-tertiary-color: rgba(var(--p2-white-rgb), 0.4);
  --bs-border-color: rgba(var(--p2-white-rgb), 0.11);
  --bs-border-color-translucent: rgba(var(--p2-white-rgb), 0.11);

  --bs-primary: var(--p2-orange);
  --bs-primary-rgb: var(--p2-orange-rgb);
  --bs-primary-text-emphasis: var(--p2-orange);
  --bs-primary-border-subtle: rgba(var(--p2-orange-rgb), 0.26);
  --bs-primary-bg-subtle: rgba(var(--p2-orange-rgb), 0.12);

  --bs-link-color: var(--p2-white);
  --bs-link-color-rgb: var(--p2-white-rgb);
  --bs-link-hover-color: var(--p2-orange);
  --bs-link-hover-color-rgb: var(--p2-orange-rgb);

  --bs-code-color: var(--p2-white);
  --bs-focus-ring-color: rgba(var(--p2-white-rgb), 0.55);

  /* Bootstrap: type */
  --bs-font-sans-serif: "Inter", ui-sans-serif, system-ui, "Helvetica Neue", Arial, sans-serif;
  --bs-font-monospace: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --bs-body-font-size: 1.0625rem;
  --bs-body-line-height: 1.65;

  /* Bootstrap: shape. The design has no rounded corners anywhere, and
     setting this once is most of what stops the page looking like a
     Bootstrap page. */
  --bs-border-radius: 0;
  --bs-border-radius-sm: 0;
  --bs-border-radius-lg: 0;
  --bs-border-radius-xl: 0;
  --bs-border-radius-xxl: 0;
  --bs-border-radius-2xl: 0;
  --bs-border-radius-pill: 0;
}

/* Narrower than Bootstrap's default so the measure stays readable on a
   wide screen. */
.container {
  max-width: 1120px;
}

/* Nothing white ever sits on orange: white on #F7931A is 2.30:1 and
   fails AA, black on orange is 8.57:1. Every filled-orange control sets
   its own text to black. */
.btn-primary {
  --bs-btn-color: var(--p2-black);
  --bs-btn-bg: var(--p2-orange);
  --bs-btn-border-color: var(--p2-orange);
  --bs-btn-hover-color: var(--p2-black);
  --bs-btn-hover-bg: rgba(var(--p2-orange-rgb), 0.82);
  --bs-btn-hover-border-color: rgba(var(--p2-orange-rgb), 0.82);
  --bs-btn-active-color: var(--p2-black);
  --bs-btn-active-bg: rgba(var(--p2-orange-rgb), 0.82);
  --bs-btn-active-border-color: rgba(var(--p2-orange-rgb), 0.82);
}

.btn-outline-primary {
  --bs-btn-color: var(--p2-white);
  --bs-btn-border-color: var(--p2-orange);
  --bs-btn-hover-color: var(--p2-black);
  --bs-btn-hover-bg: var(--p2-orange);
  --bs-btn-hover-border-color: var(--p2-orange);
  --bs-btn-active-color: var(--p2-black);
  --bs-btn-active-bg: var(--p2-orange);
  --bs-btn-active-border-color: var(--p2-orange);
}

.btn-outline-light {
  --bs-btn-color: var(--p2-white);
  --bs-btn-border-color: rgba(var(--p2-white-rgb), 0.11);
  --bs-btn-hover-color: var(--p2-white);
  --bs-btn-hover-bg: transparent;
  --bs-btn-hover-border-color: var(--p2-white);
  --bs-btn-active-color: var(--p2-white);
  --bs-btn-active-bg: transparent;
  --bs-btn-active-border-color: var(--p2-white);
}

.btn {
  font-family: var(--bs-font-monospace);
  font-weight: 700;
  letter-spacing: -0.02em;
  --bs-btn-font-size: 0.92rem;
  --bs-btn-padding-x: 1.5rem;
  --bs-btn-padding-y: 0.7rem;
}

.btn-sm {
  --bs-btn-font-size: 0.82rem;
  --bs-btn-padding-x: 0.75rem;
  --bs-btn-padding-y: 0.3rem;
}

a {
  text-decoration-color: var(--p2-orange);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

code {
  background: rgba(var(--p2-orange-rgb), 0.12);
  padding: 1px 5px;
}

.skip-link {
  display: inline-block;
  background: var(--p2-orange);
  color: var(--p2-black);
  padding: 8px 14px;
  text-decoration: none;
}

/* ---------------------------------------------------------------
   2. type
   --------------------------------------------------------------- */

.hero-title {
  font-family: var(--bs-font-monospace);
  font-weight: 800;
  font-size: clamp(2.5rem, 7.2vw, 4.9rem);
  line-height: 0.97;
  letter-spacing: -0.05em;
  color: var(--p2-white);
}

.section-title {
  font-family: var(--bs-font-monospace);
  font-weight: 700;
  font-size: clamp(1.6rem, 3.4vw, 2.4rem);
  line-height: 1.08;
  letter-spacing: -0.04em;
  max-width: 24ch;
}

h3,
.sub,
.swap-title,
.defs dt {
  font-family: var(--bs-font-monospace);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
  color: var(--p2-white);
}

.sub {
  color: var(--p2-orange);
  margin-bottom: 0.75rem;
}

.defs dt {
  font-size: 1.02rem;
  letter-spacing: -0.03em;
}

p {
  max-width: 62ch;
}

.lede {
  font-size: 1.17rem;
  line-height: 1.6;
  max-width: 58ch;
}

.intro {
  font-size: 1.08rem;
}

.cta-line {
  font-size: 1.05rem;
  color: var(--p2-white);
}

/* ---------------------------------------------------------------
   3. layout rhythm and the top bar
   --------------------------------------------------------------- */

.band {
  padding-top: 5.75rem;
  padding-bottom: 5.75rem;
}

.topbar {
  background: rgba(var(--p2-black-rgb), 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--bs-border-color);
}

.brand-logo {
  display: block;
  height: 38px;
  width: auto;
}

.topnav {
  font-family: var(--bs-font-monospace);
  font-size: 0.82rem;
  letter-spacing: -0.01em;
}

.topnav a:not(.btn) {
  --bs-nav-link-padding-x: 0;
  --bs-nav-link-padding-y: 0.45rem;
  color: var(--bs-secondary-color);
  text-decoration: none;
}

.topnav a:not(.btn):hover,
.topnav a:not(.btn):focus {
  color: var(--p2-white);
}

/* The toggler. Bootstrap draws its icon as a background SVG in
   --bs-navbar-toggler-icon-bg, so recolouring means replacing that data
   URI rather than setting a fill. */
.navbar-toggler {
  --bs-navbar-toggler-border-color: var(--bs-border-color);
  --bs-navbar-toggler-focus-width: 0.2rem;
  --bs-navbar-toggler-icon-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%23f7931a' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2.5' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
  padding: 0.35rem 0.55rem;
}

/* The open menu on phones: give it room off the bar and rule it off from
   the page behind, which is translucent. */
@media (max-width: 991.98px) {
  .navbar-collapse {
    padding: 0.5rem 0 0.75rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--bs-border-color);
  }

  .topnav .btn {
    align-self: flex-start;
  }
}

/* ---------------------------------------------------------------
   4. components Bootstrap has no equivalent for
   --------------------------------------------------------------- */

/* the share chain figure */

.chainfig-scroll {
  overflow-x: auto;
  padding-bottom: 6px;
}

.dag {
  display: block;
  width: 100%;
  min-width: 660px;
  height: auto;
}

.dag .tip {
  fill: var(--p2-orange);
  opacity: 0.8;
}

.edge {
  fill: none;
  stroke: var(--p2-orange);
  stroke-width: 2;
  opacity: 0.5;
}

.edge-uncle {
  stroke-dasharray: 5 5;
  opacity: 0.38;
}

.share {
  fill: var(--p2-near-black);
  stroke: var(--p2-orange);
  stroke-width: 2;
}

/* Orange carries the chain, so the share that also cleared the network
   target is marked in white. Orange against gold would be 1.28:1. */
.share-won {
  fill: rgba(var(--p2-white-rgb), 0.16);
  stroke: var(--p2-white);
}

.share-uncle {
  stroke-dasharray: 4 4;
  stroke: rgba(var(--p2-orange-rgb), 0.7);
}

.legend {
  gap: 8px 28px;
  font-size: 0.88rem;
  color: var(--bs-secondary-color);
}

.legend li {
  display: flex;
  align-items: center;
  gap: 9px;
}

.key {
  width: 17px;
  height: 13px;
  flex: none;
  background: var(--p2-near-black);
  border: 2px solid var(--p2-orange);
}

.key-won {
  background: rgba(var(--p2-white-rgb), 0.16);
  border-color: var(--p2-white);
}

.key-uncle {
  border-style: dashed;
}

/* pull quote */

.pull {
  border-left-width: 2px !important;
  border-left-color: var(--p2-orange) !important;
}

.pull p {
  font-family: var(--bs-font-monospace);
  font-size: 0.98rem;
  line-height: 1.5;
  letter-spacing: -0.02em;
  color: var(--p2-white);
  margin-bottom: 0.75rem;
}

.pull cite {
  font-style: normal;
  font-size: 0.85rem;
}

/* comparison table */

.cmp {
  --bs-table-bg: transparent;
  --bs-table-color: var(--bs-body-color);
  font-size: 0.95rem;
}

.cmp caption {
  font-family: var(--bs-font-monospace);
  font-size: 0.82rem;
  color: var(--bs-secondary-color);
  letter-spacing: -0.01em;
  padding-bottom: 0.75rem;
}

.cmp th,
.cmp td {
  padding: 0.875rem 1.125rem 0.875rem 0;
  vertical-align: top;
}

.cmp thead th {
  font-family: var(--bs-font-monospace);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--p2-white);
  border-bottom-color: var(--bs-primary-border-subtle);
}

.cmp tbody th {
  font-weight: 500;
  color: var(--p2-white);
  width: 32%;
}

.cmp td {
  color: var(--bs-secondary-color);
  width: 34%;
}

.cmp .yes {
  color: var(--p2-white);
}

/* the one big number. Prose is white, so the payoff is marked in
   orange, the reverse of the chain figure. */

.stat {
  border-top: 1px solid var(--bs-primary-border-subtle);
  border-bottom: 1px solid var(--bs-primary-border-subtle);
}

.stat-value {
  font-family: var(--bs-font-monospace);
  font-weight: 800;
  font-size: clamp(2.1rem, 5.4vw, 3.5rem);
  letter-spacing: -0.055em;
  line-height: 1;
  color: var(--p2-orange);
}

.stat-note {
  font-size: 0.95rem;
  max-width: 52ch;
}

/* hairline-separated lists, in place of a stack of cards */

.plain {
  max-width: 62ch;
}

.plain li {
  padding: 1rem 0 1rem 1.25rem;
  border-top: 1px solid var(--bs-border-color);
  position: relative;
}

.plain li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1.7rem;
  width: 8px;
  height: 8px;
  background: var(--p2-orange);
}

.plain li:last-child {
  border-bottom: 1px solid var(--bs-border-color);
}

.plain strong {
  color: var(--p2-white);
  font-weight: 600;
}

.plain-tight {
  font-size: 0.95rem;
}

.plain-tight li {
  padding: 0.7rem 0 0.7rem 1.25rem;
}

.plain-tight li::before {
  top: 1.3rem;
  width: 6px;
  height: 6px;
}

/* the swap, the one genuine sequence on the page */

.swap {
  counter-reset: step;
}

.swap li {
  counter-increment: step;
  padding: 1.375rem 1.25rem 1.5rem;
  border-right: 1px solid var(--bs-border-color);
  border-bottom: 1px solid var(--bs-border-color);
}

.swap li::before {
  content: counter(step);
  display: block;
  font-family: var(--bs-font-monospace);
  font-weight: 800;
  font-size: 0.82rem;
  color: var(--p2-orange);
  margin-bottom: 0.875rem;
}

.swap-title {
  margin-bottom: 0.5rem;
}

.swap p {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--bs-secondary-color);
}

/* terminal blocks */

.term {
  background: var(--p2-near-black);
  border: 1px solid var(--bs-border-color);
  border-left: 2px solid var(--p2-orange);
  padding: 1.25rem 1.375rem;
  overflow-x: auto;
  margin-bottom: 1.125rem;
}

.term code {
  background: none;
  padding: 0;
  font-size: 0.86rem;
  line-height: 1.75;
  color: var(--p2-white);
  white-space: pre;
}

.term .c {
  color: var(--bs-secondary-color);
}

.term .p {
  color: var(--p2-orange);
}

.foot-nav {
  font-family: var(--bs-font-monospace);
  font-size: 0.85rem;
}

.foot-nav a {
  color: var(--bs-secondary-color);
  text-decoration: none;
}

.foot-nav a:hover {
  color: var(--p2-orange);
}

/* GitHub and X marks, in the top bar and the footer. The glyphs are inline
   SVG and take their colour from the link, so they follow its hover. */
.social-icon {
  display: block;
  width: 1.1rem;
  height: 1.1rem;
  fill: currentColor;
}

/* ---------------------------------------------------------------
   5. the one motion moment: the chain builds once, on load
   --------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  .share {
    opacity: 0;
    animation: land 460ms ease-out forwards;
    animation-delay: calc(220ms + var(--i, 0) * 105ms);
  }

  .edge {
    opacity: 0;
    animation: reach 320ms ease-out forwards;
    animation-delay: calc(300ms + var(--i, 0) * 105ms);
  }

  .edge-uncle {
    animation-name: reach-uncle;
  }

  @keyframes land {
    from {
      opacity: 0;
      transform: translateY(6px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  @keyframes reach {
    from {
      opacity: 0;
    }
    to {
      opacity: 0.5;
    }
  }

  @keyframes reach-uncle {
    from {
      opacity: 0;
    }
    to {
      opacity: 0.38;
    }
  }
}

/* ---------------------------------------------------------------
   6. narrow screens. Bootstrap's grid handles the columns; these are
      the things it does not know about.
   --------------------------------------------------------------- */

@media (max-width: 991.98px) {
  .band {
    padding-top: 4.25rem;
    padding-bottom: 4.25rem;
  }

  .swap li {
    border-right: 0;
  }

  .chainfig-scroll {
    -webkit-mask-image: linear-gradient(to right, var(--p2-black) 84%, transparent 100%);
    mask-image: linear-gradient(to right, var(--p2-black) 84%, transparent 100%);
  }
}

@media (max-width: 575.98px) {
  .section-title {
    max-width: none;
  }
}

/* The swap strip draws its own cell borders, so drop the ones that
   would double up with the outer border of the list. */
.swap li:last-child {
  border-right: 0;
}

@media (min-width: 992px) {
  .swap li {
    border-bottom: 0;
  }
}

.defs dd {
  max-width: 62ch;
}

/* The running testnet4 pool, flagged in the top bar. The dot is a status
   light, not decoration: if the pool goes away, this goes with it. */
.live {
  font-family: var(--bs-font-monospace);
  font-size: 0.82rem;
  letter-spacing: -0.01em;
  color: var(--p2-white);
  text-decoration: none;
  white-space: nowrap;
}

.live:hover {
  color: var(--p2-orange);
}

.live-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--p2-orange);
  box-shadow: 0 0 0 3px rgba(var(--p2-orange-rgb), 0.22);
}

/* The hero's three properties, one box each. A single bordered frame split
   by hairlines, the same construction as the swap strip, rather than three
   free-floating cards. They are parallel, not a sequence, so no numbers. */
.prop {
  padding: 1.375rem 1.5rem 1.5rem;
}

.prop-body {
  font-size: 1rem;
  color: var(--bs-body-color);
  max-width: none;
}

@media (min-width: 768px) {
  .prop:not(:last-child) {
    border-right: 1px solid var(--bs-border-color);
  }
}

@media (max-width: 767.98px) {
  .prop:not(:last-child) {
    border-bottom: 1px solid var(--bs-border-color);
  }
}
