/* Caroufy for Agencies — stylesheet
   Documentation-adjacent, text-forward, structural.
   Layout is normal document flow; CSS grid is reserved for the two
   structural diagrams (approval sequence, permission matrix wrapper). */

:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --text: #17171a;
  --text-muted: #4c4c50;
  --border: #dcdcd7;
  --border-strong: #b9b9b3;
  --accent: #1d3a4f;
  --accent-contrast: #ffffff;
  --code-bg: #f1f1ee;

  --state-draft: #5a5a5e;
  --state-internal: #7a5b12;
  --state-client: #2f4f7a;
  --state-changes: #8a3b24;
  --state-approved: #2e6b45;
  --state-exported: #1d3a4f;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --measure: 42rem;
  --wide: 58rem;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101012;
    --surface: #1a1a1c;
    --text: #ecebe7;
    --text-muted: #a9a9ae;
    --border: #303032;
    --border-strong: #46464a;
    --accent: #8fb8d6;
    --accent-contrast: #0c1a22;
    --code-bg: #1f1f22;

    --state-draft: #a3a3a8;
    --state-internal: #d1a94b;
    --state-client: #85aad6;
    --state-changes: #d98a6c;
    --state-approved: #7cc79a;
    --state-exported: #8fb8d6;
  }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-thickness: 2px;
}

a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

img, svg {
  max-width: 100%;
}

/* ---------- layout shells ---------- */

.brandbar {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 2.75rem 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 1rem;
}

.wordmark {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.wordmark .word {
  font-weight: 700;
}

.wordmark .slug {
  color: var(--text-muted);
}

.tagline {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  flex: 1 0 auto;
}

.contact-link {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  white-space: nowrap;
}

main {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0 1.5rem;
}

section {
  padding: 3.25rem 0;
  border-bottom: 1px solid var(--border);
}

section:last-of-type {
  border-bottom: none;
}

.prose {
  max-width: var(--measure);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.85rem;
}

h1, h2, h3 {
  font-family: var(--font-sans);
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 0 0 1.1rem;
  max-width: var(--measure);
}

h1 {
  font-size: 2.05rem;
}

h2 {
  font-size: 1.4rem;
}

h3 {
  font-size: 1.05rem;
  font-weight: 650;
  margin-bottom: 0.5rem;
}

p {
  margin: 0 0 1.1rem;
  max-width: var(--measure);
}

p:last-child {
  margin-bottom: 0;
}

.lede {
  color: var(--text-muted);
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

/* ---------- tables ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 32rem;
}

caption {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

th, td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

thead th {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--code-bg);
  white-space: nowrap;
}

tbody th[scope="row"] {
  font-weight: 650;
  white-space: nowrap;
}

tbody tr:last-child td,
tbody tr:last-child th {
  border-bottom: none;
}

/* ---------- comparison table emphasis column ---------- */

td.col-agency, th.col-agency {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

/* ---------- approval workflow diagram ---------- */

.sequence {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
  max-width: var(--wide);
  display: grid;
  grid-template-columns: 2.75rem 1fr;
  column-gap: 1rem;
}

.sequence-step {
  display: contents;
}

.sequence-index {
  position: relative;
  display: flex;
  justify-content: center;
}

.sequence-index-mark {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-contrast);
  background: var(--marker-color, var(--state-draft));
  width: 1.9rem;
  height: 1.9rem;
  min-height: 1.9rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.sequence-index::after {
  content: "";
  position: absolute;
  top: 1.9rem;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  background: var(--border-strong);
}

.sequence-step:last-child .sequence-index::after {
  content: none;
}

.sequence-body {
  padding-top: 0.15rem;
  padding-bottom: 2.25rem;
}

.sequence-step:last-child .sequence-body {
  padding-bottom: 0;
}

.state-code {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--marker-color, var(--state-draft));
  font-weight: 650;
  display: block;
  margin-bottom: 0.2rem;
}

.sequence-body h3 {
  margin: 0 0 0.35rem;
}

.sequence-body p {
  margin-bottom: 0;
  color: var(--text-muted);
  max-width: 36rem;
}

.sequence-loop {
  margin-top: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--state-changes);
  border-left: 2px dashed var(--state-changes);
  padding-left: 0.6rem;
}

/* ---------- roles matrix cell states ---------- */

.perm-yes {
  color: var(--state-approved);
  font-weight: 650;
}

.perm-no {
  color: var(--text-muted);
}

.perm-scoped {
  color: var(--state-internal);
}

/* ---------- pricing ---------- */

.plans {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15.5rem, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin: 2rem 0 1.5rem;
  max-width: var(--wide);
}

.plan {
  background: var(--surface);
  padding: 1.5rem 1.5rem 1.75rem;
}

.plan-name {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.plan-price {
  font-size: 1.9rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.plan-price span {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
}

.plan ul {
  list-style: none;
  margin: 1.1rem 0 0;
  padding: 0;
  font-size: 0.92rem;
}

.plan li {
  padding: 0.45rem 0;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
}

.plan li:first-child {
  border-top: none;
}

.plan li strong {
  color: var(--text);
  font-weight: 600;
}

.plan-overage {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px dashed var(--border-strong);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ---------- what-this-isn't ---------- */

.limits {
  list-style: none;
  margin: 1.75rem 0 0;
  padding: 0;
  max-width: var(--measure);
  display: grid;
  gap: 1.15rem;
}

.limits li {
  padding-left: 1.15rem;
  border-left: 2px solid var(--border-strong);
}

.limits strong {
  display: block;
  margin-bottom: 0.15rem;
}

.limits span {
  color: var(--text-muted);
}

/* ---------- footer ---------- */

footer {
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

.footer-grid {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 2.75rem 1.5rem 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 2rem;
}

.footer-col h2 {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 0.85rem;
}

.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.9rem;
}

.footer-col li {
  margin-bottom: 0.5rem;
}

.footer-col address {
  font-style: normal;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.55;
  white-space: pre-line;
}

.footer-legal {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ---------- simple document pages (privacy/terms/unsubscribe) ---------- */

.doc main {
  max-width: var(--measure);
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.doc h1 {
  font-size: 1.7rem;
}

.doc section {
  padding: 1.75rem 0;
}

.doc .updated {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---------- responsive ---------- */

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  h1 {
    font-size: 1.65rem;
  }

  .sequence {
    grid-template-columns: 2.25rem 1fr;
  }

  .plans {
    grid-template-columns: 1fr;
  }
}
