/* ─────────────────────────────────────────────────────────────────
   Ghost Permits — shared site shell
   Single source of truth for header, footer, status pill, tokens.
   Theme is selected by [data-theme] on <body>: "light" or "dark".
   ───────────────────────────────────────────────────────────────── */

/* Tokens — both themes always defined; theme attribute picks one */
:root {
  /* Light (parchment / case-file) */
  --gp-l-bg:        #fbfaf6;
  --gp-l-elev:      #ffffff;
  --gp-l-ink-900:   #0a0e14;
  --gp-l-ink-700:   #2a2c30;
  --gp-l-ink-500:   #4a5568;
  --gp-l-ink-400:   #64748b;
  --gp-l-rule:      #dbe3ec;
  --gp-l-rule-soft: #ebe7dc;

  /* Dark (operations console) */
  --gp-d-bg:        #0a0e14;
  --gp-d-elev:      #101822;
  --gp-d-ink-900:   #f0f4f8;
  --gp-d-ink-700:   #cbd5e1;
  --gp-d-ink-500:   #94a3b8;
  --gp-d-rule:      #22303e;
  --gp-d-rule-soft: #1a2230;

  /* Brand — same on both themes */
  --gp-red:         #c0392b;
  --gp-red-mid:     #e74c3c;
  --gp-red-soft:    #fdecea;
  --gp-amber:       #d97706;
  --gp-green:       #16a34a;

  --gp-header-h:    72px;
  --gp-radius-sm:   2px;
  --gp-radius-md:   4px;

  /* Layout system — single source of truth for container width and
     section rhythm. Every page on the site aligns to the same vertical
     rules as the header. */
  --gp-container-max:   1240px;
  --gp-container-pad:   24px;
  --gp-section-pad-y:   clamp(64px, 8vw, 128px);
  --gp-section-pad-y-sm: clamp(48px, 6vw, 88px);
  --gp-prose-max:       68ch;
  --gp-grid-gap:        24px;
}

/* Active theme aliases — read these in component CSS */
[data-theme="light"] {
  --gp-bg:        var(--gp-l-bg);
  --gp-elev:      var(--gp-l-elev);
  --gp-ink:       var(--gp-l-ink-900);
  --gp-ink-2:     var(--gp-l-ink-700);
  --gp-ink-3:     var(--gp-l-ink-500);
  --gp-ink-4:     var(--gp-l-ink-400);
  --gp-rule:      var(--gp-l-rule);
  --gp-rule-soft: var(--gp-l-rule-soft);
  --gp-header-bg: rgba(251,250,246,.92);
  --gp-cta-fg:    #ffffff;
}
[data-theme="dark"] {
  --gp-bg:        var(--gp-d-bg);
  --gp-elev:      var(--gp-d-elev);
  --gp-ink:       var(--gp-d-ink-900);
  --gp-ink-2:     var(--gp-d-ink-700);
  --gp-ink-3:     var(--gp-d-ink-500);
  --gp-ink-4:     var(--gp-d-ink-500);
  --gp-rule:      var(--gp-d-rule);
  --gp-rule-soft: var(--gp-d-rule-soft);
  --gp-header-bg: rgba(10,14,20,.92);
  --gp-cta-fg:    #ffffff;
}

/* ─── Header ─────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--gp-header-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--gp-rule);
}
.site-header__inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.site-header__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--gp-ink);
  flex-shrink: 0;
}
.brand-mark {
  width: 26px; height: 26px; border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  background:
    radial-gradient(circle at 50% 50%, var(--gp-red-mid) 0 3px, transparent 3px),
    radial-gradient(circle at 50% 50%, transparent 0 5px, var(--gp-red-mid) 5px 6px, transparent 6px),
    radial-gradient(circle at 50% 50%, transparent 0 9px, var(--gp-red-mid) 9px 10px, transparent 10px),
    radial-gradient(circle at 50% 50%, transparent 0 12px, var(--gp-red-mid) 12px 13px, transparent 13px);
}
.brand-mark::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 1px solid var(--gp-ink);
}
.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.1;
}
.brand-name {
  font-family: 'Epilogue', system-ui, sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -.01em;
  color: var(--gp-ink);
}
.brand-tagline {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 10px;
  color: var(--gp-ink-3);
  letter-spacing: .08em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-left: auto;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.site-nav a {
  color: var(--gp-ink-3);
  text-decoration: none;
  white-space: nowrap;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  transition: color .12s, border-color .12s;
}
.site-nav a:hover { color: var(--gp-ink); }
.site-nav a[aria-current="page"] {
  color: var(--gp-ink);
  border-bottom-color: currentColor;
}

.site-header__cta {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 9px 14px;
  background: var(--gp-red-mid);
  color: var(--gp-cta-fg);
  border: 1px solid var(--gp-red-mid);
  border-radius: var(--gp-radius-sm);
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.site-header__cta:hover { background: var(--gp-red); border-color: var(--gp-red); }
.site-header__cta[aria-current="page"] {
  background: transparent;
  color: var(--gp-ink-3);
  border-color: var(--gp-rule);
}

@media (max-width: 900px) {
  .site-nav { gap: 14px; font-size: 10px; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; -webkit-overflow-scrolling: touch; max-width: 100%; }
  .site-nav::-webkit-scrollbar { display: none; }
  .brand-tagline { display: none; }
  .site-header__inner { gap: 14px; }
}

/* ─── Status pill (content widget — never inside header) ──── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border: 1px solid var(--gp-red-mid);
  color: var(--gp-red-mid);
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  border-radius: var(--gp-radius-sm);
  white-space: nowrap;
  background: transparent;
}
.status-pill::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--gp-red-mid);
  animation: gp-pulse 1.6s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes gp-pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* ─── Footer ─────────────────────────────────────────────────── */
.site-footer {
  background: var(--gp-bg);
  color: var(--gp-ink-3);
  border-top: 1px solid var(--gp-rule);
  padding: 56px 0 36px;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
}
.site-footer__inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  gap: 36px;
}
.site-footer__brand {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.site-footer__brand .brand-mark { width: 22px; height: 22px; }
.site-footer__brand .brand-name { font-size: 13px; }
.site-footer__brand p {
  font-family: 'Instrument Serif', ui-serif, serif;
  font-style: italic;
  font-size: 14px;
  line-height: 1.5;
  color: var(--gp-ink-3);
  max-width: 28ch;
  margin-top: 4px;
}
.site-footer__col h4 {
  font-size: 9px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--gp-ink-4);
  font-weight: 500;
  margin-bottom: 14px;
}
.site-footer__col a, .site-footer__col span {
  display: block;
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--gp-ink-3);
  text-decoration: none;
  padding: 4px 0;
  text-transform: none;
}
.site-footer__col a:hover { color: var(--gp-ink); }
.site-footer__credit {
  grid-column: 1 / -1;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--gp-rule);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 10px;
  letter-spacing: .08em;
  color: var(--gp-ink-4);
  text-transform: uppercase;
}
@media (max-width: 760px) {
  .site-footer__inner { grid-template-columns: 1fr 1fr; gap: 28px; }
  .site-footer__brand { grid-column: 1 / -1; }
}

/* ─── Sample-brief preview chrome (screen-only) ──────────── */
.preview-chrome { display: contents; }
@media print {
  .site-header, .site-footer, .preview-banner { display: none !important; }
}
.preview-banner {
  max-width: 1240px;
  margin: 14px auto 0;
  padding: 10px 22px;
  background: #fef3c7;
  border: 1px solid var(--gp-amber);
  color: #92400e;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: .04em;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.preview-banner a { color: inherit; text-decoration: underline; }

/* ─── Page container (AL01) ─────────────────────────────────────
   Single source of truth for content width across every page.
   Matches the header's inner width exactly, so logo X aligns with
   body content X. Legacy `.wrap` is normalised to the same value.
   ───────────────────────────────────────────────────────────── */
.page-container,
.wrap {
  max-width: var(--gp-container-max);
  margin-inline: auto;
  padding-inline: var(--gp-container-pad);
}

/* ─── 12-column grid (AL02) ─────────────────────────────────────
   Apply to a section's inner wrapper. Children opt into tracks
   via .page-grid__rail | __body | __aside | __full. Defaults at
   narrower widths gracefully collapse to single column.
   ───────────────────────────────────────────────────────────── */
.page-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  column-gap: var(--gp-grid-gap);
  row-gap: 0;
}
.page-grid__rail   { grid-column: 1 / span 2; }
.page-grid__body   { grid-column: 3 / span 7; }
.page-grid__aside  { grid-column: 10 / span 3; }
.page-grid__full   { grid-column: 1 / -1; }
@media (max-width: 900px) {
  .page-grid { grid-template-columns: 1fr; column-gap: 0; }
  .page-grid__rail,
  .page-grid__body,
  .page-grid__aside,
  .page-grid__full { grid-column: 1 / -1; }
}

/* ─── Section rhythm (AL07) ─────────────────────────────────── */
.page-section {
  padding-block: var(--gp-section-pad-y);
}
.page-section--sm {
  padding-block: var(--gp-section-pad-y-sm);
}

/* ─── Section head: number rail + title (AL03) ──────────────── */
.section-head {
  display: grid;
  grid-template-columns: 64px 1fr;
  column-gap: 20px;
  align-items: baseline;
  margin: 56px 0 18px;
  scroll-margin-top: 100px;
}
.section-head:first-child { margin-top: 0; }
.section-head__num {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .08em;
  color: var(--gp-red-mid);
  padding-top: .25em;       /* baseline-align with the serif title */
  white-space: nowrap;
}
.section-head__title {
  font-family: 'Instrument Serif', ui-serif, serif;
  font-weight: 400;
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: -.02em;
  color: inherit;
  max-width: var(--gp-prose-max);
}
@media (max-width: 760px) {
  .section-head { grid-template-columns: 1fr; row-gap: 6px; }
  .section-head__num { padding-top: 0; }
}

/* ─── Reading-width prose helper (AL06) ─────────────────────── */
.prose-track > p,
.prose-track > ul,
.prose-track > ol,
.prose-track > pre,
.prose-track > .callout,
.prose-track > h3 {
  max-width: var(--gp-prose-max);
}
