/* ============================================
   SIM-AI.COM - Neubrutalist Simulation AI
   ============================================ */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 400;
    font-size: clamp(15px, 1.5vw, 18px);
    line-height: 1.7;
    color: #1a1a1a;
    background-color: #f0e8d8;
    overflow-x: hidden;
    position: relative;
}

/* --- Whiteboard Ghost Canvas --- */
#whiteboardCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.03;
}

/* --- Coffee Stain Decorative Elements --- */
body::before {
    content: '';
    position: fixed;
    top: 20%;
    right: 8%;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, #d4a040 0%, transparent 70%);
    opacity: 0.05;
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    bottom: 30%;
    left: 5%;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, #d4a040 0%, transparent 70%);
    opacity: 0.04;
    pointer-events: none;
    z-index: 0;
}

/* --- Paper Texture Overlay --- */
body {
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(58, 54, 50, 0.008) 2px,
            rgba(58, 54, 50, 0.008) 3px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 2px,
            rgba(58, 54, 50, 0.005) 2px,
            rgba(58, 54, 50, 0.005) 3px
        );
}

/* --- Typography --- */
h1, h2, h3 {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.1;
}

h2 {
    font-size: clamp(24px, 3.5vw, 42px);
    font-weight: 700;
}

h3 {
    font-size: clamp(18px, 2vw, 24px);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

code, pre {
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: clamp(13px, 1.3vw, 16px);
}

strong {
    font-weight: 600;
}

em {
    font-style: italic;
}

a {
    color: #d4a040;
    text-decoration: none;
    border-bottom: 2px solid currentColor;
    transition: color 200ms ease;
}

a:hover {
    color: #b85c38;
}

/* --- Floating Mini-Nav --- */
.mini-nav {
    position: fixed;
    top: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #1a1a1a;
    border: 3px solid #1a1a1a;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: transform 200ms ease, box-shadow 200ms ease;
    box-shadow: 3px 3px 0 #3a3632;
}

.mini-nav:hover {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 #3a3632;
}

.mini-nav .dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #f8f4ec;
    display: block;
}

/* --- Nav Overlay --- */
.nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1a1a1a;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 300ms ease;
}

.nav-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.nav-close {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    background: none;
    border: 3px solid #f8f4ec;
    border-radius: 50%;
    color: #f8f4ec;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 200ms ease;
}

.nav-close:hover {
    background: rgba(248, 244, 236, 0.1);
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    text-align: center;
}

.nav-link {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-size: clamp(24px, 4vw, 48px);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #f8f4ec;
    border-bottom: none;
    transition: color 200ms ease;
}

.nav-link:hover {
    color: #d4a040;
}

/* --- Hero Section --- */
.hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    z-index: 1;
    background: #f0e8d8;
}

.hero-border-box {
    border: 4px solid #1a1a1a;
    padding: 3rem 4rem;
    text-align: center;
    position: relative;
    background: #f8f4ec;
    box-shadow: 8px 8px 0 #3a3632;
    /* Initially hidden for animation */
    clip-path: inset(0 100% 100% 0);
    animation: borderReveal 1.2s ease-out 0.5s forwards;
}

@keyframes borderReveal {
    0% {
        clip-path: inset(0 100% 100% 0);
    }
    25% {
        clip-path: inset(0 100% 0 0);
    }
    50% {
        clip-path: inset(0 0 0 0);
    }
    100% {
        clip-path: inset(0 0 0 0);
    }
}

.hero-title {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 800;
    font-size: clamp(60px, 12vw, 160px);
    letter-spacing: 0.06em;
    color: #1a1a1a;
    line-height: 1;
    opacity: 0;
    animation: titleAppear 0.8s ease-out 1.2s forwards;
}

@keyframes titleAppear {
    0% {
        opacity: 0;
        transform: scale(1.1);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.hero-subtitle {
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 400;
    font-size: clamp(14px, 1.8vw, 20px);
    color: #3a3632;
    margin-top: 0.75rem;
    letter-spacing: 0.02em;
    opacity: 0;
    animation: fadeIn 0.6s ease-out 1.8s forwards;
}

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

/* --- Simulation Loop Diagram --- */
.sim-loop-diagram {
    margin-top: 3rem;
    max-width: 600px;
    width: 90%;
    opacity: 0;
    animation: fadeIn 1s ease-out 2s forwards;
}

.sim-loop-svg {
    width: 100%;
    height: auto;
}

.diagram-label {
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    font-weight: 400;
    fill: #1a1a1a;
}

.diagram-label-small {
    font-family: 'Fira Code', monospace;
    font-size: 12px;
    font-weight: 400;
    fill: #1a1a1a;
}

.feedback-label {
    font-size: 11px;
    fill: #3a3632;
}

.sim-arrow {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: drawLine 1.5s ease-out 2.5s forwards;
}

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

.sim-node {
    opacity: 0;
    animation: fadeIn 0.5s ease-out forwards;
}

#nodeInput { animation-delay: 2s; }
#nodeModel { animation-delay: 2.3s; }
#nodeOutput { animation-delay: 2.6s; }

/* --- Tutorial Blocks --- */
.tutorial-block {
    border: 3px solid #1a1a1a;
    box-shadow: 6px 6px 0 #1a1a1a;
    background: #f8f4ec;
    padding: 0;
    margin: 3rem auto;
    max-width: 800px;
    width: 85%;
    position: relative;
    z-index: 1;
    transition: box-shadow 200ms ease, transform 200ms ease;
    opacity: 0;
    transform: translateY(30px);
}

.tutorial-block.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out, box-shadow 200ms ease;
}

.tutorial-block:hover {
    transform: translate(-2px, -2px);
    box-shadow: 8px 8px 0 #1a1a1a;
}

.tutorial-block.visible:hover {
    transform: translate(-2px, -2px);
}

/* Offset stacking */
.offset-left {
    margin-left: 5%;
}

.offset-right {
    margin-left: 15%;
}

@media (max-width: 768px) {
    .offset-left,
    .offset-right {
        margin-left: auto;
        margin-right: auto;
    }
}

/* --- Block Headers --- */
.block-header {
    padding: 1rem 1.5rem;
    border-bottom: 3px solid #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.amber-header {
    background: #d4a040;
}

.sage-header {
    background: #7a9468;
}

.rust-header {
    background: #b85c38;
}

.block-header h2 {
    color: #1a1a1a;
    margin: 0;
    font-size: clamp(20px, 3vw, 32px);
}

/* --- Block Content --- */
.block-content {
    padding: 2rem;
}

.block-content p {
    margin-bottom: 1rem;
}

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

/* --- Stickers --- */
.sticker {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 800;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 4px 10px;
    border: 2px solid #1a1a1a;
    background: #f8f4ec;
    color: #1a1a1a;
    box-shadow: 2px 2px 0 #1a1a1a;
    display: inline-block;
    white-space: nowrap;
    flex-shrink: 0;
}

.sticker-rotate-left {
    transform: rotate(-3deg);
}

.sticker-rotate-right {
    transform: rotate(3deg);
}

/* --- Model Grid --- */
.model-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.model-card {
    border: 2px solid #1a1a1a;
    padding: 1.25rem;
    background: #f0e8d8;
    box-shadow: 3px 3px 0 #3a3632;
    transition: transform 200ms ease, box-shadow 200ms ease;
}

.model-card:hover {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 #3a3632;
}

.model-card h3 {
    font-size: clamp(16px, 1.8vw, 20px);
    margin-bottom: 0.5rem;
    color: #1a1a1a;
}

.model-card p {
    font-size: clamp(13px, 1.3vw, 15px);
    line-height: 1.6;
    color: #3a3632;
}

/* --- Loop Steps --- */
.loop-steps {
    padding-left: 1.5rem;
    margin: 1rem 0;
}

.loop-steps li {
    margin-bottom: 0.75rem;
    padding-left: 0.5rem;
}

.loop-steps li::marker {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 800;
    color: #d4a040;
}

/* --- Gotcha Items --- */
.gotcha-item {
    padding: 1.25rem;
    border: 2px solid #1a1a1a;
    background: #f0e8d8;
    margin-bottom: 1rem;
    border-left: 5px solid #b85c38;
}

.gotcha-item:last-child {
    margin-bottom: 0;
}

.gotcha-item h3 {
    color: #b85c38;
    margin-bottom: 0.5rem;
}

/* --- Code Block --- */
.code-block {
    background: #1a1a1a;
    color: #f0e8d8;
    padding: 1.5rem;
    border: 2px solid #3a3632;
    overflow-x: auto;
    line-height: 1.8;
    margin: 1rem 0;
}

.code-block code {
    color: #f0e8d8;
    font-family: 'Fira Code', monospace;
}

/* Inline code */
p code {
    font-family: 'Fira Code', monospace;
    background: #f0e8d8;
    border: 1px solid #3a3632;
    padding: 2px 6px;
    font-size: 0.9em;
}

/* --- Inline Diagrams --- */
.diagram-inline {
    margin: 1.5rem 0;
    text-align: center;
}

.inline-svg {
    max-width: 400px;
    width: 100%;
    height: auto;
}

.timeline-svg {
    max-width: 500px;
}

/* --- Morph Animations --- */
.morph-shape {
    transition: all 1.5s ease-in-out;
}

.morph-diagram.morphed #morphRect1 {
    rx: 45px;
    ry: 45px;
}

/* --- Future List --- */
.future-list {
    padding-left: 1.5rem;
    margin: 1rem 0;
}

.future-list li {
    margin-bottom: 1rem;
    padding-left: 0.5rem;
}

.future-list li::marker {
    color: #d4a040;
    font-weight: 700;
}

/* --- Footer --- */
.site-footer {
    border-top: 4px solid #1a1a1a;
    background: #1a1a1a;
    color: #f8f4ec;
    padding: 2.5rem 2rem;
    position: relative;
    z-index: 1;
    margin-top: 4rem;
}

.footer-inner {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-brand {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 800;
    font-size: 28px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.footer-tagline {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 14px;
    color: #d4a040;
    letter-spacing: 0.02em;
}

/* --- Sepia Background Fade-In --- */
body {
    animation: sepiaFadeIn 0.5s ease-out forwards;
}

@keyframes sepiaFadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* --- Scrollbar Styling --- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f0e8d8;
}

::-webkit-scrollbar-thumb {
    background: #3a3632;
    border: 2px solid #f0e8d8;
}

::-webkit-scrollbar-thumb:hover {
    background: #1a1a1a;
}

/* --- Responsive Adjustments --- */
@media (max-width: 600px) {
    .hero-border-box {
        padding: 2rem;
    }

    .tutorial-block {
        width: 92%;
    }

    .block-content {
        padding: 1.25rem;
    }

    .model-grid {
        grid-template-columns: 1fr;
    }

    .footer-inner {
        flex-direction: column;
        text-align: center;
    }

    .nav-link {
        font-size: clamp(20px, 5vw, 32px);
    }

    .mini-nav {
        top: 16px;
        right: 16px;
    }
}
