:root {
  --bg: #e8ebef;
  --bg-soft: #dde1e8;
  --bg-paper: #f1f3f6;
  --ink: #0c1638;
  --ink-dim: #4b537a;
  --ink-faint: #8c93a8;
  --rule: #c4c9d4;
  --rule-soft: #d6dae2;
  --accent: #1d2c8a; /* navy, primary highlight */
  --accent-bright: #2a3da8;
  --accent-soft: #c8cdea;
  --hover-paper: #fff;
  --ghost-hover: rgba(29, 44, 138, 0.06);
  --serif: "Fraunces", "Times New Roman", ui-serif, serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --max: 1240px;
  --pad: clamp(20px, 4vw, 56px);
  --radius: 2px;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0a1024;
  --bg-soft: #121a3a;
  --bg-paper: #161e42;
  --ink: #e8eaf3;
  --ink-dim: #a8b0cc;
  --ink-faint: #6b7298;
  --rule: #2a3460;
  --rule-soft: #1d2647;
  --accent: #7b95ff;
  --accent-bright: #9fb2ff;
  --accent-soft: #2a3460;
  --hover-paper: #1d2750;
  --ghost-hover: rgba(123, 149, 255, 0.08);

  color-scheme: dark;
}

[data-theme="dark"] #turbine {
  filter: invert(1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 400;
  font-optical-sizing: auto;
  font-variation-settings: "opsz" 60;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Opaque cover: paints over the fixed turbine when scrolled past the hero */
.page-cover {
  position: relative;
  background: var(--bg);
  z-index: 2;
}

/* Background turbine: spinning greyscale element, anchored off the right edge */
#turbine-wrap {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

#turbine-pos {
  position: absolute;
  top: 50%;
  right: -32vmin;
  width: 124vmin;
  height: 124vmin;
  transform: translateY(-50%);
}

#turbine {
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0.7;
  will-change: transform;
}

@media (max-width: 900px) {
  #turbine-pos {
    right: -45vmin;
    width: 130vmin;
    height: 130vmin;
  }
  #turbine {
    opacity: 0.5;
  }
}

header,
main,
footer {
  position: relative;
  z-index: 1;
}

/* ───────── Nav ───────── */
.nav {
  position: relative;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px var(--pad);
  max-width: var(--max);
  margin: 0 auto;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}

.brand-badge {
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 5px 10px;
  border-radius: 2px;
  white-space: nowrap;
  transition: background 200ms ease;
}

.brand:hover .brand-badge {
  background: var(--accent-bright);
}

.brand-tag {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  text-transform: lowercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.nav nav {
  display: flex;
  gap: 28px;
  align-items: center;
}

.nav-toggle {
  display: none;
  background: transparent;
  border: 0;
  padding: 0;
  width: 36px;
  height: 36px;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  z-index: 60;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 1.5px;
  background: var(--ink);
  transition: transform 200ms ease, opacity 200ms ease;
}

.nav.open .nav-toggle span:nth-child(1) {
  transform: translateY(6.5px) rotate(45deg);
}

.nav.open .nav-toggle span:nth-child(2) {
  opacity: 0;
}

.nav.open .nav-toggle span:nth-child(3) {
  transform: translateY(-6.5px) rotate(-45deg);
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink-dim);
  padding: 4px 10px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.4;
  transition: border-color 200ms ease, color 200ms ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle [data-icon-dark] {
  display: none;
}

[data-theme="dark"] .theme-toggle [data-icon-light] {
  display: none;
}

[data-theme="dark"] .theme-toggle [data-icon-dark] {
  display: inline;
}

.nav nav a {
  color: var(--ink-dim);
  text-decoration: none;
  text-transform: lowercase;
  transition: color 200ms ease;
}

.nav nav a::before {
  content: "> ";
  color: var(--ink-faint);
}

.nav nav a:hover {
  color: var(--accent);
}

.nav nav a.cta {
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  padding: 8px 14px;
  border-radius: 2px;
  transition: background 200ms ease;
}

.nav nav a.cta::before {
  content: "> ";
  color: rgba(255, 255, 255, 0.7);
}

.nav nav a.cta:hover {
  background: var(--accent-bright);
}

/* ───────── Sections shared ───────── */
section {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(80px, 12vw, 160px) var(--pad);
  border-top: 1px solid var(--rule);
}

section:first-of-type {
  border-top: 0;
}

.section-label {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: lowercase;
  color: var(--accent);
  margin: 0 0 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.section-label .prompt-inline {
  color: var(--ink-faint);
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 400;
  font-variation-settings: "opsz" 144;
  letter-spacing: -0.02em;
  color: var(--ink);
}

h1 {
  font-size: clamp(54px, 9vw, 132px);
  line-height: 0.95;
  font-weight: 300;
}

h1 em,
h2 em {
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
}

h2 {
  font-size: clamp(36px, 5.4vw, 76px);
  line-height: 1;
  font-weight: 400;
  max-width: 18ch;
}

h3 {
  font-size: clamp(22px, 2vw, 28px);
  font-weight: 500;
  margin-bottom: 12px;
}

p.body {
  font-size: clamp(18px, 1.5vw, 22px);
  color: var(--ink-dim);
  max-width: 60ch;
  line-height: 1.5;
  margin: 24px 0 0;
}

/* ───────── Hero ───────── */
.hero {
  min-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-top: clamp(60px, 10vw, 120px);
  padding-bottom: clamp(40px, 8vw, 80px);
  border-top: 0;
}

.hero-inner {
  max-width: 720px;
}

.caret {
  display: inline-block;
  width: 7px;
  height: 1.05em;
  background: currentColor;
  margin-left: 4px;
  vertical-align: -2px;
  animation: blink 1.05s steps(2, start) infinite;
}

@keyframes blink {
  to {
    visibility: hidden;
  }
}

.lede {
  margin: 32px 0 40px;
  font-size: clamp(20px, 1.7vw, 26px);
  color: var(--ink-dim);
  max-width: 42ch;
  line-height: 1.45;
}

.hero-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  padding: 14px 22px;
  border-radius: 2px;
  text-decoration: none;
  transition: transform 200ms ease, background 200ms ease, color 200ms ease,
    border-color 200ms ease;
}

.btn::before {
  content: "> ";
  opacity: 0.7;
  margin-right: 4px;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
}

.btn.primary:hover {
  transform: translateY(-1px);
  background: var(--accent-bright);
}

.btn.ghost {
  color: var(--accent);
  border: 1px solid var(--accent);
  background: transparent;
}

.btn.ghost:hover {
  background: var(--ghost-hover);
}

.hero-meta {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  color: var(--ink-faint);
  padding-top: 60px;
}

/* ───────── Thesis ───────── */
.thesis h2 {
  max-width: 22ch;
}

/* ───────── Focus ───────── */
.focus-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  margin-top: 12px;
}

.vertical {
  background: var(--bg-paper);
  padding: 40px 32px 56px;
  transition: background 300ms ease;
  position: relative;
}

.vertical::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width 400ms ease;
}

.vertical h3::before {
  content: "// ";
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 0.7em;
  font-weight: 400;
  letter-spacing: 0.05em;
  vertical-align: 2px;
}

.vertical:hover {
  background: var(--hover-paper);
}

.vertical:hover::before {
  width: 100%;
}

.vertical p {
  color: var(--ink-dim);
  font-size: 16px;
  line-height: 1.55;
  margin: 0;
  max-width: 28ch;
}

@media (max-width: 900px) {
  .focus-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 540px) {
  .focus-grid {
    grid-template-columns: 1fr;
  }
}

/* ───────── Portfolio ───────── */
.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  margin-top: 12px;
}

.portco {
  background: var(--bg-paper);
  display: flex;
  flex-direction: column;
  padding: 32px;
  gap: 24px;
  text-decoration: none;
  color: inherit;
  position: relative;
  transition: background 300ms ease;
}

/* Uniform container so the title row below stays aligned across cards.
   mask-size: contain guarantees the logo always fits — wider logos
   end up shorter, taller logos end up narrower. Aspect ratios of the
   source images are doing all the visual work here. */
.portco-logo {
  display: block;
  height: 60px;
  width: 100%;
  max-width: 220px;
  overflow: hidden;
  background-color: var(--ink-dim);
  -webkit-mask-position: left center;
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-position: left center;
  mask-size: contain;
  mask-repeat: no-repeat;
  transition: background-color 300ms ease;
}

.logo-ctrl {
  -webkit-mask-image: url("/assets/portfolio/ctrl-labs.png");
  mask-image: url("/assets/portfolio/ctrl-labs.png");
}
.logo-turion {
  -webkit-mask-image: url("/assets/portfolio/turion.svg");
  mask-image: url("/assets/portfolio/turion.svg");
}
.logo-generalsense {
  -webkit-mask-image: url("/assets/portfolio/generalsense.png");
  mask-image: url("/assets/portfolio/generalsense.png");
}
.logo-omneky {
  -webkit-mask-image: url("/assets/portfolio/omneky.svg");
  mask-image: url("/assets/portfolio/omneky.svg");
}
.logo-sania {
  -webkit-mask-image: url("/assets/portfolio/sania.png");
  mask-image: url("/assets/portfolio/sania.png");
}

.portco:hover .portco-logo {
  background-color: var(--accent);
}

.portco-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.portco::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width 400ms ease;
}

.portco:hover {
  background: var(--hover-paper);
}

.portco:hover::before {
  width: 100%;
}

.portco h3 {
  margin: 0;
  font-size: clamp(18px, 1.4vw, 22px);
  display: flex;
  align-items: baseline;
  gap: 0.4em;
  flex-wrap: wrap;
}

.portco h3::before {
  content: "//";
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 0.6em;
  font-weight: 400;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.portco .sector {
  color: var(--ink-dim);
  font-size: 15px;
}

.portco .tag {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
  margin-top: 6px;
}

/* ───────── Contact ───────── */
.contact h2 {
  max-width: 14ch;
}

.mailto {
  display: inline-block;
  margin-top: 40px;
  font-family: var(--serif);
  font-size: clamp(28px, 4vw, 56px);
  font-weight: 300;
  font-style: italic;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 6px;
  transition: color 250ms ease, border-color 250ms ease;
}

.mailto:hover {
  color: var(--accent-bright);
  border-color: var(--accent);
}

/* ───────── Footer ───────── */
footer {
  position: relative;
  background: var(--bg);
  z-index: 2;
  border-top: 1px solid var(--rule);
}

.footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 40px var(--pad) 56px;
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  color: var(--ink-faint);
}

@media (max-width: 640px) {
  .nav-toggle {
    display: flex;
  }
  .nav nav {
    position: fixed;
    inset: 0;
    background-color: #0a1024;
    background-color: var(--bg);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 28px;
    padding: 80px var(--pad) calc(48px + env(safe-area-inset-bottom));
    transform: translateY(-100%);
    transition: transform 280ms ease;
    z-index: 100;
    pointer-events: none;
  }
  [data-theme="light"] .nav nav {
    background-color: #e8ebef;
    background-color: var(--bg);
  }
  .nav.open nav {
    transform: translateY(0);
    pointer-events: auto;
  }
  .nav nav a {
    font-size: 22px;
  }
  .nav nav a.cta {
    margin-top: 8px;
  }
  .nav-toggle {
    z-index: 110;
    position: relative;
  }
  .brand-tag {
    display: none;
  }
  .hero {
    text-align: center;
    min-height: 100dvh;
  }
  .hero-inner {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .hero-inner h1 {
    margin-top: auto;
  }
  .hero-actions {
    margin-top: auto;
    margin-bottom: calc(72px + env(safe-area-inset-bottom));
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  .lede {
    margin-left: auto;
    margin-right: auto;
  }
  .btn {
    justify-content: center;
  }
  .hero-meta {
    display: none;
  }
  .footer-inner {
    flex-direction: column;
    gap: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .caret {
    animation: none;
  }
  html {
    scroll-behavior: auto;
  }
}
