/* ===== Design tokens ===== */
:root {
  --primary: #800020;
  --primary-dark: #5c0017;
  --accent: #c0394b;
  --text: #0f172a;
  --muted: #64748b;
  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --border: #e2e8f0;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --header-h: 72px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; scroll-padding-top: var(--header-h); }

body {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

.container { width: min(1180px, 100% - 40px); margin-inline: auto; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 14px 28px; border-radius: 999px; font-weight: 600;
  border: 2px solid transparent; cursor: pointer; font: inherit; font-weight: 600;
  transition: transform .2s, box-shadow .2s, background .2s;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; box-shadow: 0 8px 20px rgba(128, 0, 32, .3);
}
.btn-primary:hover { box-shadow: 0 12px 28px rgba(128, 0, 32, .4); }
.btn-outline { border-color: var(--border); background: #fff; }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 10px 20px; font-size: .9rem; }
.btn-block { width: 100%; }

/* ===== Header ===== */
.header {
  position: fixed; inset: 0 0 auto 0; height: var(--header-h); z-index: 100;
  transition: background .3s, box-shadow .3s;
}
.header.scrolled {
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 var(--border);
}
.nav { height: 100%; display: flex; align-items: center; justify-content: space-between; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.3rem; }
.logo-mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff;
}
.nav-links { display: flex; align-items: center; gap: 32px; }
.nav-link { font-weight: 500; color: var(--muted); position: relative; transition: color .2s; }
.nav-link::after {
  content: ""; position: absolute; left: 0; bottom: -6px; width: 0; height: 2px;
  background: var(--primary); transition: width .25s;
}
.nav-link:hover, .nav-link.active { color: var(--text); }
.nav-link.active::after, .nav-link:hover::after { width: 100%; }

.menu-toggle { display: none; background: none; border: 0; cursor: pointer; padding: 8px; }
.menu-toggle span { display: block; width: 24px; height: 2px; background: var(--text); margin: 5px 0; transition: .3s; }
.menu-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle.open span:nth-child(2) { opacity: 0; }
.menu-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ===== Hero ===== */
.hero { position: relative; padding: calc(var(--header-h) + 80px) 0 100px; overflow: hidden; }
.hero-bg {
  position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(600px circle at 85% 20%, rgba(192, 57, 75, .15), transparent 60%),
    radial-gradient(700px circle at 10% 80%, rgba(128, 0, 32, .12), transparent 60%);
}
.hero-inner { display: grid; grid-template-columns: 1.1fr 1fr; gap: 60px; align-items: center; }
.badge {
  display: inline-block; padding: 8px 16px; border-radius: 999px; font-size: .85rem; font-weight: 600;
  background: rgba(128, 0, 32, .08); color: var(--primary); margin-bottom: 24px;
}
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.1; font-weight: 800; letter-spacing: -.02em; }
.gradient-text {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { margin: 24px 0 36px; font-size: 1.15rem; color: var(--muted); max-width: 540px; }
.hero-actions { display: flex; gap: 16px; flex-wrap: wrap; }

.hero-visual { position: relative; }
.code-card {
  background: #0f172a; color: #e2e8f0; border-radius: var(--radius); box-shadow: 0 30px 60px rgba(15, 23, 42, .25);
  overflow: hidden; transform: rotate(-2deg);
}
.code-card-head { display: flex; align-items: center; gap: 8px; padding: 14px 18px; background: #1e293b; }
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.red { background: #ef4444; } .dot.yellow { background: #f59e0b; } .dot.green { background: #22c55e; }
.file-name { margin-left: 12px; font-size: .85rem; color: #94a3b8; }
.code-card pre { padding: 24px; font-family: ui-monospace, Consolas, monospace; font-size: .95rem; overflow-x: auto; }
.kw { color: #c084fc; } .fn { color: #38bdf8; } .str { color: #4ade80; } .cm { color: #64748b; }

/* 3D scene */
.hero-3d, .hero-3d-hint { display: none; }
.hero-visual.has-3d .hero-3d { display: block; height: 480px; cursor: grab; touch-action: pan-y; }
.hero-visual.has-3d .hero-3d:active { cursor: grabbing; }
.hero-visual.has-3d .hero-3d canvas { display: block; width: 100% !important; height: 100% !important; }
.hero-visual.has-3d .hero-3d-hint {
  display: block; text-align: center; font-size: .8rem; color: var(--muted); margin-top: -8px;
}
.hero-visual.has-3d .code-fallback { display: none; }

.float-card {
  position: absolute; background: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600;
  box-shadow: var(--shadow); font-size: .9rem; animation: float 4s ease-in-out infinite;
}
.float-1 { top: -20px; right: 10px; }
.float-2 { bottom: -20px; left: -10px; animation-delay: -2s; }
@keyframes float { 50% { transform: translateY(-10px); } }

/* ===== Clients ===== */
.clients { padding: 40px 0; border-block: 1px solid var(--border); }
.clients .container { display: flex; align-items: center; gap: 40px; flex-wrap: wrap; justify-content: center; }
.clients p { color: var(--muted); font-size: .9rem; }
.client-logos { display: flex; gap: 48px; flex-wrap: wrap; justify-content: center; }
.client-logos span { font-weight: 800; font-size: 1.2rem; color: #94a3b8; letter-spacing: -.01em; }

/* ===== Sections ===== */
.section { padding: 100px 0; }
.section-alt { background: var(--bg-alt); }
.section-head { text-align: center; max-width: 640px; margin: 0 auto 56px; }
.eyebrow { color: var(--primary); font-weight: 700; text-transform: uppercase; letter-spacing: .1em; font-size: .8rem; }
h2 { font-size: clamp(1.8rem, 3.5vw, 2.6rem); line-height: 1.2; margin: 12px 0 16px; letter-spacing: -.02em; }
.section-head p { color: var(--muted); }

/* ===== Services ===== */
.services-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; }
.service-card {
  padding: 36px 32px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
  transition: transform .3s, box-shadow .3s, border-color .3s;
}
.service-card:hover { transform: translateY(-6px); box-shadow: var(--shadow); border-color: transparent; }
/* 3D stage per service (rendered by services3d.js); the emoji is the fallback */
.service-3d {
  position: relative; height: 190px; margin: -8px -8px 22px; border-radius: 14px;
  display: grid; place-items: center; font-size: 3rem; overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, rgba(192, 57, 75, .16), transparent 65%),
    linear-gradient(135deg, rgba(128, 0, 32, .05), rgba(192, 57, 75, .08));
}
.service-3d canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.service-3d.ready .service-emoji { display: none; }
.service-card h3 { margin-bottom: 10px; }
.service-card p { color: var(--muted); }
.service-list { display: grid; gap: 14px; margin-top: 14px; }
.service-list li { position: relative; padding-left: 18px; color: var(--muted); font-size: .95rem; }
.service-list li::before {
  content: ""; position: absolute; left: 0; top: .6em; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
}
.service-list strong { display: block; color: var(--text); }

/* ===== About + Why ===== */
.about-grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: 60px; align-items: center; }
.about-text p { color: var(--muted); margin-bottom: 28px; }
.why .eyebrow { display: block; margin-bottom: 16px; }
.why-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.why-card { background: #fff; padding: 28px; border-radius: var(--radius); box-shadow: var(--shadow); }
.why-num {
  font-size: 2rem; font-weight: 800; line-height: 1;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.why-card h3 { font-size: 1.05rem; margin: 12px 0 8px; }
.why-card p { color: var(--muted); font-size: .92rem; }

/* ===== Tech stack ===== */
.stack-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.stack-card {
  padding: 28px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
  transition: box-shadow .3s, border-color .3s;
}
.stack-card:hover { box-shadow: var(--shadow); border-color: transparent; }
.stack-card h3 { font-size: 1.05rem; margin-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 6px 14px; border-radius: 999px; font-size: .85rem; font-weight: 600;
  background: rgba(128, 0, 32, .07); color: var(--primary-dark);
}

/* ===== Engagement models ===== */
.models-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; align-items: stretch; }
.model-card {
  display: flex; flex-direction: column; gap: 12px; padding: 36px 32px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  transition: transform .3s, box-shadow .3s;
}
.model-card:hover { transform: translateY(-6px); box-shadow: var(--shadow); }
.model-card h3 { font-size: 1.4rem; }
.model-card p { color: var(--muted); flex: 1; }
.model-card .btn { align-self: flex-start; }
.model-sub { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--primary); }
.model-card.featured {
  background: linear-gradient(160deg, var(--primary-dark), var(--primary) 60%, var(--accent));
  color: #fff; border-color: transparent; box-shadow: 0 20px 40px rgba(128, 0, 32, .3);
}
.model-card.featured p, .model-card.featured .model-sub { color: rgba(255, 255, 255, .85); }
.btn-light { background: #fff; color: var(--primary); }

/* ===== Workflow ===== */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; list-style: none; counter-reset: step; }
.step {
  counter-increment: step; padding: 32px 28px; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.step::before {
  content: counter(step, decimal-leading-zero);
  display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 18px;
  border-radius: 14px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
}
.step {
  cursor: pointer;
  transition: transform .3s, box-shadow .3s, border-color .3s;
}
.step:hover { border-color: var(--accent); }
.step:focus-visible { outline: 3px solid rgba(192, 57, 75, .4); outline-offset: 2px; }
.step.active {
  transform: translateY(-6px); border-color: var(--primary);
  box-shadow: 0 16px 36px rgba(128, 0, 32, .18);
}
.step.active::before { box-shadow: 0 0 0 6px rgba(192, 57, 75, .18); }
.step h3 { font-size: 1.05rem; margin-bottom: 8px; }

/* 3D workflow path */
.flow-3d {
  height: 380px; margin: -12px 0 36px; border-radius: var(--radius); overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 60%, rgba(192, 57, 75, .12), transparent 70%),
    linear-gradient(180deg, #fff, var(--bg-alt));
}
.flow-3d canvas { display: block; width: 100% !important; height: 100% !important; }
.step p { color: var(--muted); font-size: .95rem; }

/* ===== Contact ===== */
.contact-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 60px; }
.contact-info p { color: var(--muted); margin-bottom: 28px; }
.contact-list { display: grid; gap: 14px; font-weight: 500; }
.contact-list a { color: var(--primary); }
.contact-list a:hover { text-decoration: underline; }
.contact-form { background: #fff; padding: 40px; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 16px; border: 1px solid var(--border); border-radius: 10px;
  font: inherit; background: var(--bg-alt); transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(128, 0, 32, .12); background: #fff;
}
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: #ef4444; }
.error { color: #ef4444; font-size: .8rem; min-height: 1em; display: block; margin-top: 4px; }
.form-status { margin-top: 14px; text-align: center; font-weight: 600; color: #16a34a; }
.form-status.error { color: #dc2626; }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ===== Footer ===== */
.footer { background: #0f172a; color: #cbd5e1; padding: 70px 0 0; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 40px; }
.footer .logo { color: #fff; margin-bottom: 14px; }
.footer h4 { color: #fff; margin-bottom: 14px; }
.footer ul { display: grid; gap: 10px; }
.footer a:hover { color: #fff; }
.footer-bottom { border-top: 1px solid #1e293b; margin-top: 50px; padding: 24px 0; font-size: .9rem; text-align: center; }

/* ===== Back to top ===== */
.back-to-top {
  position: fixed; right: 24px; bottom: 24px; width: 48px; height: 48px; border-radius: 50%; border: 0;
  background: var(--primary); color: #fff; font-size: 1.2rem; cursor: pointer; box-shadow: var(--shadow);
  opacity: 0; visibility: hidden; transform: translateY(20px); transition: .3s; z-index: 90;
}
.back-to-top.show { opacity: 1; visibility: visible; transform: none; }

/* ===== Scroll reveal ===== */
.reveal { opacity: 0; transform: translateY(30px); transition: opacity .7s ease, transform .7s ease; }
.reveal.visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .float-card { animation: none; }
  html { scroll-behavior: auto; }
}

/* ===== Responsive ===== */
@media (max-width: 960px) {
  .hero-inner, .about-grid, .contact-grid { grid-template-columns: 1fr; }
  .hero-visual { max-width: 520px; margin: 0 auto; width: 100%; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .steps { grid-template-columns: 1fr 1fr; }
  .nav-links { gap: 22px; }
}

@media (max-width: 600px) {
  .steps { grid-template-columns: 1fr; }
  .flow-3d { height: 440px; }
}

@media (max-width: 768px) {
  .menu-toggle { display: block; }
  .nav-links {
    position: fixed; top: var(--header-h); left: 0; right: 0; flex-direction: column; gap: 24px;
    background: #fff; padding: 32px 20px; box-shadow: var(--shadow);
    transform: translateY(-120%); transition: transform .35s ease;
  }
  .nav-links.open { transform: none; }
  .header:has(.nav-links.open) { background: #fff; }
  .section { padding: 72px 0; }
  .form-row { grid-template-columns: 1fr; }
  .contact-form { padding: 28px 20px; }
  .services-grid, .portfolio-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .why-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .float-card { display: none; }
  .hero-visual.has-3d .hero-3d { height: 340px; }
}
