/**
 * Gotifiestas Eventos 2.9 — capa UX/accesibilidad.
 * Se carga después de los estilos históricos para reducir overrides dispersos.
 */

:root {
    --gf-ux-focus: var(--ast-global-color-1, #ff3b3b);
    --gf-ux-accent: var(--ast-global-color-0, #c90000);
    --gf-ux-surface: var(--ast-global-color-5, #171717);
    --gf-ux-surface-alt: var(--ast-global-color-4, #0f0f0f);
    --gf-ux-text: var(--ast-global-color-3, #d8d8d8);
    --gf-ux-title: var(--ast-global-color-2, #fff);
    --gf-ux-border: var(--ast-global-color-6, #454545);
    --gf-ux-safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- Accesibilidad transversal ---------- */
.gf-single-event :where(a, button, input, select, textarea, summary):focus-visible,
.gf-filter-table :where(a, button, input, select):focus-visible,
.gf-events-instance :where(a, button):focus-visible {
    outline: 2px solid var(--gf-ux-focus) !important;
    outline-offset: 3px !important;
}

.gf-single-event button,
.gf-single-event a.gf-event-button,
.gf-filter-table button,
.gf-filter-table select,
.gf-filter-table input {
    min-height: 44px;
}

.gf-skip-link {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 10000000;
    transform: translateY(-160%);
    padding: 10px 14px;
    background: var(--gf-ux-accent);
    color: var(--ast-global-color-8, #fff) !important;
    text-decoration: none;
}
.gf-skip-link:focus { transform: translateY(0); }

/* ---------- Resultado y filtros activos ---------- */
.gf-events-result-summary {
    margin: 8px 0 14px;
    color: var(--gf-ux-text);
    font-size: .9rem;
}
.gf-events-result-summary strong { color: var(--gf-ux-title); }

.gf-filter-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.gf-active-filter-chips {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    gap: 7px;
    min-width: 0;
}
.gf-active-filter-chip,
.gf-active-filter-chip:visited {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--gf-ux-border);
    border-radius: 999px;
    background: var(--gf-ux-surface);
    color: var(--gf-ux-text) !important;
    font-size: .76rem;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
}
.gf-active-filter-chip i { color: var(--gf-ux-accent); }
.gf-active-filter-chip:hover,
.gf-active-filter-chip:focus-visible { border-color: var(--gf-ux-accent); }
.gf-active-filter-chip--clear {
    border-color: transparent;
    background: transparent;
    color: var(--ast-global-color-1, #f66) !important;
    cursor: pointer;
}

.gf-filter-sheet__header,
.gf-filter-sheet__footer,
.gf-filter-sheet-overlay { display: none; }
.gf-filter-sheet { min-width: 0; }

/* ---------- Cards: jerarquía y targets ---------- */
.gf-events-wrapper .gf-event-card__permalink {
    z-index: 5;
}
.gf-events-wrapper .gf-event-actions,
.gf-events-wrapper .gf-event-bookmark,
.gf-events-wrapper .gf-event-admin-quality,
.gf-events-wrapper .gf-event-image-wrap,
.gf-events-wrapper .gf-event-featured-badge {
    z-index: 8;
}
.gf-events-wrapper .gf-event-title { text-wrap: balance; }
.gf-events-wrapper .gf-event-cancelled-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}


/* Estado de navegación: feedback inmediato antes del cambio de página. */
.gf-events-is-navigating .gf-events-instance {
    position: relative;
    pointer-events: none;
    opacity: .62;
}
.gf-events-is-navigating .gf-events-instance::after {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 999999;
    content: "Cargando eventos…";
    padding: 10px 14px;
    background: var(--gf-ux-surface);
    border: 1px solid var(--gf-ux-border);
    color: var(--gf-ux-title);
    font-size: .82rem;
}

/* ---------- Ficha: acciones y lectura ---------- */
.gf-single-event .gf-event-long-description {
    max-width: 72ch;
    font-size: 1rem;
    line-height: 1.65;
}

.gf-single-event .gf-event-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.gf-event-more-actions {
    margin-top: 2px;
    border-top: 1px solid var(--gf-ux-border);
}
.gf-event-more-actions > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    padding: 8px 0;
    color: var(--gf-ux-text);
    font-size: .84rem;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}
.gf-event-more-actions > summary::-webkit-details-marker { display: none; }
.gf-event-more-actions > summary i {
    color: var(--gf-ux-accent);
    transition: transform .18s ease;
}
.gf-event-more-actions[open] > summary i { transform: rotate(180deg); }
.gf-event-more-actions__content {
    display: grid;
    gap: 9px;
    padding: 2px 0 8px;
}

.gf-event-share {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
    gap: 7px !important;
    margin: 0 !important;
}
.gf-event-share-native { width: 100%; }
.gf-event-share__fallback {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
}
.gf-event-share__fallback[hidden] { display: none !important; }
.gf-event-share__fallback a,
.gf-event-share__fallback button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border: 1px solid var(--gf-ux-border) !important;
    border-radius: 50% !important;
    background: transparent !important;
    color: var(--gf-ux-title) !important;
}

/* Comentario y quedada comparten el mismo patrón secundario. */
.gf-single-event .gf-event-comment-add,
.gf-single-event .gfem-add-button {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 9px 14px !important;
    border: 1px solid var(--gf-ux-accent) !important;
    border-radius: 6px !important;
    background: transparent !important;
    color: var(--gf-ux-title) !important;
    font-weight: 700;
    text-decoration: none;
}
.gf-single-event .gf-event-comment-add:hover,
.gf-single-event .gf-event-comment-add:focus-visible,
.gf-single-event .gfem-add-button:hover,
.gf-single-event .gfem-add-button:focus-visible {
    background: var(--gf-ux-accent) !important;
    color: var(--ast-global-color-8, #fff) !important;
}

/* Toast y avisos: por encima de la barra sticky. */
.gf-event-toast {
    bottom: calc(18px + var(--gf-ux-safe-bottom));
    font-size: .875rem;
}

/* Barra móvil, escondida en desktop. */
.gf-event-mobile-cta { display: none; }

/* ---------- Tablet ---------- */
@media (max-width: 820px) {
    .gf-single-event .gf-event-hero {
        grid-template-columns: 1fr !important;
    }
    .gf-single-event .gf-event-summary { order: 1; }
    .gf-single-event .gf-event-poster { order: 2; }
    .gf-single-event .gf-event-hero-aside { order: 3; }

    .gf-single-event .gf-event-summary h1 {
        font-size: clamp(1.8rem, 7vw, 2.5rem);
        line-height: 1.05;
    }
}

/* ---------- Móvil ---------- */
@media (max-width: 720px) {
    body.gf-filter-sheet-open { overflow: hidden !important; }

    /* Filtros como bottom sheet. */
    .gf-filter-table {
        position: relative;
        z-index: 80;
        margin-bottom: 12px;
    }
    .gf-filter-toolbar {
        align-items: flex-start;
        margin: 0;
    }
    .gf-mobile-filters-toggle {
        display: inline-flex !important;
        flex: 0 0 44px;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        min-width: 44px;
        padding: 0 !important;
        border-radius: 6px !important;
    }
    .gf-mobile-filters-toggle__label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
    .gf-active-filter-chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        scrollbar-width: none;
        padding: 4px 2px 7px;
    }
    .gf-active-filter-chips::-webkit-scrollbar { display: none; }
    .gf-active-filter-chip { flex: 0 0 auto; }

    .gf-filter-sheet-overlay {
        position: fixed;
        inset: 0;
        z-index: 999996;
        display: block;
        visibility: hidden;
        background: rgba(0,0,0,.68);
        opacity: 0;
        transition: opacity .2s ease, visibility .2s ease;
    }
    .gf-filter-sheet {
        position: fixed;
        z-index: 999997;
        right: 0;
        bottom: 0;
        left: 0;
        display: flex;
        max-height: min(88dvh, 760px);
        flex-direction: column;
        overflow: hidden;
        transform: translateY(104%);
        background: var(--gf-ux-surface-alt);
        border-top: 1px solid var(--gf-ux-border);
        border-radius: 14px 14px 0 0;
        box-shadow: 0 -18px 45px rgba(0,0,0,.5);
        transition: transform .24s ease;
    }
    .gf-filters-open .gf-filter-sheet-overlay {
        visibility: visible;
        opacity: 1;
    }
    .gf-filters-open .gf-filter-sheet { transform: translateY(0); }

    .gf-filter-sheet__header {
        display: flex;
        flex: 0 0 auto;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 14px 16px 11px;
        border-bottom: 1px solid var(--gf-ux-border);
    }
    .gf-filter-sheet__header > div { display: grid; gap: 2px; }
    .gf-filter-sheet__eyebrow {
        color: var(--gf-ux-accent);
        font-size: .78rem;
        font-weight: 800;
        letter-spacing: .1em;
        text-transform: uppercase;
    }
    .gf-filter-sheet__header strong { color: var(--gf-ux-title); font-size: 1.05rem; }
    .gf-filter-sheet__close {
        display: grid;
        width: 44px;
        height: 44px;
        place-items: center;
        padding: 0;
        border: 1px solid var(--gf-ux-border);
        border-radius: 50%;
        background: transparent;
        color: var(--gf-ux-title);
    }

    .gf-filter-table .gf-filter-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 13px !important;
        overflow-y: auto;
        padding: 14px 16px 18px !important;
        overscroll-behavior: contain;
    }
    .gf-filter-table .gf-filter-grid > label { display: grid !important; gap: 6px; }
    .gf-filter-table .gf-filter-select-control,
    .gf-filter-table .gf-filter-select-control select,
    .gf-filter-table .gf-filter-search-control,
    .gf-filter-table .gf-filter-search-control input {
        width: 100% !important;
        min-height: 48px !important;
        font-size: 16px !important; /* evita zoom automático de iOS */
    }
    .gf-filter-sheet__footer {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        gap: 8px;
        flex: 0 0 auto;
        padding: 10px 16px calc(10px + var(--gf-ux-safe-bottom));
        border-top: 1px solid var(--gf-ux-border);
        background: var(--gf-ux-surface);
    }
    .gf-filter-clear-button,
    .gf-filter-apply {
        min-height: 48px;
        border-radius: 6px;
    }
    .gf-filter-clear-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 7px;
        padding: 0 13px;
        border: 1px solid var(--gf-ux-border);
        background: transparent;
        color: var(--gf-ux-text);
    }
    .gf-filter-apply { width: 100%; }

    /* Cards: se conserva el diseño vertical gótico de 2.8/2.6.x. */

    /* Ficha: primero decisión, luego flyer. */
    .gf-event-single-page .gf-single-event { padding-bottom: calc(78px + var(--gf-ux-safe-bottom)); }
    .gf-single-event .gf-event-breadcrumb {
        gap: 5px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        font-size: .72rem;
    }
    .gf-single-event .gf-event-breadcrumb > :first-child,
    .gf-single-event .gf-event-breadcrumb > :nth-child(2) { display: none; }

    .gf-single-event .gf-event-summary {
        padding: 15px !important;
    }
    .gf-single-event .gf-event-facts {
        gap: 7px !important;
    }
    .gf-single-event .gf-event-fact {
        min-height: 32px;
    }
    .gf-single-event .gf-event-action-row--primary,
    .gf-single-event .gf-event-action-row--primary.gf-event-action-row--no-tickets {
        grid-template-columns: 1fr !important;
    }
    .gf-single-event .gf-event-button { min-height: 48px !important; }

    .gf-single-event .gf-event-poster {
        max-height: 520px;
    }
    .gf-single-event .gf-event-poster__image {
        max-height: 500px;
        object-fit: contain;
    }

    .gf-single-event .gf-event-panel,
    .gf-single-event .gfem-section.gf-event-panel {
        padding: 14px !important;
    }
    .gf-single-event .gf-event-long-description {
        font-size: .95rem;
        line-height: 1.62;
    }

    .gf-single-event .gf-event-description-toggle {
        width: 100% !important;
        min-height: 44px !important;
        margin: 8px 0 0 !important;
    }

    .gf-single-event .gf-event-comments__header,
    .gf-single-event .gfem-heading {
        align-items: stretch !important;
        flex-direction: column !important;
    }
    .gf-single-event .gf-event-comment-add,
    .gf-single-event .gfem-add-button { width: 100% !important; }

    /* Sticky CTA: principal punto de acción durante todo el scroll. */
    .gf-event-mobile-cta {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 999990;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 5px;
        padding: 7px 8px calc(7px + var(--gf-ux-safe-bottom));
        border-top: 1px solid var(--gf-ux-border);
        background: color-mix(in srgb, var(--gf-ux-surface-alt) 96%, transparent);
        box-shadow: 0 -10px 30px rgba(0,0,0,.34);
        backdrop-filter: blur(10px);
    }
    .gf-event-mobile-cta--no-tickets {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .gf-event-mobile-cta__button,
    .gf-event-mobile-cta__button:visited {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 5px;
        min-width: 0;
        min-height: 48px;
        padding: 5px 4px;
        border: 1px solid var(--gf-ux-border);
        border-radius: 5px;
        background: var(--gf-ux-surface);
        color: var(--gf-ux-title) !important;
        font-size: .78rem;
        font-weight: 800;
        line-height: 1.05;
        text-align: center;
        text-decoration: none;
    }
    .gf-event-mobile-cta__button--tickets {
        border-color: var(--gf-ux-accent);
        background: var(--gf-ux-accent);
    }
    .gf-event-mobile-cta__button.is-active {
        border-color: var(--gf-ux-accent);
        color: var(--ast-global-color-1, #ff6969) !important;
    }

    .gf-event-toast {
        right: 10px;
        bottom: calc(76px + var(--gf-ux-safe-bottom));
        left: 10px;
        max-width: none;
    }
}

@media (max-width: 420px) {
    .gf-event-mobile-cta__button span { font-size: .72rem; }
}

/* El fallback scoop de cards vive en gf-calendar.css para mantener el diseño anterior. */

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
    .gf-filter-sheet,
    .gf-filter-sheet-overlay,
    .gf-event-more-actions > summary i,
    .gf-single-event *,
    .gf-events-instance * {
        scroll-behavior: auto !important;
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
    .gf-events-wrapper .gf-event-card:hover,
    .gf-events-wrapper .gf-event-card:focus-within { transform: none !important; }
}

/* Mejora para contraste forzado de Windows / navegadores. */
@media (forced-colors: active) {
    .gf-event-mobile-cta,
    .gf-filter-sheet,
    .gf-event-card,
    .gf-event-button { border: 1px solid CanvasText !important; }
}

.gf-event-section-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 5px 0 -2px;
    color: var(--gf-ux-accent);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
}
.gf-event-section-divider::after {
    flex: 1 1 auto;
    height: 1px;
    content: "";
    background: var(--gf-ux-border);
}

/* Vista lista: conserva el diseño anterior definido en gf-event-list.css. */

/* Formularios y modales: tamaño mínimo legible y scroll seguro. */
@media (max-width: 720px) {
    .gf-event-editor input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
    .gf-event-editor select,
    .gf-event-editor textarea,
    .gfem-modal input,
    .gfem-modal textarea,
    .gf-event-comment-modal textarea {
        font-size: 16px !important;
    }
    .gf-event-comment-modal__dialog,
    .gfem-modal__dialog,
    .gf-event-editor__dialog {
        max-height: calc(100dvh - var(--gf-editor-safe-top, 0px) - var(--gf-ux-safe-bottom) - 12px) !important;
        overscroll-behavior: contain;
    }
}

[aria-busy="true"] {
    cursor: progress !important;
    opacity: .7;
}

body.gf-event-comment-modal-open,
body.gf-event-attendees-modal-open,
body.gf-image-lightbox-active,
body.gf-event-editor-open,
body.gfem-modal-open {
    overflow: hidden !important;
    overscroll-behavior: none;
}

@media (hover: none) {
    .gf-events-wrapper .gf-event-card:hover,
    .gf-events-wrapper .gf-event-card:focus-within {
        transform: none !important;
    }
    .gf-events-wrapper .gf-event-card:hover .gf-event-image-wrap img {
        transform: none !important;
    }
}

@media (max-width: 720px) {
    .gf-mobile-filters-toggle[data-active-count] { position: relative; }
    .gf-mobile-filters-toggle[data-active-count]::after {
        position: absolute;
        top: -5px;
        right: -5px;
        display: grid;
        min-width: 19px;
        height: 19px;
        padding: 0 4px;
        place-items: center;
        content: attr(data-active-count);
        border: 2px solid var(--gf-ux-surface-alt);
        border-radius: 999px;
        background: var(--gf-ux-accent);
        color: var(--ast-global-color-8, #fff);
        font-size: 10px;
        font-weight: 800;
        line-height: 1;
    }
}

@media (min-width: 721px) {
    .gf-filter-sheet__footer {
        display: flex;
        justify-content: flex-end;
        margin-top: 10px;
    }
    .gf-filter-sheet__footer .gf-filter-apply { display: none; }
    .gf-filter-clear-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 7px;
        min-height: 42px;
        padding: 8px 12px;
        border: 1px solid var(--gf-ux-border);
        border-radius: 6px;
        background: transparent;
        color: var(--gf-ux-text);
        cursor: pointer;
    }
    .gf-filter-clear-button:hover,
    .gf-filter-clear-button:focus-visible {
        border-color: var(--gf-ux-accent);
        color: var(--gf-ux-title);
    }
}

/* Feedback común en listados y estados de carga. */
.gf-ux-toast {
    position: fixed;
    right: 16px;
    bottom: calc(16px + var(--gf-ux-safe-bottom));
    z-index: 1000002;
    max-width: min(360px, calc(100vw - 32px));
    padding: 11px 14px;
    border: 1px solid var(--gf-ux-border);
    border-left: 3px solid var(--gf-ux-accent);
    background: var(--gf-ux-surface);
    color: var(--gf-ux-title);
    box-shadow: 0 12px 34px rgba(0,0,0,.42);
    font-size: .875rem;
    line-height: 1.4;
}

[aria-busy="true"] { position: relative; }
[aria-busy="true"]::after {
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
    content: "";
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: gf-ux-spin .65s linear infinite;
}
@keyframes gf-ux-spin { to { transform: rotate(360deg); } }

.gf-events-is-navigating .gf-event-card .gf-event-content > * {
    opacity: .12 !important;
}
.gf-events-is-navigating .gf-event-card .gf-event-content {
    background-image: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.05) 45%, rgba(255,255,255,.1) 50%, rgba(255,255,255,.05) 55%, transparent 100%);
    background-size: 220% 100%;
    animation: gf-ux-skeleton 1.1s linear infinite;
}
@keyframes gf-ux-skeleton { to { background-position: -220% 0; } }

@media (max-width: 720px) {
    .gf-ux-toast { bottom: calc(78px + var(--gf-ux-safe-bottom)); left: 10px; right: 10px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
    [aria-busy="true"]::after,
    .gf-events-is-navigating .gf-event-card .gf-event-content { animation: none !important; }
}

/* Cards desktop: conserva límites y extracto del diseño anterior. */
