/* Fonts */
@font-face {
  font-family: 'btSans';
  src: url('./btSans.woff2') format('woff2');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'SuisseMono';
  src: url('./SuisseMonno.woff2') format('woff2');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg: #000;
  --surface: #0b0b0b;
  --panel: rgba(255, 255, 255, 0.03);
  --panel-border: rgba(255, 255, 255, 0.14);
  --text: #ffffff;
  --muted: #b5b5b5;
  --accent: #ffffff;
  --accent-2: #ffffff;
  --grid: rgba(255, 255, 255, 0.56);
  --corner: rgba(255, 255, 255, 0.22);
  --ink: #ffffff; /* drawing/stroke color for canvases */
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'btSans', ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, 'Apple Color Emoji', 'Segoe UI Emoji';
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

.container {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
}

/* Background: CSS-only noisy gradients */
.bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: #000;
}
.bg::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.55;
  background-image:
    repeating-conic-gradient(from 0deg, rgba(255,255,255,0.04) 0 2deg, transparent 2deg 4deg),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.02) 0 1px, transparent 1px 2px);
  mix-blend-mode: overlay;
}

/* Blueprint grid overlay */
.grid-overlay {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(70% 50% at 50% 50%, black, transparent 90%);
  mask-image: radial-gradient(70% 50% at 50% 50%, black, transparent 90%);
  opacity: var(--grid-opacity, 0.3);
}

/* Grid electrical effects canvas */
.grid-fx {
  position: fixed;
  inset: 0;
  z-index: 0; /* above grid-overlay (-1) and below header/content */
  pointer-events: none;
}

/* Particles canvas */
.particles {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1rem;
  background: rgba(13, 17, 26, 0.55);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  backdrop-filter: blur(10px) saturate(140%);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.brand {
  font-weight: 700;
  letter-spacing: 0.3px;
  text-decoration: none;
  color: var(--text);
}
.primary-nav {
  display: flex;
  align-items: center;
  font-size: inherit;
  gap: 1rem;
}
.primary-nav a { color: var(--text); text-decoration: none; opacity: 0.85; }
.primary-nav a:hover { opacity: 1; }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 36px;
  border-radius: 12px;
  border: 1px dashed rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor: pointer;
  padding: 0;
}
.theme-toggle:hover { background: rgba(255,255,255,0.12); }
.theme-toggle .icon { display: grid; place-items: center; width: 18px; height: 18px; line-height: 0; }
.theme-toggle .icon svg { width: 18px; height: 18px; }
.theme-toggle .icon--moon { display: none; }
[data-theme="light"] .theme-toggle { border: 1px dashed rgba(0,0,0,0.2); background: rgba(0,0,0,0.06); }
[data-theme="light"] .theme-toggle:hover { background: rgba(0,0,0,0.1); }
[data-theme="light"] .theme-toggle .icon--sun { display: none; }
[data-theme="light"] .theme-toggle .icon--moon { display: grid; }

.highlight-button {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--text);
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
}

/* Dropdown (glassmorphic, more opaque) */
.dropdown { position: relative; }
.dropdown-toggle {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--text);
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
}
.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  min-width: 240px;
  gap: 0.25rem;
  padding: 0.5rem;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(20,22,29,0.7);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  backdrop-filter: blur(12px) saturate(160%);
  box-shadow: 0 10px 24px rgba(0,0,0,0.35);
  visibility: hidden;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .2s ease, transform .2s ease, visibility .2s step-end;
}
.dropdown:hover .dropdown-menu,
.dropdown:focus-within .dropdown-menu {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  transition: opacity .18s ease, transform .18s ease, visibility 0s step-start;
}
.dropdown-menu a {
  color: var(--text);
  text-decoration: none;
  padding: 0.6rem 0.6rem;
  border-radius: 8px;
  opacity: 0.9;
}
.dropdown-menu a:hover {
  background: rgba(255,255,255,0.06);
  opacity: 1;
}

/* Hero */
.hero { padding: 8rem 0 4rem; }
.hero h1 { font-size: clamp(2rem, 3.6vw + 1rem, 4rem); margin: 0 0 0.6rem; line-height: 1.08; }
.hero__sub { display: block; font-weight: 400; color: var(--muted); font-size: 0.6em; letter-spacing: 0.5px; margin-top: 0.15em; }
.lede { color: var(--muted); max-width: 64ch; }
.hero__actions { margin-top: 3.5rem; margin-bottom: -0.75rem; display: flex; gap: 0.75rem; }

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.78rem 1.05rem;
  border-radius: 12px;
  text-decoration: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  font-family: 'SuisseMono', ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.02em;
  font-weight: 600;
  transition: transform .12s ease, background-color .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.button::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18);
}
.button:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(255,255,255,0.18); }

.button--primary {
  background: #ffffff;
  color: #000000;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 0 rgba(255,255,255,0.4), 0 0 0 1px rgba(0,0,0,0.7) inset;
}
.button--primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(255,255,255,0.12), 0 0 0 1px rgba(0,0,0,0.75) inset; }
.button--primary:active { transform: translateY(0); }

/* Ghost buttons with only rounded corner outlines */
.button--ghost {
  background: rgba(255,255,255,0.02);
  color: var(--text);
  border: none;
}
.button--ghost:hover { background: rgba(255,255,255,0.06); transform: translateY(-1px); }
.button--ghost:active { transform: translateY(0); }
/* override full outline and draw only corners with rounded inner cutout */
.button--ghost::before {
  box-shadow: none;
  --l: 14px; /* corner box size */
  border: 2px solid #fff;
  border-radius: inherit;
  background: none;
  /* Reveal only corner squares; since this element only has a border, the visible part becomes the rounded arcs */
  -webkit-mask:
    linear-gradient(#000 0 0) top left,
    linear-gradient(#000 0 0) top right,
    linear-gradient(#000 0 0) bottom left,
    linear-gradient(#000 0 0) bottom right;
  -webkit-mask-size: var(--l) var(--l);
  -webkit-mask-repeat: no-repeat;
  mask:
    linear-gradient(#000 0 0) top left,
    linear-gradient(#000 0 0) top right,
    linear-gradient(#000 0 0) bottom left,
    linear-gradient(#000 0 0) bottom right;
  mask-size: var(--l) var(--l);
  mask-repeat: no-repeat;
}

/* Panels */
.panels { display: grid; gap: 1rem; padding: 2rem 0; }
.panels--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panels--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .panels--three { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .panels--two { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 1.2rem;
  position: relative;
}
.panel::before, .panel::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border: 1px solid var(--corner);
}
.panel::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; border-top-left-radius: 12px; }
.panel::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; border-bottom-right-radius: 12px; }

.panel__title { font-weight: 700; margin-bottom: 0.25rem; }
.panel__copy { color: var(--muted); margin-top: 0; }
.panel__list { margin: 0.5rem 0 0; padding-left: 1rem; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.8rem; }
.tags span { font-family: 'SuisseMono', ui-monospace, SFMono-Regular, Menlo, monospace; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.14); padding: 0.2rem 0.5rem; border-radius: 6px; color: var(--text); font-size: 0.85rem; }

/* Blueprint stages */
.blueprint { padding: 2rem 0 0.5rem; }
.blueprint__header h2 { margin: 0; }
.blueprint .sub { color: var(--muted); margin-top: 0.25rem; }

.stages { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 0.6rem; counter-reset: step; }
.stage { display: grid; grid-template-columns: 72px 1fr; gap: 1rem; align-items: start; padding: 1rem; border: 1px dashed rgba(255,255,255,0.18); border-radius: 14px; background: rgba(255,255,255,0.02); }
.stage__index { font-family: 'SuisseMono', ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--accent); letter-spacing: 0.08em; font-size: 1rem; margin-top: 0.2rem; }
.stage h3 { margin: 0 0 0.25rem; }
.stage p { color: var(--muted); margin: 0; }

/* Contact */
.contact { padding: 3rem 0 5rem; }
.contact .lede { margin-bottom: 1rem; }
.contact__form { display: grid; gap: 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-row { grid-template-columns: 1fr; } }

label span { display: block; margin-bottom: 0.35rem; color: var(--muted); font-size: 0.95rem; }
input, textarea {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.04);
  color: var(--text);
}
input::placeholder, textarea::placeholder { color: #93a1b5; }

.form-actions { margin-top: 0.25rem; }

/* Footer */
.site-footer { display: flex; justify-content: space-between; gap: 1rem; padding: 2rem 0; border-top: 1px solid rgba(255,255,255,0.1); color: var(--muted); }
.site-footer a { color: var(--text); }

/* Reveal */
[data-reveal] { opacity: 0; transform: translateY(8px); transition: opacity .36s ease, transform .36s ease; }
[data-reveal].reveal--in { opacity: 1; transform: none; }

/* Form status */
.form-status {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.04);
  color: var(--text);
}
.success-message { border-color: rgba(255,255,255,0.28); }
.error-message { border-color: rgba(255,255,255,0.28); }

/* Form container replacement */
.form-container { position: relative; }
.form-container .form-status[hidden] { display: none; }
.form-container .form-status { text-align: left; }
.form-container .form-status.success-message { font-weight: 600; background: rgba(255,255,255,0.06); }

/* Corner-outline button (empty button style) */
.button--corner {
  background: transparent;
  color: var(--text);
  border: none;
  position: relative;
}
.button--corner::before,
.button--corner::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  pointer-events: none;
}
/* corners: draw only short segments */
.button--corner::before {
  --l: 12px; /* corner length */
  background:
    linear-gradient(#fff, #fff) left top / var(--l) 2px no-repeat,
    linear-gradient(#fff, #fff) left top / 2px var(--l) no-repeat,
    linear-gradient(#fff, #fff) right top / var(--l) 2px no-repeat,
    linear-gradient(#fff, #fff) right top / 2px var(--l) no-repeat,
    linear-gradient(#fff, #fff) left bottom / var(--l) 2px no-repeat,
    linear-gradient(#fff, #fff) left bottom / 2px var(--l) no-repeat,
    linear-gradient(#fff, #fff) right bottom / var(--l) 2px no-repeat,
    linear-gradient(#fff, #fff) right bottom / 2px var(--l) no-repeat;
  border-radius: inherit;
  opacity: 0.9;
}
.button--corner:hover { background: rgba(255,255,255,0.05); }

/* Case Study page */
.cs-page #gridfx { display: none !important; }
.cs-shell { padding: 6rem 0 4rem; }
/* Dim grid opacity by half on case study page */
.cs-page .grid-overlay { opacity: calc(var(--grid-opacity, 0.3) * 0.25) !important; }
/* Disable reveal animation on case study page (no JS) */
.cs-page [data-reveal] { opacity: 1 !important; transform: none !important; }
.cs-card {
  position: relative;
  z-index: 1; /* ensure above particles */
  background: var(--bg); /* solid background to mask particles underneath */
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 22px;
  padding: 2rem; 
  box-shadow: 0 40px 80px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.04);
  max-width: 980px;
}
.cs-header h1 { margin: 0; }
.cs-rule {
  height: 1px;
  background: rgba(255,255,255,0.12);
  border: none;
  margin: 1rem 0 1.25rem;
}
.cs-body p { margin: 0 0 1rem; color: var(--text); }

/* Light theme — invert palette and drawing colors */
[data-theme="light"] {
  --bg: #f4efe2; /* warm beige */
  --surface: #f7f3ea;
  --panel: rgba(0, 0, 0, 0.035);
  --panel-border: rgba(0, 0, 0, 0.16);
  --text: #111111;
  --muted: #4d4d4d;
  --accent: #000000;
  --accent-2: #000000;
  --grid: rgba(0, 0, 0, 0.5);
  --corner: rgba(0, 0, 0, 0.22);
  --ink: #000000; /* canvases draw in black */
}

/* Light theme background: beige with Perlin-like noise overlay */
[data-theme="light"] .bg { background: var(--bg); }
[data-theme="light"] .bg::after {
  opacity: 0.35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' seed='7' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0.0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.13' /></svg>");
  background-size: 320px 320px;
}

/* Light theme component overrides */
[data-theme="light"] .site-header {
  background: rgba(205, 188, 150, 0.8); /* darker beige banner */
  border-bottom: 1px solid rgba(0,0,0,0.1);
}
[data-theme="light"] .button--primary {
  background: #000000;
  color: #ffffff;
  border: 2px solid #000000;
  box-shadow: 0 2px 0 rgba(0,0,0,0.32), 0 0 0 1px rgba(0,0,0,0.7) inset;
}
[data-theme="light"] .button--primary:hover { box-shadow: 0 6px 18px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.75) inset; }
[data-theme="light"] .button--ghost { background: rgba(0,0,0,0.02); }
[data-theme="light"] .button--ghost:hover { background: rgba(0,0,0,0.06); }
[data-theme="light"] .button--ghost::before { border-color: #000; }

[data-theme="light"] .button--corner::before {
  background:
    linear-gradient(#000, #000) left top / var(--l) 2px no-repeat,
    linear-gradient(#000, #000) left top / 2px var(--l) no-repeat,
    linear-gradient(#000, #000) right top / var(--l) 2px no-repeat,
    linear-gradient(#000, #000) right top / 2px var(--l) no-repeat,
    linear-gradient(#000, #000) left bottom / var(--l) 2px no-repeat,
    linear-gradient(#000, #000) left bottom / 2px var(--l) no-repeat,
    linear-gradient(#000, #000) right bottom / var(--l) 2px no-repeat,
    linear-gradient(#000, #000) right bottom / 2px var(--l) no-repeat;
}
[data-theme="light"] .button--corner:hover { background: rgba(0,0,0,0.05); }

[data-theme="light"] input,
[data-theme="light"] textarea {
  border-color: rgba(0,0,0,0.18);
  background: rgba(0,0,0,0.04);
  color: var(--text);
}
[data-theme="light"] input::placeholder,
[data-theme="light"] textarea::placeholder { color: #687080; }

[data-theme="light"] .dropdown-toggle {
  background: rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.18);
  color: var(--text);
}
[data-theme="light"] .dropdown-menu {
  border: 1px solid rgba(0,0,0,0.18);
  background: rgba(255,255,255,0.82);
  box-shadow: 0 10px 24px rgba(0,0,0,0.2);
}
[data-theme="light"] .dropdown-menu a:hover { background: rgba(0,0,0,0.06); }

[data-theme="light"] .stage { border-color: rgba(0,0,0,0.2); background: rgba(0,0,0,0.03); }
[data-theme="light"] .tags span { background: rgba(0,0,0,0.06); border-color: rgba(0,0,0,0.14); color: var(--text); }
[data-theme="light"] .site-footer { border-top-color: rgba(0,0,0,0.12); }
[data-theme="light"] .cs-card { background: var(--bg); border-color: rgba(0,0,0,0.16); box-shadow: 0 40px 80px rgba(0,0,0,0.12), inset 0 1px 0 rgba(0,0,0,0.04); }
[data-theme="light"] .cs-rule { background: rgba(0,0,0,0.12); }

/* Mobile header/nav adjustments */
@media (max-width: 640px) {
  .site-header {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.65rem 0.85rem;
  }
  .brand img {
    width: 104px;
    height: auto;
  }
  .primary-nav {
    flex: 1 1 100%;
    order: 2;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .primary-nav a,
  .primary-nav .button {
    font-size: 0.95rem;
  }
  .primary-nav .button {
    padding: 0.6rem 0.8rem;
    border-radius: 10px;
  }
  .theme-toggle {
    width: 40px;
    height: 32px;
    border-radius: 10px;
  }
}
