/* -------------------------------------------------------- */
/* VARIABLES & TOKENS */
/* -------------------------------------------------------- */

:root {
  /* Background Colors */
  --bg-color: #c7fec6e9;
  --content-bg: transparent;
  --sidebar-bg: transparent;

  /* Text Colors */
  --text-color: #24331e;
  --sidebar-text: #456e2e;
  --link-color: #63ce64;
  --link-hover: #e76a7b;

  /* Typography */
  --font-main: "Lucida Console", Monaco, monospace;
  --font-heading: "Courier New", Courier, monospace;
  --font-size-base: 18px; /* Ajustado para melhor legibilidade geral */

  /* Layout & Spacing */
  --margin: 22px;
  --padding: 20px;
  --border-radius: 0px;
}

/* -------------------------------------------------------- */
/* BASE RESETS */
/* -------------------------------------------------------- */

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  margin: 0;
  padding: var(--margin);
  
  font-family: var(--font-main);
  font-size: var(--font-size-base);
  line-height: 1.5; /* Padrão de acessibilidade melhor que 1.2 */
  color: var(--text-color);
  
  background: var(--bg-color) url("https://sadhost.neocities.org/images/tiles/rdbg.jpg") repeat;
}

/* Seleção de texto e Destaques */
::selection {
  background-color: rgba(0, 0, 0, 0.2);
}

mark {
  text-shadow: 1px 1px 4px var(--link-color);
  background-color: transparent;
  color: currentColor;
}

/* Links Globais */
a {
  color: var(--link-color);
  text-decoration: underline;
  transition: color 0.2s ease, text-decoration 0.2s ease;
}

a:hover,
a:focus-visible {
  color: var(--link-hover);
  text-decoration: none;
  outline: 2px solid var(--link-hover);
  outline-offset: 4px;
}

/* -------------------------------------------------------- */
/* LAYOUT STRUCTURE (CSS Grid Moderno) */
/* -------------------------------------------------------- */

.layout {
  width: 100%;
  max-width: 1200px;
  display: grid;
  gap: var(--margin);
  grid-template-columns: 170px 1fr;
  grid-template-areas:
    "header header"
    "leftSidebar main"
    "footer footer";
}

main {
  grid-area: main;
  padding: var(--padding);
  background: var(--content-bg);
  border-radius: var(--border-radius);
}

/* -------------------------------------------------------- */
/* HEADER & NAVIGATION */
/* -------------------------------------------------------- */

header {
  grid-area: header;
  background: var(--content-bg);
  border-radius: var(--border-radius);
}

.header-content {
  padding: var(--padding);
}

.header-title {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: bold;
}

.header-image img {
  width: 100%;
  height: auto;
  display: block;
}

/* Menu de Navegação */
nav {
  margin-bottom: 3em;
}

nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

nav > ul li > a,
nav > ul li > strong {
  display: inline-block;
  padding: 5px 10px;
}

nav > ul li > a.active {
  font-weight: bold;
}

/* Navegação do Header (Horizontal com Flexbox) */
header nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

header nav ul li {
  position: relative;
}

/* Submenu Dropdown Otimizado */
header nav ul ul {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 160px;
  padding: 0.5em;
  background: var(--bg-color);
  z-index: 10;
  box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.15);
}

header nav ul li:hover ul,
header nav ul li:focus-within ul {
  display: block;
}

/* -------------------------------------------------------- */
/* SIDEBARS */
/* -------------------------------------------------------- */

aside {
  border-radius: var(--border-radius);
  background: var(--sidebar-bg);
  padding: var(--padding);
  color: var(--sidebar-text);
}

.left-sidebar { grid-area: leftSidebar; }
.right-sidebar { grid-area: rightSidebar; }

.sidebar-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: bold;
}

.sidebar-section:not(:last-child) {
  margin-bottom: 2.5em;
}

.sidebar-section ul,
.sidebar-section ol {
  padding-left: 1.2em;
}

/* Componente de botão de troca/código */
.site-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.site-button textarea {
  font-family: monospace;
  font-size: 0.75rem;
  width: 100%;
  resize: vertical;
}

/* -------------------------------------------------------- */
/* MAIN CONTENT TYPOGRAPHY */
/* -------------------------------------------------------- */

main h1, main h2, main h3, main h4, main h5, main h6 {
  font-family: var(--font-heading);
  margin: 1.5em 0 0.5em;
  line-height: 1.3;
}

main h1:first-child, main h2:first-child, main h3:first-child {
  margin-top: 0;
}

main h1 { font-size: 1.8rem; }
main h2 { font-size: 1.5rem; }
main h3 { font-size: 1.3rem; }

main p {
  margin: 0 0 1em;
}

/* Links específicos do conteúdo */
main a:hover,
main a:focus-visible {
  text-decoration-style: wavy;
}

/* Listas, Citações e Blocos */
main ol, main ul {
  margin: 0 0 1em;
  padding-left: 1.5em;
}

main li {
  margin-bottom: 0.4em;
}

main blockquote,
.sidebar-section blockquote {
  background: rgba(0, 0, 0, 0.05);
  padding: 15px;
  margin: 1.5em 0;
  border-radius: 8px;
  border-left: 4px solid var(--link-color);
}

main hr {
  border: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  margin: 2em 0;
}

/* Sistema de Duas Colunas Flexível */
.two-columns {
  display: flex;
  flex-wrap: wrap;
  gap: var(--padding);
}

.two-columns > * {
  flex: 1 1 250px; /* Responsivo por padrão */
}

/* Imagens do Conteúdo */
.image, .full-width-image {
  display: block;
  max-width: 100%;
  height: auto;
}

.full-width-image {
  width: 100%;
}

.images {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.images img {
  flex: 1 1 150px;
  max-width: 100%;
  height: auto;
  object-fit: cover;
}

/* -------------------------------------------------------- */
/* FOOTER */
/* -------------------------------------------------------- */

footer {
  grid-area: footer;
  border-radius: var(--border-radius);
  font-size: 0.8rem;
  padding: var(--padding);
  background: var(--content-bg);
  display: flex;
  justify-content: center;
}

/* -------------------------------------------------------- */
/* ACCESSIBILITY & UTILITIES */
/* -------------------------------------------------------- */

#skip-to-content-link {
  position: fixed;
  top: 0;
  left: 0;
  padding: 0.5rem 1rem;
  background-color: var(--text-color);
  color: var(--bg-color);
  transform: translateY(-100%);
  transition: transform 0.2s ease-in-out;
  z-index: 99999;
}

#skip-to-content-link:focus {
  transform: translateY(0);
}

/* -------------------------------------------------------- */
/* MOBILE RESPONSIVE (< 800px) */
/* -------------------------------------------------------- */

@media (max-width: 800px) {
  :root {
    --font-size-base: 15px;
    --margin: 12px;
    --padding: 12px;
  }

  .layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "leftSidebar"
      "main"
      "rightSidebar"
      "footer";
  }

  header nav ul {
    flex-direction: column;
    gap: 5px;
  }

  header nav ul ul {
    position: static;
    box-shadow: none;
    padding-left: 1.5em;
  }
}