:root {
  --green: #98cc5a;     /* page background + accent (config.js AD_GREEN / SITE_BG) */
  --ad-side: #d3d0ca;   /* background of the ad half */
  --ad-bg: #f4f1e8;     /* off-white ad border (config.js AD_BG) */
  --ink: #161515;       /* off-black (config.js OFF_BLACK) */
  --light: #f4f1e8;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  /* split in half: green pitch side, off-grey ad side */
  background: linear-gradient(to right, var(--green) 0 50%, var(--ad-side) 50%);
  color: var(--ink);
  font: 400 16px/1.5 Figtree, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- layout ---------- */
.layout {
  min-height: 100vh;
  display: grid;
  gap: clamp(12px, 1.8vw, 26px) clamp(28px, 4vw, 72px);
  padding: clamp(28px, 4vw, 60px) clamp(22px, 4vw, 64px);
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr auto auto auto;
  grid-template-areas:
    "brand    ad"
    "headline ad"
    "copy     ad"
    "controls cap";
}

/* ---------- wordmark ---------- */
.site-brand {
  grid-area: brand;
  align-self: start;
  font-family: Figtree, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.site-brand::after {
  content: "";
  display: block;
  width: clamp(120px, 16vw, 200px);
  height: 1px;
  margin-top: 12px; /* healthy padding between the wordmark and the rule */
  background: var(--ink);
  opacity: 0.5;
}

.site-headline {
  grid-area: headline;
  margin: 0;
  font-family: "Cal Sans", Figtree, sans-serif;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 0.98;
  font-size: clamp(40px, 5.4vw, 88px);
  max-width: none;
}
/* "Zcash." drops to its own line, set a touch apart from the line above */
.site-headline .hl-zcash { display: block; margin-top: 0.18em; }

.site-copy {
  grid-area: copy;
  max-width: 46ch;
  font-weight: 300;
  font-size: clamp(15px, 1.15vw, 19px);
  line-height: 1.5;
}
.site-copy p { margin: 0 0 1em; }
.site-copy p:last-child { margin-bottom: 0; }

/* ---------- ad pane ---------- */
.ad-pane {
  grid-area: ad;
  position: relative; /* contains the absolutely-positioned, scaled ad */
  min-width: 0;
  min-height: 0;
  /* no overflow:hidden — it would clip the ad's soft drop shadow */
}
/* Absolutely positioned so the true-pixel ad can never inflate the grid. */
.ad-scale {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: center center;
  will-change: transform;
  transition: opacity 0.12s ease;
}

/* ---------- controls ---------- */
.controls {
  grid-area: controls;
  justify-self: start;
  align-self: end;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 100%;
}
.control-row { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  appearance: none;
  border: 1.5px solid var(--ink);
  background: var(--ink);
  color: #fff;
  font: 700 13px/1 Figtree, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 11px 14px;
  border-radius: 0;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: transparent; color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: progress; }
.btn.accent { background: var(--green); border-color: var(--ink); color: var(--ink); }
.btn.accent:hover { background: transparent; }

.meta {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(22, 21, 21, 0.6);
}

/* ---------- corner bugs ---------- */
.gallery-bug {
  position: fixed;
  top: clamp(14px, 2.5vw, 26px);
  right: clamp(14px, 2.5vw, 26px);
  z-index: 30;
  color: var(--ink);
  background: var(--ad-side); /* sits on the ad (grey) half; masks content under it */
  display: inline-flex;
  padding: 8px;
  line-height: 0;
}
.gallery-bug svg rect { fill: currentColor; }
.gallery-bug:hover { opacity: 0.65; }

.credit-bug {
  position: fixed;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: var(--ink);
  color: #fff;
  text-decoration: none;
  font-weight: 400;
  font-size: 13px;
  letter-spacing: 0.02em;
  padding: 9px 16px;
}
.credit-bug:hover { background: #000; }

/* ---------- the ad ---------- */
.ad {
  position: relative;
  overflow: hidden;
  background: var(--ad-bg);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.2); /* soft depth only; no built-in border */
}

.field {
  position: absolute;
  overflow: hidden;
}

/* the faded base layer — image, article headline and text block all fade
   together; the slogan on top stays full opacity */
.base {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0.6;
}

/* paper-texture base layer (sits below the faded content; rotated per-ad) */
.texture {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 0;
  object-fit: cover;
  pointer-events: none;
}

/* headline scaled to FILL the whole frame (title-only / headline ads) */
.headline-poster {
  position: absolute;
  inset: 0;
  z-index: 1;
  padding: 12%;
  color: var(--ink);
  overflow: hidden;
}
.headline-poster .hp-kicker {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink); /* follows the paper (off-black / off-white); base layer fades it */
  opacity: 0.6;
  margin-bottom: 3%;
}
.headline-poster .hp-headline {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  line-height: 1.02;
  font-size: 60px; /* fitHeadlineFill() overrides this */
  /* no word-breaking — fitHeadlineFill sizes so whole words fit the width */
}

/* approach A — single B&W faded news image */
.field-fill {
  position: absolute;
  inset: 0;
  z-index: 1;
  filter: grayscale(1) contrast(0.95);
}
.field-fill img,
.field-fill canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* monochrome film grain over the base layer (masks low-res images) */
.grain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 6;
  mix-blend-mode: overlay;
  opacity: 0.62;
  pointer-events: none;
}

/* approach C — JUST the article text, tri-column newspaper, faded */
.news-text {
  position: absolute;
  inset: 0;
  z-index: 1;
  padding: 10%;
  color: var(--ink);
  overflow: hidden;
}
.news-text .nt-headline {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 58px;
  line-height: 1.02;
  margin-bottom: 3%;
}
.news-text .nt-body {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  line-height: 1.34;
  text-align: justify;
  hyphens: auto;
  column-count: 3;
  column-gap: 4%;
}

/* approach D — full-page text wall (no headline), backdrop for the big slogan */
.text-wall {
  position: absolute;
  inset: 0;
  z-index: 1;
  padding: 9%;
  color: var(--ink);
  overflow: hidden;
}
.text-wall .tw-headline {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 34px;
  line-height: 1.06;
  margin-bottom: 2.5%;
}
.text-wall .tw-body {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.36;
  text-align: justify;
  hyphens: auto;
}
.newsclip {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 2;
  padding: 4.5% 5% 7%;
  background: linear-gradient(to bottom, rgba(244, 241, 232, 0.96) 58%, rgba(244, 241, 232, 0));
}
.newsclip .kicker {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #555;
  margin-bottom: 8px;
}
.newsclip .headline {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 50px;
  line-height: 1.03;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* approach B — colour block filled with the article's own text */
.text-block {
  position: absolute;
  inset: 0;
  z-index: 1;
  padding: 6% 6% 9%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.text-block.align-left { text-align: left; }
.text-block.align-center { text-align: center; }
.text-block .tb-kicker {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: 18px;
}
.text-block .tb-headline {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 56px;
  line-height: 1.02;
  margin-bottom: 22px;
}
.text-block .tb-body {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  line-height: 1.34;
  flex: 1;
  overflow: hidden;
}
.text-block.align-left .tb-body { column-count: 2; column-gap: 6%; }
.text-block.align-center .tb-body { max-width: 86%; margin: 0 auto; }

/* read-the-article link — sits UNDER the ad (not overlaid), clickable */
.ad-caption {
  grid-area: cap;
  justify-self: center;
  align-self: start;
  margin-top: 12px;
  font: 700 13px/1 ui-monospace, Menlo, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  border: 1.5px solid var(--ink);
  padding: 9px 12px;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ad-caption:hover { background: var(--ink); color: var(--green); }
.ad-caption[hidden] { display: none; }

/* custom share menu */
.share-wrap { position: relative; display: inline-flex; }
.share-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 40;
  min-width: 190px;
  background: var(--ink);
  border: 1.5px solid var(--ink);
}
.share-menu[hidden] { display: none; }
.share-item {
  appearance: none;
  display: block;
  width: 100%;
  background: var(--ink);
  color: #fff;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  font: 600 12px/1 Figtree, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
  padding: 12px 13px;
  cursor: pointer;
}
.share-item:last-child { border-bottom: 0; }
.share-item:hover { background: var(--green); color: var(--ink); }

/* overlay slogan — Cal Sans, block or scattered */
.message { position: absolute; z-index: 5; }
.message.scattered { left: 0; top: 0; }

/* slogan horizontal placement — the vertical position (and the gap down to the
   separated "Zcash.") is set by fitAd, so the lead and "Zcash." always stack
   into one readable sentence, "Zcash." underneath. */
.message.pos-left   { left: 10%; right: auto; transform: none;             text-align: left; }
.message.pos-center { left: 50%; right: auto; transform: translateX(-50%); text-align: center; }
/* line-height high enough that the highlight fully contains Cal Sans's tall
   ascenders/descenders and adjacent lines don't overlap (which clips glyphs) */
.m-line { white-space: nowrap; line-height: 1.32; margin: 0; }
.m-word { white-space: nowrap; display: inline-block; }
.hl {
  background: var(--hl-bg, var(--green));
  color: var(--hl-ink, var(--ink));
  padding: 0.08em 0.2em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* ---------- gallery / timeline ---------- */
.gallery-page .layout { display: block; min-height: 0; }
.wrap { max-width: 1100px; margin: 0 auto; width: 100%; }
.g-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 8px; }
.g-actions { display: flex; gap: 8px; align-items: center; }
.page-title {
  font-family: "Cal Sans", Figtree, sans-serif;
  font-weight: 400;
  font-size: clamp(34px, 5vw, 64px);
  line-height: 1;
  margin: 0;
}
.page-sub { font-weight: 300; opacity: 0.8; }

.timeline { position: relative; margin-top: 28px; padding-left: 28px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--ink);
}
.tl-day { position: relative; margin-bottom: 34px; }
.tl-date {
  display: inline-block;
  background: var(--ink);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  font-size: 13px;
  padding: 5px 10px;
  margin-bottom: 14px;
}
.tl-date::before {
  content: "";
  position: absolute;
  left: -28px;
  top: 6px;
  width: 14px;
  height: 14px;
  background: var(--green);
  border: 2px solid var(--ink);
}
.tl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.tl-card { background: var(--ad-bg); border: 2px solid var(--ink); padding: 8px; }
.tl-card img { width: 100%; height: auto; display: block; }
.tl-card .cap {
  margin-top: 7px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.65;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}
.empty {
  margin-top: 30px;
  padding: 36px;
  border: 2px dashed var(--ink);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--ink); color: #fff; }

/* gallery lightbox — click a card to view the full ad */
.tl-card { cursor: zoom-in; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(22, 21, 21, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 48px);
  cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}

/* ---------- mobile ---------- */
@media (max-width: 880px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto auto auto;
    grid-template-areas:
      "brand"
      "headline"
      "copy"
      "ad"
      "cap"
      "controls";
    gap: 14px;
    padding: 64px 18px 88px; /* bottom room for the always-present credit bug */
  }
  /* mobile: green page, with the grey ad-side as a full-bleed band behind the ad */
  body { background: var(--green); }
  .ad-pane {
    height: 56vh;
    background: var(--ad-side);
    width: 100vw;
    margin-left: calc(50% - 50vw);
  }
  .gallery-bug { background: var(--green); }
  .site-headline { max-width: none; }
  .site-copy { max-width: none; }
  /* minimal controls — compact and wrapping, so they take little space */
  .controls { justify-self: stretch; align-self: auto; }
  .control-row { flex-wrap: wrap; gap: 6px; }
  .btn { padding: 9px 11px; font-size: 11px; letter-spacing: 0.06em; }
  .credit-bug { font-size: 12px; padding: 8px 13px; }
}

@media (max-width: 520px) {
  .site-headline { font-size: clamp(32px, 10vw, 52px); }
  .ad-pane { height: 52vh; }
}
