/* ============================================================
   Phantom Lab — COMPONENTS
   Header & nav, language switch, theme toggle, burger + mobile
   menu, buttons, generic cards, chips, form controls.
   Media queries live next to the component they affect.
   ============================================================ */

/* ============ Header ============ */
.header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  transition: background-color 0.4s ease, box-shadow 0.4s ease, backdrop-filter 0.4s ease;
}
.header.is-scrolled {
  background: var(--header-bg);
  /* backdrop-filter is intentionally kept here (and on .mobile-menu) only */
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
}
.header-inner {
  width: min(1280px, 100% - 40px);
  margin-inline: auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-5);
  padding: 18px 0;
  transition: padding 0.4s ease;
}
.header.is-scrolled .header-inner { padding: 10px 0; }

.logo { display: flex; align-items: center; gap: 10px; flex: none; min-height: 44px; }
.logo-mark { width: 30px; height: 30px; flex: none; }
.logo-molecule {
  transform-origin: 16px 16px;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.logo:hover .logo-molecule { transform: rotate(120deg); }
.logo-text {
  font-family: var(--font-display);
  font-weight: 700; font-size: 1.3rem;
  /* must never wrap to two lines — that doubles the header height */
  white-space: nowrap;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav { display: flex; gap: var(--space-5); }
.nav-link {
  font-size: 0.95rem; color: var(--text-muted);
  position: relative;
  transition: color 0.25s ease;
}
.nav-link::after {
  content: ""; position: absolute; left: 0; bottom: -5px;
  width: 100%; height: 2px;
  background: var(--grad);
  border-radius: 2px;
  transform: scaleX(0); transform-origin: left;
  transition: transform 0.3s ease;
}
.nav-link:hover { color: var(--text); }
.nav-link:hover::after { transform: scaleX(1); }

.header-actions { display: flex; align-items: center; gap: var(--space-3); }

/* ============ Language switch ============ */
.lang-switch { position: relative; }
.lang-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-pill);
  padding: var(--space-2) 14px;
  font-size: 0.85rem; font-weight: 600;
  transition: border-color 0.25s ease, background 0.25s ease;
}
.lang-btn:hover { border-color: var(--accent-2); }
.lang-menu {
  position: absolute; top: calc(100% + var(--space-2)); right: 0;
  min-width: max-content;
  white-space: nowrap;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
  z-index: 20;
}
.lang-menu.is-open { display: block; }
.lang-menu button {
  display: block; width: 100%;
  text-align: left;
  background: none; border: none;
  color: var(--text);
  font-size: 0.88rem;
  padding: 9px var(--space-3);
  border-radius: var(--radius-xs);
  transition: background 0.2s ease;
}
.lang-menu button:hover { background: var(--surface-strong); }
.lang-menu button.is-active { color: var(--accent-3); }

/* ============ Theme toggle ============ */
.theme-toggle {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  transition: border-color 0.25s ease, transform 0.25s ease;
}
.theme-toggle:hover { border-color: var(--accent-2); transform: rotate(15deg); }
.theme-toggle svg { width: 19px; height: 19px; }
.theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ============ Burger + mobile menu ============ */
.burger {
  display: none;
  width: 42px; height: 42px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 50%;
  position: relative;
}
.burger span {
  position: absolute; left: var(--space-3); right: var(--space-3);
  height: 2px; background: var(--text);
  border-radius: 2px;
  transition: transform 0.3s ease, top 0.3s ease;
}
/* positioned off the centre line so the bars stay centred at any button size */
.burger span:nth-child(1) { top: calc(50% - 5px); }
.burger span:nth-child(2) { top: calc(50% + 3px); }
.burger.is-open span:nth-child(1) { top: calc(50% - 1px); transform: rotate(45deg); }
.burger.is-open span:nth-child(2) { top: calc(50% - 1px); transform: rotate(-45deg); }

.mobile-menu {
  position: fixed; inset: 0; z-index: 90;
  background: var(--header-bg);
  /* backdrop-filter intentionally kept here */
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--space-5);
  opacity: 0; visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}
.mobile-menu.is-open { opacity: 1; visibility: visible; }
.mobile-link {
  font-family: var(--font-display);
  font-size: 1.6rem; font-weight: 500;
}

@media (max-width: 820px) {
  .nav { display: none; }
  .header-actions .btn { display: none; }
  .burger { display: block; }
}

/* Narrow phones: the logo + three 44px controls have to fit on one row,
   so the header tightens up instead of wrapping. */
@media (max-width: 560px) {
  .header-inner { width: min(1280px, 100% - 32px); gap: var(--space-2); }
  .header-actions { gap: var(--space-2); }
  .logo { gap: 8px; }
  .logo-mark { width: 26px; height: 26px; }
  .logo-text { font-size: 1.05rem; }
  .lang-btn { padding: var(--space-2) 10px; font-size: 0.8rem; }
}
/* 320px (iPhone SE / older Android): the row is 9px over budget at 560px
   sizing, so shave the brand lockup rather than let the burger overhang. */
@media (max-width: 380px) {
  .header-actions { gap: 6px; }
  .logo { gap: 6px; }
  .logo-mark { width: 24px; height: 24px; }
  .logo-text { font-size: 0.98rem; }
}

/* ---- Touch targets ----
   `flex: none` stops the header controls being squeezed below their declared
   size by the flex row; the min-heights bring every control to 44px. */
.theme-toggle, .burger, .lang-btn { flex: none; }

@media (hover: none), (pointer: coarse), (max-width: 820px) {
  .theme-toggle, .burger {
    width: 44px; height: 44px;
  }
  .lang-btn { min-height: 44px; }
  .chip { min-height: 44px; display: inline-flex; align-items: center; }
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 13px var(--space-5);
  border: none;
  transition: box-shadow 0.3s ease, transform 0.3s ease, border-color 0.3s ease;
  will-change: transform;
}
.btn-sm { padding: 9px var(--space-4); font-size: 0.85rem; }
.btn-lg { padding: 16px 36px; font-size: 1rem; }
.btn-primary {
  background: var(--grad);
  background-size: 150% 150%;
  color: #fff;
  box-shadow: 0 8px 30px rgba(124, 58, 237, 0.35);
}
.btn-primary:hover { box-shadow: 0 10px 45px rgba(79, 124, 255, 0.55); }
.btn-ghost {
  /* no backdrop-filter: a slightly opaque surface reads the same */
  background: var(--surface-strong);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--accent-2); box-shadow: var(--glow); }

/* ============ Generic card ============ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  transition: transform 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
}

/* ============ Chips ============ */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-pill);
  padding: 9px 18px;
  font-size: 0.88rem;
  font-weight: 500;
  transition: color 0.25s ease, background-color 0.25s ease,
              border-color 0.25s ease, box-shadow 0.25s ease;
}
.chip:hover { border-color: var(--accent-2); color: var(--text); }
.chip.is-active {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.35);
}

/* ============ Form controls ============ */
.form-group { margin-bottom: 22px; }
.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 10px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}
input[type="text"], textarea, select {
  width: 100%;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  /* NEVER drop below 16px: iOS Safari auto-zooms a focused field with a
     smaller font, which widens the layout and looks like horizontal scroll. */
  font-size: 1rem;
  padding: 14px 16px;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  resize: vertical;
}
input[type="text"]:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: var(--focus-ring);
}
input.is-invalid, textarea.is-invalid { border-color: #F0506E; }
::placeholder { color: var(--text-muted); opacity: 0.7; }

/* ---- GDPR consent row (required before the lead is sent to Telegram) ---- */
.form-consent {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.form-consent input[type="checkbox"] {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--accent-2);
  cursor: pointer;
}
.form-consent input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}
.form-consent input[type="checkbox"].is-invalid {
  outline: 2px solid #F0506E;
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}
/* override the bold block label of .form-group */
.form-consent label {
  display: block;
  margin: 0;
  padding-top: 2px;
  font-weight: 400;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text-muted);
  cursor: pointer;
  /* long German compounds must not push the form wider than the viewport */
  overflow-wrap: anywhere;
}
.form-consent a {
  color: var(--accent-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.form-consent a:hover { color: var(--accent-3); }
.form-consent a:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* Honeypot: clipped to a 1px box instead of parked at left:-9999px, so it can
   never widen the document on engines that ignore the clipping ancestor. */
.hp-field {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; border: 0;
  clip-path: inset(50%);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

/* `display: inline-flex` put the button in a line box whose height is driven by
   the baseline of its label, so ~16px of the 52px button hung BELOW the line
   box and the next block sibling (.form-error) was drawn on top of it.
   A block-level flex box takes its own full height in the flow. */
.btn-submit {
  display: flex;
  width: fit-content;
  max-width: 100%;
  margin-top: var(--space-2);
  min-width: min(240px, 100%);
}
.btn-submit.is-loading { pointer-events: none; opacity: 0.7; }
.form-error {
  color: #F0506E;
  margin-top: 14px;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.form-success {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  position: relative; z-index: 2;
}
.success-check { width: 84px; height: 84px; margin: 0 auto 22px; }
.form-success h3 { font-size: 1.5rem; margin-bottom: var(--space-2); }
.form-success p { color: var(--text-muted); }

@media (max-width: 820px) {
  .form-row { grid-template-columns: 1fr; }
}
