/* ═══════════════════════════════════════════════════════════════
   PHM ENGINE SYSTEM — v1.0  (Crown Green · Light Theme)
   PHM Engine pages only. Extends phm-design-system.
   Green identity: #0D5C2E Crown Green replaces platform amber.
   ═══════════════════════════════════════════════════════════════ */

/* ── FONT LOAD ── */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,400;0,700;0,900;1,700;1,900&family=Figtree:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

/* ── DESIGN TOKENS ── */
:root {

  /* Typography */
  --font:         'Figtree', system-ui, -apple-system, sans-serif;
  --display-font: 'Montserrat', system-ui, sans-serif;
  --mono:         'DM Mono', 'Courier New', monospace;

  /* Type scale */
  --f-xs:    0.65rem;
  --f-sm:    0.72rem;
  --f-label: 0.78rem;
  --f-body:  1rem;
  --f-md:    1.1rem;
  --f-lg:    1.2rem;
  --f-xl:    1.4rem;
  --f-2xl:   1.8rem;
  --f-3xl:   2.4rem;
  --f-4xl:   3.2rem;

  /* Font weights */
  --fw-light:   300;
  --fw-regular: 400;
  --fw-medium:  500;
  --fw-semi:    600;
  --fw-bold:    700;
  --fw-black:   900;

  /* Line heights */
  --lh-tight:   1.1;
  --lh-snug:    1.2;
  --lh-normal:  1.75;
  --lh-relaxed: 1.75;

  /* ── Color palette ── */

  /* Backgrounds — light theme */
  --bg:       transparent;
  --panel:    rgba(255,255,255,0.38);
  --card:     rgba(255,255,255,0.60);
  --card2:    rgba(255,255,255,0.40);

  /* Navigation & dark sections */
  --nav-bg:   #1C1C1C;
  --hero-bg:  #1C1C1C;
  --footer-bg:#1C1C1C;

  /* Text */
  --white:    rgba(0,0,0,0.82);
  --text:     rgba(0,0,0,0.70);
  --mute:     rgba(0,0,0,0.45);
  --dim:      rgba(0,0,0,0.30);
  --silver:   rgba(255,255,255,0.55);

  /* Borders */
  --line:      rgba(0,0,0,0.10);
  --line-dark: rgba(255,255,255,0.08);

  /* Brand amber */
  --green:    #0D5C2E;
  --green-l:  #0D5C2E;
  --green-lt: #2A7A4A;
  --green-d:  rgba(13,92,46,0.06);

  /* Semantic */
  --red-l:    #A82818;
  --red-d:    rgba(168,40,24,0.06);
  --green-l:  #1A6838;
  --green-d:  rgba(26,104,56,0.06);
  --blue:     #2563EB;
  --blue-l:   #3B82F6;
  --blue-d:   #EFF6FF;

  /* Legacy aliases — so old var() references resolve correctly */
  --ink:       rgba(0,0,0,0.82);
  --navy:      #1C1C1C;
  --navy-mid:  rgba(255,255,255,0.38);
  --navy-card: rgba(255,255,255,0.60);
  --navy-line: rgba(0,0,0,0.10);
  --navy-mute: rgba(0,0,0,0.45);
  --text-mute: rgba(0,0,0,0.45);
  --text-dim:  rgba(0,0,0,0.30);
  --sub:       rgba(0,0,0,0.60);
  --rule:      rgba(0,0,0,0.10);

  /* ── Spacing ── */
  --s1:  0.5rem;
  --s2:  1rem;
  --s3:  1.5rem;
  --s4:  2rem;
  --s5:  3rem;
  --s6:  5rem;
  --s7:  7.5rem;

  /* ── Layout ── */
  --max-w:     1320px;
  --content-w: 980px;
  --radius:    6px;
  --radius-sm: 4px;
  --radius-lg: 10px;


  /* ── Engine page legacy var remaps ── */
  /* Text vars (were white-on-dark, now dark-on-light) */
  --t0: rgba(0,0,0,0.82);
  --t1: rgba(0,0,0,0.70);
  --t2: rgba(0,0,0,0.55);
  --t3: rgba(0,0,0,0.40);
  /* Row/background vars */
  --r0: rgba(0,0,0,0.10);
  --r1: rgba(0,0,0,0.08);
  --r2: rgba(0,0,0,0.06);
  /* Gutters and layout */
  --gut: 56px;
  --max: 1320px;
  /* Green signal vars */
  --g:  #0D5C2E;
  --gl: #2A7A4A;
  --gd: rgba(13,92,46,0.06);
  /* Signal environment section backgrounds (intentional dark) */
  --dbg:  #1C1C1C;
  --dbg2: #1C1C1C;
  --dbg3: #1C1C1C;

  /* ── Green identity (Engine) ── */
  --green:    #0D5C2E;
  --green-l:  #0D5C2E;
  --green-lt: #2A7A4A;
  --green-d:  rgba(13,92,46,0.06);
  /* Keep amber aliases pointing to green for engine pages */
  --amber:    #0D5C2E;
  --amber-l:  #0D5C2E;
  --amber-lt: #2A7A4A;
  --amber-d:  rgba(13,92,46,0.06);

  /* ── Transitions ── */
  --ease: 0.15s ease;
}

/* ── RESET ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 18px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  padding-top: 64px;
  font-family: var(--font);
  font-size: var(--f-body);
  font-weight: var(--fw-light);
  line-height: var(--lh-normal);
  color: var(--text);
  background: linear-gradient(to right,#C8C8C8 0%,#D4D4D4 25%,#E0E0E0 50%,#EBEBEB 72%,#F2F2F2 88%,#F8F8F8 100%) fixed;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(90deg,rgba(0,0,0,0.025) 0px 8px,transparent 8px 36px);
  opacity: .30;
  pointer-events: none;
  z-index: 0;
}

/* ── BASE TYPOGRAPHY ── */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Montserrat', system-ui, sans-serif;
  font-weight: 700;
  color: var(--white);
  line-height: var(--lh-tight);
  letter-spacing: -0.02em;
}

h1 { font-size: var(--f-4xl); font-weight: 900; }
h2 { font-size: var(--f-2xl); font-weight: 900; }
h3 { font-size: var(--f-xl); }
h4 { font-size: var(--f-lg); font-weight: 700; }

p  { line-height: var(--lh-normal); }
a  { text-decoration: none; color: inherit; }
strong { font-weight: 600; }

/* ── NAV — CANONICAL ── */
nav {
  background: var(--nav-bg);
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  border-bottom: 1px solid var(--line-dark);
  height: 64px;
}

.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.nav-logo {
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-logo-top {
  font-family: 'Montserrat', sans-serif;
  font-size: var(--f-md);
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
  line-height: 1;
  white-space: nowrap;
}

.nav-logo-top:hover { color: var(--green-lt); }

.nav-logo-sub {
  font-family: 'Montserrat', sans-serif;
  font-size: var(--f-xs);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--green-l);
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.nav-logo-sub::before {
  content: '';
  width: 16px;
  height: 1px;
  background: var(--green-l);
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
}

.nav-links li a {
  font-family: 'Figtree', sans-serif;
  font-size: var(--f-label);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--silver);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: color var(--ease), background var(--ease);
  white-space: nowrap;
}

.nav-links li a:hover     { color: #fff; background: rgba(255,255,255,0.06); }
.nav-links li a.nav-active { color: #fff; font-weight: 600; }
.nav-links li a.nav-amber  { color: var(--green-lt); }
.nav-links li a.nav-red    { color: #F87171; }

.nav-links li a.btn-nav {
  background: var(--green-l);
  color: #fff;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  padding: 9px 20px;
  border-radius: var(--radius);
  letter-spacing: 0.06em;
}
.nav-links li a.btn-nav:hover { background: var(--green-lt); }

.nav-pill {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
}
.nav-pill--amber { background: rgba(13,92,46,0.15); color: var(--green-l); }
.nav-pill--red   { background: rgba(168,40,24,0.10);  color: #F87171; }

/* Mobile nav */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 6px;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 1.5px;
  background: rgba(255,255,255,0.70);
  transition: all var(--ease);
}

.mobile-menu {
  display: none;
  position: fixed;
  top: 64px;
  left: 0; right: 0;
  background: var(--nav-bg);
  border-top: 1px solid var(--line-dark);
  padding: 16px 24px 24px;
  flex-direction: column;
  gap: 2px;
  z-index: 999;
}

.mobile-menu a {
  font-family: 'Figtree', sans-serif;
  font-size: var(--f-label);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--silver);
  text-decoration: none;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.mobile-menu a:hover, .mobile-menu a.active { color: #fff; }

.mob-cta, .sw-mob-cta, .ea-mob-cta {
  display: inline-block;
  background: var(--green-l);
  color: #fff !important;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  padding: 12px 20px;
  margin-top: 12px;
  text-align: center;
  border-bottom: none !important;
  border-radius: var(--radius);
  letter-spacing: 0.06em;
}

@media (max-width: 768px) {
  .hamburger   { display: flex; }
  .nav-links   { display: none; }
  .nav-inner   { padding: 0 20px; }
  .mobile-menu.open { display: flex; }
}

/* ── SECTION RHYTHM ── */
.section       { padding: var(--s6) 0; }
.section-hero  { padding: var(--s7) 0 var(--s6); }
.section-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 36px;
  position: relative;
  z-index: 1;
}
.section-inner--narrow {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 0 36px;
}

/* ── EYEBROWS ── */
.eyebrow {
  font-family: 'Montserrat', sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--green-l);
  margin-bottom: 12px;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Montserrat', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 12px 24px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--ease);
  white-space: nowrap;
}

.btn-primary, .btn.primary {
  background: var(--green-l);
  color: #fff;
}
.btn-primary:hover, .btn.primary:hover { background: var(--green-lt); }

.btn-outline {
  background: transparent;
  color: var(--green-l);
  border: 1.5px solid var(--green-l);
}
.btn-outline:hover { background: var(--green-d); }

.btn-ghost {
  background: transparent;
  color: var(--mute);
  border: 1.5px solid var(--line);
}
.btn-ghost:hover { border-color: var(--mute); color: var(--white); }

/* ── CARDS ── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--s4);
  position: relative;
  z-index: 1;
}

.card-amber { border-top: 3px solid var(--green-l); }

/* ── FOOTER ── */
footer, .footer {
  background: var(--footer-bg);
  color: var(--silver);
  padding: 48px 0 32px;
  position: relative;
  z-index: 1;
}

/* ── UTILITY ── */
.text-muted { color: var(--mute); }
.text-amber { color: var(--green-l); }
.text-white { color: #fff; }
.text-body  { color: var(--text); }

.bg-dark  { background: var(--hero-bg); }
.bg-panel { background: var(--panel); }

/* Dark section — text must be white */
.bg-dark *, .bg-dark h1, .bg-dark h2, .bg-dark h3 { color: #fff; }
.bg-dark .text-muted { color: rgba(255,255,255,0.50); }

@media (max-width: 768px) {
  :root {
    --f-4xl: 2.5rem;
    --f-3xl: 2rem;
    --f-2xl: 1.75rem;
    --f-xl:  1.5rem;
    --s6: 3.5rem;
    --s7: 5rem;
  }
  .section-inner,
  .section-inner--narrow { padding: 0 20px; }
}

/* ── Engine page typography overrides ── */
/* Replace Instrument Serif with Montserrat italic */
[style*="Instrument Serif"],
.cases-cv,
.rh-l1, .rh-l2, .rh-em {
  font-family: 'Montserrat', sans-serif !important;
  font-style: italic;
}

/* Fix text vars used in inline styles */
[style*="color:var(--t0)"] { color: rgba(0,0,0,0.82) !important; }
[style*="color:var(--t1)"] { color: rgba(0,0,0,0.70) !important; }
[style*="color:var(--t2)"] { color: rgba(0,0,0,0.55) !important; }
[style*="color:var(--t3)"] { color: rgba(0,0,0,0.40) !important; }

/* Dark signal environment sections (intentional dark) */
[style*="background:var(--dbg)"],
[style*="background:#1C1C1C"] {
  color: rgba(255,255,255,0.82);
}
[style*="background:var(--dbg)"] *,
[style*="background:#1C1C1C"] * {
  color: inherit;
}

/* Consistent card treatment */
[style*="background:var(--bg)"],
[style*="background:var(--bg2)"],
[style*="background:var(--r0)"],
[style*="background:var(--r1)"] {
  background: rgba(255,255,255,0.60) !important;
  border: 1px solid rgba(0,0,0,0.10) !important;
}

/* Green border accents */
[style*="border-top:2px solid var(--g)"],
[style*="border-left:2px solid var(--g)"],
[style*="border-left:3px solid var(--g)"] {
  border-color: #0D5C2E !important;
}

/* Canvas section — keep dark wrapper */
#viz {
  display: block;
  width: 100%;
  height: auto;
}

/* ── Engine nav additions ── */
.nav-back-link {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.30);
  text-decoration: none;
  transition: color 0.15s;
  white-space: nowrap;
}
.nav-back-link:hover { color: rgba(255,255,255,0.65); }

.nav-eng-badge {
  color: var(--green-l);
}

/* Engine nav: logo-sub uses green instead of amber */
.nav-logo-sub {
  color: var(--green-l) !important;
}
.nav-logo-sub::before {
  background: var(--green-l) !important;
}

/* Hamburger JS toggle */
.mobile-menu.open { display: flex; }
