/* [telegram_feed]: endless feed and "Ключевые слова" panel, keyword chips under posts.
 *
 * Styled like the site's theme, Twenty Sixteen: Montserrat for labels and buttons, the theme's own
 * colours, tags like the theme's tag cloud. The colours come from the light/dark/night switch of
 * the "Килослов: обзор" plugin (--km-* on <html>) when it is there, otherwise they are the theme's
 * light colours. Selectors are a little more specific than the theme's (".entry-content a" and so
 * on), so the theme's underlines and button styles don't leak into the feed. */
:root {
    --tcs-text: var(--km-text, #1a1a1a);
    --tcs-text2: var(--km-text2, #686868);
    --tcs-link: var(--km-link, #007acc);
    --tcs-page: var(--km-page, #fff);
    --tcs-border: var(--km-border, #d1d1d1);
    --tcs-input: var(--km-input, #f7f7f7);
    --tcs-ui: Montserrat, "Helvetica Neue", sans-serif;
}

.tcs-feed { position: relative; }
.tcs-item { position: relative; padding: 0 0 2.5em; margin: 0 0 2.5em; border-bottom: 1px solid var(--tcs-border); }
/* The heading (the post's first line, linked to its page) stays in the HTML for search engines and
   screen readers but is not shown: the text below already starts with the same line. */
.tcs-item-title {
    position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
    overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.tcs-item-content img, .tcs-item-content video { max-width: 100%; height: auto; }

/* The date under a post, like the theme's post dates. */
.tg-date {
    color: var(--tcs-text2); font-family: var(--tcs-ui); font-size: 13px; font-size: .8125rem; line-height: 1.6153846154;
}
.tcs-feed .tg-date a, .entry-content .tg-date a {
    color: var(--tcs-text2); box-shadow: none; text-decoration: none;
}
.tcs-feed .tg-date a:hover, .tcs-feed .tg-date a:focus,
.entry-content .tg-date a:hover, .entry-content .tg-date a:focus { color: var(--tcs-link); }

/* Keyword chips, like the theme's tags. */
.tcs-item-keywords { display: flex; flex-wrap: wrap; gap: .4375em; margin-top: 1.25em; }
.tcs-feed .tcs-chip, .tcs-post-keywords .tcs-chip {
    display: inline-block; padding: .5625em .5625em .5em; border: 1px solid var(--tcs-border); border-radius: 2px;
    color: var(--tcs-text); background: none; box-shadow: none; text-decoration: none;
    font-family: var(--tcs-ui); font-size: 13px; font-size: .8125rem; line-height: 1;
}
.tcs-feed .tcs-chip:hover, .tcs-feed .tcs-chip:focus,
.tcs-post-keywords .tcs-chip:hover, .tcs-post-keywords .tcs-chip:focus {
    color: var(--tcs-link); border-color: var(--tcs-link);
}

/* Keywords under a post on its own page */
.tcs-post-keywords { display: flex; flex-wrap: wrap; align-items: center; gap: .4375em; margin: 2em 0 1em; }
.tcs-post-keywords-label {
    margin-right: .3em; color: var(--tcs-text2); font-family: var(--tcs-ui); font-size: 13px; font-size: .8125rem;
}

/* "Ключевое слово: Гоголь · 3 записи · Очистить выбор" over the filtered feed */
.tcs-filter-bar {
    position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: baseline; gap: .5em 1em;
    padding: .875em 1em; margin: 0 0 1.75em; background: var(--tcs-page); color: var(--tcs-text);
    border: 1px solid var(--tcs-border); border-radius: 2px;
    font-family: var(--tcs-ui); font-size: 13px; font-size: .8125rem; line-height: 1.6;
}
.tcs-filter-bar[hidden] { display: none; }
.tcs-filter-name { font-weight: 700; }
.tcs-filter-count { color: var(--tcs-text2); }
.tcs-feed .tcs-kw-page, .tcs-feed .tcs-clear {
    color: var(--tcs-link); font-weight: 700; letter-spacing: .046875em; text-transform: uppercase;
    box-shadow: none; text-decoration: none;
}
.tcs-feed .tcs-kw-page[hidden] { display: none; }
/* On the right, together: "Страница слова →" (when the keyword has a page) and "Очистить выбор". */
.tcs-filter-links { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5em 1.25em; margin-left: auto; }
@media (max-width: 480px) {
    .tcs-filter-bar { gap: .4em .8em; padding: .75em .875em; }
    .tcs-filter-links { gap: .4em 1em; }
    .tcs-feed .tcs-kw-page, .tcs-feed .tcs-clear { letter-spacing: 0; }
}
.tcs-feed .tcs-kw-page:hover, .tcs-feed .tcs-kw-page:focus,
.tcs-feed .tcs-clear:hover, .tcs-feed .tcs-clear:focus { color: var(--tcs-text); }

.tcs-loader { display: flex; justify-content: center; padding: 1.5em 0; visibility: hidden; }
.tcs-loader.is-active { visibility: visible; }
.tcs-spinner {
    width: 28px; height: 28px; border-radius: 50%;
    border: 3px solid var(--tcs-border); border-top-color: var(--tcs-text2);
    animation: tcs-spin .8s linear infinite;
}
@keyframes tcs-spin { to { transform: rotate(360deg); } }
.tcs-pager[hidden] { display: none; }
.tcs-feed .tcs-pager a {
    color: var(--tcs-link); box-shadow: none; text-decoration: none;
    font-family: var(--tcs-ui); font-size: 13px; font-size: .8125rem; font-weight: 700; letter-spacing: .046875em; text-transform: uppercase;
}

/* The "Ключевые слова" button: a tab on the left edge, in the theme's accent colour, so it stands
   out on the theme's dark frame. */
.tcs-feed .tcs-kw-toggle {
    position: fixed; left: 0; top: 50%; transform: translateY(-50%); z-index: 99998;
    writing-mode: vertical-rl; rotate: 180deg; padding: 16px 9px; margin: 0; border: 0; border-radius: 0 2px 2px 0;
    background: var(--tcs-link); color: var(--tcs-page); cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
    /* Its own small font: themes would otherwise make it as big as the text. */
    font: 700 12px/1.2 var(--tcs-ui); letter-spacing: .08em; text-transform: uppercase; min-height: 0; width: auto;
}
.tcs-feed .tcs-kw-toggle:hover, .tcs-feed .tcs-kw-toggle:focus { background: var(--tcs-text); color: var(--tcs-page); }
.tcs-panel-open .tcs-kw-toggle { visibility: hidden; }

/* Phones and tablets: a small round button in the bottom-right corner instead of a tab over the text. */
@media (max-width: 900px) {
    .tcs-feed .tcs-kw-toggle {
        top: auto; left: auto; right: 14px; bottom: 16px; transform: none;
        writing-mode: horizontal-tb; rotate: none; border-radius: 999px; padding: 11px 16px;
        box-shadow: 0 3px 12px rgba(0, 0, 0, .3);
    }
    .tcs-feed { padding-bottom: 64px; } /* room so the button never hides the end of the feed */
}
.tcs-kw-overlay { position: fixed; inset: 0; z-index: 99998; background: rgba(0, 0, 0, .45); }
.tcs-kw-overlay[hidden] { display: none; }

/* The panel */
.tcs-kw-panel {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 99999; width: 300px; max-width: 85vw;
    display: flex; flex-direction: column; background: var(--tcs-page); color: var(--tcs-text);
    box-shadow: 2px 0 16px rgba(0, 0, 0, .3); border-right: 1px solid var(--tcs-border);
    transform: translateX(-105%); transition: transform .25s ease; font-size: 15px;
}
.tcs-panel-open .tcs-kw-panel { transform: none; }
.tcs-kw-head { display: flex; flex: none; align-items: center; justify-content: space-between; padding: 1.1em 1em .75em; }
.tcs-kw-head strong {
    font-family: var(--tcs-ui); font-size: 14px; font-weight: 700; letter-spacing: .046875em; text-transform: uppercase;
}
.tcs-kw-panel .tcs-kw-close {
    margin: 0; padding: 0 .2em; border: 0; background: none; box-shadow: none; color: var(--tcs-text2);
    font-size: 26px; line-height: 1; cursor: pointer; min-height: 0; width: auto;
}
.tcs-kw-panel .tcs-kw-close:hover, .tcs-kw-panel .tcs-kw-close:focus { background: none; color: var(--tcs-link); }

/* Search field and order switch, like the theme's search form. */
.tcs-kw-panel .tcs-kw-search {
    flex: none; margin: 0 1em .6em; padding: .625em .5em; width: auto;
    background: var(--tcs-input); color: var(--tcs-text); border: 1px solid var(--tcs-border); border-radius: 2px;
    font: inherit; font-size: 15px;
}
.tcs-kw-panel .tcs-kw-search:focus { background: var(--tcs-page); border-color: var(--tcs-link); outline: 0; }
.tcs-kw-panel .tcs-kw-search::placeholder { color: var(--tcs-text2); opacity: 1; }
.tcs-kw-sort {
    display: flex; flex: none; margin: 0 1em .75em; border: 1px solid var(--tcs-border); border-radius: 2px; overflow: hidden;
}
.tcs-kw-sort[hidden] { display: none; }
.tcs-kw-panel .tcs-kw-sort button {
    flex: 1 1 50%; margin: 0; padding: .55em .5em; border: 0; border-radius: 0; background: none; color: var(--tcs-text2);
    box-shadow: none; cursor: pointer; min-height: 0; width: auto;
    /* Its own small font: themes style buttons big. */
    font: 700 11px/1.3 var(--tcs-ui); letter-spacing: .046875em; text-transform: uppercase;
}
.tcs-kw-panel .tcs-kw-sort button + button { border-left: 1px solid var(--tcs-border); }
.tcs-kw-panel .tcs-kw-sort button:hover, .tcs-kw-panel .tcs-kw-sort button:focus { background: none; color: var(--tcs-link); }
.tcs-kw-panel .tcs-kw-sort button[aria-pressed="true"] { background: var(--tcs-text); color: var(--tcs-page); }

/* The list */
.tcs-kw-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 1em 1em; }
.tcs-kw-panel .tcs-kw-letter {
    margin: 1.1em 0 .3em .5em; color: var(--tcs-text2);
    font-family: var(--tcs-ui); font-size: 12px; font-weight: 700; line-height: 1.5; letter-spacing: .08em; text-transform: uppercase;
}
.tcs-kw-letter[hidden], .tcs-kw-list[hidden], .tcs-kw-list li[hidden] { display: none; }
.tcs-kw-panel .tcs-kw-list { list-style: none; margin: 0; padding: 0; }
.tcs-kw-by-count { margin-top: .4em; }
.tcs-kw-panel .tcs-kw-link {
    display: flex; justify-content: space-between; align-items: baseline; gap: .5em; padding: .3em .5em; border-radius: 2px;
    color: var(--tcs-text); box-shadow: none; text-decoration: none; line-height: 1.5;
}
.tcs-kw-panel .tcs-kw-link:hover, .tcs-kw-panel .tcs-kw-link:focus { background: var(--tcs-input); color: var(--tcs-link); }
.tcs-kw-panel .tcs-kw-list li.is-active .tcs-kw-link { background: var(--tcs-link); color: var(--tcs-page); }
.tcs-count { color: var(--tcs-text2); font-family: var(--tcs-ui); font-size: 12px; }
.tcs-kw-list li.is-active .tcs-count { color: inherit; }
.tcs-kw-empty { color: var(--tcs-text2); }
