/* ============================
   p9.rs -- styles.css
   Anti-design aesthetic with gradient retro palette
   ============================ */

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

/* Colors:
   Hot pink: #E84070
   Amber energy: #F0A030
   Teal fresh: #30C0A0
   Dark slate: #1A1A2A
   Cream soft: #F8F4F0
   Violet pop: #8050D0
   Light gray: #E8E4E0
*/

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: clamp(15px, 1vw, 17px);
    line-height: 1.75;
    color: #1A1A2A;
    background: linear-gradient(135deg, #E84070 0%, #F0A030 40%, #30C0A0 100%);
    background-attachment: fixed;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================
   SPLASH SECTION
   ============================ */
#splash {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: linear-gradient(135deg, #E84070 0%, #F0A030 35%, #30C0A0 70%, #8050D0 100%);
}

/* Retro zigzag borders */
.retro-border {
    position: absolute;
    left: 0;
    width: 100%;
    height: 40px;
    z-index: 2;
}

#retro-border-top {
    top: 0;
}

#retro-border-bottom {
    bottom: 0;
}

.zigzag-line {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    animation: drawZigzag 800ms ease-out forwards;
}

.zigzag-2 {
    animation-delay: 150ms;
}

.zigzag-3 {
    animation-delay: 300ms;
}

.zigzag-4 {
    animation-delay: 450ms;
}

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

/* Checkerboard patches */
.checkerboard-patch {
    position: absolute;
    width: 80px;
    height: 80px;
    background-image:
        linear-gradient(45deg, rgba(248, 244, 240, 0.15) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(248, 244, 240, 0.15) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(248, 244, 240, 0.15) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(248, 244, 240, 0.15) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    z-index: 1;
    opacity: 0.5;
}

.patch-tl {
    top: 60px;
    left: 30px;
    transform: rotate(5deg);
}

.patch-tr {
    top: 80px;
    right: 40px;
    transform: rotate(-3deg);
    width: 60px;
    height: 60px;
}

.patch-bl {
    bottom: 80px;
    left: 50px;
    transform: rotate(-7deg);
    width: 70px;
    height: 70px;
}

.patch-br {
    bottom: 60px;
    right: 30px;
    transform: rotate(4deg);
}

/* Isometric icons container */
.iso-icons-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.iso-icon {
    position: absolute;
    width: 50px;
    height: 50px;
    opacity: 0;
    animation: fadeInIcon 600ms ease-out forwards;
    transition: transform 300ms ease;
}

.iso-cube {
    top: 15%;
    left: 10%;
    animation-delay: 600ms;
}

.iso-cylinder {
    top: 25%;
    right: 12%;
    width: 45px;
    height: 55px;
    animation-delay: 750ms;
}

.iso-gear {
    bottom: 25%;
    left: 18%;
    width: 55px;
    height: 55px;
    animation-delay: 900ms;
}

.iso-circuit {
    top: 12%;
    left: 55%;
    width: 48px;
    height: 48px;
    animation-delay: 1050ms;
}

.iso-cube-2 {
    bottom: 30%;
    right: 20%;
    width: 42px;
    height: 42px;
    animation-delay: 1200ms;
}

.iso-gear-2 {
    top: 40%;
    left: 35%;
    width: 38px;
    height: 38px;
    animation-delay: 1350ms;
}

@keyframes fadeInIcon {
    from {
        opacity: 0;
        transform: scale(0.5) rotate(-10deg);
    }
    to {
        opacity: 0.7;
        transform: scale(1) rotate(0deg);
    }
}

/* Domain title */
#domain-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(60px, 12vw, 160px);
    color: #F8F4F0;
    text-shadow: 4px 4px 0 rgba(26, 26, 42, 0.15);
    z-index: 3;
    animation: bounceIn 500ms cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    transform: scale(0.8);
    letter-spacing: -2px;
}

@keyframes bounceIn {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    60% {
        transform: scale(1.05);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

#splash-tagline {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(14px, 2vw, 22px);
    color: rgba(248, 244, 240, 0.85);
    z-index: 3;
    margin-top: 8px;
    animation: fadeInUp 600ms 400ms ease-out both;
}

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

/* Scatter dots */
.scatter-dots {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.scatter-dot {
    position: absolute;
    border-radius: 50%;
    opacity: 0.25;
}

/* ============================
   RETRO INTERSTITIALS
   ============================ */
.retro-interstitial {
    width: 100%;
    padding: 12px 0;
    overflow: hidden;
    position: relative;
}

.retro-interstitial .memphis-pattern {
    width: 100%;
    height: 30px;
    display: block;
}

.interstitial-1 {
    background: rgba(248, 244, 240, 0.1);
}

.interstitial-2 {
    background: rgba(26, 26, 42, 0.05);
}

/* ============================
   MASONRY SECTION
   ============================ */
#masonry-section {
    padding: 40px 20px 60px;
    max-width: 1200px;
    margin: 0 auto;
}

#masonry-grid {
    columns: 3;
    column-gap: 12px;
}

/* Masonry blocks */
.masonry-block {
    break-inside: avoid;
    margin-bottom: 12px;
    padding: 24px;
    background: rgba(248, 244, 240, 0.9);
    border-radius: 4px;
    position: relative;
    transition: transform 300ms ease, box-shadow 300ms ease;
}

/* Anti-design misalignment */
.masonry-block:nth-child(3) {
    transform: rotate(1.2deg);
}

.masonry-block:nth-child(6) {
    transform: rotate(-1.5deg);
}

.masonry-block:nth-child(9) {
    transform: rotate(0.8deg);
}

.masonry-block:nth-child(11) {
    transform: rotate(-2deg);
}

/* Hover: straighten misaligned blocks */
.masonry-block:hover {
    transform: rotate(0deg) translateY(-2px);
    box-shadow: 0 8px 24px rgba(26, 26, 42, 0.12);
}

/* Gradient bleed-through: different opacities per position */
.masonry-block:nth-child(1) { background: rgba(248, 244, 240, 0.88); }
.masonry-block:nth-child(2) { background: rgba(248, 244, 240, 0.92); }
.masonry-block:nth-child(3) { background: rgba(248, 244, 240, 0.85); }
.masonry-block:nth-child(4) { background: rgba(248, 244, 240, 0.9); }
.masonry-block:nth-child(5) { background: rgba(248, 244, 240, 0.87); }
.masonry-block:nth-child(6) { background: rgba(248, 244, 240, 0.93); }
.masonry-block:nth-child(7) { background: rgba(248, 244, 240, 0.86); }
.masonry-block:nth-child(8) { background: rgba(248, 244, 240, 0.91); }
.masonry-block:nth-child(9) { background: rgba(248, 244, 240, 0.89); }
.masonry-block:nth-child(10) { background: rgba(248, 244, 240, 0.94); }
.masonry-block:nth-child(11) { background: rgba(248, 244, 240, 0.85); }
.masonry-block:nth-child(12) { background: rgba(248, 244, 240, 0.88); }

/* Anti-design: mismatched padding on some blocks */
.masonry-block:nth-child(4) {
    padding: 18px 30px 28px 16px;
}

.masonry-block:nth-child(7) {
    padding: 30px 20px 16px;
}

.masonry-block:nth-child(11) {
    padding: 14px 24px 32px;
}

/* Block size variants */
.block-wide {
    column-span: none;
}

.block-narrow {
    padding: 20px;
}

.block-medium {
    padding: 28px;
}

.block-code {
    background: rgba(26, 26, 42, 0.92) !important;
    color: #F8F4F0;
    padding: 20px;
}

.block-code:hover {
    background: rgba(26, 26, 42, 0.96) !important;
}

.block-aside {
    border-left: 3px solid #F0A030;
    padding-left: 20px;
}

.block-diagram {
    background: rgba(248, 244, 240, 0.95) !important;
}

/* Typography in blocks */
.masonry-block h2 {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(22px, 3vw, 36px);
    margin-bottom: 12px;
    color: #1A1A2A;
    line-height: 1.2;
}

.masonry-block h3 {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(16px, 2vw, 22px);
    margin-bottom: 10px;
    color: #1A1A2A;
    line-height: 1.3;
}

.block-code h3 {
    color: #F0A030;
}

.masonry-block p {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: clamp(15px, 1vw, 17px);
    line-height: 1.75;
    color: #1A1A2A;
}

.block-code p {
    color: #E8E4E0;
}

.aside-text {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-style: italic;
    font-size: 13px !important;
    color: #1A1A2A;
    opacity: 0.85;
}

/* Code blocks */
.masonry-block pre {
    overflow-x: auto;
    margin: 0;
}

.masonry-block code {
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.6;
    display: block;
}

/* Code syntax coloring */
.kw { color: #E84070; }
.fn-name { color: #30C0A0; }
.str { color: #F0A030; }
.comment { color: #8050D0; opacity: 0.7; }

/* Lists */
.masonry-block ul {
    list-style: none;
    padding: 0;
}

.masonry-block li {
    padding: 6px 0;
    padding-left: 20px;
    position: relative;
    font-family: 'Nunito', sans-serif;
}

.masonry-block li::before {
    content: '>';
    position: absolute;
    left: 0;
    color: #E84070;
    font-weight: 800;
}

/* Big number stat */
.big-number {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(36px, 5vw, 56px) !important;
    color: #E84070 !important;
    line-height: 1.1 !important;
    margin-bottom: 4px !important;
}

.unit {
    font-size: 0.4em;
    color: #30C0A0;
    font-weight: 600;
}

/* Diagram */
.ascii-diagram {
    background: rgba(26, 26, 42, 0.06);
    border-radius: 4px;
    padding: 16px;
    overflow-x: auto;
}

.ascii-diagram pre {
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    font-size: 12px;
    line-height: 1.5;
    color: #1A1A2A;
    white-space: pre;
}

/* Underline-draw animation */
.underline-draw {
    position: relative;
    display: inline;
}

.underline-draw::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 3px;
    border-radius: 2px;
    transition: width 300ms ease;
}

.underline-draw.visible::after {
    width: 100%;
}

/* Alternating underline colors */
.masonry-block:nth-child(odd) .underline-draw::after {
    background: #E84070;
}

.masonry-block:nth-child(even) .underline-draw::after {
    background: #30C0A0;
}

.masonry-block:nth-child(3n) .underline-draw::after {
    background: #8050D0;
}

/* Underline-draw hover highlight */
.underline-draw:hover {
    background-color: rgba(240, 160, 48, 0.15);
}

/* Masonry block entry animations */
.masonry-block {
    opacity: 0;
}

.masonry-block.anim-slide-left {
    animation: slideLeft 500ms ease-out forwards;
}

.masonry-block.anim-fade-up {
    animation: fadeUp 500ms ease-out forwards;
}

.masonry-block.anim-snap {
    animation: snapIn 100ms linear forwards;
}

@keyframes slideLeft {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

@keyframes snapIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Preserve misalignment on animated blocks */
.masonry-block:nth-child(3).anim-slide-left,
.masonry-block:nth-child(3).anim-fade-up,
.masonry-block:nth-child(3).anim-snap {
    animation-name: slideLeftRotated1;
}

.masonry-block:nth-child(6).anim-slide-left,
.masonry-block:nth-child(6).anim-fade-up,
.masonry-block:nth-child(6).anim-snap {
    animation-name: fadeUpRotated2;
}

.masonry-block:nth-child(9).anim-slide-left,
.masonry-block:nth-child(9).anim-fade-up,
.masonry-block:nth-child(9).anim-snap {
    animation-name: slideLeftRotated3;
}

.masonry-block:nth-child(11).anim-slide-left,
.masonry-block:nth-child(11).anim-fade-up,
.masonry-block:nth-child(11).anim-snap {
    animation-name: snapRotated4;
}

@keyframes slideLeftRotated1 {
    from { opacity: 0; transform: translateX(-40px) rotate(1.2deg); }
    to { opacity: 1; transform: translateX(0) rotate(1.2deg); }
}

@keyframes fadeUpRotated2 {
    from { opacity: 0; transform: translateY(30px) rotate(-1.5deg); }
    to { opacity: 1; transform: translateY(0) rotate(-1.5deg); }
}

@keyframes slideLeftRotated3 {
    from { opacity: 0; transform: translateX(-40px) rotate(0.8deg); }
    to { opacity: 1; transform: translateX(0) rotate(0.8deg); }
}

@keyframes snapRotated4 {
    from { opacity: 0; transform: rotate(-2deg); }
    to { opacity: 1; transform: rotate(-2deg); }
}

/* ============================
   FOOTER / PLAYGROUND
   ============================ */
#playground {
    max-width: 700px;
    margin: 0 auto 60px;
    background: rgba(26, 26, 42, 0.95);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(26, 26, 42, 0.3);
}

.playground-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(26, 26, 42, 1);
    border-bottom: 1px solid rgba(232, 228, 224, 0.1);
}

.playground-dots {
    display: flex;
    gap: 6px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot-red { background: #E84070; }
.dot-yellow { background: #F0A030; }
.dot-green { background: #30C0A0; }

.playground-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    font-size: 13px;
    color: #E8E4E0;
    opacity: 0.7;
}

.playground-body {
    padding: 24px;
}

.playground-body code {
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.7;
    color: #F8F4F0;
}

.playground-footer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-top: 1px solid rgba(232, 228, 224, 0.1);
}

.iso-footer-icons {
    display: flex;
    gap: 12px;
}

.iso-icon-sm {
    width: 24px;
    height: 24px;
    opacity: 0.6;
    transition: transform 300ms ease, opacity 300ms ease;
}

.iso-icon-sm:hover {
    opacity: 1;
    transform: rotate(15deg);
}

.footer-note {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-style: italic;
    font-size: 12px;
    color: #E8E4E0;
    opacity: 0.5;
}

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 900px) {
    #masonry-grid {
        columns: 2;
    }
}

@media (max-width: 560px) {
    #masonry-grid {
        columns: 1;
    }

    .checkerboard-patch {
        display: none;
    }

    .iso-icon {
        width: 35px;
        height: 35px;
    }

    #playground {
        margin-left: 12px;
        margin-right: 12px;
    }

    .playground-footer-bar {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}

/* ============================
   SCROLL HUE SHIFT
   ============================ */
body.hue-shift-1 {
    filter: hue-rotate(2deg);
}

body.hue-shift-2 {
    filter: hue-rotate(5deg);
}

body.hue-shift-3 {
    filter: hue-rotate(8deg);
}

/* Retro interstitial slight speed offset (handled in JS via transform) */
.retro-interstitial {
    will-change: transform;
}
