/*
Theme Name: Teste sua Sorte
Theme URI: https://testarsorte.com.br
Description: Simulador de probabilidade interativo com links de afiliado do Mercado Livre
Version: 1.0
Requires at least: 5.8
Requires PHP: 7.4
License: GNU General Public License v2 or later
Text Domain: testarsorte
*/

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

body {
  background: #0a0a0a;
  color: #f0f0f0;
  font-family: system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  max-width: 480px;
}

h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #f0f0f0;
  margin-bottom: 0.4rem;
}

h2 {
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #444;
  margin-bottom: 2rem;
}

.mode-toggle {
  display: flex;
  gap: 0;
  border: 1px solid #222;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 3rem;
  margin-top: -2rem;
}

.mode-btn {
  background: transparent;
  color: #555;
  border: none;
  border-radius: 0;
  width: auto;
  height: auto;
  font-size: 0.78rem;
  font-family: inherit;
  font-weight: 500;
  letter-spacing: 0.05em;
  cursor: pointer;
  padding: 0.45rem 1rem;
  transition: background 0.15s, color 0.15s;
  box-shadow: none;
}

.mode-btn:hover { background: #1a1a1a; color: #888; box-shadow: none; }
.mode-btn:active { transform: none; }
.mode-btn.active { background: #1e1e1e; color: #f0f0f0; }

.input-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 3rem;
}

label {
  font-size: 1rem;
  color: #999;
  text-align: center;
  margin-top: -2rem;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

input[type="number"], #freq {
  background: transparent;
  border: none;
  border-bottom: 1px solid #333;
  color: #f0f0f0;
  font-size: 2.5rem;
  font-family: inherit;
  text-align: center;
  outline: none;
  padding: 0.25rem 0;
  transition: border-color 0.2s;
  appearance: textfield;
  border-radius: 0;
}
input[type="number"] { width: 5rem; }
#freq { width: auto; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
input[type="number"]:focus, #freq:focus { border-color: #666; }

.input-label {
  font-size: 2rem;
  color: #555;
  position: absolute;
  white-space: nowrap;
}

#wrapPercent .input-label { left: 100%; padding-left: 0.4rem; }
#wrapFreq    .input-label { right: 100%; padding-right: 0.4rem; }

button {
  background: #f0f0f0;
  color: #0a0a0a;
  border: none;
  border-radius: 50%;
  width: 200px;
  height: 200px;
  font-size: 1.1rem;
  font-family: inherit;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, box-shadow 0.2s, transform 0.1s;
  box-shadow: 0 0 0 0 rgba(240,240,240,0);
}

button:hover {
  background: #ffffff;
  box-shadow: 0 0 40px rgba(240,240,240,0.15);
}

button:active { transform: scale(0.96); }
#btn:active:not(.pressing) { transform: scale(0.93); }

@keyframes btn-press {
  0%   { transform: scale(0.93); }
  60%  { transform: scale(1.04); }
  100% { transform: scale(1);    }
}
@keyframes btn-ring {
  0%   { box-shadow: 0 0 0 0    rgba(240,240,240,0.35); }
  100% { box-shadow: 0 0 0 28px rgba(240,240,240,0);    }
}
#btn.pressing {
  animation: btn-press 0.38s cubic-bezier(0.34, 1.56, 0.64, 1),
             btn-ring  0.5s  ease-out;
}

@keyframes float-up {
  0%   { opacity: 1; transform: translateX(-50%) translateY(0)      scale(1.1); }
  15%  { opacity: 1; transform: translateX(-50%) translateY(-18px)   scale(1.2); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-195px)  scale(0.85); }
}
.click-score {
  position: fixed;
  font-size: 1.3rem;
  font-weight: 700;
  color: #ef4444;
  pointer-events: none;
  user-select: none;
  z-index: 1000;
  animation: float-up 1.125s ease-out forwards;
}

.btn-wrapper {
  position: relative;
  width: 200px;
  height: 200px;
  flex-shrink: 0;
  touch-action: manipulation;
}

.btn-wrapper button {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

@keyframes btn-explode {
  0%   { transform: scale(1);    opacity: 1; }
  15%  { transform: scale(0.92) rotate(-4deg); }
  30%  { transform: scale(1.1)  rotate(3deg);  }
  50%  { transform: scale(1.18); opacity: 1; }
  100% { transform: scale(3);    opacity: 0; }
}

#btn.exploding {
  animation: btn-explode 0.55s cubic-bezier(0.3, 0, 0.15, 1) forwards;
  pointer-events: none;
}

#restartInPlace {
  background: transparent;
  border: 1px solid #222;
  color: #444;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, color 0.2s, border-color 0.2s;
  box-shadow: none;
}

#restartInPlace.visible { opacity: 1; pointer-events: auto; }
#restartInPlace:hover { background: transparent; border-color: #555; color: #f0f0f0; box-shadow: none; }
#restartInPlace:active { transform: scale(0.96); }

.result {
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2.5rem;
}

.win-message {
  font-size: 1.6rem;
  font-weight: 700;
  color: #4ade80;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.win-message.visible {
  opacity: 1;
  transform: translateY(0);
}

.stats {
  margin-top: 0rem;
  font-size: 0.85rem;
  color: #444;
  text-align: center;
  min-height: 1.2em;
  transition: color 0.3s;
}

.stats.active { color: #666; }

.first-win {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: #4ade80;
  text-align: center;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.first-win.visible { opacity: 1; }

.reset-btn {
  margin-top: 0.5rem;
  background: transparent;
  border: none;
  border-radius: 0;
  width: auto;
  height: auto;
  font-size: 0.90rem;
  font-family: inherit;
  color: #333;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  letter-spacing: 0.05em;
  box-shadow: none;
  opacity: 0;
  transition: color 0.2s, opacity 0.3s;
  pointer-events: none;
}

.reset-btn.visible { opacity: 1; pointer-events: auto; }
.reset-btn:hover { color: #888; box-shadow: none; }
.reset-btn:active { transform: none; }

.top-nav {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 100;
}

.nav-link {
  display: inline-block;
  font-size: 0.72rem;
  color: #444;
  text-decoration: none;
  border: 1px solid #1e1e1e;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-family: system-ui, -apple-system, sans-serif;
  letter-spacing: 0.05em;
  transition: color 0.15s, border-color 0.15s;
}
.nav-link:hover { color: #888; border-color: #333; }

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  width: 100%;
  margin-top: 0.5rem;
}

.product-card {
  background: #0f0f0f;
  border: 1px solid #1e1e1e;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  text-align: left;
  transition: border-color 0.2s;
  overflow: hidden;
}
.product-card:hover { border-color: #333; }

.product-card-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #1a1a1a;
  flex-shrink: 0;
}
.product-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.product-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem 1.5rem;
  flex: 1;
}

.product-card-badge {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #3a3a3a;
}

.product-card-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #d0d0d0;
  line-height: 1.45;
  flex: 1;
  margin: 0;
}

.product-card-btn {
  display: block;
  background: #ffe600;
  color: #0a0a0a;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.03em;
  text-decoration: none;
  text-align: center;
  transition: background 0.15s, transform 0.1s;
  margin-top: auto;
}
.product-card-btn:hover { background: #fff200; }
.product-card-btn:active { transform: scale(0.97); }

.hint {
  margin-top: 0rem;
  font-size: 0.75rem;
  color: #333;
  text-align: center;
  max-width: 400px;
  line-height: 1.5;
}

.presets-label {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #2e2e2e;
  margin-bottom: 0.65rem;
}

.presets-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 2.5rem;
  max-width: 100%;
}

.presets {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scrollbar-width: none;
  max-width: 100%;
}
.presets::-webkit-scrollbar { display: none; }

.preset-nav-btn {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid #1e1e1e;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  color: #444;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s, opacity 0.2s;
  box-shadow: none;
}
.preset-nav-btn:hover  { border-color: #333; color: #888; box-shadow: none; }
.preset-nav-btn:active { transform: scale(0.93); }
.preset-nav-btn.hidden { opacity: 0; pointer-events: none; }

@media (hover: none) {
  .preset-nav-btn { display: none; }
}

.preset-chip {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid #1e1e1e;
  border-radius: 999px;
  width: auto;
  height: auto;
  color: #555;
  font-size: 0.72rem;
  font-family: inherit;
  font-weight: 500;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s, box-shadow 0.15s;
  letter-spacing: 0.03em;
  box-shadow: none;
  white-space: nowrap;
}
.preset-chip:hover { border-color: #333; color: #888; box-shadow: none; }
.preset-chip:active { transform: none; }
.preset-chip.active {
  border-color: var(--chip-color, #555);
  color: #f0f0f0;
  background: #1a1a1a;
  box-shadow: 0 0 10px -2px var(--chip-color, transparent);
}

@keyframes chip-select {
  0%   { transform: scale(1);    box-shadow: 0 0 0 0    var(--chip-color, #555); }
  40%  { transform: scale(1.12); box-shadow: 0 0 22px 4px var(--chip-color, #555); }
  100% { transform: scale(1);    box-shadow: 0 0 10px -2px var(--chip-color, #555); }
}
.preset-chip.selecting { animation: chip-select 0.35s ease forwards; }

#lightning-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
}
@keyframes lightning-flash {
  0%   { opacity: 0;    background: #fffbeb; }
  8%   { opacity: 0.9;  background: #ffffff; }
  22%  { opacity: 0.05; background: #fbbf24; }
  38%  { opacity: 0.75; background: #ffffff; }
  100% { opacity: 0;    background: #fffbeb; }
}
#lightning-overlay.active { animation: lightning-flash 0.65s ease forwards; }

.sort-toggle {
  display: flex;
  gap: 0;
  border: 1px solid #222;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.5rem;
  align-self: flex-start;
}

.sort-btn {
  background: transparent;
  color: #555;
  border: none;
  border-radius: 0;
  width: auto;
  height: auto;
  font-size: 0.78rem;
  font-family: inherit;
  font-weight: 500;
  letter-spacing: 0.05em;
  cursor: pointer;
  padding: 0.45rem 1rem;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  box-shadow: none;
  white-space: nowrap;
}
.sort-btn:hover { background: #1a1a1a; color: #888; }
.sort-btn.active { background: #1e1e1e; color: #f0f0f0; }

/* Links page template */
body.page-template-template-links { align-items: flex-start; }
body.page-template-template-links main { max-width: 720px; padding-top: 3rem; }

@media (max-width: 480px) {
  button { width: 160px; height: 160px; font-size: 1rem; }
  .btn-wrapper { width: 160px; height: 160px; }
  .hint { white-space: normal; width: 90%; }
  body { padding-top: 3.5rem; }
}
