/* ============================================================
   MF — prof. Marcio Feitosa — Estilos principais
   ============================================================ */

:root {
    --color-primary:    #1a3a5c;
    --color-accent:     #2e7cbf;
    --color-light:      #f4f7fb;
    --color-white:      #ffffff;
    --color-text:       #2c2c2c;
    --color-muted:      #6b7280;
    --color-border:     #dde3ec;
    --header-height:    80px;
    --font-main:        'Inter', 'Segoe UI', system-ui, sans-serif;
    --radius:           10px;
    --shadow:           0 2px 12px rgba(0,0,0,.08);
    --shadow-card:      0 4px 20px rgba(0,0,0,.38);
}

/* ── Reset básico ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font-main);
    background: var(--color-light);
    color: var(--color-text);
    line-height: 1.65;
}
img { max-width: 100%; height: auto; display: block; }
a   { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header fixo ── */
#site-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-height);
    background: var(--color-primary);
    color: var(--color-white);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
    gap: 1rem;
}

#site-header .header-photo {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,.5);
    flex-shrink: 0;
}

#site-header .header-photo-placeholder {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

#site-header .header-title {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: .01em;
}

#site-header .header-subtitle {
    font-size: .8rem;
    opacity: .75;
    margin-top: 2px;
}

#site-header .header-login-btn {
    margin-left: auto;
    font-size: 1rem;
    opacity: .35;
    color: var(--color-white);
    text-decoration: none;
    padding: .3rem .4rem;
    border-radius: 4px;
    transition: opacity .2s;
    line-height: 1;
}
#site-header .header-login-btn:hover {
    opacity: .85;
    text-decoration: none;
    background: rgba(255,255,255,.1);
}

/* ── Layout principal ── */
#page-content {
    margin-top: var(--header-height);
}

.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* ── Seção Sobre ── */
#about {
    background: var(--color-white);
    border-bottom: 1px solid var(--color-border);
    padding: 3rem 0 2.5rem;
}

#about .about-inner {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

#about .about-photo {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: var(--shadow);
}

#about .about-photo-placeholder {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    flex-shrink: 0;
}

#about h2 {
    font-size: 1.5rem;
    color: var(--color-primary);
    margin-bottom: .5rem;
}

#about p {
    color: var(--color-muted);
    font-size: .97rem;
}

/* ── Seção Posts ── */
#posts {
    padding: 2.5rem 0 4rem;
}

/* Layout com coluna lateral */
#posts .posts-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2rem;
    max-width: 1160px;
}

#posts .posts-main { min-width: 0; }

#posts h2 {
    font-size: 1.3rem;
    color: var(--color-primary);
    margin-bottom: 1.5rem;
    padding-bottom: .5rem;
    border-bottom: 2px solid var(--color-accent);
    display: inline-block;
}

#posts h2 .cat-current-tag {
    font-size: .85rem;
    color: var(--color-muted);
    font-weight: 400;
    margin-left: .35rem;
}

/* ── Sidebar de categorias ── */
#cat-sidebar {
    background: var(--color-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.1rem;
    align-self: start;
    position: sticky;
    top: calc(var(--header-height) + 1rem);
    max-height: calc(100vh - var(--header-height) - 2rem);
    overflow-y: auto;
}

#cat-sidebar h3 {
    font-size: .78rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
    margin-bottom: .6rem;
    padding-bottom: .4rem;
    border-bottom: 1px solid var(--color-border);
}

#cat-sidebar .cat-radio {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: .55rem;
    padding: .35rem .3rem;
    font-size: .82rem;
    color: var(--color-text);
    border-radius: 6px;
    cursor: pointer;
    transition: background .12s, color .12s;
}
#cat-sidebar .cat-radio:hover { background: var(--color-light); }
#cat-sidebar .cat-radio input[type="radio"] {
    accent-color: var(--color-accent);
    margin: 0;
}
#cat-sidebar .cat-radio em {
    font-style: normal;
    font-size: .72rem;
    color: var(--color-muted);
    background: var(--color-light);
    padding: .05rem .45rem;
    border-radius: 10px;
    min-width: 1.6em;
    text-align: center;
}
#cat-sidebar .cat-radio:has(input:checked) {
    background: #eaf3fb;
    color: var(--color-primary);
    font-weight: 500;
}
#cat-sidebar .cat-radio:has(input:checked) em {
    background: var(--color-accent);
    color: #fff;
}

.cat-apply-btn {
    margin-top: .7rem; width: 100%;
    padding: .45rem; border-radius: 6px;
    border: none; background: var(--color-accent); color: #fff;
    cursor: pointer; font-size: .85rem;
}

/* ── Categorias no card de post ── */
.post-card__categories {
    display: flex; flex-wrap: wrap; gap: .3rem;
    margin-top: .4rem;
}
.post-card__categories a {
    font-size: .72rem;
    background: var(--color-light);
    color: var(--color-primary);
    padding: .1rem .55rem;
    border-radius: 10px;
    text-decoration: none;
    border: 1px solid var(--color-border);
    transition: background .15s;
}
.post-card__categories a:hover {
    background: var(--color-accent); color: #fff;
    border-color: var(--color-accent);
    text-decoration: none;
}

/* ── Card de Post ── */
.post-card {
    background: var(--color-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    margin-bottom: 1.75rem;
    overflow: hidden;
    transition: box-shadow .2s;
}
.post-card:hover { box-shadow: 0 6px 28px rgba(0,0,0,.14); }

.post-card__header {
    padding: 1.25rem 1.5rem .75rem;
}

.post-card__title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: .25rem;
}

.post-card__date {
    font-size: .78rem;
    color: var(--color-muted);
}

.post-card__body {
    padding: 0 1.5rem 1.25rem;
    font-size: .95rem;
    color: var(--color-text);
}

.post-card__body p { margin-bottom: .75rem; }
.post-card__body img {
    border-radius: var(--radius);
    margin: .75rem 0;
    max-height: 400px;
    width: 100%;
    object-fit: cover;
}

/* ── Thumbnail de destaque ── */
.post-card__thumbnail {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
}

/* ── Galeria de imagens ── */
.post-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: .5rem;
    margin: .75rem 0;
}
.post-gallery img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    transition: transform .2s;
}
.post-gallery img:hover { transform: scale(1.03); }

/* ── PDF Viewer ── */
.pdf-container {
    margin: 1rem 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.pdf-container iframe {
    width: 100%;
    height: 500px;
    border: none;
    display: block;
}

.pdf-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem 1rem;
    background: #f0f4f8;
    font-size: .85rem;
    color: var(--color-muted);
    border-top: 1px solid var(--color-border);
}

/* ── Vídeo ── */
.video-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
    border-radius: var(--radius);
    margin: .75rem 0;
    background: #000;
}
.video-container iframe,
.video-container video {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    border: none;
}

/* ── Conteúdo colapsável ── */
.post-full-content.collapsed {
    max-height: 180px;
    overflow: hidden;
    position: relative;
}
.post-full-content.collapsed::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: linear-gradient(transparent, var(--color-white));
    pointer-events: none;
}

/* ── "Ler mais" ── */
.post-card__footer {
    padding: .75rem 1.5rem 1.25rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
}

.btn-expand {
    background: none;
    border: 1px solid var(--color-accent);
    color: var(--color-accent);
    padding: .35rem .9rem;
    border-radius: 20px;
    font-size: .83rem;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.btn-expand:hover {
    background: var(--color-accent);
    color: var(--color-white);
}

/* ── Paginação / Carregar mais ── */
#load-more {
    text-align: center;
    margin-top: 1rem;
}
#load-more button {
    background: var(--color-accent);
    color: var(--color-white);
    border: none;
    padding: .65rem 2rem;
    border-radius: 25px;
    font-size: .95rem;
    cursor: pointer;
    transition: background .2s;
}
#load-more button:hover { background: var(--color-primary); }
#load-more button:disabled { background: var(--color-border); color: var(--color-muted); cursor: not-allowed; }

/* ── Loading spinner ── */
.spinner {
    display: inline-block;
    width: 22px; height: 22px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    vertical-align: middle;
    margin-right: .5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Lightbox simples ── */
#lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.85);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}
#lightbox.active { display: flex; }
#lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 6px;
    box-shadow: 0 8px 40px rgba(0,0,0,.5);
}
#lightbox-close {
    position: absolute;
    top: 1.25rem; right: 1.5rem;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    opacity: .8;
}
#lightbox-close:hover { opacity: 1; }

/* ── Responsivo ── */
@media (max-width: 860px) {
    #posts .posts-layout {
        grid-template-columns: 1fr;
    }
    #cat-sidebar {
        position: static;
        max-height: none;
    }
    #cat-sidebar .cat-radio {
        display: inline-grid;
        margin-right: .35rem;
    }
}
@media (max-width: 600px) {
    #site-header .header-title { font-size: 1rem; }
    #about .about-inner { flex-direction: column; align-items: center; text-align: center; }
    #about .about-photo, #about .about-photo-placeholder { width: 100px; height: 100px; }
    .pdf-container iframe { height: 340px; }
    .post-gallery { grid-template-columns: repeat(2, 1fr); }
}

/* ── Barra de pesquisa ── */
#search-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: .75rem;
    margin-bottom: .6rem;
}

#search-input-wrap {
    position: relative;
    flex: 1 1 380px;
}

#search-input {
    width: 100%;
    padding: .75rem 2.4rem .75rem 1.1rem;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    font-family: var(--font-main);
    font-size: 1.05rem;
    color: var(--color-text);
    background: var(--color-white);
    outline: none;
    height: 100%;
    min-height: 48px;
    transition: border-color .2s;
}
#search-input:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(46,124,191,.15);
}
#search-input::-webkit-search-cancel-button { display: none; }

#search-clear {
    position: absolute;
    right: .65rem;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    cursor: pointer;
    color: var(--color-muted);
    font-size: .9rem;
    border-radius: 50%;
    transition: color .15s, background .15s;
}
#search-clear:hover { color: var(--color-text); background: var(--color-border); }

#btn-search {
    padding: 0 1.4rem;
    min-height: 48px;
    background: var(--color-accent);
    color: var(--color-white);
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .2s, transform .1s;
    flex-shrink: 0;
}
#btn-search:hover  { background: var(--color-primary); }
#btn-search:active { transform: scale(.97); }

#search-options {
    display: flex;
    gap: 1.25rem;
    align-items: center;
    margin-bottom: .9rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .9rem;
    color: var(--color-muted);
    cursor: pointer;
    user-select: none;
}
.radio-label input[type="radio"] {
    accent-color: var(--color-accent);
    cursor: pointer;
}
.radio-label:has(input:checked) { color: var(--color-accent); font-weight: 500; }

/* ── Indicador de resultados ── */
#search-status {
    font-size: .85rem;
    color: var(--color-muted);
    min-height: 1.2em;
    margin-bottom: .5rem;
    opacity: 0;
    transition: opacity .2s;
}
#search-status.visible { opacity: 1; }
