@font-face {
    font-family: 'Roboto-Bold';
    src: url('/font/Roboto/Roboto-Bold.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Roboto-Regular';
    src: url('/font/Roboto/Roboto-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --gray-txt: #323639;
    --red-one: #E11E00;
    --gray-header: #F6F9FC;
    --gray-three: #F1F3F5;
    --gray-four: #A3A3A3;
    --white: #ffffff;
    --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.05);
    --shadow-medium: 0 4px 20px rgba(0, 0, 0, 0.08);
    --transition: all 0.3s ease;
    --border-radius: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Roboto-Regular', sans-serif;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--white);
    color: var(--gray-txt);
    line-height: 1.5;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1920px;
    height: 70px;
    padding: 0 2%;
    background: var(--gray-header);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.ctn-header-img {
    display: inline-block;
    line-height: 0;
    text-decoration: none;
    border-radius: 4px;
    width: clamp(180px, 40vw, 257px);
    flex-shrink: 1;
}

.ctn-header-img img {
    width: 100%;
    max-width: 257px;
    height: auto;
    aspect-ratio: 257 / 56;
    object-fit: contain;

}

.ctn-header-title {
    color: var(--gray-txt);
    font-family: 'Roboto-Bold', sans-serif;
    font-size: 25px;
}

a:focus-visible,
button:focus-visible {
    outline: 3px solid var(--gray-txt);
    outline-offset: 3px;
}

.ctn-header-title:focus-visible,
.definiciones-section > h2:focus-visible {
    outline: 3px solid var(--gray-txt);
    outline-offset: 4px;
}

.main-content {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    min-height: 80vh;
    padding: 2rem;
}

.definiciones-section {
    max-width: 100%;
    margin-top: 0;
    padding: 2rem;
    border-radius: var(--border-radius);
    background: var(--white);
    box-shadow: var(--shadow-medium);
    animation: fadeIn 0.8s ease-out 0.5s both;
}

.definiciones-section h2 {
    margin: 1rem 0;
    color: var(--red-one);
    font-family: 'Roboto-Regular', sans-serif;
    font-size: 1.6rem;
    text-align: center;
}

.definiciones-section > .desglosable-categoria {
    margin-top: 1.5rem;
}

.desglosable-categoria {
    overflow: hidden;
    border: 1px solid var(--gray-three);
    border-radius: var(--border-radius);
    background: var(--white);
    box-shadow: var(--shadow-light);
    transition: var(--transition);
}

.desglosable-categoria:hover {
    box-shadow: var(--shadow-medium);
}

.desglosable-categoria.activo {
    border-color: var(--gray-four);
    box-shadow: var(--shadow-medium);
}

.desglosable-header {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 1.2rem;
    padding: 1rem;
    border: 0;
    border-bottom: 1px solid transparent;
    background: var(--white);
    color: inherit;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.desglosable-header:focus-visible {
    outline-offset: -3px;
}

.desglosable-header:hover .desglosable-titulo,
.desglosable-categoria.activo .desglosable-titulo {
    color: var(--red-one);
}

.desglosable-titulo {
    flex-grow: 1;
    color: var(--gray-txt);
    font-family: 'Roboto-Regular', sans-serif;
    font-size: 1rem;
    font-weight: normal;
}

.desglosable-flecha {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    color: var(--gray-txt);
    transition: transform 0.3s ease;
}

.desglosable-flecha svg {
    width: 100%;
    height: 100%;
}

.desglosable-flecha svg path {
    stroke: currentColor;
}

.desglosable-categoria.activo .desglosable-flecha {
    transform: rotate(180deg);
    color: var(--red-one);
}

.desglosable-contenido {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
    will-change: max-height;
}

.desglosable-contenido[hidden] {
    display: none;
}

.desglosable-categoria.activo .desglosable-contenido {
    max-height: 50000px;
}

.desglosable-contenido > .trimestres-grid {
    padding: 1rem 1.5rem 1.5rem;
}

.trimestres-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.8rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.trimestres-grid > li {
    flex: 0 0 auto;
}

.trimestre-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    background: var(--white);
    color: var(--gray-txt);
    text-decoration: none;
    transition: var(--transition);
}

.trimestre-item:hover,
.trimestre-item:focus-visible {
    color: var(--red-one);
    text-decoration: underline;
}

.trimestre-item:hover svg,
.trimestre-item:focus-visible svg {
    fill: currentColor;
}

.back-to-top {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 50%;
    background: var(--red-one);
    color: var(--white);
    box-shadow: var(--shadow-medium);
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.back-to-top[hidden] {
    display: none;
}

.back-to-top:hover {
    transform: translateY(-3px);
    background: #940a00;
}

.back-to-top:focus-visible {
    outline: 3px solid var(--gray-txt);
    outline-offset: 3px;
}

.back-to-top img {
    width: 24px;
    height: 24px;
    filter: brightness(0) invert(1);
}

@media (max-width: 768px) {
    .main-content {
        padding: 1.5rem;
    }

    .definiciones-section {
        padding: 1.5rem;
    }

    .desglosable-header {
        gap: 1rem;
        padding: 1rem;
    }

    .desglosable-titulo {
        font-size: 1.2rem;
    }

    .desglosable-contenido > .trimestres-grid {
        padding: 1rem 1.2rem 1.2rem;
    }

    .trimestre-item {
        padding: 0.2rem 0.5rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 576px) {
    .header {
        height: 60px;
    }

    .main-content {
        padding: 1rem 0.75rem;
    }

    .definiciones-section {
        padding: 1rem;
    }

    .definiciones-section h2 {
        font-size: 1rem;
    }

    .desglosable-header {
        padding: 0.75rem;
    }

    .desglosable-titulo {
        font-size: 1rem;
    }

    .desglosable-contenido > .trimestres-grid {
        padding: 0.75rem;
    }

    .trimestres-grid {
        gap: 0.5rem;
    }

    .ctn-header-title {
        font-size: 16px;
    }
}

@media (max-width: 400px) {
    .main-content {
        padding-right: 0.5rem;
        padding-left: 0.5rem;
    }

    .definiciones-section {
        padding: 0.75rem;
    }

    .definiciones-section h2 {
        font-size: 0.9rem;
    }

    .ctn-header-title {
        font-size: 14px;
    }

    .back-to-top {
        right: 1rem;
        bottom: 1rem;
        width: 44px;
        height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
