/* === Reset === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* === Base === */
html {
    font-size: 100%; /* 16px base */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: Georgia, 'Times New Roman', Times, serif;
    font-size: clamp(1rem, 0.9rem + 0.5vw, 1.2rem);
    line-height: 1.7;
    background-color: #ccffff;
    color: #1a1a1a;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img {
    border: 0;
    max-width: 100%;
    height: auto;
    display: block;
}

a:link {
    color: #1a4b8c;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s ease;
}

a:visited {
    color: #5a3a7a;
    text-decoration: underline;
    text-underline-offset: 2px;
}

a:hover {
    color: #cc3333;
}

/* === Page wrapper === */
.page-wrapper {
    max-width: 720px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem;
}

/* === Legacy language pages (non-rusyn) === */
.Section1 {
    max-width: 720px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem;
}

.Section1 > div,
.Section1 table {
    margin-left: auto;
    margin-right: auto;
}

/* Legacy 3-column header/menu block */
.Section1 > div > table > tbody > tr:nth-child(n + 3):nth-child(-n + 8) > td:first-child {
    text-align: right;
}

.Section1 > div > table > tbody > tr:nth-child(n + 3):nth-child(-n + 8) > td:last-child {
    text-align: left;
}

.Section1 > div > table > tbody > tr:nth-child(n + 3):nth-child(-n + 8) a {
    font-weight: bold;
    font-size: clamp(0.85rem, 0.8rem + 0.3vw, 1rem);
    line-height: 1.3;
}

.Section1 > div > table > tbody > tr:nth-child(n + 3):nth-child(-n + 8) p {
    margin: 0.15rem 0;
}

/* === Header / Logo === */
header {
    text-align: center;
    margin-bottom: 1.25rem;
}

.logo {
    width: 537px;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}

/* === Hero: nav + image + nav === */
.hero {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
    margin-bottom: 2rem;
    justify-content: center;
}

/* Legacy Word-export shell helpers (phase-in replacement for inline styles). */
.legacy-shell-table {
    width: 447.3pt;
    max-width: 100%;
    border-collapse: collapse;
}

.legacy-shell-head-row {
    height: 48.6pt;
}

.legacy-shell-head-cell {
    padding: 0 5.4pt;
    height: 48.6pt;
}

.nav-primary {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    text-align: right;
    min-width: 110px;
    flex-shrink: 1;
    padding-top: 0;
}

.hero-image {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    flex: 1;
    min-width: 0;
}

.hero-image img {
    max-width: 100%;
    height: auto;
    display: block;
}

.nav-languages {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    text-align: left;
    min-width: 120px;
    flex-shrink: 1;
    padding-top: 0;
}

nav a {
    display: block;
    font-weight: bold;
    font-size: clamp(0.85rem, 0.8rem + 0.3vw, 1rem);
    padding: 0.1rem 0;
    white-space: nowrap;
}

nav a.is-active {
    color: #8b0000;
    text-decoration: none;
    font-weight: 700;
}

.nav-languages a.is-active-language {
    color: #8b0000;
    text-decoration: none;
    border-bottom: 2px solid #8b0000;
}

/* === Main content === */
main {
    max-width: 660px;
    margin: 0 auto;
}

main p {
    margin-bottom: 1rem;
    text-align: justify;
    hyphens: auto;
}

main h2 {
    text-align: center;
    font-size: clamp(1.1rem, 1rem + 0.4vw, 1.35rem);
    font-weight: bold;
    margin: 1.75rem 0 0.75rem;
    color: #2a2a2a;
}

main h3 {
    text-align: center;
    font-size: clamp(1rem, 0.95rem + 0.3vw, 1.15rem);
    font-weight: bold;
    margin: 1.25rem 0 0.5rem;
    color: #3a3a3a;
}

/* === Song / Poem block === */
.song {
    text-align: center;
    line-height: 2.2;
    margin: 1.25rem 0;
    font-style: italic;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

/* === Historical data table === */
.history-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.25rem 0;
    font-size: clamp(0.9rem, 0.85rem + 0.3vw, 1rem);
}

.history-table thead th {
    text-align: center;
    font-weight: bold;
    padding: 0.6rem 0.5rem;
    border-bottom: 2px solid #888;
    font-size: clamp(0.95rem, 0.9rem + 0.3vw, 1.1rem);
}

.history-table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.history-table td {
    padding: 0.3rem 0.5rem;
    vertical-align: top;
    border-bottom: 1px solid #d0d0d0;
}

.year {
    text-align: center;
    white-space: nowrap;
    width: 100px;
    font-weight: bold;
}

/* === Contact === */
.contact {
    text-align: center;
    margin: 1.5rem 0;
}

.contact img {
    display: inline-block;
}

.video-wrap,
.video-container,
.video-wrapper {
    display: flex;
    justify-content: center;
    margin: 1rem 0 1.5rem;
    width: 100%;
}

.video-wrap iframe,
.video-container iframe,
.video-wrapper iframe {
    max-width: 100%;
    border: none;
    aspect-ratio: 16 / 9;
    width: 560px;
}

/* === Gallery === */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.gallery a {
    display: block;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gallery a:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.gallery img {
    max-height: 140px;
    object-fit: cover;
    border-radius: 4px;
    margin: 0 auto;
}

/* Legacy gallery-grid support */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.gallery-grid a {
    display: block;
    text-align: center;
}

.gallery-grid img {
    max-height: 140px;
    object-fit: cover;
}

/* === Links === */
.links-block {
    text-align: center;
    margin: 1rem 0 1.5rem;
}

.links-section {
    margin: 1.5rem 0 1.75rem;
}

.links-section h3 {
    text-align: center;
    font-size: clamp(1rem, 0.95rem + 0.3vw, 1.1rem);
    margin-bottom: 0.6rem;
    color: #2a2a2a;
}

.resource-list {
    list-style: none;
    margin: 0 auto;
    padding: 0;
    max-width: 38rem;
    text-align: center;
}

.resource-list li {
    margin: 0.4rem 0;
}

.resource-list a {
    word-break: break-all;
}

/* === Responsive: Tablet & Mobile === */
@media (max-width: 820px) {
    body {
        line-height: 1.65;
    }

    .page-wrapper {
        padding: 1rem 0.75rem;
    }

    .hero {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
    }

    .hero-image {
        align-items: center;
    }

    .nav-primary,
    .nav-languages {
        text-align: center;
        min-width: 0;
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.25rem 0.5rem;
    }

    nav a {
        font-size: clamp(0.9rem, 0.85rem + 0.4vw, 1.05rem);
        white-space: normal;
        padding: 0.2rem 0;
    }

    main p {
        text-align: left;
        margin-bottom: 1rem;
    }

    main h2 {
        margin: 1.25rem 0 0.6rem;
    }

    #istorija {
        overflow-x: auto;
    }

    .history-table {
        min-width: 500px;
        font-size: clamp(0.85rem, 0.8rem + 0.5vw, 0.95rem);
    }

    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.5rem;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .video-wrap iframe,
    .video-container iframe,
    .video-wrapper iframe {
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 9;
    }
}

@media (max-width: 480px) {
    body {
        font-size: clamp(0.95rem, 0.9rem + 0.5vw, 1rem);
        line-height: 1.6;
    }

    .page-wrapper {
        padding: 0.75rem 0.5rem;
    }

    main h2 {
        font-size: clamp(1rem, 0.95rem + 0.5vw, 1.1rem);
    }

    .gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.4rem;
    }

    .gallery img {
        max-height: 110px;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .history-table {
        font-size: clamp(0.8rem, 0.75rem + 0.5vw, 0.9rem);
        min-width: 420px;
    }

    .year {
        width: 80px;
    }
}

/* === Print === */
@media print {
    body {
        background: #fff;
        color: #000;
        font-size: 12pt;
    }

    .hero {
        display: block;
    }

    .nav-primary,
    .nav-languages {
        display: none;
    }

    a {
        color: #000 !important;
        text-decoration: underline !important;
    }
}
