/* =========================================================================
   RELAY — systems integration site
   Single stylesheet. Tokens → base → layout → components → RTL → a11y → responsive
   Replace the "Relay" brand, colors, and copy freely.
   ========================================================================= */

/* ---- 1. Design tokens ---------------------------------------------------- */
:root {
  /* Palette — physical (amber) meets digital (teal) on a deep slate base */
  --bg:          #0B1017;
  --surface:     #121A24;
  --surface-2:   #18222E;
  --border:      #26333F;
  --border-soft: #1E2A36;

  --text:        #E7EDF3;
  --text-dim:    #92A2B3;
  --text-faint:  #64748B;

  --amber:       #F6A821;   /* physical / industrial signal */
  --amber-soft:  #f6a82122;
  --teal:        #3AD1C8;   /* digital / enterprise data   */
  --teal-soft:   #3ad1c822;

  --accent:      var(--amber);
  --danger:      #ff6b6b;
  --ok:          #4ade80;

  /* Type */
  --font-display: "Space Grotesk", "IBM Plex Sans Hebrew", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --font-body:    "IBM Plex Sans", "IBM Plex Sans Hebrew", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;

  /* Rhythm */
  --wrap: 1180px;
  --gap: clamp(1rem, 3vw, 2rem);
  --radius: 14px;
  --radius-lg: 22px;
  --shadow: 0 18px 50px -20px rgba(0,0,0,.7);

  --header-h: 68px;
  --ease: cubic-bezier(.22,.61,.36,1);
}

/* High-contrast mode — toggled from the accessibility panel */
html.hc {
  --bg:        #000000;
  --surface:   #0a0a0a;
  --surface-2: #141414;
  --border:    #6b7683;
  --border-soft:#4a5560;
  --text:      #ffffff;
  --text-dim:  #d6dde4;
  --text-faint:#b8c0c8;
  --amber:     #ffc24d;
  --teal:      #5ef2e8;
}

/* Light mode — optional toggle */
html.light {
  --bg:        #f5f7fa;
  --surface:   #ffffff;
  --surface-2: #eef2f6;
  --border:    #d3dce4;
  --border-soft:#e4eaf0;
  --text:      #0f1b28;
  --text-dim:  #4a5c6e;
  --text-faint:#7a8a9a;
  --amber:     #c67c00;
  --teal:      #0f9a90;
  --shadow: 0 18px 50px -24px rgba(15,27,40,.25);
}

/* Readable-font toggle (dyslexia-friendly stack) */
html.readable, html.readable body { --font-body: "Atkinson Hyperlegible", Verdana, sans-serif; }
html.readable .h-display { font-family: var(--font-body); letter-spacing: 0; }

/* ---- 2. Base ------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Ambient background grid — subtle, evokes a control board */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1100px 500px at 80% -10%, var(--teal-soft), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, var(--amber-soft), transparent 55%),
    linear-gradient(transparent 31px, var(--border-soft) 32px) 0 0 / 100% 32px,
    linear-gradient(90deg, transparent 31px, var(--border-soft) 32px) 0 0 / 32px 100%;
  opacity: .5;
  mask-image: linear-gradient(to bottom, #000 0%, #000 30%, transparent 75%);
  pointer-events: none;
}

h1,h2,h3,h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.1; margin: 0 0 .5em; letter-spacing: -.01em; }
p { margin: 0 0 1rem; }
a { color: inherit; text-decoration: none; }
img, svg { max-width: 100%; }
ul { margin: 0; padding: 0; list-style: none; }

.h-display { font-family: var(--font-display); }
.mono { font-family: var(--font-mono); }

/* Focus — always visible, thick, high-contrast */
:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 3px;
  border-radius: 4px;
}
html.link-highlight a:not(.btn) {
  text-decoration: underline;
  text-underline-offset: 3px;
  color: var(--amber);
}

/* Skip link */
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 200;
  background: var(--amber); color: #10161e; font-weight: 600;
  padding: .6rem 1rem; border-radius: 8px; transition: top .2s var(--ease);
}
.skip-link:focus { top: 12px; }

/* ---- 3. Layout ----------------------------------------------------------- */
.wrap { width: min(100% - 2.4rem, var(--wrap)); margin-inline: auto; }
.section { padding-block: clamp(3.5rem, 8vw, 6.5rem); position: relative; }
.section--tight { padding-block: clamp(2.5rem, 5vw, 4rem); }

.eyebrow {
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--teal);
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  margin-bottom: 1rem;
}
.eyebrow::before {
  content: ""; width: 26px; height: 1px; background: var(--teal);
  display: inline-block;
}

.section-title { font-size: clamp(1.7rem, 4vw, 2.6rem); max-width: 20ch; }
.lead { font-size: clamp(1rem, 2vw, 1.18rem); color: var(--text-dim); max-width: 60ch; }

/* ---- 4. Buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: .55rem;
  font-family: var(--font-body); font-weight: 600; font-size: .95rem;
  padding: .8rem 1.35rem; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent; transition: transform .15s var(--ease), background .2s, border-color .2s;
  text-align: center;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--amber); color: #10161e; }
.btn-primary:hover { background: #ffb43e; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--teal); color: var(--teal); }
.btn svg { width: 18px; height: 18px; }

/* ---- 5. Header ----------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  display: flex; align-items: center;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}
.site-header .wrap { display: flex; align-items: center; gap: 1.5rem; width: min(100% - 2.4rem, var(--wrap)); }

.brand { display: inline-flex; align-items: center; gap: .6rem; font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; letter-spacing: .02em; }
.brand .glyph { width: 30px; height: 30px; flex: none; }

.nav { display: flex; align-items: center; gap: .35rem; margin-inline-start: auto; }
.nav a {
  font-size: .92rem; color: var(--text-dim); padding: .5rem .75rem; border-radius: 8px;
  transition: color .18s, background .18s;
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); background: var(--surface); }
.nav a[aria-current="page"] { color: var(--amber); }

.header-tools { display: flex; align-items: center; gap: .4rem; }

/* icon buttons (lang + a11y) */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  height: 40px; min-width: 40px; padding: 0 .6rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); cursor: pointer; font-family: var(--font-mono); font-size: .78rem;
  transition: border-color .18s, color .18s;
}
.icon-btn:hover { border-color: var(--teal); color: var(--teal); }
.icon-btn svg { width: 20px; height: 20px; }

.nav-toggle { display: none; }

/* mobile menu */
@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; }
  .nav {
    position: fixed; inset: var(--header-h) 0 auto 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: .5rem; margin: 0;
    transform: translateY(-120%); transition: transform .3s var(--ease);
    box-shadow: var(--shadow);
  }
  .nav.open { transform: translateY(0); }
  .nav a { padding: .9rem 1rem; font-size: 1rem; }
}

/* ---- 6. Hero + signal-flow signature ------------------------------------ */
.hero { padding-top: clamp(2.5rem, 6vw, 4.5rem); padding-bottom: clamp(3rem, 7vw, 5.5rem); }
.hero-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: clamp(1.5rem, 4vw, 3.5rem); align-items: center; }
.hero h1 { font-size: clamp(2.2rem, 5.5vw, 3.9rem); margin-bottom: 1rem; }
.hero h1 .hl { color: var(--amber); }
.hero h1 .hl2 { color: var(--teal); }
.hero .lead { margin-bottom: 1.8rem; }
.hero-cta { display: flex; gap: .8rem; flex-wrap: wrap; }
.hero-stats { display: flex; gap: 2rem; margin-top: 2.4rem; flex-wrap: wrap; }
.hero-stats .num { font-family: var(--font-display); font-size: 1.7rem; color: var(--text); }
.hero-stats .lbl { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); }

.signal-stage {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.25rem; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.signal-stage .cap {
  display: flex; justify-content: space-between; font-family: var(--font-mono);
  font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint);
  margin-bottom: .5rem;
}
.signal-stage svg { width: 100%; height: auto; display: block; }

/* animated pulse along the connector wire */
.wire { stroke: var(--border); stroke-width: 2; fill: none; }
.wire-live {
  stroke: var(--amber); stroke-width: 2.5; fill: none;
  stroke-dasharray: 14 220; stroke-linecap: round;
  animation: flow 3.2s linear infinite;
}
.wire-live.rev { stroke: var(--teal); animation-delay: 1.6s; }
@keyframes flow { to { stroke-dashoffset: -234; } }

.node-phys circle { fill: var(--amber-soft); stroke: var(--amber); }
.node-dig  circle { fill: var(--teal-soft);  stroke: var(--teal);  }
.pulse-dot { animation: blink 2.4s ease-in-out infinite; }
@keyframes blink { 0%,100%{opacity:.35} 50%{opacity:1} }

@media (prefers-reduced-motion: reduce) {
  .wire-live, .pulse-dot { animation: none; }
  .wire-live { stroke-dasharray: none; }
}
html.no-motion .wire-live, html.no-motion .pulse-dot,
html.no-motion * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }

/* ---- 7. Cards / grids ---------------------------------------------------- */
.grid { display: grid; gap: 1.1rem; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
  transition: border-color .2s, transform .2s var(--ease), background .2s;
  position: relative; overflow: hidden;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); transform: translateY(-3px); }
.card h3 { font-size: 1.2rem; margin-bottom: .4rem; }
.card p { color: var(--text-dim); font-size: .95rem; margin: 0; }

.card .idx { font-family: var(--font-mono); font-size: .72rem; color: var(--text-faint); letter-spacing: .1em; }
.svc-icon {
  width: 46px; height: 46px; border-radius: 11px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 1rem;
}
.svc-icon svg { width: 24px; height: 24px; }
/* alternate the accent per card to reinforce physical↔digital */
.card--phys .svc-icon { border-color: color-mix(in srgb, var(--amber) 50%, var(--border)); color: var(--amber); }
.card--dig  .svc-icon { border-color: color-mix(in srgb, var(--teal) 50%, var(--border)); color: var(--teal); }
.card--phys:hover { border-color: color-mix(in srgb, var(--amber) 55%, var(--border)); }
.card--dig:hover  { border-color: color-mix(in srgb, var(--teal) 55%, var(--border)); }

.tag { font-family: var(--font-mono); font-size: .7rem; letter-spacing: .06em; color: var(--text-faint); border: 1px solid var(--border); border-radius: 999px; padding: .2rem .6rem; display: inline-block; }

/* process steps (numbered — a real sequence, so numbers earn their place) */
.steps { counter-reset: step; display: grid; gap: 1rem; }
.step { display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: start; padding: 1.2rem; border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--surface); }
.step::before { counter-increment: step; content: counter(step,decimal-leading-zero); font-family: var(--font-mono); color: var(--amber); font-size: .95rem; padding-top: .1rem; }

/* logo strip */
.logos { display: flex; flex-wrap: wrap; gap: 1.2rem 2.4rem; align-items: center; justify-content: center; opacity: .7; }
.logos span { font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; color: var(--text-faint); }

/* callout / CTA band */
.cta-band {
  background: linear-gradient(120deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: clamp(2rem, 5vw, 3.2rem); text-align: center;
}
.cta-band h2 { font-size: clamp(1.6rem, 3.5vw, 2.3rem); }

/* ---- 8. Forms + integration mini-tool ----------------------------------- */
.field { display: grid; gap: .4rem; margin-bottom: 1rem; }
.field label { font-size: .85rem; color: var(--text-dim); font-weight: 500; }
.field input, .field textarea, .field select {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font: inherit; padding: .75rem .85rem; width: 100%;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 3px var(--teal-soft); }
.field .req { color: var(--amber); }
.form-note { font-size: .85rem; color: var(--text-faint); }
.form-status { font-size: .9rem; padding: .75rem 1rem; border-radius: 10px; margin-top: .5rem; display: none; }
.form-status.show { display: block; }
.form-status.ok { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); }
.form-status.err { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); }

.tool { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: clamp(1.4rem, 4vw, 2rem); }
.tool .opts { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1.2rem; }
.chip {
  font: inherit; font-size: .9rem; padding: .55rem 1rem; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim); cursor: pointer;
  transition: all .18s;
}
.chip[aria-pressed="true"] { background: var(--amber); color: #10161e; border-color: var(--amber); font-weight: 600; }
.chip:hover { border-color: var(--teal); }
.tool-result { margin-top: 1.2rem; padding: 1.2rem; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface-2); font-size: .95rem; color: var(--text-dim); min-height: 3rem; }
.tool-result strong { color: var(--teal); }

/* ---- 9. Footer ----------------------------------------------------------- */
.site-footer { border-top: 1px solid var(--border-soft); padding-block: 3rem 2rem; margin-top: 2rem; }
.footer-grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 2rem; margin-bottom: 2.5rem; }
.footer-grid h4 { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 1rem; }
.footer-grid a { display: block; color: var(--text-dim); font-size: .92rem; padding: .25rem 0; }
.footer-grid a:hover { color: var(--teal); }
.footer-bottom { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-top: 1px solid var(--border-soft); padding-top: 1.5rem; color: var(--text-faint); font-size: .85rem; }

/* ---- 10. Accessibility panel -------------------------------------------- */
.a11y-panel {
  position: fixed; inset-block-start: 0; inset-inline-end: 0; z-index: 300;
  width: min(360px, 92vw); height: 100dvh; overflow-y: auto;
  background: var(--surface); border-inline-start: 1px solid var(--border);
  box-shadow: var(--shadow); padding: 1.5rem;
  transform: translateX(110%); transition: transform .3s var(--ease);
}
[dir="rtl"] .a11y-panel { transform: translateX(-110%); }
.a11y-panel.open { transform: translateX(0); }
.a11y-panel h2 { font-size: 1.15rem; display: flex; justify-content: space-between; align-items: center; }
.a11y-panel .close { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 1.5rem; line-height: 1; padding: .2rem .4rem; }
.a11y-group { margin: 1.4rem 0; }
.a11y-group h3 { font-family: var(--font-mono); font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint); margin-bottom: .7rem; }
.a11y-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.a11y-toggle {
  flex: 1 1 auto; min-width: 46%; font: inherit; font-size: .88rem;
  padding: .65rem .7rem; border-radius: 10px; cursor: pointer; text-align: start;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
  display: flex; align-items: center; gap: .5rem; transition: all .18s;
}
.a11y-toggle[aria-pressed="true"] { border-color: var(--teal); color: var(--text); background: color-mix(in srgb, var(--teal) 12%, var(--surface-2)); }
.a11y-toggle .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border); flex: none; }
.a11y-toggle[aria-pressed="true"] .dot { background: var(--teal); }
.a11y-reset { width: 100%; margin-top: .5rem; }
.a11y-note { font-size: .78rem; color: var(--text-faint); margin-top: 1.2rem; line-height: 1.5; }

.a11y-scrim { position: fixed; inset: 0; z-index: 250; background: rgba(0,0,0,.5); opacity: 0; visibility: hidden; transition: opacity .3s; }
.a11y-scrim.open { opacity: 1; visibility: visible; }

/* lang menu */
.lang-menu {
  position: absolute; inset-block-start: calc(100% + 6px); inset-inline-end: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: .35rem; box-shadow: var(--shadow); min-width: 160px; display: none; z-index: 120;
}
.lang-menu.open { display: block; }
.lang-menu button {
  width: 100%; text-align: start; font: inherit; font-size: .9rem; padding: .55rem .7rem;
  background: none; border: none; color: var(--text-dim); border-radius: 8px; cursor: pointer;
  display: flex; justify-content: space-between; gap: 1rem;
}
.lang-menu button:hover { background: var(--surface-2); color: var(--text); }
.lang-menu button[aria-current="true"] { color: var(--amber); }
.lang-wrap { position: relative; }

/* ---- 11. RTL ------------------------------------------------------------- */
[dir="rtl"] body { line-height: 1.75; }
[dir="rtl"] .eyebrow::before { /* logical—handled by inline-flex + gap already */ }
[dir="rtl"] .hero-grid { direction: rtl; }
/* keep the signal diagram LTR-neutral; it's symbolic, not textual */
[dir="rtl"] .wire-live { animation-direction: reverse; }

/* ---- 12. Responsive ------------------------------------------------------ */
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .footer-bottom { justify-content: flex-start; }
  .hero-stats { gap: 1.4rem; }
}

/* utilities */
.center { text-align: center; }
.mx-auto { margin-inline: auto; }
.mt-2 { margin-top: 2rem; }
.mt-3 { margin-top: 3rem; }
.muted { color: var(--text-dim); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(1.5rem,4vw,3rem); align-items: center; }
@media (max-width:820px){ .split{ grid-template-columns:1fr; } }
.visually-hidden { position:absolute; width:1px; height:1px; margin:-1px; padding:0; overflow:hidden; clip:rect(0 0 0 0); border:0; }
