/* ==========================================================================
   Engineered Agents AI — Design System
   ========================================================================== */

:root {
  /* Core palette derived from EA logo */
  --ink:        #0B1E2A;        /* deepest navy */
  --ink-2:      #0F2E3E;        /* primary navy (logo left) */
  --ink-3:      #1A3F52;        /* mid navy */
  --teal:       #5FB8B8;        /* logo right */
  --teal-bright:#7DD4D4;
  --teal-deep:  #3E8F8F;
  --bone:       #F4F1EA;        /* warm off-white */
  --paper:      #FAF8F3;
  --rule:       #D9D3C4;
  --dim:        #6B7A82;
  --accent:     #E85D3A;        /* signal orange for alerts/CTAs */

  /* Typography */
  --f-display: 'Fraunces', 'Times New Roman', serif;
  --f-body:    'Inter Tight', -apple-system, BlinkMacSystemFont, sans-serif;
  --f-mono:    'JetBrains Mono', 'SF Mono', 'Courier New', monospace;

  /* Scale */
  --s-0: 0.5rem;
  --s-1: 1rem;
  --s-2: 1.5rem;
  --s-3: 2rem;
  --s-4: 3rem;
  --s-5: 5rem;
  --s-6: 8rem;

  /* Layout */
  --container: 1320px;
  --gutter: clamp(1.25rem, 4vw, 3rem);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.55;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Grain overlay for texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0.035;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Typography */
h1, h2, h3, h4 {
  font-family: var(--f-display);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.02;
  color: var(--ink);
}

h1 { font-size: clamp(3rem, 7.5vw, 7rem); }
h2 { font-size: clamp(2.25rem, 4.5vw, 4rem); }
h3 { font-size: clamp(1.5rem, 2.5vw, 2.25rem); }
h4 { font-size: 1.125rem; font-family: var(--f-body); font-weight: 500; letter-spacing: 0; }

em { font-style: italic; color: var(--teal-deep); }

.mono {
  font-family: var(--f-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}

.mono-small { font-family: var(--f-mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; }

.kicker {
  font-family: var(--f-mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--teal-deep);
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}
.kicker::before {
  content: '';
  width: 24px;
  height: 1px;
  background: var(--teal-deep);
}

/* ==========================================================================
   Navigation
   ========================================================================== */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(250, 248, 243, 0.82);
  border-bottom: 1px solid var(--rule);
}

.nav-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 1rem var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: var(--ink);
}
.brand img { height: 32px; width: auto; display: block; }
.brand-text {
  font-family: var(--f-display);
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  font-weight: 500;
}
.brand-text .dim { color: var(--dim); font-weight: 300; }

.nav-links {
  display: flex;
  gap: 2rem;
  list-style: none;
  align-items: center;
}
.nav-links a {
  color: var(--ink-2);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  position: relative;
  padding: 0.3rem 0;
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--teal-deep); }
.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--teal);
}

.nav-cta {
  background: var(--ink-2);
  color: var(--paper);
  padding: 0.65rem 1.25rem;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 2px;
  transition: background 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.nav-cta:hover { background: var(--teal-deep); }
.nav-cta::after { content: '→'; transition: transform 0.2s; }
.nav-cta:hover::after { transform: translateX(3px); }

.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 0.5rem; }

@media (max-width: 820px) {
  .nav-links { display: none; }
  .nav-toggle { display: block; }
}

/* ==========================================================================
   Layout primitives
   ========================================================================== */

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

section { position: relative; }

.section-head {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--s-4);
  align-items: end;
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--s-4);
}
.section-head h2 { max-width: 20ch; }
@media (max-width: 720px) {
  .section-head { grid-template-columns: 1fr; gap: var(--s-1); }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.95rem 1.6rem;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 2px;
  transition: all 0.2s;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-primary { background: var(--ink-2); color: var(--paper); }
.btn-primary:hover { background: var(--ink); transform: translateY(-1px); box-shadow: 0 10px 30px -10px rgba(15,46,62,0.4); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--ink-2); }
.btn-ghost:hover { background: var(--ink-2); color: var(--paper); }
.btn::after { content: '→'; transition: transform 0.2s; }
.btn:hover::after { transform: translateX(4px); }

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  background: var(--ink-2);
  color: var(--bone);
  padding: var(--s-5) 0 var(--s-3);
  margin-top: var(--s-6);
  position: relative;
  overflow: hidden;
}
.footer::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(95,184,184,0.06) 1px, transparent 1px);
  background-size: 80px 100%;
  pointer-events: none;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: var(--s-3);
  position: relative;
}
.footer-grid h5 {
  font-family: var(--f-mono);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 1.25rem;
  font-weight: 500;
}
.footer a {
  color: var(--bone);
  text-decoration: none;
  display: block;
  padding: 0.25rem 0;
  opacity: 0.75;
  transition: opacity 0.2s;
  font-size: 0.9rem;
}
.footer a:hover { opacity: 1; color: var(--teal-bright); }

.footer-wordmark {
  font-family: var(--f-display);
  font-size: 2rem;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  color: var(--paper);
}
.footer-tagline {
  max-width: 32ch;
  opacity: 0.7;
  font-size: 0.95rem;
  line-height: 1.5;
}

.footer-base {
  margin-top: var(--s-4);
  padding-top: var(--s-2);
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  justify-content: space-between;
  font-family: var(--f-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.6;
  flex-wrap: wrap;
  gap: 1rem;
  position: relative;
}

@media (max-width: 820px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-grid > div:first-child { grid-column: 1 / -1; }
}

/* ==========================================================================
   Reveal animations
   ========================================================================== */

.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.9s cubic-bezier(.2,.65,.3,1), transform 0.9s cubic-bezier(.2,.65,.3,1);
}
.reveal.in { opacity: 1; transform: none; }
.reveal[data-delay="1"] { transition-delay: 0.08s; }
.reveal[data-delay="2"] { transition-delay: 0.16s; }
.reveal[data-delay="3"] { transition-delay: 0.24s; }
.reveal[data-delay="4"] { transition-delay: 0.32s; }
.reveal[data-delay="5"] { transition-delay: 0.4s; }

/* Focus */
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}

/* Selection */
::selection { background: var(--teal); color: var(--ink); }

/* Grid background utility */
.grid-bg {
  background-image:
    linear-gradient(to right, rgba(15,46,62,0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15,46,62,0.04) 1px, transparent 1px);
  background-size: 80px 80px;
}

/* ==========================================================================
   Contact Modal (triggered by mailto links)
   ========================================================================== */
.ea-modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(11, 30, 42, 0.72);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center; justify-content: center;
  padding: 1rem;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.ea-modal-backdrop.open { display: flex; opacity: 1; }
.ea-modal {
  background: var(--paper);
  color: var(--ink);
  width: 100%; max-width: 520px;
  border-radius: 8px;
  box-shadow: 0 40px 80px -20px rgba(0,0,0,0.5);
  transform: translateY(12px);
  transition: transform 0.25s ease;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}
.ea-modal-backdrop.open .ea-modal { transform: translateY(0); }
.ea-modal-header {
  padding: 1.75rem 2rem 1rem;
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
}
.ea-modal-header h3 {
  font-family: var(--f-display); font-size: 1.65rem; line-height: 1.1; font-weight: 400;
}
.ea-modal-header p {
  margin-top: 0.5rem; font-size: 0.92rem; color: var(--dim); line-height: 1.45;
}
.ea-modal-close {
  background: transparent; border: 0; cursor: pointer;
  width: 32px; height: 32px; border-radius: 4px;
  color: var(--dim); font-size: 1.3rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ea-modal-close:hover { background: var(--rule); color: var(--ink); }
.ea-modal-body { padding: 1.5rem 2rem 2rem; }
.ea-modal-body label {
  display: block;
  font-family: var(--f-mono); font-size: 0.68rem;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--dim); margin-bottom: 0.4rem;
}
.ea-modal-body input,
.ea-modal-body textarea {
  width: 100%;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.75rem 0.9rem;
  font-family: var(--f-body);
  font-size: 0.95rem;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ea-modal-body input:focus,
.ea-modal-body textarea:focus {
  outline: none;
  border-color: var(--teal-deep);
  box-shadow: 0 0 0 3px rgba(95, 184, 184, 0.15);
}
.ea-modal-body textarea { resize: vertical; min-height: 110px; }
.ea-modal-row { margin-bottom: 1.1rem; }
.ea-modal-row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 520px) { .ea-modal-row.two { grid-template-columns: 1fr; } }
.ea-hp { position: absolute !important; left: -9999px !important; opacity: 0 !important; pointer-events: none !important; }
.ea-modal-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin-top: 0.5rem; flex-wrap: wrap;
}
.ea-modal-footer small { font-size: 0.75rem; color: var(--dim); }
.ea-submit {
  background: var(--ink-2); color: var(--paper);
  border: 0; border-radius: 2px;
  padding: 0.7rem 1.4rem;
  font-family: var(--f-body); font-size: 0.9rem; font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  display: inline-flex; align-items: center; gap: 0.5rem;
}
.ea-submit:hover { background: var(--ink); }
.ea-submit:disabled { opacity: 0.6; cursor: wait; }
.ea-submit::after { content: '→'; transition: transform 0.2s; }
.ea-submit:hover::after { transform: translateX(3px); }
.ea-modal-status {
  margin-top: 1rem; padding: 0.75rem 1rem; border-radius: 4px; font-size: 0.9rem;
  display: none;
}
.ea-modal-status.success { display: block; background: rgba(95, 184, 184, 0.12); color: var(--teal-deep); border: 1px solid rgba(95, 184, 184, 0.3); }
.ea-modal-status.error   { display: block; background: rgba(232, 93, 58, 0.08); color: var(--accent); border: 1px solid rgba(232, 93, 58, 0.3); }
