/* Tema técnico oscuro, sobrio y accesible. */

:root {
    color-scheme: dark;
    --background: #071014;
    --surface: #0b171d;
    --surface-raised: #102028;
    --text: #c8d4d8;
    --text-muted: #83969d;
    --cyan: #63cbd2;
    --cyan-bright: #83e1e6;
    --amber: #d09a55;
    --border: #1b343d;
    --border-strong: #2b515c;
    --danger: #e27d7d;
    --content-width: 1040px;
    --reading-width: 800px;
    --radius: 6px;
    --transition: 160ms ease;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at 50% -20%, rgba(46, 105, 117, 0.12), transparent 38rem),
        var(--background);
    color: var(--text);
    font-family: "JetBrains Mono", "Adwaita Mono", "Fira Code", "Courier New", monospace;
    font-size: 16px;
    line-height: 1.7;
}

::selection {
    background: rgba(99, 203, 210, 0.25);
    color: var(--cyan-bright);
}

.site-wrapper {
    width: min(100% - 40px, var(--content-width));
    min-height: 100vh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--cyan);
    font-weight: 500;
    line-height: 1.3;
}

h1 {
    margin: 0 0 1.25rem;
    font-size: clamp(1.75rem, 4vw, 2.35rem);
}

h2 {
    font-size: 1.4rem;
}

h3 {
    font-size: 1.15rem;
}

a {
    color: var(--cyan);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--cyan-bright);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--amber);
    outline-offset: 3px;
}

/* Cabecera compacta */
.site-header {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    border-bottom: 1px solid var(--border);
}

.site-identity {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
}

.site-identity:hover {
    color: var(--cyan-bright);
}

.site-identity img {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    object-fit: cover;
}

.site-name {
    overflow: hidden;
    font-size: 1.08rem;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cursor {
    color: var(--cyan);
    animation: cursor-blink 1.1s steps(1, end) infinite;
}

@keyframes cursor-blink {
    0%, 48% { opacity: 1; }
    49%, 100% { opacity: 0; }
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-actions form {
    width: auto;
    margin: 0;
}

.header-actions .icon-link {
    width: 40px;
    height: 40px;
    padding: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition:
        color var(--transition),
        border-color var(--transition),
        background-color var(--transition);
}

.header-actions .icon-link:hover {
    border-color: var(--border-strong);
    background: var(--surface);
    color: var(--cyan-bright);
}

.icon-link svg {
    width: 100%;
    height: 100%;
    display: block;
    fill: currentcolor;
}

/* Mensajes */
.messages {
    width: min(100%, var(--reading-width));
    margin: 20px auto 0;
}

.message {
    padding: 10px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 0.9rem;
}

.message + .message {
    margin-top: 8px;
}

.message.success {
    border-color: rgba(99, 203, 210, 0.5);
}

.message.error {
    border-color: var(--danger);
    color: var(--danger);
}

.message.warning {
    border-color: var(--amber);
    color: var(--amber);
}

.message.info {
    color: var(--cyan);
}

/* Portada */
.page-content {
    flex: 1;
    padding: clamp(48px, 8vw, 88px) 0;
}

.about-section {
    width: min(100%, var(--reading-width));
    margin: 0 auto;
}

.about-section p {
    margin: 0 0 1.15rem;
}

.about-section p:first-of-type {
    margin-bottom: 1.7rem;
    color: var(--cyan);
    font-size: clamp(1rem, 2.2vw, 1.12rem);
}

.projects-section {
    margin-top: clamp(64px, 10vw, 104px);
}

.section-title {
    width: min(100%, var(--reading-width));
    margin: 0 auto 32px;
    display: flex;
    align-items: center;
    gap: 18px;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.section-title::before,
.section-title::after {
    height: 1px;
    flex: 1;
    background: var(--border);
    content: "";
}

.projects-grid {
    width: min(100%, var(--reading-width));
    margin: 0 auto;
    display: grid;
    gap: 22px;
}

.project-card-link {
    display: block;
    border-radius: var(--radius);
    color: inherit;
}

.project-card-link:hover {
    color: inherit;
}

.project-card-link:focus-visible {
    outline-offset: 5px;
}

.project-card {
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    transition:
        border-color var(--transition),
        background-color var(--transition),
        transform var(--transition);
}

.project-card-link:hover .project-card,
.project-card-link:focus-visible .project-card {
    border-color: var(--border-strong);
    background: var(--surface-raised);
    transform: translateY(-2px);
}

.project-card img {
    width: 100%;
    height: clamp(210px, 38vw, 320px);
    display: block;
    border-bottom: 1px solid var(--border);
    object-fit: cover;
    object-position: center;
}

.project-card-content {
    padding: 20px 22px;
}

.project-card h3 {
    margin: 0 0 8px;
    color: var(--cyan);
    font-size: 1.15rem;
}

.project-card-meta {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.empty-state {
    margin: 0;
    color: var(--text-muted);
    text-align: center;
}

.admin-links {
    width: min(100%, var(--reading-width));
    margin: -12px auto 24px;
    padding: 0;
    display: flex;
    justify-content: flex-end;
    list-style: none;
}

.admin-links a {
    padding: 7px 12px;
    display: inline-block;
    border: 1px solid rgba(208, 154, 85, 0.5);
    border-radius: var(--radius);
    color: var(--amber);
    font-size: 0.82rem;
}

.admin-links a:hover {
    border-color: var(--amber);
    background: rgba(208, 154, 85, 0.08);
}

/* Detalle de proyecto y páginas secundarias */
.page-content > article {
    width: min(100%, 900px);
    margin: 0 auto;
    padding: clamp(20px, 4vw, 34px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.page-content > article h1:first-of-type {
    text-align: left;
}

.page-content > article picture img {
    max-width: 100%;
    height: auto;
}

.page-content > h1,
.page-content > h2 {
    text-align: center;
}

.project-images {
    margin: 24px auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
    gap: 14px;
}

.project-images picture {
    position: relative;
    height: 250px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: zoom-in;
}

.project-images picture:hover {
    border-color: var(--border-strong);
}

.project-images picture img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

/* Formularios */
form {
    width: min(100%, 600px);
    margin: 24px auto 0;
}

label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-muted);
    font-size: 0.88rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="file"],
textarea,
select {
    width: 100%;
    max-width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    transition: border-color var(--transition);
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--cyan);
}

textarea {
    min-height: 130px;
    resize: vertical;
}

button,
input[type="submit"] {
    padding: 9px 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--cyan);
    cursor: pointer;
    font: inherit;
    transition:
        border-color var(--transition),
        background-color var(--transition),
        color var(--transition);
}

button:hover,
input[type="submit"]:hover {
    border-color: var(--cyan);
    background: var(--surface-raised);
    color: var(--cyan-bright);
}

.errorlist {
    margin: 5px 0;
    padding: 0;
    color: var(--danger);
    font-size: 0.84rem;
    list-style: none;
}

/* Visor de imágenes */
.image-modal {
    max-width: 80vw;
    max-height: 80vh;
    padding: 0;
    overflow: visible;
    border: 0;
    background: transparent;
}

.image-modal::backdrop {
    background: rgba(3, 8, 10, 0.92);
}

.image-modal img {
    max-width: 80vw;
    max-height: 80vh;
    display: block;
    object-fit: contain;
}

.image-modal-close {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1;
}

/* Pie */
footer {
    padding: 24px 0;
    border-top: 1px solid var(--border);
    text-align: center;
}

footer p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.78rem;
}

@media (max-width: 600px) {
    .site-wrapper {
        width: min(100% - 28px, var(--content-width));
    }

    .site-header {
        min-height: 64px;
        gap: 10px;
    }

    .site-identity {
        gap: 9px;
    }

    .site-identity img {
        width: 38px;
        height: 38px;
    }

    .site-name {
        font-size: 0.94rem;
    }

    .header-actions {
        gap: 1px;
    }

    .header-actions .icon-link {
        width: 36px;
        height: 36px;
        padding: 8px;
    }

    .page-content {
        padding: 42px 0 56px;
    }

    .project-card-content {
        padding: 16px;
    }

    .section-title {
        gap: 12px;
    }
}

@media (max-width: 390px) {
    .site-name {
        max-width: 82px;
    }
}

@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;
    }
}
