/*
 * esablonai.lt — dizainas perkeltas iš senojo css/style.css.
 *
 * Spalvos, proporcijos ir fono paveikslėliai tyčia palikti tokie patys, kad
 * svetainė atrodytų kaip anksčiau. Pagrindinis skirtumas — tai responsive:
 * senasis variantas turėjo <meta viewport width=1024> ir atskirą mobile
 * vaizdų šaką, dėl kurios Google (mobile-first) matė skurdesnį turinį.
 */

:root {
    --ink: #333;
    --ink-soft: #666;
    --ink-faint: #999;
    --line: #ccc;
    --line-soft: #eeefef;
    --page: #eeefef;
    --card: #fff;
    --link: #08c;
    --nav-hover: #385a78;
    /*
     * Turinio plotis: iki ~1050px lango — visas plotis (mobilus/planšetė),
     * nuo ten laikosi ~1024px, kaip originalus 1024px maketas, o didesniuose
     * ekranuose auga kartu su langu, kol atsiduria į 1760px stabdį.
     *
     * 1366px lange → 1024px | 1600 → 1152 | 1920 → 1382 | 2560+ → 1760
     */
    --shell: clamp(1024px, 72vw, 1760px);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    color: var(--ink);
    background: var(--page);
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.shell {
    width: 100%;
    max-width: var(--shell);
    margin: 0 auto;
    padding: 0 16px;
}

/* --- Viršutinė juosta ----------------------------------------------------- */

.topbar {
    background: #2f4f6f url('/images/meniu.jpg') repeat-x;
}

.topbar__toggle {
    display: none;
    width: 100%;
    padding: 10px;
    border: 0;
    font: inherit;
    font-weight: 700;
    color: #fff;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin: 0;
    padding: 5px 0;
    list-style: none;
}

.nav > li {
    position: relative;
}

.nav > li > a {
    display: block;
    padding: 3px 5px;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-decoration: underline;
}

.nav > li > a:hover,
.nav > li:focus-within > a {
    background: var(--nav-hover);
    text-decoration: none;
}

.nav__sub {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 40;
    min-width: 220px;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    background: var(--nav-hover);
    display: none;
}

.nav > li:hover .nav__sub,
.nav > li:focus-within .nav__sub {
    display: block;
}

.nav__sub a {
    display: block;
    padding: 5px 12px;
    color: #fff;
    font-size: 13px;
    text-decoration: none;
}

.nav__sub a:hover {
    background: #4a7099;
}

.nav__send a {
    color: #ffe08a;
}

/* --- Logotipas ir paieška ------------------------------------------------- */

.masthead {
    background: #f5f6f6 url('/images/subheader.jpg') repeat-x;
}

.masthead__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
    padding: 10px;
}

.masthead__logo {
    flex: 0 0 auto;
}

.search {
    position: relative;
    flex: 1 1 260px;
    min-width: 0;
}

/* Laukas + mygtukas kaip vienas elementas. */
.search__field {
    display: flex;
    align-items: stretch;
    height: 40px;
    background: var(--card);
    border: 1px solid #27405a;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}

.search:focus-within .search__field {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.4);
}

.search__input {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    padding: 0 12px;
    border: 0;
    background: transparent;
    color: var(--ink);
    font-size: 14px;
    font-family: inherit;
}

.search__input:focus {
    outline: 0;
}

.search__button {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 18px;
    border: 0;
    border-left: 1px solid #27405a;
    background: #2f4f6f;
    color: #fff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

.search__button:hover {
    background: var(--nav-hover);
}

.search__button:active {
    background: #27405a;
}

.search__icon {
    flex: 0 0 auto;
}

.search__results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}

.search__results:empty {
    display: none;
}

.search__result {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--line-soft);
    font-size: 12px;
}

.search__result img {
    width: 32px;
}

/* Paieškos juosta rezultatų puslapyje (kategorija + žodis + mygtukas). */
.searchbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding-bottom: 14px;
}

.searchbar__select,
.searchbar__input {
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: var(--card);
    color: var(--ink);
    font-size: 14px;
    font-family: inherit;
}

.searchbar__select {
    flex: 0 1 220px;
    min-width: 0;
}

.searchbar__input {
    flex: 1 1 220px;
    min-width: 0;
}

.button.button--search {
    height: 36px;
    display: inline-flex;
    align-items: center;
    padding: 0 20px;
    background: #2f4f6f;
    font-size: 14px;
}

.button.button--search:hover {
    background: var(--nav-hover);
}

/* --- Puslapio karkasas ---------------------------------------------------- */

.layout {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 0 30px;
    align-items: flex-start;
}

.main {
    flex: 1 1 620px;
    min-width: 0;
    max-width: 100%;
    background: var(--card);
    padding: 10px 14px 20px;
}

.aside {
    flex: 0 1 290px;
    min-width: 0;
    max-width: 100%;
    background: var(--card);
    padding: 10px;
}

.crumb {
    font-size: 12px;
    color: var(--ink-faint);
    padding: 6px 0;
}

.page-title {
    margin: 4px 0 12px;
    font-size: 22px;
    font-weight: 700;
    color: #444;
}

.section-title {
    margin: 18px 0 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--line-soft);
    font-size: 15px;
    font-weight: 700;
}

.result-count {
    padding: 4px 0 10px;
    font-size: 12px;
    color: var(--ink-soft);
}

/* --- Dokumentų sąrašas ---------------------------------------------------- */

.doc-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.doc-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line-soft);
}

.doc-item__thumb {
    flex: 0 0 90px;
}

.doc-item__thumb img {
    width: 90px;
    border: 1px solid var(--line-soft);
    background: var(--card);
}

.doc-item__body {
    flex: 1 1 auto;
    min-width: 0;
}

.doc-item__name {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 700;
}

.doc-item__from {
    font-size: 11px;
    color: var(--ink-faint);
    margin-bottom: 4px;
}

.doc-item__desc {
    font-size: 12px;
    color: var(--ink-soft);
    overflow-wrap: break-word;
}

.doc-item__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-top: 5px;
    font-size: 11px;
    color: var(--ink-faint);
}

.related__intro {
    margin: 0 0 10px;
    color: var(--ink-soft);
}

.doc-item__stat {
    flex: 0 0 72px;
    text-align: center;
    font-size: 11px;
    color: var(--ink-soft);
}

/* Prezentacijų sąrašas senajame kode buvo plytelėmis, ne eilutėmis. */
.doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.doc-grid figure {
    margin: 0;
}

.doc-grid img {
    width: 100%;
    border: 1px solid var(--line-soft);
}

.doc-grid figcaption {
    padding-top: 6px;
    font-size: 12px;
}

/* --- Subkategorijų plytelės ----------------------------------------------- */

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tile {
    display: flex;
    height: 100%;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 16px 12px 14px;
    background: var(--card);
    border: 1px solid var(--line-soft);
    border-radius: 6px;
    text-align: center;
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.tile:hover {
    border-color: #b9c7d4;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
    text-decoration: none;
}

/* Trys populiariausių dokumentų miniatiūros, viena ant kitos kaip kortos. */
.tile__thumbs {
    display: flex;
    justify-content: center;
    height: 62px;
}

.tile__thumbs img {
    width: 44px;
    height: 62px;
    margin-left: -16px;
    border: 1px solid var(--line-soft);
    border-radius: 2px;
    background: #fff;
    object-fit: cover;
    object-position: top;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
    transition: margin-left 0.18s;
}

.tile__thumbs img:first-child {
    margin-left: 0;
}

/* Užvedus „kortos“ prasiskleidžia. */
.tile:hover .tile__thumbs img {
    margin-left: -6px;
}

.tile:hover .tile__thumbs img:first-child {
    margin-left: 0;
}

.tile__thumbs-empty {
    width: 44px;
    height: 62px;
    border: 1px dashed var(--line);
    border-radius: 2px;
}

.tile__label {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--link);
}

.tile__count {
    margin-top: auto;
    font-size: 11px;
    color: var(--ink-faint);
}

/* --- Dokumento puslapis --------------------------------------------------- */

.doc {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    /* Peržiūra + duomenys laikomi vienoje grupėje, kad per visą ekraną
       neišsiskirstytų į skirtingus kraštus. */
    max-width: 920px;
}

.doc__preview {
    flex: 1 1 320px;
    min-width: 0;
    /* Originalus failo peržiūros dydis — didinti nėra ko, tik išsipikseliuotų. */
    max-width: 425px;
}

.doc__preview img {
    width: 100%;
    border: 1px solid var(--line-soft);
}

.doc__meta {
    flex: 0 1 220px;
}

.doc__meta dl {
    margin: 0;
}

.doc__meta dt {
    font-size: 11px;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.doc__meta dd {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 700;
}

.button {
    display: inline-block;
    padding: 10px 18px;
    border: 0;
    border-radius: 4px;
    background: #5bb75b;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

/* Apatinis atsisiuntimo mygtukas — pagrindinis puslapio veiksmas. */
.doc__download {
    margin: 18px 0 6px;
}

.button--big {
    font-size: 16px;
    padding: 10px 26px;
}

.button.is-disabled {
    background: #c8c8c8;
    border-color: #c8c8c8;
    color: #f2f2f2;
    cursor: default;
    pointer-events: none;
}

.button:hover {
    background: #4a9d4a;
    text-decoration: none;
    color: #fff;
}

.vote {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 12px 0;
}

.vote button {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 4px 8px;
    border: 1px solid var(--line-soft);
    background: var(--card);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.vote img {
    width: 22px;
}

.prose {
    font-size: 14px;
    max-width: 95ch;
}

.prose h2 {
    font-size: 16px;
}

/* --- Puslapiavimas -------------------------------------------------------- */

.pager {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    padding: 14px 0;
}

.pager a,
.pager span {
    min-width: 28px;
    padding: 4px 8px;
    border: 1px solid var(--line-soft);
    text-align: center;
    font-size: 13px;
}

.pager .is-active {
    background: var(--link);
    border-color: var(--link);
    color: #fff;
    font-weight: 700;
}

/* --- Šoninis blokas ------------------------------------------------------- */

.popular {
    margin: 0;
    padding: 0;
    list-style: none;
}

.popular li {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--line-soft);
    font-size: 12px;
}

.popular img {
    width: 40px;
    flex: 0 0 40px;
}

/* Slankusis „Ieškomiausi šablonai“ blokas: matomos 3 eilutės. Tikslų aukštį
   pagal pirmą elementą nustato JS; čia — atsarginė reikšmė be JS. */
.slider {
    position: relative;
    overflow: hidden;
    max-height: 174px;
    cursor: pointer;
}

.slider [data-slider-track] {
    transition: transform 0.5s ease;
}

@media (prefers-reduced-motion: reduce) {
    .slider [data-slider-track] {
        transition: none;
    }
}

/* --- Reklamos vieta ------------------------------------------------------- */

.ad {
    margin: 14px 0;
    min-height: 1px;
    text-align: center;
}

.advert {
    margin: 14px 0;
}

.advert img {
    display: block;
    width: 100%;
    height: auto;
}

/* --- Poraštė -------------------------------------------------------------- */

.footer {
    background: #fff;
    border-top: 1px solid var(--line);
    padding: 18px 0;
    font-size: 12px;
    color: var(--ink-soft);
}

.footer__links {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    padding-bottom: 8px;
}

/* --- Mobilus ------------------------------------------------------------- */

@media (max-width: 860px) {
    .topbar__toggle {
        display: block;
    }

    /* Logotipas ir paieška netelpa vienoje eilutėje — skaidom. */
    .masthead__inner {
        gap: 10px;
    }

    .search {
        flex: 1 1 100%;
    }

    .nav {
        display: none;
        flex-direction: column;
        align-items: stretch;
        padding-bottom: 8px;
    }

    .nav.is-open {
        display: flex;
    }

    .nav > li > a {
        padding: 8px 10px;
    }

    .nav__sub {
        position: static;
        display: block;
        min-width: 0;
        background: rgba(0, 0, 0, 0.15);
    }

    .aside {
        flex-basis: 100%;
    }

    .doc-item__stat {
        display: none;
    }
}

@media (max-width: 480px) {
    .shell {
        padding: 0 10px;
    }

    /* Siaurame ekrane mygtuke lieka tik piktograma. */
    .search__button {
        padding: 0 14px;
    }

    .search__button-text {
        display: none;
    }

    .doc-item__thumb,
    .doc-item__thumb img {
        flex-basis: 64px;
        width: 64px;
    }

    .page-title {
        font-size: 19px;
    }
}
