/* =============================================
   ROOS LABS — shared design system
   Canonical stylesheet for rooslabs.com, signal,
   photos, and ripple. Source of truth for tokens,
   typography, chrome, and module layout.
============================================= */

/* =============================================
   SELF-HOSTED FONTS
   Self-hosting Saira Condensed + Saira + Share Tech Mono
   eliminates the fonts.googleapis.com → fonts.gstatic.com
   round-trips that were dominating mobile LCP (~8s on
   slow 4G profiles). Files live at /assets/fonts/.
   font-display:swap shows fallback text immediately and
   swaps to the real face once loaded — no FOIT.
   Saira ships here as static TTFs, six faces total — the
   old Cormorant/Plex pair were single variable woff2 files,
   so watch the weight map: only 400/500 (Saira) and
   500/600/700 (Condensed) exist. A 300 lands on no face.
============================================= */
/* =============================================
   SELF-HOSTED TYPE
   Six faces, the only ones the site actually uses. Served as TTF because
   that is what Google Fonts hands you on download; converting these to
   woff2 cuts them from ~500 KB to ~120 KB and is worth doing.
   ============================================= */
@font-face {
  font-family: 'Saira';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/Saira-Regular.ttf') format('truetype');
}
@font-face {
  font-family: 'Saira';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/Saira-Medium.ttf') format('truetype');
}
@font-face {
  font-family: 'Saira Condensed';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/Saira_Condensed-Medium.ttf') format('truetype');
}
@font-face {
  font-family: 'Saira Condensed';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/assets/fonts/Saira_Condensed-SemiBold.ttf') format('truetype');
}
@font-face {
  font-family: 'Saira Condensed';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/assets/fonts/Saira_Condensed-Bold.ttf') format('truetype');
}
@font-face {
  font-family: 'Share Tech Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/ShareTechMono-Regular.ttf') format('truetype');
}

:root {
  --bg:           #131313;
  --surface:      #1a1a1a;
  --surface-hi:   #202020;
  --border:       rgba(255, 255, 255, 0.13);
  --border-hi:    rgba(255, 255, 255, 0.22);
  --text:         #f3f2f0;
  --text-muted:   #9d9d99;
  /* Bumped from #7a756e (4.66:1 contrast on --bg, borderline AA) to
     #8c867c (5.42:1, comfortable AA) after Lighthouse flagged .cta-note
     and .footer-left link text. Visually almost imperceptible — same
     warm gray, just enough lighter to clear the threshold. */
  --text-dim:     #8a8a86;
  --accent:       #b3342c;
  /* Brand red is 3.05:1 on --bg — fine for headline scale and fills, short
     of AA for body text. --accent-ink is the same hue lifted to 5.2:1 and is
     what every small accent-coloured TEXT run uses. */
  --accent-ink:   #dc6150;   /* was #d6543f — 4.31:1 on --bg-soft */
  /* Soft accent wash for callouts (crisis box). Heavier in dark so it
     reads at all; lighter in light so text on top keeps contrast. */
  --accent-soft: rgba(179, 52, 44, 0.16);
  --accent-lo:    #b3342c18;
  --accent-mid:   #b3342c44;
  --font-mono:    'Share Tech Mono', monospace;
  --font-body:    'Saira', system-ui, sans-serif;
  --font-serif:   'Saira Condensed', system-ui, sans-serif;
  --transition:   0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.75;
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 999;
  opacity: 0.35;
}

.container { max-width: 1280px; margin: 0 auto; padding: 0 2rem; }

/* NAV */
nav {
  position: sticky;
  top: 0;
  z-index: 60;
  height: 72px;
  box-sizing: border-box;
  padding: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  animation: fadeUp 0.6s ease both;
}

/* The nav sits inside .container, but on the built pages the header is a
   direct child of the page and spans the whole viewport. -2rem only bled it
   to the container's padding edge, which is why ripple's bar stopped short
   of the screen edges while the marketing pages' did not.
   calc(50% - 50vw) pulls each side out to the viewport, and the padding
   matches the built pages' clamp() so the wordmark and links land in the
   same place on every page. */
.container > nav {
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  padding-left: clamp(16px, 4vw, 56px);
  padding-right: clamp(16px, 4vw, 56px);
  width: auto;
}

/* The footer rule above it spans the viewport on the built pages too, so its
   top border reads as a full-width divider rather than a 1280px line. Same
   bleed, same clamp() padding as the nav. */
.container > footer {
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  padding-left: clamp(16px, 4vw, 56px);
  padding-right: clamp(16px, 4vw, 56px);
  width: auto;
}

/* 50vw counts the scrollbar, so the full-bleed bar would otherwise force a
   few pixels of horizontal scroll. clip (not hidden) avoids turning the page
   into a scroll container, which would break position: sticky. */
html, body { overflow-x: clip; }

.nav-home {
  font-family: var(--font-serif);
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  flex-shrink: 0;
  transition: color var(--transition);
}

.nav-home span { color: var(--accent-ink); }
.nav-home:hover { color: var(--text); }

.nav-links {
  display: flex;
  gap: clamp(12px, 2.2vw, 30px);
  align-items: center;
}

.nav-link {
  /* Matches the built pages: Saira Condensed 600 at 15px. Was 12px in the
     body font, which made ripple's nav read as a different design. */
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--transition);
}

.nav-link:hover { color: var(--accent-ink); }

/* Current page: accent text with a 2px rule under it. */
.nav-link.active,
.nav-link[aria-current] {
  color: var(--accent-ink);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 2px;
}
.nav-link.active:hover,
.nav-link[aria-current]:hover { color: var(--accent-ink); }

/* HEADER */
.page-header {
  padding: 5rem 0 3rem;
  animation: fadeUp 0.7s ease 0.1s both;
}

.page-eyebrow {
  font-size: 9px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent-ink);
  display: block;
  margin-bottom: 1.2rem;
}

.page-title {
  font-family: var(--font-serif);
  font-size: clamp(2.4rem, 6vw, 4rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin-bottom: 1.8rem;
  max-width: 22ch;
}

.page-title em { font-style: italic; color: var(--accent-ink); }

.page-premise {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--text-muted);
  border-left: 2px solid var(--accent);
  padding-left: 1.2rem;
  line-height: 1.65;
  max-width: 580px;
  margin-bottom: 1.5rem;
}

/* MODULES */
.modules {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 3rem 0 5rem;
  animation: fadeUp 0.7s ease 0.2s both;
}

.module {
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid;
  grid-template-columns: 3rem 1fr;
  transition: border-color var(--transition);
  position: relative;
  overflow: hidden;
}

.module:hover { border-color: var(--border-hi); }

.module-accent {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 0.3s ease;
}

.module:hover .module-accent { transform: scaleY(1); }

.module-num {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.8rem 0 1.8rem 0.5rem;
  font-size: 9px;
  font-weight: 500;
  /* Was var(--accent-mid) — that's #b8832a44 (27% alpha orange), which
     blends with the dark bg to ~#3C2D13 and fails WCAG AA contrast hard
     (~1.8:1). Switched to var(--text-muted), a desaturated warm gray
     that gives 7.7:1 contrast and keeps the label subtle without
     competing with the brand orange used by .module-label. The callout
     and CTA modules still override to var(--accent) for emphasis. */
  color: var(--text-muted);
  letter-spacing: 0.1em;
  border-right: 1px solid var(--border);
}

.module-body { padding: 1.8rem 2rem; }

.module-label {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-ink);
  display: block;
  margin-bottom: 0.8rem;
}

.module-heading {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  font-weight: 600;
  text-transform: uppercase;
  line-height: 1.25;
  margin-bottom: 1rem;
  color: var(--text);
  max-width: 32ch;
}

.module-text {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.9;
  font-weight: 400;
  max-width: 72ch;
}

.module-text strong { color: var(--text); font-weight: 500; }
.module-text em { color: var(--accent-ink); font-style: italic; }
.module-text p + p { margin-top: 1rem; }

/* VARIANTS */
.module-wide { background: var(--surface-hi); }

.module-callout {
  background: var(--accent-lo);
  border-color: var(--accent-mid);
}

.module-callout .module-num {
  border-right-color: var(--accent-mid);
  color: var(--accent-ink);
}

.module-callout .module-text { color: var(--text); }

.module-cta {
  background: var(--bg);
  border-color: var(--accent-mid);
  margin-top: 24px;
}

.module-cta .module-num {
  border-right-color: var(--accent-mid);
  color: var(--accent-ink);
}

.cta-link {
  display: inline-block;
  margin-top: 1.2rem;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-ink);
  text-decoration: none;
  border: 1px solid var(--accent-mid);
  padding: 10px 24px;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.cta-link:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent-ink);
}

.cta-note {
  display: block;
  margin-top: 0.8rem;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

/* FOOTER */
footer {
  border-top: 1px solid var(--border);
  padding: 30px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  /* Inherited the body's 1.75 prose leading, which made this footer 8px
     taller than the identical footer on the DC-built pages. */
  line-height: 1.2;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  animation: fadeUp 0.7s ease 0.3s both;
}

.footer-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
}
.footer-left a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}
.footer-left a:hover { color: var(--accent-ink); }

.footer-right a,
a.footer-right {
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--transition);
}
.footer-right a:hover,
a.footer-right:hover { color: var(--accent-ink); }

@media (max-width: 500px) {
  footer { gap: 12px; }
  .footer-left { gap: 8px; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 500px) {
  .module { grid-template-columns: 2.2rem 1fr; }
  .module-body { padding: 1.4rem 1.2rem; }
}

/* Keyboard focus indicators. :focus-visible only shows for keyboard users,
   not mouse clicks — preserves the clean mouse-driven aesthetic. */
.nav-home:focus-visible,
.nav-link:focus-visible,
.cta-link:focus-visible,
.footer-right a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 1px;
}

/* Skip-to-content link — hidden until focused, lands keyboard users past the nav. */
.skip-link {
  position: absolute;
  left: 0;
  top: -100px;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-decoration: none;
  z-index: 10000;
  transition: top var(--transition);
}
.skip-link:focus {
  top: 0;
}

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

/* =============================================
   PRINT
   Flip to ink-on-paper. Hide chrome. Serif body
   for readability. Keep the editorial feel but
   use the printed-page conventions readers expect.
============================================= */
@media print {
  body {
    background: #fff !important;
    color: #111 !important;
    font-family: var(--font-serif) !important;
    font-size: 11pt !important;
    line-height: 1.55 !important;
  }
  body::before { display: none !important; }

  nav, footer, .skip-link { display: none !important; }

  .container { max-width: none; padding: 0; margin: 0; }

  .page-header { padding: 0 0 1.5rem; }
  .page-eyebrow {
    color: #666 !important;
    font-size: 8pt;
    letter-spacing: 0.2em;
  }
  .page-title {
    color: #111 !important;
    font-size: 28pt !important;
    line-height: 1.1;
    max-width: none;
  }
  .page-title em { color: #333 !important; }
  .page-premise {
    color: #333 !important;
    font-size: 13pt !important;
    border-left-color: #999 !important;
    max-width: none;
  }
  .page-intro { color: #333 !important; max-width: none; }

  .modules { margin: 1rem 0 2rem; gap: 0; }
  .module, .module-callout, .module-cta, .module-wide, .module-dark {
    background: transparent !important;
    border: none !important;
    border-top: 1px solid #ccc !important;
    page-break-inside: avoid;
  }
  .module-accent { display: none !important; }
  .module-num {
    color: #888 !important;
    border: none !important;
    padding: 1.2rem 0 0 0;
    font-size: 9pt;
  }
  .module-body { padding: 1rem 0 1.2rem 1rem; }
  .module-label {
    color: #666 !important;
    font-size: 8pt;
  }
  .module-heading {
    color: #111 !important;
    font-size: 16pt !important;
    max-width: none;
  }
  .module-text {
    color: #222 !important;
    font-size: 11pt !important;
    line-height: 1.55;
    max-width: none;
    font-family: var(--font-serif);
  }
  .module-text strong { color: #000 !important; }
  .module-text em { color: #333 !important; font-style: italic; }

  .cta-link, .cta-note { display: none !important; }

  /* Show link URLs in parentheses after the link text, for printed reference.
     Skip anchors, tel:, and javascript: — noise on paper. */
  a[href]:not([href^="#"]):not([href^="mailto:"]):not([href^="tel:"]):not([href^="javascript:"])::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #666;
    word-break: break-all;
  }

  /* Avoid orphan headings at the bottom of pages */
  h1, h2, h3, .page-title, .module-heading, .prose h2 {
    page-break-after: avoid;
  }

  /* Keep pull quotes and tables together */
  .pull-quote, .domain-table, figure, table { page-break-inside: avoid; }

  @page {
    margin: 1.8cm 2cm;
  }
}


/* =============================================
   LIGHT MODE
   Set by assets/theme-toggle.js, which writes data-theme="light" on <html>
   and persists the choice to the "roos_theme" cookie, scoped to
   .rooslabs.com so it is shared by every subdomain. localStorage
   "roos-theme" is a same-origin fast path, not the source of truth.
   Resolution order: ?theme= → cookie → localStorage → dark.
   ============================================= */
html[data-theme="light"] {
  --bg:           #f5f3ef;
  --surface:      #eae7e1;
  --surface-hi:   #e0dcd4;
  --border:       rgba(0, 0, 0, 0.15);
  --border-hi:    rgba(0, 0, 0, 0.24);
  --text:         #1b1b1a;
  --text-muted:   #5d5d58;
  --text-dim:     #64645d;   /* was #6e6e66 — only 4.17:1 on --bg-secondary */
  --accent:       #b3342c;
  --accent-ink:   #b3342c;
  --accent-soft: rgba(179, 52, 44, 0.09);   /* 5.5:1 on parchment — no lift needed */
  --accent-lo:    #b3342c14;
  --accent-mid:   #b3342c3a;
}

/* =============================================
   NAV CHROME  (built by assets/theme-toggle.js)
   The toggle sits inside .nav-links so its placement matches the built
   pages. Below 760px the link row collapses into [ Menu ] and a
   full-screen panel takes over — the panel's links are cloned from the
   nav, so pages don't maintain a second copy.
   ============================================= */
.roos-theme-toggle {
  min-height: 44px;
  padding: 0 14px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 2px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: border-color var(--transition), color var(--transition);
}
.roos-theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* Only used on pages with no .nav-links to mount into. */
.roos-theme-toggle--floating {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 4000;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.rl-menu-btn {
  display: none;
  min-height: 44px;
  padding: 0 14px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 2px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: border-color var(--transition), color var(--transition);
}
.rl-menu-btn:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

.rl-menu-panel {
  position: fixed;
  inset: 0;
  z-index: 4500;
  background: var(--bg);
  padding: 14px clamp(16px, 4vw, 56px) 40px;
  overflow-y: auto;
}
.rl-menu-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 46px;
  margin-bottom: clamp(28px, 8vw, 56px);
}
.rl-menu-brand {
  font-family: var(--font-serif);
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--text);
}
.rl-menu-brand span { color: var(--accent-ink); }
.rl-menu-close {
  min-height: 44px;
  padding: 0 14px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 2px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.rl-menu-close:hover { border-color: var(--accent); color: var(--accent-ink); }
.rl-menu-links {
  display: grid;
  gap: clamp(14px, 4vw, 22px);
}
.rl-menu-links a {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(28px, 8vw, 44px);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.rl-menu-links a:hover { color: var(--accent-ink); }
.rl-menu-links a[aria-current] { color: var(--accent-ink); }

@media (max-width: 760px) {
  /* Hide the real links but keep the two buttons, which are siblings. */
  .nav-links > a { display: none !important; }
  .rl-menu-btn { display: inline-flex !important; align-items: center; }
}
@media (min-width: 761px) {
  .rl-menu-btn { display: none !important; }
  .rl-menu-panel { display: none !important; }
}

@media print {
  .roos-theme-toggle, .rl-menu-btn, .rl-menu-panel { display: none !important; }
}
