/* Pehmeä sivun sisääntulo — sivu alkaa näkymättömänä ja häipyy esiin (ei välähdystä) */
body {
  animation: pageFadeIn 0.45s ease both;
}
@keyframes pageFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Yhteydenoton onnistumisanimaatio (vesipisara → väreily → check) */
#form-success .sa-circle { transform-box: view-box; transform-origin: 60px 62px; animation: saPop 0.5s cubic-bezier(0.22, 1.2, 0.36, 1) both; }
@keyframes saPop { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#form-success .sa-drop { transform-box: view-box; transform-origin: 60px 46px; animation: saDrop 0.75s cubic-bezier(0.5, 0, 0.6, 1) 0.35s both; }
@keyframes saDrop { 0% { transform: translateY(-42px); opacity: 0; } 55% { opacity: 1; } 100% { transform: translateY(0); opacity: 0; } }
#form-success .sa-ripple { transform-box: view-box; transform-origin: 60px 66px; opacity: 0; animation: saRipple 0.85s ease-out 1s both; }
@keyframes saRipple { 0% { transform: scale(0.2); opacity: 0.7; } 100% { transform: scale(1.7); opacity: 0; } }
#form-success .sa-check { stroke-dasharray: 64; stroke-dashoffset: 64; animation: saCheck 0.5s ease-out 1.2s forwards; }
@keyframes saCheck { to { stroke-dashoffset: 0; } }
#form-success .sa-text > * { animation: saTextIn 0.55s ease-out both; }
#form-success .sa-text > *:nth-child(1) { animation-delay: 1.25s; }
#form-success .sa-text > *:nth-child(2) { animation-delay: 1.4s; }
@keyframes saTextIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

:root {
  --color-bg: #ffffff;
  --color-bg-soft: #f0f9ff;   /* sky-50 */
  --color-bg-muted: #f8fafc;  /* slate-50 */
  --color-ink: #0f172a;       /* slate-900 */
  --color-body: #475569;      /* slate-600 */
  --color-accent: #0284c7;    /* sky-600 */
  --color-accent-bright: #0ea5e9; /* sky-500 */
}

html {
  scroll-behavior: smooth;
  overflow-x: clip;            /* prevent horizontal scroll / zoom-out without breaking sticky */
}

body {
  background-color: var(--color-bg);
  overflow-x: clip;
  max-width: 100%;
}

img, video, iframe, table {
  max-width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  /* Hero-sisääntulo näytetään myös reduced motion -tilassa (toivottu efekti) */
  .hero-video { animation-duration: 1.8s !important; }
  .hero-overlay { animation-duration: 1.8s !important; }
  .hero-copy > * { animation-duration: 0.9s !important; }
  /* Sivun sisääntulohäivytys myös reduced motion -tilassa */
  body { animation-duration: 0.45s !important; }
  /* Sisällön reveal-sisääntulo näytetään myös reduced motion -tilassa (toivottu efekti) */
  .reveal { transition-duration: 0.8s !important; }
  .reveal-scale { transition-duration: 1.1s !important; }
  /* Yhteydenoton onnistumisanimaatio myös reduced motion -tilassa */
  #form-success .sa-circle { animation-duration: 0.5s !important; }
  #form-success .sa-drop { animation-duration: 0.75s !important; }
  #form-success .sa-ripple { animation-duration: 0.85s !important; }
  #form-success .sa-check { animation-duration: 0.5s !important; }
  #form-success .sa-text > * { animation-duration: 0.55s !important; }
}

/* Reveal-on-scroll */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, opacity;
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }

/* Scale-in reveal for imagery */
.reveal-scale {
  opacity: 0;
  transform: scale(1.06);
  transition: opacity 1s ease, transform 1.2s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, opacity;
}
.reveal-scale.is-visible {
  opacity: 1;
  transform: scale(1);
}

.parallax-layer {
  will-change: transform;
}

/* Glass surface for floating nav — light translucent */
.glass {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
}

/* Site header: transparent on arrival, solid white bar once you scroll */
#site-header {
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: background-color 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
}
#site-header.glass {
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
}
/* Over a dark hero (front page): white nav text while transparent */
/* White text only in the top bar (.max-w-7xl), never in the mobile dropdown menu */
#site-header.over-hero:not(.glass) .max-w-7xl nav a,
#site-header.over-hero:not(.glass) .max-w-7xl a[href^="tel"],
#site-header.over-hero:not(.glass) #menu-btn {
  color: #ffffff;
  text-shadow: 0 1px 10px rgba(8, 22, 40, 0.45);
}
#site-header.over-hero:not(.glass) .max-w-7xl .font-sans .text-slate-900 { color: #ffffff; }
#site-header.over-hero:not(.glass) .max-w-7xl .font-sans .text-sky-500 { color: #bae6fd; }
#site-header.over-hero:not(.glass) .max-w-7xl .nav-link::after { background: #ffffff; }
/* Musta logo pysyy luettavana hero-videon päällä (vaalea hehku) */
#site-header.over-hero:not(.glass) .site-logo {
  filter: drop-shadow(0 1px 8px rgba(255, 255, 255, 0.7));
}

/* Hero: sulava sisääntulo sivun latautuessa */
.hero-video {
  animation: heroVideoIn 1.8s cubic-bezier(0.22, 1, 0.36, 1) both;
  will-change: transform, opacity;
}
@keyframes heroVideoIn {
  from { opacity: 0; transform: scale(1.09); }
  to   { opacity: 1; transform: scale(1); }
}
.hero-overlay {
  animation: heroFadeIn 1.8s ease-out both;
}
@keyframes heroFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
/* Hero-tekstien porrastettu nousu */
.hero-copy > * {
  animation: heroCopyIn 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.hero-copy > *:nth-child(2) { animation-delay: 0.45s; }
.hero-copy > *:nth-child(3) { animation-delay: 0.6s; }
.hero-copy > *:nth-child(4) { animation-delay: 0.75s; }
@keyframes heroCopyIn {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Hero soft glow */
.hero-glow {
  background:
    radial-gradient(circle at 75% 25%, rgba(14, 165, 233, 0.12), transparent 55%),
    radial-gradient(circle at 15% 80%, rgba(2, 132, 199, 0.08), transparent 50%);
}

/* Floating drip / glow */
@keyframes floatY {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.float-anim {
  animation: floatY 7s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .float-anim { animation: none; }
}

.counter {
  font-variant-numeric: tabular-nums;
}

/* Marquee for service areas */
.marquee-track {
  animation: marquee 32s linear infinite;
}
@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  .marquee-track { animation: none; }
}

/* Animated underline on nav links */
.nav-link {
  position: relative;
}
.nav-link::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 0;
  height: 2px;
  background: var(--color-accent);
  transition: width 0.25s ease;
}
.nav-link:hover::after {
  width: 100%;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

#mobile-menu {
  transition: max-height 0.35s ease, opacity 0.35s ease;
}

/* Stylish service cards */
.service-card {
  position: relative;
  background: #ffffff;
  border: 1px solid #e2e8f0;            /* slate-200 */
  border-radius: 1rem;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}
.service-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, #0ea5e9, #38bdf8);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s ease;
}
.service-card:hover {
  transform: translateY(-6px);
  border-color: #bae6fd;                /* sky-200 */
  box-shadow: 0 22px 45px -18px rgba(2, 132, 199, 0.35);
}
.service-card:hover::before { transform: scaleX(1); }

.service-icon {
  background: linear-gradient(135deg, #e0f2fe, #bae6fd);
  color: #0284c7;
  transition: transform 0.3s ease, background 0.3s ease, color 0.3s ease;
}
.service-card:hover .service-icon {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: #ffffff;
  transform: scale(1.08);
}

/* Stacked service deck — collapses to a pile, opens into a side-by-side grid */
.stack {
  position: relative;
  max-width: 36rem;
  margin: 0 auto;
  transition: max-width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.stack[data-collapsed] { height: 350px; cursor: pointer; }

.stack-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(238, 247, 255, 0.6);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 1.4rem;
  padding: 1.4rem;
  box-shadow: 0 20px 45px -22px rgba(2, 132, 199, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.65);
  transform-origin: top center;
}

/* Constant stacking order so opening never flips z-index */
.stack-card:nth-child(1) { z-index: 6; }
.stack-card:nth-child(2) { z-index: 5; }
.stack-card:nth-child(3) { z-index: 4; }
.stack-card:nth-child(4) { z-index: 3; }
.stack-card:nth-child(5) { z-index: 2; }
.stack-card:nth-child(6) { z-index: 1; }

/* Collapsed: pile the cards on top of each other */
.stack[data-collapsed] .stack-card {
  position: absolute;
  left: 0; right: 0;
  height: 300px;
  pointer-events: none;
  transition: top 0.9s cubic-bezier(0.22, 1, 0.36, 1), transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.stack[data-collapsed] .stack-card:nth-child(1) { top: 0;    transform: scale(1); }
.stack[data-collapsed] .stack-card:nth-child(2) { top: 10px; transform: scale(0.97); }
.stack[data-collapsed] .stack-card:nth-child(3) { top: 20px; transform: scale(0.94); }
.stack[data-collapsed] .stack-card:nth-child(4) { top: 30px; transform: scale(0.91); }
.stack[data-collapsed] .stack-card:nth-child(5) { top: 40px; transform: scale(0.88); opacity: 0.9; }
.stack[data-collapsed] .stack-card:nth-child(6) { top: 50px; transform: scale(0.85); opacity: 0.8; }

/* Open: spread into a side-by-side grid */
.stack.is-open {
  max-width: 66rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}
@media (min-width: 1024px) {
  .stack.is-open { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.stack.is-open .stack-card {
  position: static;
  height: auto;
  min-height: 300px;
  pointer-events: auto;
  animation: cardIn 0.7s cubic-bezier(0.16, 1, 0.3, 1) backwards;
  transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
}
/* Hover lift + image zoom (same feel as the Palvelut cards) */
.stack.is-open .stack-card:hover {
  transform: translateY(-6px);
  border-color: #bae6fd;
  box-shadow: 0 28px 55px -22px rgba(2, 132, 199, 0.5);
}
.stack-card img { transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1); }
.stack.is-open .stack-card:hover img { transform: scale(1.06); }
.stack.is-open .stack-card:nth-child(1) { animation-delay: 0.04s; }
.stack.is-open .stack-card:nth-child(2) { animation-delay: 0.10s; }
.stack.is-open .stack-card:nth-child(3) { animation-delay: 0.16s; }
.stack.is-open .stack-card:nth-child(4) { animation-delay: 0.22s; }
.stack.is-open .stack-card:nth-child(5) { animation-delay: 0.28s; }
.stack.is-open .stack-card:nth-child(6) { animation-delay: 0.34s; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(22px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}

.stack-collapse { display: none; }
.stack.is-open .stack-collapse {
  display: inline-flex;
  grid-column: 1 / -1;
  justify-self: center;
  margin-top: 0.5rem;
}

/* Click-to-reveal services (legacy, unused) */
#services-grid[data-collapsed] { display: none; }
.svc-item {
  opacity: 0;
  transform: translateY(26px) scale(0.98);
  transition: opacity 0.55s cubic-bezier(0.16, 1, 0.3, 1), transform 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}
#services-grid.is-open .svc-item { opacity: 1; transform: none; }
#services-grid.is-open .svc-item:nth-child(1) { transition-delay: 0.04s; }
#services-grid.is-open .svc-item:nth-child(2) { transition-delay: 0.10s; }
#services-grid.is-open .svc-item:nth-child(3) { transition-delay: 0.16s; }
#services-grid.is-open .svc-item:nth-child(4) { transition-delay: 0.22s; }
#services-grid.is-open .svc-item:nth-child(5) { transition-delay: 0.28s; }
#services-grid.is-open .svc-item:nth-child(6) { transition-delay: 0.34s; }
[data-toggle-icon] { transition: transform 0.3s ease; }
#services-toggle[aria-expanded="true"] [data-toggle-icon] { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) {
  .svc-item { opacity: 1; transform: none; }
}

/* Scroll-expand hero media */
.se-section {
  position: relative;
  height: 240vh;            /* scroll room that drives the expand */
}
.se-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0b1622;
}
.se-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  will-change: opacity;
}
.se-bg-tint {
  position: absolute;
  inset: 0;
  background: rgba(8, 22, 40, 0.35);
}
.se-media {
  position: relative;
  border-radius: 1.25rem;
  overflow: hidden;
  box-shadow: 0 30px 70px rgba(8, 22, 40, 0.35);
  max-width: 100vw;
  max-height: 100vh;
  will-change: width, height;
}
.se-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.se-title {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  pointer-events: none;
  z-index: 10;
  text-align: center;
  will-change: transform;
}
.se-hint {
  position: absolute;
  left: 50%;
  bottom: 8vh;
  transform: translateX(-50%);
  z-index: 10;
  pointer-events: none;
}
/* Wordmark that appears mid-scroll, anchored top-left below the floating navbar */
.se-wordmark {
  position: absolute;
  top: 6.25rem;
  left: 0;
  right: 0;
  z-index: 10;
  pointer-events: none;
  will-change: opacity;
}
@media (min-width: 640px) {
  .se-wordmark { top: 7rem; }
}
