/* ==========================================
   haru.club - Urban Sketches Portfolio
   Hand-drawn isometric city illustrations
   ========================================== */

:root {
    /* Color Palette - Terracotta Warm */
    --color-primary-terracotta: #C4663A;
    --color-deep-terracotta: #8B3A1F;
    --color-warm-sand: #FAF0E6;
    --color-cream-paper: #FFF8F0;
    --color-ochre-accent: #D4A04A;
    --color-sage-green: #7A8B6F;
    --color-ink-dark: #2C1810;
    --color-warm-gray: #6B5B4F;
    --color-dusty-rose: #C49B8A;
    --color-muted-tan: #9E7B5A;

    /* Typography */
    --font-handwritten: 'Caveat', cursive;
    --font-body: 'Source Sans 3', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;

    /* Spacing */
    --spacing-unit: 1rem;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background-color: var(--color-warm-sand);
    color: var(--color-ink-dark);
    line-height: 1.65;
    overflow-x: hidden;
}

/* ==========================================
   Navigation Bar
   ========================================== */

.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background-color: var(--color-cream-paper);
    border-bottom: 2px solid var(--color-primary-terracotta);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.navbar-brand {
    font-family: var(--font-handwritten);
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 700;
    color: var(--color-deep-terracotta);
    letter-spacing: 0.01em;
}

.navbar-filters {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-pill {
    font-family: var(--font-handwritten);
    font-size: 1rem;
    font-weight: 400;
    padding: 0.5rem 1rem;
    background-color: transparent;
    border: 2px solid var(--color-primary-terracotta);
    color: var(--color-primary-terracotta);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.filter-pill:hover {
    background-color: var(--color-primary-terracotta);
    color: var(--color-cream-paper);
}

.filter-pill.active {
    background-color: var(--color-primary-terracotta);
    color: var(--color-cream-paper);
}

/* ==========================================
   Hero Section
   ========================================== */

.hero {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: var(--color-warm-sand);
    overflow: hidden;
    padding: 2rem;
}

.hero-svg {
    position: absolute;
    width: 90%;
    max-width: 800px;
    height: auto;
    opacity: 0.95;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -55%);
}

.hero-element {
    animation: fadeIn 0.8s ease-out forwards;
}

.draw-path {
    animation: drawStroke 3s ease-in-out forwards;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
}

.draw-path:nth-of-type(1) { animation-delay: 0s; }
.draw-path:nth-of-type(2) { animation-delay: 0.3s; }
.draw-path:nth-of-type(3) { animation-delay: 0.6s; }

.fill-element {
    animation: fillWash 0.5s ease-out forwards;
    animation-delay: inherit;
    opacity: 0;
}

@keyframes drawStroke {
    from {
        stroke-dashoffset: 100;
        opacity: 1;
    }
    to {
        stroke-dashoffset: 0;
        opacity: 1;
    }
}

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

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

.hero-title {
    position: absolute;
    bottom: 8rem;
    font-family: var(--font-handwritten);
    font-size: clamp(2.5rem, 7vw, 5rem);
    font-weight: 700;
    color: var(--color-deep-terracotta);
    letter-spacing: 0.01em;
    text-align: center;
    z-index: 10;
    animation: fadeInUp 1s ease-out 0.5s backwards;
}

.hero-subtitle {
    position: absolute;
    bottom: 5rem;
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    color: var(--color-warm-gray);
    letter-spacing: 0.02em;
    text-align: center;
    z-index: 10;
    animation: fadeInUp 1s ease-out 0.8s backwards;
}

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

.site-name-text {
    animation: fillWash 0.5s ease-out forwards;
    animation-delay: 1.8s;
}

/* ==========================================
   Portfolio Section
   ========================================== */

.portfolio {
    padding: 4rem 2rem;
    background-color: var(--color-warm-sand);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    grid-auto-rows: 80px;
    gap: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* ==========================================
   Tiles
   ========================================== */

.tile {
    position: relative;
    background-color: var(--color-cream-paper);
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(139, 58, 31, 0.03) 2px, rgba(139, 58, 31, 0.03) 4px);
    border: none;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.4s ease;
    border-radius: 2px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.tile::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.3), transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
    pointer-events: none;
}

.tile:hover::before {
    opacity: 0.5;
}

.tile-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.tile-path {
    animation: drawStrokeTile 0.8s ease-out forwards;
}

.tile-fill {
    animation: fillWash 0.5s ease-out forwards;
    animation-delay: 0.3s;
}

@keyframes drawStrokeTile {
    from {
        stroke-dashoffset: 100;
        opacity: 1;
    }
    to {
        stroke-dashoffset: 0;
        opacity: 1;
    }
}

/* Staggered drop-in animation for tiles */
.tile {
    animation: dropIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
    opacity: 0;
}

@keyframes dropIn {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }
    60% {
        transform: translateY(3px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.tile:nth-child(1) { animation-delay: 0.04s; }
.tile:nth-child(2) { animation-delay: 0.08s; }
.tile:nth-child(3) { animation-delay: 0.12s; }
.tile:nth-child(4) { animation-delay: 0.16s; }
.tile:nth-child(5) { animation-delay: 0.20s; }
.tile:nth-child(6) { animation-delay: 0.24s; }
.tile:nth-child(7) { animation-delay: 0.28s; }
.tile:nth-child(8) { animation-delay: 0.32s; }
.tile:nth-child(9) { animation-delay: 0.36s; }
.tile:nth-child(10) { animation-delay: 0.40s; }
.tile:nth-child(11) { animation-delay: 0.44s; }
.tile:nth-child(12) { animation-delay: 0.48s; }

/* Hover micro-shake */
.tile:hover {
    animation: microShake 0.15s ease-in-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

@keyframes microShake {
    0%, 100% {
        transform: translateX(0) rotate(0deg);
    }
    25% {
        transform: translateX(-1px) rotate(-0.5deg);
    }
    75% {
        transform: translateX(1px) rotate(0.5deg);
    }
}

/* Tile annotations */
.tile-annotation {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.5rem 0.6rem;
    background: linear-gradient(to top, rgba(250, 240, 230, 0.95), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 2;
}

.tile:hover .tile-annotation {
    opacity: 1;
}

.tile-annotation p {
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--color-ink-dark);
    line-height: 1.3;
    margin: 0;
}

.tile-meta {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--color-muted-tan);
    margin-top: 0.2rem;
}

/* Shake animation for filtered-out tiles */
@keyframes shakeOut {
    0%, 100% {
        transform: translateX(0) rotate(0deg);
        opacity: 1;
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-4px) rotate(-1deg);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(4px) rotate(1deg);
    }
}

.tile.shake-out {
    animation: shakeOut 0.3s ease-in-out forwards;
}

.tile.hidden {
    animation: fadeOutTile 0.4s ease-out forwards;
}

@keyframes fadeOutTile {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* Expand tile overlay */
.tile-expanded {
    position: fixed;
    inset: 2rem;
    z-index: 1000;
    background-color: var(--color-cream-paper);
    border: 3px solid var(--color-primary-terracotta);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    animation: expandTile 0.4s ease-out;
    padding: 2rem;
    overflow-y: auto;
}

@keyframes expandTile {
    from {
        transform: scale(0.9) translate(0, 20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translate(0, 0);
        opacity: 1;
    }
}

.tile-expanded-content {
    display: flex;
    gap: 2rem;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.tile-expanded-svg {
    width: 100%;
    max-width: 400px;
    height: auto;
    flex: 1;
}

.tile-expanded-annotations {
    flex: 1;
    min-width: 250px;
}

.tile-expanded-annotations h2 {
    font-family: var(--font-handwritten);
    font-size: 2rem;
    color: var(--color-deep-terracotta);
    margin-bottom: 1rem;
}

.tile-expanded-annotations p {
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--color-ink-dark);
    margin-bottom: 0.5rem;
}

.annotation-arrow {
    position: absolute;
    width: 30px;
    height: 30px;
}

/* Close button for expanded tile */
.tile-close {
    position: absolute;
    top: 2rem;
    right: 2rem;
    width: 40px;
    height: 40px;
    background: none;
    border: 2px solid var(--color-primary-terracotta);
    border-radius: 50%;
    font-size: 1.5rem;
    color: var(--color-primary-terracotta);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
}

.tile-close:hover {
    background-color: var(--color-primary-terracotta);
    color: var(--color-cream-paper);
}

/* ==========================================
   Scroll Hint
   ========================================== */

.scroll-hint {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-handwritten);
    font-size: 0.9rem;
    color: var(--color-warm-gray);
    opacity: 0.6;
    animation: fadeInOut 3s ease-in-out infinite;
    z-index: 50;
    pointer-events: none;
}

@keyframes fadeInOut {
    0%, 100% {
        opacity: 0.3;
        transform: translateX(-50%) translateY(0);
    }
    50% {
        opacity: 0.7;
        transform: translateX(-50%) translateY(-10px);
    }
}

/* ==========================================
   Responsive Design
   ========================================== */

@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .navbar-filters {
        justify-content: center;
        gap: 0.5rem;
    }

    .filter-pill {
        font-size: 0.9rem;
        padding: 0.4rem 0.8rem;
    }

    .hero {
        height: 80vh;
    }

    .hero-title {
        bottom: 5rem;
        font-size: clamp(1.8rem, 5vw, 3rem);
    }

    .grid {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
        gap: 1rem;
    }

    .tile {
        aspect-ratio: 16 / 9;
    }

    .tile-expanded {
        inset: 1rem;
        padding: 1rem;
    }

    .tile-expanded-content {
        flex-direction: column;
        gap: 1rem;
    }

    .tile-close {
        top: 1rem;
        right: 1rem;
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .navbar {
        padding: 0.8rem;
    }

    .navbar-brand {
        font-size: 1.2rem;
    }

    .navbar-filters {
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .filter-pill {
        font-size: 0.8rem;
        padding: 0.3rem 0.6rem;
    }

    .hero-subtitle {
        bottom: 3rem;
        font-size: 0.9rem;
    }

    .portfolio {
        padding: 2rem 1rem;
    }

    .scroll-hint {
        bottom: 1rem;
        font-size: 0.8rem;
    }
}

/* ==========================================
   Paper Texture & Details
   ========================================== */

.portfolio::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="4" result="noise" /></filter><rect width="100" height="100" fill="%23FAF0E6" filter="url(%23noise)" opacity="0.03"/></svg>');
    pointer-events: none;
    z-index: -1;
}
