/* Meridian Atlas: the boxed price tag, the hero buy button and the sticky bar.
   Shared by the six product pages; injected by api/pricebar.py, served by the
   /ma-pricebar.css route. See api/pricebar.py for why this exists.

   Every colour here is taken from the page it lands on, through currentColor or
   a --ma-* variable the page sets next to its own palette, because three of the
   six pages are dark (coordinates, wayfinding, north-star) and three are light
   (chart, before-we, we). Nothing in this file assumes an ink or a ground. */

:root {
  /* Space above the tag line at the top of the page. api/pricebar.py overrides
     it per page; see its PAGES table. */
  --ma-tagline-gap: 14px;

  /* Falls back to the page's own ink if it sets nothing. */
  --ma-bar-bg: #f2ede2;
  --ma-bar-ink: #2a2118;
  --ma-bar-line: rgba(128, 118, 100, .3);
  --ma-btn-bg: #2a2118;
  --ma-btn-ink: #f2ede2;
  --ma-btn-radius: 3px;

  --ma-sans: 'Jost', Helvetica, Arial, sans-serif;
  --ma-serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
}

/* ── the tag ────────────────────────────────────────────────────────────────
   The planner prints this at 6pt Jost, letterspaced .2em, uppercase, inside a
   .5pt rule in the title's ink, with 2pt/4pt padding. These are the same
   proportions at screen sizes. The right padding is smaller than the left
   because letter-spacing leaves a gap after the last letter. */
.ma-tag {
  display: inline-block;
  font-family: var(--ma-sans);
  font-weight: 500;
  font-size: 11px;
  line-height: 1;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: inherit;
  border: 1px solid currentColor;
  padding: .36em .22em .36em .52em;
  white-space: nowrap;
  vertical-align: baseline;
}

/* At the top of the page the tag is a line of its own, centred between the
   eyebrow and the title. The gap above matches the one the page already puts
   above its title, so the tag reads as part of that block rather than as
   something dropped into it.

   The margin below is the same figure and simply collapses with the title's
   own margin-top where it has one, which is why five of the six pages need no
   per-page spacing beyond the one number. */
.ma-tagline {
  margin: var(--ma-tagline-gap) 0;
  text-align: center;
  line-height: 1;
}

/* The tag is the same box everywhere: the title line, the sticky bar and the
   bottom buy section all take it at its own size, centred on its own line. */
.ma-tag--bar,
.ma-tag--foot {
  vertical-align: middle;
}

/* Before We's promo code rewrites the tag's contents with the old price struck
   through beside the new one. */
.ma-tag .was {
  opacity: .55;
  text-decoration: line-through;
  margin-right: .5em;
}

/* ── the buy button ───────────────────────────────────────────────────────── */
.ma-buy {
  display: inline-block;
  font-family: var(--ma-sans);
  font-weight: 400;
  font-size: 12.5px;
  line-height: 1;
  letter-spacing: .18em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ma-btn-ink);
  background: var(--ma-btn-bg);
  border: 1px solid var(--ma-btn-bg);
  border-radius: var(--ma-btn-radius);
  padding: 15px 26px;
  cursor: pointer;
  transition: opacity .16s ease;
}

.ma-buy:hover,
.ma-buy:focus-visible { opacity: .86; }

/* Centred, like the masthead above it on all six pages. The hero sits outside
   the <header> on most of them, so it cannot inherit that alignment. */
.ma-hero {
  margin: 22px 0 6px;
  text-align: center;
}

/* The bottom buy section the Wayfinding sample page did not have. The other
   five pages already had one and keep their own. */
.ma-buybox { margin: 10px 0 0; }

.ma-buybox__in {
  text-align: center;
  padding: 34px 0 10px;
}

.ma-buybox__price {
  font-family: var(--ma-serif);
  font-size: 19px;
  line-height: 1.5;
  margin: 0 0 20px;
}

/* ── the sticky bar ─────────────────────────────────────────────────────────
   None of the six pages has a sticky site nav (chart's .nav and wayfinding's
   .topbar are both position:relative and scroll away), so the bar takes the top
   edge for itself rather than sitting under anything.

   It is position:fixed and parked with a transform, so it is out of flow both
   before and after it appears: showing or hiding it cannot move the document by
   a pixel. */
.ma-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9000;
  background: var(--ma-bar-bg);
  color: var(--ma-bar-ink);
  border-bottom: 1px solid var(--ma-bar-line);
  padding-top: env(safe-area-inset-top, 0px);
  transform: translateY(-100%);
  will-change: transform;
  /* Parked, it is decoration: visibility:hidden keeps its button out of the tab
     order and off the accessibility tree. The 0s visibility transition is
     delayed by the length of the slide so hiding waits for the bar to finish
     leaving, rather than snapping it away mid-animation. */
  visibility: hidden;
  transition: transform .22s ease, visibility 0s linear .22s;
}

.ma-bar.is-on {
  transform: translateY(0);
  visibility: visible;
  transition: transform .22s ease, visibility 0s linear 0s;
}

@media (prefers-reduced-motion: reduce) {
  .ma-bar,
  .ma-bar.is-on { transition: none; }
}

.ma-bar__in {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  max-width: 1120px;
  margin: 0 auto;
  padding-top: 9px;
  padding-bottom: 9px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

.ma-bar__name {
  font-family: var(--ma-serif);
  font-weight: 400;
  font-size: 22px;
  line-height: 1;
  letter-spacing: .01em;
  /* The name gives way first: the price and the button must survive 390px. */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ma-bar .ma-buy--bar {
  margin-left: auto;
  flex: none;
  padding: 11px 18px;
  font-size: 11px;
  letter-spacing: .14em;
}

@media (max-width: 460px) {
  .ma-bar__in { gap: 8px; min-height: 50px; }
  .ma-bar__name { font-size: 19px; }
  .ma-tag--bar { font-size: 10px; }
  .ma-bar .ma-buy--bar { padding: 10px 14px; font-size: 10.5px; letter-spacing: .12em; }
  .ma-buy { padding: 14px 22px; font-size: 12px; }
}
