@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Newsreader:ital,opsz,wght@0,6..72,200..800;1,6..72,200..800&family=Inter:wght@400;500;600&display=swap');

:root {
    --bg-color: #fbf9f4;
    --surface-color: #ffffff;
    --primary-color: #62557e;
    --primary-container: #eaddff;
    --on-primary-container: #21005d;
    --text-color: #1b1c19;
    --text-muted: #49454e;
    --border-color: #e4e2dd;
    --accent-color: #9e3d15;

    --font-mono: 'JetBrains Mono', monospace;
    --font-serif: 'Newsreader', serif;
    --font-sans: 'Inter', sans-serif;

    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 2rem;
    --spacing-lg: 4rem;

    --shadow-md: 0 10px 20px rgba(98, 85, 126, 0.15);
    --transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    --glow: 0 0 10px rgba(98, 85, 126, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3e%3cfilter id='noiseFilter'%3e%3cturbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3e%3c/filter%3e%3crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3e%3c/svg%3e");
    color: var(--text-color);
    font-family: var(--font-mono);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    align-items: flex-start;
    /* canvia l'anterior 'center' */
}

/* ── Layout ── */
main {
    flex: 1;
    display: flex;
    align-items: flex-start;
    /* canvia center per flex-start */
    justify-content: center;
    padding: var(--spacing-lg);
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

.content-wrapper {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: var(--spacing-lg);
    width: 100%;
}

@media (max-width: 768px) {
    .content-wrapper {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}

/* ── Profile Photo ── */
.profile-section {
    position: sticky;
    top: var(--spacing-lg);
    align-self: flex-start;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    width: 180px;
}

.profile-img-container {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    overflow: hidden;
    border: 6px solid var(--surface-color);
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.profile-img-container:hover {
    transform: scale(1.02) rotate(2deg);
}

.profile-img-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: pixelated;
}

/* ── Speech Bubble ── */
.bubble-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.editorial-bubble {
    background-color: var(--primary-color);
    color: white;
    border-radius: 1.5rem;
    position: relative;
    box-shadow: var(--shadow-md);
    animation: slideIn 0.6s ease-out;
}

/* Tail → left (desktop/tablet) */
.editorial-bubble::before {
    content: '';
    position: absolute;
    left: -18px;
    top: 36px;
    width: 0;
    height: 0;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    border-right: 18px solid var(--primary-color);
}

/* Tail → down (mobile) */
@media (max-width: 768px) {
    .editorial-bubble::before {
        left: 50%;
        transform: translateX(-50%);
        top: auto;
        bottom: -18px;
        width: 0;
        height: 0;
        border-left: 12px solid transparent;
        border-right: 12px solid transparent;
        border-top: 18px solid var(--primary-color);
        border-bottom: none;
    }
}

/* ── Ghost / Live overlay (fixed bubble size) ── */
.bubble-inner {
    position: relative;
    padding: var(--spacing-md) var(--spacing-lg);
}

.bubble-ghost {
    visibility: hidden;
    user-select: none;
    pointer-events: none;
}

.bubble-live {
    position: absolute;
    top: var(--spacing-md);
    left: var(--spacing-lg);
    right: var(--spacing-lg);
}

.bubble-text {
    font-size: 1.05rem;
    font-weight: 400;
    letter-spacing: -0.01em;
    line-height: 1.8;
    text-shadow: var(--glow);
}

/* ── Blinking Cursor ── */
.cursor {
    display: inline-block;
    width: 10px;
    height: 1em;
    background-color: #fff;
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 1s step-end infinite;
}

@keyframes blink {

    from,
    to {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* ── Imatge de presentació (substitueix el globus) ── */
.presentation-image {
    display: flex;
    justify-content: center;
    animation: slideIn 0.6s ease-out;
}

.presentation-image img {
    width: 100%;
    max-width: 420px;
    max-height: 58vh;
    height: auto;
    object-fit: contain;
}

@media (max-width: 768px) {
    .presentation-image {
        justify-content: center;
    }

    .presentation-image img {
        max-height: 42vh;
    }
}

/* ── Navigation Links ── */
.nav-links {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    margin-top: var(--spacing-sm);
}

.terminal-link {
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 500;
    transition: var(--transition);
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: inherit;
    padding: 0;
}

.terminal-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: var(--accent-color);
    transition: var(--transition);
}

.terminal-link:hover {
    color: var(--accent-color);
}

.terminal-link:hover::after {
    width: 100%;
}

.disabled-link {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

.disabled-link::after {
    display: none;
}

/* ── Footer ── */
footer {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: var(--spacing-md) var(--spacing-lg);
    background: none;
    border: none;
}

.copyright {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--primary-color);
    opacity: 0.8;
    margin-left: calc(180px + var(--spacing-lg));
    text-align: center;
}

@media (max-width: 768px) {
    footer {
        padding: var(--spacing-md) var(--spacing-sm);
    }
    .copyright {
        margin-left: 0;
    }
}

/* ── Animations ── */
@keyframes slideIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

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

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #d4d2cd;
}


/* ════════════════════════════════════════════
   PÀGINES INTERNES (Gallery, Docs, Blog)
   ════════════════════════════════════════════ */

/* La columna dreta de pàgines internes no té el globus,
   sinó contingut directe. Aliniació superior. */
.inner-section {
    animation: slideIn 0.5s ease-out;
    padding-top: 0.25rem;
    /* alinea visualment amb la foto */
}

/* Botó de tornada */
.back-link {
    display: block;
    font-size: 0.9rem;
    opacity: 0.65;
    margin-top: var(--spacing-xs);
    text-align: center;
    width: 100%;
}

.back-link:hover {
    opacity: 1;
}

.back-link::after {
    display: none;
}

/* ── Blog ── */
.blog-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-top: 3rem;
}

.blog-entry {
    display: flex;
    align-items: baseline;
    gap: 1.25rem;
}

.entry-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.entry-title {
    font-size: 0.9rem;
}

.post-title {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.post-content {
    margin-top: var(--spacing-md);
    font-size: 0.9rem;
    line-height: 1.9;
    color: var(--text-color);
    max-width: 60ch;
}

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

.post-content a {
    color: var(--accent-color);
}

/* ── Grid comú (Gallery i Docs) ── */
.inner-grid {
    display: grid;
    gap: 1.25rem;
    width: 100%;
}

/* En mòbil, 1 columna per defecte */
@media (max-width: 480px) {
    .inner-grid {
        grid-template-columns: 1fr !important;
    }
}


/* ════════════
   GALLERY
   ════════════ */

.gallery-grid {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.gallery-item {
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 0.35rem;
    cursor: zoom-in;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.45s cubic-bezier(0.23, 1, 0.32, 1),
        filter 0.45s ease;
    filter: saturate(0.92);
}

.gallery-item:hover img {
    transform: scale(1.04);
    filter: saturate(1.1);
}


/* ════════════
   DOCS
   ════════════ */

.docs-grid {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 768px) {
    .docs-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.doc-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.doc-thumb {
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 0.35rem;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-container);
    transition: border-color 0.3s ease;
    cursor: pointer;
}

.doc-thumb:hover {
    border-color: var(--primary-color);
}

/* Miniatura de vídeo */
.video-thumb {
    position: relative;
    background-color: #000;
}

.video-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.85;
    transition: opacity 0.3s ease;
}

.video-thumb:hover img {
    opacity: 0.7;
}

.play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    transition: transform 0.3s ease;
}

.video-thumb:hover .play-icon {
    transform: translate(-50%, -50%) scale(1.15);
}

/* Miniatura de PDF / Presentació */
.pdf-thumb svg {
    width: 48px;
    height: auto;
}

/* Metadades del document */
.doc-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}

.doc-title {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
    max-width: 18ch;
}

.doc-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.doc-actions .terminal-link {
    font-size: 0.75rem;
}


/* ════════════
   LIGHTBOX / MODAL (Gallery i Docs)
   ════════════ */

.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(27, 28, 25, 0.88);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.25s ease;
}

.lightbox.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.lightbox-close {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-md);
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    z-index: 1001;
}

.lightbox-close:hover {
    color: #fff;
}

.lightbox-close::after {
    display: none;
}

/* Gallery: imatge a pantalla completa */
.lightbox-img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 0.35rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: zoomIn 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

@keyframes zoomIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Docs: iframe centrat */
.modal-content {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: zoomIn 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

/* Foto de perfil fixa en scroll */
.profile-section {
    position: sticky;
    top: var(--spacing-lg);
    align-self: flex-start;
}

/* Botó de tornada fix en scroll */
.back-link {
    position: sticky;
    top: var(--spacing-lg);
    align-self: flex-start;
    z-index: 10;
}