/* ==========================================================================
   kakuritsu.com — 確率 :: the mathematics of chance
   Generative-art background + ma-negative-space + frosted content islands
   ========================================================================== */

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

:root {
    --ink:    #0f1923;  /* deep ink — main background, the void of uncertainty */
    --deep:   #1a2a3a;  /* dark slate — card backgrounds */
    --mid:    #2a3a4a;  /* muted teal-gray — borders */
    --light:  #d4dce8;  /* cool silver — body text */
    --amber:  #e8a838;  /* golden ratio — highlights */
    --blue:   #4a90d9;  /* probability blue — curves */
    --island-bg: rgba(15, 25, 35, 0.7);
    --island-border: rgba(74, 144, 217, 0.15);
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--ink);
    color: var(--light);
    font-family: 'Source Sans 3', 'Helvetica Neue', sans-serif;
    font-weight: 400;
    line-height: 1.8;
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
}

::selection {
    background: rgba(232, 168, 56, 0.35);
    color: var(--light);
}

/* ==========================================================================
   GENERATIVE BACKGROUND LAYER
   ========================================================================== */
.bg-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.bg-watermark {
    position: absolute;
    top: 12%;
    left: -5%;
    width: 110%;
    height: 60%;
    opacity: 0.03;
}

.bg-spiral {
    position: absolute;
    bottom: -8%;
    right: -8%;
    width: 60vw;
    height: 60vw;
    max-width: 720px;
    max-height: 720px;
    opacity: 0.05;
    transform: rotate(-12deg);
}

.dice-field {
    position: absolute;
    inset: 0;
}

.dice-pip {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--blue);
    opacity: 0.05;
    will-change: transform;
}

@keyframes drift {
    0%   { transform: translate(0, 0); }
    50%  { transform: translate(10px, -10px); }
    100% { transform: translate(0, 0); }
}

.random-walk {
    position: absolute;
    top: 0;
    left: 1.5rem;
    width: 60px;
    height: 4000px;
    opacity: 0.22;
    pointer-events: none;
}

.vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 0%,
        transparent 45%,
        rgba(15, 25, 35, 0.55) 80%,
        var(--ink) 100%
    );
}

/* lift all real content above bg-layer */
.hero, .section, .footer, .divider {
    position: relative;
    z-index: 1;
}

/* ==========================================================================
   HERO :: The Distribution
   ========================================================================== */
.hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 4rem 2rem;
    background: transparent;
    overflow: hidden;
}

.bell-curve {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 92%;
    max-width: 900px;
    opacity: 0.85;
    z-index: 0;
}

.curve-path {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    animation: drawCurve 3s ease-in-out forwards;
    filter: drop-shadow(0 0 6px rgba(74, 144, 217, 0.35));
}

@keyframes drawCurve {
    to { stroke-dashoffset: 0; }
}

.curve-axis,
.curve-mu,
.curve-sigma-l,
.curve-sigma-r {
    opacity: 0;
    animation: fadeInLate 1.2s ease-in 2.4s forwards;
}

@keyframes fadeInLate {
    to { opacity: 1; }
}

.hero-text {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 640px;
    padding: 1rem;
}

.hero-eyebrow {
    font-family: 'Fira Code', monospace;
    font-size: 0.78rem;
    color: var(--mid);
    letter-spacing: 0.18em;
    text-transform: lowercase;
    opacity: 0;
    animation: fadeUp 1.2s ease 0.6s forwards;
}

.hero-title {
    font-family: 'Cormorant Garamond', 'Times New Roman', serif;
    font-size: clamp(4rem, 12vw, 9rem);
    font-weight: 600;
    color: var(--light);
    letter-spacing: 0.05em;
    line-height: 1;
    margin: 1.5rem 0 1rem;
    opacity: 0;
    animation: fadeUp 1.4s ease 1.2s forwards;
    text-shadow: 0 0 24px rgba(15, 25, 35, 0.9);
}

.hero-domain {
    font-family: 'Fira Code', monospace;
    font-size: 0.95rem;
    color: var(--blue);
    letter-spacing: 0.18em;
    margin-top: 0.25rem;
    opacity: 0;
    animation: fadeUp 1.2s ease 1.8s forwards;
}

.hero-sub {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1rem, 2.4vw, 1.4rem);
    color: var(--amber);
    margin-top: 1rem;
    font-style: italic;
    font-weight: 500;
    letter-spacing: 0.03em;
    opacity: 0;
    animation: fadeUp 1.2s ease 2.2s forwards;
}

.hero-formula {
    margin-top: 2.5rem;
    opacity: 0;
    animation: fadeUp 1.2s ease 2.8s forwards;
}

.hero-formula code {
    font-family: 'Fira Code', monospace;
    font-size: clamp(0.7rem, 1.6vw, 0.9rem);
    color: var(--light);
    opacity: 0.55;
    letter-spacing: 0.04em;
    border-left: 2px solid var(--amber);
    padding: 0.25rem 0 0.25rem 0.85rem;
    font-style: italic;
    display: inline-block;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.scroll-cue {
    position: absolute;
    bottom: 2.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    opacity: 0;
    animation: fadeUp 1.2s ease 3.4s forwards;
    z-index: 2;
}

.cue-line {
    width: 1px;
    height: 36px;
    background: linear-gradient(to bottom, transparent, var(--blue));
    animation: cuePulse 2.2s ease-in-out infinite;
}

@keyframes cuePulse {
    0%, 100% { transform: scaleY(0.6); opacity: 0.4; }
    50%      { transform: scaleY(1);   opacity: 1; }
}

.cue-label {
    font-family: 'Fira Code', monospace;
    font-size: 0.68rem;
    color: var(--mid);
    letter-spacing: 0.18em;
    text-transform: lowercase;
}

/* ==========================================================================
   DIVIDERS — small bell curve glyph between sections
   ========================================================================== */
.divider {
    display: flex;
    justify-content: center;
    padding: 1.5rem 0;
}

.divider svg {
    width: 130px;
    height: 22px;
}

/* ==========================================================================
   SECTIONS :: ma-negative-space, floating content islands
   ========================================================================== */
.section {
    min-height: 60vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 6rem 1.5rem;
}

.content-island {
    max-width: 640px;
    width: 100%;
    text-align: left;
    padding: 2.75rem 2.5rem;
    background: var(--island-bg);
    border: 1px solid var(--island-border);
    border-radius: 12px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow:
        0 1px 0 rgba(212, 220, 232, 0.04) inset,
        0 30px 60px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1s ease, transform 1s ease, border-color 0.6s ease;
}

.content-island.wide {
    max-width: 900px;
}

.content-island.visible {
    opacity: 1;
    transform: translateY(0);
}

.content-island:hover {
    border-color: rgba(74, 144, 217, 0.3);
}

.section-marker {
    font-family: 'Fira Code', monospace;
    font-size: 0.72rem;
    color: var(--mid);
    letter-spacing: 0.2em;
    text-transform: lowercase;
    margin-bottom: 1.25rem;
}

.section-marker span {
    color: var(--amber);
    margin-right: 0.5rem;
}

.content-island h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(2rem, 5vw, 3.4rem);
    font-weight: 600;
    color: var(--light);
    margin-bottom: 1.5rem;
    line-height: 1.1;
    letter-spacing: 0.005em;
}

.content-island p {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 1rem;
    line-height: 1.85;
    color: var(--light);
    opacity: 0.85;
    margin-bottom: 1.1rem;
}

.content-island p:last-child {
    margin-bottom: 0;
}

.section-lede {
    color: var(--light) !important;
    opacity: 0.95 !important;
    font-size: 1.08rem !important;
    font-style: italic;
}

.kanji {
    font-family: 'Cormorant Garamond', serif;
    color: var(--amber);
    font-weight: 600;
    font-size: 1.1em;
}

blockquote {
    margin: 2rem 0 1rem;
    padding: 0.5rem 0 0.5rem 1.25rem;
    border-left: 2px solid var(--amber);
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 1.15rem;
    color: var(--light);
    opacity: 0.9;
    line-height: 1.6;
    position: relative;
}

blockquote .quote-mark {
    color: var(--amber);
    font-size: 2rem;
    line-height: 0;
    margin-right: 0.15em;
    vertical-align: -0.4em;
}

blockquote cite {
    display: block;
    margin-top: 0.75rem;
    font-family: 'Fira Code', monospace;
    font-style: normal;
    font-size: 0.78rem;
    color: var(--mid);
    letter-spacing: 0.1em;
}

/* ==========================================================================
   FORMULA BLOCK
   ========================================================================== */
.formula-block {
    margin: 2rem 0;
    padding: 1.25rem 1.5rem;
    background: rgba(232, 168, 56, 0.04);
    border-left: 2px solid var(--amber);
    border-radius: 0 6px 6px 0;
    overflow-x: auto;
}

.formula {
    display: block;
    font-family: 'Fira Code', monospace !important;
    font-size: clamp(0.95rem, 2.2vw, 1.25rem);
    color: var(--amber);
    letter-spacing: 0.04em;
    font-style: italic;
    line-height: 1.6;
    opacity: 1 !important;
}

.formula sub {
    font-size: 0.7em;
}

.bayes-legend {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.65rem;
    margin: 1.5rem 0 2rem;
    padding: 1.2rem 1.4rem;
    background: rgba(74, 144, 217, 0.04);
    border: 1px solid rgba(74, 144, 217, 0.1);
    border-radius: 8px;
}

.legend-row {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 1rem;
    align-items: baseline;
    font-size: 0.92rem;
    line-height: 1.5;
}

.legend-symbol {
    font-family: 'Fira Code', monospace;
    color: var(--blue);
    font-size: 0.85rem;
    letter-spacing: 0.03em;
}

.legend-text {
    color: var(--light);
    opacity: 0.85;
}

.legend-text strong {
    color: var(--amber);
    font-weight: 600;
    margin-right: 0.4em;
}

/* ==========================================================================
   DISTRIBUTIONS GRID
   ========================================================================== */
.dist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-top: 2.5rem;
}

.dist-card {
    background: rgba(26, 42, 58, 0.55);
    border: 1px solid rgba(74, 144, 217, 0.12);
    padding: 1.65rem 1.5rem;
    border-radius: 10px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.7s ease, transform 0.7s ease, border-color 0.4s ease, background 0.4s ease;
    position: relative;
    overflow: hidden;
}

.dist-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(74, 144, 217, 0.4), transparent);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.dist-card:hover {
    border-color: rgba(232, 168, 56, 0.35);
    background: rgba(26, 42, 58, 0.75);
    transform: translateY(-4px);
}

.dist-card:hover::before {
    opacity: 1;
}

.dist-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.dist-icon {
    margin-bottom: 1rem;
    height: 44px;
    display: flex;
    align-items: center;
}

.mini-curve {
    width: 90px;
    height: 44px;
}

.dist-card h3 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.45rem;
    font-weight: 600;
    color: var(--light);
    margin-bottom: 0.6rem;
    letter-spacing: 0.02em;
}

.dist-card p {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.92rem;
    color: var(--light);
    opacity: 0.78;
    line-height: 1.65;
    margin-bottom: 0.85rem;
}

.dist-formula {
    font-family: 'Fira Code', monospace;
    font-size: 0.78rem;
    color: var(--amber);
    letter-spacing: 0.05em;
    opacity: 0.85;
    display: inline-block;
    padding: 0.15rem 0.55rem;
    background: rgba(232, 168, 56, 0.06);
    border-radius: 3px;
    border: 1px solid rgba(232, 168, 56, 0.15);
}

/* ==========================================================================
   DICE ROW (randomness section)
   ========================================================================== */
.dice-row {
    display: flex;
    justify-content: space-between;
    gap: 0.6rem;
    margin-top: 2.2rem;
    flex-wrap: wrap;
}

.die {
    width: 48px;
    height: 48px;
    background: rgba(15, 25, 35, 0.85);
    border: 1px solid rgba(74, 144, 217, 0.3);
    border-radius: 8px;
    padding: 6px;
    display: grid;
    gap: 2px;
    transition: transform 0.4s ease, border-color 0.4s ease;
    flex: 0 0 48px;
}

.die:hover {
    transform: rotate(8deg) scale(1.08);
    border-color: var(--amber);
}

.die .pip {
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--blue);
    align-self: center;
    justify-self: center;
}

.die[data-pips="1"] {
    grid-template: 1fr / 1fr;
    place-items: center;
}
.die[data-pips="2"] {
    grid-template: 1fr 1fr / 1fr 1fr;
}
.die[data-pips="2"] .pip:nth-child(1) { grid-area: 1/1; }
.die[data-pips="2"] .pip:nth-child(2) { grid-area: 2/2; }

.die[data-pips="3"] {
    grid-template: 1fr 1fr 1fr / 1fr 1fr 1fr;
}
.die[data-pips="3"] .pip:nth-child(1) { grid-area: 1/1; }
.die[data-pips="3"] .pip:nth-child(2) { grid-area: 2/2; }
.die[data-pips="3"] .pip:nth-child(3) { grid-area: 3/3; }

.die[data-pips="4"] {
    grid-template: 1fr 1fr / 1fr 1fr;
}
.die[data-pips="5"] {
    grid-template: 1fr 1fr 1fr / 1fr 1fr 1fr;
}
.die[data-pips="5"] .pip:nth-child(1) { grid-area: 1/1; }
.die[data-pips="5"] .pip:nth-child(2) { grid-area: 1/3; }
.die[data-pips="5"] .pip:nth-child(3) { grid-area: 2/2; }
.die[data-pips="5"] .pip:nth-child(4) { grid-area: 3/1; }
.die[data-pips="5"] .pip:nth-child(5) { grid-area: 3/3; }

.die[data-pips="6"] {
    grid-template: 1fr 1fr 1fr / 1fr 1fr;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.footer {
    text-align: center;
    padding: 6rem 2rem 4rem;
    margin-top: 4rem;
    border-top: 1px solid rgba(74, 144, 217, 0.1);
}

.footer-inner {
    max-width: 480px;
    margin: 0 auto;
}

.footer-kanji {
    font-family: 'Cormorant Garamond', serif;
    font-size: 3rem;
    font-weight: 600;
    color: var(--amber);
    line-height: 1;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.footer-text {
    font-family: 'Fira Code', monospace;
    font-size: 0.95rem;
    color: var(--light);
    letter-spacing: 0.18em;
    opacity: 0.9;
}

.footer-sub {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 1rem;
    color: var(--mid);
    margin-top: 0.5rem;
}

.footer-coda {
    margin-top: 2rem;
    opacity: 0.55;
}

.footer-coda code {
    font-family: 'Fira Code', monospace;
    font-size: 0.78rem;
    color: var(--blue);
    letter-spacing: 0.05em;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 720px) {
    .section { padding: 4.5rem 1rem; }
    .content-island { padding: 2rem 1.5rem; }
    .dist-grid { grid-template-columns: 1fr; }
    .legend-row {
        grid-template-columns: 1fr;
        gap: 0.2rem;
    }
    .random-walk { left: 0.4rem; width: 30px; opacity: 0.15; }
    .die { width: 38px; height: 38px; flex: 0 0 38px; padding: 4px; }
    .die .pip { width: 4px; height: 4px; }
}

@media (max-width: 420px) {
    .dice-row { justify-content: center; gap: 0.5rem; }
}
