:root {
    color-scheme: light;
    --primary: #3776ab;        /* azul do logo oficial do Python */
    --primary-dark: #2c5f8a;
    --primary-soft: #e8f1f8;
    --button-primary-bg: #3776ab;
    --button-primary-hover: #2c5f8a;
    --secondary: #ffd43b;      /* amarelo do logo oficial do Python */
    --secondary-dark: #e6be2e;
    --ink: #0f172a;
    --muted: #64748b;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --background: #f8fafc;
    --border: #e2e8f0;
    --success: #15803d;
    --danger: #b91c1c;
    --warning: #a16207;
    --radius-sm: 10px;
    --radius: 16px;
    --shadow-sm: 0 8px 24px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 24px 70px rgba(15, 23, 42, 0.16);
}

[data-theme="dark"] {
    color-scheme: dark;
    --primary: #5b9fd4;        /* azul Python clareado para fundo escuro */
    --primary-dark: #85bce8;   /* links sobre fundo escuro */
    --primary-soft: #102a45;
    /* botão preenchido usa o azul oficial (não o --primary clareado para
       links): texto branco sobre #5b9fd4 fica em ~2.9:1, abaixo do WCAG AA
       (4.5:1) — #3776ab mantém ~4.8:1 nos dois temas. */
    --button-primary-bg: #3776ab;
    --button-primary-hover: #2c5f8a;
    --secondary: #ffd43b;
    --secondary-dark: #e2ba20;
    --ink: #e8eef7;
    --muted: #9fb0c4;
    --surface: #111c2e;
    --surface-raised: #17243a;
    --background: #08111f;
    --border: #27364a;
    --success: #4ade80;
    --danger: #f87171;
    --warning: #facc15;
    --shadow-sm: 0 8px 24px rgba(0, 0, 0, 0.24);
    --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.36);
}

/* === BASE === */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    background: var(--background);
    color: var(--ink);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 1rem;
    line-height: 1.6;
}
img { display: block; max-width: 100%; height: auto; }
a { color: var(--primary-dark); text-underline-offset: 0.18em; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 70%, white); outline-offset: 3px; }
.container { width: min(1200px, calc(100% - 32px)); margin-inline: auto; }
.skip-link { position: absolute; left: -9999px; top: 0; }
.skip-link:focus { left: 16px; top: 16px; background: var(--surface); color: var(--ink); padding: 10px 14px; border-radius: var(--radius-sm); z-index: 1000; }

/* === TYPOGRAPHY === */
h1, h2, h3 { line-height: 1.12; letter-spacing: -0.025em; }
h1 { font-size: clamp(2.4rem, 7vw, 4.8rem); margin: 0 0 20px; }
h2 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
h3 { font-size: clamp(1.25rem, 2vw, 1.5rem); }
.eyebrow { color: var(--primary-dark); font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.85rem; }
.lead { color: var(--muted); font-size: clamp(1.05rem, 2vw, 1.2rem); max-width: 62ch; }
.text-muted { color: var(--muted); }

/* === HEADER === */
.site-header {
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}
.header-inner { min-height: 72px; display: flex; align-items: center; gap: 24px; position: relative; }
.brand { color: var(--ink); font-weight: 850; font-size: 1.35rem; text-decoration: none; display: flex; align-items: center; }
.brand-logo { height: 36px; width: auto; max-width: none; }
.brand-logo-dark { display: none; }
[data-theme="dark"] .brand-logo-light { display: none; }
[data-theme="dark"] .brand-logo-dark { display: block; }
nav { display: flex; gap: 18px; margin-left: auto; flex-wrap: wrap; }
nav a { color: var(--ink); text-decoration: none; font-weight: 600; }
nav a:hover { color: var(--primary-dark); }
[data-theme-toggle] { min-width: 44px; min-height: 44px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--ink); cursor: pointer; }
.nav-toggle { display: none; min-width: 44px; min-height: 44px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--ink); cursor: pointer; font-size: 1.1rem; }

/* === BUTTONS === */
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 18px;
    border: 1px solid transparent;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 750;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--button-primary-bg); color: #fff; }
.button.primary:hover { background: var(--button-primary-hover); }
.button.cta { background: var(--secondary); color: #16120a; }
.button.cta:hover { background: var(--secondary-dark); }
.button.secondary { border-color: var(--border); color: var(--ink); background: var(--surface); }

/* === HERO === */
.hero { padding: clamp(64px, 10vw, 104px) 0; }
.hero-grid { display: grid; gap: 40px; align-items: center; }
.hero-card {
    min-height: 280px;
    border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border));
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    color: white;
    font-size: 2rem;
    font-weight: 850;
    background: linear-gradient(135deg, var(--primary), #6d4aff 70%, var(--secondary));
    box-shadow: var(--shadow-lg);
}
/* Variante usada na faixa de CTA de cadastro (docs/03 home): mesmo fundo em
   degradê, mas com texto alinhado à esquerda em vez do mark central. */
.hero-cta { align-items: start; justify-items: start; padding: 48px; gap: 16px; font-size: 1rem; font-weight: 700; }
.hero-cta-title { color: #fff; margin: 0; font-size: 1.75rem; }
.hero-cta-text { color: #fff; opacity: .9; max-width: 60ch; }

/* === SECTIONS AND CARDS === */
.section { padding: 64px 0; }
.section-header { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 20px; }
.card {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: clip;
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--primary); }
.card-body { padding: 20px; }
.badge { display: inline-flex; padding: 4px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-dark); font-size: 0.78rem; font-weight: 750; }

/* === FORMS === */
.form-field { display: grid; gap: 6px; margin-bottom: 18px; }
label { font-weight: 700; }
input, textarea, select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    padding: 10px 12px;
}
textarea { min-height: 140px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: auto; vertical-align: middle; }
.field-error { color: var(--danger); font-size: 0.875rem; }
.field-help { color: var(--muted); font-size: 0.85rem; }
.form-field-tight { margin-bottom: 0; }
fieldset.form-field { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; }
fieldset.form-field legend { padding: 0 6px; }

/* === LMS: player e lista de aulas === */
.lesson-layout { display: grid; gap: 32px; margin-top: 24px; }
.player-wrap { position: relative; width: 100%; aspect-ratio: 16/9; background: #000; border-radius: var(--radius); overflow: clip; }
.player-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.lesson-list { list-style: decimal; padding-left: 1.4em; display: grid; gap: 10px; }
.lesson-sidebar h2 { font-size: 1.1rem; margin-bottom: 12px; }
@media (min-width: 900px) { .lesson-layout { grid-template-columns: 2fr 1fr; } }

/* === ALERTS === */
.alert-success {
    display: block;
    background: var(--primary-soft);
    color: var(--primary-dark);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}
.notice-warning {
    display: block;
    background: color-mix(in srgb, var(--warning) 12%, var(--surface));
    color: var(--warning);
    border: 1px solid var(--warning);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
}

/* === ANTISPAM (honeypot) === */
.hp-field { position: absolute; left: -9999px; top: -9999px; opacity: 0; height: 0; overflow: hidden; }

/* === LAYOUT HELPERS === */
.container-form { max-width: 480px; }
.container-form.is-medium { max-width: 640px; }
.container-form.is-wide { max-width: 760px; }
.container-legal { max-width: 720px; }
.card-narrow { max-width: 640px; }
.mt-8 { margin-top: 8px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-10 { margin-bottom: 10px; }
.d-block { display: block; }
.fw-normal { font-weight: 400; }
.text-preserve { white-space: pre-wrap; max-width: 48ch; }
.table-scroll { overflow-x: auto; }
.inline-form { display: inline; }

/* Miniaturas em cards de listagem (artigos, cursos, dicas, eventos,
   imperdíveis, projetos, destaques na home): recorta para 16:9. */
.card-thumb { aspect-ratio: 16 / 9; object-fit: cover; }

/* Dica do dia: a imagem (geralmente retrato, texto explicativo dentro
   dela) precisa aparecer inteira, sem corte — largura total do card,
   altura livre para acompanhar a proporção real da imagem. */
.tip-image { width: 100%; height: auto; }

/* Prévia de imagem já enviada nos formulários administrativos. */
.admin-preview { max-width: 240px; border-radius: 8px; margin-bottom: 8px; }
.admin-preview-sm { max-width: 160px; border-radius: 8px; margin-bottom: 8px; }
.admin-logo-preview { max-height: 48px; margin-bottom: 8px; }
.admin-logo-preview-dark { max-height: 48px; margin-bottom: 8px; background: #111; }

/* === ADMIN TABLE === */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.admin-table thead { background: var(--surface-raised); }

/* === PAGINATION === */
.pagination { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 20px; }
.pagination a {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    text-decoration: none;
    color: var(--ink);
}
.pagination a[aria-current="page"] { background: var(--button-primary-bg); color: #fff; border-color: var(--button-primary-bg); }

/* === EDITOR RICO (progressive enhancement sobre textarea) === */
.editor-source-hidden { display: none; }
.editor-wrap { display: grid; gap: 8px; margin-bottom: 8px; }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 6px; }
.editor-button {
    min-height: 36px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
}
.editor-button:hover { border-color: var(--primary); color: var(--primary-dark); }
.editor-surface {
    min-height: 260px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    padding: 14px 16px;
    overflow-y: auto;
}
.editor-surface:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 70%, white); outline-offset: 2px; }
.editor-status { color: var(--danger); }

/* === ARTICLE CONTENT (HTML editorial sanitizado) === */
.article-cover { border-radius: 16px; margin: 24px 0; }
.article-content { max-width: 72ch; }
.article-content > * + * { margin-top: 1em; }
.article-content h2 { margin-top: 1.6em; }
.article-content h3, .article-content h4 { margin-top: 1.3em; }
.article-content ul, .article-content ol { padding-left: 1.4em; }
.article-content li + li { margin-top: 0.4em; }
.article-content blockquote {
    margin: 0;
    padding: 4px 20px;
    border-left: 4px solid var(--primary);
    color: var(--muted);
    background: var(--primary-soft);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.article-content pre {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    overflow-x: auto;
}
.article-content code { background: var(--primary-soft); border-radius: 4px; padding: 0.1em 0.35em; }
.article-content pre code { background: none; padding: 0; }
.article-content img { border-radius: var(--radius-sm); }
.article-content table { width: 100%; border-collapse: collapse; }
.article-content th, .article-content td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }

/* === FOOTER === */
.site-footer { border-top: 1px solid var(--border); padding: 32px 0; color: var(--muted); }
.footer-inner { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: center; }
.footer-social { display: flex; gap: 16px; }
.footer-social a { color: var(--muted); text-decoration: none; font-weight: 600; }
.footer-social a:hover { color: var(--primary-dark); }

@media (min-width: 860px) { .hero-grid { grid-template-columns: 1.25fr 0.75fr; } }
@media (max-width: 700px) {
    .header-inner { flex-wrap: wrap; }
    .nav-toggle { display: inline-flex; align-items: center; justify-content: center; order: 3; margin-left: auto; }
    [data-theme-toggle] { order: 4; }
    nav {
        display: none;
        order: 5;
        width: 100%;
        flex-direction: column;
        gap: 4px;
        margin-left: 0;
        padding: 8px 0 4px;
        border-top: 1px solid var(--border);
    }
    nav.nav-open { display: flex; }
    nav a { padding: 10px 4px; }
    .section-header { align-items: start; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; } }
