/* ============================================
   CactusPaper Style System — Namespaced cp-
   ============================================ */

:root {
  /* Color tokens */
  --cp-primary: #9bbf7c;       /* cactus green (primary accent) */
  --cp-primary-dark: #6a8a55;
  --cp-surface: #f8f7f2;       /* paper-like light surface */
  --cp-surface-deep: #e7e5da;
  --cp-ink: #1c1c1c;           /* dark text */
  --cp-muted: #8a8a8a;
  --cp-edge: rgba(0,0,0,0.12); /* subtle border */
  --cp-edge-strong: rgba(0,0,0,0.22);

  /* Motion tokens */
  --cp-motion-fast: 150ms;
  --cp-motion-med: 260ms;
  --cp-motion-slow: 420ms;
  --cp-easing: cubic-bezier(.22,.61,.36,1);

  /* Radius & shadows */
  --cp-radius-sm: 6px;
  --cp-radius-md: 12px;
  --cp-radius-lg: 18px;
  --cp-shadow-soft: 0 4px 10px rgba(0,0,0,0.08);
  --cp-shadow-paper: 0 2px 6px rgba(0,0,0,0.04), 0 1px 4px rgba(0,0,0,0.06);

  /* Typography */
  --cp-font-body: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;

  /* Container */
  --cp-max-width: 72rem;
  --cp-space-lg: 3rem;
  --cp-space-md: 2rem;
  --cp-space-sm: 1rem;
}

/* ======================================================
   Global resets & base
   ====================================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  background: var(--cp-surface);
  color: var(--cp-ink);
  font-family: var(--cp-font-body);
  line-height: 1.65;
}

body {
  overflow-x: hidden;
  position: relative;
}

/* Ultra subtle moving background wash */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(120% 70% at 80% 10%, rgba(0,0,0,0.04), transparent 60%),
    url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='320' viewBox='0 0 320 320'><rect width='320' height='320' fill='white'/><path d='M0 0H320V320H0z' fill='none' stroke='rgba(0,0,0,0.04)' stroke-width='0.6'/></svg>");
  opacity: .42;
  animation: cp-wash 24s ease-in-out infinite alternate;
}

@keyframes cp-wash {
  0% { transform: translate3d(0,0,0) scale(1); }
  100% { transform: translate3d(0,-2%,0) scale(1.02); }
}

/* ======================================================
   Layout container
   ====================================================== */

.cp-shell {
  width: 100%;
  max-width: var(--cp-max-width);
  margin: 0 auto;
  padding: var(--cp-space-lg) var(--cp-space-sm);
}

/* ======================================================
   Header & Navigation
   ====================================================== */

.cp-header {
  margin-bottom: var(--cp-space-lg);
}

.cp-header-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--cp-space-md);
}

.cp-logo {
  width: 145px;
  height: auto;
  display: block;
}

.cp-nav-list {
  list-style: none;
  display: flex;
  gap: 1.8rem;
}

.cp-nav-link {
  text-decoration: none;
  font-weight: 600;
  color: var(--cp-ink);
  padding: .4rem .9rem;
  border-radius: var(--cp-radius-md);
  position: relative;
  transition: background var(--cp-motion-fast) var(--cp-easing);
}

/* link underline grow */
.cp-nav a,
.cp-link {
  position: relative;
  text-decoration: none;
}

.cp-nav a::after,
.cp-link::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  bottom: -2px;
  height: 2px;
  background: linear-gradient(90deg, var(--cp-primary), transparent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--cp-motion-med) var(--cp-easing);
}

.cp-nav a:hover::after,
.cp-link:hover::after {
  transform: scaleX(1);
}

.cp-nav-link--active {
  color: var(--cp-primary-dark);
}

.cp-nav-link--active::after {
  transform: scaleX(1);
}

/* ======================================================
   Titles & spacing
   ====================================================== */

.cp-title {
  font-size: 2.3rem;
  margin-bottom: var(--cp-space-sm);
  line-height: 1.25;
}

.cp-dek {
  font-size: 1.1rem;
  color: var(--cp-muted);
  margin-bottom: var(--cp-space-md);
}

/* Force paragraph justification — required */
article p,
section p,
main p,
p {
  text-align: justify !important;
  text-justify: inter-word !important;
  -webkit-hyphens: auto !important;
  -ms-hyphens: auto !important;
  hyphens: auto !important;
}

/* ======================================================
   Sections
   ====================================================== */

.cp-section {
  margin: var(--cp-space-lg) 0;
  padding-bottom: var(--cp-space-md);
  border-bottom: 1px dotted var(--cp-edge);
  position: relative;
}

/* Section capsule reveal line */
.cp-section::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, var(--cp-primary), transparent);
  transition: width var(--cp-motion-slow) var(--cp-easing);
}

.cp-section.is-seen::before {
  width: 100%;
}

.cp-section-title {
  font-size: 1.6rem;
  margin-bottom: var(--cp-space-sm);
}

/* ======================================================
   Figure styling
   ====================================================== */

.cp-figure {
  margin: var(--cp-space-md) 0 var(--cp-space-lg) 0;
  padding: var(--cp-space-sm);
  background: var(--cp-surface-deep);
  border-radius: var(--cp-radius-lg);
  box-shadow: var(--cp-shadow-paper);
  border: 1px solid var(--cp-edge);
}

.cp-figure-img {
  width: 100%;
  display: block;
  border-radius: var(--cp-radius-md);
}

.cp-figure-caption {
  margin-top: .5rem;
  font-size: .9rem;
  color: var(--cp-muted);
}

/* ======================================================
   Cards
   ====================================================== */

.cp-card {
  border: 1px solid var(--cp-edge);
  border-radius: var(--cp-radius-md);
  padding: var(--cp-space-sm);
  transition:
    transform var(--cp-motion-fast) var(--cp-easing),
    box-shadow var(--cp-motion-fast) var(--cp-easing),
    border-color var(--cp-motion-fast) var(--cp-easing);
}

.cp-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px var(--cp-shadow-soft);
  border-color: var(--cp-edge-strong);
}

/* ======================================================
   Footer — Pebble Curve Shape
   ====================================================== */

.cp-footer {
  margin-top: var(--cp-space-lg);
  display: flex;
  justify-content: center;
}

.cp-footer-inner {
  padding: 1rem 1.8rem;
  background: var(--cp-surface-deep);
  text-align: center;
  color: var(--cp-muted);
  font-size: .95rem;

  /* Pebble Curve Shape (unique) */
  border-radius: 40% 8% 30% 20% / 30% 12% 40% 18%;
  border: 1px solid var(--cp-edge);
  box-shadow:
    inset 0 2px 4px rgba(0,0,0,0.04),
    0 3px 6px rgba(0,0,0,0.05);
}

/* ======================================================
   Reading progress bar
   ====================================================== */

.cp-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--cp-primary), transparent);
  z-index: 9998;
  transition: width var(--cp-motion-fast) linear;
}

/* ======================================================
   Back to Top — Cactus Teardrop Shape
   ====================================================== */

.cp-to-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 58px;
  height: 64px;

  /* Cactus Teardrop Shape (unique) */
  border-radius: 60% 40% 75% 25% / 55% 50% 55% 45%;

  border: 1px solid rgba(255,255,255,0.25);
  background: var(--cp-primary);
  color: #111;
  font: 700 20px/64px var(--cp-font-body);
  text-align: center;
  cursor: pointer;

  opacity: 0 !important;
  transform: translateY(10px) !important;
  pointer-events: none !important;

  transition:
    opacity .25s ease,
    transform .25s ease,
    background .2s ease;
  z-index: 9999 !important;
  overflow: hidden;
}

.cp-to-top:hover {
  background: #fff;
}

.cp-to-top.cp-show {
  opacity: 1 !important;
  transform: translateY(0) !important;
  pointer-events: auto !important;
}

/* Ripple animation */
.cp-to-top .ripple {
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
  opacity: .35;
  transform: translate(-50%, -50%) scale(0);
  background: #fff;
  animation: cp-ripple .6s ease-out forwards;
}

@keyframes cp-ripple {
  to {
    transform: translate(-50%, -50%) scale(6);
    opacity: 0;
  }
}

/* ======================================================
   Responsive
   ====================================================== */

@media (max-width: 768px) {
  .cp-nav-list {
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
  }

  .cp-title {
    font-size: 1.9rem;
  }

  .cp-section-title {
    font-size: 1.4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
