/* ============================================================
   Thought Pattern AI - Shared site chrome
   Reset, base, type primitives, buttons, nav, footer, CTA band.
   Consumes canonical tokens from colors_and_type.css.
   Loaded by every page; page-specific layout lives in <page>.css.
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: transparent; /* ground gradient paints on the fixed layer below */
  overflow-x: hidden;
}

/* Viewport-fixed ground gradient. Painted on a fixed pseudo-element because
   iOS Safari ignores background-attachment: fixed; html keeps --tp-bg as the
   fallback canvas color. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--tp-gradient-ground), var(--tp-bg);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--tp-yellow);
  color: var(--tp-action-fg);
  padding: var(--tp-space-2) var(--tp-space-4);
  z-index: 100;
}
.skip-link:focus {
  left: var(--tp-space-4);
  top: var(--tp-space-4);
}

/* Keep email addresses on a single line (never break mid-address). */
a[href^="mailto:"] {
  white-space: nowrap;
}

.eyebrow {
  font-family: var(--tp-font-mono);
  font-size: var(--tp-fs-xs);
  letter-spacing: var(--tp-ls-caps);
  text-transform: uppercase;
  color: var(--tp-yellow-deep);
  margin: 0 0 var(--tp-space-4);
}

.section-title {
  font-family: var(--tp-font-display);
  font-weight: var(--tp-fw-regular);
  letter-spacing: var(--tp-ls-display);
  font-size: var(--tp-fs-2xl);
  line-height: var(--tp-lh-snug);
  color: var(--tp-fg);
  margin: 0;
}

/* -------- Content links (in-prose) ----------------------- */
/* Inline links inside body copy. Defined here in the shared chrome so every
   page with .article prose renders them in the legible accent - otherwise a
   page whose CSS omits this rule falls back to the browser default link colour
   (blue, or visited-purple) which is unreadable on the dark ground. */
/* WCAG 1.4.1: colour alone cannot distinguish a link inside a text block, and
   the accent sits at 1.05:1 against body copy, so carry a muted underline at
   rest and bring it to full strength on hover. */
.article a {
  color: var(--tp-yellow);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--tp-yellow) 45%, transparent);
  text-decoration-thickness: from-font;
  text-underline-offset: 0.18em;
}
.article a:hover {
  text-decoration-color: currentColor;
}

/* -------- Buttons ---------------------------------------- */
.btn {
  display: inline-block;
  font-family: var(--tp-font-mono);
  font-size: var(--tp-fs-sm);
  letter-spacing: 0.06em;
  text-decoration: none;
  padding: 12px 22px;
  border-radius: var(--tp-radius-sm);
  border: 1px solid transparent;
  transition:
    background var(--tp-duration-base) var(--tp-ease-out),
    border-color var(--tp-duration-base) var(--tp-ease-out),
    color var(--tp-duration-base) var(--tp-ease-out);
}
.btn-primary {
  background: var(--tp-action);
  color: var(--tp-action-fg);
  font-weight: var(--tp-fw-medium);
}
.btn-primary:hover {
  background: var(--tp-action-hover);
}
.btn-ghost {
  color: var(--tp-fg);
  border-color: var(--tp-border-strong);
}
.btn-ghost:hover {
  border-color: var(--tp-border-active);
  color: var(--tp-yellow);
}
.btn-lg {
  padding: 15px 32px;
  font-size: var(--tp-fs-base);
}

/* -------- Status dots ------------------------------------ */
.dot {
  width: 8px;
  height: 8px;
  border-radius: var(--tp-radius-pill);
  flex: none;
}
.dot-success {
  background: var(--tp-success);
  box-shadow: 0 0 8px var(--tp-success-bg);
}
.dot-running {
  background: var(--tp-running);
  box-shadow: 0 0 8px var(--tp-running-bg);
}
.dot-warning {
  background: var(--tp-warning);
  box-shadow: 0 0 8px var(--tp-warning-bg);
}

/* -------- Nav -------------------------------------------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--tp-space-6);
  padding: var(--tp-space-4) var(--tp-space-8);
  background: rgba(13, 4, 13, 0.72);
  -webkit-backdrop-filter: blur(12px); /* Safari < 18 */
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--tp-border);
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--tp-space-3);
  text-decoration: none;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.brand-name {
  font-family: var(--tp-font-mono);
  font-size: var(--tp-fs-sm);
  letter-spacing: 0.22em;
  color: var(--tp-fg);
}
.brand-ai {
  color: var(--tp-yellow);
}
.brand-sub {
  font-family: var(--tp-font-mono);
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--tp-yellow-deep);
}
.nav-links {
  display: flex;
  gap: var(--tp-space-6);
}
.nav-links a {
  font-family: var(--tp-font-mono);
  font-size: var(--tp-fs-sm);
  letter-spacing: 0.08em;
  color: var(--tp-fg-muted);
  text-decoration: none;
  transition: color var(--tp-duration-fast) var(--tp-ease-out);
}
.nav-links a:hover {
  color: var(--tp-yellow);
}
/* "page" marks the page itself; "true" marks a section the page belongs to. */
.nav-links a[aria-current="page"],
.nav-links a[aria-current="true"] {
  color: var(--tp-yellow);
}

/* Hamburger toggle - hidden on desktop, revealed in the mobile bar. */
.nav-toggle {
  display: none;
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: -6px 0;
  background: transparent;
  border: 1px solid var(--tp-border-strong);
  border-radius: var(--tp-radius-sm);
  color: var(--tp-fg);
  cursor: pointer;
  transition:
    border-color var(--tp-duration-fast) var(--tp-ease-out),
    color var(--tp-duration-fast) var(--tp-ease-out);
}
.nav-toggle:hover {
  border-color: var(--tp-border-active);
  color: var(--tp-yellow);
}
.nav-toggle:focus-visible {
  outline: 2px solid var(--tp-yellow);
  outline-offset: 2px;
}
.nav-toggle-box {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 5px;
}
.nav-toggle-box span {
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition:
    transform var(--tp-duration-base) var(--tp-ease-out),
    opacity var(--tp-duration-fast) var(--tp-ease-out);
}
.nav.is-open .nav-toggle-box span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav.is-open .nav-toggle-box span:nth-child(2) {
  opacity: 0;
}
.nav.is-open .nav-toggle-box span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* -------- CTA band --------------------------------------- */
.cta-band {
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(56px, 9vw, 120px) var(--tp-space-8);
}
.cta-inner {
  text-align: center;
  max-width: 620px;
  margin: 0 auto;
}
.cta-title {
  font-family: var(--tp-font-display);
  font-weight: var(--tp-fw-regular);
  letter-spacing: var(--tp-ls-display);
  font-size: clamp(2rem, 5vw, var(--tp-fs-3xl));
  color: var(--tp-fg);
  margin: 0 0 var(--tp-space-4);
}
.cta-sub {
  font-family: var(--tp-font-serif);
  font-size: var(--tp-fs-md);
  line-height: var(--tp-lh-body);
  color: var(--tp-fg-muted);
  margin: 0 0 var(--tp-space-8);
}
/* The band is centred text, so a second button needs its own row. */
.cta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--tp-space-4);
  justify-content: center;
}


/* -------- Sticky mobile CTA ------------------------------ */
/* The header button sits out of thumb reach on a phone, so below 720px it
   moves to a bar pinned at the bottom of the viewport and the header one
   stands down. Pages without a bar keep their header button. */
.mcta {
  display: none;
}
@media (max-width: 720px) {
  .mcta {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    padding: var(--tp-space-3) var(--tp-space-5);
    padding-bottom: calc(var(--tp-space-3) + env(safe-area-inset-bottom, 0px));
    background: rgba(13, 4, 13, 0.94);
    -webkit-backdrop-filter: blur(12px); /* Safari < 18 */
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--tp-border);
  }
  .mcta .btn {
    display: block;
    width: 100%;
    padding: 14px 22px;
    text-align: center;
  }
  /* One call to action at a time. */
  body:has(.mcta) .nav-cta {
    display: none;
  }
  /* Keep the bar from covering the end of the page. */
  body:has(.mcta) {
    padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  }
}
/* -------- Footer ----------------------------------------- */
.site-foot {
  border-top: 1px solid var(--tp-border);
  display: flex;
  flex-wrap: wrap;
  gap: var(--tp-space-12);
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--tp-space-16) var(--tp-space-8);
}
.foot-copy {
  font-family: var(--tp-font-mono);
  font-size: var(--tp-fs-xs);
  letter-spacing: 0.08em;
  color: var(--tp-fg-subtle);
  margin: var(--tp-space-5) 0 0;
}
.foot-social {
  display: flex;
  gap: var(--tp-space-4);
  margin: var(--tp-space-5) 0 0;
}
.foot-social a {
  display: inline-flex;
  color: var(--tp-fg-muted);
  transition: color var(--tp-duration-fast) var(--tp-ease-out);
}
.foot-social a:hover {
  color: var(--tp-yellow);
}
.foot-social svg {
  width: 19px;
  height: 19px;
}
.foot-cols {
  display: flex;
  flex-wrap: wrap;
  gap: var(--tp-space-12);
}
.foot-cols h2 {
  font-family: var(--tp-font-mono);
  font-size: var(--tp-fs-xs);
  font-weight: 700;
  line-height: normal;
  letter-spacing: var(--tp-ls-caps);
  text-transform: uppercase;
  color: var(--tp-fg-muted);
  margin: 0 0 var(--tp-space-4);
}
.foot-cols a {
  display: block;
  font-family: var(--tp-font-serif);
  font-size: var(--tp-fs-base);
  color: var(--tp-fg-body);
  text-decoration: none;
  margin-bottom: var(--tp-space-2);
}
.foot-cols a:hover {
  color: var(--tp-yellow);
}

/* -------- Utilities -------------------------------------- */
/* The serif face defaults to oldstyle figures, which renders "Apache-2.0" as
   "Apache-2.o" in body prose. Use lining figures for version and license
   strings so they read as the literal identifiers they are. */
.lining-nums {
  font-variant-numeric: lining-nums;
}

/* -------- Responsive (shared chrome) --------------------- */
@media (max-width: 900px) {
  .nav-toggle {
    display: inline-flex;
  }

  /* Primary nav collapses into a drawer that drops below the sticky bar. */
  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    gap: 0;
    padding: var(--tp-space-2) var(--tp-space-8) var(--tp-space-4);
    background: rgba(13, 4, 13, 0.96);
    -webkit-backdrop-filter: blur(12px); /* Safari < 18 */
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--tp-border);
    box-shadow: 0 16px 28px rgba(0, 0, 0, 0.38);
  }
  .nav.is-open .nav-links {
    display: flex;
  }
  .nav-links a {
    padding: var(--tp-space-3) 0;
    font-size: var(--tp-fs-base);
    color: var(--tp-fg-body);
    border-bottom: 1px solid var(--tp-border);
  }
  .nav-links a:last-child {
    border-bottom: 0;
  }
}
@media (max-width: 560px) {
  .nav {
    padding: var(--tp-space-4) var(--tp-space-5);
  }
  .nav-links {
    padding-left: var(--tp-space-5);
    padding-right: var(--tp-space-5);
  }
  /* Yield bar width to the logo, CTA and toggle: drop the wordmark. */
  .brand-text {
    display: none;
  }
  .cta-band {
    padding-left: var(--tp-space-5);
    padding-right: var(--tp-space-5);
  }
  .site-foot {
    padding: var(--tp-space-12) var(--tp-space-5);
    gap: var(--tp-space-8);
  }
  .foot-cols {
    gap: var(--tp-space-8);
  }
}
