/* ================================================================
   JOAQUIN ESTRADA — Portfolio · Dark & Cinematic Theme
   ================================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
    --bg:         #0a0a0a;
    --surface:    #111111;
    --surface-2:  #1a1a1a;
    --border:     rgba(255, 255, 255, 0.07);

    --text-1:     #edeae2;   /* warm off-white */
    --text-2:     #78746c;   /* muted */
    --text-3:     #3a3632;   /* very muted */

    --accent:     #c8a96e;   /* warm gold */

    --serif:      'Playfair Display', Georgia, serif;
    --sans:       'Inter', system-ui, -apple-system, sans-serif;

    --nav-h:      68px;
    --ease:       cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    background: var(--bg);
    color: var(--text-1);
    font-family: var(--sans);
    font-weight: 300;
    line-height: 1.75;
    overflow-x: hidden;
}
img, video { display: block; max-width: 100%; height: auto; }
a          { color: inherit; text-decoration: none; }
ul         { list-style: none; }
button     { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }

/* ── Container ─────────────────────────────────────────────── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 clamp(1.5rem, 5vw, 4rem);
}

/* ================================================================
   NAVIGATION
   ================================================================ */
#nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    height: var(--nav-h);
    transition: background 0.4s var(--ease), border-color 0.4s var(--ease);
    border-bottom: 1px solid transparent;
}
#nav.scrolled {
    background: rgba(10, 10, 10, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-color: var(--border);
}
.nav-inner {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 clamp(1.5rem, 5vw, 4rem);
}
.nav-logo {
    font-family: var(--serif);
    font-size: 1.2rem;
    font-style: italic;
    letter-spacing: 0.05em;
}
.nav-links {
    display: flex;
    gap: 2.5rem;
    align-items: center;
}
.nav-links a {
    font-size: 0.68rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-2);
    transition: color 0.2s;
}
.nav-links a:hover { color: var(--text-1); }

/* Hamburger */
.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    padding: 4px;
}
.nav-toggle span {
    display: block;
    width: 22px;
    height: 1px;
    background: var(--text-1);
    transition: transform 0.3s var(--ease), opacity 0.3s;
    transform-origin: center;
}
.nav-toggle.open span:nth-child(1) { transform: translateY(3px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { transform: translateY(-3px) rotate(-45deg); }

/* Mobile overlay */
.nav-mobile {
    position: fixed;
    inset: 0;
    z-index: 99;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2.5rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s var(--ease), visibility 0.35s;
}
.nav-mobile.open { opacity: 1; visibility: visible; }
.nav-mobile a {
    font-family: var(--serif);
    font-size: 2.8rem;
    font-weight: 400;
    color: var(--text-2);
    transition: color 0.2s;
}
.nav-mobile a:hover { color: var(--text-1); }

/* ================================================================
   HERO
   ================================================================ */
#hero {
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: calc(var(--nav-h) + 2rem) 2rem 4rem;
    background:
        radial-gradient(ellipse 70% 50% at 50% 40%, rgba(200, 169, 110, 0.05) 0%, transparent 70%),
        var(--bg);
}
/* Subtle grain */
#hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
    pointer-events: none;
    opacity: 0.6;
}

.hero-content {
    text-align: center;
    position: relative;
    z-index: 1;
}
.hero-eyebrow {
    font-size: 0.62rem;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 1.5rem;
    opacity: 0;
    animation: fadeUp 1s var(--ease) 0.2s forwards;
}
.hero-name {
    font-family: var(--serif);
    font-size: clamp(3.5rem, 10vw, 8rem);
    font-weight: 400;
    line-height: 1;
    letter-spacing: -0.02em;
    display: flex;
    flex-direction: column;
    gap: 0.05em;
    opacity: 0;
    animation: fadeUp 1s var(--ease) 0.4s forwards;
}
.hero-name span:nth-child(2) {
    font-style: italic;
    color: var(--text-2);
}
.hero-line {
    width: 36px;
    height: 1px;
    background: var(--accent);
    margin: 2rem auto;
    opacity: 0;
    transform: scaleX(0);
    transform-origin: left;
    animation: expandLine 0.9s var(--ease) 0.8s forwards;
}
.hero-role {
    font-size: 0.7rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--text-2);
    opacity: 0;
    animation: fadeUp 1s var(--ease) 1s forwards;
}

/* Scroll indicator */
.hero-scroll {
    position: absolute;
    bottom: 2.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
    opacity: 0;
    animation: fadeIn 1s var(--ease) 1.6s forwards;
}
.scroll-dot {
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-3);
    animation: bounce 2s ease-in-out infinite;
}

/* ================================================================
   SECTION COMMONS
   ================================================================ */
section { padding: clamp(5rem, 10vw, 9rem) 0; }

.section-title {
    font-family: var(--serif);
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 400;
    letter-spacing: -0.01em;
    line-height: 1.1;
}

/* ================================================================
   WORK SECTION
   ================================================================ */
#work { padding-top: 0; }

.section-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    padding-top: clamp(4rem, 8vw, 7rem);
}

/* Filter buttons */
.filters { display: flex; gap: 2px; }

.filter-btn {
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    padding: 0.45rem 0.9rem;
    color: var(--text-2);
    border: 1px solid transparent;
    border-radius: 2px;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.filter-btn:hover { color: var(--text-1); border-color: var(--border); }
.filter-btn.active {
    color: var(--text-1);
    border-color: var(--border);
    background: var(--surface-2);
}
.filter-count {
    font-size: 0.55rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 0.4em;
    line-height: 1.6;
    color: var(--text-2);
    transition: opacity 0.2s;
}
.filter-btn.active .filter-count {
    background: var(--surface-2);
    color: var(--accent);
    border-color: rgba(200, 169, 110, 0.2);
}

/* ================================================================
   GALLERY — CSS Columns masonry
   ================================================================ */
.gallery-grid {
    columns: 3 260px;
    column-gap: 10px;
}

.gallery-item {
    break-inside: avoid;
    margin-bottom: 10px;
    position: relative;
    overflow: hidden;
    border-radius: 2px;
    cursor: pointer;
    background: var(--surface);

    /* Staggered entrance */
    opacity: 0;
    transform: translateY(14px);
    animation: fadeUp 0.55s var(--ease) forwards;
}
.gallery-item:nth-child(1)  { animation-delay: 0.04s; }
.gallery-item:nth-child(2)  { animation-delay: 0.08s; }
.gallery-item:nth-child(3)  { animation-delay: 0.12s; }
.gallery-item:nth-child(4)  { animation-delay: 0.16s; }
.gallery-item:nth-child(5)  { animation-delay: 0.20s; }
.gallery-item:nth-child(6)  { animation-delay: 0.24s; }
.gallery-item:nth-child(7)  { animation-delay: 0.28s; }
.gallery-item:nth-child(n+8){ animation-delay: 0.32s; }

.gallery-item.hidden { display: none; }

.gallery-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.gallery-thumb { position: relative; overflow: hidden; }
.gallery-thumb img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.55s var(--ease);
}
.gallery-item:hover .gallery-thumb img { transform: scale(1.04); }

.gallery-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(0,0,0,0.88) 0%,
        rgba(0,0,0,0.25) 45%,
        transparent 70%
    );
    opacity: 0;
    transition: opacity 0.35s var(--ease);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1.1rem;
    gap: 0.2rem;
}
.gallery-item:hover .gallery-overlay,
.gallery-item:focus-visible .gallery-overlay { opacity: 1; }

.gallery-title {
    font-family: var(--serif);
    font-size: 0.95rem;
    font-style: italic;
    color: var(--text-1);
    line-height: 1.3;
}
.gallery-cat {
    font-size: 0.58rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 7rem 2rem;
    color: var(--text-2);
}
.empty-icon {
    font-size: 2.5rem;
    color: var(--text-3);
    margin-bottom: 1.5rem;
}
.empty-state p { font-size: 0.9rem; }
.empty-hint {
    margin-top: 0.5rem;
    font-size: 0.8rem !important;
    color: var(--text-3) !important;
}
.empty-hint code {
    color: var(--accent);
    font-family: var(--sans);
    font-size: 0.78rem;
}

/* ================================================================
   ABOUT
   ================================================================ */
#about { border-top: 1px solid var(--border); }

.about-inner {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}
.about-body {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 4rem;
    align-items: start;
}
.about-text p {
    font-size: 0.92rem;
    color: var(--text-2);
    margin-bottom: 0.9rem;
}
.about-intro {
    font-family: var(--serif) !important;
    font-style: italic;
    font-size: 1.05rem !important;
    color: var(--text-1) !important;
    line-height: 1.65;
}
.about-skills {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}
.skill-col h3 {
    font-size: 0.58rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 1rem;
}
.skill-col li {
    font-size: 0.82rem;
    color: var(--text-2);
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
}

/* ================================================================
   CONTACT
   ================================================================ */
#contact {
    border-top: 1px solid var(--border);
    text-align: center;
}
.contact-inner {
    max-width: 560px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}
.contact-sub {
    color: var(--text-2);
    font-size: 0.88rem;
}
.contact-btn {
    display: inline-block;
    padding: 0.8rem 2.25rem;
    border: 1px solid var(--accent);
    color: var(--accent);
    font-size: 0.68rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    border-radius: 2px;
    margin-top: 0.4rem;
    transition: background 0.25s, color 0.25s;
}
.contact-btn:hover { background: var(--accent); color: var(--bg); }

.social-links {
    display: flex;
    gap: 2rem;
    margin-top: 0.25rem;
}
.social-links a {
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-3);
    transition: color 0.2s;
    border-bottom: 1px solid transparent;
    padding-bottom: 2px;
}
.social-links a:hover { color: var(--text-1); border-color: var(--border); }

/* ================================================================
   FOOTER
   ================================================================ */
footer { border-top: 1px solid var(--border); padding: 2rem 0; }
footer .container { display: flex; justify-content: center; }
footer p {
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    color: var(--text-3);
}

/* ================================================================
   LIGHTBOX
   ================================================================ */
#lightbox {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s var(--ease), visibility 0.3s;
}
#lightbox.active { visibility: visible; opacity: 1; }

.lb-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.94);
    cursor: pointer;
}
.lb-content {
    position: relative;
    z-index: 1;
    max-width: min(88vw, 1100px);
    max-height: 90svh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    transform: scale(0.97);
    transition: transform 0.3s var(--ease);
}
#lightbox.active .lb-content { transform: scale(1); }

.lb-image {
    max-width: 100%;
    max-height: calc(90svh - 55px);
    object-fit: contain;
    border-radius: 2px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.7);
    opacity: 0;
    transition: opacity 0.3s;
}
.lb-image.loaded { opacity: 1; }

.lb-info {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0 0.25rem;
    gap: 1rem;
}
.lb-title {
    font-family: var(--serif);
    font-style: italic;
    font-size: 0.95rem;
    color: var(--text-1);
}
.lb-cat {
    font-size: 0.58rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
    margin-left: auto;
}

/* Close + nav buttons */
.lb-close,
.lb-nav {
    position: fixed;
    z-index: 2;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-2);
    border-radius: 50%;
    border: 1px solid var(--border);
    background: rgba(10,10,10,0.6);
    transition: color 0.2s, background 0.2s, border-color 0.2s, transform 0.2s;
}
.lb-close { top: 1.5rem; right: 1.5rem; }
.lb-close:hover { color: var(--text-1); transform: rotate(90deg); border-color: rgba(255,255,255,0.15); }
.lb-close svg { width: 16px; height: 16px; }

.lb-prev { top: 50%; left: 1.5rem; transform: translateY(-50%); }
.lb-next { top: 50%; right: 1.5rem; transform: translateY(-50%); }
.lb-prev:hover { transform: translateY(-50%) translateX(-2px); color: var(--text-1); border-color: rgba(255,255,255,0.15); }
.lb-next:hover { transform: translateY(-50%) translateX(2px);  color: var(--text-1); border-color: rgba(255,255,255,0.15); }
.lb-nav svg { width: 18px; height: 18px; }
.lb-nav.hidden { opacity: 0; pointer-events: none; }

/* ================================================================
   SCROLL REVEAL
   ================================================================ */
.reveal {
    opacity: 0;
    transform: translateY(22px);
    transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ================================================================
   KEYFRAMES
   ================================================================ */
@keyframes fadeUp {
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    to { opacity: 1; }
}
@keyframes expandLine {
    to { opacity: 1; transform: scaleX(1); }
}
@keyframes bounce {
    0%, 100% { transform: translateY(0);   opacity: 0.9; }
    50%       { transform: translateY(9px); opacity: 0.3; }
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

/* Tablet */
@media (max-width: 860px) {
    .about-body { grid-template-columns: 1fr; gap: 2.5rem; }
}

/* Mobile */
@media (max-width: 640px) {
    .gallery-grid { columns: 1; }
    .section-top  { flex-direction: column; gap: 1rem; }
    .nav-links    { display: none; }
    .nav-toggle   { display: flex; }
    .lb-prev      { left: 0.75rem; }
    .lb-next      { right: 0.75rem; }
    .lb-close     { top: 1rem; right: 1rem; }
    .about-skills { grid-template-columns: 1fr 1fr; }
    .social-links { gap: 1.25rem; flex-wrap: wrap; justify-content: center; }
}

/* Mid tablet */
@media (min-width: 641px) and (max-width: 900px) {
    .gallery-grid { columns: 2; }
}
