/* ============================================================================
   Mátra Coding — style.css
   Engineering-first studio site. Dark-first, mint/terminal accent.
   Theming via CSS custom properties on [data-theme].
   ========================================================================== */

/* ----------------------------------- Reset ------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; padding: 0; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

/* ------------------------------- Design tokens --------------------------- */
:root {
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;

  --maxw: 1280px;
  --pad: clamp(20px, 5vw, 88px);

  --r-sm: 6px;
  --r-md: 12px;
  --r-lg: 18px;

  --ease: cubic-bezier(.22, 1, .36, 1);
  --t-fast: .18s var(--ease);
  --t: .32s var(--ease);
}

/* Dark (default) */
[data-theme='dark'] {
  --bg:        #0a0c10;
  --bg-2:      #0d1014;
  --surface:   #12161c;
  --surface-2: #161b22;
  --border:    rgba(255, 255, 255, .09);
  --border-2:  rgba(255, 255, 255, .15);
  --text:      #e8ebef;
  --text-dim:  #9aa6b4;
  --text-faint:#5a6573;
  --accent:        oklch(0.84 0.15 165);
  --accent-strong: oklch(0.88 0.16 165);
  --accent-ink:    #06120c;            /* text on accent fills */
  --accent-soft:   color-mix(in oklch, var(--accent) 14%, transparent);
  --particle:      rgba(120, 230, 190, .55);
  --particle-line: rgba(120, 230, 190, .14);
  --shadow:    0 24px 60px -28px rgba(0, 0, 0, .8);
  --grid-line: rgba(255, 255, 255, .035);
}

/* Light */
[data-theme='light'] {
  --bg:        #f5f6f4;
  --bg-2:      #eef0ec;
  --surface:   #ffffff;
  --surface-2: #ffffff;
  --border:    rgba(15, 23, 25, .10);
  --border-2:  rgba(15, 23, 25, .18);
  --text:      #0f1417;
  --text-dim:  #4a555d;
  --text-faint:#8a949c;
  --accent:        oklch(0.58 0.13 165);
  --accent-strong: oklch(0.52 0.14 165);
  --accent-ink:    #ffffff;
  --accent-soft:   color-mix(in oklch, var(--accent) 12%, transparent);
  --particle:      rgba(20, 110, 80, .5);
  --particle-line: rgba(20, 110, 80, .12);
  --shadow:    0 24px 60px -30px rgba(20, 40, 35, .28);
  --grid-line: rgba(15, 23, 25, .045);
}

/* --------------------------------- Base ---------------------------------- */
html { scroll-behavior: smooth; scroll-padding-top: 92px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  font-family: var(--font-display);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: clamp(15px, 1.05vw, 17px);
  overflow-x: hidden;
  transition: background var(--t), color var(--t);
  /* faint engineering grid wash */
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 64px 64px, 64px 64px;
}

strong { color: var(--text); font-weight: 600; }
.accent { color: var(--accent); }

/* Particle canvas sits behind everything */
.bg-canvas {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
}
main, .nav, .footer, .drawer { position: relative; z-index: 1; }

.skip-link {
  position: fixed; top: 10px; left: 50%; translate: -50% -200%;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 18px; border-radius: var(--r-sm);
  font-family: var(--font-mono); font-size: 13px; z-index: 100;
  transition: translate var(--t);
}
.skip-link:focus { translate: -50% 0; }

/* ------------------------------- Buttons --------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--font-mono); font-size: 14px; font-weight: 500;
  letter-spacing: .01em;
  padding: 13px 22px; border-radius: var(--r-sm);
  border: 1px solid transparent;
  transition: transform var(--t-fast), background var(--t-fast),
              border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn--solid {
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 8px 30px -12px color-mix(in oklch, var(--accent) 60%, transparent);
}
.btn--solid:hover { background: var(--accent-strong); transform: translateY(-2px); }
.btn--ghost {
  background: transparent; color: var(--text);
  border-color: var(--border-2);
}
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn--lg { padding: 16px 30px; font-size: 15px; }

/* ------------------------------- Navbar ---------------------------------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(14px);
  background: color-mix(in oklch, var(--bg) 72%, transparent);
  border-bottom: 1px solid transparent;
  transition: border-color var(--t), background var(--t);
}
.nav.is-scrolled { border-bottom-color: var(--border); }
.nav__inner {
  max-width: var(--maxw); margin: 0 auto;
  padding: 14px var(--pad);
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.brand {
  font-family: var(--font-mono); font-weight: 500; font-size: 16px;
  letter-spacing: .02em; display: inline-flex; align-items: center;
}
.brand__bracket { color: var(--text-faint); }
.brand__accent { color: var(--accent); }
.brand__name { color: var(--text); }

.nav__links { display: flex; gap: 28px; }
.nav__links a {
  font-family: var(--font-mono); font-size: 14px; color: var(--text-dim);
  position: relative; padding: 4px 0; transition: color var(--t-fast);
}
.nav__links a::after {
  content: ''; position: absolute; left: 0; bottom: -2px;
  width: 100%; height: 1.5px; background: var(--accent);
  transform: scaleX(0); transform-origin: left; transition: transform var(--t);
}
.nav__links a:hover { color: var(--text); }
.nav__links a.is-active { color: var(--accent); }
.nav__links a.is-active::after { transform: scaleX(1); }

.nav__actions { display: flex; align-items: center; gap: 12px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: var(--r-sm);
  border: 1px solid var(--border); display: grid; place-items: center;
  color: var(--text-dim); transition: color var(--t-fast), border-color var(--t-fast);
  position: relative;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; position: absolute; transition: opacity var(--t), transform var(--t); }
[data-theme='dark'] .icon-sun  { opacity: 1; transform: rotate(0) scale(1); }
[data-theme='dark'] .icon-moon { opacity: 0; transform: rotate(-90deg) scale(.6); }
[data-theme='light'] .icon-sun  { opacity: 0; transform: rotate(90deg) scale(.6); }
[data-theme='light'] .icon-moon { opacity: 1; transform: rotate(0) scale(1); }

.hamburger { display: none; width: 40px; height: 40px; border: 1px solid var(--border); border-radius: var(--r-sm); flex-direction: column; align-items: center; justify-content: center; gap: 5px; }
.hamburger span { width: 18px; height: 1.8px; background: var(--text); border-radius: 2px; transition: transform var(--t), opacity var(--t-fast); }
.hamburger[aria-expanded='true'] span:nth-child(1) { transform: translateY(6.8px) rotate(45deg); }
.hamburger[aria-expanded='true'] span:nth-child(2) { opacity: 0; }
.hamburger[aria-expanded='true'] span:nth-child(3) { transform: translateY(-6.8px) rotate(-45deg); }

/* Drawer (mobile) */
.drawer {
  position: fixed; top: 0; right: 0; z-index: 60;
  height: 100dvh; width: min(82vw, 340px);
  background: var(--surface); border-left: 1px solid var(--border);
  padding: 96px 32px 32px;
  transform: translateX(100%); transition: transform var(--t);
}
.drawer.is-open { transform: translateX(0); }
.drawer__nav { display: flex; flex-direction: column; gap: 6px; }
.drawer__nav a { font-family: var(--font-mono); font-size: 18px; color: var(--text-dim); padding: 14px 0; border-bottom: 1px solid var(--border); transition: color var(--t-fast); }
.drawer__nav a:hover { color: var(--accent); }
.drawer__nav .btn { margin-top: 20px; justify-content: center; }
.drawer-scrim { position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.5); backdrop-filter: blur(2px); }

/* ------------------------------ Sections --------------------------------- */
.section {
  max-width: var(--maxw); margin: 0 auto;
  padding: clamp(72px, 11vw, 150px) var(--pad);
}
.section__head { display: flex; align-items: baseline; gap: 18px; margin-bottom: clamp(36px, 6vw, 64px); }
.section__index { font-family: var(--font-mono); font-size: 14px; color: var(--accent); padding-top: 6px; }
.section__title {
  font-size: clamp(34px, 6.5vw, 76px); line-height: .98; font-weight: 600;
  letter-spacing: -.02em; text-wrap: balance;
}

/* --------------------------------- Hero ---------------------------------- */
.hero {
  max-width: var(--maxw); margin: 0 auto; position: relative;
  min-height: calc(100dvh - 70px);
  padding: clamp(40px, 8vw, 80px) var(--pad) 64px;
  display: flex; align-items: center;
}
.hero__grid { max-width: 920px; }
.overline {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: 13px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 100px; padding: 7px 16px;
  margin-bottom: 28px;
}
.overline__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 var(--accent); animation: pulse 2.4s var(--ease) infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--accent) 55%, transparent); } 70%,100% { box-shadow: 0 0 0 9px transparent; } }

.hero__title {
  font-size: clamp(56px, 15vw, 188px); line-height: .86; font-weight: 700;
  letter-spacing: -.045em; margin-bottom: 26px; text-wrap: balance;
}
.hero__dot { color: var(--accent); }

.hero__type {
  font-family: var(--font-mono); font-size: clamp(15px, 2.4vw, 24px);
  display: flex; align-items: center; gap: 10px; color: var(--text);
  margin-bottom: 30px; min-height: 1.6em;
}
.hero__prompt { color: var(--accent); }
.typewriter { color: var(--text); }
.caret { display: inline-block; width: 9px; height: 1.05em; background: var(--accent); translate: 0 2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.hero__lead { max-width: 560px; font-size: clamp(16px, 1.6vw, 19px); color: var(--text-dim); margin-bottom: 36px; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 14px; }

.hero__rail {
  position: absolute; right: var(--pad); bottom: 60px;
  display: flex; flex-direction: column; gap: 6px; text-align: right;
  font-family: var(--font-mono); font-size: 12px; color: var(--text-faint);
}
.hero__rail .rail-line span { color: var(--accent); margin-right: 8px; }
.hero__rail .rail-line em { color: var(--text-dim); font-style: normal; }

.scroll-cue {
  position: absolute; left: var(--pad); bottom: 34px;
  display: flex; align-items: center; gap: 9px;
  font-family: var(--font-mono); font-size: 12px; color: var(--text-faint);
  letter-spacing: .1em; text-transform: uppercase;
}
.scroll-cue svg { width: 16px; height: 16px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; animation: nudge 1.8s var(--ease) infinite; }
@keyframes nudge { 0%,100% { transform: translateY(0); } 50% { transform: translateY(4px); } }

/* --------------------------------- About --------------------------------- */
.about__grid {
  display: grid;
  grid-template-columns: 1.4fr .9fr;
  grid-template-areas: 'lead founder' 'stats founder';
  gap: clamp(28px, 4vw, 56px);
  align-items: start;
}
.about__lead { grid-area: lead; }
.about__lead p { font-size: clamp(17px, 1.9vw, 22px); color: var(--text-dim); margin-bottom: 22px; max-width: 60ch; }
.about__lead p:last-child { margin-bottom: 0; }

/* Founder photo — theme-swapped editorial portrait, contained in the side column */
.about__founder { grid-area: founder; position: sticky; top: 110px; }
.about__photo {
  border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden;
  background: var(--surface); box-shadow: var(--shadow);
}
.about__img { width: 100%; height: auto; display: block; }
[data-theme='dark']  .about__img--light { display: none; }
[data-theme='light'] .about__img--dark  { display: none; }
.about__founder figcaption { display: flex; flex-direction: column; gap: 3px; margin-top: 16px; }
.founder__name { font-weight: 600; font-size: 18px; }
.founder__role { font-family: var(--font-mono); font-size: 13px; color: var(--text-dim); }

.about__stats { grid-area: stats; display: flex; flex-wrap: wrap; gap: clamp(20px, 4vw, 48px); padding-top: 8px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat__num { font-size: clamp(38px, 5vw, 58px); font-weight: 700; letter-spacing: -.03em; line-height: 1; color: var(--accent); }
.stat__label { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-dim); max-width: 14ch; }

.industries { margin-top: clamp(48px, 7vw, 88px); border-top: 1px solid var(--border); padding-top: 36px; }
.industries__label { font-family: var(--font-mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint); }
.industries__list { display: flex; flex-wrap: wrap; gap: 12px 14px; margin-top: 20px; }
.industries__list li {
  font-family: var(--font-mono); font-size: 14px; color: var(--text-dim);
  padding: 8px 16px; border: 1px solid var(--border); border-radius: 100px;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.industries__list li:hover { color: var(--accent); border-color: var(--accent); }

/* ------------------------------- Services -------------------------------- */
.services__grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(6, 1fr);
}
.card {
  grid-column: span 2;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 30px 28px 32px;
  position: relative; overflow: hidden;
  transition: transform var(--t), border-color var(--t), background var(--t);
}
.card::before {
  content: ''; position: absolute; left: 0; top: 0; height: 100%; width: 2px;
  background: var(--accent); transform: scaleY(0); transform-origin: top;
  transition: transform var(--t);
}
.card:hover, .card:focus-visible { transform: translateY(-5px); border-color: var(--border-2); background: var(--surface-2); }
.card:hover::before, .card:focus-visible::before { transform: scaleY(1); }
.card__num { font-family: var(--font-mono); font-size: 13px; color: var(--text-faint); position: absolute; top: 26px; right: 28px; }
.card__title { font-size: clamp(20px, 2.2vw, 26px); font-weight: 600; letter-spacing: -.01em; margin-bottom: 12px; margin-top: 6px; }
.card__body { color: var(--text-dim); font-size: 15.5px; }

/* feature card spans wider + taller */
.card--feature {
  grid-column: span 4; grid-row: span 2;
  background:
    radial-gradient(120% 120% at 100% 0%, var(--accent-soft), transparent 55%),
    var(--surface);
  display: flex; flex-direction: column;
}
.card--feature .card__title { font-size: clamp(28px, 3.4vw, 42px); margin-top: 18px; }
.card--feature .card__body { font-size: clamp(15px, 1.5vw, 17.5px); max-width: 46ch; }
.card__tag {
  align-self: flex-start; font-family: var(--font-mono); font-size: 11px;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); border: 1px solid var(--accent);
  border-radius: 100px; padding: 5px 12px;
}
.card__list { margin-top: auto; padding-top: 22px; display: flex; flex-direction: column; gap: 9px; }
.card__list li { font-family: var(--font-mono); font-size: 13.5px; color: var(--text-dim); display: flex; align-items: center; gap: 10px; }
.card__list li::before { content: ''; width: 6px; height: 6px; background: var(--accent); border-radius: 1px; rotate: 45deg; flex: none; }

/* --------------------------------- Stack --------------------------------- */
.stack__groups { display: grid; gap: clamp(28px, 4vw, 44px); }
.stack__group { display: grid; grid-template-columns: 240px 1fr; gap: clamp(16px, 3vw, 40px); align-items: start; padding-bottom: clamp(28px, 4vw, 44px); border-bottom: 1px solid var(--border); }
.stack__group:last-child { border-bottom: none; padding-bottom: 0; }
.stack__cat { display: inline-flex; align-items: center; gap: 12px; font-family: var(--font-mono); font-size: 14px; color: var(--text); padding-top: 6px; }
.stack__cat-mark { width: 9px; height: 9px; border-radius: 2px; background: var(--accent); rotate: 45deg; flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 12px; }
.chip {
  font-family: var(--font-mono); font-size: 14.5px; color: var(--text-dim);
  padding: 11px 18px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface);
  transition: transform var(--t-fast), color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.chip:hover { transform: translateY(-3px); color: var(--text); border-color: var(--border-2); }
.chip--hot { color: var(--accent); border-color: color-mix(in oklch, var(--accent) 40%, transparent); background: var(--accent-soft); }
.chip--hot:hover { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

/* -------------------------------- Contact -------------------------------- */
.contact { padding-top: clamp(60px, 9vw, 120px); }
.contact__inner { max-width: 760px; }
.contact .section__head { margin-bottom: 28px; }
.contact__lead { font-size: clamp(17px, 1.9vw, 21px); color: var(--text-dim); max-width: 52ch; margin-bottom: 34px; }
.contact__list { display: grid; gap: 2px; margin-top: 54px; border-top: 1px solid var(--border); }
.contact__list li { display: flex; align-items: baseline; gap: 24px; padding: 22px 4px; border-bottom: 1px solid var(--border); }
.contact__k { font-family: var(--font-mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint); width: 110px; flex: none; }
.contact__v { font-family: var(--font-mono); font-size: clamp(16px, 2vw, 22px); color: var(--text); position: relative; transition: color var(--t-fast); }
.contact__v::after { content: ''; position: absolute; left: 0; bottom: -3px; width: 100%; height: 1.5px; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform var(--t); }
.contact__v:hover { color: var(--accent); }
.contact__v:hover::after { transform: scaleX(1); }

/* -------------------------------- Footer --------------------------------- */
.footer { border-top: 1px solid var(--border); }
.footer__inner {
  max-width: var(--maxw); margin: 0 auto; padding: 32px var(--pad);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px;
  font-family: var(--font-mono); font-size: 13px; color: var(--text-faint);
}
.footer__brand { color: var(--text-dim); }
.footer__copy { color: var(--text-faint); }

/* ------------------------------- Back to top ----------------------------- */
.to-top {
  position: fixed; right: 24px; bottom: 24px; z-index: 40;
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--border-2); background: var(--surface);
  display: grid; place-items: center; color: var(--text);
  opacity: 0; visibility: hidden; transform: translateY(12px);
  transition: opacity var(--t), transform var(--t), visibility var(--t), color var(--t-fast), border-color var(--t-fast);
  box-shadow: var(--shadow);
}
.to-top.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }
.to-top:hover { color: var(--accent); border-color: var(--accent); }
.to-top svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------- Consent --------------------------------- */
.consent {
  position: fixed; left: 24px; bottom: 24px; z-index: 60;
  width: min(440px, calc(100vw - 48px));
  display: flex; flex-direction: column; gap: 16px;
  padding: 20px 22px;
  background: color-mix(in oklch, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-2); border-radius: var(--r-md);
  box-shadow: var(--shadow);
}
.consent[hidden] { display: none; }
.consent__text { font-family: var(--font-mono); font-size: 13px; line-height: 1.6; color: var(--text-dim); }
.consent__text strong { color: var(--accent); font-weight: 500; }
.consent__ok { align-self: flex-start; padding: 11px 28px; }
/* Lift the back-to-top button while the banner occupies the corner */
.consent-open .to-top { bottom: 24px; right: 24px; }
@media (max-width: 560px) {
  .consent { left: 16px; right: 16px; bottom: 16px; width: auto; }
  .consent-open .to-top { bottom: 188px; }
}

/* --------------------------- Scroll reveal anim -------------------------- */
.js .reveal { opacity: 0; transform: translateY(26px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.js .reveal.is-in { opacity: 1; transform: none; }
/* Instantaneous failsafe: guarantees final visible state even in environments
   that freeze CSS transitions (e.g. background/offscreen rendering). */
.js .reveal.is-shown { opacity: 1 !important; transform: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .overline__dot, .caret, .scroll-cue svg { animation: none; }
}

/* -------------------------------- Responsive ----------------------------- */
@media (max-width: 980px) {
  .about__grid { grid-template-columns: 1fr; grid-template-areas: 'founder' 'lead' 'stats'; }
  .about__founder { position: static; max-width: 420px; }
  .stack__group { grid-template-columns: 1fr; gap: 16px; }
  .card, .card--feature { grid-column: span 3; }
  .card--feature { grid-row: auto; }
}
@media (max-width: 720px) {
  .nav__links, .nav__cta { display: none; }
  .hamburger { display: flex; }
  .hero__rail { display: none; }
  .scroll-cue { display: none; }
  .services__grid { grid-template-columns: 1fr; }
  .card, .card--feature { grid-column: 1 / -1; }
  .hero { min-height: auto; padding-top: 56px; padding-bottom: 56px; }
  .contact__list li { flex-direction: column; gap: 6px; }
  .contact__k { width: auto; }
}
