/* ==========================================================================
   British Built Power — Components
   Buttons, cards, chips, forms, nav, stats. Consumes tokens.css.
   ========================================================================== */

/* --------------------------------------------------------------------
   Buttons
   Caps + semibold per the identity. Primary = gold gradient (action),
   secondary = teal gradient (brand), plus outline/ghost for quiet actions.
   -------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border: 2px solid transparent;
  border-radius: var(--radius-pill);
  /* paint backgrounds to the true outer edge — with the default
     padding-box origin, fills stop 2px short of the pill curve */
  background-origin: border-box;
  background-clip: border-box;
  font-family: var(--font-display);
  font-size: var(--text-small);
  font-weight: var(--weight-semibold);
  letter-spacing: normal;
  text-transform: uppercase;
  text-decoration: none;
  line-height: 1;
  cursor: pointer;
  transition:
    transform var(--hover-duration) var(--ease-out),
    box-shadow var(--hover-duration) var(--ease-out),
    filter var(--hover-duration) var(--ease-out),
    border-color var(--hover-duration) var(--ease-out),
    background-color var(--hover-duration) var(--ease-out),
    color var(--hover-duration) var(--ease-out);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  filter: brightness(1.05);
}

.btn:active {
  transition-duration: var(--duration-fast); /* the press stays snappy */
  transform: translateY(0);
  box-shadow: none;
  filter: brightness(0.97);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
}

/* Primary: gold at rest; on hover an ink fill sweeps in from the left
   with a hard 45° leading edge — the same angle as the map's hatching.
   Built as a sliding background layer so the label stays on top. */
.btn-primary {
  background-image:
    linear-gradient(45deg, var(--ink-700) 49.6%, rgba(34, 37, 64, 0) 50.4%),
    var(--grad-gold);
  background-size: 300% 100%, 100% 100%;
  background-position: 100% 0, 0 0;
  background-repeat: no-repeat;
  color: var(--ink-700);
  transition:
    transform var(--hover-duration) var(--ease-out),
    box-shadow var(--hover-duration) var(--ease-out),
    background-position var(--hover-duration) var(--ease-out),
    color var(--hover-duration) var(--ease-out);
}

.btn-primary:hover {
  background-position: 0 0, 0 0;
  color: var(--gold-300);
  filter: none;
}

/* Letter-accurate colour swap: buttons carrying data-label re-render
   their text in gold on a ::after layer masked by the SAME sweeping
   gradient as the ink fill (same geometry, same clock) — so each glyph
   turns gold at the exact moment the ink passes beneath it. */
.btn-primary[data-label] {
  position: relative;
}

.btn-primary[data-label],
.btn-primary[data-label]:hover {
  /* the base label stays ink; the gold comes from the overlay */
  color: var(--ink-700);
  transition:
    transform var(--hover-duration) var(--ease-out),
    box-shadow var(--hover-duration) var(--ease-out),
    background-position var(--hover-duration) var(--ease-out);
}

.btn-primary[data-label]::after {
  content: attr(data-label);
  position: absolute;
  inset: 0;
  z-index: 0;
  display: flex;
  align-items: center;
  padding: inherit;
  color: var(--gold-300);
  pointer-events: none;
  -webkit-mask-image: linear-gradient(45deg, #000 49.6%, transparent 50.4%);
  mask-image: linear-gradient(45deg, #000 49.6%, transparent 50.4%);
  -webkit-mask-size: 300% 100%;
  mask-size: 300% 100%;
  -webkit-mask-position: 100% 0;
  mask-position: 100% 0;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  transition:
    -webkit-mask-position var(--hover-duration) var(--ease-out),
    mask-position var(--hover-duration) var(--ease-out);
}

.btn-primary[data-label]:hover::after {
  -webkit-mask-position: 0 0;
  mask-position: 0 0;
}

/* keep the arrow chip above the overlay layer */
.btn-primary[data-label] .btn-cta-icon {
  position: relative;
  z-index: 1;
}

.btn-secondary {
  background: var(--grad-teal);
  color: var(--white);
}

.btn-dark {
  background: var(--grad-ink);
  color: var(--paper);
}

.btn-outline {
  background: transparent;
  border-color: var(--color-border-strong);
  color: var(--color-text);
}

.btn-outline:hover {
  border-color: var(--ink-500);
  box-shadow: none;
}

.btn-ghost {
  background: transparent;
  color: var(--color-text);
}

.btn-ghost:hover {
  box-shadow: none;
  background: rgba(38, 38, 74, 0.06);
}

/* On dark/brand surfaces */
.surface-dark .btn-outline,
.surface-teal .btn-outline,
.surface-oxblood .btn-outline {
  border-color: rgba(245, 242, 236, 0.5);
  color: var(--paper);
}

.surface-dark .btn-ghost,
.surface-teal .btn-ghost,
.surface-oxblood .btn-ghost {
  color: var(--paper);
}

.surface-dark .btn-ghost:hover,
.surface-teal .btn-ghost:hover,
.surface-oxblood .btn-ghost:hover {
  background: rgba(245, 242, 236, 0.1);
}

/* Sizes */
.btn-sm { padding: var(--space-2) var(--space-4); font-size: var(--text-overline); }
.btn-lg { padding: var(--space-4) var(--space-6); font-size: var(--text-body); }

/* --------------------------------------------------------------------
   CTA arrow chip: a round badge at the pill's end holding a ↗ arrow.
   On hover the arrow exits diagonally top-right while its twin sweeps
   in from bottom-left — same diagonal language as the hatching.
   -------------------------------------------------------------------- */

.btn-cta {
  padding-right: 0.25em;
  gap: var(--space-4);
}

/* Chip nearly fills the pill height (even 4px-ish inset all round, like
   the reference); negative block margins keep it from inflating the
   button's text-driven height. */
.btn-cta-icon {
  position: relative;
  flex: none;
  width: 2.75em;
  height: 2.75em;
  margin-block: -0.875em;
  border-radius: var(--radius-pill);
  background: var(--white);
  overflow: hidden;
}

/* default-size buttons are shorter (12px padding, small type): a
   smaller chip keeps the same ~4px inset all round as on .btn-lg */
.btn-cta:not(.btn-lg) .btn-cta-icon {
  width: 2.4em;
  height: 2.4em;
  margin-block: -0.7em;
}

.btn-cta-icon svg {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 55%;
  height: 55%;
  fill: none;
  stroke: var(--ink-700);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--hover-duration) var(--ease-out);
}

.btn-cta-icon .arr-b {
  transform: translate(-130%, 130%);
}

/* the arrow swap runs on the shared hover clock with the ink sweep and
   the gold lettering: same start, same curve, same landing, in and out */
.btn-cta:hover .arr-a {
  transform: translate(130%, -130%);
}

.btn-cta:hover .arr-b {
  transform: translate(0, 0);
}

/* --------------------------------------------------------------------
   Stamp cards
   The rounded-rectangle "stamp of approval" container, as a surface.
   .stamp = gradient-filled (like the logo); .card = light surface.
   -------------------------------------------------------------------- */

.card {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.stamp {
  border-radius: var(--radius-stamp);
  padding: var(--space-7);
  box-shadow: var(--shadow-md);
}

.card-accent {
  position: relative;
  overflow: hidden;
}

.card-accent::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: var(--grad-gold);
}

/* --------------------------------------------------------------------
   Accordion — native <details> cards that open in place. Give sibling
   items the same name="" to make the group exclusive (one open at a
   time); everything works with no JS. Height animation is progressive:
   browsers without ::details-content / interpolate-size just snap open.
   -------------------------------------------------------------------- */

.accordion-item {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  interpolate-size: allow-keywords;
}

.accordion-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  padding: var(--space-5) var(--space-6);
  cursor: pointer;
  list-style: none;
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  font-size: var(--text-body-lg);
  color: var(--ink-500);
  transition: color var(--hover-duration) var(--ease-out);
}

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

.accordion-summary:hover {
  color: var(--teal-500);
}

.accordion-summary:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 4px;
  border-radius: var(--radius-lg);
}

/* chevron chip; flips when open, fills gold like the active states */
.accordion-summary::after {
  content: "";
  flex: none;
  width: 1rem;
  height: 1rem;
  background-color: currentColor;
  -webkit-mask: center / contain no-repeat
    url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 9l8 8 8-8" fill="none" stroke="black" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></svg>');
  mask: center / contain no-repeat
    url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 9l8 8 8-8" fill="none" stroke="black" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></svg>');
  transition: transform var(--duration-base) var(--ease-out);
}

.accordion-item[open] > .accordion-summary {
  color: var(--teal-500);
}

.accordion-item[open] > .accordion-summary::after {
  transform: rotate(180deg);
  background-color: var(--gold-500);
}

.accordion-body {
  padding: 0 var(--space-6) var(--space-6);
  display: grid;
  gap: var(--space-3);
}

.accordion-item::details-content {
  opacity: 0;
  block-size: 0;
  overflow: hidden;
  transition: block-size var(--duration-base) var(--ease-out),
              opacity var(--duration-base) var(--ease-out),
              content-visibility var(--duration-base) allow-discrete;
}

.accordion-item[open]::details-content {
  opacity: 1;
  block-size: auto;
}

@media (prefers-reduced-motion: reduce) {
  .accordion-item::details-content,
  .accordion-summary::after {
    transition: none;
  }
}

/* --------------------------------------------------------------------
   Chips & badges
   -------------------------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-size: var(--text-overline);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.chip-gold    { background: var(--gold-100);    color: var(--oxblood-500); }
.chip-teal    { background: var(--teal-100);    color: var(--teal-700); }
.chip-oxblood { background: var(--oxblood-100); color: var(--oxblood-700); }
.chip-ink     { background: var(--ink-100);     color: var(--ink-700); }

/* --------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------- */

.field {
  display: grid;
  gap: var(--space-2);
}

.field label {
  font-family: var(--font-display);
  font-size: var(--text-overline);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-text);
}

.field input,
.field select,
.field textarea {
  font: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  transition: border-color var(--hover-duration) var(--ease-out);
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--color-text-muted);
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: var(--teal-500);
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 0;
  border-color: var(--ink-500);
}

.field .hint {
  font-size: var(--text-small);
  color: var(--color-text-muted);
}

.field.is-error input,
.field.is-error select,
.field.is-error textarea {
  border-color: var(--color-error);
}

.field.is-error .hint {
  color: var(--color-error);
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-small);
}

.checkbox input {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--teal-500);
}

/* --------------------------------------------------------------------
   Nav bar
   -------------------------------------------------------------------- */

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
  border-bottom: 1.5px solid var(--color-border);
}

.navbar-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  text-decoration: none;
  color: var(--color-text);
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  list-style: none;
  padding: 0;
}

.navbar-links a {
  font-family: var(--font-display);
  font-size: var(--text-small);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  text-decoration: none;
  color: var(--color-text);
  transition: color var(--hover-duration) var(--ease-out);
}

.navbar-links a:hover,
.navbar-links a[aria-current="page"] {
  color: var(--teal-500);
}

/* --------------------------------------------------------------------
   Stat tile
   -------------------------------------------------------------------- */

.stat {
  display: grid;
  gap: var(--space-1);
}

.stat .stat-value {
  font-family: var(--font-display);
  font-size: var(--text-h1);
  font-weight: var(--weight-display);
  line-height: var(--leading-tight);
  color: var(--color-text);
}

.stat .stat-label {
  font-family: var(--font-display);
  font-size: var(--text-overline);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.surface-gold .stat .stat-value { color: var(--oxblood-700); }
.surface-gold .stat .stat-label { color: var(--oxblood-500); }

/* --------------------------------------------------------------------
   Logo — animated stamp (inline SVG lock-up)
   The map hatching is real dashed strokes (.hatch-line) whose dash/gap
   sequences are measured from the official artwork by
   scripts/gen_animated_logo.py — at rest it matches the official layout,
   round caps included. Keep stroke-width in sync with the script output.

   Adding .is-stamping slides each line's stroke-dashoffset by a whole
   number of its pattern cycles (--pp, set inline per line), so dashes
   travel up the diagonal, shrink out through a round cap, fresh ones grow
   in behind, and the pattern lands back on the official layout. No masks,
   no clipping, no fades. Every line moves at the same speed: --dur scales
   with each line's travel. --d staggers starts (0–280ms sweep).
   -------------------------------------------------------------------- */

.bbp-logo {
  display: block;
  height: auto;
}

.bbp-logo .hatch-line {
  fill: none;
  stroke: #fff;
  stroke-width: 6.4px;
  stroke-linecap: round;
}

.bbp-logo.is-stamping .hatch-line {
  animation: bbp-hatch-flow var(--dur, 1400ms) cubic-bezier(0.45, 0, 0.3, 1) both;
  animation-delay: var(--d, 0ms);
}

@keyframes bbp-hatch-flow {
  from { stroke-dashoffset: 0; }
  to   { stroke-dashoffset: calc(-1 * var(--pp, 0px)); }
}

/* The power O presses once on page load only — the button metaphor: the
   glyph dips like a pressed power button and springs back, scaled about
   the ring's centre. The map flow (.is-stamping) is hover-only and does
   not touch the O. */
.bbp-logo .bbp-switch {
  transform-box: view-box;
  transform-origin: 418.35px 342.9px;
  animation: bbp-press 550ms ease-out 500ms both;
}

@keyframes bbp-press {
  0%   { transform: scale(1); }
  30%  { transform: scale(0.8); }
  60%  { transform: scale(1.08); }
  80%  { transform: scale(0.97); }
  100% { transform: scale(1); }
}

/* --------------------------------------------------------------------
   Emphasis — THE house style for emphasising words in text (per the
   VI header treatment): a translucent stamp-pill behind the words,
   text colour unchanged. Never coloured text for emphasis.
   -------------------------------------------------------------------- */

mark,
.text-emphasis {
  background: rgba(21, 23, 46, 0.08);
  color: inherit;
  font-weight: var(--weight-bold);
  border-radius: 0.3em;
  padding: 0.06em 0.32em;
  margin-inline: -0.04em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.surface-dark mark, .surface-teal mark, .surface-oxblood mark,
.surface-dark .text-emphasis, .surface-teal .text-emphasis,
.surface-oxblood .text-emphasis {
  background: rgba(255, 255, 255, 0.16);
}

/* --------------------------------------------------------------------
   Social links — round chips; hover mirrors the primary button
   (ink fill, gold glyph)
   -------------------------------------------------------------------- */

.social-links {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* tone-on-tone stamp tiles (per the VI): a darker rounded square of
   whatever surface they sit on, white glyph. Hover keeps the house 45°
   sweep — paper fill, glyph flips to ink. */
.social-link {
  --chip-fill: var(--paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-logo);
  color: var(--white);
  background-color: rgba(0, 0, 0, 0.25);
  background-image: linear-gradient(45deg, var(--chip-fill) 49.6%, transparent 50.4%);
  background-size: 300% 100%;
  background-position: 100% 0;
  background-repeat: no-repeat;
  transition: background-position var(--hover-duration) var(--ease-out),
              color var(--hover-duration) var(--ease-out);
}

.social-link svg {
  width: 1.125rem;
  height: 1.125rem;
  fill: currentColor;
  display: block;
}

.social-link:hover {
  background-position: 0 0;
  color: var(--ink-900);
}

/* --------------------------------------------------------------------
   Section header pattern: title + gold rule (no eyebrows — house rule)
   -------------------------------------------------------------------- */

.section-header {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-7);
}

.section-header::after {
  content: "";
  width: var(--space-8);
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--grad-gold);
}

/* --------------------------------------------------------------------
   Weight pairing — the VI's high-contrast display device: a Light
   setup line turning to a Black payoff line in the yellow gradient
   ("BRITAIN HAS ALREADY BUILT THE POWER. / NOW LET'S USE IT.").
   Wrap the two halves of any display heading:
     <h1 class="display-xl display-pair">
       <span class="pair-light">Setup line.</span>
       <span class="pair-payoff">Payoff line.</span>
     </h1>
   The setup keeps the heading's own colour (white on dark surfaces);
   the payoff fills top-light to bottom-dark like the VI artwork.
   -------------------------------------------------------------------- */

.display-pair .pair-light,
.display-pair .pair-payoff {
  display: block;
}

.display-pair .pair-light {
  font-weight: var(--weight-light);
}

.display-pair .pair-payoff {
  font-weight: var(--weight-display);
  background: linear-gradient(to bottom, var(--gold-500) 0%, var(--gold-700) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--gold-500); /* fallback where text clipping isn't supported */
}
