/*
  Shared site layout: the page frame, the header and the footer. Loaded by every page.
  Header and footer markup comes from /components/layout/site-layout.js.

  Page skeleton (use it for new pages too):
    <head>
      <link rel="stylesheet" href="/css/site-layout.css">
    </head>
    <body>
      <div class="bpl-frame">                     (or <main class="bpl-frame">)
        <div data-site-header></div>
        ... page content ...
        <div data-site-footer></div>
      </div>
      <script src="/components/layout/site-layout.js" defer></script>
    </body>

  !important is used on purpose: several pages carry older layered styles
  that also size the page box, and the frame must win everywhere.
*/

:root {
  --bpl-ink: #013220;
  --bpl-paper: #EDEAE1;
  --bpl-accent: #B87333;
  --bpl-frame-max: 1120px;
  /* Inner left/right margin shared by the header and footer: their content lines up on it */
  --bpl-gutter: 28px;
}

@media (max-width: 759px) {
  :root { --bpl-gutter: 20px; }
}

/* ---------- Page frame ---------- */

/* Always reserve the scrollbar's space so the frame never shifts between pages */
html { scrollbar-gutter: stable; background: var(--bpl-paper); }

body:has(.bpl-frame) {
  margin: 0 !important;
  background: var(--bpl-paper) !important;
}

.bpl-frame {
  box-sizing: border-box !important;
  width: min(var(--bpl-frame-max), calc(100% - 72px)) !important;
  max-width: none !important;
  margin: 18px auto 36px !important;
  border: 1px solid var(--bpl-ink) !important;
  background: var(--bpl-paper) !important;
  box-shadow: 0 12px 30px rgba(17, 22, 19, .08) !important;
  overflow-x: clip !important;
}

@media (max-width: 759px) {
  .bpl-frame {
    width: calc(100% - 16px) !important;
    margin: 18px auto 8px !important;
  }
}

/* ---------- Page-to-page transition ---------- */

/* A short crossfade instead of a hard cut; the header stays put.
   Browsers without view transitions (Firefox today) just switch pages as before. */
@view-transition { navigation: auto; }

.bpl-header { view-transition-name: site-header; }

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: .35s;
  animation-timing-function: cubic-bezier(.2, .7, .2, 1);
}
::view-transition-new(root) { animation-name: bpl-page-in; }
@keyframes bpl-page-in { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

/* ---------- Header (markup from /components/layout/site-layout.js) ---------- */

/* Reserve the header's height so the page doesn't jump while the script runs */
[data-site-header] { display: block; min-height: 65px; }

.bpl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 10px var(--bpl-gutter);
  background: var(--bpl-paper);
  color: var(--bpl-ink);
  border-bottom: 1px solid var(--bpl-ink);
  font-family: 'IBM Plex Mono', 'IBM Plex Mono Local', ui-monospace, monospace;
  font-weight: 500;
  line-height: 1;
}

.bpl-header .bpl-header__brand,
.bpl-header .bpl-header__link {
  color: var(--bpl-ink);
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Brand on one line: "Bar Profit Lab / Laboratoire vivant", the name in a quiet olive */
.bpl-header .bpl-header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 2px 0;
  text-transform: none;
}

.bpl-header .bpl-header__brand b {
  font: 700 17px/1 Archivo, Arial, sans-serif;
  letter-spacing: -.01em;
  color: #646B55;
  transition: color .2s;
}

.bpl-header .bpl-header__brand span {
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #5D6450;
}

.bpl-header .bpl-header__brand span::before {
  content: "/";
  margin-right: 10px;
  color: #80866E;
}

.bpl-header .bpl-header__brand:hover b { color: var(--bpl-ink); }

.bpl-header .bpl-header__links { display: flex; gap: 8px; }

.bpl-header .bpl-header__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 44px;
  padding: 7px 14px;
  border: 1px solid var(--bpl-ink);
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
  letter-spacing: .07em;
}

.bpl-header .bpl-header__link:hover { background: rgba(1, 50, 32, .08); }

.bpl-header .bpl-header__link[aria-current="page"] {
  background: var(--bpl-ink);
  color: var(--bpl-paper);
}

.bpl-header a:focus-visible {
  outline: 2px solid var(--bpl-accent);
  outline-offset: 2px;
}

/* Phones: brand on its own row, three tappable pills underneath */
@media (max-width: 759px) {
  [data-site-header] { min-height: 105px; }
  .bpl-header { flex-wrap: wrap; row-gap: 8px; }
  .bpl-header .bpl-header__brand { flex: 1 0 100%; }
  .bpl-header .bpl-header__brand span { display: none; }
  .bpl-header .bpl-header__links { flex: 1 1 100%; gap: 5px; }
  .bpl-header .bpl-header__link { flex: 1 1 auto; min-height: 44px; padding: 8px 4px; }
}

/* ---------- Footer (markup from /components/layout/site-layout.js) ---------- */

/*
  Grid, desktop:   [ title ............ | Explorer | Suivre le projet ]
                   [ ── divider line across all three columns ──────── ]
                   [ Observer · Tester · Publier |       | © year       ]
  Every column starts on the same top line, and the bottom row reuses the
  same column edges, so everything lines up vertically and horizontally.
  Left/right padding is --bpl-gutter, the same as the header.
*/
.bpl-footer {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: 1fr auto;
  column-gap: 32px;
  box-sizing: border-box;
  min-height: 330px;
  margin: 0;
  padding: 44px var(--bpl-gutter) 28px;
  border: 0 !important;
  background: var(--bpl-ink) url('/img/footer-edgar-chaparro.jpg') center / cover no-repeat;
  color: var(--bpl-paper);
  font-family: 'Archivo', 'Archivo Local', Arial, sans-serif;
  line-height: normal;
  text-align: left;
}

/* Green wash over the photo so the text stays readable */
.bpl-footer::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: rgba(1, 50, 32, .28);
}

/* Some pages style every <footer> (e.g. a decorative ::after on the tool pages); keep this one clean */
.bpl-footer::after { content: none !important; display: none !important; }

.bpl-footer .bpl-footer__title {
  grid-column: 1;
  grid-row: 1;
  align-self: start;
  margin: 0;
  font: 700 42px/.95 'Archivo', 'Archivo Local', Arial, sans-serif;
  letter-spacing: -.05em;
  color: var(--bpl-paper);
}

.bpl-footer .bpl-footer__col {
  grid-row: 1;
  align-self: start;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  /* drop the small label to sit on the title's cap height */
  padding-top: 6px;
}

.bpl-footer .bpl-footer__label {
  margin-bottom: 6px;
  font: 500 12px/1.2 'IBM Plex Mono', 'IBM Plex Mono Local', ui-monospace, monospace;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(237, 234, 225, .7);
}

.bpl-footer .bpl-footer__link {
  font: 400 14px/1.3 'Archivo', 'Archivo Local', Arial, sans-serif;
  color: var(--bpl-paper);
  text-decoration: none;
}

.bpl-footer .bpl-footer__link:hover { text-decoration: underline; text-underline-offset: 3px; }

.bpl-footer a:focus-visible { outline: 2px solid var(--bpl-accent); outline-offset: 3px; }

/* Bottom row: one divider line across the full width, text under the same columns */
.bpl-footer .bpl-footer__method,
.bpl-footer .bpl-footer__legal {
  grid-row: 2;
  margin: 0;
  padding-top: 16px;
  border-top: 1px solid rgba(237, 234, 225, .3);
  font: 500 12px/1.2 'IBM Plex Mono', 'IBM Plex Mono Local', ui-monospace, monospace;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.bpl-footer .bpl-footer__method { grid-column: 1 / 3; color: var(--bpl-paper); }
.bpl-footer .bpl-footer__legal { grid-column: 3; color: rgba(237, 234, 225, .6); }

/* The divider has to be continuous across the column gap */
.bpl-footer .bpl-footer__method { margin-right: -32px; padding-right: 32px; }

/* Phones: title on top, the two link columns side by side, bottom row under them */
@media (max-width: 759px) {
  .bpl-footer {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr auto auto;
    column-gap: 20px;
    row-gap: 24px;
    min-height: 0;
    padding: 28px var(--bpl-gutter) 22px;
  }
  .bpl-footer .bpl-footer__title { grid-column: 1 / -1; font-size: 30px; }
  .bpl-footer .bpl-footer__col { grid-row: 2; padding-top: 0; }
  .bpl-footer .bpl-footer__link { font-size: 15px; padding: 2px 0; }
  /* Bottom: method on one full-width line, © right under it on the same left edge */
  .bpl-footer .bpl-footer__method,
  .bpl-footer .bpl-footer__legal { grid-column: 1 / -1; font-size: 12px; letter-spacing: .1em; }
  .bpl-footer .bpl-footer__method { grid-row: 3; margin-right: 0; padding-right: 0; }
  .bpl-footer .bpl-footer__legal { grid-row: 4; margin-top: -16px; padding-top: 0; border-top: 0; }
}