/* ===== Temas (variables CSS) ===== */
:root,
[data-theme="light"] {
  --bg: #f0fbf4;
  --bg-accent: #d7f4e3;
  --card: #ffffff;
  --text: #2b3d33;
  --muted: #8a9b91; /* fonética en gris, legible sobre claro */
  --border: #e3efe8;

  --green: #58cc02;
  --green-shadow: #46a302; /* sombra inferior sólida del botón 3D */
  --green-hover: #61d80a;
  --accent: #ffc800; /* acento alegre (amarillo) */
  --accent-2: #1cb0f6; /* acento alegre (azul) */

  --shadow-card: 0 6px 0 rgba(70, 163, 2, 0.08), 0 10px 24px rgba(43, 61, 51, 0.06);
}

[data-theme="dark"] {
  --bg: #131f1a;
  --bg-accent: #1b2c24;
  --card: #1e2d27;
  --text: #eaf5ee;
  --muted: #9fb3a8; /* fonética en gris, legible sobre oscuro */
  --border: #2c3f36;

  --green: #58cc02;
  --green-shadow: #3c8a02;
  --green-hover: #63d80a;
  --accent: #ffc800;
  --accent-2: #1cb0f6;

  --shadow-card: 0 6px 0 rgba(0, 0, 0, 0.25), 0 10px 24px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Nunito", system-ui, -apple-system, sans-serif;
  font-weight: 600;
  background: radial-gradient(
      1200px 600px at 50% -10%,
      var(--bg-accent),
      transparent 70%
    ),
    var(--bg);
  color: var(--text);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===== Barra superior ===== */
.topbar {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 900;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}

.brand-logo {
  height: 2.2rem;
  width: auto;
  display: block;
  object-fit: contain;
}

.brand-accent {
  color: var(--green);
}

.theme-toggle {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  border: 2px solid var(--border);
  background: var(--card);
  font-size: 1.25rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.15s ease, border-color 0.2s ease,
    background-color 0.3s ease;
}

.theme-toggle:hover {
  transform: translateY(-2px) rotate(-8deg);
  border-color: var(--accent);
}

.theme-toggle:active {
  transform: translateY(0) scale(0.95);
}

/* ===== Layout ===== */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 24px;
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.hero h1 {
  font-size: 1.9rem;
  font-weight: 900;
  margin: 0 0 0.25rem;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--muted);
  margin: 0 0 1.5rem;
  font-weight: 700;
}

/* ===== Input ===== */
textarea {
  width: 100%;
  padding: 1rem 1.1rem;
  font-size: 1.05rem;
  font-family: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 18px;
  resize: vertical;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea::placeholder {
  color: var(--muted);
}

textarea:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(28, 176, 246, 0.15);
}

/* ===== Botón 3D estilo Duolingo ===== */
.btn-3d {
  margin-top: 1rem;
  width: 100%;
  padding: 0.95rem 1.5rem;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #fff;
  background: var(--green);
  border: none;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--green-shadow);
  transition: transform 0.08s ease, background-color 0.2s ease,
    box-shadow 0.08s ease;
}

.btn-3d:hover {
  background: var(--green-hover);
}

/* Efecto de hundirse al presionar. */
.btn-3d:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 var(--green-shadow);
}

.btn-3d:disabled {
  background: var(--muted);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
  cursor: default;
  transform: none;
  opacity: 0.8;
}

/* ===== Estado ===== */
.status {
  margin-top: 1.1rem;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

/* ===== Resultado ===== */
.result {
  margin-top: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.9rem;
}

.result:empty {
  display: none;
}

/* Animación leve al aparecer el resultado. */
.result.show {
  animation: pop-in 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28) both;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Cada unidad palabra + fonética envuelve naturalmente en frases largas. */
.word-unit {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0.35rem 0.6rem;
  border-radius: 14px;
  background: var(--bg);
  border: 2px solid var(--border);
  transition: transform 0.15s ease, border-color 0.2s ease;
  /* aparición escalonada por palabra */
  animation: word-in 0.3s ease both;
}

.word-unit:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.word-unit .word {
  font-size: 1.1rem;
  font-weight: 800;
}

.word-unit .phonetic {
  margin-top: 0.1rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted); /* gris, legible en claro y oscuro */
}

@keyframes word-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .card {
    padding: 1.35rem;
    border-radius: 20px;
  }

  .hero h1 {
    font-size: 1.6rem;
  }

  .brand {
    font-size: 1.2rem;
  }

  .brand-logo {
    height: 1.9rem;
  }
}

/* ===== Footer ===== */
.footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  text-align: center;
}

.footer-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
  transition: color 0.2s ease, background-color 0.2s ease, transform 0.15s ease;
}

.footer-link:hover {
  color: var(--green);
  background: var(--bg-accent);
  transform: translateY(-2px);
}

.footer-ig-icon {
  flex-shrink: 0;
}
