/**
 * TecNerds Theme v3.0 — Melhorias CSS
 * Layout otimizado, modo escuro aprimorado, acessibilidade
 */

/* ============================================================
   HERO SECTION — Melhorias de layout responsivo
   ============================================================ */
.tn-hero {
  margin: 40px 0;
  padding: 0;
}

.tn-hero__grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 32px;
  align-items: start;
}

/* Responsivo: tablet */
@media (max-width: 1024px) {
  .tn-hero__grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .tn-hero__main {
    order: 1;
  }

  .tn-hero__side {
    order: 2;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
  }
}

/* Responsivo: mobile */
@media (max-width: 640px) {
  .tn-hero {
    margin: 24px 0;
  }

  .tn-hero__grid {
    gap: 16px;
  }

  .tn-hero__main {
    padding: 0;
  }

  .tn-hero__title {
    font-size: clamp(1.5rem, 6vw, 2.2rem) !important;
  }

  .tn-hero__excerpt {
    font-size: 0.95rem;
  }
}

/* ============================================================
   SEÇÕES DE CONTEÚDO — Grid responsivo
   ============================================================ */
.tn-posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 28px;
  margin: 40px 0;
}

@media (max-width: 768px) {
  .tn-posts-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin: 32px 0;
  }
}

@media (max-width: 480px) {
  .tn-posts-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* ============================================================
   CARDS — Estilo aprimorado
   ============================================================ */
.tn-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-card);
  border: 1px solid var(--brd);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: all var(--t-med);
  box-shadow: var(--sh-sm);
}

.tn-card:hover {
  border-color: var(--c-green);
  box-shadow: var(--sh-md);
  transform: translateY(-2px);
}

.tn-card__img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  overflow: hidden;
}

.tn-card__body {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.tn-card__title {
  font-size: 1.1rem;
  margin-bottom: 12px;
  line-height: 1.4;
}

.tn-card__meta {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--brd);
  font-size: 0.85rem;
  color: var(--tx-3);
}

/* ============================================================
   DARK MODE — Otimizações
   ============================================================ */
[data-theme="dark"] .tn-card {
  background: var(--bg-card);
  border-color: var(--brd);
}

[data-theme="dark"] .tn-card:hover {
  border-color: var(--c-green);
  box-shadow: 0 0 16px rgba(0, 232, 122, 0.1);
}

/* ============================================================
   BOTÃO VOLTAR AO TOPO — Melhorado
   ============================================================ */
#tn-back-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 48px;
  height: 48px;
  border-radius: var(--r-full);
  background: var(--c-green);
  color: #000;
  border: none;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all var(--t-med);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: var(--sh-md);
}

#tn-back-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

#tn-back-top:hover {
  background: var(--c-green-dark);
  transform: translateY(-2px);
  box-shadow: var(--sh-lg);
}

#tn-back-top:active {
  transform: scale(0.95);
}

[data-theme="dark"] #tn-back-top {
  background: var(--c-green);
  box-shadow: 0 0 16px rgba(0, 232, 122, 0.2);
}

/* Mobile */
@media (max-width: 640px) {
  #tn-back-top {
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    font-size: 1rem;
  }
}

/* ============================================================
   ACESSIBILIDADE — Botão melhorado
   ============================================================ */
.tn-a11y-header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  background: var(--bg-card-2);
  color: var(--tx-1);
  border: 1px solid var(--brd);
  cursor: pointer;
  transition: all var(--t-fast);
  font-size: 1.1rem;
}

.tn-a11y-header-btn:hover {
  background: var(--bg-card);
  border-color: var(--c-green);
  color: var(--c-green);
}

.tn-a11y-header-btn[aria-expanded="true"] {
  background: var(--c-green);
  color: #000;
  border-color: var(--c-green);
}

/* ============================================================
   BUSCA — Melhorada
   ============================================================ */
.tn-searchbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.5);
  padding: 24px;
  z-index: 1000;
  backdrop-filter: blur(4px);
  animation: slideDown var(--t-med) ease-out;
}

.tn-searchbar.open {
  display: flex;
  align-items: center;
  justify-content: center;
}

.tn-searchbar form {
  display: flex;
  gap: 8px;
  background: var(--bg-card);
  padding: 12px 16px;
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 600px;
  box-shadow: var(--sh-lg);
}

.tn-searchbar input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--tx-1);
  font-size: 1.1rem;
  outline: none;
}

.tn-searchbar input::placeholder {
  color: var(--tx-3);
}

.tn-searchbar button {
  padding: 8px 16px;
  background: var(--c-green);
  color: #000;
  border-radius: var(--r-md);
  font-weight: 600;
  transition: all var(--t-fast);
}

.tn-searchbar button:hover {
  background: var(--c-green-dark);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   COMPARTILHAMENTO — Botões melhorados
   ============================================================ */
.tn-share {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 32px 0;
  padding: 20px;
  background: var(--bg-card-2);
  border-radius: var(--r-lg);
  border: 1px solid var(--brd);
}

.tn-share__pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--brd);
  border-radius: var(--r-full);
  color: var(--tx-1);
  cursor: pointer;
  transition: all var(--t-fast);
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
}

.tn-share__pill:hover {
  background: var(--c-green);
  color: #000;
  border-color: var(--c-green);
  transform: translateY(-2px);
}

.tn-share__pill i {
  font-size: 1rem;
}

.tn-share__dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--bg-card);
  border: 1px solid var(--brd);
  border-radius: var(--r-lg);
  margin-top: 8px;
  min-width: 180px;
  box-shadow: var(--sh-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--t-fast);
  z-index: 10;
}

.tn-share__dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.tn-share__drop-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  color: var(--tx-1);
  transition: all var(--t-fast);
  border-bottom: 1px solid var(--brd);
}

.tn-share__drop-item:last-child {
  border-bottom: none;
}

.tn-share__drop-item:hover {
  background: var(--bg-card-2);
  color: var(--c-green);
  padding-left: 20px;
}

.tn-share__drop-item i {
  font-size: 1.1rem;
  min-width: 24px;
}

/* Mobile */
@media (max-width: 640px) {
  .tn-share {
    flex-direction: column;
    gap: 8px;
  }

  .tn-share__pill {
    width: 100%;
    justify-content: center;
  }

  .tn-share__dropdown {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    border: none;
    box-shadow: none;
    background: transparent;
    margin-top: 0;
  }
}

/* ============================================================
   RESPONSIVE GERAL — Melhorias finais
   ============================================================ */
@media (max-width: 1200px) {
  :root {
    --gap: 24px;
    --sidebar-w: 280px;
  }
}

@media (max-width: 768px) {
  :root {
    --gap: 20px;
    --sidebar-w: 100%;
  }

  .tn-layout {
    grid-template-columns: 1fr;
  }

  .tn-container {
    padding: 0 16px;
  }
}

@media (max-width: 480px) {
  :root {
    font-size: 14px;
    --gap: 16px;
    --r-lg: 12px;
    --r-md: 8px;
  }

  body {
    font-size: clamp(14px, 4vw, 16px);
  }

  .tn-container {
    padding: 0 12px;
  }
}

/* ============================================================
   PRINT — Otimizações para impressão
   ============================================================ */
@media print {
  #tn-back-top,
  .tn-header,
  .tn-footer,
  .tn-share,
  .tn-a11y-panel {
    display: none !important;
  }

  .tn-article {
    max-width: 100%;
  }
}
