/* =========================================================
   FenWorks: styles
   Tokens first; change --accent to switch the whole palette.
   ========================================================= */

:root {
  --bg: #0b0f14;
  --bg-raised: #121821;
  --bg-card: #141b25;
  --line: #222c39;
  --line-strong: #2f3b4c;
  --text: #e6ebf1;
  --text-muted: #9aa7b8;   /* 7.6:1 on --bg */
  --accent: #f5b544;       /* amber, 10.6:1 on --bg */
  --accent-ink: #1a1204;   /* text on accent buttons */
  --grid: rgba(154, 167, 184, 0.045);

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --container: 72rem;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
  --section-y: clamp(4.5rem, 10vw, 8rem);
  --radius: 6px;
}

/* ---------- Base ---------- */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  background-color: var(--bg);
  /* Faint engineering grid behind everything */
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 650;
  text-wrap: balance;
}

p { margin: 0; }

a { color: var(--accent); }

ul, ol { margin: 0; padding: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius);
}
.skip-link:focus { top: 1rem; }

/* ---------- Type helpers ---------- */

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.lede,
.section-intro {
  color: var(--text-muted);
  max-width: 40rem;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11, 15, 20, 0.88);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4rem;
  flex-wrap: wrap;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.01em;
}
.wordmark-glyph {
  width: 1.6rem;
  height: 1.6rem;
  color: var(--accent);
}
.wordmark-accent { color: var(--text-muted); font-weight: 500; }

.nav-list {
  display: flex;
  list-style: none;
  gap: clamp(0.25rem, 2vw, 1.75rem);
}
.nav-list a {
  display: inline-block;
  padding: 0.5rem 0.4rem;
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  transition: color 0.15s ease;
}
.nav-list a:hover,
.nav-list a:focus-visible,
.nav-list a[aria-current="true"] { color: var(--text); }

@media (max-width: 520px) {
  .header-inner {
    justify-content: center;
    padding-block: 0.5rem 0.25rem;
    min-height: 0;
  }
  .nav-list { gap: 0.25rem; }
  .nav-list a { font-size: 0.8125rem; padding-inline: 0.5rem; }
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  padding-block: clamp(5rem, 14vw, 10rem) clamp(4rem, 10vw, 7rem);
  overflow: hidden;
  isolation: isolate;
}

/* Decorative trace art, top right */
.hero::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0 0 auto auto;
  width: min(46rem, 90vw);
  aspect-ratio: 46 / 30;
  background: url("assets/traces.svg") no-repeat right top / contain;
  opacity: 0.55;
  -webkit-mask-image: linear-gradient(to bottom left, #000 30%, transparent 85%);
  mask-image: linear-gradient(to bottom left, #000 30%, transparent 85%);
}

.hero h1 {
  margin-top: 1.25rem;
  max-width: 18ch;
  font-size: clamp(2.25rem, 6.2vw, 4.25rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.hero .lede {
  margin-top: 1.5rem;
  font-size: clamp(1.0625rem, 1.6vw, 1.25rem);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2.5rem;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { background: #ffc965; }
.btn-ghost {
  color: var(--text);
  border-color: var(--line-strong);
}
.btn-ghost:hover { border-color: var(--text-muted); }
.btn:active { transform: translateY(1px); }

/* ---------- Sections ---------- */

.section { padding-block: var(--section-y); }
.section-tight { padding-block: clamp(2.5rem, 6vw, 4rem); }

.section-head { margin-bottom: clamp(2.5rem, 5vw, 3.5rem); }
.section h2 {
  margin-top: 0.85rem;
  font-size: clamp(1.75rem, 3.6vw, 2.5rem);
}
.section-intro { margin-top: 1rem; }

/* Divider: a single trace with a via at each end */
.trace-divider {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
  height: 12px;
  background:
    radial-gradient(circle, var(--line-strong) 3px, transparent 3.5px) var(--gutter) 50% / 12px 12px no-repeat,
    radial-gradient(circle, var(--accent) 3px, transparent 3.5px) calc(100% - var(--gutter)) 50% / 12px 12px no-repeat,
    linear-gradient(var(--line), var(--line)) center / calc(100% - 2 * var(--gutter) - 24px) 1px no-repeat;
}

/* ---------- Cards ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15.5rem), 1fr));
  gap: 1rem;
  list-style: none;
}
.card-grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
}

/* Tablet: two columns, with an odd last card spanning the row */
@media (min-width: 640px) and (max-width: 1000px) {
  .card-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .card-grid-3 > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.75rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.2s ease;
}
.card:hover { border-color: var(--line-strong); }

/* Small corner "pad" accent */
.card::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 1.5rem;
  width: 2rem;
  height: 2px;
  background: var(--accent);
}

.card h3 { font-size: 1.1875rem; }
.card p { color: var(--text-muted); font-size: 1rem; }

.card-icon {
  width: 2.5rem;
  height: 2.5rem;
  margin-bottom: 0.5rem;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.case p { flex-grow: 1; }

/* ---------- Tags ---------- */

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
}
.tags li {
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.5;
}
.card .tags { margin-top: 0.5rem; }

.section .stack-title { margin: 0 0 1.25rem; font-size: 0.8125rem; letter-spacing: 0.08em; }
.tags-quiet li { background: var(--bg-raised); border-color: var(--line); }

/* ---------- Approach steps ---------- */

.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  list-style: none;
  counter-reset: step;
}

.step {
  position: relative;
  padding: 0 1.5rem 0 0;
}

/* Horizontal trace linking each step's node */
.step::before {
  content: "";
  position: absolute;
  top: 0.6rem;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--line-strong);
}
.step:last-child::before { right: 1.5rem; }

.step-num {
  position: relative;
  display: inline-block;
  padding-right: 0.75rem;
  background: var(--bg);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
}
.step-num::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 0.6rem;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--bg);
  vertical-align: 0.05em;
}

.step h3 { margin-top: 1.5rem; font-size: 1.1875rem; }
.step p { margin-top: 0.6rem; color: var(--text-muted); font-size: 1rem; }

@media (max-width: 860px) {
  .steps { grid-template-columns: 1fr; gap: 0; }
  .step { padding: 0 0 2.25rem 2rem; }
  .step:last-child { padding-bottom: 0; }
  /* Vertical trace on the left */
  .step::before,
  .step:last-child::before {
    top: 0.6rem;
    bottom: -0.6rem;
    left: 5px;
    right: auto;
    width: 1px;
    height: auto;
  }
  .step:last-child::before { display: none; }
  .step-num { margin-left: -2rem; padding-right: 0.5rem; }
  .step h3 { margin-top: 0.75rem; }
}

/* ---------- Contact ---------- */

.contact .container { max-width: 52rem; }
.contact-email {
  display: inline-block;
  margin-top: 2rem;
  font-family: var(--font-mono);
  font-size: clamp(1.25rem, 4.2vw, 2rem);
  font-weight: 600;
  text-decoration: none;
  text-underline-offset: 0.2em;
  overflow-wrap: anywhere;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.15rem;
}
.contact-email:hover { color: #ffc965; border-color: #ffc965; }
.engagements { margin-top: 2rem; color: var(--text-muted); }
.engagements strong { color: var(--text); font-weight: 600; }

/* ---------- Privacy ---------- */

.privacy { border-top: 1px solid var(--line); }
.privacy .container { max-width: 52rem; }
.privacy p:not(.eyebrow) { margin-top: 0.75rem; color: var(--text-muted); font-size: 0.9375rem; }
.privacy h2 { margin-top: 0; font-size: 0.8125rem; letter-spacing: 0.08em; }

/* ---------- Footer ---------- */

.site-footer {
  padding-block: 2rem;
  border-top: 1px solid var(--line);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.875rem;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 2rem;
}
.footer-company address { margin-top: 0.25rem; font-style: normal; }
.footer-meta { font-family: var(--font-mono); font-size: 0.8125rem; }
.site-footer a { color: var(--text); text-underline-offset: 0.2em; }
.site-footer a:hover { color: var(--accent); }

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
