/*
Theme Name: Init Press
Theme URI: https://inithtml.com/theme/init-press/
Author: Init HTML
Author URI: https://inithtml.com/
Description: A modern, performance-focused WordPress blog theme built for writers, creators, and publishers. Init Press features a guided Setup Wizard, clean typography, SEO-first structure, and seamless auto-updates via the Init Ecosystem.
Version: 1.3.4
Requires at least: 6.3
Tested up to: 7.2
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: init-press
Domain Path: /languages
Tags: blog, publishing, content, news, magazine, personal blog, clean, fast, modern, seo
*/

/* Theme Colors */

:root {
    --ip-font-scale: 100;
    --ip-gradient: linear-gradient(to right, var(--ip-theme-color), var(--ip-gradient-color));

    /* Design tokens — light values match UIkit's defaults.
       Skins override these instead of re-declaring selector lists. */
    --ip-radius: 10px;
    --ip-card-bg: #fff;
    --ip-heading-color: #333;
    --ip-muted: #999;
    --ip-line: #e5e5e5;
    --ip-surface-muted: #f8f8f8;
    --ip-shadow: 0 5px 15px rgba(0, 0, 0, .08);
    --ip-shadow-hover: 0 14px 25px rgba(0, 0, 0, .16);

    /* Dark surfaces (used whenever dark mode is on) */
    --ip-dark-surface: #272727;
    --ip-dark-surface-2: #2a2a2a;
}

/* Values while dark mode is on. data-theme is set by the inline script in
   <head> before first paint, so everything below renders dark immediately —
   no JavaScript class swapping, no flash. */
html[data-theme="dark"] {
    color-scheme: dark;
    --ip-card-bg: var(--ip-dark-surface);
    --ip-heading-color: #fff;
    --ip-muted: rgba(255, 255, 255, .5);
    --ip-line: rgba(255, 255, 255, .12);
    --ip-surface-muted: rgba(255, 255, 255, .05);
    --ip-shadow: 0 5px 15px rgba(0, 0, 0, .25);
    --ip-shadow-hover: 0 14px 25px rgba(0, 0, 0, .45);
}

::selection {
    background: var(--ip-theme-color);
}

.is-pinned,
.theme-color {
    color: var(--ip-theme-color) !important;
}

.uk-link,
a {
    color: var(--ip-theme-color);
}

.uk-link-toggle:hover .uk-link,
.uk-link:hover,
a:hover,
.uk-link-heading a:hover,
.uk-link-toggle:hover .uk-link-heading,
a.uk-link-heading:hover {
    color: var(--ip-theme-color);
}

#iep-modal.iep-dark input[type="checkbox"]:checked:focus,
#iep-modal input[type="checkbox"]:checked:focus {
    background-color: var(--ip-theme-color);
}

.uk-button-primary,
#iep-modal.iep-dark input[type="checkbox"]:checked,
#iep-modal input[type="checkbox"]:checked {
    background-color: var(--ip-theme-color);
}

.uk-button-primary.uk-active,
.uk-button-primary:active,
.uk-button-primary:hover {
    background-color: var(--ip-theme-hover);
}

#iep-modal input[type="checkbox"]:focus,
.uk-button-special {
    border-color: var(--ip-theme-color) !important;
}

em {
    color: currentColor;
}

.no-color,
.not-achieved {
    filter: grayscale(100%);
}

.uk-progress::-webkit-progress-value {
    background: var(--ip-gradient);
}

.uk-progress::-moz-progress-bar {
    background: var(--ip-gradient);
}

.uk-offcanvas-page #wpadminbar {
    position: fixed;
    z-index: 999 !important;
}

@media (max-width: 639px) {
    .uk-offcanvas-bar {
        width: 310px;
    }
}

/* Logo */

.site-name {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1;
}

.site-logo {
    max-height: 45px;
    width: auto;
}

.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Post */

.uk-breadcrumb {
    line-height: 20px;
}

.uk-article+.uk-article {
    margin-top: 45px;
}

.uk-overflow-x-auto {
    overflow-x: auto;
    overflow-y: hidden;
}

.disable-scrollbar::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.max-2-line,
.max-3-line {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.max-2-line {
    -webkit-line-clamp: 2;
}
.max-3-line {
    -webkit-line-clamp: 3;
}

@media (max-width: 480px) {
    .format-standard .uk-width-auto img.wp-post-image {
        width: 95px;
        height: auto;
    }
}

.uk-article-content h1,
.uk-article-content h2,
.uk-article-content h3,
.uk-article-content h4,
.uk-article-content h5,
.uk-article-content h6 {
    font-weight: 700;
    margin-top: 0;
}

.format-standard .uk-width-auto img.wp-post-image {
    width: 115px;
    height: auto;
}

.recent-post-thumbnail img {
    width: 85px;
    max-width: 85px;
    height: 85px;
    object-fit: cover;
}

/* Sidebar Recent Posts tabs (Day / Week / Month / All Time / Latest) */

/* Drop UIkit's 20px tab gutter so five tabs fit a sidebar column; logical
   properties keep this correct under RTL too */

#recent-posts-widget .ip-recent-tabs {
    margin-inline: 0;
}

#recent-posts-widget .ip-recent-tabs::before {
    inset-inline: 0;
}

#recent-posts-widget .ip-recent-tabs > * {
    flex: 1 1 auto;
    padding-inline-start: 0;
}

#recent-posts-widget .ip-recent-tabs > * > a {
    padding: 6px 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: none;
    white-space: nowrap;
}

#recent-posts-widget .ip-recent-tabs > .uk-active > a {
    border-color: var(--ip-theme-color);
}

.ip-recent-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 12px;
}

.format-standard .uk-width-expand .max-3-line p {
    margin-bottom: 0;
}

.uk-article-content img {
    border-radius: 5px;
}

.uk-article-content .aligncenter {
    display: block;
    margin-inline: auto;
}

.uk-text-initcase {
    text-transform: initial;
}

.wp-caption-text {
    margin-top: 15px;
}

.uk-pagination .uk-active a,
.uk-pagination .uk-active span {
    border-bottom: 1px solid var(--ip-theme-color);
}

.uk-border-modal {
    border-radius: 12px;
}

/* Scrollbar for code blocks */

pre[class*=language-]::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
pre[class*=language-]::-webkit-scrollbar-thumb {
    background-color: var(--ip-theme-color);
    outline: 0;
}

/* Size */

.format-standard .uk-article-title {
    font-size: 1.6rem;
}

@media (min-width: 960px) {
    .format-standard .uk-article-title {
        font-size: 1.8rem;
    }
}

/* Recent comments */

.recent-comment-max-height {
    max-height: 650px;
}

#recent-comments-page .recent-comment-max-height {
    max-height: none !important;
}

/* Image Size */

.image-16-9 {
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.image-1-1 {
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

.image-3-4 {
    aspect-ratio: 3 / 4;
    object-fit: cover;
}

.image-4-3 {
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.video-16-9 {
    aspect-ratio: 16 / 9;
    width: 100%;
    height: auto;
    display: block;
}

/* Comments */

.uk-comment-list>:nth-child(n+2),
.uk-comment-list .uk-comment~ul {
    margin-top: 40px;
}

@media (min-width: 960px) {
    .uk-comment-list .uk-comment~ul {
        padding-inline-start: 50px;
    }
}

.cmt-clipping {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}

/* Dark mode toggle */

.mode-checkbox {
    opacity: 0;
    position: absolute;
    z-index: 999;
    cursor: pointer;
}

.mode-checkbox-label {
    width: 44px;
    height: 26px;
    border-radius: 50px;
    position: relative;
    padding: 0 5px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    overflow: hidden;
}

/* Driven by html[data-theme], which is already correct before first paint —
   the switch shows the right state immediately, no JS class swap needed. */
html[data-theme="dark"] .mode-checkbox-label {
    background: linear-gradient(to right, #2c3e50, #2980b9);
}

html[data-theme="dark"] .mode-checkbox-label:before {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    top: 2px;
    left: 15px;
    background: url('data:image/svg+xml,<svg viewBox="0 0 24 24" fill="%23fff" xmlns="http://www.w3.org/2000/svg"><path d="M7.45 2.71a1.13 1.13 0 0 1 2.1 0l1.16 2.95q.18.45.63.63l2.95 1.16c.95.38.95 1.72 0 2.1l-2.95 1.16q-.45.18-.63.63L9.55 14.3c-.38.95-1.72.95-2.1 0L6.3 11.34a1.1 1.1 0 0 0-.63-.63L2.7 9.55a1.13 1.13 0 0 1 0-2.1L5.66 6.3q.45-.18.63-.63zm9.47 10.69a.62.62 0 0 1 1.16 0l.9 2.28q.1.24.34.34l2.29.9c.52.21.52.95 0 1.16l-2.29.9a.6.6 0 0 0-.34.34l-.9 2.29a.62.62 0 0 1-1.16 0l-.9-2.29a.6.6 0 0 0-.34-.34l-2.29-.9a.62.62 0 0 1 0-1.16l2.29-.9a.6.6 0 0 0 .34-.34z"/></svg>');
    animation: fade-stars 3s ease infinite;
    pointer-events: none;
    z-index: 0;
    will-change: opacity;
}

@keyframes fade-stars {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.3; }
}

html:not([data-theme="dark"]) .mode-checkbox-label {
    background: linear-gradient(to left, #0052d4, #65c7f7, #9cecfb);
}

html:not([data-theme="dark"]) .mode-checkbox-label:after {
    content: '';
    position: absolute;
    width: 32px;
    height: 32px;
    top: 8px;
    left: -32px;
    background: url('data:image/svg+xml,<svg viewBox="0 -4 32 32" fill="%23fff" xmlns="http://www.w3.org/2000/svg"><path d="M23.07 5.03A9 9 0 0 0 6.03 8.35 8.1 8.1 0 0 0 0 16c0 4.26 3.54 7.75 8 8h15c4.97 0 9-4.25 9-9.5a9.5 9.5 0 0 0-8.93-9.47" fill-rule="evenodd"/></svg>');
    /* Tối ưu chuyển đổi từ left sang translateX để ép dùng GPU */
    animation: chillin-cloud 10s linear infinite;
    pointer-events: none;
    z-index: 0;
    will-change: transform;
}

@keyframes chillin-cloud {
    0%   { transform: translateX(0); }
    100% { transform: translateX(86px); } /* Khoảng dịch chuyển tương đương từ -32px đến 54px */
}

.light-mode-icon {
    color: #f3c612;
}

.dark-mode-icon {
    color: #f1c40f;
}

.mode-checkbox-label .ball {
    background-color: #fff;
    width: 22px;
    height: 22px;
    position: absolute;
    left: 2px;
    top: 2px;
    border-radius: 50%;
    /* Dùng transform thay vì left/top để GPU gánh hộ */
    transition: transform 0.2s linear;
    z-index: 1;
    will-change: transform;
}

/* Tạm dừng animation khi class paused được kích hoạt */
.mode-checkbox-label.paused,
.mode-checkbox-label.paused::before,
.mode-checkbox-label.paused::after {
    animation-play-state: paused !important;
}

html[data-theme="dark"] .mode-checkbox-label .ball {
    transform: translateX(28px);
}

[dir="rtl"] .mode-checkbox-label {
    direction: ltr;
}

.mode-checkbox:focus-visible + .mode-checkbox-label {
    outline: 2px solid var(--ip-theme-color);
    outline-offset: 2px;
}

/* Dark mode toggle — Simple style */

.ip-mode-simple-btn {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.ip-mode-simple-btn:hover,
.ip-mode-simple-btn:focus {
    background-color: rgba(128, 128, 128, .15);
}

.ip-mode-simple-btn:focus {
    outline: none;
}

.ip-mode-simple-icon-moon {
    color: #7c8ba1;
}

.ip-mode-simple-icon-sun {
    display: none;
    color: #f3c612;
}

html[data-theme="dark"] .ip-mode-simple-icon-moon {
    display: none;
}

html[data-theme="dark"] .ip-mode-simple-icon-sun {
    display: block;
}

/* Dark mode */

.uk-light .uk-navbar-dropdown-nav .uk-nav-header {
    color: rgba(255,255,255,.9);
}

.uk-light .uk-section-default,
.uk-light .uk-navbar-dropdown,
.uk-light .uk-section-muted,
.uk-light .uk-comment-primary,
.uk-light .uk-card-default,
.uk-light .uk-navbar-container:not(.uk-navbar-transparent),
.uk-light .uk-background-muted,
.uk-light .uk-card-secondary,
.uk-light .uk-card-secondary.uk-card-hover:hover,
.uk-light .uk-modal-dialog,
.uk-light .uk-modal-header,
.uk-light .uk-modal-footer {
    background-color: var(--ip-dark-surface);
}

/* Dark cards, CSS-only.
   Up to 1.3.2 the theme swapped .uk-card-default → .uk-card-secondary with
   JavaScript on DOMContentLoaded, so every card first painted with light
   text colors and then "blinked". These rules give .uk-card-default the
   exact .uk-card-secondary look from UIkit (inverse context, text colors,
   title color, hover, shadow) as soon as dark mode is on — including cards
   injected later by AJAX, dropdowns or plugins. */
html[data-theme="dark"] .uk-card-default,
.uk-light .uk-card-default {
    --uk-inverse: light;
    background-color: var(--ip-dark-surface);
    color: rgba(255, 255, 255, .7);
    box-shadow: 0 5px 15px rgba(0, 0, 0, .08);
}

html[data-theme="dark"] .uk-card-default .uk-card-title,
.uk-light .uk-card-default .uk-card-title {
    color: #fff;
}

html[data-theme="dark"] .uk-card-default.uk-card-hover:hover,
.uk-light .uk-card-default.uk-card-hover:hover {
    background-color: var(--ip-dark-surface);
    box-shadow: 0 14px 25px rgba(0, 0, 0, .16);
}

html[data-theme="dark"] .uk-card-default .uk-card-header,
.uk-light .uk-card-default .uk-card-header {
    border-bottom-color: rgba(255, 255, 255, .2);
}

html[data-theme="dark"] .uk-card-default .uk-card-footer,
.uk-light .uk-card-default .uk-card-footer {
    border-top-color: rgba(255, 255, 255, .2);
}

/* Keep genuinely secondary cards (and plugins that still add the class)
   on the same surface as the default ones */
html[data-theme="dark"] .uk-card-secondary,
html[data-theme="dark"] .uk-card-secondary.uk-card-hover:hover {
    background-color: var(--ip-dark-surface);
}

/* Focus Mode */

body.is-focus-mode #ip-sidebar {
    display: none !important;
}

body.is-focus-mode #ip-content {
    margin-inline: auto;
}

/* Post Meta (RTL-safe) */

.uk-article-meta {
    display: flex;
    align-items: center;
    gap: 15px;
}

.ip-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Comment identity (Name / Email / Website remembered via localStorage) */

.ip-comment-identity-summary {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ip-comment-identity-change {
    text-decoration: underline;
}

.iep-embed-ui .iep-copy-btn {
    padding: 0 !important;
}

.iep-embed-ui .iep-copy-btn:hover {
    color: #666 !important;
}

/* Back to Top */

#ip-back-to-top {
    position: fixed;
    bottom: 15px;
    inset-inline-end: 15px;
    z-index: 999;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background-color: var(--ip-theme-color);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease, background-color 0.2s ease;
}

#ip-back-to-top.ip-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#ip-back-to-top:hover,
#ip-back-to-top:focus {
    background-color: var(--ip-theme-hover);
}

#ip-back-to-top:focus {
    outline: 2px solid var(--ip-theme-color);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    #ip-back-to-top {
        transition: none;
    }
}

/* Reading Progress Bar */

#ip-reading-progress {
    position: fixed;
    top: 0;
    inset-inline-start: 0;
    width: 0%;
    height: 3px;
    background: var(--ip-gradient);
    z-index: 999;
    transition: width 0.1s ease-out;
}

@media (prefers-reduced-motion: reduce) {
    #ip-reading-progress {
        transition: none;
    }
}

/* Đứng dưới #wpadminbar thay vì bị nó đè lên — theo đúng chiều cao responsive
   mà WordPress core dùng cho thanh admin bar (32px desktop, 46px < 783px). */
body.admin-bar #ip-reading-progress {
    top: 32px;
}

@media screen and (max-width: 782px) {
    body.admin-bar #ip-reading-progress {
        top: 0;
    }
}

/* Pinned Post Badge */

.ip-pinned-badge {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.ip-pinned-badge [uk-icon] {
    width: 14px;
    height: 14px;
}

.single .ip-pinned-badge {
    font-size: 12px;
}

.single .ip-pinned-badge [uk-icon] {
    width: 16px;
    height: 16px;
}

/* Reading Font Size Control */

.uk-article-content {
    font-size: calc(1em * var(--ip-font-scale) / 100);
}

.ip-font-size-control {
    position: fixed;
    bottom: 15px;
    inset-inline-start: 15px;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    border-radius: 999px;
}

.ip-font-size-btn {
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    padding: 6px;
    border-radius: 999px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.ip-font-size-btn:hover,
.ip-font-size-btn:focus {
    background-color: var(--ip-theme-color);
    color: #fff;
}

.ip-font-size-btn:focus {
    outline: none;
}

.ip-font-size-divider {
    width: 1px;
    height: 18px;
    background-color: rgba(128, 128, 128, .3);
    margin: 0 2px;
}

.ip-focus-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Dưới 960px (mốc @m của UIkit), #ip-sidebar không còn nằm ở cột riêng nữa mà
   xếp chồng xuống dưới #ip-content — Focus Mode (vốn chỉ ẩn cột sidebar) không
   còn tác dụng thu gọn bố cục như trên desktop, nên ẩn hẳn nút + divider đi. */
@media (max-width: 959.98px) {
    .ip-focus-toggle-btn,
    .ip-font-size-control .ip-font-size-divider:has(+ .ip-focus-toggle-btn) {
        display: none !important;
    }
}

@media print {
    .ip-font-size-control {
        display: none !important;
    }
}

/* "Only show within the reading area" option: hidden by default, revealed
   by JS (IntersectionObserver against .uk-article.post) once that element
   is actually in view, hidden again once scrolled past it. */
.ip-reading-controls-scoped {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.ip-reading-controls-scoped.ip-reading-controls-in-view {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
    .ip-reading-controls-scoped {
        transition: none;
    }
}

/* Series Progress & Index */

.init-series-progress-badge {
    font-size: 11px;
    vertical-align: middle;
}

.init-series-progress-bar {
    width: 100%;
    height: 4px;
    border-radius: 999px;
    background-color: rgba(0, 0, 0, .08);
    overflow: hidden;
}

.init-series-progress-fill {
    height: 100%;
    background: var(--ip-gradient);
    transition: width 0.3s ease;
}

.init-series-index-current {
    color: var(--ip-theme-color);
}

/* Print Stylesheet */

@media print {
    #ip-header,
    #ip-sidebar,
    #ip-footer,
    #ip-back-to-top,
    #ip-reading-progress,
    .like-share-section,
    .uk-breadcrumb,
    .related-posts-section,
    #comments,
    .uk-offcanvas {
        display: none !important;
    }

    body {
        background: #fff !important;
        color: #000 !important;
    }

    #ip-content {
        width: 100% !important;
        margin: 0 !important;
    }

    a {
        color: #000 !important;
        text-decoration: underline;
    }

    .uk-article-content img {
        max-width: 100% !important;
        page-break-inside: avoid;
    }

    .uk-article-title,
    h1, h2, h3 {
        page-break-after: avoid;
    }
}

/* ============================================
   READING PROGRESS CIRCLE + TOC v3
   ============================================ */

/* --- Wrapper --- */
.ip-toc-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

/* --- Trigger button --- */
.ip-toc-placeholder,
.ip-toc-trigger {
    position: relative;
    width: 28px !important;
    height: 28px !important;
    padding: 0 !important;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 50%;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.ip-toc-trigger:hover,
.ip-toc-trigger:focus {
    background-color: rgba(128, 128, 128, 0.15);
}

.ip-toc-trigger:focus-visible {
    outline: 2px solid var(--ip-theme-color);
    outline-offset: 2px;
}

/* --- SVG Circle 22px --- */
.ip-toc-circle-svg {
    display: block;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.ip-toc-circle-bar {
    transition: stroke-dashoffset 0.12s ease-out;
    will-change: stroke-dashoffset;
}

/* --- Dropdown --- */
.ip-toc-drop {
    width: 300px;
    max-width: calc(100vw - 28px);
    border-radius: 10px;
    padding: 0;
    overflow: hidden;
}

.ip-toc-drop .uk-card-header {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(128, 128, 128, 0.12);
}

.ip-toc-drop .uk-card-header h5 {
    font-size: 13px;
    letter-spacing: 0.2px;
}

.ip-toc-drop .uk-card-body {
    padding: 4px 0;
}

/* Scrollbar */
.ip-toc-drop .uk-card-body::-webkit-scrollbar {
    width: 3px;
}

.ip-toc-drop .uk-card-body::-webkit-scrollbar-track {
    background: transparent;
}

.ip-toc-drop .uk-card-body::-webkit-scrollbar-thumb {
    background-color: rgba(128, 128, 128, 0.25);
    border-radius: 3px;
}

/* --- TOC Nav --- */
.ip-toc-nav {
    padding: 0;
    margin: 0;
    list-style: none;
}

.ip-toc-nav > li {
    margin: 0;
}

.ip-toc-nav > li > a.ip-toc-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    color: inherit;
    text-decoration: none;
    font-size: 12.5px;
    line-height: 1.35;
    transition: background-color 0.12s ease, color 0.12s ease;
    min-height: 28px;
}

.ip-toc-nav > li > a.ip-toc-item:hover {
    background-color: rgba(128, 128, 128, 0.06);
    color: var(--ip-theme-color);
}

.ip-toc-nav > li.uk-active > a.ip-toc-item {
    background-color: rgba(var(--ip-theme-color-rgb), 0.07);
    color: var(--ip-theme-color);
    font-weight: 600;
}

/* Dot */
.ip-toc-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: rgba(128, 128, 128, 0.35);
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.ip-toc-dot-active {
    background-color: var(--ip-theme-color);
    transform: scale(1.4);
}

/* Percent in header */
.ip-toc-percent {
    font-size: 11px;
    font-weight: 700;
    color: var(--ip-theme-color);
}

/* --- Dark mode --- */
.uk-light .ip-toc-drop {
    background-color: var(--ip-dark-surface-2);
}

.uk-light .ip-toc-drop .uk-card-header {
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

.uk-light .ip-toc-nav > li > a.ip-toc-item:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

.uk-light .ip-toc-dot {
    background-color: rgba(255, 255, 255, 0.25);
}

/* --- Responsive --- */
@media (max-width: 480px) {
    .ip-toc-drop {
        width: 260px;
    }
    .ip-toc-drop .uk-card-body {
        max-height: 50vh !important;
    }
}

@media print {
    .ip-toc-wrap {
        display: none !important;
    }
}

/* ==========================================================================
   HIGHLIGHT & NOTE
   ========================================================================== */

mark.ip-highlight {
    background-color: rgba(var(--ip-theme-color-rgb), 0.25);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
    cursor: pointer;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

mark.ip-highlight:hover {
    background-color: rgba(var(--ip-theme-color-rgb), 0.4);
}

mark.ip-highlight.ip-highlight-has-note {
    box-shadow: inset 0 -2px 0 0 var(--ip-theme-color);
}

/* Toolbar nổi khi bôi đen văn bản */
.ip-highlight-toolbar {
    position: absolute;
    z-index: 999;
    display: flex;
    gap: 2px;
    background-color: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    padding: 4px;
}

.ip-highlight-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.2;
    text-transform: none;
    letter-spacing: normal;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}
.ip-highlight-btn:hover,
.ip-highlight-btn:focus-visible {
    background-color: rgba(var(--ip-theme-color-rgb), 0.12);
    color: var(--ip-theme-color);
}
.ip-highlight-btn-danger:hover,
.ip-highlight-btn-danger:focus-visible {
    background-color: rgba(224, 67, 63, 0.12);
    color: #e0433f;
}

/* Popover xem/sửa ghi chú khi click vào đoạn đã highlight */
.ip-highlight-popover {
    position: absolute;
    z-index: 999;
    max-width: calc(100vw - 16px);
    box-sizing: border-box;
    background-color: #fff;
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    padding: 4px;
}

.ip-highlight-popover-note {
    margin: 0 0 8px;
    padding: 4px;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.ip-highlight-popover-textarea {
    display: block;
    width: 100%;
    min-width: 260px;
    min-height: 70px;
    box-sizing: border-box;
    resize: vertical;
    font-size: 13px;
    line-height: 1.5;
    padding: 8px;
    border: 1px solid rgba(128, 128, 128, 0.25);
    outline: none;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    margin-bottom: 4px;
}

.ip-highlight-popover-actions {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
}

/* --- Dark mode --- */
.uk-light .ip-highlight-toolbar,
.uk-light .ip-highlight-popover {
    background-color: var(--ip-dark-surface-2);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.uk-light .ip-highlight-popover-textarea {
    border-color: rgba(255, 255, 255, 0.15);
}

/* --- In: bỏ toolbar/popover, giữ nguyên nền highlight --- */
@media print {
    .ip-highlight-toolbar,
    .ip-highlight-popover {
        display: none !important;
    }
}

/* ==========================================================================
   1.3.4 — Content tools
   ========================================================================== */

/* --- Code block toolbar (Copy + language label) --- */

.ip-code-block {
    position: relative;
    margin: 0 0 20px 0;
}

* + .ip-code-block {
    margin-top: 20px;
}

.ip-code-block > pre {
    margin-top: 0;
    margin-bottom: 0;
}

.ip-code-block.has-lang > pre {
    padding-top: 30px;
}

.ip-code-toolbar {
    position: absolute;
    top: 6px;
    inset-inline-end: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 1;
    pointer-events: none;
}

.ip-code-lang::before {
    content: attr(data-lang);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ip-muted);
}

.ip-code-copy {
    pointer-events: auto;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--ip-line);
    border-radius: 8px;
    background: var(--ip-card-bg);
    color: var(--ip-muted);
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s ease, color .15s ease, border-color .15s ease;
}

.ip-code-block:hover .ip-code-copy,
.ip-code-copy:focus-visible,
.ip-code-copy.is-copied {
    opacity: 1;
}

/* Touch screens have no hover: keep the button visible */
@media (hover: none) {
    .ip-code-copy {
        opacity: 1;
    }
}

.ip-code-copy:hover,
.ip-code-copy:focus-visible {
    color: var(--ip-theme-color);
    border-color: var(--ip-theme-color);
}

.ip-code-copy:focus-visible {
    outline: 2px solid var(--ip-theme-color);
    outline-offset: 2px;
}

.ip-code-copy.is-copied {
    color: #32d296;
    border-color: #32d296;
}

/* "Copied!" bubble — drawn with CSS so no text lands in the article DOM */
.ip-code-copy[data-feedback]::after {
    content: attr(data-feedback);
    position: absolute;
    top: 50%;
    inset-inline-end: calc(100% + 6px);
    transform: translateY(-50%);
    padding: 2px 8px;
    border-radius: 6px;
    background: #32d296;
    color: #fff;
    font-size: 12px;
    line-height: 20px;
    white-space: nowrap;
}

/* --- Heading anchor links --- */

.uk-article-content h1[id],
.uk-article-content h2[id],
.uk-article-content h3[id],
.uk-article-content h4[id],
.uk-article-content h5[id],
.uk-article-content h6[id] {
    scroll-margin-top: 24px;
}

.admin-bar .uk-article-content [id] {
    scroll-margin-top: 56px;
}

.ip-heading-anchor {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    margin-inline-start: .35em;
    padding: 2px;
    border-radius: 6px;
    color: var(--ip-muted);
    opacity: 0;
    transition: opacity .15s ease, color .15s ease;
}

.ip-has-anchor:hover .ip-heading-anchor,
.ip-heading-anchor:focus-visible {
    opacity: 1;
}

.ip-heading-anchor:hover,
.ip-heading-anchor:focus-visible {
    color: var(--ip-theme-color);
}

.ip-heading-anchor:focus-visible {
    outline: 2px solid var(--ip-theme-color);
    outline-offset: 2px;
}

@media (hover: none) {
    .ip-heading-anchor {
        opacity: .45;
    }
}

/* --- Share menu --- */

.ip-share-dropdown {
    min-width: 200px;
    padding: 12px;
}

html[data-theme="dark"] .ip-share-dropdown {
    background-color: var(--ip-dark-surface-2);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
}

.ip-share-dropdown .uk-nav > li > a {
    display: flex;
    align-items: center;
    padding: 6px 4px;
    color: var(--ip-heading-color);
}

.ip-share-dropdown .uk-nav > li > a:hover,
.ip-share-dropdown .uk-nav > li > a:focus-visible {
    color: var(--ip-theme-color);
}

/* --- Image lightbox --- */

.ip-lightbox-img,
.ip-lightbox-link img {
    cursor: zoom-in;
}

.ip-lightbox-img:focus-visible {
    outline: 2px solid var(--ip-theme-color);
    outline-offset: 3px;
}

/* --- 404 suggestions --- */

.ip-404-suggestions .uk-list > li {
    padding-top: 10px;
}

@media (prefers-reduced-motion: reduce) {
    .ip-code-copy,
    .ip-heading-anchor {
        transition: none;
    }
}

@media print {
    .ip-code-toolbar,
    .ip-heading-anchor {
        display: none !important;
    }

    .ip-code-block.has-lang > pre {
        padding-top: 10px;
    }
}
