:root {
  --bg: #ffffff;
  --text: #202124;
  --muted: #5f6368;
  --border: #dadce0;
  --hover: #f1f3f4;
  --accent: #1a73e8;
  --logo-blue: #4285f4;
  --logo-red: #ea4335;
  --logo-yellow: #fbbc05;
  --logo-green: #34a853;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #202124;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --border: #5f6368;
    --hover: #303134;
    --accent: #8ab4f8;
  }
}

:root[data-theme="dark"] {
  --bg: #202124;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --border: #5f6368;
  --hover: #303134;
  --accent: #8ab4f8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 18vh 16px 40px;
}

.logo {
  margin: 0 0 28px;
  font-size: clamp(56px, 14vw, 108px);
  font-weight: 700;
  letter-spacing: -2px;
  line-height: 1;
  user-select: none;
}

.logo > span:nth-child(1),
.logo > span:nth-child(4) {
  color: var(--logo-blue);
}

.logo > span:nth-child(2) {
  color: var(--logo-red);
}

.logo > span:nth-child(3) {
  color: var(--logo-yellow);
}

.logo > span:nth-child(5) {
  color: var(--logo-green);
}

/* Faixa com as cores da bandeira embaixo da logo */
.logo {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding-bottom: 12px;
}

.logo::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, #009c3b 0 33.3%, #ffdf00 33.3% 66.6%, #002776 66.6%);
}

/* Selo "BR" com o desenho da bandeira: verde, losango amarelo e círculo azul */
/* Faz parte da logo: o conjunto letras + bandeira fica centralizado na página */
.br-badge {
  position: relative;
  top: 0.06em;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.7em;
  height: 1.16em;
  margin-left: 0.2em;
  border-radius: 0.2em;
  overflow: hidden;
  background: #009c3b;
  font-size: 0.6em;
  /* Começa um pouco antes de a letra "a" ficar totalmente visível */
  transform-origin: left center;
  animation: br-badge-flow 1.1s cubic-bezier(0.45, 0.05, 0.3, 1.2) 0.42s both;
}

.br-badge::before {
  content: "";
  position: absolute;
  inset: 0;
  background: #ffdf00;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.br-badge::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.95em;
  height: 0.95em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #4d7fd8, #002776);
  transform: translate(-50%, -50%);
}

/* Ao abrir: estrelas aparecem, somem e o BR entra no lugar */
.br-stars,
.br-text {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
}

.br-stars {
  font-size: 0.24em;
  letter-spacing: 0.02em;
  animation: br-stars-out 0.4s ease 1.7s forwards;
}

.br-text {
  font-size: 0.55em;
  letter-spacing: 0.02em;
  opacity: 0;
  animation: br-text-in 0.4s ease 1.9s forwards;
}

/* A bandeira escorre para fora da letra "a" como líquido: começa esticada e borrada,
   forma uma gota e se acomoda no formato final com um leve balanço */
@keyframes br-badge-flow {
  0% {
    opacity: 0;
    transform: translateX(-1.2em) scale(0.3, 0.6);
    filter: blur(4px);
    border-radius: 50%;
  }
  35% {
    opacity: 1;
    transform: translateX(-0.3em) scale(1.25, 0.8);
    filter: blur(2px);
    border-radius: 60% 40% 55% 45% / 45% 60% 40% 55%;
  }
  70% {
    transform: translateX(0.05em) scale(0.92, 1.06);
    filter: blur(0);
    border-radius: 45% 55% 40% 60% / 55% 40% 60% 45%;
  }
  100% {
    opacity: 1;
    transform: none;
    filter: none;
    border-radius: 0.2em;
  }
}

@keyframes br-stars-out {
  to {
    opacity: 0;
  }
}

@keyframes br-text-in {
  to {
    opacity: 1;
  }
}

/* Letras de "Busca" entram uma a uma (invisíveis no início) com um pulinho ao aparecer */
@keyframes letter-hop {
  0% {
    opacity: 0;
    transform: translateY(12px);
  }
  40% {
    opacity: 1;
    transform: translateY(-14px);
  }
  70%,
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.logo > span:not(.br-badge) {
  display: inline-block;
  animation: letter-hop 0.6s ease-out both;
}

.logo > span:nth-child(1) {
  animation-delay: 0s;
}

.logo > span:nth-child(2) {
  animation-delay: 0.08s;
}

.logo > span:nth-child(3) {
  animation-delay: 0.16s;
}

.logo > span:nth-child(4) {
  animation-delay: 0.24s;
}

.logo > span:nth-child(5) {
  animation-delay: 0.32s;
}

@media (prefers-reduced-motion: reduce) {
  .logo > span,
  .br-badge,
  .br-stars,
  .br-text {
    animation: none;
  }

  .br-stars {
    display: none;
  }

  .br-text {
    opacity: 1;
  }
}

.suggestion-link {
  display: block;
  margin: 4px 14px 0;
  color: var(--accent);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-wrap {
  position: relative;
  width: 100%;
  max-width: 584px;
}

/* Sugestões que combinam com o que está sendo digitado */
.autocomplete {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 10;
  list-style: none;
  margin: 0;
  padding: 6px 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(32, 33, 36, 0.18);
}

.autocomplete[hidden] {
  display: none;
}

.autocomplete button {
  width: 100%;
  border: 0;
  background: none;
  color: var(--text);
  font-size: 15px;
  text-align: left;
  padding: 10px 18px;
  cursor: pointer;
}

.autocomplete button:hover,
.autocomplete button:focus-visible {
  background: var(--hover);
  outline: 0;
}

.search {
  width: 100%;
  max-width: 584px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 6px 6px 6px 18px;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.search:focus-within {
  border-color: transparent;
  box-shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  padding: 10px 0;
}

.search button {
  border: 0;
  border-radius: 18px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  padding: 10px 18px;
  cursor: pointer;
  white-space: nowrap;
}

.search button:hover {
  filter: brightness(1.08);
}

.suggestions {
  list-style: none;
  margin: 24px 0 0;
  padding: 0;
  width: 100%;
  max-width: 584px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.suggestions:empty {
  display: none;
}

.history-button {
  margin: 18px 0 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: transparent;
  color: var(--accent);
  font-size: 14px;
  padding: 6px 16px;
  cursor: pointer;
}

.history-button:hover,
.history-button[aria-expanded="true"] {
  background: var(--hover);
}

.featured {
  width: 100%;
  max-width: 584px;
}

.featured:empty {
  display: none;
}

.featured-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.suggestion-row {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding-right: 6px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.suggestion-row:hover,
.suggestion-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 1px 4px rgba(32, 33, 36, 0.18);
}

/* Lista discreta fixa no lado esquerdo da tela, com rolagem própria */
.more-suggestions {
  position: fixed;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 200px;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 6px;
}

@media (max-width: 900px) {
  .more-suggestions {
    position: static;
    transform: none;
    width: 100%;
    max-height: 180px;
    margin-top: 18px;
  }
}

/* Botão discreto no fim da página, que mostra as pesquisas relacionadas */
.related-button {
  margin-top: 36px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  opacity: 0.6;
  cursor: pointer;
}

.related-button:hover,
.related-button:focus-visible,
.related-button[aria-expanded="true"] {
  opacity: 1;
  color: var(--accent);
  outline: 0;
}

.share-button {
  margin-top: 12px;
}

.share-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.share-fallback[hidden] {
  display: none;
}

.related-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  width: 100%;
  max-width: 584px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.related-list[hidden] {
  display: none;
}

.related-list li {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.related-item {
  border: 0;
  background: none;
  color: var(--text);
  font-size: 14px;
  padding: 4px 8px;
  cursor: pointer;
}

.related-item:hover,
.related-item:focus-visible {
  text-decoration: underline;
  outline: 0;
}

.more-suggestion {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  padding: 2px 4px;
  opacity: 0.5;
  cursor: pointer;
  transition: opacity 0.2s, color 0.2s;
}

/* Olhinho preto e transparente com o número de aparelhos que clicaram */
.click-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 0 8px;
  color: #000;
  opacity: 0.45;
  font-size: 12px;
  white-space: nowrap;
}

.more-suggestion .click-count,
.autocomplete .click-count {
  padding: 0;
  font-size: inherit;
}

.more-suggestion:hover,
.more-suggestion:focus-visible {
  color: var(--accent);
  opacity: 1;
  text-decoration: underline;
  outline: 0;
}

.suggestion-row .suggestion {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  padding: 12px 14px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-row .suggestion:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.suggestion-row .remove {
  border: 0;
  background: transparent;
  color: #d93025;
  font-size: 13px;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 8px;
  flex-shrink: 0;
}

.suggestion-row .remove:hover {
  background: rgba(217, 48, 37, 0.12);
}

@media (max-width: 480px) {
  .page {
    padding-top: 12vh;
  }

  .search button {
    padding: 10px 12px;
  }
}

/* Telefones e tablets */
@media (max-width: 600px) {
  .page {
    padding: 10vh 16px 32px;
  }

  .suggestion-row .suggestion {
    white-space: normal;
    font-size: 16px;
  }

  .related-item,
  .more-suggestion {
    font-size: 14px;
  }
}

/* Telas de toque: alvos maiores para o dedo */
@media (pointer: coarse) {
  .history-button,
  .related-button {
    min-height: 44px;
    padding: 10px 20px;
    opacity: 0.8;
  }

  .suggestion-row .suggestion,
  .suggestion-row .remove {
    min-height: 44px;
  }

  .more-suggestion,
  .related-item {
    min-height: 40px;
    padding: 8px 12px;
  }

  .autocomplete button {
    min-height: 44px;
  }
}

/* Ajustes conforme o aparelho detectado (device.js) */
:root:not([data-device="desktop"]) .more-suggestions {
  position: static;
  transform: none;
  width: 100%;
  max-height: 180px;
  margin-top: 18px;
}

:root[data-device="phone"] .more-suggestion,
:root[data-device="phone"] .related-item {
  font-size: 14px;
}

/* Celular deitado tem pouca altura: a logo e os espaçamentos diminuem */
:root[data-device="phone"][data-orientation="landscape"] .page {
  padding-top: 4vh;
}

:root[data-device="phone"][data-orientation="landscape"] .logo {
  font-size: 48px;
  margin-bottom: 16px;
}

:root[data-device="phone"][data-orientation="landscape"] .history-button {
  margin-top: 12px;
}

.share-post {
  max-width: 584px;
  margin: 0;
  white-space: pre-line;
  text-align: left;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
