/* ==========================================================================
   RH Mechatronics — single-page portfolio
   ========================================================================== */

:root {
  --bg: #f5f7fb;
  --bg-alt: #e9eef7;
  --surface: #ffffff;
  --text: #111827;
  --text-muted: #4f5a6e;
  --border: #d6deeb;
  --accent: #2f6fed;          /* brand blue */
  --accent-hover: #255fd4;
  --accent-ink: #ffffff;      /* text on accent */
  --accent-text: #1f5bd6;     /* accent used as text on light bg (AA) */
  --accent-light: #7fb0ff;    /* accent on dark backgrounds */
  --dark: #0b1324;
  --dark-2: #111b30;
  --on-dark: #eef2f9;
  --on-dark-muted: #a7b3c8;

  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(11 19 36 / .06), 0 8px 24px rgb(11 19 36 / .07);
  --shadow-lift: 0 2px 4px rgb(11 19 36 / .08), 0 18px 40px rgb(11 19 36 / .13);
  --nav-h: 68px;
  --gutter: clamp(16px, 4vw, 32px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1120;
    --bg-alt: #0e1729;
    --surface: #131e34;
    --text: #eef2f9;
    --text-muted: #a3afc4;
    --border: #22314d;
    --accent-text: #7fb0ff;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
    --shadow-lift: 0 2px 4px rgb(0 0 0 / .35), 0 18px 40px rgb(0 0 0 / .4);
  }
}
:root[data-theme="dark"] {
  --bg: #0a1120;
  --bg-alt: #0e1729;
  --surface: #131e34;
  --text: #eef2f9;
  --text-muted: #a3afc4;
  --border: #22314d;
  --accent-text: #7fb0ff;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
  --shadow-lift: 0 2px 4px rgb(0 0 0 / .35), 0 18px 40px rgb(0 0 0 / .4);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: var(--nav-h); -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; }

.container { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 var(--gutter); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: var(--radius-sm); font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 12px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: .78rem;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent-text);
  margin-bottom: .9rem;
  display: inline-flex;
  align-items: center;
  gap: .6rem;
}
.eyebrow::before { content: ""; width: 22px; height: 2px; background: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .55rem;
  padding: .85rem 1.35rem;
  border-radius: 999px;
  font-weight: 600; font-size: .98rem;
  text-decoration: none;
  border: 1.5px solid transparent;
  transition: transform .15s ease, background-color .2s ease, border-color .2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { border-color: rgb(255 255 255 / .35); color: var(--on-dark); }
.btn-ghost:hover { border-color: var(--on-dark); background: rgb(255 255 255 / .06); }

/* ---------- Nav ---------- */
.site-nav {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  height: var(--nav-h);
  color: var(--on-dark);
  transition: background-color .25s ease, box-shadow .25s ease;
}
.site-nav.is-scrolled, .site-nav.is-open {
  background: rgb(11 19 36 / .92);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  box-shadow: 0 1px 0 rgb(255 255 255 / .06);
}
.nav-inner { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .65rem; text-decoration: none; font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; }
.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink);
  font-size: .85rem; letter-spacing: .02em;
}
.nav-menu { display: flex; align-items: center; gap: .35rem; }
.nav-menu a {
  text-decoration: none; font-size: .95rem; font-weight: 500;
  padding: .5rem .85rem; border-radius: 999px;
  color: var(--on-dark-muted);
  transition: color .2s ease, background-color .2s ease;
}
.nav-menu a:hover, .nav-menu a.is-active { color: var(--on-dark); }
.nav-menu a.is-active:not(.nav-cta) { background: rgb(255 255 255 / .08); }
.nav-menu .nav-cta { background: var(--accent); color: var(--accent-ink); margin-left: .4rem; }
.nav-menu .nav-cta:hover { color: var(--accent-ink); background: var(--accent-hover); }
.nav-toggle { display: none; background: none; border: 0; padding: 8px; margin-right: -8px; cursor: pointer; color: var(--on-dark); }

@media (max-width: 760px) {
  .nav-toggle { display: inline-flex; }
  .nav-menu {
    position: absolute; top: var(--nav-h); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    padding: .5rem var(--gutter) 1.25rem;
    background: rgb(11 19 36 / .97);
    border-bottom: 1px solid rgb(255 255 255 / .06);
    display: none;
  }
  .site-nav.is-open .nav-menu { display: flex; }
  .nav-menu a { padding: .8rem 1rem; border-radius: var(--radius-sm); }
  .nav-menu .nav-cta { margin: .5rem 0 0; text-align: center; }
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: min(100svh, 860px);
  display: flex; align-items: center;
  padding: calc(var(--nav-h) + 3rem) 0 4rem;
  color: var(--on-dark);
  background:
    linear-gradient(100deg, rgb(8 16 34 / .95) 0%, rgb(10 22 48 / .80) 45%, rgb(14 34 74 / .50) 100%),
    url("../assets/img/hero.jpg") center / cover no-repeat,
    var(--dark);
}
.hero::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
}
.hero-inner { max-width: 1160px; }
.hero .eyebrow { color: var(--accent-light); }
.hero .eyebrow::before, .contact .eyebrow::before { background: var(--accent-light); }
.hero h1 {
  font-size: clamp(2.3rem, 6vw, 4.4rem);
  font-weight: 700;
  max-width: 16ch;
  letter-spacing: -0.025em;
}
.hero-lede { margin-top: 1.4rem; max-width: 60ch; font-size: clamp(1.05rem, 1.6vw, 1.22rem); color: #cdd6e6; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 2.2rem; }
.industries { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 2.6rem; }
.industries li {
  font-family: var(--font-mono); font-size: .78rem; letter-spacing: .04em;
  padding: .38rem .75rem; border-radius: 999px;
  border: 1px solid rgb(255 255 255 / .18);
  color: var(--on-dark-muted);
  background: rgb(255 255 255 / .03);
}

/* ---------- Sections ---------- */
.section { padding: clamp(4.5rem, 9vw, 7rem) 0; }
.section-alt { background: var(--bg-alt); }
.section-head { max-width: 680px; margin-bottom: clamp(2.5rem, 5vw, 3.5rem); }
.section-head h2 { font-size: clamp(1.9rem, 4vw, 2.75rem); font-weight: 700; }
.section-intro { margin-top: 1rem; color: var(--text-muted); font-size: 1.1rem; }

/* ---------- Timeline ---------- */
.timeline { position: relative; display: grid; gap: 1.75rem; }
.timeline::before {
  content: ""; position: absolute; top: 12px; bottom: 12px; left: 39px; width: 2px;
  background: linear-gradient(var(--accent), var(--border) 80%);
}
.timeline-item { position: relative; display: grid; grid-template-columns: 80px 1fr; gap: 1.5rem; align-items: start; }
.timeline-marker {
  width: 80px; height: 80px; border-radius: 50%;
  background: #fff; overflow: hidden;
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 2px var(--accent), var(--shadow);
  position: relative; z-index: 1;
}
.timeline-marker img { width: 100%; height: 100%; object-fit: cover; }
.timeline-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.6rem;
  box-shadow: var(--shadow);
}
.timeline-card h3 { font-size: 1.3rem; font-weight: 600; }
.timeline-org { font-family: var(--font-mono); font-size: .8rem; color: var(--accent-text); margin-top: .35rem; }
.timeline-card p:last-child { margin-top: .75rem; color: var(--text-muted); }

@media (min-width: 900px) {
  .timeline::before { left: 50%; transform: translateX(-1px); }
  .timeline-item { grid-template-columns: 1fr 96px 1fr; gap: 2rem; }
  .timeline-marker { grid-column: 2; grid-row: 1; width: 96px; height: 96px; justify-self: center; }
  .timeline-card { grid-column: 3; grid-row: 1; }
  .timeline-item:nth-child(even) .timeline-card { grid-column: 1; text-align: right; }
}
@media (max-width: 480px) {
  .timeline::before { left: 27px; }
  .timeline-item { grid-template-columns: 56px 1fr; gap: 1rem; }
  .timeline-marker { width: 56px; height: 56px; }
  .timeline-card { padding: 1.25rem; }
}

/* ---------- Services ---------- */
.cards-3 { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.service-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.9rem 1.7rem;
  box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease;
}
.service-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.service-icon {
  width: 52px; height: 52px; border-radius: 12px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent-text);
  margin-bottom: 1.3rem;
}
.service-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.service-card h3 { font-size: 1.3rem; font-weight: 600; margin-bottom: .6rem; }
.service-card p { color: var(--text-muted); }

/* ---------- Portfolio ---------- */
.work-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.work-card {
  display: flex; flex-direction: column; width: 100%; height: 100%;
  padding: 0; text-align: left; cursor: zoom-in;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease;
}
.work-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.work-media { display: block; aspect-ratio: 4 / 3; overflow: hidden; background: var(--dark-2); }
.work-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.work-media-light { background: #fff; }
.work-media-light img { object-fit: contain; padding: .5rem; }
.work-card:hover .work-media img { transform: scale(1.04); }
.work-body { display: flex; flex-direction: column; gap: .15rem; padding: 1.1rem 1.25rem 1.3rem; border-top: 1px solid var(--border); }
.work-tag { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-text); margin-bottom: .25rem; }
.work-title { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; }
.work-sub { color: var(--text-muted); font-size: .96rem; }

/* ---------- Lightbox ---------- */
.lightbox {
  width: min(1100px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0; border: 0; border-radius: var(--radius);
  background: var(--dark-2); color: var(--on-dark);
  overflow: hidden;
}
.lightbox::backdrop { background: rgb(5 10 20 / .82); backdrop-filter: blur(4px); }
.lightbox figure { margin: 0; display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.lightbox img { width: 100%; max-height: calc(100vh - 140px); object-fit: contain; background: #070d19; }
.lightbox figcaption { padding: 1rem 1.4rem 1.2rem; display: flex; flex-direction: column; gap: .2rem; }
.lightbox figcaption strong { font-family: var(--font-display); font-size: 1.2rem; }
.lightbox figcaption span { color: var(--on-dark-muted); }
.lightbox-close {
  position: absolute; top: 12px; right: 12px; z-index: 1;
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 50%; border: 0; cursor: pointer;
  background: rgb(11 19 36 / .75); color: #fff;
}
.lightbox-close:hover { background: rgb(11 19 36 / .95); }

/* ---------- Expertise ---------- */
.process { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); counter-reset: step; }
.process li {
  position: relative;
  padding: 1.9rem 1.7rem 1.8rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.process li::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--accent); }
.process-num { font-family: var(--font-mono); font-size: .9rem; color: var(--accent-text); display: block; margin-bottom: .9rem; }
.process h3 { font-size: 1.3rem; font-weight: 600; margin-bottom: .6rem; }
.process p { color: var(--text-muted); }

/* ---------- Contact ---------- */
.contact {
  padding: clamp(4.5rem, 9vw, 7rem) 0;
  background:
    radial-gradient(900px 400px at 85% 0%, rgb(47 111 237 / .28), transparent 60%),
    var(--dark);
  color: var(--on-dark);
}
.contact-inner { text-align: center; display: flex; flex-direction: column; align-items: center; }
.contact .eyebrow { color: var(--accent-light); }
.contact h2 { font-size: clamp(2rem, 4.5vw, 3rem); font-weight: 700; max-width: 18ch; }
.contact-lede { margin-top: 1rem; color: var(--on-dark-muted); font-size: 1.1rem; }
.contact-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .8rem; margin-top: 2rem; }
.contact-actions .btn { max-width: 100%; }

/* ---------- Footer ---------- */
.footer { background: #070d19; color: var(--on-dark-muted); font-size: .9rem; padding: 1.5rem 0; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; }
.footer a { text-decoration: none; }
.footer a:hover { color: var(--on-dark); }

/* ---------- Reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
.reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; } }
