/*
 * Archiva — Design System & Custom Styles
 * ========================================
 * Design tokens mirror the Tailwind theme config so both CSS
 * custom properties and Tailwind utilities share the same values.
 */

/* ─── Design Tokens ────────────────────────────────────────────── */
:root {
  /* Color palette */
  --color-primary:                  #06402b;
  --color-primary-fixed:            #b8efd0;
  --color-primary-fixed-dim:        #9cd2b5;
  --color-on-primary:               #ffffff;
  --color-on-primary-container:     #ffffff;
  --color-on-primary-fixed:         #002114;
  --color-on-primary-fixed-variant: #1b503a;
  --color-inverse-primary:          #356850;

  --color-secondary:                #4f6354;
  --color-secondary-container:      #d2e8d9;
  --color-secondary-fixed:          #d2e8d9;
  --color-secondary-fixed-dim:      #b6ccbe;
  --color-on-secondary:             #ffffff;
  --color-on-secondary-container:   #3a4d43;
  --color-on-secondary-fixed:       #0c1f16;
  --color-on-secondary-fixed-variant: #384b40;

  --color-tertiary:                 #8b6a24;
  --color-tertiary-fixed:           #ffdea5;
  --color-tertiary-fixed-dim:       #e9c176;
  --color-tertiary-container:       #4a3400;
  --color-on-tertiary:              #ffffff;
  --color-on-tertiary-container:    #ffffff;
  --color-on-tertiary-fixed:        #261900;
  --color-on-tertiary-fixed-variant: #5d4201;

  --color-surface:                  #fdfdfd;
  --color-surface-dim:              #f8faf9;
  --color-surface-bright:           #f8faf9;
  --color-surface-container:        #f1f4f2;
  --color-surface-container-low:    #f7f9f7;
  --color-surface-container-lowest: #ffffff;
  --color-surface-container-high:   #e7ebe8;
  --color-surface-container-highest: #e1e3df;
  --color-surface-variant:          #dee5df;
  --color-surface-tint:             #356850;
  --color-on-surface:               #191c1a;
  --color-on-surface-variant:       #404943;
  --color-inverse-surface:          #2e312f;
  --color-inverse-on-surface:       #f1f4f2;

  --color-background:               #fdfdfd;
  --color-on-background:            #191c1a;

  --color-outline:                  #707973;
  --color-outline-variant:          #c0c9c1;

  --color-error:                    #ba1a1a;
  --color-on-error:                 #ffffff;
  --color-on-error-container:       #410002;

  /* Typography */
  --font-headline: 'Manrope', sans-serif;
  --font-body:     'Inter', sans-serif;

  /* Type scale */
  --text-display:  clamp(2.5rem, 6vw, 4.5rem);
  --text-h1:       clamp(2rem, 5vw, 3.5rem);
  --text-h2:       clamp(1.75rem, 3.5vw, 3rem);
  --text-h3:       1.5rem;
  --text-h4:       1.125rem;
  --text-body-lg:  1.125rem;
  --text-body:     1rem;
  --text-body-sm:  0.875rem;
  --text-caption:  0.75rem;
  --text-label:    0.625rem;

  /* Spacing scale (multiples of 4px) */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Border radius */
  --radius-xs:   0.125rem;
  --radius-sm:   0.25rem;
  --radius-md:   0.5rem;
  --radius-lg:   0.75rem;
  --radius-full: 9999px;

  /* Elevation / shadows */
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.08), 0 1px 2px -1px rgb(0 0 0 / 0.06);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.05);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.04);
  --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.18);
}

/* ─── Base & Resets ─────────────────────────────────────────────── */
html {
  scroll-behavior: smooth;
  overflow-x: clip;
}

body {
  overflow-x: clip;
  max-width: 100%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

/* ─── Animations ────────────────────────────────────────────────── */
@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

@keyframes hero-cube-float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

/* Scroll-triggered reveal: visible by default; JS hides then reveals on scroll */
.scroll-animate {
  opacity: 1;
}

.js .scroll-animate {
  opacity: 0;
}

.js .scroll-animate.in-view {
  animation: fade-in-up 0.7s ease-out forwards;
}

/* Hero content animates on page load without waiting for scroll */
.hero-animate {
  animation: fade-in-up 0.9s ease-out forwards;
}

/* ─── Utility Components ────────────────────────────────────────── */
.glass-panel {
  background: rgb(255 255 255 / 0.72);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

/* ─── Material Symbols ──────────────────────────────────────────── */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24;
  /* Prevent icon text from being selectable */
  user-select: none;
}

/* ─── Navigation ────────────────────────────────────────────────── */
#mobile-menu {
  /* Smooth height collapse */
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#mobile-menu.hidden {
  display: none;
}

/* ─── Pricing card scale fix on mobile ─────────────────────────── */
/* The recommended card uses lg:scale-105 which is fine on desktop
   but on mobile it clips. Reset to normal scale below lg. */
@media (max-width: 1023px) {
  .pricing-featured {
    transform: none !important;
  }
}

/* ─── Form focus styles ─────────────────────────────────────────── */
input:focus,
select:focus,
textarea:focus {
  outline: none;
}

/* Ensure consistent bottom-border focus indicator (Tailwind forms plugin
   resets many defaults; we restore a visible focus ring here). */
.form-field:focus-visible {
  border-bottom-color: var(--color-primary);
  box-shadow: 0 2px 0 0 var(--color-primary);
}

/* ─── Accessibility ─────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Skip-to-content helper (used if added in HTML) */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: 9999;
  background: var(--color-primary);
  color: var(--color-on-primary);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-family: var(--font-headline);
  font-size: var(--text-body-sm);
  font-weight: 700;
  text-decoration: none;
  transition: top 0.1s;
}

.skip-link:focus {
  top: var(--space-4);
}

/* ─── Hero SVG background ───────────────────────────────────────── */

/*
 * The isometric cube grid SVG (viewBox 2000×900) is inlined in hero.njk.
 * Each cube is a grouped <g> so CSS can animate faces and JS can react to
 * cursor position on desktop. mask-image fades all four edges.
 */
.hero-bg-image {
  overflow: hidden;
  pointer-events: none;
}

.hero-bg-parallax {
  width: 100%;
  height: 100%;
  will-change: transform;
}

.hero-bg-svg {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0.28;
  pointer-events: none;
  user-select: none;

  /* ── All-sides fade mask ──────────────────────────────────────── */
  -webkit-mask-image:
    linear-gradient(to right,  transparent 0%,  black 22%, black 78%, transparent 100%),
    linear-gradient(to bottom, transparent 0%,  black 12%, black 72%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(to right,  transparent 0%,  black 22%, black 78%, transparent 100%),
    linear-gradient(to bottom, transparent 0%,  black 12%, black 72%, transparent 100%);
  mask-composite: intersect;
}

.hero-cube {
  transform: translateY(var(--cube-lift, 0px));
  transition: transform 0.35s ease-out, filter 0.35s ease-out;
  will-change: transform;
}

.hero-cube.is-near {
  filter: brightness(1.12);
}

.hero-cube-float {
  transform-origin: center center;
  animation: hero-cube-float var(--cube-duration, 4s) ease-in-out infinite;
  animation-delay: var(--cube-delay, 0s);
}

@media (prefers-reduced-motion: reduce) {
  .hero-bg-parallax {
    transform: none !important;
  }

  .hero-cube {
    transform: none;
    transition: none;
  }

  .hero-cube.is-near {
    filter: none;
  }

  .hero-cube-float {
    animation: none;
  }
}

/* ─── Responsive helpers ────────────────────────────────────────── */
@media (max-width: 1023px) {
  .hero-bg-svg {
    opacity: 0.24;
  }
}

@media (max-width: 767px) {
  .hero-bg-parallax {
    transform: scale(1.08);
    transform-origin: 62% 40%;
  }

  .hero-bg-svg {
    opacity: 0.2;

    -webkit-mask-image:
      linear-gradient(to right,  transparent 0%,  black 18%, black 82%, transparent 100%),
      linear-gradient(to bottom, transparent 0%,  black 10%, black 78%, transparent 100%);
    mask-image:
      linear-gradient(to right,  transparent 0%,  black 18%, black 82%, transparent 100%),
      linear-gradient(to bottom, transparent 0%,  black 10%, black 78%, transparent 100%);
  }
}

@media (max-width: 479px) {
  .hero-bg-parallax {
    transform: scale(1.15);
    transform-origin: 68% 42%;
  }

  .hero-bg-svg {
    opacity: 0.16;
  }
}

/* Security diagram: pyramid steps — base (offset-3) widest, top (offset-0) narrowest */
.security-layers-grid {
  grid-template-rows: repeat(4, minmax(0, 1fr));
}

/* Flat stack until the diagram sits in the side column (lg+) */
.security-layer-offset-0,
.security-layer-offset-1,
.security-layer-offset-2,
.security-layer-offset-3 {
  margin-inline: 0;
  width: 100%;
  max-width: 100%;
}

@media (min-width: 1024px) {
  .security-layer-offset-0,
  .security-layer-offset-1,
  .security-layer-offset-2,
  .security-layer-offset-3 {
    width: auto;
    max-width: none;
  }

  .security-layer-offset-0 { margin-left: 4.5rem; }
  .security-layer-offset-1 { margin-left: 3rem; }
  .security-layer-offset-2 { margin-left: 1.5rem; }
  .security-layer-offset-3 { margin-left: 0; }
}

@media (min-width: 1280px) {
  .security-layer-offset-0 { margin-left: 6rem; }
  .security-layer-offset-1 { margin-left: 4rem; }
  .security-layer-offset-2 { margin-left: 2rem; }
}

.security-layer-glow {
  background: linear-gradient(
    90deg,
    var(--color-primary),
    var(--color-primary-fixed-dim)
  );
  opacity: 0;
  transition: opacity 0.45s ease;
}

.security-layer-icon {
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
  color: var(--color-primary);
  transition:
    background-color 0.35s ease,
    color 0.35s ease,
    transform 0.35s ease;
}

.security-layer-card {
  transition:
    border-color 0.35s ease,
    box-shadow 0.35s ease;
}

.security-layer:hover .security-layer-glow,
.security-layer:focus-within .security-layer-glow {
  opacity: 0.28;
}

.security-layer:hover .security-layer-card,
.security-layer:focus-within .security-layer-card {
  border-color: color-mix(in srgb, var(--color-primary) 35%, transparent);
  box-shadow:
    0 4px 24px color-mix(in srgb, var(--color-primary) 12%, transparent),
    0 1px 3px rgb(0 0 0 / 0.04);
}

.security-layer:hover .security-layer-icon,
.security-layer:focus-within .security-layer-icon {
  background: var(--color-primary);
  color: var(--color-on-primary);
  transform: scale(1.05);
}

@keyframes security-layer-pulse {
  0%, 100% {
    opacity: 0;
  }
  45% {
    opacity: 0.22;
  }
}

.js .scroll-animate.in-view .security-layer-glow {
  animation: security-layer-pulse 5s ease-in-out infinite;
  animation-delay: calc(var(--layer-index) * 1.1s);
}

/* ─── Workflow pipeline ─────────────────────────────────────────── */

.workflow-pipeline {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  max-width: 72rem;
  margin-inline: auto;
}

.workflow-connector {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 0 0 auto;
  padding: 0.75rem 0;
}

.workflow-link {
  flex-shrink: 0;
  overflow: visible;
}

.workflow-link--h {
  display: none;
  width: 5.5rem;
  height: 1.5rem;
}

.workflow-link--v {
  display: block;
  width: 1.5rem;
  height: 5.5rem;
}

.workflow-link-rail {
  opacity: 0.45;
}

.workflow-link-pulse {
  stroke-dasharray: 20 46;
  animation: workflow-link-march 2.4s ease-in-out infinite;
  animation-delay: var(--connector-delay, 0s);
}

.workflow-link-head {
  opacity: 0.65;
}

.workflow-details {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-top: 3rem;
  padding-top: 2.5rem;
  border-top: 1px solid rgb(192 201 193 / 0.45);
}

.workflow-detail {
  padding: 1.25rem 1.5rem;
  border-radius: 0.75rem;
  background: rgb(255 255 255 / 0.72);
  border: 1px solid rgb(192 201 193 / 0.35);
}

.workflow-detail-title {
  font-family: var(--font-headline);
  font-size: var(--text-body);
  font-weight: 700;
  color: var(--color-primary-container);
  margin-bottom: 0.5rem;
}

.workflow-detail-text {
  font-size: var(--text-body-sm);
  line-height: 1.65;
  color: var(--color-on-surface-variant);
  font-weight: 300;
}

.workflow-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 14rem;
  padding: 1.25rem 1rem 1.5rem;
  border-radius: 1rem;
  background: var(--color-surface-container-lowest);
  border: 1px solid rgb(192 201 193 / 0.45);
  box-shadow: var(--shadow-sm);
  transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
  opacity: 1;
}

.js .scroll-animate .workflow-step {
  opacity: 0;
}

.js .scroll-animate.in-view .workflow-step {
  animation: workflow-step-in 0.65s ease-out forwards;
  animation-delay: var(--workflow-delay, 0s);
}

.workflow-step:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: rgb(6 64 43 / 0.2);
}

.workflow-step--verify {
  border-color: rgb(6 64 43 / 0.28);
  box-shadow:
    var(--shadow-md),
    0 0 0 1px rgb(6 64 43 / 0.06);
}

.workflow-step--verify:hover {
  border-color: rgb(6 64 43 / 0.38);
}

.workflow-step-graphic {
  width: 100%;
  max-width: 9.5rem;
  aspect-ratio: 6 / 7;
  display: flex;
  align-items: center;
  justify-content: center;
}

.workflow-svg {
  width: 100%;
  height: 100%;
}

.workflow-step-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.workflow-step-icon {
  font-size: 1.125rem;
  color: var(--color-primary);
}

.workflow-step-name {
  font-family: var(--font-headline);
  font-size: var(--text-body-sm);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-on-surface);
}

@keyframes workflow-step-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes workflow-link-march {
  0%   { stroke-dashoffset: 68; opacity: 0.35; }
  18%  { opacity: 1; }
  82%  { opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 0.35; }
}

@keyframes workflow-ring-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes workflow-pulse {
  0%, 100% { transform: scale(1); opacity: 0.35; }
  50%       { transform: scale(1.35); opacity: 0.15; }
}

.workflow-compose-ring {
  transform-origin: 60px 118px;
  animation: workflow-ring-spin 8s linear infinite;
}

.workflow-sign-ring {
  transform-origin: 60px 70px;
  animation: workflow-ring-spin 12s linear infinite reverse;
}

.workflow-verify-pulse {
  transform-origin: 60px 118px;
  animation: workflow-pulse 2.5s ease-in-out infinite;
}

@media (max-width: 639px) {
  .workflow-pipeline {
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    flex-wrap: nowrap;
  }

  .workflow-step {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    gap: 0.375rem;
    padding: 0.5rem 0.25rem 0.625rem;
    border-radius: 0.625rem;
  }

  .workflow-step-graphic {
    max-width: 2.75rem;
  }

  .workflow-step-label {
    flex-direction: column;
    gap: 0.125rem;
    text-align: center;
  }

  .workflow-step-icon {
    font-size: 0.875rem;
  }

  .workflow-step-name {
    font-size: var(--text-label);
    letter-spacing: 0.03em;
    line-height: 1.2;
  }

  .workflow-connector {
    align-self: center;
    padding: 0;
  }

  .workflow-link--h {
    display: block;
    width: 0.625rem;
    height: 0.75rem;
  }

  .workflow-link--v {
    display: none;
  }

  .workflow-details {
    margin-top: 1.75rem;
    padding-top: 1.5rem;
    gap: 0.75rem;
  }

  .workflow-detail {
    padding: 0.875rem 1rem;
  }

  .workflow-detail-title {
    font-size: var(--text-body-sm);
    margin-bottom: 0.25rem;
  }

  .workflow-detail-text {
    font-size: var(--text-caption);
    line-height: 1.5;
  }
}

@media (min-width: 640px) {
  .workflow-details {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 3.5rem;
  }

  .workflow-pipeline {
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    flex-wrap: nowrap;
  }

  .workflow-step {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
  }

  .workflow-connector {
    align-self: center;
    padding: 0 0.25rem;
  }

  .workflow-link--h {
    display: block;
    width: 4.5rem;
    height: 1.5rem;
  }

  .workflow-link--v {
    display: none;
  }
}

@media (min-width: 1024px) {
  .workflow-details {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1.25rem;
    margin-top: 4rem;
  }

  .workflow-detail-text {
    font-size: var(--text-body);
  }

  .workflow-step-graphic {
    max-width: 11rem;
  }

  .workflow-step-name {
    font-size: var(--text-body);
  }

  .workflow-link--h {
    width: 5.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .js .scroll-animate {
    opacity: 1;
  }

  .js .scroll-animate.in-view {
    animation: none;
  }

  .js .scroll-animate .workflow-step,
  .workflow-step {
    opacity: 1;
  }

  .js .scroll-animate.in-view .workflow-step {
    animation: none;
  }

  .workflow-compose-ring,
  .workflow-sign-ring,
  .workflow-verify-pulse {
    animation: none;
  }

  .workflow-link-pulse {
    animation: none;
    stroke-dashoffset: 0;
    opacity: 0.65;
  }

  .js .scroll-animate.in-view .security-layer-glow {
    animation: none;
  }

  .security-layer:hover .security-layer-icon,
  .security-layer:focus-within .security-layer-icon {
    transform: none;
  }
}
