/*
 * Amusement Factory - estilo da página principal (mobile first).
 * A identidade de sempre: fundo lavanda claro, faixas azuis nos títulos, logotipo em pixel
 * e a capitular azul nas notícias.
 */

:root {
  --bg: #eef0fb;
  --paper: #ffffff;
  --ink: #0a1432;
  --muted: #4a5272;
  --line: #c3cbf2;
  --blue: #1b2470;
  --blue-2: #2f43b8;
  --blue-soft: #e3e7fb;
  --link: #1f3bbf;
  --bar: linear-gradient(180deg, #3b52c9 0%, #1d2b8f 55%, #121b63 100%);
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 30, 90, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--link);
}

a:hover {
  color: var(--blue-2);
}

:focus-visible {
  outline: 3px solid #f2b400;
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 10;
  padding: 0.5rem 1rem;
  background: var(--blue);
  color: #fff;
}

.skip:focus {
  left: 0;
}

/* ---------- Cabeçalho e menu ---------- */

.site-header {
  position: relative;
  z-index: 10;   /* os submenus abrem por cima do carrossel e do resto da página */
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1rem 0;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: calc(100% - 5.5rem);
  text-decoration: none;
}

.brand-logo {
  width: 64px;
  flex: none;
}

.brand-text {
  flex: 1 1 0;
  min-width: 0;
  max-width: 260px;
}

.lang {
  position: absolute;
  top: 0.9rem;
  right: 1rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.8rem;
  text-decoration: none;
}

.site-nav > ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0.75rem 0 0;
  padding: 0 0 0.6rem;
  list-style: none;
}

/* No celular, os submenus abrem na largura toda, logo abaixo do cabeçalho */
.site-nav li {
  position: static;
}

.site-nav summary,
.site-nav > ul > li > a {
  display: block;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  list-style: none;
}

.site-nav summary::-webkit-details-marker {
  display: none;
}

.site-nav summary::after {
  content: " ▾";
  font-size: 0.75em;
}

.site-nav details[open] > summary,
.site-nav summary:hover,
.site-nav > ul > li > a:hover {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.site-nav details ul {
  position: absolute;
  top: calc(100% - 0.25rem);
  right: 1rem;
  left: 1rem;
  z-index: 5;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(20, 30, 90, 0.18);
}

.site-nav details ul a {
  display: block;
  padding: 0.45rem 0.6rem;
  border-radius: 5px;
  color: var(--ink);
  text-decoration: none;
}

.site-nav details ul a:hover {
  background: var(--blue-soft);
}

/* ---------- Conteúdo ---------- */

.site-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem;
}

/* Faixa azul dos títulos (seções, notícias e páginas antigas) */
.section-title,
.content > h1,
.news > header {
  margin: 0;
  padding: 0.45rem 0.8rem;
  background: var(--bar);
  color: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 1.05rem;
  line-height: 1.35;
}

.section-title {
  margin-bottom: 1rem;
  border-radius: var(--radius);
}

.content {
  margin: 0 0 1.25rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.content > h1 {
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
}

.contentdata {
  padding: 0.25rem 1rem 1rem;
  overflow-wrap: break-word;
}

.contentdata > div:first-child:has(> hr:only-child) {
  display: none;
}

/* Recuo de primeira linha nos parágrafos, como no site original */
.contentdata p,
.news-body p {
  text-indent: 20px;
}

.content div + p,
.news-body > p:first-of-type,
.card p {
  text-indent: 0;
}

.content h2 {
  color: var(--blue);
  font-size: 1.15rem;
}

.content h1:not(:first-child) {
  margin: 1.5rem 0 0.5rem;
  color: var(--blue);
  font-size: 1.1rem;
}

/* Imagem de abertura das páginas antigas (à direita) */
.content > .fr {
  float: right;
  margin: 0.75rem 1rem 0.5rem 0.75rem;
}

.content > .fr img {
  display: block;
  width: 90px;
}

.fr {
  float: right;
  margin: 0 0 0.5rem 0.75rem;
}

.center {
  text-align: center;
}

.nodisp {
  display: none;
}

.signature {
  text-align: right;
  font-style: italic;
  color: var(--muted);
}

.menupath {
  font-weight: 600;
}

/* Curso de Assembly: código em formulário contínuo, saídas como a tela do MSX-DOS e
   comandos digitados numa faixa lavanda, como no site original */
pre,
code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  font-size: 0.85em;
  line-height: 1.45;
}

.contentdata code {
  display: block;
  overflow-x: auto;
  white-space: pre;
  margin: 1.5em auto;
  padding: 0.5em 1em 1em 60px;
  background: #fff url(form3.png) repeat-y top left;
  border: 1px solid rgba(190, 200, 250, 0.7);
  border-radius: 5px;
}

.contentdata pre {
  overflow-x: auto;
  margin: 1em 0;
  padding: 10px;
  background-color: rgba(190, 200, 250, 0.3);
}

.contentdata pre.prompt {
  margin: 1.5em auto;
  padding: 1em;
  background: #000;
  color: #ccc;
  border: 1px solid rgb(190, 200, 250);
  border-radius: 10px;
}

table {
  border-collapse: collapse;
}

.contentdata table:not(.products) {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

.contentdata table.center {
  display: table;
  margin-inline: auto;
}

/* Tabelas de produtos: no celular, cada produto vira um cartão */
.products {
  width: 100%;
}

.products th,
.products tr:has(> th) {
  display: none;
}

.products tr {
  display: block;
  margin: 0 0 1rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  scroll-margin-top: 1rem;
}

.products tr:target {
  border-color: var(--blue-2);
  box-shadow: 0 0 0 3px rgba(47, 67, 184, 0.25);
}

.products td {
  display: block;
  padding: 0.2rem 0;
}

.products td:first-child {
  font-weight: 700;
  color: var(--blue);
}

.products td:first-child img {
  display: block;
  max-width: 160px;
  margin-top: 0.35rem;
}

/* Contribua: Ko-fi e Pix */
.cards {
  display: grid;
  gap: 1rem;
  margin: 1.25rem 0;
  clear: both;
}

.card {
  padding: 0 1rem 0.5rem;
  background: var(--blue-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
}

.card h2 {
  margin: 0 -1rem 0.75rem;
  padding: 0.4rem;
  background: var(--bar);
  color: #fff;
  border-radius: 7px 7px 0 0;
  font-size: 1rem;
}

.button {
  display: inline-block;
  padding: 0.5rem 1.1rem;
  border: 0;
  border-radius: 6px;
  background: var(--bar);
  color: #fff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  color: #fff;
  filter: brightness(1.15);
}

.pix-qr {
  display: block;
  width: 200px;
  margin: 0 auto;
  padding: 8px;
  background: #fff;
  border-radius: 6px;
  image-rendering: pixelated;
}

.pix-label {
  margin-bottom: 0.25rem;
}

.pix-code {
  display: block;
  padding: 0.5rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: 0.75rem/1.4 ui-monospace, Consolas, monospace;
  word-break: break-all;
  text-align: left;
}

/* ---------- Destaques (carrossel) e Software da Semana ---------- */

.hero {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.carousel {
  position: relative;
  isolation: isolate;   /* as camadas dos slides e dos controles ficam só aqui dentro */
  min-width: 0;
  overflow: hidden;
  background: var(--blue);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.slides {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
}

.slides::-webkit-scrollbar {
  display: none;
}

.slide {
  position: relative;
  flex: 0 0 100%;
  scroll-snap-align: start;
}

.slide a {
  display: block;
  color: #fff;
  text-decoration: none;
}

.slide img {
  display: block;
  width: 100%;
  aspect-ratio: 640 / 300;
  object-fit: cover;
}

.slide-caption {
  display: block;
  padding: 0.6rem 0.8rem 2.6rem;
  background: var(--blue);
  font-size: 0.9rem;
  line-height: 1.4;
}

.slide-caption strong,
.slide-caption > span {
  display: block;
}

.slide-caption strong {
  font-size: 1.05rem;
}

.carousel-nav {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  left: 0.5rem;
  z-index: 5;    /* acima dos slides, que se empilham durante as trocas */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.carousel-nav button {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 6px;
  background: rgba(10, 20, 60, 0.7);
  color: #fff;
  font-size: 0.8rem;
  cursor: pointer;
}

.carousel-nav .dot {
  width: 0.8rem;
  height: 0.8rem;
  border: 2px solid #fff;
  border-radius: 50%;
  background: transparent;
}

.carousel-nav .dot[aria-current="true"] {
  background: #fff;
}

/* Com JavaScript: os slides ficam empilhados e trocam com um efeito sorteado a cada vez
   (fusão, deslizar, zoom, cortina e círculo); a imagem ativa se move devagar */
.js .slides {
  display: grid;
  overflow: hidden;
  scroll-snap-type: none;
}

.js .slide {
  grid-area: 1 / 1;
  visibility: hidden;
  overflow: hidden;
}

.js .slide.is-active,
.js .slide.is-leaving {
  visibility: visible;
}

.js .slide.is-active {
  z-index: 2;
}

.js .slide.is-leaving {
  z-index: 1;
}

.js .slide .slide-img {
  display: block;
  overflow: hidden;
}

/* Zoom lento: velocidade constante, na placa de vídeo, e sem parar quando o slide sai
   (continua enquanto o próximo entra, para não dar um salto de volta) */
.js .slide img {
  will-change: transform;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
}

.js .slide.is-active img,
.js .slide.is-leaving img {
  animation: af-drift 8s linear both;
}

.js .slide:nth-child(even).is-active img,
.js .slide:nth-child(even).is-leaving img {
  animation-name: af-drift-2;
}

.js .slide.is-active .slide-caption strong,
.js .slide.is-active .slide-caption span {
  animation: af-caption 0.7s 0.35s ease-out both;
}

.js .slide.is-active .slide-caption span {
  animation-delay: 0.5s;
}

.js .slide.is-active.fx-fade   { animation: af-fade 1s ease both; }
.js .slide.is-active.fx-slide  { animation: af-slide 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.js .slide.is-active.fx-slide.from-left { animation-name: af-slide-left; }
.js .slide.is-active.fx-zoom   { animation: af-zoom 1s ease-out both; }
.js .slide.is-active.fx-wipe   { animation: af-wipe 0.9s ease-in-out both; }
.js .slide.is-active.fx-wipe.from-left { animation-name: af-wipe-left; }
.js .slide.is-active.fx-circle { animation: af-circle 1s ease-in-out both; }

@keyframes af-fade   { from { opacity: 0; } to { opacity: 1; } }
@keyframes af-slide  { from { transform: translateX(100%); } to { transform: none; } }
@keyframes af-slide-left { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes af-zoom   { from { opacity: 0; transform: scale(1.25); } to { opacity: 1; transform: none; } }
@keyframes af-wipe   { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0); } }
@keyframes af-wipe-left { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0); } }
@keyframes af-circle { from { clip-path: circle(0% at 50% 45%); } to { clip-path: circle(75% at 50% 45%); } }
@keyframes af-drift  { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(-1.5%, -1%, 0) scale(1.08); } }
@keyframes af-drift-2 { from { transform: translate3d(1.5%, 1%, 0) scale(1.08); } to { transform: translate3d(0, 0, 0) scale(1); } }
@keyframes af-caption { from { opacity: 0; transform: translateY(0.6rem); } to { opacity: 1; transform: none; } }

/* Quem pediu menos movimento no sistema: só a fusão, sem zoom nem deslocamento */
@media (prefers-reduced-motion: reduce) {
  .js .slide.is-active[class*="fx-"] { animation: af-fade 0.8s ease both; }
  .js .slide.is-active img,
  .js .slide.is-leaving img,
  .js .slide.is-active .slide-caption strong,
  .js .slide.is-active .slide-caption span { animation: none; }
}

.carousel-nav .pause {
  margin-left: 0.5rem;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
}

.gow {
  overflow: hidden;
  background: #000;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.gow h2 {
  margin: 0;
  padding: 0.45rem;
  background: var(--bar);
  color: #fff;
  font-size: 0.95rem;
}

.gow a {
  display: block;
  color: #fff;
  text-decoration: none;
}

.gow img {
  display: block;
  width: 100%;
  image-rendering: pixelated;
}

.gow-title {
  display: block;
  padding: 0.5rem;
  font-weight: 700;
  font-variant: small-caps;
  letter-spacing: 0.05em;
}

/* ---------- Notícias ---------- */

.news {
  margin: 0 0 1.25rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  scroll-margin-top: 1rem;
}

.news > header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0 1rem;
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
}

.news h1,
.news h2 {
  margin: 0;
  font-size: 1.05rem;
}

.news header a {
  color: #fff;
  text-decoration: none;
}

.news header a:hover {
  text-decoration: underline;
}

.news time {
  font-size: 0.8rem;
  opacity: 0.9;
}

.news-body {
  padding: 0.75rem 1rem;
}

.news-body::after {
  content: "";
  display: block;
  clear: both;
}

.news-img {
  display: block;
  max-width: 220px;
  max-height: 160px;
  margin: 0 auto 0.75rem;
  object-fit: contain;
}

/* A capitular azul do primeiro parágrafo */
.news-body > p:first-of-type::first-letter {
  float: left;
  margin: 0.25rem 0.5rem 0 0;
  padding: 0.15rem 0.45rem;
  background: var(--bar);
  color: #fff;
  border-radius: 6px;
  font-size: 2.2em;
  font-weight: 700;
  line-height: 1;
}

.more {
  text-align: right;
  font-weight: 600;
}

/* Curso de Assembly: abas das aulas */
.lessons ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.lessons a {
  display: block;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  text-decoration: none;
}

.lessons a[aria-current="page"] {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

/* ---------- Rodapé ---------- */

.site-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.site-footer p {
  margin: 0.3rem 0;
}

.counter {
  font-family: ui-monospace, Consolas, monospace;
  opacity: 0.6;
}

/* ---------- Telas maiores ---------- */

@media (min-width: 640px) {
  .brand-logo {
    width: 96px;
  }

  .site-nav li {
    position: relative;
  }

  .site-nav details ul {
    top: calc(100% + 4px);
    right: auto;
    left: 0;
    min-width: 15rem;
  }

  .site-nav > ul > li:last-child details ul,
  .site-nav > ul > li:nth-last-child(-n+3) details ul {
    right: 0;
    left: auto;
  }

  .news-img {
    float: right;
    margin: 0.25rem 0 0.5rem 1rem;
  }

  .content > .fr img {
    width: 120px;
  }

  .contentdata,
  .news-body {
    text-align: justify;
    hyphens: auto;
  }

  .contentdata .card,
  .contentdata .center {
    text-align: center;
  }

  .products th {
    display: table-cell;
    padding: 0.5rem;
    background: var(--blue-soft);
    color: var(--blue);
    text-align: left;
  }

  .products tr,
  .products tr:has(> th) {
    display: table-row;
    border: 0;
  }

  .products td {
    display: table-cell;
    padding: 0.75rem 0.5rem;
    vertical-align: top;
    border-top: 1px solid var(--line);
  }

  .products td:first-child {
    width: 11rem;
  }

  .products tr:target td {
    background: #f3f5ff;
  }
}

@media (min-width: 900px) {
  .site-header {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    margin-top: 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }

  .brand {
    max-width: none;
    padding-bottom: 0.75rem;
  }

  .brand-logo {
    width: 110px;
  }

  .site-nav > ul {
    justify-content: flex-end;
  }

  .hero {
    grid-template-columns: 2fr 1fr;
    align-items: start;
  }

  /* No desktop a legenda fica sobre a imagem, bem embaixo, e os controles vão para o canto
     de cima, à direita */
  .slide-caption {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 2.5rem 1rem 0.8rem;
    background: linear-gradient(0deg, rgba(8, 12, 48, 0.95) 0%, rgba(8, 12, 48, 0.85) 55%, rgba(8, 12, 48, 0) 100%);
    text-shadow: 0 1px 2px #000, 0 0 6px rgba(0, 0, 0, 0.8);
  }

  .slide-caption strong {
    font-size: 1.2rem;
  }

  .carousel-nav {
    top: 0.6rem;
    right: 0.6rem;
    bottom: auto;
    left: auto;
    padding: 0.3rem 0.4rem;
    background: rgba(8, 12, 48, 0.55);
    border-radius: 8px;
  }

  .contentdata.dualcol {
    columns: 2;
    column-gap: 2rem;
  }

  .cards.two {
    grid-template-columns: 1fr 1fr;
  }

  .contentdata code {
    width: 75%;
  }

  .contentdata pre {
    margin-left: 3em;
  }

  .contentdata pre.prompt {
    width: 70%;
  }

  .contentdata.dualcol > .signature {
    break-inside: avoid;
  }
}

@media (prefers-reduced-motion: reduce) {
  .slides {
    scroll-behavior: auto;
  }
}
