/* =========================================================
   FERROUS DYNAMICS — style.css
   Design tokens + all site styles in one file.
   ========================================================= */

:root {
  /* Color tokens — dark PCB-substrate background, cyan/blue accents */
  --bg: #0a0e14;
  --bg-elevated: #0f1520;
  --bg-card: #131a26;
  --border: #1e2733;
  --border-bright: #2a3644;
  --ink-primary: #e6edf3;
  --ink-secondary: #a8b3c2;
  --ink-muted: #66717f;
  --cyan: #22d3ee;
  --cyan-dim: #0e7490;
  --blue: #3b82f6;
  --copper: #f0a030;

  /* Type tokens */
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --max-width: 1200px;
}

/* ---------- Reset ---------- */
* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink-primary);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img {
  max-width: 100%;
  display: block;
}
a {
  color: inherit;
  text-decoration: none;
}
ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
::selection {
  background: rgba(34, 211, 238, 0.3);
  color: #fff;
}
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

/* ---------- Layout helpers ---------- */
.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}
.section {
  padding: 80px 24px;
}
.section-border {
  border-top: 1px solid var(--border);
}
@media (min-width: 768px) {
  .wrap {
    padding: 0 40px;
  }
  .section {
    padding: 110px 40px;
  }
}

/* ---------- Type ---------- */
h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0;
}
h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
}
h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
}
h3 {
  font-size: 1.125rem;
}
p {
  margin: 0;
  color: var(--ink-secondary);
}

/* Silkscreen-style eyebrow label — mirrors PCB reference designators, e.g. [SERVICES] */
.eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 12px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 6px;
  padding: 13px 24px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--cyan);
  color: var(--bg);
}
.btn-primary:hover {
  box-shadow: 0 0 24px rgba(34, 211, 238, 0.25);
  transform: translateY(-2px);
}
.btn-secondary {
  border-color: var(--border-bright);
  color: var(--ink-primary);
  background: transparent;
}
.btn-secondary:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  transform: translateY(-2px);
}
.btn-block {
  width: 100%;
  justify-content: center;
}

/* ---------- Nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 14, 20, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
}
@media (min-width: 768px) {
  .nav {
    padding: 16px 40px;
  }
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo svg,
.logo img {
  height: 42px;
  width: auto;
}
.nav-links {
  display: none;
  gap: 32px;
  align-items: center;
}
.nav-links a {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-secondary);
  transition: color 0.2s ease;
}
.nav-links a:hover,
.nav-links a.active {
  color: var(--cyan);
}
.nav-actions {
  display: none;
  align-items: center;
  gap: 16px;
}
.status-led {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-muted);
}
.led-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  animation: pulse-led 2.4s ease-in-out infinite;
}
@keyframes pulse-led {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 6px 2px rgba(34, 211, 238, 0.7);
  }
  50% {
    opacity: 0.4;
    box-shadow: 0 0 2px 0 rgba(34, 211, 238, 0.3);
  }
}
@media (min-width: 768px) {
  .nav-links,
  .nav-actions {
    display: flex;
  }
  .nav-toggle {
    display: none;
  }
}
.nav-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  color: var(--ink-primary);
  cursor: pointer;
}
.mobile-menu {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 16px 24px 24px;
  border-top: 1px solid var(--border);
}
.mobile-menu.open {
  display: flex;
}
.mobile-menu a {
  padding: 10px 8px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-secondary);
}
.mobile-menu a:hover {
  background: var(--bg-elevated);
  color: var(--cyan);
}
.mobile-menu .btn {
  margin-top: 8px;
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  padding: 96px 24px;
}
@media (min-width: 768px) {
  .hero {
    padding: 128px 40px;
  }
}
.hero-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.hero-bg path,
.hero-bg circle {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: trace-draw 2.4s ease-out forwards;
}
@keyframes trace-draw {
  to {
    stroke-dashoffset: 0;
  }
}
.hero-content {
  position: relative;
  max-width: var(--max-width);
  margin: 0 auto;
}
.hero h1 {
  max-width: 720px;
}
.hero-sub {
  max-width: 560px;
  font-size: 1.05rem;
  margin-top: 24px;
}
@media (min-width: 768px) {
  .hero-sub {
    font-size: 1.15rem;
  }
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 36px;
}
.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  margin-top: 64px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 16px;
  border-left: 1px solid var(--border-bright);
}
.stat:first-child {
  padding-left: 0;
  border-left: none;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
}
.stat-label {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-muted);
}

/* ---------- Grid / cards ---------- */
.grid {
  display: grid;
  gap: 24px;
}
.grid-2 {
  grid-template-columns: repeat(1, 1fr);
}
.grid-3 {
  grid-template-columns: repeat(1, 1fr);
}
@media (min-width: 640px) {
  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (min-width: 900px) {
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.2s ease;
  overflow: hidden;
}
.card:hover {
  border-color: var(--border-bright);
}
.card-body {
  padding: 20px;
}
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.tag {
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

/* Project / service card link */
.project-card,
.service-card {
  display: block;
  position: relative;
}
.project-card h3,
.service-card h3 {
  margin-top: 4px;
  transition: color 0.2s ease;
}
.project-card:hover h3 {
  color: var(--cyan);
}
.badge-upcoming {
  position: absolute;
  top: 16px;
  right: 16px;
  border: 1px solid rgba(240, 160, 48, 0.4);
  background: rgba(240, 160, 48, 0.1);
  color: var(--copper);
  border-radius: 999px;
  padding: 3px 10px;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ---------- Placeholder image block ---------- */
.placeholder {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--bg-elevated);
  border: 1px dashed var(--border-bright);
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.placeholder.square {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
}
.placeholder.wide {
  aspect-ratio: 16 / 9;
  border-radius: 8px;
}
.placeholder.tall {
  aspect-ratio: 4 / 5;
  border-radius: 8px;
}
.placeholder::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    45deg,
    var(--border) 0,
    var(--border) 1px,
    transparent 1px,
    transparent 10px
  );
  opacity: 0.5;
}
.placeholder-label {
  position: relative;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  text-align: center;
  padding: 0 16px;
}
.placeholder {
  flex-direction: column;
  gap: 10px;
}
.placeholder-icon {
  position: relative;
  display: flex;
  opacity: 0.85;
}
/* Real photo overlay — hidden until it successfully loads (see smartImage()
   and mediaBlock() in script.js), then covers the icon + label. */
.placeholder .thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.placeholder.has-photo .thumb-img {
  opacity: 1;
}
.placeholder.has-photo .placeholder-icon,
.placeholder.has-photo .placeholder-label {
  display: none;
}
.placeholder.has-photo::before {
  opacity: 0;
}
/* Demo video — same auto-load pattern as photos above. Drop a file at
   assets/projects/<slug>/demo.mp4 and it appears automatically. */
.placeholder .demo-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.placeholder.has-video .demo-video {
  opacity: 1;
}
.placeholder.has-video .placeholder-label {
  display: none;
}
.placeholder.has-video::before {
  opacity: 0;
}

/* ---------- Testimonials ---------- */
.testimonial-quote-mark {
  color: rgba(34, 211, 238, 0.6);
  margin-bottom: 16px;
}
.testimonial-person {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-bright);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  color: var(--ink-muted);
}
.testimonial-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-primary);
}
.testimonial-role {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

/* ---------- CTA banner ---------- */
.cta-banner {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
}
.cta-banner .wrap {
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: flex-start;
  padding-top: 56px;
  padding-bottom: 56px;
}
@media (min-width: 768px) {
  .cta-banner .wrap {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}
.cta-banner p {
  max-width: 420px;
  margin-top: 8px;
  font-size: 0.9rem;
}

/* ---------- Forms ---------- */
.field {
  margin-bottom: 20px;
}
.field label {
  display: block;
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}
.field input,
.field select,
.field textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  color: var(--ink-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
}
.field input::placeholder,
.field textarea::placeholder {
  color: var(--ink-muted);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--cyan);
}
.field-row {
  display: grid;
  gap: 20px;
}
@media (min-width: 640px) {
  .field-row {
    grid-template-columns: 1fr 1fr;
  }
}
.form-success {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 56px 24px;
}
.form-success.show {
  display: flex;
}
#contact-form.hide {
  display: none;
}
.form-note {
  text-align: center;
  font-size: 0.85rem;
  color: #f87171;
  margin-top: 16px;
  display: none;
}

/* ---------- Contact channel list ---------- */
.channel-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px;
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--ink-secondary);
  border: 1px solid transparent;
  transition: all 0.2s ease;
}
.channel-list a:hover {
  border-color: var(--border-bright);
  color: var(--cyan);
}
.channel-label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
}
.footer-grid {
  display: grid;
  gap: 40px;
  padding: 56px 0;
}
@media (min-width: 768px) {
  .footer-grid {
    grid-template-columns: 1.4fr 1fr 1fr;
  }
}
.footer-about p {
  max-width: 320px;
  margin-top: 16px;
  font-size: 0.875rem;
}
.footer-col ul li {
  margin-bottom: 8px;
}
.footer-col ul li a {
  font-size: 0.875rem;
  color: var(--ink-secondary);
}
.footer-col ul li a:hover {
  color: var(--cyan);
}
.footer-bottom {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding: 24px 0;
  font-size: 0.75rem;
  color: var(--ink-muted);
}
.footer-bottom-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
@media (min-width: 768px) {
  .footer-bottom-main {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}
.footer-bottom .mono {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.footer-updated {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  opacity: 0.7;
}

/* ---------- Project detail page ---------- */
.back-link {
  display: inline-flex;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--cyan);
  margin-bottom: 32px;
}
.back-link:hover {
  text-decoration: underline;
}
.detail-gallery {
  display: grid;
  gap: 16px;
  margin-top: 40px;
  grid-template-columns: 1fr;
}
@media (min-width: 768px) {
  .detail-gallery {
    grid-template-columns: repeat(3, 1fr);
  }
  .detail-gallery .placeholder:first-child {
    grid-column: span 2;
    grid-row: span 2;
  }
}
.detail-columns {
  display: grid;
  gap: 40px;
  margin-top: 56px;
}
@media (min-width: 768px) {
  .detail-columns {
    grid-template-columns: 1fr 1fr;
  }
}
.detail-columns h2.eyebrow-h {
  margin-top: 32px;
}
.eyebrow-h {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 12px;
}
.detail-cta {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: flex-start;
  border-top: 1px solid var(--border);
  margin-top: 64px;
  padding-top: 40px;
}
@media (min-width: 768px) {
  .detail-cta {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

/* ---------- Photo lightbox (click a project photo to view it full-size) ---------- */
.detail-gallery .placeholder.has-photo {
  cursor: zoom-in;
}
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(6, 8, 12, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  cursor: zoom-out;
}
.lightbox-overlay[hidden] {
  display: none;
}
.lightbox-overlay .lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  width: auto;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-bright);
}
.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  background: transparent;
  border: 1px solid var(--border-bright);
  color: var(--ink-primary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.lightbox-close:hover {
  color: var(--cyan);
  border-color: var(--cyan);
}

/* Utility */
.text-center {
  text-align: center;
}
.mt-8 {
  margin-top: 8px;
}
.mt-16 {
  margin-top: 16px;
}
.mt-24 {
  margin-top: 24px;
}
.mt-40 {
  margin-top: 40px;
}
.link-cyan {
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 0.875rem;
}
.link-cyan:hover {
  text-decoration: underline;
}
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 40px;
  flex-wrap: wrap;
  gap: 16px;
}

/* ---------- Legal pages (Privacy Policy / Terms & Conditions) ---------- */
.legal-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.legal-body {
  max-width: 760px;
}
.legal-body h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink-primary);
  margin-top: 40px;
  margin-bottom: 12px;
}
.legal-body h2:first-child {
  margin-top: 0;
}
.legal-body p {
  margin-bottom: 16px;
  font-size: 0.95rem;
}
.legal-body ul {
  list-style: disc;
  padding-left: 22px;
  margin: 0 0 16px;
}
.legal-body li {
  margin-bottom: 6px;
  color: var(--ink-secondary);
  font-size: 0.95rem;
}
.legal-body a {
  color: var(--cyan);
  text-decoration: underline;
}
.legal-nav {
  display: flex;
  gap: 24px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.legal-nav a {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-secondary);
}
.legal-nav a:hover,
.legal-nav a.active {
  color: var(--cyan);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
