/* CSS Variables for easy theming and a modern look */
:root {
    --background-color: #111827; /* Dark blue-gray */
    --surface-color: #1F2937;    /* Lighter gray for cards */
    --primary-color: #818CF8;     /* Soft purple */
    --secondary-color: #34D399;   /* Vibrant green */
    --text-color: #E5E7EB;       /* Off-white */
    --text-muted-color: #9CA3AF; /* Gray for subtitles */
    --font-main: 'Inter', sans-serif;
}

/* Basic Reset and Body Styling */
body {
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: var(--font-main);
    margin: 0;
    padding: 2rem;
    text-align: center;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
    z-index: 1;
}

/* Animated Background Canvas */
#pi-stream-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

header, main, footer {
    position: relative;
    z-index: 2;
}

/* Header Styling */
header {
    margin-bottom: 4rem;
}

h1 {
    font-size: clamp(2.5rem, 5vw, 3.5rem);
    color: var(--text-color);
    font-weight: 700;
    letter-spacing: -1px;
}

h1 .pi-symbol {
    color: var(--primary-color);
    font-weight: 700;
}

h1 .domain-name {
    font-size: clamp(0.8rem, 2vw, 1rem);
    color: var(--text-muted-color);
    font-weight: 400;
    display: block;
    margin-top: 0.5rem;
    word-break: break-all;
}

/* Project Grid */
#pi-tapestry {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

.pi-quartet {
    background-color: var(--surface-color);
    padding: 1.5rem 1rem;
    border-radius: 12px;
    font-size: 1.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out, border-color 0.2s ease-out;
    border: 1px solid #374151;
    opacity: 0;
    transform: translateY(20px);
    animation: reveal 0.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.pi-quartet:hover {
    transform: translateY(-8px);
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.3), 0 0 15px -3px var(--primary-color);
    border-color: var(--primary-color);
}

@keyframes reveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Footer credits */
footer {
    margin-top: 5rem;
    font-size: 0.9rem;
    color: var(--text-muted-color);
}

footer a {
    color: var(--secondary-color);
    text-decoration: none;
}
footer a:hover {
    text-decoration: underline;
}

/* --- Modal Styles --- */
#modal-backdrop {
    position: fixed;
    z-index: 100;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(8px);
    display: none; 
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#modal-backdrop.visible {
    display: flex;
    opacity: 1;
}

#project-modal {
    background-color: var(--surface-color);
    padding: 2.5rem;
    border-radius: 16px;
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    border: 1px solid #374151;
    text-align: left;
}

#modal-backdrop.visible #project-modal {
    transform: scale(1) translateY(0);
}

#modal-close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: var(--text-muted-color);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
    z-index: 10;
}

#modal-close-btn:hover {
    color: var(--text-color);
    transform: rotate(90deg);
}

/* Media Viewer (Carousel) Styles */
#modal-media-viewer {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    background-color: #111827;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 2rem;
}

#modal-media-viewer img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    opacity: 0;
    transition: opacity 0.4s ease;
}

#modal-media-viewer img.active {
    opacity: 1;
}

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0,0,0,0.4);
    color: white;
    border: none;
    font-size: 1.5rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    z-index: 5;
    transition: background-color 0.2s ease;
}
.carousel-btn:hover {
    background-color: rgba(0,0,0,0.7);
}
#carousel-prev { left: 1rem; border-radius: 8px 0 0 8px; }
#carousel-next { right: 1rem; border-radius: 0 8px 8px 0; }

/* Modal Content Styles */
#modal-title {
    margin: 0 0 1rem 0;
    color: var(--primary-color);
    font-size: 2rem;
}

#modal-description {
    line-height: 1.7;
    margin-bottom: 2rem;
}

/* Architect's Notes Styles */
#modal-architect-notes {
    margin: 2.5rem 0;
    padding-top: 2rem;
    border-top: 1px solid #374151;
}

#modal-architect-notes h4 {
    color: var(--secondary-color);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

#modal-architect-notes p {
    margin: 0 0 1.5rem 0;
    color: var(--text-muted-color);
    font-size: 0.95rem;
    line-height: 1.6;
}

#modal-tech-stack {
    margin-bottom: 2rem;
}

#modal-tech-stack span {
    display: inline-block;
    background-color: #374151;
    color: var(--secondary-color);
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
    margin: 0.25rem;
}

#modal-links a {
    background-color: var(--primary-color);
    color: #111827;
    font-weight: 600;
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    margin-right: 1rem;
    transition: background-color 0.2s ease;
}

#modal-links a:hover {
    background-color: #A7B1FB;
}