/* === Reset === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* === Body & Background === */
html {
  scroll-behavior: smooth;
}

body {
  background-color: #F7F0E6;
  color: #4A3F35;
  font-family: 'Source Sans 3', 'Source Sans Pro', sans-serif;
  font-size: clamp(1rem, 1.8vw, 1.125rem);
  line-height: 1.75;
  position: relative;
  overflow-x: hidden;
}

.noise-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  filter: url(#noise);
  opacity: 0.03;
  background: #F7F0E6;
}

/* === Topographic margin texture === */
body::before,
body::after {
  content: '';
  position: fixed;
  top: 0;
  bottom: 0;
  width: calc((100vw - 640px) / 2);
  pointer-events: none;
  z-index: 0;
  background-image:
    repeating-radial-gradient(circle at 30% 20%, #D4C1A8 0px, transparent 1px, transparent 60px),
    repeating-radial-gradient(circle at 70% 50%, #D4C1A8 0px, transparent 1px, transparent 80px),
    repeating-radial-gradient(circle at 50% 80%, #D4C1A8 0px, transparent 1px, transparent 70px);
  opacity: 0.04;
}

body::before {
  left: 0;
}

body::after {
  right: 0;
}

/* === Main === */
main {
  max-width: 640px;
  margin: 0 auto;
  padding: 4rem 1.5rem 6rem;
  position: relative;
  z-index: 1;
}

/* === Station === */
.station {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 2rem 0;
}

/* === Station Marker === */
.station-marker {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  margin: 0 auto 2rem;
  background-color: #F0E4D4;
  box-shadow:
    inset 2px 2px 6px rgba(74, 63, 53, 0.15),
    inset -1px -1px 4px rgba(255, 255, 255, 0.3);
  position: relative;
}

.station-marker::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: repeating-conic-gradient(
    from 0deg,
    transparent 0deg 8deg,
    rgba(139, 125, 107, 0.06) 8deg 10deg
  );
}

/* === Headings === */
h2 {
  font-family: 'Libre Baskerville', 'Georgia', serif;
  font-weight: 700;
  font-size: clamp(1.6rem, 3.2vw, 2.4rem);
  line-height: 1.2;
  letter-spacing: 0.01em;
  color: #3D2E1F;
  margin-bottom: 1.5rem;
  position: relative;
}

/* Ceramic crazing glitch */
h2::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    37deg,
    transparent,
    transparent 98px,
    rgba(200, 149, 108, 0.2) 98px,
    rgba(200, 149, 108, 0.2) 99px
  );
  opacity: 0;
}

h2.craze::before {
  animation: crazing 2s ease forwards;
}

@keyframes crazing {
  0%   { opacity: 0; }
  36%  { opacity: 0.5; }
  45%  { opacity: 0.5; }
  100% { opacity: 0; }
}

/* === Body text === */
.station-body p {
  text-align: justify;
  hyphens: auto;
  margin-bottom: 1.25rem;
}

/* === Code blocks === */
pre {
  background: #F5EDE0;
  border-left: 3px solid #C8956C;
  padding: 1.25rem;
  margin: 1.5rem 0;
  overflow-x: auto;
}

code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #5C4F3D;
}

/* === Icon Clusters === */
.icon-cluster {
  display: flex;
  gap: 1rem;
  padding: 1.5rem 0;
  color: #C8956C;
  flex-wrap: wrap;
}

.icon {
  width: 52px;
  height: 52px;
  transition: color 0.4s ease, transform 0.4s ease;
  cursor: default;
}

.icon:hover {
  color: #C17A56;
  transform: rotate(1deg);
}

/* === Kintsugi Seams === */
.kintsugi {
  border: none;
  height: 1px;
  background: #C8956C;
  margin: 2rem 0 0;
  clip-path: polygon(
    0% 40%, 3% 60%, 7% 35%, 12% 55%, 18% 42%,
    24% 58%, 30% 40%, 36% 62%, 42% 38%, 48% 55%,
    54% 42%, 60% 60%, 66% 35%, 72% 58%, 78% 40%,
    84% 55%, 90% 38%, 95% 58%, 100% 45%,
    100% 100%, 0% 100%
  );
}

/* === Erosion Gaps === */
.erosion-gap {
  height: 20vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: 0 -50vw;
  left: 50%;
  width: 100vw;
}

.contour-line {
  width: 100%;
  height: 80px;
}

.contour-line path {
  stroke-dasharray: var(--path-length, 2000);
  stroke-dashoffset: var(--path-length, 2000);
  transition: stroke-dashoffset 2.5s ease;
}

.contour-line.drawn path {
  stroke-dashoffset: 0;
}

/* === Station Counter === */
.station-counter {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  font-family: 'Libre Baskerville', Georgia, serif;
  font-style: italic;
  font-size: 0.75rem;
  color: #8B7D6B;
  opacity: 0.6;
  z-index: 100;
  pointer-events: none;
  user-select: none;
}

/* === Responsive === */
@media (max-width: 720px) {
  main {
    padding: 2rem 1rem 4rem;
  }

  body::before,
  body::after {
    display: none;
  }
}
