/* ========================================
   ronri.org — Logic Made Visible
   Swiss Grid + Coastal Palette + Pulse
   ======================================== */

/* --- CSS Custom Properties --- */
:root {
    --deep-marble: #1A2332;
    --coastal-teal: #1B7A7D;
    --adriatic-blue: #3AA5B2;
    --coral-pulse: #E8735A;
    --mediterranean-sand: #F5E6D3;
    --seafoam-white: #F0F7F4;
    --veined-gray: #8A9BA8;
    --limestone-warm: #D4B896;
    --slate-marble: #2D3748;
    --verde-dark: #0D4F52;
    --nero-vein: #2D3748;
    --light-text: #D4E5DE;

    --grid-columns: 12;
    --grid-gutter: 24px;
    --pulse-ease: cubic-bezier(0.37, 0, 0.63, 1);
    --reveal-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Quicksand', sans-serif;
    font-weight: 400;
    color: var(--slate-marble);
    background: var(--seafoam-white);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Marble Textures --- */
.marble-carrara {
    background:
        radial-gradient(ellipse at 20% 50%, rgba(138,155,168,0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(138,155,168,0.1) 0%, transparent 40%),
        radial-gradient(ellipse at 50% 80%, rgba(212,184,150,0.08) 0%, transparent 45%),
        linear-gradient(135deg, #F0F7F4 0%, #E8EFEd 50%, #F0F7F4 100%);
    filter: url('#marble-noise');
}

.marble-nero {
    background:
        radial-gradient(ellipse at 30% 40%, rgba(45,55,72,0.4) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 70%, rgba(45,55,72,0.3) 0%, transparent 45%),
        radial-gradient(ellipse at 50% 20%, rgba(138,155,168,0.08) 0%, transparent 40%),
        linear-gradient(135deg, #1A2332 0%, #222d3f 50%, #1A2332 100%);
    filter: url('#marble-noise');
}

.marble-verde {
    background:
        radial-gradient(ellipse at 25% 45%, rgba(13,79,82,0.25) 0%, transparent 50%),
        radial-gradient(ellipse at 75% 30%, rgba(13,79,82,0.15) 0%, transparent 45%),
        radial-gradient(ellipse at 50% 75%, rgba(58,165,178,0.1) 0%, transparent 40%),
        linear-gradient(135deg, #1B7A7D 0%, #1a6d70 50%, #1B7A7D 100%);
    filter: url('#marble-noise');
}

/* --- Foyer --- */
#foyer {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    opacity: 0;
    animation: foyer-fade 1.5s ease forwards;
}

@keyframes foyer-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.foyer-content {
    text-align: center;
    z-index: 2;
}

.foyer-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(4rem, 10vw, 9rem);
    letter-spacing: -0.03em;
    color: var(--deep-marble);
    line-height: 1;
    margin-bottom: 0.2em;
}

.foyer-title .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(10px);
    animation: char-reveal 0.5s var(--reveal-ease) forwards;
    animation-delay: var(--char-delay);
}

.foyer-subtitle {
    font-family: 'Varela Round', sans-serif;
    font-size: clamp(0.75rem, 1.2vw, 0.95rem);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--coastal-teal);
    opacity: 0;
    animation: subtitle-fade 0.8s ease 1.2s forwards;
}

@keyframes char-reveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes subtitle-fade {
    to { opacity: 1; }
}

.chevron-container {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

.chevron-icon {
    animation: chevron-pulse 2.5s var(--pulse-ease) infinite;
    opacity: 0.3;
}

@keyframes chevron-pulse {
    0%, 100% { opacity: 0.3; transform: translateY(0); }
    50% { opacity: 0.8; transform: translateY(4px); }
}

/* --- Grid Overlay --- */
#grid-awakening {
    min-height: 200vh;
    position: relative;
    overflow: hidden;
}

.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
}

.grid-line {
    position: absolute;
    background: var(--coastal-teal);
    opacity: 0;
    transition: opacity 0.6s ease;
}

.grid-line-h {
    height: 1px;
    width: 0;
    left: 50%;
    transform: translateX(-50%);
    transition: width 0.6s ease, opacity 0.6s ease;
}

.grid-line-h:nth-child(1) { top: 25%; }
.grid-line-h:nth-child(2) { top: 50%; }
.grid-line-h:nth-child(3) { top: 75%; }
.grid-line-h:nth-child(4) { top: 90%; }

.grid-line-v {
    width: 1px;
    height: 0;
    top: 50%;
    transform: translateY(-50%);
    transition: height 0.8s ease, opacity 0.8s ease;
}

.grid-line-v:nth-child(5)  { left: calc(100% / 12 * 1); }
.grid-line-v:nth-child(6)  { left: calc(100% / 12 * 2); }
.grid-line-v:nth-child(7)  { left: calc(100% / 12 * 3); }
.grid-line-v:nth-child(8)  { left: calc(100% / 12 * 4); }
.grid-line-v:nth-child(9)  { left: calc(100% / 12 * 5); }
.grid-line-v:nth-child(10) { left: calc(100% / 12 * 6); }
.grid-line-v:nth-child(11) { left: calc(100% / 12 * 7); }
.grid-line-v:nth-child(12) { left: calc(100% / 12 * 8); }
.grid-line-v:nth-child(13) { left: calc(100% / 12 * 9); }
.grid-line-v:nth-child(14) { left: calc(100% / 12 * 10); }
.grid-line-v:nth-child(15) { left: calc(100% / 12 * 11); }
.grid-line-v:nth-child(16) { left: calc(100% / 12 * 12); }

.grid-line.active.grid-line-h {
    width: 100%;
    opacity: 0.25;
}

.grid-line.active.grid-line-v {
    height: 100%;
    opacity: 0.15;
}

/* --- Awakening Shapes --- */
.awakening-shapes {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: var(--grid-gutter);
    padding: var(--grid-gutter);
    z-index: 2;
    pointer-events: none;
}

.shape-item {
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.shape-item.visible {
    opacity: 1;
    transform: scale(1);
}

.marble-circle {
    grid-column: var(--col-start) / span var(--col-span, 3);
    grid-row: var(--row, 1);
    width: 100%;
    aspect-ratio: 1;
    max-width: 280px;
    border-radius: 50%;
    background:
        radial-gradient(ellipse at 30% 40%, rgba(138,155,168,0.4) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 60%, rgba(240,247,244,0.6) 0%, transparent 40%),
        radial-gradient(ellipse at 50% 50%, rgba(212,184,150,0.3) 0%, transparent 45%),
        var(--seafoam-white);
    filter: url('#marble-noise');
    animation: shape-pulse 3s var(--pulse-ease) infinite;
    animation-delay: var(--phase, 0s);
    align-self: center;
    justify-self: center;
}

.marble-circle.small {
    max-width: 140px;
}

.marble-circle.medium-circle {
    max-width: 200px;
}

.marble-circle.large-circle {
    max-width: 350px;
}

.rounded-rect {
    grid-column: var(--col-start, 1) / span var(--col-span, 3);
    grid-row: var(--row, 1);
    border-radius: 24px;
    aspect-ratio: 1.618;
    align-self: center;
    justify-self: center;
    width: 100%;
    animation: shape-pulse 3s var(--pulse-ease) infinite;
    animation-delay: var(--phase, 0s);
}

.rounded-rect.coral { background: var(--coral-pulse); }
.rounded-rect.teal { background: var(--adriatic-blue); }
.rounded-rect.sand { background: var(--mediterranean-sand); }

.rounded-rect.large-rect {
    max-width: 400px;
}

.soft-polygon {
    grid-column: var(--col-start, 1) / span var(--col-span, 3);
    grid-row: var(--row, 1);
    align-self: center;
    justify-self: center;
    width: 100%;
    max-width: 300px;
    animation: slow-rotate 60s linear infinite, shape-pulse 3s var(--pulse-ease) infinite;
    animation-delay: var(--phase, 0s);
}

@keyframes shape-pulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.08); opacity: 1; }
}

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

/* --- Pulse Dots --- */
.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--coral-pulse);
    grid-column: var(--col-start, 1) / span var(--col-span, 1);
    grid-row: var(--row, 1);
    align-self: center;
    justify-self: center;
    animation: dot-pulse 1.5s var(--pulse-ease) infinite;
    animation-delay: var(--phase, 0s);
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.3s var(--pulse-ease);
    z-index: 5;
}

.pulse-dot:hover {
    transform: scale(1.4);
}

@keyframes dot-pulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.5); opacity: 1; }
}

/* --- Logic Sections --- */
.logic-section {
    min-height: 120vh;
    position: relative;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--grid-gutter);
    padding: 0 var(--grid-gutter);
    align-content: center;
}

.breathing-space {
    grid-column: 1 / -1;
    height: 20vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.marble-rule {
    width: 60%;
    border: none;
    height: 1px;
    background: var(--coastal-teal);
    opacity: 0.3;
}

.light-rule {
    background: var(--adriatic-blue);
    opacity: 0.2;
}

.verde-rule {
    background: var(--seafoam-white);
    opacity: 0.2;
}

/* Logic Content - Zigzag positioning */
.logic-content {
    position: relative;
    padding: 2rem 0;
}

.logic-left {
    grid-column: 2 / 7;
}

.logic-right {
    grid-column: 6 / 11;
}

.section-dot {
    position: absolute;
    top: 0;
    left: -20px;
    grid-column: auto;
    grid-row: auto;
}

.section-label {
    font-family: 'Varela Round', sans-serif;
    font-size: clamp(0.75rem, 1.2vw, 0.95rem);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--coastal-teal);
    display: block;
    margin-bottom: 1.2rem;
}

.light-label {
    color: var(--adriatic-blue);
}

.verde-label {
    color: var(--seafoam-white);
    opacity: 0.8;
}

.section-heading {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    letter-spacing: -0.01em;
    color: var(--deep-marble);
    line-height: 1.1;
    margin-bottom: 0.8rem;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.7s var(--reveal-ease), transform 0.7s var(--reveal-ease);
}

.section-heading.revealed {
    opacity: 1;
    transform: translateY(0);
}

.light-heading {
    color: var(--seafoam-white);
}

.verde-heading {
    color: var(--seafoam-white);
}

.heading-underline {
    width: 0;
    height: 3px;
    background: var(--coral-pulse);
    border-radius: 2px;
    margin-bottom: 2rem;
    transition: width 0.8s var(--reveal-ease);
}

.heading-underline.expanded {
    width: 80px;
    animation: underline-pulse 2s var(--pulse-ease) infinite;
}

.light-underline {
    background: var(--coral-pulse);
}

.verde-underline {
    background: var(--mediterranean-sand);
}

@keyframes underline-pulse {
    0%, 100% { width: 80px; opacity: 0.8; }
    50% { width: 100px; opacity: 1; }
}

.section-body {
    font-family: 'Quicksand', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.5vw, 1.15rem);
    line-height: 1.72;
    color: var(--slate-marble);
    max-width: 65ch;
    margin-bottom: 1.5rem;
}

.light-body {
    color: var(--light-text);
}

.verde-body {
    color: var(--light-text);
}

/* Logic Shapes (decorative side) */
.logic-shapes {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    position: relative;
}

.logic-shapes-right {
    grid-column: 8 / 12;
}

.logic-shapes-left {
    grid-column: 2 / 5;
    grid-row: 2;
}

.logic-shapes .rounded-rect {
    grid-column: auto;
    grid-row: auto;
    width: 100%;
    max-width: 300px;
    aspect-ratio: 1.618;
}

.logic-shapes .marble-circle {
    grid-column: auto;
    grid-row: auto;
    width: 80%;
    max-width: 200px;
}

.logic-shapes .soft-polygon {
    grid-column: auto;
    grid-row: auto;
    width: 100%;
    max-width: 250px;
}

.logic-shapes .pulse-dot {
    grid-column: auto;
    grid-row: auto;
}

/* --- Section color contexts --- */
.section-light {
    background-color: var(--seafoam-white);
}

.section-dark {
    color: var(--seafoam-white);
}

.section-verde {
    color: var(--seafoam-white);
}

/* --- Dissolution --- */
.dissolution-section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.dissolution-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.dissolve-line {
    opacity: 0.15;
    transition: opacity 1.5s ease;
}

.dissolve-line.fading {
    opacity: 0;
}

.dissolution-grid .grid-line-h:nth-child(1) { top: 30%; width: 100%; }
.dissolution-grid .grid-line-h:nth-child(2) { top: 70%; width: 100%; }
.dissolution-grid .grid-line-v:nth-child(3) { left: 25%; height: 100%; }
.dissolution-grid .grid-line-v:nth-child(4) { left: 50%; height: 100%; }
.dissolution-grid .grid-line-v:nth-child(5) { left: 75%; height: 100%; }

.dissolution-content {
    text-align: center;
    z-index: 2;
    max-width: 700px;
    padding: 0 var(--grid-gutter);
}

.dissolution-heading {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(3rem, 8vw, 7rem);
    color: var(--deep-marble);
    letter-spacing: -0.03em;
    margin-bottom: 2rem;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.7s var(--reveal-ease), transform 0.7s var(--reveal-ease);
}

.dissolution-heading.revealed {
    opacity: 1;
    transform: translateY(0);
}

.dissolution-text {
    font-family: 'Quicksand', sans-serif;
    font-weight: 500;
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    line-height: 1.72;
    color: var(--slate-marble);
    transition: letter-spacing 0.3s ease;
}

.dissolution-dots {
    display: flex;
    gap: 24px;
    justify-content: center;
    margin-top: 3rem;
}

.dissolution-dots .pulse-dot {
    grid-column: auto;
    grid-row: auto;
}

/* --- Background color transitions between sections --- */
.logic-section::before {
    content: '';
    position: absolute;
    top: -20vh;
    left: 0;
    right: 0;
    height: 40vh;
    pointer-events: none;
    z-index: -1;
}

/* --- Grid breathing animation (scroll-driven opacity wave) --- */
.grid-line.breathing {
    animation: grid-breathe 4s var(--pulse-ease) infinite;
    animation-delay: var(--breathe-delay, 0s);
}

@keyframes grid-breathe {
    0%, 100% { opacity: 0.15; }
    50% { opacity: 0.4; }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    :root {
        --grid-columns: 4;
        --grid-gutter: 16px;
    }

    .logic-left,
    .logic-right {
        grid-column: 1 / -1;
        padding: 1.5rem var(--grid-gutter);
    }

    .logic-shapes-right,
    .logic-shapes-left {
        grid-column: 1 / -1;
        grid-row: auto;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        padding-bottom: 2rem;
    }

    .logic-shapes .rounded-rect,
    .logic-shapes .marble-circle,
    .logic-shapes .soft-polygon {
        max-width: 160px;
    }

    .awakening-shapes {
        grid-template-columns: repeat(4, 1fr);
    }

    .shape-item {
        transform: scale(0.5);
    }

    .shape-item.visible {
        transform: scale(0.6);
    }

    .grid-line.active.grid-line-v {
        opacity: 0.1;
    }

    .grid-line.active.grid-line-h {
        opacity: 0.15;
    }

    .section-heading {
        font-size: clamp(2rem, 8vw, 3rem);
    }

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

    .grid-line-v:nth-child(5),
    .grid-line-v:nth-child(6),
    .grid-line-v:nth-child(7),
    .grid-line-v:nth-child(8),
    .grid-line-v:nth-child(9),
    .grid-line-v:nth-child(10),
    .grid-line-v:nth-child(11),
    .grid-line-v:nth-child(12),
    .grid-line-v:nth-child(13),
    .grid-line-v:nth-child(14),
    .grid-line-v:nth-child(15),
    .grid-line-v:nth-child(16) {
        display: none;
    }

    .grid-line-v:nth-child(5)  { display: block; left: 25%; }
    .grid-line-v:nth-child(6)  { display: block; left: 50%; }
    .grid-line-v:nth-child(7)  { display: block; left: 75%; }
    .grid-line-v:nth-child(8)  { display: block; left: 100%; }
}

@media (min-width: 769px) and (max-width: 1024px) {
    :root {
        --grid-columns: 8;
    }

    .logic-left {
        grid-column: 1 / 6;
    }

    .logic-right {
        grid-column: 4 / 9;
    }

    .logic-shapes-right {
        grid-column: 7 / 9;
    }

    .logic-shapes-left {
        grid-column: 1 / 3;
    }
}
