/* ============================================
   adhoc.quest - Styles
   Anti-design collage pinboard aesthetic
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Palette */
    --canvas-base: #f4efe6;
    --card-surface: #fffef9;
    --primary-ink: #2a2a28;
    --secondary-ink: #7b6b5d;
    --washi-red: #c84b31;
    --stamp-blue: #2d5f8a;
    --mustard-yellow: #d4a843;
    --sage-green: #6b8f71;
    --shadow-tone: #b8a99a;
    --deep-ground: #3d3429;

    /* Tear patterns (clip-path polygons for torn paper edges) */
    --tear-1: polygon(2% 0%, 98% 1%, 97% 3%, 100% 5%, 99% 15%, 100% 25%, 98% 35%, 100% 45%, 99% 55%, 100% 65%, 97% 75%, 100% 85%, 98% 95%, 99% 100%, 1% 99%, 0% 97%, 2% 90%, 0% 82%, 1% 73%, 0% 64%, 2% 55%, 0% 46%, 1% 37%, 0% 28%, 2% 19%, 0% 10%);
    --tear-2: polygon(0% 2%, 3% 0%, 10% 2%, 18% 0%, 25% 1%, 33% 0%, 40% 2%, 48% 0%, 55% 1%, 63% 0%, 70% 2%, 78% 0%, 85% 1%, 93% 0%, 100% 2%, 98% 10%, 100% 20%, 99% 30%, 100% 40%, 98% 50%, 100% 60%, 99% 70%, 100% 80%, 98% 90%, 100% 98%, 97% 100%, 90% 98%, 82% 100%, 74% 99%, 66% 100%, 58% 98%, 50% 100%, 42% 99%, 34% 100%, 26% 98%, 18% 100%, 10% 99%, 3% 100%, 0% 98%);
    --tear-3: polygon(1% 0%, 8% 2%, 15% 0%, 23% 1%, 30% 0%, 38% 2%, 45% 0%, 53% 1%, 60% 0%, 68% 2%, 75% 0%, 83% 1%, 90% 0%, 98% 2%, 100% 0%, 99% 8%, 100% 18%, 98% 28%, 100% 38%, 99% 48%, 100% 58%, 98% 68%, 100% 78%, 99% 88%, 100% 100%, 92% 99%, 84% 100%, 76% 98%, 68% 100%, 60% 99%, 52% 100%, 44% 98%, 36% 100%, 28% 99%, 20% 100%, 12% 98%, 4% 100%, 0% 99%);
    --tear-4: polygon(0% 1%, 5% 0%, 12% 3%, 20% 0%, 28% 2%, 35% 0%, 43% 1%, 50% 0%, 58% 3%, 65% 0%, 73% 2%, 80% 0%, 88% 1%, 95% 0%, 100% 3%, 98% 12%, 100% 22%, 97% 32%, 100% 42%, 98% 52%, 100% 62%, 97% 72%, 100% 82%, 98% 92%, 100% 100%, 95% 98%, 87% 100%, 79% 97%, 71% 100%, 63% 98%, 55% 100%, 47% 97%, 39% 100%, 31% 98%, 23% 100%, 15% 97%, 7% 100%, 0% 98%);
    --tear-5: polygon(2% 0%, 10% 1%, 17% 0%, 25% 3%, 32% 0%, 40% 1%, 47% 0%, 55% 2%, 62% 0%, 70% 1%, 77% 0%, 85% 3%, 92% 0%, 100% 1%, 99% 10%, 100% 20%, 98% 30%, 100% 40%, 99% 50%, 100% 60%, 98% 70%, 100% 80%, 99% 90%, 98% 100%, 90% 99%, 82% 100%, 74% 98%, 66% 100%, 58% 99%, 50% 100%, 42% 98%, 34% 100%, 26% 99%, 18% 100%, 10% 98%, 2% 100%, 0% 99%, 1% 88%, 0% 78%, 2% 68%, 0% 58%, 1% 48%, 0% 38%, 2% 28%, 0% 18%, 1% 8%);
    --tear-6: polygon(0% 0%, 7% 2%, 14% 0%, 22% 1%, 29% 0%, 37% 3%, 44% 0%, 52% 1%, 59% 0%, 67% 2%, 74% 0%, 82% 1%, 89% 0%, 97% 3%, 100% 0%, 100% 7%, 98% 17%, 100% 27%, 98% 37%, 100% 47%, 98% 57%, 100% 67%, 98% 77%, 100% 87%, 98% 97%, 100% 100%, 93% 98%, 85% 100%, 77% 98%, 69% 100%, 61% 98%, 53% 100%, 45% 98%, 37% 100%, 29% 98%, 21% 100%, 13% 98%, 5% 100%, 0% 98%);
    --tear-7: polygon(1% 0%, 9% 3%, 16% 0%, 24% 2%, 31% 0%, 39% 1%, 46% 0%, 54% 3%, 61% 0%, 69% 2%, 76% 0%, 84% 1%, 91% 0%, 99% 2%, 100% 5%, 98% 15%, 100% 25%, 97% 35%, 100% 45%, 98% 55%, 100% 65%, 97% 75%, 100% 85%, 98% 95%, 100% 100%, 91% 97%, 83% 100%, 75% 97%, 67% 100%, 59% 97%, 51% 100%, 43% 97%, 35% 100%, 27% 97%, 19% 100%, 11% 97%, 3% 100%, 0% 97%);
    --tear-8: polygon(0% 2%, 6% 0%, 13% 2%, 21% 0%, 28% 3%, 36% 0%, 43% 2%, 51% 0%, 58% 3%, 66% 0%, 73% 2%, 81% 0%, 88% 3%, 96% 0%, 100% 2%, 99% 12%, 100% 22%, 98% 32%, 100% 42%, 99% 52%, 100% 62%, 98% 72%, 100% 82%, 99% 92%, 97% 100%, 89% 98%, 81% 100%, 73% 98%, 65% 100%, 57% 98%, 49% 100%, 41% 98%, 33% 100%, 25% 98%, 17% 100%, 9% 98%, 1% 100%, 0% 97%);
}

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

html {
    overflow: hidden;
    height: 100%;
    width: 100%;
}

body {
    font-family: 'Libre Baskerville', serif;
    color: var(--primary-ink);
    background: var(--canvas-base);
    overflow: hidden;
    height: 100%;
    width: 100%;
}

/* --- Canvas (2D scrollable pinboard) --- */
#canvas {
    position: relative;
    width: 250vw;
    height: 220vh;
    overflow: auto;
    background-color: var(--canvas-base);
    /* Paper grain texture via SVG noise */
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    cursor: grab;
}

#canvas:active {
    cursor: grabbing;
}

/* Actual scrollable wrapper on body */
body {
    overflow: auto;
}

html {
    overflow: auto;
}

#canvas {
    min-width: 250vw;
    min-height: 220vh;
}

/* --- Watermark Letters --- */
.watermark {
    position: absolute;
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    color: var(--primary-ink);
    opacity: 0.04;
    pointer-events: none;
    user-select: none;
    z-index: 1;
    line-height: 1;
}

/* --- Coffee Ring Stains --- */
.coffee-ring {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, transparent 55%, var(--shadow-tone) 56%, var(--shadow-tone) 60%, transparent 61%);
    opacity: 0.08;
    pointer-events: none;
    z-index: 2;
}

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

.connector-line {
    fill: none;
    stroke: var(--shadow-tone);
    stroke-width: 1;
    stroke-dasharray: 8 6;
    opacity: 0.2;
    animation: marchingAnts 40s linear infinite;
}

@keyframes marchingAnts {
    to {
        stroke-dashoffset: -560;
    }
}

/* --- Navigation Pins --- */
.nav-pin {
    position: fixed;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #e8735e, var(--washi-red) 60%, #a03a22);
    color: var(--card-surface);
    font-family: 'Azeret Mono', monospace;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.25), 0 1px 2px rgba(0,0,0,0.15);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    user-select: none;
}

.nav-pin:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
}

.nav-pin.active {
    background: radial-gradient(circle at 35% 35%, #5a8fbf, var(--stamp-blue) 60%, #1d4060);
    transform: scale(1.2);
}

/* --- Clusters --- */
.cluster {
    position: absolute;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.cluster.dimmed {
    opacity: 0.4;
    transform: scale(0.95);
}

/* --- Cards --- */
.card {
    position: absolute;
    background: var(--card-surface);
    padding: 28px 24px;
    transform: rotate(var(--rotate, 0deg));
    z-index: var(--z, 10);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.4s ease,
                opacity 0.4s ease;
    will-change: transform;
}

/* Card sizes */
.card-large {
    width: 340px;
    min-height: 240px;
    box-shadow: 0 4px 16px rgba(61, 52, 41, 0.12), 0 2px 6px rgba(61, 52, 41, 0.08);
}

.card-medium {
    width: 300px;
    min-height: 180px;
    box-shadow: 0 3px 12px rgba(61, 52, 41, 0.1), 0 1px 4px rgba(61, 52, 41, 0.06);
}

.card-small {
    width: 220px;
    min-height: 120px;
    box-shadow: 0 2px 8px rgba(61, 52, 41, 0.08), 0 1px 3px rgba(61, 52, 41, 0.05);
}

.card-tiny {
    width: 160px;
    min-height: 70px;
    padding: 16px 14px;
    box-shadow: 0 1px 6px rgba(61, 52, 41, 0.08);
}

/* Card depth shadows based on z-index */
.card[style*="--z: 40"] {
    box-shadow: 0 8px 24px rgba(61, 52, 41, 0.15), 0 3px 8px rgba(61, 52, 41, 0.1);
    transform: rotate(var(--rotate, 0deg)) scale(1.02);
}

.card[style*="--z: 30"] {
    box-shadow: 0 5px 16px rgba(61, 52, 41, 0.12), 0 2px 6px rgba(61, 52, 41, 0.08);
}

.card[style*="--z: 20"] {
    box-shadow: 0 3px 10px rgba(61, 52, 41, 0.1), 0 1px 4px rgba(61, 52, 41, 0.06);
}

.card[style*="--z: 10"] {
    box-shadow: 0 2px 6px rgba(61, 52, 41, 0.08), 0 1px 2px rgba(61, 52, 41, 0.04);
}

/* Card hover lift (enhanced by JS tilt) */
.card:hover {
    z-index: 50 !important;
    box-shadow: 0 12px 32px rgba(61, 52, 41, 0.2), 0 4px 12px rgba(61, 52, 41, 0.12);
}

/* Card types */
.card-accent {
    background: var(--mustard-yellow);
    color: var(--primary-ink);
}

.card-note {
    background: var(--card-surface);
    border-left: 3px solid var(--mustard-yellow);
}

.card-green {
    background: #e8f0ea;
    border-left: 3px solid var(--sage-green);
}

.card-stamp {
    background: var(--card-surface);
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    justify-content: center;
}

/* Torn paper edges via clip-path */
.card-tear-1 { clip-path: var(--tear-1); }
.card-tear-2 { clip-path: var(--tear-2); }
.card-tear-3 { clip-path: var(--tear-3); }
.card-tear-4 { clip-path: var(--tear-4); }
.card-tear-5 { clip-path: var(--tear-5); }
.card-tear-6 { clip-path: var(--tear-6); }
.card-tear-7 { clip-path: var(--tear-7); }
.card-tear-8 { clip-path: var(--tear-8); }

/* --- Typography --- */
.card-title {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(1.8rem, 5vw, 3.6rem);
    line-height: 1.1;
    text-shadow: 0.5px 0.5px 0 rgba(0,0,0,0.15);
    margin-bottom: 12px;
    color: var(--primary-ink);
}

.card-subtitle {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: 1.5rem;
    text-shadow: 0.5px 0.5px 0 rgba(0,0,0,0.15);
    margin-bottom: 8px;
    color: var(--primary-ink);
}

.card-body {
    font-family: 'Libre Baskerville', serif;
    font-weight: 400;
    font-size: 15px;
    line-height: 1.7;
    color: var(--primary-ink);
}

.card-annotation {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: 1.2rem;
    line-height: 1.4;
    color: var(--secondary-ink);
    text-shadow: 0.5px 0.5px 0 rgba(0,0,0,0.1);
}

.stamp-label {
    font-family: 'Azeret Mono', monospace;
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--secondary-ink);
}

/* --- Washi Tape Strips --- */
.washi-tape {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%) rotate(var(--tape-rotate, 0deg));
    width: 100px;
    height: 24px;
    z-index: 5;
    background-image: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 4px,
        rgba(255,255,255,0.08) 4px,
        rgba(255,255,255,0.08) 5px
    );
    backdrop-filter: saturate(1.1);
    transition: transform 0.2s ease;
}

.washi-red {
    background-color: rgba(200, 75, 49, 0.7);
}

.washi-yellow {
    background-color: rgba(212, 168, 67, 0.7);
}

/* Tape lift on card hover */
.card:hover .washi-tape {
    transform: translateX(-50%) rotate(var(--tape-rotate, 0deg)) translateY(-2px);
}

.card:hover {
    margin-top: 1px;
}

/* --- Push Pins --- */
.push-pin {
    position: absolute;
    top: -10px;
    right: 20px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: radial-gradient(circle at 38% 35%, #e8735e, var(--washi-red) 55%, #8b2f1d 100%);
    box-shadow: 0 2px 3px rgba(0,0,0,0.3);
    z-index: 6;
}

.push-pin::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, rgba(255,255,255,0.5), transparent);
}

/* --- Rubber Stamps --- */
.stamp {
    display: inline-block;
    font-family: 'Azeret Mono', monospace;
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 4px 10px;
    border: 2px solid;
    border-radius: 2px;
    transform: rotate(var(--stamp-rotate, 0deg));
    margin-top: 12px;
    filter: blur(0.3px) contrast(1.5);
}

.stamp-blue {
    color: var(--stamp-blue);
    border-color: var(--stamp-blue);
    opacity: 0.7;
}

/* Stamp entrance animation */
.stamp.stamp-hidden {
    opacity: 0;
    transform: rotate(var(--stamp-rotate, 0deg)) scale(1.3);
}

.stamp.stamp-reveal {
    animation: stampIn 0.45s ease-out forwards;
}

@keyframes stampIn {
    0% {
        opacity: 0;
        transform: rotate(var(--stamp-rotate, 0deg)) scale(1.3);
    }
    33% {
        opacity: 0;
        transform: rotate(var(--stamp-rotate, 0deg)) scale(1.0);
    }
    100% {
        opacity: 0.7;
        transform: rotate(var(--stamp-rotate, 0deg)) scale(1.0);
    }
}

/* --- Scroll Hint (mobile) --- */
.scroll-hint {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--secondary-ink);
    font-family: 'Azeret Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.6;
    z-index: 999;
    animation: scrollBounce 2s ease-in-out infinite;
}

.scroll-hint.visible {
    display: flex;
}

@keyframes scrollBounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-6px); }
}

/* --- Responsive / Mobile --- */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        overflow-y: auto;
    }

    #canvas {
        width: 100vw;
        min-width: 100vw;
        max-width: 100vw;
        height: auto;
        min-height: auto;
        padding: 20px 10px 60px;
        display: flex;
        flex-direction: column;
        gap: 40px;
        overflow: visible;
    }

    .cluster {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        display: flex;
        flex-direction: column;
        gap: 16px;
        padding: 10px;
    }

    .card {
        position: relative !important;
        left: auto !important;
        top: auto !important;
        width: calc(100vw - 40px) !important;
        min-height: auto !important;
        max-width: 400px;
        margin: 0 auto;
    }

    .connectors {
        display: none;
    }

    /* Replace connector lines with dashed vertical borders between clusters */
    .cluster + .cluster {
        border-top: 1px dashed var(--shadow-tone);
        padding-top: 40px;
    }

    .watermark {
        display: none;
    }

    .coffee-ring {
        display: none;
    }

    .nav-pin {
        position: relative;
        display: inline-flex;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
    }

    /* Cluster nav pins into a row at top */
    .nav-pin {
        display: none;
    }

    .scroll-hint.visible {
        display: flex;
    }
}

/* --- Selection color --- */
::selection {
    background: var(--mustard-yellow);
    color: var(--primary-ink);
}
