/* =========================================================================
   FRONTEND LAYOUT – rozloženie verejnej časti a používateľskej zóny.
   Farby a tvary sú v theme.css.
   ========================================================================= */

.site-main {
    min-height: 60vh;
}

/* Skip-to-content: viditeľný až pri fokuse klávesnicou. */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 1080;
    padding: 0.6rem 1rem;
    background: var(--color-surface-raised);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: 0 0 var(--border-radius) 0;
}

.skip-link:focus {
    left: 0;
}

/* Text nemá byť na ultrawide monitore neobmedzene široký (§13). */
.content-column {
    max-width: var(--content-width);
}

.site-header {
    background: var(--color-surface);
}

.site-footer {
    background: var(--color-surface);
}

.dev-preview-banner {
    background: #7a2e2e;
    color: #fff;
}

.dev-preview-banner code {
    color: #ffd9d9;
}

.theme-toggle {
    white-space: nowrap;
}

.flash-messages:empty {
    display: none;
}

/* --- Obsah článku -------------------------------------------------------- */

.content-title {
    font-size: clamp(1.6rem, 1.2rem + 1.8vw, 2.35rem);
}

.content-excerpt {
    color: var(--color-text-muted);
}

.article-content > * + * {
    margin-top: 1.1rem;
}

.article-content h2 {
    margin-top: 2.25rem;
    font-size: clamp(1.3rem, 1.1rem + 0.9vw, 1.6rem);
}

.article-content h3 {
    margin-top: 1.75rem;
    font-size: clamp(1.15rem, 1.05rem + 0.5vw, 1.3rem);
}

.article-content ul,
.article-content ol {
    padding-left: 1.35rem;
}

.article-content li + li {
    margin-top: 0.35rem;
}

.article-content blockquote {
    margin: 1.75rem 0;
    padding: 0.25rem 0 0.25rem 1.15rem;
    border-left: 4px solid var(--color-primary);
    color: var(--color-text-muted);
    font-style: italic;
}

.article-content pre {
    padding: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    overflow-x: auto;
}

.article-content :not(pre) > code {
    padding: 0.1em 0.35em;
    background: var(--color-surface);
    border-radius: var(--border-radius-sm);
    font-size: 0.9em;
}

.article-content table {
    width: 100%;
    border-collapse: collapse;
}

.article-content th,
.article-content td {
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--color-border);
    vertical-align: top;
}

.article-content thead th {
    background: var(--color-surface);
    text-align: left;
}

/* Obsahové boxy povolené whitelistom sanitizera (§19). */
.article-content .article-box-info,
.article-content .article-box-tip,
.article-content .article-box-warning,
.article-content .article-box-important,
.article-content .article-box-example {
    margin: 1.75rem 0;
    padding: 1rem 1.15rem;
    border-left: 4px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    background: var(--color-surface);
}

.article-content .article-box-info      { border-left-color: var(--color-info); }
.article-content .article-box-tip       { border-left-color: var(--color-success); }
.article-content .article-box-warning   { border-left-color: var(--color-warning); }
.article-content .article-box-important { border-left-color: var(--color-danger); }
.article-content .article-box-example   { border-left-color: var(--color-text-muted); }

.article-content .text-highlight-info,
.article-content .text-highlight-warning,
.article-content .text-highlight-success {
    padding: 0.05em 0.25em;
    border-radius: 0.2em;
}

.article-content .text-highlight-info    { background: rgba(27, 110, 194, 0.16); }
.article-content .text-highlight-warning { background: rgba(183, 121, 31, 0.20); }
.article-content .text-highlight-success { background: rgba(26, 127, 75, 0.16); }

.article-content img,
.article-content video,
.article-content iframe {
    max-width: 100%;
    height: auto;
}

.article-content figure {
    margin: 1.5rem 0;
}

.article-content figcaption {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* Široké tabuľky scrollujú samy, nie celá stránka (§14). */
.article-content .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* --- Sidebar (FÁZA 5) ----------------------------------------------------- */

.sidebar-card-thumb {
    aspect-ratio: 16 / 9;
    object-fit: cover;
    width: 100%;
}

@media (min-width: 992px) {
    .sidebar-sticky {
        position: sticky;
        top: 1rem;
    }
}

/* --- Tlač (§41) ----------------------------------------------------------- */

@media print {
    .site-header,
    .site-footer,
    .skip-link,
    .dev-preview-banner,
    .theme-toggle,
    .article-sidebar,
    .article-share,
    .article-comments {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
        font-size: 12pt;
    }

    .content-column {
        max-width: none;
    }

    a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.85em;
        word-break: break-all;
    }
}

/* --- Karta článku (sidebar aj výpisy) ------------------------------------ */

.article-card-link {
    display: flex;
    gap: 0.75rem;
    color: inherit;
    text-decoration: none;
}

.article-card-link:hover .article-card-title,
.article-card-link:focus .article-card-title {
    color: var(--color-primary);
    text-decoration: underline;
}

/* Jednotný pomer 16:9; skutočný obrázok pribudne vo FÁZE 6. */
.article-card-thumb {
    flex: 0 0 auto;
    width: 6.5rem;
    aspect-ratio: 16 / 9;
    display: grid;
    place-items: center;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    background: hsl(var(--thumb-h, 210) 45% 88%);
    color: hsl(var(--thumb-h, 210) 55% 28%);
    font-weight: 700;
}

.article-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Deterministické odtiene ako triedy – inline style by CSP zablokovala. */
.thumb-v0  { --thumb-h: 205; }
.thumb-v1  { --thumb-h: 235; }
.thumb-v2  { --thumb-h: 265; }
.thumb-v3  { --thumb-h: 295; }
.thumb-v4  { --thumb-h: 325; }
.thumb-v5  { --thumb-h: 355; }
.thumb-v6  { --thumb-h: 25; }
.thumb-v7  { --thumb-h: 45; }
.thumb-v8  { --thumb-h: 95; }
.thumb-v9  { --thumb-h: 135; }
.thumb-v10 { --thumb-h: 165; }
.thumb-v11 { --thumb-h: 185; }

[data-bs-theme="dark"] .article-card-thumb {
    background: hsl(var(--thumb-h, 210) 30% 24%);
    color: hsl(var(--thumb-h, 210) 60% 78%);
}

.article-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.article-card-title {
    font-weight: 600;
    line-height: 1.3;
}

.article-card-sidebar .article-card-title {
    font-size: 0.92rem;
}

.article-card-meta {
    color: var(--color-text-muted);
    font-size: 0.8rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Široká varianta vo výpisoch kategórií a tagov. */
.article-card-list {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.article-card-list:last-child {
    border-bottom: 0;
}

.article-card-list .article-card-thumb {
    width: 11rem;
}

.article-card-list .article-card-title {
    font-size: 1.1rem;
}

.article-card-excerpt {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.article-card-category {
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 600;
}

@media (max-width: 575.98px) {
    .article-card-list .article-card-link {
        flex-direction: column;
    }

    .article-card-list .article-card-thumb {
        width: 100%;
    }
}

/* --- Tagy ---------------------------------------------------------------- */

.tag-chip {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.85rem;
    text-decoration: none;
}

.tag-chip:hover,
.tag-chip:focus {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* --- Hlavný obrázok obsahu ----------------------------------------------- */

.featured-image {
    margin: 0 0 1.75rem;
}

.featured-image img {
    width: 100%;
    height: auto;
    border-radius: var(--border-radius);
}

.featured-image figcaption {
    margin-top: 0.5rem;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.featured-image-credit {
    display: inline-block;
    margin-left: 0.35rem;
    opacity: 0.85;
}

/* Skutočný thumbnail v karte musí vyplniť rovnaký rám ako placeholder. */
.article-card-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* --- Anketa, FAQ, TOC, zdroje (FÁZA 9) ---------------------------------- */

.poll-bar {
    height: 0.5rem;
    margin-top: 0.2rem;
    background: var(--color-surface);
    border-radius: 999px;
    overflow: hidden;
}

.poll-bar-fill {
    display: block;
    height: 100%;
    background: var(--color-primary);
    border-radius: 999px;
}

/* Šírka je trieda po 5 % – inline style by CSP zablokovala. */
.poll-fill-0 { width: 0%; }
.poll-fill-5 { width: 5%; }
.poll-fill-10 { width: 10%; }
.poll-fill-15 { width: 15%; }
.poll-fill-20 { width: 20%; }
.poll-fill-25 { width: 25%; }
.poll-fill-30 { width: 30%; }
.poll-fill-35 { width: 35%; }
.poll-fill-40 { width: 40%; }
.poll-fill-45 { width: 45%; }
.poll-fill-50 { width: 50%; }
.poll-fill-55 { width: 55%; }
.poll-fill-60 { width: 60%; }
.poll-fill-65 { width: 65%; }
.poll-fill-70 { width: 70%; }
.poll-fill-75 { width: 75%; }
.poll-fill-80 { width: 80%; }
.poll-fill-85 { width: 85%; }
.poll-fill-90 { width: 90%; }
.poll-fill-95 { width: 95%; }
.poll-fill-100 { width: 100%; }

.article-toc {
    padding: 1rem 1.15rem;
    margin: 1.75rem 0;
    background: var(--color-surface);
    border-radius: var(--border-radius);
}

.article-toc li + li { margin-top: 0.3rem; }
.article-toc .toc-level-3 { padding-left: 1.1rem; font-size: 0.925rem; }

.article-summary {
    padding: 1rem 1.15rem;
    margin: 1.75rem 0;
    background: var(--color-surface);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--border-radius-sm);
}

.faq-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--color-border);
}

.faq-item summary {
    font-weight: 600;
    cursor: pointer;
}

.faq-answer { margin-top: 0.5rem; }

.article-sources a { word-break: break-word; }

@media print {
    .article-toc,
    .article-poll,
    .article-usefulness {
        display: none !important;
    }
}

/* --- Kotva pri nadpise (§26) --------------------------------------------- */

.heading-anchor {
    margin-left: 0.4rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--color-text-muted);
    font-size: 0.7em;
    opacity: 0;
    cursor: pointer;
    transition: opacity 0.15s;
}

.article-content h2:hover .heading-anchor,
.article-content h3:hover .heading-anchor,
.heading-anchor:focus-visible {
    opacity: 1;
}

.heading-anchor.is-copied {
    opacity: 1;
    color: var(--color-success);
}

@media print {
    .heading-anchor,
    .article-share {
        display: none !important;
    }
}

/* -----------------------------------------------------------------
   Dvojfaktorové overenie (§5)
   ----------------------------------------------------------------- */

/* QR nesmie byť cez celú šírku – na veľkom monitore by bol obrovský. */
.totp-qr {
    max-width: 15rem;
}

.totp-qr .qr-code {
    display: block;
    width: 100%;
    height: auto;
    /* Biely okraj kódu má hranu aj na bielom pozadí stránky. */
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: var(--radius, 0.375rem);
}

/* Kľúč aj kódy sa prepisujú ručne – radšej väčšie a rozstrapkané. */
.totp-secret code {
    font-size: 1.15rem;
    letter-spacing: 0.12em;
    word-break: break-all;
}

.recovery-codes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    gap: 0.35rem 1rem;
}

.recovery-codes code {
    font-size: 1rem;
    letter-spacing: 0.05em;
}

/* -----------------------------------------------------------------
   Galéria a lightbox (§21)
   ----------------------------------------------------------------- */

/* Mriežka je tu, nie v uloženom HTML článku (§45). */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
    margin: 0;
    padding: 0;
}

.gallery-figure {
    margin: 0;
}

.gallery-link {
    display: block;
    overflow: hidden;
    border-radius: var(--radius, 0.375rem);
    line-height: 0;
}

.gallery-link img {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    transition: transform 0.2s ease;
}

/* Zväčšenie signalizuje, že sa obrázok dá otvoriť. */
.gallery-link:hover img,
.gallery-link:focus-visible img {
    transform: scale(1.04);
}

.gallery-caption {
    margin: 0.35rem 0 0;
    font-size: 0.85rem;
    line-height: 1.35;
    color: var(--bs-secondary-color, #6c757d);
}

.lightbox {
    max-width: min(96vw, 1400px);
    max-height: 94vh;
    padding: 0;
    border: 0;
    border-radius: var(--radius, 0.375rem);
    background: var(--bs-body-bg, #fff);
    color: var(--bs-body-color, #212529);
}

.lightbox::backdrop {
    background: rgba(0, 0, 0, 0.82);
}

.lightbox-figure {
    margin: 0;
}

.lightbox-image {
    display: block;
    max-width: 100%;
    /* Ovládanie pod obrázkom si musí nechať miesto. */
    max-height: calc(94vh - 4.5rem);
    margin: 0 auto;
    object-fit: contain;
}

.lightbox-caption {
    padding: 0.5rem 0.75rem 0;
    font-size: 0.9rem;
    text-align: center;
}

.lightbox-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem;
}

.lightbox-button {
    min-width: 2.75rem;
    min-height: 2.75rem;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: var(--radius, 0.375rem);
    background: transparent;
    color: inherit;
    font-size: 1.1rem;
    cursor: pointer;
}

.lightbox-button:hover,
.lightbox-button:focus-visible {
    background: var(--bs-tertiary-bg, #f8f9fa);
}

.lightbox-position {
    min-width: 4rem;
    text-align: center;
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
    .gallery-link img {
        transition: none;
    }

    .gallery-link:hover img,
    .gallery-link:focus-visible img {
        transform: none;
    }
}

/* -----------------------------------------------------------------
   Autorský podpis pod článkom
   ----------------------------------------------------------------- */

.author-box {
    padding-top: 1.25rem;
    border-top: 1px solid var(--bs-border-color, #dee2e6);
}

.author-box-body {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.author-box-avatar {
    flex: 0 0 auto;
    width: 4rem;
    height: 4rem;
    border-radius: 50%;
    object-fit: cover;
}

.author-box-name {
    margin: 0 0 0.25rem;
    font-weight: 600;
}

/* Bio je HTML od redakcie – odseky v ňom nemajú robiť diery. */
.author-box-bio > :first-child {
    margin-top: 0;
}

.author-box-bio > :last-child {
    margin-bottom: 0;
}

.author-box-bio {
    font-size: 0.95rem;
    line-height: 1.55;
}
