/* =================================================================
   CloudBlogs — tema blog/default
   Folha unica: tokens -> reset -> layout -> components -> post.
   Adaptada do tema master (sem nav JS, sidebar, author, badges).
   ================================================================= */

/* ============================ TOKENS ============================== */
:root {
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: #eff6ff;

  --color-bg: #ffffff;
  --color-bg-alt: #f8fafc;
  --color-surface: #ffffff;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-text-inverse: #f8fafc;
  --color-border: #e2e8f0;

  --color-header-bg: #0f172a;
  --color-header-text: #f8fafc;
  --color-footer-bg: #0f172a;
  --color-footer-text: #cbd5e1;

  --color-code-bg: #f1f5f9;
  --color-code-text: #1e293b;
  --color-blockquote-border: var(--color-primary);
  --color-blockquote-bg: var(--color-primary-light);

  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --font-heading: var(--font-sans);
  --font-body: var(--font-sans);

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;

  --line-height-tight: 1.25;
  --line-height-normal: 1.6;
  --line-height-relaxed: 1.8;

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  --max-width-content: 720px;
  --max-width-wide: 1140px;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 999px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-card-hover: 0 8px 24px rgba(0, 0, 0, 0.12);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

/* Dark mode — segue a preferencia do sistema. */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0f172a;
    --color-bg-alt: #1e293b;
    --color-surface: #1e293b;
    --color-text: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-text-inverse: #0f172a;
    --color-border: #334155;

    --color-header-bg: #020617;
    --color-header-text: #e2e8f0;
    --color-footer-bg: #020617;
    --color-footer-text: #94a3b8;

    --color-code-bg: #1e293b;
    --color-code-text: #e2e8f0;
    --color-primary-light: #172554;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-card-hover: 0 8px 24px rgba(0, 0, 0, 0.5);
  }
  img:not([src*=".svg"]) { filter: brightness(0.9); }
}

/* ============================ RESET ============================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: var(--line-height-normal);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

img, video {
  max-width: 100%;
  height: auto;
  display: block;
}

ul[role="list"], ol[role="list"] { list-style: none; }

table { border-collapse: collapse; }

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Skip link (acessibilidade WCAG AA) */
.skip-link {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link:focus {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 10000;
  width: auto;
  height: auto;
  padding: var(--space-2) var(--space-4);
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
}

/* ============================ LAYOUT ============================= */
.container {
  width: 100%;
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.container--narrow { max-width: var(--max-width-content); }

.site-main {
  flex: 1;
  padding: var(--space-6) 0;
}

/* Header */
.site-header {
  background: var(--color-header-bg);
  color: var(--color-header-text);
  padding: var(--space-4) 0;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.site-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-header-text);
  font-weight: var(--font-weight-bold);
  text-decoration: none;
  min-width: 0;
}

.site-brand:hover {
  text-decoration: none;
  opacity: 0.9;
}

.site-name {
  font-size: var(--text-base);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Footer */
.site-footer {
  background: var(--color-footer-bg);
  color: var(--color-footer-text);
  padding: var(--space-8) 0;
  margin-top: auto;
}

.footer-copy { font-size: var(--text-sm); }

/* Breadcrumbs */
.breadcrumbs {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}

.breadcrumbs a { color: var(--color-text-muted); }
.breadcrumbs a:hover { color: var(--color-primary); }
.breadcrumbs [aria-current="page"] { color: var(--color-text); }

/* =========================== COMPONENTS ========================= */

/* Hero */
.hero {
  text-align: center;
  padding: var(--space-12) 0 var(--space-10);
}

.hero-title {
  font-size: var(--text-4xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  font-family: var(--font-heading);
  margin-bottom: var(--space-3);
}

.hero-lead {
  max-width: var(--max-width-content);
  margin: 0 auto;
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  line-height: var(--line-height-relaxed);
}

.section-title {
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-bold);
  font-family: var(--font-heading);
  margin-bottom: var(--space-6);
}

/* Post grid + cards */
.post-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-12);
}

.post-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}

.post-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}

.post-card a { text-decoration: none; }

.post-card-body {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.post-card-title {
  font-size: var(--text-lg);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
}

.post-card-title a { color: var(--color-text); }
.post-card-title a:hover { color: var(--color-primary); }

.post-card-meta {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.post-card-excerpt {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: var(--line-height-relaxed);
}

.read-more {
  color: var(--color-primary-hover);
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-sm);
}

/* Page links */
.page-nav { margin-bottom: var(--space-8); }

.page-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  list-style: none;
  padding: 0;
  margin: 0;
}

.page-links a { font-weight: var(--font-weight-medium); }

/* Empty state */
.empty-state {
  color: var(--color-text-muted);
  text-align: center;
  padding: var(--space-12) 0;
}

/* ============================= POST ============================= */
.post-header { margin-bottom: var(--space-8); }

.post-title {
  font-size: var(--text-4xl);
  font-weight: var(--font-weight-bold);
  font-family: var(--font-heading);
  line-height: var(--line-height-tight);
  margin-bottom: var(--space-3);
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  align-items: center;
}

/* Conteudo rich-text */
.post-content { font-size: var(--text-base); }

.post-content h2 {
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-bold);
  font-family: var(--font-heading);
  line-height: var(--line-height-tight);
  margin: var(--space-10) 0 var(--space-4);
}

.post-content h3 {
  font-size: var(--text-xl);
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-heading);
  line-height: var(--line-height-tight);
  margin: var(--space-8) 0 var(--space-3);
}

.post-content h4 {
  font-size: var(--text-lg);
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-heading);
  margin: var(--space-6) 0 var(--space-2);
}

.post-content p {
  margin-bottom: var(--space-4);
  line-height: var(--line-height-relaxed);
}

.post-content ul, .post-content ol {
  margin-bottom: var(--space-4);
  padding-left: var(--space-6);
}

.post-content li {
  margin-bottom: var(--space-1);
  line-height: var(--line-height-relaxed);
}

.post-content a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-content a:hover { color: var(--color-primary-hover); }

.post-content blockquote {
  border-left: 4px solid var(--color-blockquote-border);
  background: var(--color-blockquote-bg);
  padding: var(--space-4) var(--space-6);
  margin: var(--space-6) 0;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-style: italic;
}

.post-content blockquote p { margin-bottom: 0; }

.post-content code {
  background: var(--color-code-bg);
  color: var(--color-code-text);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.post-content pre {
  background: var(--color-code-bg);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: var(--space-4);
}

.post-content pre code {
  background: none;
  padding: 0;
  font-size: var(--text-sm);
}

.post-content img {
  border-radius: var(--radius-md);
  margin: var(--space-4) 0;
}

.post-content figure { margin: var(--space-6) 0; }

.post-content figcaption {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
  margin-top: var(--space-2);
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-4);
}

.post-content th, .post-content td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}

.post-content th {
  font-weight: var(--font-weight-semibold);
  background: var(--color-bg-alt);
}

.post-content strong { font-weight: var(--font-weight-semibold); }

.post-content hr {
  border: none;
  height: 1px;
  background: var(--color-border);
  margin: var(--space-8) 0;
}

/* ========================== RESPONSIVO ========================= */
@media (min-width: 640px) {
  .post-grid { grid-template-columns: repeat(2, 1fr); }
  .site-main { padding: var(--space-8) 0; }
  .site-name { font-size: var(--text-xl); }
}

@media (min-width: 900px) {
  .post-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1200px) {
  .container { padding: 0 var(--space-8); }
  .site-main { padding: var(--space-10) 0; }
}

@media (max-width: 640px) {
  .hero-title, .post-title { font-size: var(--text-3xl); }
}

@media (max-width: 480px) {
  .hero-title, .post-title { font-size: var(--text-2xl); }
}
