/* ============================================================
   AIflowBPM — płyta główna 3D ze sterowanym robotem
   Dwa tryby:
   - bez WebGL / bez JS: zwykła strona, wszystkie sekcje jedna pod drugą
   - html.is-3d: pełnoekranowa scena, treść w panelu po wjechaniu w strefę
   ============================================================ */

:root {
  --bg: #0a0712;
  --board: #1c1036;
  --trace: #38206c;
  --trace-hi: #553596;
  --gold: #e8be62;
  --gold-dim: #a8873f;
  --silk: #f3eefc;
  --text: #e8e1f6;
  --muted: #b5a9d2;
  --signal: #3fe3f5;
  --robot: #f552e0;
  --ink: #1a0d33;
  --pkg: #0f0a1c;
  --glass: rgba(19, 10, 38, .93);

  --display: 'Chakra Petch', 'Trebuchet MS', system-ui, sans-serif;
  --body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --panel-w: clamp(370px, 37vw, 560px);
  --sheet-h: 48vh;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1.0625rem/1.62 var(--body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--display); color: var(--silk); line-height: 1.14; margin: 0; text-wrap: balance; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
a { color: var(--signal); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: #fff; }
strong { font-weight: 600; color: var(--silk); }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; border-radius: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: fixed; left: 12px; top: -80px; z-index: 60; background: var(--gold); color: var(--ink); padding: 10px 16px; font: 600 1rem var(--display); text-decoration: none; }
.skip:focus { top: 12px; }

/* ---------- pasek górny i zakładki ---------- */
.top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px 28px;
  padding: 10px clamp(14px, 2.4vw, 28px);
  background: rgba(10, 7, 18, .9);
  border-bottom: 1px solid var(--trace);
}
.brand { font: 700 1.45rem/1 var(--display); color: var(--silk); text-decoration: none; letter-spacing: -.01em; flex: none; }
.tabs { position: relative; display: flex; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex: none; padding: 9px 13px; border-radius: 4px;
  font: 600 .98rem/1 var(--display); color: var(--muted); text-decoration: none;
  border: 1px solid transparent; transition: color .2s, border-color .2s, background-color .2s;
}
.tabs a:hover { color: var(--silk); border-color: var(--trace-hi); }
.tabs a.is-active { color: var(--ink); background: var(--signal); border-color: var(--signal); }
.top-contact { margin: 0 0 0 auto; flex: none; font: 600 1rem var(--display); }
.top-contact a { color: var(--gold); text-decoration: none; }
.top-contact a:hover { color: #fff; }

/* elementy widoczne tylko w trybie 3D */
#scene, .vignette, .help, .mini, .dpad, .boot, .panel-close { display: none; }

/* ---------- treść (wspólna dla obu trybów) ---------- */
.panel { display: block; max-width: 50rem; margin-inline: auto; padding-inline: clamp(18px, 4vw, 40px); }
.sec { padding-block: 64px; border-top: 1px solid var(--trace); }
.sec:first-child { border-top: 0; }
.block { margin-top: 44px; }

.hero-kicker { font: 500 1.08rem var(--display); color: var(--signal); margin-bottom: 14px; }
h1 { font-size: clamp(2.5rem, 3.6vw, 3.6rem); font-weight: 700; line-height: .98; letter-spacing: -.02em; margin-bottom: 22px; }
.lead { font-size: 1.16rem; line-height: 1.55; }
.sec-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.sec-head h2 { font-size: clamp(1.7rem, 2.3vw, 2.2rem); font-weight: 700; letter-spacing: -.01em; }
.glyph { flex: none; width: 46px; height: 46px; fill: none; stroke: var(--gold); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.glyph .on { fill: rgba(232, 190, 98, .16); }
.glyph .dash { stroke-dasharray: 2 3; }
.glyph .thick { stroke-width: 2.5; }
.glyph .flag-w { fill: #fff; stroke: none; }
.glyph .flag-r { fill: #dc2f4a; stroke: none; }
.sub { font-size: 1.4rem; font-weight: 600; margin-bottom: 14px; }
h3 { font-size: 1.22rem; font-weight: 600; }
h4 { font-size: 1.05rem; font-weight: 600; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 28px 0 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 50px; padding: 12px 22px;
  font: 600 1.02rem/1.2 var(--display); text-decoration: none; text-align: center;
  border: 0; cursor: pointer;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  transition: background-color .2s, color .2s;
}
.btn-gold { background: var(--gold); color: var(--ink); }
.btn-gold:hover { background: #fff; color: var(--ink); }
.btn-line { background: var(--trace); color: var(--silk); }
.btn-line:hover { background: var(--trace-hi); color: #fff; }
.btn:focus-visible { outline: none; background: var(--signal); color: var(--ink); }

.trio { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 20px; }
.trio li { border-top: 2px solid var(--gold-dim); padding-top: 12px; }
.trio h3, .trio h4 { font-size: 1.12rem; margin-bottom: 6px; }
.trio h3 a { color: var(--silk); text-decoration: none; }
.trio h3 a:hover { color: var(--signal); }
.trio p { color: var(--muted); font-size: 1rem; }

.checks { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 18px; }
.checks li { position: relative; padding-left: 26px; color: var(--muted); }
.checks li::before { content: ''; position: absolute; left: 0; top: .5em; width: 11px; height: 11px; background: var(--gold); }
.checks strong { display: block; font: 600 1.08rem/1.3 var(--display); margin-bottom: 3px; }

.clients { list-style: none; padding: 0; margin: 20px 0 0; display: flex; flex-wrap: wrap; gap: 10px; }
.clients a { display: block; padding: 10px 15px; text-decoration: none; background: rgba(56, 32, 108, .35); border: 1px solid var(--trace-hi); border-radius: 4px; transition: border-color .2s; }
.clients a:hover { border-color: var(--gold); }
.clients strong { display: block; font: 600 1.04rem/1.3 var(--display); }
.clients span { color: var(--muted); font-size: .9rem; }

.callout { background: rgba(56, 32, 108, .35); border: 1px solid var(--trace-hi); border-radius: 6px; padding: 24px; }

.news { margin-top: 26px; }
.news article { padding-block: 22px; border-top: 1px dashed var(--trace-hi); }
.news article:last-child { border-bottom: 1px dashed var(--trace-hi); }
.news-meta { font: 500 .98rem/1.4 var(--display); color: var(--gold); margin: 0 0 8px; }
.news-meta span { margin-left: 12px; color: var(--muted); }
.news h3 { margin-bottom: 8px; }
.news p { color: var(--muted); }

.cards { display: grid; gap: 38px; margin-top: 30px; }
.card { position: relative; background: rgba(56, 32, 108, .32); border: 1px solid var(--trace-hi); border-radius: 6px 6px 0 0; padding: 24px; }
.card::before, .card::after { content: ''; position: absolute; bottom: -12px; height: 12px; background: repeating-linear-gradient(90deg, var(--gold) 0 5px, transparent 5px 9px); }
.card::before { left: 22px; width: 50px; }
.card::after { left: 86px; right: 18%; }
.card h3 { font-size: 1.36rem; margin-bottom: 12px; }
.card h4 { margin: 20px 0 8px; color: var(--gold); }
.pins { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.pins li { position: relative; padding-left: 22px; }
.pins li::before { content: ''; position: absolute; left: 0; top: .62em; width: 12px; height: 4px; background: var(--gold-dim); }

.stamp { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; font: 700 1.3rem/1.1 var(--display); color: var(--silk); }
.stamp span { padding: 10px 14px; border: 2px solid var(--silk); border-radius: 4px; }
.stamp span + span { border-color: #dc2f4a; }

.links { list-style: none; padding: 0; margin: 16px 0 0; }
.links li { padding-block: 15px; border-top: 1px dashed var(--trace-hi); }
.links li:last-child { border-bottom: 1px dashed var(--trace-hi); }
.links a { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; text-decoration: none; margin-bottom: 4px; }
.links a strong { font: 600 1.1rem/1.3 var(--display); transition: color .2s; }
.links a:hover strong { color: var(--signal); }
.links p { color: var(--muted); font-size: 1rem; }
.url { font: 500 .94rem/1.4 var(--display); color: var(--signal); }

.chips { list-style: none; padding: 0 10px; margin: 30px 0 0; display: grid; gap: 22px; }
.chip { position: relative; background: var(--pkg); border: 1px solid #3a3152; border-radius: 6px; padding: 18px 20px 16px 24px; }
.chip::before, .chip::after { content: ''; position: absolute; top: 16px; bottom: 16px; width: 9px; background: repeating-linear-gradient(180deg, var(--gold-dim) 0 5px, transparent 5px 12px); }
.chip::before { left: -10px; }
.chip::after { right: -10px; }
.chip h3 { font-size: 1.4rem; margin-bottom: 2px; }
.chip h3::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #5d5378; margin-right: 10px; vertical-align: .22em; }
.chip .maker { color: var(--gold); font: 500 .94rem var(--display); margin-bottom: 10px; }
.chip p { color: var(--muted); font-size: 1rem; margin-bottom: 10px; }
.chip .kind { color: var(--signal); font: 500 .92rem var(--display); margin: 0; }

.steps { list-style: none; counter-reset: step; padding: 0; margin: 24px 0 0 15px; border-left: 2px solid var(--trace-hi); }
.steps li { position: relative; padding: 0 0 24px 34px; counter-increment: step; }
.steps li:last-child { padding-bottom: 0; }
.steps li::before { content: counter(step); position: absolute; left: -16px; top: -3px; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: #150b2a; border: 2px solid var(--gold); color: var(--gold); font: 600 .95rem var(--display); }
.steps h4 { font-size: 1.12rem; margin-bottom: 5px; }
.steps p { color: var(--muted); }

.projects { margin-top: 26px; }
.project { display: grid; gap: 18px; padding-block: 26px; border-top: 1px dashed var(--trace-hi); }
.project:last-child { border-bottom: 1px dashed var(--trace-hi); }
.project h3 { font-size: 1.3rem; margin-bottom: 4px; }
.project .url { margin-bottom: 12px; }
.project p { color: var(--muted); }
.project .btn { justify-self: start; }
.note { margin-top: 22px; color: var(--muted); font: 500 1rem var(--display); }
.tags { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 7px; }
.tags li { font: 500 .88rem/1.2 var(--display); color: var(--muted); padding: 6px 9px; border: 1px solid var(--trace-hi); border-radius: 3px; }
.tags-lg li { font-size: .98rem; color: var(--silk); padding: 7px 11px; }

.years { display: flex; flex-wrap: wrap; gap: 16px 44px; margin: 6px 0 22px; }
.years dt { font: 700 2.7rem/1 var(--display); color: var(--gold); }
.years dd { margin: 6px 0 0; color: var(--muted); }
.duo { display: grid; gap: 34px; }
.duo p { color: var(--muted); }
.values { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 20px 28px; margin: 18px 0 0; }
.values div { border-top: 2px solid var(--gold-dim); padding-top: 12px; }
.values dt { font: 600 1.1rem/1.3 var(--display); color: var(--silk); }
.values dd { margin: 4px 0 0; color: var(--muted); font-size: 1rem; }

.contact { display: grid; gap: 36px; margin-top: 28px; }
.form { background: rgba(56, 32, 108, .32); border: 1px solid var(--trace-hi); border-radius: 6px; padding: 22px; }
.field { margin: 0 0 16px; }
.field label { display: block; font: 600 1rem/1.3 var(--display); color: var(--silk); margin-bottom: 6px; }
.field label span { color: var(--gold); }
.field input, .field textarea { display: block; width: 100%; padding: 12px 13px; font: 400 1.0625rem/1.4 var(--body); color: var(--silk); background: #0d0619; border: 1px solid var(--trace-hi); border-radius: 4px; }
.field textarea { resize: vertical; min-height: 120px; }
.field input:focus-visible, .field textarea:focus-visible { outline: 2px solid var(--signal); outline-offset: 0; border-color: var(--signal); }
.field input.is-bad, .field textarea.is-bad { border-color: #ff7d92; }
.form .actions { margin-top: 20px; }
.form-note { margin-top: 12px; font-size: .94rem; color: var(--muted); }
.form-note.is-error { color: #ff9aaa; }
.reach { margin: 0; display: grid; gap: 22px; }
.reach div { border-top: 2px solid var(--gold-dim); padding-top: 10px; }
.reach dt { font: 600 1rem var(--display); color: var(--gold); margin-bottom: 4px; }
.reach dd { margin: 0; }
.reach a { display: block; font: 600 1.25rem/1.3 var(--display); color: var(--silk); text-decoration: none; overflow-wrap: anywhere; }
.reach a:hover { color: var(--signal); }
.reach span { display: block; color: var(--muted); font-size: 1rem; }

.foot { border-top: 1px solid var(--trace); padding-block: 34px 44px; color: var(--muted); font-size: .96rem; }
.foot p { margin-bottom: 6px; }
.foot-brand { font: 700 1.4rem var(--display); color: var(--silk); }
.foot-legal { margin-top: 12px; font-size: .88rem; }

/* ============================================================
   TRYB 3D
   ============================================================ */
.is-3d, .is-3d body { height: 100%; overflow: hidden; overscroll-behavior: none; }
.is-3d #scene { display: block; position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; outline: none; cursor: crosshair; }
.is-3d .vignette { display: block; position: fixed; inset: 0; pointer-events: none; background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(5, 3, 10, .62) 100%); }

.is-3d .top { position: fixed; left: 0; right: 0; background: linear-gradient(rgba(10, 7, 18, .92), rgba(10, 7, 18, .55) 70%, transparent); border-bottom: 0; padding-bottom: 22px; }
.is-3d .tabs { background: rgba(19, 10, 38, .78); border: 1px solid var(--trace); border-radius: 7px; padding: 4px; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }

.is-3d .panel {
  position: fixed; z-index: 20; top: 74px; right: 16px; bottom: 16px; width: var(--panel-w); max-width: none; margin: 0; padding: 0;
  background: var(--glass); border: 1px solid var(--trace-hi); border-radius: 10px;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .55);
  transform: translateX(calc(100% + 32px)); visibility: hidden;
  transition: transform .45s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .45s;
}
.is-3d .panel.is-open { transform: none; visibility: visible; transition: transform .45s cubic-bezier(.2, .8, .2, 1), visibility 0s; }
.is-3d .panel-scroll { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: 8px 30px 0; scrollbar-width: thin; scrollbar-color: var(--trace-hi) transparent; }
.is-3d .sec { display: none; border-top: 0; padding-block: 34px 38px; }
.is-3d .sec.is-on { display: block; }
.is-3d .foot { padding-block: 22px 26px; font-size: .9rem; }
.is-3d .foot-brand { font-size: 1.15rem; }
.is-3d .panel-close {
  display: block; position: absolute; top: 12px; right: 14px; z-index: 2;
  padding: 7px 12px; font: 600 .9rem/1 var(--display); color: var(--muted);
  background: rgba(10, 7, 18, .7); border: 1px solid var(--trace-hi); border-radius: 4px; cursor: pointer;
}
.is-3d .panel-close:hover { color: var(--silk); border-color: var(--gold); }

.is-3d .help {
  display: flex; align-items: center; gap: 14px;
  position: fixed; z-index: 15; left: 204px; bottom: 16px;
  width: max-content; max-width: min(calc(100vw - 220px), 600px); margin: 0; padding: 12px 18px;
  background: var(--glass); border: 1px solid var(--trace-hi); border-radius: 8px;
  font: 500 1rem/1.4 var(--display); color: var(--silk);
  transition: opacity .6s ease 1.2s, visibility 0s linear 1.8s;
}
.is-3d.panel-open .help { max-width: min(calc(100vw - var(--panel-w) - 250px), 600px); }
.is-3d .help.is-done { opacity: 0; visibility: hidden; }
.keys { display: inline-grid; grid-template-columns: repeat(4, auto); gap: 4px; flex: none; }
kbd { display: inline-grid; place-items: center; width: 30px; height: 30px; font: 600 1rem/1 var(--display); color: var(--ink); background: var(--gold); border-radius: 4px; box-shadow: 0 2px 0 var(--gold-dim); }
.help-touch { display: none; }

.is-3d .mini { display: block; position: fixed; z-index: 15; left: 16px; bottom: 16px; padding: 6px; background: var(--glass); border: 1px solid var(--trace-hi); border-radius: 8px; }
.is-3d .mini canvas { display: block; width: 158px; height: 128px; cursor: pointer; }

.is-3d .boot { display: block; position: fixed; inset: 0; z-index: 40; margin: 0; display: grid; place-items: center; background: var(--bg); font: 600 1.2rem var(--display); color: var(--muted); transition: opacity .6s ease, visibility 0s linear .6s; }
.is-3d.is-ready .boot { opacity: 0; visibility: hidden; }

/* strzałki ekranowe: tylko na ekranach dotykowych */
.dpad button {
  width: 58px; height: 58px; font: 600 1.5rem/1 var(--display); color: var(--ink);
  background: var(--gold); border: 0; border-radius: 10px; box-shadow: 0 3px 0 var(--gold-dim);
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.dpad button.is-down { background: var(--signal); transform: translateY(2px); box-shadow: 0 1px 0 #1d8c99; }
.dpad [data-key="up"] { grid-area: u; }
.dpad [data-key="left"] { grid-area: l; }
.dpad [data-key="down"] { grid-area: d; }
.dpad [data-key="right"] { grid-area: r; }

@media (pointer: coarse) {
  .is-3d .dpad {
    display: grid; grid-template-areas: ". u ." "l d r"; gap: 6px;
    position: fixed; z-index: 25; left: 14px; bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    transition: bottom .45s cubic-bezier(.2, .8, .2, 1);
  }
  .is-3d .keys, .is-3d .help-keys { display: none; }
  .is-3d .help-touch { display: inline; }
  .is-3d .help { left: 14px; right: 14px; bottom: auto; top: 118px; width: auto; max-width: none; }
  .is-3d.panel-open .help { max-width: none; }
  .is-3d .mini { left: auto; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); transition: bottom .45s cubic-bezier(.2, .8, .2, 1); }
}

@media (max-width: 899px) {
  .top { flex-wrap: wrap; gap: 8px 16px; }
  .top-contact { order: 2; }
  .tabs { order: 3; width: 100%; }
  .is-3d .top { padding-bottom: 14px; }
  .is-3d .panel {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%; height: var(--sheet-h);
    border-radius: 14px 14px 0 0; border-width: 1px 0 0;
    transform: translateY(105%);
  }
  .is-3d .panel-scroll { padding-inline: 20px; }
  .is-3d .help { font-size: .92rem; padding: 10px 14px; }
  .is-3d .mini canvas { width: 104px; height: 84px; }
  .is-3d.panel-open .dpad { bottom: calc(var(--sheet-h) + 10px); }
  .is-3d.panel-open .mini { display: none; }
  .dpad button { width: 50px; height: 50px; font-size: 1.3rem; }
  .btn { width: 100%; }
  .project .btn { width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; transition-delay: 0s !important; animation: none !important; }
}
