/*
Theme Name: Protocol 42
Theme URI: https://protocol42.com
Author: Protocol 42
Author URI: https://protocol42.com
Description: A motion-rich, AI/SaaS marketing theme with togglable effects (ribbon strings, morphing blobs, 3D objects, magnetic cursor, scroll reveals, magnetic buttons). Compatible with Gutenberg + Elementor.
Version: 2.4.1
Requires at least: 6.0
Tested up to: 6.6
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: protocol-42
Tags: dark, custom-colors, custom-logo, custom-menu, featured-images, threaded-comments, translation-ready, full-site-editing, block-styles
*/

:root {
  --p42-bg: #0a0a0f;
  --p42-bg-soft: #12121a;
  --p42-fg: #f4f4f8;
  /* v2.2.1 — body and muted text bumped lighter for sunlight / outdoor readability */
  --p42-fg-dim: #c8c8d4;   /* was #a1a1b0 — body paragraphs */
  --p42-fg-mute: #9494a4;  /* was #66667a — eyebrow/labels */
  --p42-cyan: #00e5ff;
  --p42-magenta: #ff2d87;
  --p42-lime: #c7ff3d;
  --p42-violet: #8b5cf6;
  --p42-border: rgba(255,255,255,0.08);
  --p42-border-strong: rgba(255,255,255,0.18);

  --p42-font-display: 'Space Grotesk', system-ui, sans-serif;
  --p42-font-body: 'Inter', system-ui, sans-serif;
  --p42-font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --p42-radius: 14px;
  --p42-radius-lg: 22px;
  --p42-easing: cubic-bezier(0.22, 1, 0.36, 1);
  --p42-easing-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --p42-container: 1320px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--p42-bg);
  color: var(--p42-fg);
  font-family: var(--p42-font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  position: relative;
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }

.p42-container { width: 100%; max-width: var(--p42-container); margin: 0 auto; padding: 0 32px; }
@media (max-width: 720px) { .p42-container { padding: 0 20px; } }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--p42-font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0 0 0.4em;
}
h1 { font-size: clamp(2.6rem, 7vw, 6rem); }
h2 { font-size: clamp(2rem, 4.5vw, 3.6rem); }
h3 { font-size: clamp(1.4rem, 2.4vw, 2rem); }
p { margin: 0 0 1em; color: var(--p42-fg-dim); }

.p42-eyebrow {
  font-family: var(--p42-font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--p42-cyan);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.p42-eyebrow::before { content: ''; width: 24px; height: 1px; background: var(--p42-cyan); }
.p42-gradient-text {
  background: linear-gradient(120deg, var(--p42-cyan), var(--p42-magenta) 60%, var(--p42-lime));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Header / nav
   backdrop-filter is one of the more expensive scroll-time paint operations.
   We keep it but isolate paints with `contain` and force a GPU layer so it
   doesn't repaint the body underneath on every scroll frame. */
.p42-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  padding: 22px 0;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  background: rgba(10,10,15,0.55);
  border-bottom: 1px solid var(--p42-border);
  will-change: transform; transform: translateZ(0);
  contain: layout paint;
}
.p42-header__row { display: flex; align-items: center; justify-content: space-between; gap: 32px; }
.p42-logo {
  font-family: var(--p42-font-mono);
  font-size: 1rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 10px;
}
.p42-logo img { max-height: 36px; width: auto; }
.p42-footer .p42-logo img { max-height: 56px; }
.p42-logo__mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: conic-gradient(from 220deg, var(--p42-cyan), var(--p42-magenta), var(--p42-lime), var(--p42-cyan));
  position: relative;
}
.p42-logo__mark::after {
  content: '42';
  position: absolute; inset: 3px;
  background: var(--p42-bg);
  border-radius: 6px;
  display: grid; place-items: center;
  font-size: 0.66rem; font-weight: 700; color: var(--p42-fg);
}
.p42-nav { display: flex; gap: 28px; align-items: center; list-style: none; padding: 0; margin: 0; }
.p42-nav a {
  font-size: 0.92rem; color: var(--p42-fg-dim);
  position: relative; padding: 6px 0;
  transition: color 0.3s var(--p42-easing);
}
.p42-nav a:hover, .p42-nav .current-menu-item > a { color: var(--p42-fg); }
.p42-nav a::after {
  content: ''; position: absolute; left: 0; bottom: 0;
  width: 0; height: 1px; background: var(--p42-cyan);
  transition: width 0.4s var(--p42-easing);
}
.p42-nav a:hover::after, .p42-nav .current-menu-item > a::after { width: 100%; }
.p42-nav__toggle { display: none; }

@media (max-width: 860px) {
  .p42-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: var(--p42-bg-soft);
    flex-direction: column; padding: 24px;
    border-top: 1px solid var(--p42-border);
  }
  .p42-nav.is-open { display: flex; }
  .p42-nav__toggle {
    display: inline-grid; place-items: center;
    width: 40px; height: 40px;
    border: 1px solid var(--p42-border-strong);
    border-radius: 10px;
  }
}

/* Buttons */
.p42-btn, .wp-block-button__link {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 22px; border-radius: 999px;
  font-family: var(--p42-font-mono);
  font-size: 0.82rem; letter-spacing: 0.08em; text-transform: uppercase;
  position: relative;
  transition: transform 0.4s var(--p42-easing-spring), background 0.3s, color 0.3s;
  will-change: transform;
}
.p42-btn--primary, .wp-block-button:not(.is-style-outline) .wp-block-button__link {
  background: var(--p42-fg); color: var(--p42-bg);
}
.p42-btn--primary:hover { background: var(--p42-cyan); }
.p42-btn--ghost, .wp-block-button.is-style-outline .wp-block-button__link {
  border: 1px solid var(--p42-border-strong); color: var(--p42-fg); background: transparent;
}
.p42-btn--ghost:hover { background: var(--p42-fg); color: var(--p42-bg); }
.p42-btn__arrow { transition: transform 0.4s var(--p42-easing); }
.p42-btn:hover .p42-btn__arrow { transform: translateX(4px); }

/* Hero */
.p42-hero {
  position: relative; min-height: 100vh;
  display: grid; align-items: center;
  padding: 140px 0 80px;
  overflow: hidden;
}
.p42-hero__inner { position: relative; z-index: 2; }
.p42-hero__sub { max-width: 560px; font-size: 1.15rem; color: var(--p42-fg-dim); margin: 28px 0 40px; }
.p42-hero__cta { display: flex; gap: 16px; flex-wrap: wrap; }
.p42-hero__scroll {
  position: absolute; bottom: 36px; left: 50%; transform: translateX(-50%);
  font-family: var(--p42-font-mono); font-size: 0.7rem;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--p42-fg-mute);
  display: flex; flex-direction: column; align-items: center; gap: 12px; z-index: 2;
}
.p42-hero__scroll::after {
  content: ''; width: 1px; height: 40px;
  background: linear-gradient(to bottom, var(--p42-fg-mute), transparent);
  animation: p42-scroll-line 2s ease-in-out infinite;
}
@keyframes p42-scroll-line {
  0%, 100% { transform: scaleY(1); opacity: 0.4; }
  50% { transform: scaleY(1.4); opacity: 1; }
}

/* Section
   v2.4.0 — tightened vertical rhythm per feedback. content-visibility still on
   for the scroll-perf win. */
.p42-section {
  position: relative;
  padding: 90px 0;
  content-visibility: auto;
  contain-intrinsic-size: 1px 600px;
}
.p42-hero, #home, #contact { content-visibility: visible; } /* always render hero + contact (they're top/bottom CTAs) */
.p42-section--tight { padding: 60px 0; }
.p42-section__head {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 40px; margin-bottom: 48px; align-items: end;
}
.p42-section__head .lead { color: var(--p42-fg-dim); max-width: 480px; }
/* Full-width head modifier — title + optional lead stack vertically across full width. */
.p42-section__head--wide { grid-template-columns: 1fr; }
.p42-section__head--wide .lead { max-width: 72ch; margin-top: 12px; }
@media (max-width: 860px) {
  .p42-section__head { grid-template-columns: 1fr; gap: 12px; margin-bottom: 32px; }
  .p42-section { padding: 70px 0; }
}

/* Cards / grid */
.p42-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }

/* 5-card layout: 3 on top row, 2 on bottom row, no overhang.
   Implemented via 6-col grid where each card spans 2 cols by default; the last
   two cards (when there are exactly 5) span 3 cols each so they fill the row. */
.p42-grid--5 { grid-template-columns: repeat(6, 1fr); }
.p42-grid--5 > * { grid-column: span 2; }
.p42-grid--5 > :nth-last-child(2):nth-child(4),
.p42-grid--5 > :nth-last-child(1):nth-child(5) { grid-column: span 3; }
@media (max-width: 920px) {
  .p42-grid--5 { grid-template-columns: repeat(2, 1fr); }
  .p42-grid--5 > * { grid-column: span 1; }
  .p42-grid--5 > :nth-last-child(1):nth-child(5) { grid-column: span 2; }
}
@media (max-width: 600px) {
  .p42-grid--5 { grid-template-columns: 1fr; }
  .p42-grid--5 > * { grid-column: span 1 !important; }
}
.p42-card {
  position: relative; padding: 32px;
  background: var(--p42-bg-soft);
  border: 1px solid var(--p42-border);
  border-radius: var(--p42-radius-lg);
  overflow: hidden;
  transition: transform 0.6s var(--p42-easing), border-color 0.4s;
}
.p42-card:hover { border-color: var(--p42-border-strong); transform: translateY(-4px); }
.p42-card__num { font-family: var(--p42-font-mono); font-size: 0.78rem; color: var(--p42-cyan); letter-spacing: 0.18em; }
.p42-card h3 { margin-top: 18px; }
.p42-card p { color: var(--p42-fg-dim); font-size: 0.95rem; }

/* About split — text on left, brand image on right (per v2.4.0 feedback) */
.p42-split-row {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 60px;
  align-items: center;
  margin-bottom: 56px;
}
.p42-split-row__text h2 { margin-bottom: 16px; }
.p42-split-row__text p  { font-size: 1.05rem; }
.p42-split-row__media {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--p42-border);
}
.p42-split-row__media img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.p42-split-row__media::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgba(10,10,15,0.4) 100%);
  pointer-events: none;
}
@media (max-width: 860px) {
  .p42-split-row { grid-template-columns: 1fr; gap: 32px; }
  .p42-split-row__media { aspect-ratio: 16 / 10; }
}

/* Stats */
.p42-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 32px; border-top: 1px solid var(--p42-border); padding-top: 60px; }
.p42-stat__num {
  font-family: var(--p42-font-display);
  font-size: clamp(2.6rem, 5vw, 4.2rem);
  letter-spacing: -0.03em;
  background: linear-gradient(180deg, var(--p42-fg), var(--p42-fg-mute));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.p42-stat__label { font-family: var(--p42-font-mono); font-size: 0.78rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--p42-fg-mute); margin-top: 8px; }

/* Footer */
.p42-footer { border-top: 1px solid var(--p42-border); padding: 80px 0 40px; margin-top: 60px; position: relative; z-index: 2; }
.p42-footer__row { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 60px; margin-bottom: 60px; }
.p42-footer h4 { font-family: var(--p42-font-mono); font-size: 0.78rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--p42-fg-mute); margin-bottom: 18px; }
.p42-footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.p42-footer a { color: var(--p42-fg-dim); transition: color 0.3s; font-size: 0.95rem; }
.p42-footer a:hover { color: var(--p42-cyan); }
.p42-footer__bottom { border-top: 1px solid var(--p42-border); padding-top: 24px; display: flex; justify-content: center; font-family: var(--p42-font-mono); font-size: 0.78rem; color: var(--p42-fg-mute); text-transform: uppercase; letter-spacing: 0.12em; text-align: center; }
@media (max-width: 860px) { .p42-footer__row { grid-template-columns: 1fr; gap: 32px; } .p42-footer__bottom { flex-direction: column; gap: 12px; } }

/* Footer socials */
.p42-socials { display: flex; flex-direction: column; gap: 12px; }
.p42-social { display: inline-flex; align-items: center; gap: 10px; color: var(--p42-fg-dim); transition: color 0.3s, transform 0.3s var(--p42-easing); font-size: 0.95rem; }
.p42-social svg { transition: transform 0.3s var(--p42-easing-spring); }
.p42-social:hover { color: var(--p42-cyan); }
.p42-social:hover svg { transform: scale(1.15) rotate(-3deg); }

/* Team */
.p42-team-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; }
.p42-team-card { position: relative; border: 1px solid var(--p42-border); border-radius: var(--p42-radius-lg); padding: 32px; background: var(--p42-bg-soft); transition: transform 0.5s var(--p42-easing); }
.p42-team-card:hover { transform: translateY(-6px); }
.p42-team-card__avatar { width: 100%; aspect-ratio: 1; border-radius: 14px; background: linear-gradient(135deg, var(--p42-cyan), var(--p42-magenta)); margin-bottom: 20px; position: relative; overflow: hidden; }
.p42-team-card__avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.p42-team-card h3 { font-size: 1.4rem; margin: 0 0 4px; }
.p42-team-card .role { font-family: var(--p42-font-mono); font-size: 0.78rem; color: var(--p42-cyan); letter-spacing: 0.12em; text-transform: uppercase; }
.p42-team-card p { font-size: 0.92rem; margin: 14px 0 0; color: var(--p42-fg-dim); }

/* Form */
.p42-form { display: grid; gap: 20px; max-width: 640px; }
.p42-form__row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 600px) { .p42-form__row { grid-template-columns: 1fr; } }
.p42-field { display: grid; gap: 8px; }
.p42-field label { font-family: var(--p42-font-mono); font-size: 0.74rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--p42-fg-mute); }
.p42-field input, .p42-field textarea, .p42-field select {
  background: var(--p42-bg-soft); border: 1px solid var(--p42-border);
  border-radius: 12px; padding: 14px 16px; color: var(--p42-fg);
  transition: border-color 0.3s, background 0.3s;
}
.p42-field input:focus, .p42-field textarea:focus, .p42-field select:focus {
  outline: none; border-color: var(--p42-cyan); background: rgba(0,229,255,0.04);
}
.p42-field textarea { min-height: 140px; resize: vertical; }

/* Contact split */
.p42-contact { display: grid; grid-template-columns: 1fr 1fr; gap: 60px; align-items: start; }
.p42-contact__info dl { display: grid; gap: 24px; margin: 0; }
.p42-contact__info dt { font-family: var(--p42-font-mono); font-size: 0.74rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--p42-fg-mute); margin-bottom: 6px; }
.p42-contact__info dd { margin: 0; font-size: 1.1rem; }
@media (max-width: 860px) { .p42-contact { grid-template-columns: 1fr; gap: 40px; } }

/* Effect host containers */
.p42-fx-stage { position: absolute; inset: 0; pointer-events: none; z-index: 1; }

/* === Magnetic cursor === */
.p42-cursor { position: fixed; top: 0; left: 0; width: 16px; height: 16px; border-radius: 50%; background: var(--p42-cyan); pointer-events: none; z-index: 9999; mix-blend-mode: difference; transform: translate(-50%, -50%); transition: width 0.25s var(--p42-easing-spring), height 0.25s var(--p42-easing-spring), background 0.3s, opacity 0.3s; opacity: 0; }
.p42-cursor.is-ready { opacity: 1; }
.p42-cursor.is-hover { width: 56px; height: 56px; background: var(--p42-fg); }
.p42-cursor.is-press { width: 24px; height: 24px; }
@media (hover: none) { .p42-cursor { display: none; } }

/* === Morphing blobs ===
   Blur is the single most expensive paint operation. Reduced from 80px to 60px
   and given a will-change hint so the compositor keeps blobs on the GPU layer
   instead of repainting on every scroll frame. */
.p42-blobs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; will-change: transform; transform: translateZ(0); contain: layout paint; }
.p42-blobs__b { position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; filter: blur(60px); opacity: 0.32; mix-blend-mode: screen; animation: p42-blob 24s ease-in-out infinite; will-change: transform; }
.p42-blobs__b--1 { background: var(--p42-cyan); top: -20%; left: -10%; animation-delay: 0s; }
.p42-blobs__b--2 { background: var(--p42-magenta); top: 30%; right: -15%; animation-delay: -8s; }
.p42-blobs__b--3 { background: var(--p42-violet); bottom: -20%; left: 30%; animation-delay: -16s; }
@keyframes p42-blob { 0%, 100% { transform: translate3d(0,0,0) scale(1); } 33% { transform: translate3d(8vw, -6vh, 0) scale(1.15); } 66% { transform: translate3d(-6vw, 4vh, 0) scale(0.92); } }

.p42-three   { position: absolute; inset: 0; z-index: 1; pointer-events: none; contain: layout paint; }
.p42-ribbons { position: absolute; inset: 0; z-index: 1; pointer-events: none; contain: layout paint; }

/* 3D scene wrapper — collapses to zero height if Three.js never mounts a canvas
   inside it. Prevents the empty 420px gap when CDN is blocked / slow. */
.p42-three-host { position: relative; max-width: 1320px; margin: 0 auto 60px; height: 0; overflow: hidden; transition: height 0.4s var(--p42-easing); }
.p42-three-host:has(canvas) { height: 420px; }
@media (max-width: 720px) { .p42-three-host:has(canvas) { height: 320px; } }

/* On smaller / lower-power screens, drop the blur radius further and slow the
   blob animation to ease GPU load. */
@media (max-width: 860px) {
  .p42-blobs__b { filter: blur(40px); animation-duration: 36s; }
}

/* Scroll reveal */
[data-p42-reveal] { opacity: 0; transform: translateY(40px); transition: opacity 1s var(--p42-easing), transform 1s var(--p42-easing); }
[data-p42-reveal].is-visible { opacity: 1; transform: none; }
[data-p42-reveal-stagger] > * { opacity: 0; transform: translateY(30px); transition: opacity 0.8s var(--p42-easing), transform 0.8s var(--p42-easing); }
[data-p42-reveal-stagger].is-visible > * { opacity: 1; transform: none; }
/* Belt-and-suspenders word spacing: JS now also injects text-node spaces
   between word spans, but we keep margin-right as a backup so the words can
   never run together regardless of cache state. Slightly reduced (0.12em) so
   it compounds nicely with the natural text-node space. */
.p42-split .word { display: inline-block; overflow: hidden; vertical-align: top; margin-right: 0.12em; }
.p42-split .word:last-child { margin-right: 0; }
.p42-split .word__inner { display: inline-block; transform: translateY(110%); transition: transform 1s var(--p42-easing); }
.p42-split.is-visible .word__inner { transform: none; }

/* Simple fade-up fallback for headings whose inner markup we don't want to split (e.g., gradient spans) */
.p42-split--simple { opacity: 0; transform: translateY(40px); transition: opacity 1s var(--p42-easing), transform 1s var(--p42-easing); }
.p42-split--simple.is-visible { opacity: 1; transform: none; }

[data-p42-magnetic] { will-change: transform; }

/* Gutenberg integration */
.editor-styles-wrapper { background: var(--p42-bg); color: var(--p42-fg); }
.wp-block-group, .wp-block-cover, .wp-block-columns { color: var(--p42-fg); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .p42-blobs, .p42-three, .p42-ribbons, .p42-cursor { display: none !important; }
}

.p42-mt-0 { margin-top: 0; }
.p42-mt-1 { margin-top: 12px; }
.p42-mt-2 { margin-top: 24px; }
.p42-mt-4 { margin-top: 48px; }
.p42-mt-6 { margin-top: 72px; }
.p42-text-center { text-align: center; }
.p42-mono { font-family: var(--p42-font-mono); }

/* Page content wrapper for Gutenberg/Elementor content inside templates */
.p42-page-content { position: relative; z-index: 2; }
.p42-page-content > .wp-block-group,
.p42-page-content > .elementor { position: relative; z-index: 2; }
