/* =========================================
   확률.com — Anti-design, Ma-negative-space
   ========================================= */

/* --- CSS Custom Properties --- */
:root {
  --cream: #f5f0e8;
  --pink: #ff6b9d;
  --lemon: #e8de00;
  --cyan: #00b4d8;
  --dark: #2a2a2e;
  --coral: #ff8a65;
  --grain: rgba(0,0,0,0.04);

  --font-display: 'Gowun Batang', serif;
  --font-body: 'Space Grotesk', sans-serif;
  --font-mono: 'Fira Code', monospace;
}

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

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--cream);
  color: var(--dark);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  font-weight: 400;
  overflow-x: hidden;
  position: relative;
}

/* --- Grain Overlay (fixed, full-viewport) --- */
.grain-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/></svg>");
  opacity: 1;
}

/* --- Full-page Diagonal SVG --- */
.diagonal-lines {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* --- Typography Utilities --- */
.code-text {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--pink);
}

.formula {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--dark);
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: rgba(232, 222, 0, 0.12);
  border-left: 3px solid var(--lemon);
  display: inline-block;
}

/* =========================================
   HERO SECTION — The Coin Toss
   ========================================= */
.hero {
  position: relative;
  min-height: 100vh;
  padding: 10vh 10vw;
  overflow: hidden;
  z-index: 2;
}

/* Die — upper-left corner */
.die-container {
  position: absolute;
  top: 8vh;
  left: 8vw;
}

.die {
  width: 60px;
  height: 60px;
  position: relative;
  transform-style: preserve-3d;
  animation: rollDie 2.4s ease-in-out infinite;
}

.die-face {
  position: absolute;
  inset: 0;
  background: var(--cream);
  border: 2px solid var(--dark);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px;
  backface-visibility: hidden;
}

.die-face.face-1 { transform: translateZ(30px); }
.die-face.face-2 { transform: rotateY(90deg) translateZ(30px); }
.die-face.face-3 { transform: rotateY(180deg) translateZ(30px); }
.die-face.face-4 { transform: rotateY(-90deg) translateZ(30px); }
.die-face.face-5 { transform: rotateX(90deg) translateZ(30px); }
.die-face.face-6 { transform: rotateX(-90deg) translateZ(30px); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dark);
  flex-shrink: 0;
}

/* Face 1 — single centered dot */
.face-1 .dot { width: 10px; height: 10px; }

/* Face 2 — two dots aligned */
.face-2 { flex-direction: column; justify-content: space-between; align-items: flex-end; padding: 10px; }
.face-2 .dot:first-child { align-self: flex-start; }

/* Face 3 — diagonal */
.face-3 { flex-direction: column; padding: 8px; gap: 2px; }

/* Face 4 — 2x2 grid */
.face-4 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px; }

/* Face 5 — 5 dots */
.face-5 { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 9px; }
.face-5 .dot:nth-child(3) { grid-column: 1 / -1; justify-self: center; }

/* Face 6 — 3x2 grid */
.face-6 { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 9px; }

@keyframes rollDie {
  0%   { transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg); }
  20%  { transform: rotateX(90deg) rotateY(45deg) rotateZ(15deg); }
  40%  { transform: rotateX(180deg) rotateY(90deg) rotateZ(30deg); }
  60%  { transform: rotateX(270deg) rotateY(180deg) rotateZ(15deg); }
  80%  { transform: rotateX(360deg) rotateY(270deg) rotateZ(5deg); }
  100% { transform: rotateX(360deg) rotateY(360deg) rotateZ(0deg); }
}

/* Hero title — lower-right quadrant */
.hero-title {
  position: absolute;
  bottom: 12vh;
  right: 10vw;
  text-align: right;
  max-width: 420px;
}

.display-title {
  font-family: var(--font-display);
  font-size: clamp(3rem, 7vw, 6rem);
  font-weight: 400;
  color: var(--dark);
  line-height: 1;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}

.hero-sub {
  margin-bottom: 0.5rem;
}

.hero-tagline {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--dark);
  opacity: 0.55;
  margin-top: 0.5rem;
  letter-spacing: 0.04em;
}

/* =========================================
   SCATTER SECTION — The Scatter Plot
   ========================================= */
.scatter {
  position: relative;
  min-height: 300vh;
  padding: 10vh 10vw;
  z-index: 2;
}

.scatter-connectors {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.scatter-block {
  position: absolute;
  max-width: 360px;
  z-index: 1;
}

.scatter-block h2.section-label {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 400;
  margin-bottom: 0.6rem;
  color: var(--dark);
}

.scatter-block p {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--dark);
  opacity: 0.8;
}

/* Probability-distribution based placement */
.block-a {
  left: calc(var(--seed) * 50% + 5%);
  top: calc(var(--seed-2) * 20% + 3%);
}

.block-b {
  left: calc(var(--seed) * 50% + 25%);
  top: calc(var(--seed-2) * 15% + 8%);
}

.block-c {
  left: calc(var(--seed) * 40% + 5%);
  top: calc(var(--seed-2) * 25% + 28%);
}

.block-d {
  left: calc(var(--seed) * 30% + 55%);
  top: calc(var(--seed-2) * 20% + 32%);
}

.block-e {
  left: calc(var(--seed) * 50% + 5%);
  top: calc(var(--seed-2) * 20% + 55%);
}

.block-f {
  left: calc(var(--seed) * 40% + 40%);
  top: calc(var(--seed-2) * 10% + 72%);
}

/* --- Bell Curve Illustration --- */
.stat-illustration {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.bell-curve-svg {
  width: 160px;
  height: 80px;
  overflow: visible;
}

.bell-curve-path {
  stroke-dasharray: 300;
  stroke-dashoffset: 300;
  transition: stroke-dashoffset 3s ease-in-out;
}

.bell-curve-path.animate {
  stroke-dashoffset: 0;
}

.pie-svg {
  width: 120px;
  height: 120px;
}

.illus-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--dark);
  opacity: 0.6;
}

/* Pie chart animation */
.pie-slice-1 {
  transition: stroke-dasharray 0.8s ease-out;
}
.pie-slice-2 {
  transition: stroke-dasharray 0.8s ease-out 0.4s;
}
.pie-slice-3 {
  transition: stroke-dasharray 0.8s ease-out 0.8s;
}

/* =========================================
   SHARP ANGLES SECTION
   ========================================= */
.angles-section {
  position: relative;
  min-height: 60vh;
  padding: 12vh 10vw;
  z-index: 2;
  overflow: hidden;
}

.angle-content {
  position: relative;
  z-index: 2;
}

.angle-title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3.5vw, 2.8rem);
  font-weight: 400;
  margin-bottom: 4rem;
  color: var(--dark);
}

.angle-items {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  max-width: 500px;
}

.angle-item {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
}

.angle-num {
  font-size: 1.4rem;
  color: var(--pink);
  min-width: 100px;
}

.angle-desc {
  font-size: 1rem;
  color: var(--dark);
  opacity: 0.75;
}

/* Sharp triangles as decorative elements */
.sharp-triangle {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}

.t1 {
  border-left: 60px solid transparent;
  border-right: 0 solid transparent;
  border-bottom: 120px solid rgba(255, 107, 157, 0.12);
  top: 10%;
  right: 8%;
  transform: rotate(15deg);
}

.t2 {
  border-left: 0 solid transparent;
  border-right: 90px solid transparent;
  border-top: 160px solid rgba(0, 180, 216, 0.1);
  bottom: 15%;
  right: 20%;
  transform: rotate(-30deg);
}

.t3 {
  border-left: 45px solid transparent;
  border-right: 45px solid transparent;
  border-bottom: 80px solid rgba(232, 222, 0, 0.18);
  top: 50%;
  right: 35%;
  transform: rotate(45deg);
}

/* =========================================
   COIN FLIP SECTION
   ========================================= */
.coin-section {
  position: relative;
  min-height: 80vh;
  padding: 15vh 10vw;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.coin-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2rem;
}

.coin-label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--dark);
  opacity: 0.5;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Coin */
.coin {
  width: 100px;
  height: 100px;
  perspective: 600px;
  cursor: pointer;
}

.coin-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s ease-in-out;
}

.coin.flipping .coin-inner {
  animation: coinFlip 0.6s ease-in-out;
}

.coin-front,
.coin-back {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  backface-visibility: hidden;
}

.coin-front {
  background: var(--lemon);
  color: var(--dark);
  border: 3px solid var(--dark);
}

.coin-back {
  background: var(--pink);
  color: var(--cream);
  border: 3px solid var(--dark);
  transform: rotateY(180deg);
}

@keyframes coinFlip {
  0%   { transform: rotateY(0deg); }
  50%  { transform: rotateY(900deg) scale(1.1); }
  100% { transform: rotateY(1800deg); }
}

.coin.show-heads .coin-inner { transform: rotateY(0deg); }
.coin.show-tails .coin-inner { transform: rotateY(180deg); }

.flip-btn {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--cream);
  background: var(--dark);
  border: none;
  padding: 0.7rem 2rem;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: background 0.2s, transform 0.1s;
}

.flip-btn:hover {
  background: var(--pink);
}

.flip-btn:active {
  transform: scale(0.97);
}

.flip-stats {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  color: var(--dark);
  opacity: 0.7;
}

.stat-sep {
  opacity: 0.3;
}

/* =========================================
   FOOTER — The Expected Value
   ========================================= */
.footer {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 2;
}

.footer-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.footer-domain {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 400;
  color: var(--dark);
  letter-spacing: -0.01em;
}

.footer-dot {
  color: var(--pink);
}

.footer-eq {
  font-size: 1rem;
  color: var(--cyan);
}

.footer-note {
  font-size: 0.8rem;
  color: var(--dark);
  opacity: 0.4;
  letter-spacing: 0.06em;
}

/* Scattered data points */
.data-point {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.dp1 { width: 8px; height: 8px; background: var(--pink); top: 15%; left: 12%; opacity: 0.7; }
.dp2 { width: 5px; height: 5px; background: var(--lemon); top: 30%; right: 20%; opacity: 0.8; }
.dp3 { width: 10px; height: 10px; background: var(--cyan); bottom: 25%; left: 30%; opacity: 0.6; }
.dp4 { width: 6px; height: 6px; background: var(--coral); bottom: 40%; right: 15%; opacity: 0.7; }
.dp5 { width: 7px; height: 7px; background: var(--lemon); top: 60%; left: 65%; opacity: 0.6; }

/* =========================================
   MOBILE RESPONSIVE
   ========================================= */
@media (max-width: 768px) {
  .scatter {
    min-height: auto;
    padding: 8vh 6vw;
    display: flex;
    flex-direction: column;
    gap: 4rem;
  }

  .scatter-block {
    position: static;
    max-width: 100%;
  }

  .scatter-connectors {
    display: none;
  }

  .hero-title {
    position: static;
    text-align: left;
    margin-top: auto;
    margin-left: auto;
    max-width: 100%;
    padding-top: 40vh;
  }

  .hero {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
  }

  .die-container {
    position: absolute;
    top: 6vh;
    left: 6vw;
  }

  .display-title {
    font-size: clamp(2.5rem, 10vw, 4rem);
  }

  .angle-items {
    gap: 2rem;
  }

  .coin-section {
    justify-content: center;
    padding: 10vh 6vw;
  }

  .coin-content {
    align-items: center;
  }

  .angles-section {
    padding: 8vh 6vw;
  }

  .t1, .t2, .t3 {
    opacity: 0.6;
  }

  .diagonal-lines {
    display: none;
  }
}
