/* ==========================================================================
   Shared pieces: nav, buttons, chips, titles and section surfaces. Same
   recipes as the app's new look (controls.css).
   ========================================================================== */

/* ---- Nav ------------------------------------------------------------------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: var(--v-outline);
  background: var(--v-bg-deep);
}
.nav-inner {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  min-height: var(--nav-h);
}
.brand {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  text-decoration: none;
}
.brand-emblem {
  /* Sized by height: the file is trimmed to the shield, so its ink starts on
     the page edge. */
  width: auto;
  height: 40px;
  /* The crest is a shield with its own ink outline: no frame, only a hard
     shadow on the shape. */
  filter: drop-shadow(2px 2px 0 var(--v-ink));
}
.brand-name {
  color: var(--v-title);
  font-family: var(--v-font-display);
  font-size: 1.875rem;
  font-weight: var(--v-display-weight);
  line-height: 1;
  text-shadow: 2px 2px 0 var(--v-ink);
}
.nav-links {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(8px, 1.6vw, 28px);
}
.nav-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 4px;
  color: var(--v-text);
  font-size: var(--t-sm);
  font-weight: 700;
  text-decoration: none;
  text-underline-offset: 6px;
}
.nav-links a:hover {
  color: var(--v-title);
  text-decoration-line: underline;
  text-decoration-style: dashed;
  text-decoration-thickness: 2px;
}
@media (max-width: 899px) {
  .nav-links {
    display: none;
  }
  .nav-inner {
    justify-content: space-between;
  }
  .brand-name {
    font-size: 1.625rem;
  }
}
/* The narrowest phones: the name and the button need the emblem's room. */
@media (max-width: 359px) {
  .nav .brand-emblem {
    display: none;
  }
  .nav-inner {
    gap: var(--s-3);
  }
}

/* ---- Buttons: they sit on a hard shadow and press into it ------------------ */
.btn {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  border: var(--v-outline);
  border-radius: var(--v-radius-sm);
  background: var(--v-surface-1);
  box-shadow: var(--v-shadow-sm);
  color: var(--v-text);
  font-family: var(--v-font-text);
  font-size: var(--t-sm);
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform var(--dur-1) ease;
}
.btn:hover {
  background: var(--v-surface-2);
  box-shadow: var(--v-shadow-pressed);
  transform: translate(var(--v-press), var(--v-press));
}
.btn:active {
  box-shadow: none;
  transform: translate(calc(var(--v-press) + 1px), calc(var(--v-press) + 1px));
}
.btn--primary {
  background: var(--v-accent);
  color: var(--v-on-accent);
}
.btn--primary:hover {
  background: var(--v-accent-hi);
}
.btn--paper {
  background: var(--v-paper);
  color: var(--v-on-paper);
}
.btn--paper:hover {
  background: var(--v-paper-2);
}
/* Indigo, not ink: an ink face would merge with its own ink shadow. */
.btn--ink {
  background: var(--v-surface-1);
  color: var(--v-text);
}
.btn--ink:hover {
  background: var(--v-surface-2);
}
/* The hero's two buttons: bigger, with a second line of small print. */
.btn--lg {
  min-height: 56px;
  padding: 9px 22px;
  border-radius: var(--v-radius-md);
  box-shadow: var(--v-shadow);
  font-size: var(--t-lg);
}
.btn-stack {
  display: grid;
  gap: 1px;
  text-align: left;
}
.btn-sub {
  font-size: var(--t-xs);
  font-weight: 700;
}
/* ---- Chips ------------------------------------------------------------------ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border: var(--v-outline);
  border-radius: var(--v-radius-pill);
  /* A step lighter than both night surfaces, so the pill reads as a pill. */
  background: var(--v-surface-1);
  color: var(--v-text);
  font-size: var(--t-xs);
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.4;
  text-transform: uppercase;
  white-space: nowrap;
}
.chip--gold {
  background: var(--v-gold);
  color: var(--v-ink);
}
.chip--violet {
  background: var(--v-violet);
  color: var(--v-ink);
}
.chip--plain {
  letter-spacing: 0;
  text-transform: none;
}
/* A tilted tag, like the app's "Sample data" marker. */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border: var(--v-outline);
  border-radius: 6px;
  background: var(--v-gold);
  box-shadow: 2px 2px 0 var(--v-ink);
  color: var(--v-ink);
  font-size: var(--t-xs);
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1.4;
  text-transform: uppercase;
  white-space: nowrap;
  transform: rotate(-3deg);
}

/* Live dot. */
.dot {
  flex: none;
  width: 9px;
  height: 9px;
  border: 1.5px solid var(--v-ink);
  border-radius: 50%;
  background: var(--v-win);
}
.dot--pulse {
  animation: dot-pulse 2.4s ease-in-out infinite;
}
@keyframes dot-pulse {
  50% {
    opacity: 0.45;
    transform: scale(0.8);
  }
}
/* The live count's state, set by script.js on the hero chip and the co-op
   ticket: gold while checking, green when live, grey when nobody is signed
   up, red when the count cannot be reached. Only "checking" and "live" pulse. */
.hero-presence:not([data-state]) .dot,
.ticket:not([data-state]) .dot {
  background: var(--v-gold);
}
[data-state="empty"] .dot {
  background: var(--v-text-3);
  animation: none;
}
[data-state="down"] .dot {
  background: var(--v-loss);
  animation: none;
}

/* ---- Titles ----------------------------------------------------------------- */
/* The page's lettered titles: gold, tilted, on a hard ink shadow. */
.section-head h2,
.share-copy h3,
.closing-title {
  color: var(--v-title);
  font-family: var(--v-font-display);
  font-size: var(--t-3xl);
  font-weight: var(--v-display-weight);
  line-height: 0.98;
  text-shadow: var(--v-title-shadow);
  transform: rotate(var(--v-title-tilt));
  transform-origin: 0 100%;
}
.closing-title {
  text-shadow: 4px 4px 0 var(--v-ink);
}
.section-head {
  display: grid;
  gap: var(--s-3);
  max-width: 62rem;
  margin-bottom: var(--s-7);
}
.section-head p {
  max-width: 46rem;
  color: var(--v-text-2);
  font-size: var(--t-lg);
}
.section-head .chip {
  justify-self: start;
}
.section-head a {
  font-weight: 800;
  text-underline-offset: 4px;
}
/* A section's opening row: the heading on the left and, beside it, the thing
   it introduces (the save paths, the live count), so the right half of the
   page is never left empty. */
.section-top {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: clamp(24px, 4vw, 72px);
  align-items: end;
  margin-bottom: var(--s-7);
}
.section-top .section-head {
  max-width: none;
  margin-bottom: 0;
}
/* The same idea for a heading with nothing to sit beside it: the title on
   the left, its own paragraph on the right, ending on one line. */
@media (min-width: 1100px) {
  /* The same two columns as .section-top, so every section's right-hand
     piece starts on one line down the page. */
  .section-head--split {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    column-gap: clamp(24px, 4vw, 72px);
    align-items: end;
    max-width: none;
  }
  .section-head--split p {
    padding-bottom: 0.35em;
  }
  .section-head--split .chip {
    grid-column: 1 / -1;
  }
}
/* A heading with one action: the title on the left, the action at the far end. */
.section-head--row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  max-width: none;
}
.section-head--row .chip {
  grid-column: 1 / -1;
}
.section-head-action {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px 14px;
  padding-bottom: 0.35em;
}
@media (max-width: 699px) {
  .section-head--row {
    grid-template-columns: minmax(0, 1fr);
  }
  .section-head-action {
    justify-content: flex-start;
  }
}
@media (max-width: 899px) {
  .section-top {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }
}
/* A file name in running text reads as one token. */
.section-head code {
  padding: 1px 6px;
  border: 1.5px solid currentColor;
  border-radius: 6px;
}

/* ---- Sections: night and parchment alternate -------------------------------- */
.section {
  position: relative;
  padding-block: var(--s-section);
}
.section--night {
  background: var(--v-bg);
}
.section--paper {
  /* A gold focus ring vanishes on parchment: ink here. */
  --focus: var(--v-on-paper);
  border-block: var(--v-outline);
  background: var(--v-paper);
  color: var(--v-on-paper);
}
/* Paper grain: a fine dot screen, the same weight as the app's texture. */
.section--paper::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(var(--v-on-paper) 0.6px, transparent 0.8px);
  background-size: 5px 5px;
  opacity: var(--v-texture);
  pointer-events: none;
}
.section--paper > * {
  position: relative;
}
.section--paper .section-head h2 {
  color: var(--v-on-paper);
  text-shadow: 3px 3px 0 var(--v-gold);
}
.section--paper .section-head p {
  color: var(--v-on-paper-2);
}
