/* ---------------------------------------------------------------------------
   AutomationLab website: layout and motion, layered over the client's pages.

   The client's own files in website/ are never edited. build_website.py
   adds this stylesheet after each homepage's inline <style>, so every rule
   here wins by coming later in the cascade - same selectors, same weight.
   When he sends a new version of his site, this layer still applies as long
   as his class names stay the same.

   Motion only runs under html.al-motion, which the build's small <head>
   script sets - and only when the visitor has not asked their system for
   reduced motion. Without it (or if enhance.js never loads, see the 3-second
   failsafe in that script) every section is simply visible, as he wrote it.
--------------------------------------------------------------------------- */

:root {
  --edge: clamp(1.25rem, 4.5vw, 5.5rem);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ===========================================================================
   1. WIDTH: content runs much closer to the edges
   =========================================================================== */

.wrap { max-width: 1920px; padding-inline: var(--edge); }
section.block { padding: clamp(3.5rem, 7vw, 6rem) 0; }
.svc .body { max-width: 72ch; }
.hero-rabbit { max-width: 460px; }

/* ===========================================================================
   2. HEADER: logo left, links centred, actions right
   =========================================================================== */

.site-head { transition: box-shadow 0.3s var(--ease), background 0.3s ease; }
.site-head.is-scrolled { box-shadow: 0 12px 30px -20px rgba(0, 0, 0, 0.45); }
.site-head .wrap { height: 72px; gap: clamp(0.75rem, 1.4vw, 1.5rem); }
.site-nav { margin-inline: auto; gap: clamp(1rem, 1.5vw, 1.75rem); }
.site-nav a {
  position: relative;
  padding: 0.45rem 0;
  font-size: 0.95rem;
  transition: color 0.2s ease;
}
.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--signal);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.35s var(--ease);
}
.site-nav a:hover::after,
.site-nav a.is-active::after { transform: scaleX(1); transform-origin: left; }
.site-nav a.is-active { color: var(--ink); }
.login { transition: color 0.2s ease; }
.lang a { transition: background 0.2s ease, color 0.2s ease; }
.lang a:not([aria-current="page"]):hover { color: var(--ink); background: var(--signal-soft); }

/* His rules hid "Client login" below 1440px and every link below 1200px,
   leaving no way to navigate on a laptop or phone. The links now stay up to
   1400px, and below that a menu button opens them (built by enhance.js). */
@media (max-width: 1440px) {
  .login { display: inline; }
  .site-nav { gap: clamp(0.8rem, 1.2vw, 1.3rem); }
  .site-nav a { font-size: 0.9rem; }
}
@media (max-width: 1400px) {
  .site-nav, .login { display: none; }
  .site-head .lang { margin-left: auto; }
}

.menu-btn {
  display: none;
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.menu-btn:hover { border-color: var(--ink); }
.menu-btn span {
  position: absolute;
  left: 12px;
  right: 12px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.35s var(--ease), top 0.35s var(--ease);
}
.menu-btn span:first-child { top: 16px; }
.menu-btn span:last-child { top: 25px; }
.menu-btn[aria-expanded="true"] span:first-child { top: 20.5px; transform: rotate(45deg); }
.menu-btn[aria-expanded="true"] span:last-child { top: 20.5px; transform: rotate(-45deg); }
@media (max-width: 1400px) { .menu-btn { display: inline-block; } }

.menu-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  padding: 0.75rem var(--edge) 1.5rem;
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  box-shadow: 0 24px 40px -28px rgba(0, 0, 0, 0.5);
}
.menu-panel[hidden] { display: none; }
.menu-panel a {
  display: block;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
  font: 600 1.25rem/1.2 var(--serif);
  text-decoration: none;
}
.menu-panel a:last-child { border-bottom: 0; }
/* No colour here: his .btn.primary rules pick the right text colour for the
   light and dark themes. */
.menu-panel a.btn { display: inline-flex; margin-top: 1rem; padding: 0.9rem 1.2rem; border-bottom: 1.5px solid var(--signal); font: 600 1rem/1 var(--sans); }

/* Page progress, a thin line along the very top. */
.al-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: 2px;
  background: var(--signal);
  transform: scaleX(0);
  transform-origin: left;
  pointer-events: none;
}

/* ===========================================================================
   3. BUTTONS
   =========================================================================== */

.btn {
  position: relative;
  overflow: hidden;
  transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease), background 0.2s ease,
    border-color 0.2s ease, color 0.2s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn.primary:hover { box-shadow: 0 14px 26px -14px color-mix(in srgb, var(--signal) 80%, transparent); }
.btn.primary::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -60%;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: skewX(-20deg);
  transition: left 0.7s var(--ease);
  pointer-events: none;
}
.btn.primary:hover::after { left: 130%; }

/* ===========================================================================
   4. SECTIONS
   =========================================================================== */

/* Why it matters: counters, and the lines above them draw in. */
.stats strong { font-variant-numeric: tabular-nums; }
.stats li { position: relative; border-top-color: transparent; }
.stats li::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--signal);
  transform-origin: left;
}
.risk-grid > div { position: relative; transition: transform 0.3s var(--ease), border-color 0.3s ease; }
.risk-grid > div:hover { transform: translateX(4px); border-left-color: var(--signal); }
.risk-grid > div:hover b { color: var(--signal); }

/* Services: the one in the middle of the screen is marked. */
.svc article { transition: background 0.4s ease; }
.svc article h3 { transition: color 0.35s ease; }
.svc article.is-current h3 { color: var(--signal); }
.svc li::marker { color: var(--signal); }
.svc .why { transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease); }
.svc article:hover .why { transform: translateY(-2px); box-shadow: 0 10px 24px -18px rgba(0, 0, 0, 0.5); }

/* Platforms: real logos, in each network's colour. One-pixel lines between
   cells come from the grid gap, instead of his doubled borders. */
.plats { gap: 1px; border: 1px solid var(--rule); background: var(--rule); }
.plats > div { border: 0; background: var(--paper); }
.plat { transition: background 0.3s ease; }
.plats dt { display: flex; align-items: center; gap: 0.75rem; }
.plat-ico {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 12px;
  background: color-mix(in srgb, var(--brand, var(--ink)) 13%, transparent);
  color: var(--brand, var(--ink));
  transition: transform 0.4s var(--ease), background 0.3s ease, color 0.3s ease;
}
.plat-ico svg { width: 21px; height: 21px; display: block; }
.plat:hover { background: color-mix(in srgb, var(--brand, var(--ink)) 7%, var(--paper)); }
.plat:hover .plat-ico {
  transform: translateY(-3px) rotate(-6deg) scale(1.08);
  background: var(--brand, var(--ink));
  color: var(--plat-on, #fff);
}

/* How we work: the numbered steps. */
.steps li::before { transition: background 0.45s ease, color 0.45s ease, transform 0.35s var(--ease); }
.steps li:hover::before { transform: scale(1.1); }
.steps li::after { transform-origin: left; }

/* Why AutomationLab: a line that draws in, and a lift on hover. */
.diffs > div { position: relative; border-top-color: var(--rule); transition: transform 0.3s var(--ease); }
.diffs > div::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--ink);
  transform-origin: left;
  transition: background 0.3s ease;
}
.diffs > div:hover { transform: translateY(-4px); }
.diffs > div:hover::before { background: var(--signal); }
.diffs > div:hover b { color: var(--signal); }
.diffs b { transition: color 0.3s ease; }
.inds li { transition: transform 0.25s var(--ease), border-color 0.25s ease, background 0.25s ease, color 0.25s ease; }
.inds li:hover { transform: translateY(-2px); border-color: var(--signal); background: var(--signal-soft); }

/* AI rules. */
.ai-grid > div { transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), border-top-width 0.3s ease; }
.ai-grid > div:hover { transform: translateY(-4px); box-shadow: 0 18px 34px -24px rgba(0, 0, 0, 0.5); }

/* Projects. */
.factors > div { transition: background 0.3s ease; }
.factors > div:hover { background: color-mix(in srgb, var(--signal) 6%, var(--paper)); }
.boutique { transition: transform 0.3s var(--ease); }
.boutique li::before { transition: transform 0.4s var(--ease); }

/* FAQ: the plus turns into a cross. */
.faq summary { transition: color 0.2s ease, padding-left 0.3s var(--ease); }
.faq summary:hover { color: var(--signal); padding-left: 0.35rem; }
.faq summary::after { transition: transform 0.35s var(--ease); }
.faq details[open] summary::after { content: "+"; transform: rotate(45deg); }
.faq details p { overflow: hidden; }

/* Contact. */
.cform { transition: box-shadow 0.3s ease; }
.cform:focus-within { box-shadow: 0 20px 40px -30px color-mix(in srgb, var(--signal) 90%, transparent); }
.cform input[type=text], .cform input[type=email], .cform textarea { transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.cform input[type=text]:focus, .cform input[type=email]:focus, .cform textarea:focus {
  outline: none;
  border-color: var(--signal);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--signal) 22%, transparent);
}

/* Footer. */
.site-foot nav a { text-decoration: none; background: linear-gradient(currentColor, currentColor) left bottom / 0 1px no-repeat; transition: background-size 0.3s var(--ease), color 0.2s ease; }
.site-foot nav a:hover { color: var(--ink); background-size: 100% 1px; }

/* Hero rabbit: tilts toward the pointer (enhance.js). */
.hero-rabbit { transform-style: preserve-3d; transition: transform 0.5s var(--ease), box-shadow 0.5s var(--ease); will-change: transform; }
.hero-rabbit:hover { box-shadow: 0 40px 60px -40px rgba(0, 0, 0, 0.6); }

/* ===========================================================================
   5. MOTION - entrances, only under html.al-motion
   =========================================================================== */

@keyframes al-rise { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: none; } }
@keyframes al-clip { from { opacity: 0; transform: translateY(40%); clip-path: inset(0 0 100% 0); } to { opacity: 1; transform: none; clip-path: inset(0 0 -20% 0); } }
@keyframes al-pop { from { opacity: 0; transform: scale(0.94) translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes al-float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -8px; } }
@keyframes al-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes al-drop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* The hero plays on arrival. "backwards", not "both": a finished animation
   that holds its last frame overrides inline styles, which would freeze the
   rabbit's tilt and leave the headline's clip-path cutting its edges. */
.al-motion .hero h1 { animation: al-clip 1s var(--ease) 0.05s backwards; }
.al-motion .hero .lede { animation: al-rise 0.9s var(--ease) 0.25s backwards; }
.al-motion .hero-ctas { animation: al-rise 0.9s var(--ease) 0.4s backwards; }
.al-motion .hero-rabbit { animation: al-pop 1.1s var(--ease) 0.3s backwards; }
.al-motion .hero-rabbit img { animation: al-float 6s ease-in-out 1.4s infinite; }
.al-motion .site-head .wrap > * { animation: al-drop 0.6s var(--ease) both; }

/* Everything else plays as it scrolls into view: hidden until enhance.js
   adds .al-in. The selector list is repeated in enhance.js (REVEAL). */
.al-motion .block > .wrap > h2,
.al-motion .block > .wrap > .lede,
.al-motion .stats li,
.al-motion .src,
.al-motion .risks h3,
.al-motion .risk-grid > div,
.al-motion .svc article,
.al-motion .plats:not(.factors) > div,
.al-motion .steps li,
.al-motion .sub h3,
.al-motion .diffs > div,
.al-motion .inds li,
.al-motion .ai-grid > div,
.al-motion .proj h3,
.al-motion .factors > div,
.al-motion .boutique,
.al-motion .faq details,
.al-motion .contact > div,
.al-motion .cform {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.75s var(--ease) var(--d, 0s), transform 0.75s var(--ease) var(--d, 0s);
}
.al-motion .al-in { opacity: 1 !important; transform: none !important; }
/* Hover lifts take over once an element has arrived. */
.al-motion .diffs > div.al-in:hover,
.al-motion .ai-grid > div.al-in:hover { transform: translateY(-4px) !important; transition-delay: 0s; }
.al-motion .risk-grid > div.al-in:hover { transform: translateX(4px) !important; transition-delay: 0s; }
.al-motion .inds li.al-in:hover { transform: translateY(-2px) !important; transition-delay: 0s; }

.al-motion .stats li::before,
.al-motion .diffs > div::before { transform: scaleX(0); transition: transform 1s var(--ease) calc(var(--d, 0s) + 0.15s); }
.al-motion .stats li.al-in::before,
.al-motion .diffs > div.al-in::before { transform: scaleX(1); }

/* How we work: each step fills and draws its line to the next, in turn. */
.al-motion .steps li::before { background: transparent; }
.al-motion .steps li.al-in::before { background: var(--signal); color: var(--bg); transition-delay: calc(var(--d, 0s) + 0.2s), calc(var(--d, 0s) + 0.2s), 0s; }
.al-motion .steps li::after { transform: scaleX(0); transition: transform 0.7s var(--ease) calc(var(--d, 0s) + 0.35s); }
.al-motion .steps li.al-in::after { transform: scaleX(1); }

.al-motion .boutique li::before { transform: scale(0); transition-delay: 0.1s; }
.al-motion .boutique.al-in li:nth-child(1)::before { transform: scale(1); transition-delay: 0.3s; }
.al-motion .boutique.al-in li:nth-child(2)::before { transform: scale(1); transition-delay: 0.45s; }
.al-motion .boutique.al-in li:nth-child(3)::before { transform: scale(1); transition-delay: 0.6s; }
.al-motion .boutique.al-in li:nth-child(4)::before { transform: scale(1); transition-delay: 0.75s; }

.al-motion .menu-panel:not([hidden]) a { animation: al-rise 0.45s var(--ease) both; }
.al-motion .menu-panel:not([hidden]) a:nth-child(2) { animation-delay: 0.03s; }
.al-motion .menu-panel:not([hidden]) a:nth-child(3) { animation-delay: 0.06s; }
.al-motion .menu-panel:not([hidden]) a:nth-child(4) { animation-delay: 0.09s; }
.al-motion .menu-panel:not([hidden]) a:nth-child(5) { animation-delay: 0.12s; }
.al-motion .menu-panel:not([hidden]) a:nth-child(6) { animation-delay: 0.15s; }
.al-motion .menu-panel:not([hidden]) a:nth-child(n+7) { animation-delay: 0.18s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
