/* ==========================================================================
   Tarjeta de proyecto destacada (Inicio y Proyectos)
   Video/galería a un lado de la información; en móvil, uno sobre otro.
   ==========================================================================
*/

.project-feature {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    align-items: center;
    gap: clamp(24px, 4vw, 56px);
    width: min(100% - 48px, 1100px);
    margin: 0 auto;
    padding: clamp(16px, 2vw, 24px);
    border: 1px solid rgba(var(--card-edge, 243, 244, 246), 0.2);
    border-radius: var(--radius-card);
    background: linear-gradient(135deg, rgba(var(--card-wash, 29, 45, 68), 0.68), rgba(13, 14, 21, 0.5));
    text-align: left;
    transition: border-color 0.25s ease;
}

.project-feature:hover,
.project-feature:focus-within {
    border-color: rgba(var(--card-edge, 243, 244, 246), 0.55);
}

/* La entrada al hacer scroll define su propia transición: aquí se le suma la del borde */
@media (prefers-reduced-motion: no-preference) {
    .reveal-ready .project-feature.scroll-reveal {
        transition: opacity 0.65s ease, transform 0.65s ease, border-color 0.25s ease;
    }
}

/* Un color por proyecto, tomado de sus propias piezas: borde (--card-edge) y fondo (--card-wash).
   Rojo de la barra de Erosión, azul del tanque de agua, dorado de Satin y violeta de la portada de la tienda. */
.erosion-card {
    --card-edge: 239, 68, 68;
    --card-wash: 56, 27, 33;
}

.water-card {
    --card-edge: 56, 189, 248;
    --card-wash: 22, 45, 60;
}

.satin-card {
    --card-edge: 230, 198, 134;
    --card-wash: 54, 43, 28;
}

.stars-card {
    --card-edge: 140, 121, 255;
    --card-wash: 41, 35, 66;
}

.project-feature-media {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-inner);
    overflow: hidden;
}

.project-feature-media .yt-frame {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

.project-feature-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #0D0E15;
}

/* Varias tarjetas seguidas (Inicio y Proyectos) */
.project-feature + .project-feature {
    margin-top: 24px;
}

.project-feature-body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding: 8px 8px 8px 0;
}

.project-meta {
    margin: 0;
    color: #9CA3AF;
    font-size: 0.95rem;
    font-weight: 700;
}

.project-status {
    color: #FBBF24;
}

.project-feature-title {
    margin: 0;
    color: var(--text-primary);
    font-family: 'Oswald', sans-serif;
    font-size: clamp(1.5rem, 2.6vw, 2rem);
    font-weight: 700;
    line-height: 1.15;
}

/* El título enlaza al caso de estudio: se ve igual que el texto y marca hover y foco de teclado */
.project-title-link {
    display: inline-block;
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.project-title-link:hover {
    color: var(--brand-accent);
}

.project-title-link:focus-visible {
    color: var(--brand-accent);
    outline: 2px solid var(--brand-accent);
    outline-offset: 4px;
    border-radius: 4px;
}

.project-title-link:active {
    color: var(--brand-accent);
}

.project-feature-body > p:not(.project-meta) {
    margin: 0;
    color: #D1D5DB;
    font-size: 1.05rem;
    line-height: 1.6;
}

/* Tarjeta "próximo proyecto": honesta mientras llegan más */
.project-next {
    display: grid;
    place-items: center;
    gap: 6px;
    width: min(100% - 48px, 1100px);
    margin: 24px auto 0;
    padding: 32px 24px;
    border: 1px dashed rgba(243, 244, 246, 0.2);
    border-radius: var(--radius-card);
    color: #9CA3AF;
    text-align: center;
}

.project-next h2 {
    margin: 0;
    color: #D1D5DB;
    font-family: 'Oswald', sans-serif;
    font-size: 1.3rem;
}

.project-next p {
    margin: 0;
}

/* Tarjeta del café: el enlace a mi página de apoyo. La taza humea sola y reacciona al tocarla */
.cafe-card {
    display: flex;
    align-items: center;
    gap: clamp(16px, 4vw, 32px);
    width: min(100% - 48px, 1100px);
    margin: 24px auto 0;
    padding: 24px clamp(20px, 4vw, 40px);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-card);
    background: var(--surface-card);
    color: var(--text-primary);
    text-decoration: none;
    transition: border-color 0.25s ease;
}

.cafe-card:hover,
.cafe-card:focus-visible,
.cafe-card:active {
    border-color: var(--brand-accent);
}

.cafe-card:focus-visible {
    outline: 2px solid var(--brand-accent);
    outline-offset: 3px;
}

.cafe-cup {
    flex: none;
    width: 104px;
    height: 104px;
    overflow: visible;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.cafe-cup-coffee {
    fill: var(--brand-accent-tint);
    stroke: var(--brand-accent);
}

.cafe-cup-steam path {
    stroke: var(--text-muted);
    stroke-width: 3;
    transition: stroke 0.25s ease;
}

.cafe-card:hover .cafe-cup-steam path,
.cafe-card:focus-visible .cafe-cup-steam path,
.cafe-card:active .cafe-cup-steam path {
    stroke: var(--brand-accent-soft);
}

.cafe-card-text {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.cafe-card-title {
    font-family: 'Oswald', sans-serif;
    font-size: clamp(1.3rem, 2.6vw, 1.8rem);
    font-weight: 600;
    line-height: 1.2;
    text-wrap: balance;
}

.cafe-card-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--brand-accent);
    font-size: 0.95rem;
    font-weight: 700;
}

.cafe-card-cta .icon {
    width: 18px;
    height: 18px;
}

@media (prefers-reduced-motion: no-preference) {
    .cafe-cup {
        transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    }

    /* Al acercarte, la taza se inclina hacia ti y el café se mueve */
    .cafe-card:hover .cafe-cup,
    .cafe-card:focus-visible .cafe-cup {
        transform: translateY(-4px) rotate(-7deg);
    }

    .cafe-card:hover .cafe-cup-steam path,
    .cafe-card:focus-visible .cafe-cup-steam path {
        transform-box: fill-box;
        transform-origin: 50% 100%;
        animation: cafe-steam 3.6s ease-in-out;
    }

    .cafe-card:hover .cafe-cup-coffee,
    .cafe-card:focus-visible .cafe-cup-coffee {
        transform-box: fill-box;
        transform-origin: 50% 50%;
        animation: cafe-ripple 0.7s ease-out;
    }

    .cafe-card:hover .cafe-card-cta .icon,
    .cafe-card:focus-visible .cafe-card-cta .icon {
        transform: translateX(4px);
    }

    .cafe-card-cta .icon {
        transition: transform 0.25s ease;
    }

    /* Al tocar: la taza se hunde un poco, como un botón de verdad */
    .cafe-card:active .cafe-cup {
        transform: translateY(0) rotate(-7deg) scale(0.94);
    }
}

@keyframes cafe-steam {
    0% { opacity: 0; transform: translateY(6px) scaleY(0.7); }
    35% { opacity: 0.85; }
    100% { opacity: 0; transform: translateY(-10px) scaleY(1.15); }
}

@keyframes cafe-ripple {
    0%, 100% { transform: scaleX(1) scaleY(1); }
    30% { transform: scaleX(1.05) scaleY(1.35); }
    60% { transform: scaleX(0.97) scaleY(0.85); }
}

/* ==========================================================================
   Guiño de "Erosión" (solo en la tarjeta de SIN GUARDAR)
   Al pasar el cursor o enfocar: el título se distorsiona un instante, el
   video recibe líneas de escaneo y la barra de Erosión del juego se llena.
   ==========================================================================
*/
.erosion-scan {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    background: repeating-linear-gradient(0deg, rgba(13, 14, 21, 0.35) 0 2px, transparent 2px 4px);
    mix-blend-mode: multiply;
    transition: opacity 0.4s ease;
}

.project-feature-media:has(iframe) .erosion-scan {
    display: none;
}

.erosion-meter {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 260px;
    color: #9CA3AF;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.erosion-bar {
    flex: 1;
    height: 4px;
    border-radius: 4px;
    background: rgba(243, 244, 246, 0.1);
    overflow: hidden;
}

.erosion-bar > span {
    display: block;
    width: 8%;
    height: 100%;
    background: linear-gradient(90deg, var(--brand-accent), #EF4444);
    transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes erode {
    0%   { text-shadow: none; transform: none; }
    15%  { text-shadow: -3px 0 rgba(239, 68, 68, 0.75), 3px 0 rgba(16, 185, 129, 0.75); transform: translateX(-2px) skewX(-4deg); }
    30%  { text-shadow: 2px 0 rgba(239, 68, 68, 0.75), -2px 0 rgba(16, 185, 129, 0.75); transform: translateX(2px); }
    45%  { text-shadow: none; transform: none; opacity: 0.85; }
    60%  { text-shadow: -1px 0 rgba(239, 68, 68, 0.6), 1px 0 rgba(16, 185, 129, 0.6); transform: translateX(-1px) skewX(2deg); opacity: 1; }
    100% { text-shadow: -1px 0 rgba(239, 68, 68, 0.35), 1px 0 rgba(16, 185, 129, 0.35); transform: none; }
}

.erosion-card:hover .erosion-title,
.erosion-card:focus-within .erosion-title {
    animation: erode 0.7s steps(1, end) forwards;
}

.erosion-card:hover .erosion-scan,
.erosion-card:focus-within .erosion-scan {
    opacity: 1;
}

.erosion-card:hover .erosion-bar > span,
.erosion-card:focus-within .erosion-bar > span {
    width: 64%;
}

/* ==========================================================================
   Guiño de "Tanque de agua" (solo en la tarjeta de Project Miralta)
   Al pasar el cursor o enfocar: cae lluvia ácida sobre el video y el
   tanque se vacía y se enturbia. Usa la misma barra que la Erosión.
   ==========================================================================
*/
@keyframes acid-rain {
    /* Solo se mueven las gotas; el tinte de abajo se queda fijo */
    from { background-position: 0 0, 0 0; }
    to { background-position: -40px 160px, 0 0; }
}

.rain-scan {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    background:
        repeating-linear-gradient(104deg, transparent 0 18px, rgba(190, 242, 100, 0.22) 18px 19px, transparent 19px 41px),
        linear-gradient(180deg, rgba(120, 113, 80, 0.25), transparent 70%);
    transition: opacity 0.4s ease;
}

.project-feature-media:has(iframe) .rain-scan {
    display: none;
}

.water-bar > span {
    width: 88%;
    background: linear-gradient(90deg, #38BDF8, var(--brand-accent));
    transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1), filter 0.9s ease;
}

.water-card:hover .rain-scan,
.water-card:focus-within .rain-scan {
    opacity: 1;
    animation: acid-rain 0.8s linear infinite;
}

.water-card:hover .water-bar > span,
.water-card:focus-within .water-bar > span {
    width: 18%;
    filter: sepia(0.9) saturate(0.7);
}

/* ---------- Móvil ---------- */
@media (max-width: 860px) {
    .project-feature {
        grid-template-columns: minmax(0, 1fr);
        width: min(100% - 40px, 640px);
    }

    .project-feature-body {
        padding: 4px;
    }

    .project-next,
    .cafe-card {
        width: min(100% - 40px, 640px);
    }

    .cafe-cup {
        width: 64px;
        height: 64px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .erosion-card:hover .erosion-title,
    .erosion-card:focus-within .erosion-title {
        animation: none;
    }

    .water-card:hover .rain-scan,
    .water-card:focus-within .rain-scan {
        animation: none;
    }

    .erosion-scan,
    .rain-scan,
    .erosion-bar > span {
        transition: none;
    }
}
