/* Selector de año de las fichas (inc/js/selector-anyo.js): indicador del año visible,
   pastilla fija al bajar y rueda vertical para elegir otro año. Usa los colores de diseno.css. */

.ap-anyos[data-ap-anyo-selector].ap-anyos-mejorado { display: none; }

/* ---------------------------------------------------- indicador en la página */
.ap-anyo-sel {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
    margin: 4px 0 18px; padding: 10px 12px 10px 14px;
    background: linear-gradient(135deg, var(--ap-acento-suave, #e9f1ff), var(--ap-superficie, #fff) 70%);
    border: 1px solid var(--ap-borde, #e1e7ef); border-radius: var(--ap-radio, 12px);
    box-shadow: var(--ap-sombra);
}
.ap-anyo-sel-texto { font-size: 14px; color: var(--ap-texto-2, #4a5a70); }
.ap-anyo-sel-ayuda { font-size: 12px; color: var(--ap-texto-3, #7a889c); margin-left: auto; }

.ap-anyo-boton, .ap-anyo-flotante {
    display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
    font-family: var(--ap-letra-titulos, inherit); font-weight: 800; line-height: 1;
    color: #fff; background: var(--ap-acento, #1f6feb); border: 0; border-radius: 999px;
    box-shadow: 0 6px 16px -6px rgba(31, 111, 235, .55);
    transition: background .15s, transform .15s, box-shadow .15s;
}
.ap-anyo-boton { font-size: 20px; padding: 9px 14px 9px 14px; }
.ap-anyo-boton:hover, .ap-anyo-flotante:hover { background: var(--ap-acento-hover, #1858c4); transform: translateY(-1px); }
.ap-anyo-boton:focus-visible, .ap-anyo-flotante:focus-visible, .ap-rueda:focus-visible, .ap-anyo-panel button:focus-visible, .ap-anyo-ir:focus-visible {
    outline: 3px solid var(--ap-oro, #ffc23d); outline-offset: 2px;
}
.ap-anyo-boton svg, .ap-anyo-flotante svg { width: 18px; height: 18px; flex: none; }
.ap-anyo-flecha { transition: transform .25s cubic-bezier(.2, .9, .3, 1.2); }
[aria-expanded="true"] > .ap-anyo-flecha { transform: rotate(180deg); }

/* Número del año: entra rodando hacia arriba. */
.ap-anyo-num { display: inline-block; min-width: 2.6em; text-align: center; font-variant-numeric: tabular-nums; }
.ap-anyo-num.ap-anyo-rueda-in { animation: ap-anyo-sube .45s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes ap-anyo-sube { from { transform: translateY(70%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------------------------------------------- pastilla fija al bajar */
.ap-anyo-flotante {
    position: fixed; z-index: 45; left: 50%; top: var(--ap-anyo-top, 70px);
    font-size: 15px; padding: 7px 12px 7px 10px;
    transform: translate(-50%, -160%); opacity: 0; pointer-events: none;
    transition: transform .4s cubic-bezier(.2, .9, .3, 1.2), opacity .25s, background .15s;
    box-shadow: 0 10px 24px -8px rgba(15, 27, 45, .45);
}
.ap-anyo-flotante small { font-family: var(--ap-letra, inherit); font-size: 11px; font-weight: 600; opacity: .85; text-transform: uppercase; letter-spacing: .05em; }
.ap-anyo-flotante.visible { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.ap-anyo-flotante.visible:hover { transform: translate(-50%, -1px); }
.ap-anyo-flotante.cargando, .ap-anyo-boton.cargando { cursor: progress; }
.ap-anyo-flotante.cargando .ap-anyo-num, .ap-anyo-boton.cargando .ap-anyo-num { animation: ap-anyo-latido .8s ease-in-out infinite alternate; }
@keyframes ap-anyo-latido { to { opacity: .45; } }

/* ---------------------------------------------------- panel con la rueda */
.ap-anyo-fondo {
    position: fixed; inset: 0; z-index: 60; background: rgba(15, 27, 45, .35);
    opacity: 0; transition: opacity .25s;
}
.ap-anyo-fondo.abierto { opacity: 1; }

.ap-anyo-panel {
    --ap-rueda-item: 44px;
    position: absolute; z-index: 61; width: 220px; box-sizing: border-box; padding: 10px;
    background: var(--ap-superficie, #fff); border: 1px solid var(--ap-borde, #e1e7ef);
    border-radius: 16px; box-shadow: var(--ap-sombra-alta);
    opacity: 0; transform: translateY(-10px) scale(.94); transform-origin: top center;
    transition: opacity .2s, transform .35s cubic-bezier(.2, .9, .3, 1.2);
}
.ap-anyo-panel.arriba { transform-origin: bottom center; transform: translateY(10px) scale(.94); }
.ap-anyo-panel.abierto { opacity: 1; transform: none; }
.ap-anyo-panel[hidden] { display: none; }

.ap-anyo-panel-cab { display: flex; align-items: center; justify-content: space-between; margin: 0 2px 6px; }
.ap-anyo-panel-cab strong { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--ap-texto-3, #7a889c); }
.ap-anyo-cerrar {
    width: 30px; height: 30px; border: 0; border-radius: 50%; background: var(--ap-superficie-2, #f3f6fb);
    color: var(--ap-texto-2, #4a5a70); font-size: 18px; line-height: 1; cursor: pointer;
}
.ap-anyo-cerrar:hover { background: var(--ap-borde, #e1e7ef); }

.ap-rueda-marco { position: relative; }
/* Banda central: el año que se elige. */
.ap-rueda-marco::before {
    content: ""; position: absolute; left: 0; right: 0; top: 50%; height: var(--ap-rueda-item);
    transform: translateY(-50%); border-radius: 10px; pointer-events: none;
    background: var(--ap-acento-suave, #e9f1ff); border: 1px solid rgba(31, 111, 235, .25);
}
/* Degradado arriba y abajo para el efecto de rueda. */
.ap-rueda-marco::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(var(--ap-superficie, #fff), rgba(255, 255, 255, 0) 32%, rgba(255, 255, 255, 0) 68%, var(--ap-superficie, #fff));
}
.ap-rueda {
    position: relative; height: calc(var(--ap-rueda-item) * 5); overflow-y: auto; overscroll-behavior: contain;
    scroll-snap-type: y mandatory; scrollbar-width: none; perspective: 520px;
    padding: calc(var(--ap-rueda-item) * 2) 0; box-sizing: border-box; outline: none; border-radius: 10px;
}
.ap-rueda::-webkit-scrollbar { display: none; }
.ap-rueda-item {
    position: relative; height: var(--ap-rueda-item); display: flex; align-items: center; justify-content: center; gap: 6px;
    scroll-snap-align: center; cursor: pointer; user-select: none;
    font-family: var(--ap-letra-titulos, inherit); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums;
    color: var(--ap-texto-2, #4a5a70); transform-origin: center center; will-change: transform, opacity;
}
.ap-rueda-item.elegido { color: var(--ap-acento, #1f6feb); font-weight: 800; }
.ap-rueda-item.actual::after {
    content: "Viendo"; position: absolute; right: 8px; font-family: var(--ap-letra, inherit);
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ap-texto-3, #7a889c);
}
.ap-rueda-item.premium { color: var(--ap-premium, #b77900); }
.ap-rueda-item.premium svg { width: 15px; height: 15px; }

.ap-rueda-flecha {
    display: block; width: 100%; height: 22px; border: 0; background: none; cursor: pointer;
    color: var(--ap-texto-3, #7a889c); border-radius: 8px;
}
.ap-rueda-flecha:hover { color: var(--ap-acento, #1f6feb); background: var(--ap-superficie-2, #f3f6fb); }
.ap-rueda-flecha svg { width: 16px; height: 16px; }
.ap-rueda-flecha:disabled { opacity: .3; cursor: default; background: none; }

a.ap-anyo-ir, a.ap-anyo-ir:link, a.ap-anyo-ir:visited {
    display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 8px; padding: 10px 12px;
    border-radius: 10px; font-weight: 700; font-size: 14px; text-decoration: none; text-align: center;
    background: var(--ap-acento, #1f6feb); color: #fff; transition: background .15s;
}
a.ap-anyo-ir:hover, a.ap-anyo-ir:focus { background: var(--ap-acento-hover, #1858c4); color: #fff; text-decoration: none; }
a.ap-anyo-ir.es-actual, a.ap-anyo-ir.es-actual:hover { background: var(--ap-superficie-2, #f3f6fb); color: var(--ap-texto-2, #4a5a70); }
a.ap-anyo-ir.es-premium, a.ap-anyo-ir.es-premium:visited { background: var(--ap-oro, #ffc23d); color: #3b2a00; }
a.ap-anyo-ir.es-premium:hover, a.ap-anyo-ir.es-premium:focus { background: #ffb20f; color: #3b2a00; }
.ap-anyo-ir svg { width: 15px; height: 15px; }

/* Móvil: el panel sale desde abajo como hoja. */
@media (max-width: 600px) {
    .ap-anyo-sel { padding: 10px; }
    .ap-anyo-sel-texto { flex: 1 1 100%; }
    .ap-anyo-sel-ayuda { margin-left: 0; }
    .ap-anyo-boton { font-size: 19px; }
    .ap-anyo-panel {
        position: fixed !important; left: 0 !important; right: 0; top: auto !important; bottom: 0; width: auto;
        padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0;
        transform: translateY(100%); transform-origin: bottom center;
    }
    .ap-anyo-panel.arriba { transform: translateY(100%); }
    .ap-anyo-panel.abierto { transform: none; }
    .ap-anyo-panel::before {
        content: ""; display: block; width: 40px; height: 4px; margin: 0 auto 8px; border-radius: 4px; background: var(--ap-borde, #e1e7ef);
    }
    .ap-anyo-ir { padding: 13px 12px; font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
    .ap-anyo-flotante, .ap-anyo-panel, .ap-anyo-fondo, .ap-anyo-flecha { transition: opacity .15s; }
    .ap-anyo-num.ap-anyo-rueda-in, .ap-anyo-cargando .ap-anyo-num { animation: none; }
    .ap-rueda { scroll-behavior: auto; }
}

@media print { .ap-anyo-flotante, .ap-anyo-panel, .ap-anyo-fondo { display: none !important; } }
