:root {
    --bg: #050505;
    --bg-alt: #0a0a0a;
    --panel: rgba(22, 22, 22, 0.78);
    --panel-solid: #101010;
    --line: rgba(255, 255, 255, 0.12);
    --line-strong: rgba(255, 255, 255, 0.22);
    --text: #f4f4f0;
    --muted: #c4c4c0;
    --soft: #8f8f8b;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

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

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    font-family: "Space Grotesk", Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        radial-gradient(circle at 15% 12%, rgba(255, 255, 255, 0.08), transparent 24%),
        linear-gradient(180deg, #000000 0%, #070707 48%, #020202 100%);
}

a {
    color: inherit;
}

/* Header */

.header {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    width: 100%;
    min-height: 88px;
    padding: 18px 6%;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 24px;
}

.logo {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(32, 32, 32, 0.92);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 16px;
    font-weight: 700;
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow);
    transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.logo:hover {
    transform: translateY(-2px);
    background: rgba(48, 48, 48, 0.96);
    border-color: rgba(255, 255, 255, 0.34);
}

.navbar {
    justify-self: center;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-radius: 999px;
    background: rgba(24, 24, 24, 0.76);
    border: 1px solid var(--line);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
}

.navbar a {
    position: relative;
    min-height: 38px;
    padding: 10px 16px;
    border-radius: 999px;
    color: #dededa;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.25s ease, background 0.25s ease, transform 0.25s ease;
}

.navbar a:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
}

.contact-btn,
.btn,
.contact-links a,
.project-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border-radius: 12px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
    transition: transform 0.25s ease, background 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

.contact-btn {
    justify-self: end;
    padding: 12px 20px;
    background: rgba(43, 43, 43, 0.9);
    color: var(--text);
    border: 1px solid var(--line-strong);
    white-space: nowrap;
    box-shadow: var(--shadow);
}

.contact-btn:hover {
    transform: translateY(-2px);
    background: rgba(62, 62, 62, 0.95);
    border-color: rgba(255, 255, 255, 0.34);
}

/* Hero */

.hero {
    min-height: 100vh;
    padding: 128px 10% 80px;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.74) 36%, rgba(0, 0, 0, 0.42) 70%, rgba(0, 0, 0, 0.72) 100%),
        linear-gradient(180deg, rgba(0, 0, 0, 0.42), rgba(0, 0, 0, 0.96)),
        url("../assets/img/hero-bg.png");
    background-size: cover;
    background-position: center;
}

.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: linear-gradient(90deg, rgba(0, 0, 0, 0.65), transparent 72%);
}

.hero-content {
    position: relative;
    z-index: 1;
    width: min(680px, 100%);
    animation: fadeUp 0.85s ease both;
}

.hero-subtitle,
.section-subtitle,
.project-kicker {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
}

.hero-subtitle {
    margin-bottom: 18px;
}

h1,
h2,
h3 {
    color: var(--text);
    font-weight: 700;
}

h1 {
    max-width: 720px;
    font-size: clamp(42px, 7vw, 82px);
    line-height: 0.95;
}

h2 {
    max-width: 760px;
    margin-top: 12px;
    font-size: clamp(30px, 4vw, 52px);
    line-height: 1.04;
}

h3 {
    font-size: 22px;
    line-height: 1.2;
}

.hero-description {
    max-width: 620px;
    margin: 24px 0 34px;
    color: #ddddda;
    font-size: 18px;
    line-height: 1.7;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.btn {
    padding: 13px 22px;
    border: 1px solid var(--line-strong);
}

.btn:hover {
    transform: translateY(-3px);
}

.btn-primary {
    background: var(--text);
    color: #050505;
}

.btn-primary:hover {
    background: #dcdcd6;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.34);
}

/* Sections */

.section {
    scroll-margin-top: 112px;
    padding: 108px 6%;
    background: var(--bg);
}

.section-alt {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent),
        var(--bg-alt);
}

.section-inner {
    width: min(1160px, 100%);
    margin: 0 auto;
}

.section-subtitle {
    margin-bottom: 4px;
}

.about {
    border-top: 1px solid var(--line);
}

.about-grid {
    display: grid;
    grid-template-columns: minmax(240px, 0.85fr) minmax(280px, 1.15fr);
    gap: 52px;
    align-items: start;
}

.about-copy {
    display: grid;
    gap: 20px;
    color: var(--muted);
    font-size: 18px;
    line-height: 1.75;
}

.card-grid,
.skills-grid {
    display: grid;
    gap: 20px;
    margin-top: 36px;
}

.services-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.service-card,
.skill-group,
.project-card,
.contact-panel {
    border: 1px solid var(--line);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015)),
        var(--panel-solid);
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

.service-card,
.skill-group,
.project-card {
    border-radius: 8px;
    transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.service-card:hover,
.project-card:hover,
.skill-group:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.28);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.02)),
        #121212;
}

.service-card {
    min-height: 210px;
    padding: 26px;
}

.service-card p,
.project-card p,
.contact-panel p {
    color: var(--muted);
    line-height: 1.65;
}

.service-card h3 {
    margin-bottom: 18px;
}

.skills-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.skill-group {
    padding: 28px;
}

.skill-group h3 {
    margin-bottom: 18px;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.chips > span {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: #dfdfdb;
    background: rgba(255, 255, 255, 0.045);
    font-size: 13px;
    font-weight: 600;
}

.project-card {
    min-height: 430px;
    padding: 28px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 28px;
}

.project-kicker {
    margin-bottom: 12px;
    color: var(--soft);
}

.project-card h3 {
    margin-bottom: 16px;
}

.project-footer {
    display: grid;
    gap: 22px;
}

.project-links,
.contact-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.project-links a,
.contact-links a {
    padding: 11px 16px;
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

.project-links a:hover,
.contact-links a:hover {
    transform: translateY(-2px);
    background: var(--text);
    color: #050505;
}

.contact {
    padding-bottom: 80px;
    background:
        radial-gradient(circle at 50% 100%, rgba(255, 255, 255, 0.08), transparent 34%),
        #030303;
}

.contact-panel {
    width: min(900px, 100%);
    padding: clamp(34px, 6vw, 64px);
    border-radius: 8px;
}

.contact-panel p {
    max-width: 720px;
    margin: 22px 0 30px;
    font-size: 18px;
}

.reveal {
    animation: sectionReveal 0.7s ease both;
    animation-timeline: view();
    animation-range: entry 0% cover 26%;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }

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

@keyframes sectionReveal {
    from {
        opacity: 0.25;
        transform: translateY(18px);
    }

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

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}

@media (max-width: 1040px) {
    .header {
        grid-template-columns: auto auto;
        justify-content: space-between;
        gap: 14px;
        padding: 14px 5%;
    }

    .navbar {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
        justify-content: center;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .navbar::-webkit-scrollbar {
        display: none;
    }

    .hero {
        padding-top: 164px;
    }

    .services-grid,
    .projects-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .header {
        min-height: 76px;
        padding: 12px 4%;
    }

    .logo {
        width: 48px;
        height: 48px;
    }

    .contact-btn {
        min-height: 42px;
        padding: 10px 14px;
        font-size: 13px;
    }

    .navbar {
        justify-content: flex-start;
        gap: 4px;
        padding: 8px;
        border-radius: 18px;
    }

    .navbar a {
        min-height: 34px;
        padding: 8px 12px;
        font-size: 13px;
    }

    .hero {
        min-height: 100svh;
        padding: 164px 6% 72px;
        background-position: 58% center;
    }

    .hero-description,
    .about-copy,
    .contact-panel p {
        font-size: 16px;
    }

    .section {
        scroll-margin-top: 148px;
        padding: 78px 5%;
    }

    .about-grid,
    .services-grid,
    .skills-grid,
    .projects-grid {
        grid-template-columns: 1fr;
    }

    .service-card {
        min-height: 0;
    }

    .project-card {
        min-height: 0;
    }
}

@media (max-width: 440px) {
    .hero-actions,
    .contact-links,
    .project-links {
        flex-direction: column;
    }

    .btn,
    .contact-links a,
    .project-links a {
        width: 100%;
    }

    .navbar a {
        padding: 8px 10px;
    }
}

/* ==========================================================================
   Multi-language toggling & layout
   ========================================================================== */
body.lang-en .lang-es { display: none !important; }
body.lang-es .lang-en { display: none !important; }

.lang-toggle {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    color: var(--soft);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    gap: 8px;
    align-items: center;
    transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease, transform 0.25s ease;
    min-height: 38px;
    box-shadow: var(--shadow);
}

.lang-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--line-strong);
    color: var(--text);
    transform: translateY(-1px);
}

.lang-toggle span.active-lang {
    color: #ffffff;
    font-weight: 700;
}

.lang-toggle .lang-separator {
    opacity: 0.3;
}

/* ==========================================================================
   Scroll-spy Active Link
   ========================================================================== */
.navbar a.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
}

/* ==========================================================================
   Interactive Cyber Terminal
   ========================================================================== */
.terminal-container {
    border: 1px solid rgba(16, 185, 129, 0.2);
    background: #09090b;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    height: 380px;
    overflow: hidden;
    font-family: 'Fira Code', 'Courier New', Courier, monospace;
    font-size: 13px;
    color: #10b981; /* terminal green */
}

.terminal-header {
    background: #18181b;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--line);
}

.terminal-buttons {
    display: flex;
    gap: 6px;
}

.terminal-btn {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.terminal-btn.close { background: #ef4444; }
.terminal-btn.minimize { background: #eab308; }
.terminal-btn.maximize { background: #22c55e; }

.terminal-title {
    color: var(--soft);
    font-size: 12px;
}

.terminal-body {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(16, 185, 129, 0.3) transparent;
}

.terminal-body::-webkit-scrollbar {
    width: 6px;
}
.terminal-body::-webkit-scrollbar-thumb {
    background: rgba(16, 185, 129, 0.3);
    border-radius: 3px;
}

.terminal-line {
    line-height: 1.5;
    white-space: pre-wrap;
}

.terminal-line.command {
    color: #38bdf8; /* cyan for commands */
}
.terminal-line.output {
    color: #e2e8f0; /* light gray for outputs */
}
.terminal-line.success {
    color: #10b981; /* green for success outputs */
}
.terminal-line.error {
    color: #ef4444; /* red for errors */
}
.terminal-line.warning {
    color: #fbbf24; /* yellow warnings */
}

.terminal-input-line {
    display: flex;
    align-items: center;
    gap: 8px;
}

.terminal-prompt {
    color: #38bdf8;
    font-weight: 700;
}

.terminal-input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

.terminal-input {
    background: transparent;
    border: none;
    outline: none;
    color: #38bdf8;
    font-family: inherit;
    font-size: inherit;
    width: 100%;
    caret-color: transparent; /* custom cursor */
}

.terminal-cursor {
    position: absolute;
    left: 0;
    width: 8px;
    height: 15px;
    background: #38bdf8;
    animation: blink-cursor 1s step-end infinite;
    pointer-events: none;
}

@keyframes blink-cursor {
    50% { opacity: 0; }
}

/* ==========================================================================
   Contact Dialog Modal
   ========================================================================== */
dialog.contact-modal {
    border: 1px solid var(--line);
    background: rgba(15, 15, 18, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    width: min(540px, 90vw);
    max-height: 90vh;
    margin: auto;
    padding: 0;
    box-shadow: 0 32px 100px rgba(0, 0, 0, 0.8);
    color: var(--text);
    opacity: 0;
    transform: scale(0.95) translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease, overlay 0.3s allow-discrete, display 0.3s allow-discrete;
}

dialog.contact-modal[open] {
    opacity: 1;
    transform: scale(1) translateY(0);
}

@starting-style {
    dialog.contact-modal[open] {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
}

dialog.contact-modal::backdrop {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.3s ease, overlay 0.3s allow-discrete, display 0.3s allow-discrete;
}

dialog.contact-modal[open]::backdrop {
    opacity: 1;
}

@starting-style {
    dialog.contact-modal[open]::backdrop {
        opacity: 0;
    }
}

.modal-wrapper {
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 24px;
    margin: 0;
}

.close-modal-btn {
    background: transparent;
    border: none;
    color: var(--soft);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
}

.close-modal-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
}

.form-group input,
.form-group textarea {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.06);
}

.form-group textarea {
    min-height: 120px;
    resize: vertical;
}

.form-submit-btn {
    margin-top: 10px;
    width: 100%;
    cursor: pointer;
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: #0f172a;
    border: 1px solid #10b981;
    color: #f8fafc;
    padding: 14px 20px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    max-width: 400px;
    pointer-events: auto;
    animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: opacity 0.3s, transform 0.3s;
}

.toast.toast-out {
    animation: toastOut 0.3s ease forwards;
}

.toast-icon {
    color: #10b981;
    font-weight: bold;
    font-size: 16px;
}

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

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
}
