/* mechanic.stream - Watercolor Sketchbook Aesthetic */
/* Color Palette */
:root {
    --aged-linen: #e8e4df;
    --cool-white: #f4f5f7;
    --deep-slate: #2c3e50;
    --medium-gray: #4a5568;
    --silver-fog: #7b8fa1;
    --cerulean-wash: #5ba4cf;
    --crystal-ice: #a8d8ea;
    --graphite: #94a3b8;
    --midnight-steel: #1e293b;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Source Sans 3', 'Source Sans Pro', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.72;
    color: var(--medium-gray);
    background: var(--aged-linen);
}

/* Desk Surface - the outermost background with dense grain */
.desk-surface {
    min-height: 100vh;
    background-color: var(--aged-linen);
    position: relative;
}

.desk-surface::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23noise)' opacity='0.08'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.5;
}

/* Page Inset - content area with desk surface visible on sides */
.page-inset {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 48px;
    position: relative;
}

/* Title Band */
.title-band {
    position: relative;
    max-height: 200px;
    padding: clamp(24px, 4vw, 48px);
    padding-top: clamp(32px, 5vw, 64px);
    padding-bottom: clamp(24px, 3vw, 40px);
    overflow: hidden;
}

.title-band__wash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 32% 55%, rgba(91,164,207,0.10) 0%, transparent 65%),
        radial-gradient(ellipse at 68% 35%, rgba(168,216,234,0.06) 0%, transparent 55%);
    pointer-events: none;
}

.title-band__content {
    position: relative;
    z-index: 1;
}

.title-band__name {
    font-family: 'Zilla Slab', serif;
    font-weight: 600;
    font-size: clamp(2rem, 5vw, 3.2rem);
    letter-spacing: 0.03em;
    color: var(--deep-slate);
    line-height: 1.1;
}

.title-band__tagline {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--silver-fog);
    margin-top: 8px;
}

/* Stream Description Panel */
.stream-description {
    background: var(--cool-white);
    padding: clamp(24px, 3vw, 48px);
    margin-bottom: clamp(24px, 3vw, 40px);
    position: relative;
    display: flex;
    align-items: center;
    gap: 32px;
    border-radius: 2px;
}

.stream-description::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 128 128' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='128' height='128' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 128px 128px;
    pointer-events: none;
    border-radius: 2px;
}

.stream-description__text {
    flex: 1;
    opacity: 0;
    animation: fadeInDescription 800ms ease-out 200ms forwards;
}

.stream-description__text p {
    margin-bottom: 12px;
}

.stream-description__text p:last-child {
    margin-bottom: 0;
}

.stream-description__diagram {
    flex-shrink: 0;
}

.crystal-small {
    width: 80px;
    height: 80px;
    opacity: 0;
    animation: fadeInDescription 800ms ease-out 400ms forwards;
}

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

/* Portfolio Grid */
.portfolio-grid {
    display: grid;
    grid-template-columns: 1fr 0.85fr 1.15fr;
    gap: clamp(16px, 2.5vw, 32px);
    padding-bottom: clamp(32px, 4vw, 64px);
    position: relative;
}

/* Grid Items */
.grid-item {
    background: var(--cool-white);
    padding: clamp(20px, 2vw, 32px);
    position: relative;
    transform: rotate(var(--tilt, 0deg));
    will-change: transform;
    transition: box-shadow 600ms ease-out;
    border-radius: 2px;
}

.grid-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 128 128' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='128' height='128' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 128px 128px;
    pointer-events: none;
    border-radius: 2px;
}

/* Watercolor wash on alternating items */
.grid-item:nth-child(odd) {
    background:
        radial-gradient(ellipse at 42% 67%, rgba(168,216,234,0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 71% 28%, rgba(91,164,207,0.05) 0%, transparent 50%),
        var(--cool-white);
}

.grid-item:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

/* Pin element */
.grid-item__pin {
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--graphite);
    box-shadow: 0 1px 3px rgba(148,163,184,0.3);
    z-index: 2;
    transition: box-shadow 600ms ease-out;
}

.grid-item:hover .grid-item__pin {
    box-shadow: 0 1px 4px rgba(148,163,184,0.5);
}

/* Diagram wrapper */
.grid-item__diagram-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px 0;
}

.crystal-diagram {
    width: clamp(120px, 15vw, 180px);
    height: clamp(120px, 15vw, 180px);
}

.crystal-morph-circle {
    transition: opacity 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.crystal-morph-shape {
    transition: opacity 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.grid-item.morphed .crystal-morph-circle {
    opacity: 0;
}

.grid-item.morphed .crystal-morph-shape {
    opacity: 1 !important;
}

/* Hover: increase cerulean fill */
.grid-item:hover .crystal-morph-shape polygon:first-child,
.grid-item:hover .crystal-morph-shape rect:first-child {
    fill: rgba(91,164,207,0.18);
    transition: fill 600ms ease-out;
}

.grid-item__title {
    font-family: 'Zilla Slab', serif;
    font-weight: 600;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    letter-spacing: 0.03em;
    color: var(--deep-slate);
    margin-top: 8px;
    text-align: center;
    opacity: 0;
    transition: opacity 400ms ease-out 400ms;
}

.grid-item.morphed .grid-item__title {
    opacity: 1;
}

.grid-item__caption {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--silver-fog);
    text-align: center;
    margin-top: 8px;
    line-height: 1.5;
    opacity: 0;
    transition: opacity 400ms ease-out 600ms;
}

.grid-item.morphed .grid-item__caption {
    opacity: 1;
}

/* Connection Lines SVG */
.connection-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.connection-line {
    stroke: var(--graphite);
    stroke-width: 0.5;
    opacity: 0.3;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 1s ease-out, opacity 0.5s ease-out;
}

.connection-line.visible {
    stroke-dashoffset: 0;
}

.connection-line.hidden {
    opacity: 0;
}

/* Footer Strip */
.footer-strip {
    padding: 0 0 32px 0;
    text-align: center;
}

.footer-strip__rule {
    height: 1px;
    background: linear-gradient(
        to right,
        var(--graphite) 0%,
        rgba(91,164,207,0.4) 50%,
        transparent 100%
    );
    margin-bottom: 16px;
}

.footer-strip__name {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--silver-fog);
    font-variant: small-caps;
}

/* Responsive: Tablet */
@media (max-width: 1024px) {
    .page-inset {
        padding: 0 32px;
    }

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

    .grid-item {
        --tilt: calc(var(--tilt) * 0.5) !important;
    }
}

/* Responsive: Mobile */
@media (max-width: 640px) {
    .page-inset {
        padding: 0 16px;
    }

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

    .grid-item {
        transform: none !important;
        border-left: 4px solid var(--silver-fog);
    }

    .grid-item__pin {
        display: none;
    }

    .stream-description {
        flex-direction: column;
    }

    .stream-description__diagram {
        order: -1;
    }

    .connection-lines {
        display: none;
    }
}
