/* ============================================================
   Tessium Labs — stylesheet
   Design tokens live at the top. Theme = dark by default,
   overridden by prefers-color-scheme and by the manual toggle
   (which stamps data-theme="light"/"dark" on <html>).
   ============================================================ */

:root {
  --ink: #0b1210;
  --surface: #131b18;
  --surface-2: #1b2521;
  --paper: #edeee9;
  --muted: #8fa39a;
  --accent: #e8973d;
  --accent-2: #4fd8b0;
  --line: rgba(237, 238, 233, 0.12);
  --shadow: rgba(0, 0, 0, 0.35);

  --font-display: "IBM Plex Serif", Georgia, "Times New Roman", serif;
  --font-body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-md: 1.125rem;
  --text-lg: 1.375rem;
  --text-xl: 1.875rem;
  --text-2xl: clamp(1.9rem, 1.5rem + 1.6vw, 2.75rem);
  --text-3xl: clamp(2.6rem, 1.9rem + 3vw, 4.5rem);

  --content-w: 1120px;
  --content-w-narrow: 760px;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --section-pad: clamp(4rem, 8vw, 7.5rem);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: light) {
  :root {
    --ink: #f3f1ea;
    --surface: #ffffff;
    --surface-2: #eae7dc;
    --paper: #14201c;
    --muted: #5b6c64;
    --accent: #c96a1f;
    --accent-2: #1f8f76;
    --line: rgba(20, 32, 28, 0.12);
    --shadow: rgba(20, 32, 28, 0.12);
  }
}

:root[data-theme="dark"] {
  --ink: #0b1210;
  --surface: #131b18;
  --surface-2: #1b2521;
  --paper: #edeee9;
  --muted: #8fa39a;
  --accent: #e8973d;
  --accent-2: #4fd8b0;
  --line: rgba(237, 238, 233, 0.12);
  --shadow: rgba(0, 0, 0, 0.35);
}

:root[data-theme="light"] {
  --ink: #f3f1ea;
  --surface: #ffffff;
  --surface-2: #eae7dc;
  --paper: #14201c;
  --muted: #5b6c64;
  --accent: #c96a1f;
  --accent-2: #1f8f76;
  --line: rgba(20, 32, 28, 0.12);
  --shadow: rgba(20, 32, 28, 0.12);
}

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

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}

img { max-width: 100%; display: block; }
a { color: inherit; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 500;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  background: var(--accent);
  color: var(--ink);
  padding: 0.75em 1.25em;
  z-index: 1000;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}
.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- layout helpers ---------- */
.section-inner {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.section-inner-narrow { max-width: var(--content-w-narrow); }

.section {
  padding-block: var(--section-pad);
  border-top: 1px solid var(--line);
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.6em;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1.1rem;
}
.eyebrow .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.section-head h2 {
  font-size: var(--text-2xl);
  line-height: 1.15;
}
.section-lede {
  margin-top: 1rem;
  max-width: 46ch;
  color: var(--muted);
  font-size: var(--text-md);
}

/* ---------- reveal-on-scroll ---------- */
[data-reveal] {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
[data-reveal].is-visible {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  [data-reveal] { transform: none; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  letter-spacing: 0.02em;
  padding: 0.85em 1.5em;
  border-radius: 3px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease);
  white-space: nowrap;
}
.btn-sm { padding: 0.65em 1.15em; font-size: var(--text-xs); }
.btn-primary {
  background: var(--accent);
  color: var(--ink);
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.06); }
.btn-ghost {
  background: transparent;
  color: var(--paper);
  border-color: var(--line);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--ink) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease);
}
.site-header.is-scrolled { border-bottom-color: var(--line); }

.header-inner {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 0.9rem var(--gutter);
  display: flex;
  align-items: center;
  gap: 2rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--paper);
  margin-right: auto;
}
.brand-mark { display: inline-flex; color: var(--paper); }
.brand-word {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.brand-word em { color: var(--accent); font-style: normal; }

.site-nav {
  display: flex;
  gap: 1.75rem;
}
.site-nav a {
  position: relative;
  text-decoration: none;
  color: var(--muted);
  font-size: var(--text-sm);
  padding: 0.25rem 0;
  transition: color 0.2s var(--ease);
}
.site-nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 100%;
  bottom: -2px;
  height: 1px;
  background: var(--accent);
  transition: right 0.25s var(--ease);
}
.site-nav a:hover,
.site-nav a.is-active { color: var(--paper); }
.site-nav a.is-active::after { right: 0; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--paper);
  cursor: pointer;
}
.theme-toggle svg { fill: none; stroke: currentColor; stroke-width: 1.6; }
.theme-toggle .icon-sun circle { fill: currentColor; stroke: none; }
.theme-toggle .icon-sun,
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: block; }

@media (max-width: 720px) {
  .site-nav { display: none; }
}

/* ---------- hero ---------- */
.hero {
  position: relative;
  min-height: min(88vh, 780px);
  display: flex;
  align-items: center;
  overflow: hidden;
}
.hero-trace {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.55;
}
.hero-inner {
  position: relative;
  z-index: 1;
  max-width: var(--content-w);
  margin: 0 auto;
  padding: var(--section-pad) var(--gutter);
}
.hero-title {
  font-size: var(--text-3xl);
  line-height: 1.08;
  max-width: 16ch;
}
.hero-title em {
  font-style: italic;
  color: var(--accent);
}
.hero-sub {
  margin-top: 1.75rem;
  max-width: 52ch;
  font-size: var(--text-md);
  color: var(--muted);
}
.hero-actions {
  margin-top: 2.5rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ---------- services ---------- */
.card-grid {
  margin-top: 3rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}
.card {
  background: var(--ink);
  padding: 2rem;
  transition: background 0.25s var(--ease);
}
.card:hover { background: var(--surface); }
.card h3 {
  font-size: var(--text-md);
  margin-bottom: 0.75rem;
}
.card p {
  color: var(--muted);
  font-size: var(--text-sm);
}

/* ---------- product ---------- */
.section-product { border-top: 1px solid var(--line); }
.product-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  overflow: hidden;
}
.product-copy {
  padding: clamp(2rem, 4vw, 3.5rem);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.25rem;
}
.product-copy h2 { font-size: var(--text-2xl); }
.product-copy p:not(.eyebrow) { color: var(--muted); max-width: 48ch; }
.product-trace {
  position: relative;
  min-height: 220px;
  background: var(--surface-2);
}
.product-trace canvas { width: 100%; height: 100%; display: block; }

@media (max-width: 820px) {
  .product-panel { grid-template-columns: 1fr; }
  .product-trace { min-height: 160px; }
}

/* ---------- about ---------- */
.principle-list {
  margin-top: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.principle-list li {
  padding: 1.25rem 0;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--paper);
}
.principle-list li:last-child { border-bottom: 1px solid var(--line); }

/* ---------- contact ---------- */
.contact-box {
  margin-top: 2.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 1.75rem 2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.contact-email {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  text-decoration: none;
  color: var(--paper);
  border-bottom: 1px solid var(--accent);
}
.contact-email:hover { color: var(--accent); }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
}
.footer-inner {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 2rem var(--gutter);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--muted);
  letter-spacing: 0.03em;
}
