/* ==========================================================================
   1. Design Token Variables
   ========================================================================== */

/* Default Light Mode variables */
:root {
  --bg-color: #ffffff;
  --text-color: #111111;
  --link-color: rgb(45, 155, 45);
  --meta-color: #666666;
  --max-width: 650px;
  --footer-bg: #f5f5f7; /* Soft light gray */
}

/* Dark Mode variables */
body.dark-mode {
  --bg-color: #121212;
  --text-color: #e0e0e0;
  --link-color: rgb(45, 155, 45);
  --meta-color: #a0a0a0;
  --footer-bg: #1e1e1e; /* Deep panel gray */
}

/* ==========================================================================
   2. Base Application Framing
   ========================================================================== */

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 1.05rem;
  line-height: 1.6;
  margin: 0;
  padding: 2rem 0 0 0; 
  transition: background-color 0.3s ease, color 0.3s ease;

  /* Layout Grid to force footer to the absolute bottom window frame */
  display: grid;
  grid-template-rows: auto 1fr auto; 
  min-height: 100vh; 
  box-sizing: border-box;
}

/* Container centers the content column on the screen */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
  box-sizing: border-box;
}

/* ==========================================================================
   3. Global Typography & Core Components
   ========================================================================== */

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

a:hover {
  text-decoration: underline;
}

h1, h2, h3 {
  font-weight: normal;
  line-height: 1.2;
}

h2 {
  font-size: 1.8rem;
  margin-top: 2rem;
}

blockquote {
  border-left: 4px solid var(--link-color);
  margin: 1.5rem 0;
  padding: 0.25rem 0 0.25rem 1.25rem;
  color: var(--meta-color);
  font-style: italic;
}

img {
  max-width: 100% !important;
  height: auto !important;
  display: block;
  margin: 2rem auto;
  border-radius: 6px;
}

/* ==========================================================================
   4. Site Header & Navigation Elements
   ========================================================================== */

header {
  display: flex;
  flex-direction: column; /* Stacks rows vertically */
  align-items: center;    /* Centers items */
  text-align: center;
  margin-bottom: 3rem;    
  width: 100%;
  gap: 0.5rem;            /* Creates even spacing between all lines */
}

header h3 {
  margin: 0;      
  font-size: 1.5rem;
  font-weight: bold;      
}

.nav-utilities {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

header nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;            
  flex-wrap: wrap;        /* Allows links to wrap elegantly on small mobile views */
}

#theme-toggle {
  background: none;
  border: none;
  color: var(--text-color);
  font-family: inherit;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0;
  opacity: 0.7;
  line-height: 1;
}

#theme-toggle:hover {
  opacity: 1;
}

/* ==========================================================================
   5. Modular Layout Architecture (.page Engine)
   ========================================================================== */

.page {
  width: 100%;
}

.page p {
  margin-bottom: 1.5rem;
  font-size: 1.05rem;
  line-height: 1.6;
}

/* Tighten spacing for dates that appear immediately under article headings */
h1 + .page-date,
h2 + .page-date {
  margin-top: -1.2rem;   /* Pulls date closely underneath headers */
  margin-bottom: 2rem;   /* Spacing before body paragraphs start */
  display: block;
}

/* Standardized multi-purpose item list containers */
.page-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}

.page-item {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column; 
}

.page-date {
  color: var(--meta-color);
  font-size: 0.95rem;
  display: inline-block;
  min-width: 150px; 
  margin-bottom: 0.25rem;
}

/* Consolidated Desktop Media Query */
@media (min-width: 550px) {
  .page-item {
    flex-direction: row;          
    align-items: baseline;
    justify-content: flex-start;  
  }
  .page-date {
    margin-bottom: 0;
  }
}

/* ==========================================================================
   6. Plain Native Writing Elements (`code`, `pre`)
   ========================================================================== */

/* Plain Inline Code (Simulates single backticks) */
code {
  font-family: Fira Code, Consolas, Monaco, 'Andale Mono', Ubuntu Mono, monospace;
  font-size: 0.9em;
  background-color: rgba(0, 0, 0, 0.06);
  color: #d63384;                        
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  word-break: break-word;
}

body.dark-mode code {
  background-color: rgba(255, 255, 255, 0.1); 
  color: #ff79c6;                               
}

/* Plain Block Panels (Simulates triple backticks) */
pre {
  background-color: #f5f5f7; 
  border: 1px solid #e5e5ea;
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;          
  margin: 1.5rem 0;
}

body.dark-mode pre {
  background-color: #1e1e1e; 
  border-color: #2c2c2e;
}

/* Resets inline traits for code blocks cleanly */
pre code {
  background-color: transparent !important;
  color: inherit !important;
  padding: 0;
  border-radius: 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ==========================================================================
   7. Media Component Layer & Site Footers
   ========================================================================== */

/* Video Container Aspect Ratio Wrapper */
.video-embed {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* Perfect 16:9 ratio */
  height: 0;
  overflow: hidden;
  margin: 2rem 0;
  border-radius: 6px;
  background-color: #000;
  cursor: pointer;
}

.video-embed img,
.video-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100% !important;
  margin: 0 !important;
  object-fit: cover;
}

/* Minimalist Play Button Overlay */
.video-embed .play-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  background-color: rgba(45, 155, 45, 0.9);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  padding-left: 4px;
  transition: transform 0.2s ease, background-color 0.2s ease;
  z-index: 2;
}

.video-embed:hover .play-button {
  transform: translate(-50%, -50%) scale(1.1);
  background-color: rgb(45, 155, 45);
}

/* Anchor styling wrapper for Inline Pure SVGs */
.social-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none !important;
}

/* Clean, Reset SVG Sizing Definition */
.social-icon svg {
  width: 20px;
  height: 20px;
  fill: var(--text-color);
  transition: fill 0.2s ease, transform 0.2s ease;
}

/* Dynamic Interaction on Hover */
.social-icon:hover svg {
  fill: var(--link-color);
  transform: scale(1.1);
}

/* Global Footer Framing Block */
footer {
  display: block;
  width: 100%;
  background-color: var(--footer-bg); 
  margin-top: 6rem;     
  padding: 3rem 0 calc(3rem + env(safe-area-inset-bottom)) 0; 
  transition: background-color 0.3s ease;
  align-self: end; 
}

.footer-text {
  max-width: var(--max-width); 
  margin: 0 auto;
  padding: 0 1rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--meta-color);
}

/* ==========================================================================
   8. After Post Injections
   ========================================================================== */
   
.post-separator {
  border: 0;
  height: 1px;
  background: #ccc;
  margin: 3rem 0 2rem 0;
}

.after-post-box {
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 6px;
}

/* Dark mode compatibility */
body.dark-mode .after-post-box {
  background: rgba(255, 255, 255, 0.05);
}

/* ==========================================================================
   9. Specialized Portfolio Components (.book-grid Engine)
   ========================================================================== */

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1.5rem;
  justify-content: center;
  align-items: start;
  padding: 1.5rem 0;
  margin: 0 auto;
  width: 100%;
}

.book-cover-item {
  display: block;
  text-align: center;
  text-decoration: none;
  color: inherit;
}

.book-cover-item:hover {
  text-decoration: none; /* Prevents underlines on book cover links */
}

.book-cover-item img {
  width: 100%;
  /* Overrides global styling rules cleanly for grid context */
  height: auto !important; 
  margin: 0 auto !important; 
  border-radius: 4px;
  border: 1px solid var(--meta-color); 
  box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.1); 
  transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out, border-color 0.2s ease-in-out;
}

.book-cover-item:hover img {
  transform: scale(1.04);
  box-shadow: 4px 6px 12px rgba(0, 0, 0, 0.18); 
  border-color: var(--link-color); 
}

.book-cover-item .book-title {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.3;
  color: var(--text-color);
}

/* ==========================================================================
   10. Specialized Service & Course Grid Components
   ========================================================================== */

.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
  width: 100%;
}

.service-item {
  padding: 1.5rem;
  border: 1px solid var(--meta-color);
  border-radius: 6px;
  text-align: center;
  box-sizing: border-box;
  font-size: 0.95rem;
}

.service-item b {
  display: block;
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: var(--text-color);
}

/* Courses = maximum of 3 columns */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.5rem;
  justify-content: center;
  align-items: start;
  padding: 1.5rem 0;
  margin: 0 auto;
  width: 100%;
}

/* ==========================================================================
   11. Dynamic Course Tabs & Grid System
   ========================================================================== */

/* Contentor principal do cabeçalho estilo tabela */
.tabs-header-container {
  display: grid;
  grid-template-columns: 1fr 3fr; /* Separa 'Comprar' da área de membros */
  border: 1px solid var(--meta-color);
  border-radius: 6px;
  margin: 2rem 0 1.5rem 0;
  overflow: hidden;
}

/* Coluna da Esquerda: Botão Comprar isolado */
.tabs-buy-zone {
  display: flex;
  align-items: stretch;
}

.tabs-buy-zone .tab-btn {
  width: 100%;
  border-right: 1px solid var(--meta-color);
}

/* Coluna da Direita: Área de Membros com rótulo superior */
.tabs-member-zone {
  display: flex;
  flex-direction: column;
}

.tabs-sub-header {
  background-color: rgba(45, 155, 45, 0.1);
  color: var(--link-color);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
  padding: 0.5rem;
  border-bottom: 1px solid var(--meta-color);
}

.tabs-member-buttons {
  display: flex;
  flex: 1;
}

.tabs-member-buttons .tab-btn {
  flex: 1;
  border-right: 1px solid var(--meta-color);
}

.tabs-member-buttons .tab-btn:last-child {
  border-right: none;
}

/* Estilo geral dos botões */
.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-color);
  padding: 1rem 0.5rem;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
  text-align: center;
}

/* Estado Ativo do Botão */
.tab-btn.active {
  background-color: var(--link-color);
  color: #ffffff;
  font-weight: bold;
}

/* Grelha de Cursos Dinâmica (Garante tamanho fixo e alinhamento à esquerda) */
.course-grid-dynamic {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.5rem;
  justify-content: start; /* Alinha os itens à esquerda */
  align-items: start;
  width: 100%;
}

.course-grid-dynamic .book-cover-item {
  display: none;
  max-width: 180px; /* Garante que o tamanho não deforma quando há poucos itens */
  width: 100%;
}

.course-grid-dynamic .book-cover-item.show {
  display: block;
}

/* Adaptação para Telemóvel (Mobile Responsive) */
@media (max-width: 600px) {
  .tabs-header-container {
    grid-template-columns: 1fr; /* Transforma tudo numa coluna vertical */
  }
  .tabs-buy-zone .tab-btn {
    border-right: none;
    border-bottom: 1px solid var(--meta-color);
  }
  .tabs-sub-header {
    border-top: none;
  }
  .tabs-member-buttons {
    flex-direction: column;
  }
  .tabs-member-buttons .tab-btn {
    border-right: none;
    border-bottom: 1px solid var(--meta-color);
    padding: 0.8rem;
  }
  .tabs-member-buttons .tab-btn:last-child {
    border-bottom: none;
  }
}

/* ==========================================================================
   12. Info Tabs Bottom Section & Image Hover Fix
   ========================================================================== */

/* Remove efeitos de hover/mouseover das capas nesta grade */
.course-grid-dynamic .book-cover-item img,
.course-grid-dynamic .book-cover-item:hover img,
.course-grid-dynamic .book-cover-item::before {
  transform: none !important;
  box-shadow: none !important;
  transition: none !important;
  pointer-events: none; /* Ignora interações de mouse nas imagens */
}

/* Container de abas para a seção inferior */
.info-tabs-container {
  margin-top: 3rem;
  border: 1px solid var(--meta-color);
  border-radius: 6px;
  overflow: hidden;
}

.info-tabs-buttons {
  display: flex;
  background-color: rgba(0, 0, 0, 0.01);
  border-bottom: 1px solid var(--meta-color);
}

body.dark-mode .info-tabs-buttons {
  background-color: rgba(255, 255, 255, 0.01);
}

.info-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 1rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: bold;
  color: var(--text-color);
  cursor: pointer;
  text-align: center;
  transition: background-color 0.2s;
}

.info-tab-btn:first-child {
  border-right: 1px solid var(--meta-color);
}

.info-tab-btn.active {
  background-color: var(--link-color);
  color: #ffffff;
}

/* Janela de conteúdo das abas */
.info-tabs-content {
  padding: 1.5rem;
}

.info-content-block {
  display: none;
}

.info-content-block.show {
  display: block;
}

/* ==========================================================================
13. Responsive Photo Grid Components (.photo-grid engine)
========================================================================== /
/ STREAMING_CHUNK: Styling the square image photos grid... */
.photo-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 0.75rem;
margin: 2rem 0;
width: 100%;
}

@media (min-width: 550px) {
.photo-grid {
grid-template-columns: repeat(4, 1fr);
gap: 1rem;
}
}

.photo-item {
display: block;
position: relative;
overflow: hidden;
border-radius: 6px;
aspect-ratio: 1 / 1;
border: 1px solid rgba(0, 0, 0, 0.06);
box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.04);
transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out, border-color 0.2s ease-in-out;
}

body.dark-mode .photo-item {
border-color: rgba(255, 255, 255, 0.08);
}

.photo-item:hover {
transform: scale(1.04);
box-shadow: 4px 6px 12px rgba(0, 0, 0, 0.15);
border-color: var(--link-color);
}

.photo-item img {
width: 100% !important;
height: 100% !important;
margin: 0 !important;
object-fit: cover;
border-radius: 0;
}

/* ==========================================================================
14. Webmention Dynamic Comments Styling
========================================================================== */

/* STREAMING_CHUNK: Styling the outer container and title... */
.webmentions-container {
margin-top: 3rem;
border-top: 1px solid rgba(128, 128, 128, 0.2);
padding-top: 2rem;
}

.webmentions-title {
font-size: 1.4rem;
font-weight: bold;
margin-bottom: 1.5rem;
color: var(--text-color);
}

.webmentions-list {
display: flex;
flex-direction: column;
gap: 1.5rem;
margin-top: 1.5rem;
}

/* STREAMING_CHUNK: Styling individual comments and layouts... */
.webmention-comment {
display: flex;
gap: 1.25rem;
align-items: flex-start;
text-align: left;
padding-bottom: 1.25rem;
border-bottom: 1px solid rgba(128, 128, 128, 0.1);
}

.webmention-comment:last-child {
border-bottom: none;
}

/* STREAMING_CHUNK: Perfecting the author avatar... */
.webmention-avatar {
width: 44px;
height: 44px;
border-radius: 50%;
object-fit: cover;
border: 1px solid rgba(128, 128, 128, 0.2);
flex-shrink: 0;
}

/* STREAMING_CHUNK: Styling the comment body and metadata... */
.webmention-body {
display: flex;
flex-direction: column;
gap: 0.25rem;
flex: 1;
}

.webmention-meta {
font-size: 0.9rem;
font-weight: bold;
}

.webmention-author-link {
color: var(--text-color);
text-decoration: none;
}

.webmention-author-link:hover {
color: var(--link-color);
text-decoration: underline;
}

/* STREAMING_CHUNK: Formatting date links to social posts... */
.webmention-date {
font-weight: normal;
margin-left: 0.5rem;
font-size: 0.85rem;
}

.webmention-date-link {
color: var(--meta-color);
text-decoration: none;
}

.webmention-date-link:hover {
color: var(--link-color);
text-decoration: underline;
}

.webmention-text {
margin: 0.15rem 0 0 0;
font-size: 1rem;
line-height: 1.5;
color: var(--text-color);
}