/* =========================================================
   TU LUGAR PROPIO - MÓDULO ETAPAS DEL PROYECTO
   Archivo independiente para no alterar styles.css
   ========================================================= */

.stages-section {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at 92% 8%, rgba(207, 166, 61, .15), transparent 27%),
        linear-gradient(180deg, var(--soft) 0%, var(--white) 100%);
}

.stages-section::before {
    position: absolute;
    top: -220px;
    left: -190px;
    width: 470px;
    height: 470px;
    border: 1px solid rgba(6, 60, 49, .08);
    border-radius: 50%;
    content: "";
    pointer-events: none;
}

.stages-section .container {
    position: relative;
    z-index: 1;
}

.stages-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
}

.stage-card {
    display: flex;
    min-width: 0;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--white);
    box-shadow: 0 24px 58px rgba(4, 53, 43, .10);
    transition:
        transform .25s ease,
        box-shadow .25s ease,
        border-color .25s ease;
}

.stage-card:hover {
    transform: translateY(-7px);
    border-color: rgba(207, 166, 61, .55);
    box-shadow: 0 34px 76px rgba(4, 53, 43, .16);
}

.stage-preview {
    position: relative;
    display: block;
    width: 100%;
    height: 350px;
    padding: 18px;
    overflow: hidden;
    border: 0;
    background:
        linear-gradient(145deg, rgba(230, 240, 235, .96), rgba(251, 246, 235, .92));
    cursor: zoom-in;
}

.stage-preview img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 15px;
    background: var(--white);
    box-shadow: 0 13px 30px rgba(4, 53, 43, .12);
    transition: transform .35s ease;
}

.stage-preview:hover img,
.stage-preview:focus-visible img {
    transform: scale(1.025);
}

.stage-preview-badge {
    position: absolute;
    top: 30px;
    left: 30px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, .6);
    border-radius: 999px;
    color: var(--green-950);
    background: rgba(251, 246, 235, .94);
    box-shadow: 0 8px 24px rgba(4, 53, 43, .14);
    font-size: .74rem;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
    pointer-events: none;
}

.stage-preview-icon {
    position: absolute;
    right: 30px;
    bottom: 30px;
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 50%;
    color: var(--white);
    background: var(--green-800);
    box-shadow: 0 12px 28px rgba(4, 53, 43, .22);
    font-size: 1.15rem;
    font-weight: 900;
    pointer-events: none;
}

.stage-card-content {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: 27px 27px 29px;
}

.stage-card-kicker {
    display: block;
    margin-bottom: 8px;
    color: var(--gold);
    font-size: .74rem;
    font-weight: 900;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.stage-card h3 {
    margin: 0 0 10px;
    color: var(--green-900);
    font-size: clamp(1.4rem, 2.4vw, 1.8rem);
}

.stage-card p {
    margin: 0 0 21px;
    color: var(--muted);
    line-height: 1.7;
}

.stage-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 22px;
}

.stage-card-meta span {
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--green-800);
    background: var(--soft);
    font-size: .78rem;
    font-weight: 800;
}

.stage-open-button {
    display: inline-flex;
    min-height: 48px;
    width: 100%;
    margin-top: auto;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 13px 18px;
    border: 0;
    border-radius: 999px;
    color: var(--white);
    background: var(--green-800);
    box-shadow: 0 13px 28px rgba(4, 53, 43, .16);
    cursor: pointer;
    font: inherit;
    font-weight: 900;
    transition:
        transform .22s ease,
        background .22s ease,
        box-shadow .22s ease;
}

.stage-open-button:hover,
.stage-open-button:focus-visible {
    transform: translateY(-2px);
    background: var(--green-700);
    box-shadow: 0 17px 34px rgba(4, 53, 43, .22);
}

.stages-note {
    display: flex;
    max-width: 900px;
    margin: 28px auto 0;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 18px;
    border: 1px solid rgba(207, 166, 61, .35);
    border-radius: var(--radius-md);
    color: var(--muted);
    background: rgba(251, 246, 235, .78);
    font-size: .92rem;
    line-height: 1.55;
}

.stages-note strong {
    color: var(--green-900);
}

.stages-note-icon {
    display: grid;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    place-items: center;
    border-radius: 50%;
    color: var(--green-950);
    background: var(--gold-light);
    font-weight: 900;
}

/* Modal de plano */
body.stage-modal-open {
    overflow: hidden;
}

.stage-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    padding: 12px;
}

.stage-modal.is-open {
    display: grid;
    place-items: center;
}

.stage-modal-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(2, 22, 18, .84);
    backdrop-filter: blur(5px);
    cursor: zoom-out;
}

.stage-modal-dialog {
    position: relative;
    z-index: 1;
    display: flex;
    width: min(1440px, 100%);
    height: min(920px, calc(100vh - 24px));
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 24px;
    background: var(--white);
    box-shadow: 0 35px 90px rgba(0, 0, 0, .38);
}

.stage-modal-toolbar {
    display: flex;
    min-height: 68px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px 12px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--white);
}

.stage-modal-heading {
    min-width: 0;
}

.stage-modal-heading span {
    display: block;
    margin-bottom: 2px;
    color: var(--gold);
    font-size: .7rem;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.stage-modal-heading strong {
    display: block;
    overflow: hidden;
    color: var(--green-900);
    font-size: 1.08rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stage-modal-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
}

.stage-tool-button,
.stage-modal-link,
.stage-modal-close {
    display: inline-grid;
    min-width: 42px;
    height: 42px;
    place-items: center;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--green-900);
    background: var(--white);
    cursor: pointer;
    font: inherit;
    font-weight: 900;
    text-decoration: none;
    transition:
        transform .18s ease,
        border-color .18s ease,
        background .18s ease;
}

.stage-tool-button:hover,
.stage-tool-button:focus-visible,
.stage-modal-link:hover,
.stage-modal-link:focus-visible {
    transform: translateY(-1px);
    border-color: rgba(207, 166, 61, .65);
    background: var(--cream);
}

.stage-modal-close {
    border-color: var(--green-800);
    color: var(--white);
    background: var(--green-800);
    font-size: 1.35rem;
}

.stage-modal-close:hover,
.stage-modal-close:focus-visible {
    transform: rotate(4deg) scale(1.03);
    background: var(--green-700);
}

.stage-zoom-value {
    min-width: 56px;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 900;
    text-align: center;
}

.stage-modal-canvas {
    flex: 1;
    overflow: auto;
    padding: 24px;
    background:
        linear-gradient(45deg, #edf2ef 25%, transparent 25%),
        linear-gradient(-45deg, #edf2ef 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #edf2ef 75%),
        linear-gradient(-45deg, transparent 75%, #edf2ef 75%),
        #f8faf9;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
    background-size: 20px 20px;
    text-align: center;
    overscroll-behavior: contain;
}

.stage-modal-canvas img {
    display: block;
    width: 100%;
    min-width: 0;
    height: auto;
    margin: 0 auto;
    border-radius: 12px;
    background: var(--white);
    box-shadow: 0 16px 42px rgba(4, 53, 43, .17);
    transition: width .18s ease;
    user-select: none;
}

.stage-modal-caption {
    padding: 10px 20px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    background: var(--white);
    font-size: .82rem;
    text-align: center;
}

@media (max-width: 1020px) {
    .stages-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stage-card:last-child {
        grid-column: 1 / -1;
        max-width: 560px;
        width: 100%;
        justify-self: center;
    }
}

@media (max-width: 720px) {
    .stages-grid {
        grid-template-columns: 1fr;
    }

    .stage-card:last-child {
        grid-column: auto;
        max-width: none;
    }

    .stage-preview {
        height: 300px;
    }

    .stage-card-content {
        padding: 23px 22px 25px;
    }

    .stage-modal {
        padding: 6px;
    }

    .stage-modal-dialog {
        height: calc(100vh - 12px);
        border-radius: 18px;
    }

    .stage-modal-toolbar {
        min-height: auto;
        align-items: flex-start;
        padding: 11px;
    }

    .stage-modal-heading {
        padding: 4px 0 0 4px;
    }

    .stage-modal-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .stage-modal-link {
        display: none;
    }

    .stage-tool-button,
    .stage-modal-close {
        min-width: 38px;
        height: 38px;
        padding: 0 10px;
    }

    .stage-zoom-value {
        display: none;
    }

    .stage-modal-canvas {
        padding: 12px;
    }
}

@media (max-width: 430px) {
    .stage-preview {
        height: 265px;
        padding: 13px;
    }

    .stage-preview-badge {
        top: 23px;
        left: 23px;
    }

    .stage-preview-icon {
        right: 23px;
        bottom: 23px;
    }
}

/* =========================================================
   CORRECCIÓN DE DESBORDAMIENTO HORIZONTAL
   ========================================================= */

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.stages-section,
.stages-section *,
.stage-modal,
.stage-modal * {
    box-sizing: border-box;
}

.stages-section {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

    .stages-section .container,
    .stages-grid,
    .stage-card,
    .stage-preview,
    .stage-card-content {
        min-width: 0;
        max-width: 100%;
    }

.stage-modal {
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
}

.stage-modal-dialog {
    width: min(1440px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
}

.stage-modal-toolbar,
.stage-modal-canvas,
.stage-modal-caption {
    min-width: 0;
    max-width: 100%;
}

@media (max-width: 720px) {
    .stage-modal-dialog {
        width: calc(100vw - 12px);
        max-width: calc(100vw - 12px);
    }
}