@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&family=DM+Sans:wght@300;400;500&display=swap');

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&family=DM+Sans:wght@300;400;500&display=swap');

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

:root {
  --cream: #FFFCF8;
  --white: #FFFFFF;
  --ink: #2C1A0E;
  --ink-muted: #7A6558;
  --ink-faint: #C8BAB0;
  --accent: #078930;
  --accent-light: #E9F6ED;
  --border: #EDE8E3;
  --radius: 16px;
  --radius-sm: 10px;

  /* Colors de la bandera del poble */
  --flag-green: #078930;
  --flag-red: #ED1C24;
  --flag-yellow: #E9C102;
}

/* ── DARK MODE ── */
html.dark {
  --cream: #131210;
  --white: #1E1C1A;
  --ink: #EDE5DC;
  --ink-muted: #9A8E84;
  --ink-faint: #3D3730;
  --accent: #22A94C;
  --accent-light: #12261A;
  --border: #2A2520;
}

html.dark .word-card.featured {
  border-color: #3A4A60;
  background: #3A4A60;
}

html.dark nav {
  background: rgba(19, 18, 16, 0.88);
}

html.dark .autocomplete-list {
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── NAV ── */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 252, 248, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

nav::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(
    to right,
    var(--flag-green) 0%,
    var(--flag-green) 33.33%,
    var(--flag-yellow) 33.33%,
    var(--flag-yellow) 66.66%,
    var(--flag-red) 66.66%,
    var(--flag-red) 100%
  );
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.nav-logo {
  width: 34px;
  height: 34px;
  background: var(--ink);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
}

.nav-logo svg { width: 18px; height: 18px; fill: var(--white); }

.nav-wordmark {
  font-family: 'Cormorant Garamond', serif;
  font-size: 21px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0em;
}

.nav-wordmark span { color: var(--accent); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-links a {
  text-decoration: none;
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-muted);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  letter-spacing: 0.01em;
}

.nav-links a:hover { color: var(--accent); background: var(--accent-light); }
.nav-links a.active { color: var(--ink); font-weight: 500; }

.nav-cta {
  background: var(--ink) !important;
  color: var(--white) !important;
  border-radius: var(--radius-sm) !important;
  padding: 7px 16px !important;
  font-weight: 500 !important;
  transition: opacity 0.15s !important;
}

.nav-cta:hover { opacity: 0.85; background: var(--ink) !important; }

/* ── HERO ── */
.hero {
  padding: 7rem 2rem 5rem;
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-light);
  padding: 5px 14px;
  border-radius: 99px;
  margin-bottom: 2rem;
}

.hero-tag::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
}

.hero-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(32px, 7vw, 76px);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: 0em;
  color: var(--ink);
  margin-bottom: 1.25rem;
}

.hero-title em {
  font-style: italic;
  color: var(--accent);
}

.hero-subtitle {
  font-size: clamp(14px, 4vw, 16px);
  font-weight: 300;
  color: var(--ink-muted);
  max-width: 480px;
  margin: 0 auto 2.5rem;
  line-height: 1.75;
  letter-spacing: 0.01em;
}

/* ── SEARCH ── */
.search-container {
  max-width: 620px;
  margin: 0 auto;
}

.search-wrap {
  position: relative;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 99px;
  display: flex;
  align-items: center;
  padding: 7px 7px 7px 22px;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 12px rgba(7, 137, 48, 0.08);
}

.search-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(7, 137, 48, 0.12);
}

.search-wrap input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  color: var(--ink);
  min-width: 0;
}

.search-wrap input::placeholder { color: var(--ink-faint); }

.search-btn {
  background: var(--accent);
  color: var(--white);
  border: none;
  border-radius: 99px;
  padding: 11px 24px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  letter-spacing: 0.02em;
}

.search-btn:hover { opacity: 0.8; }

.lang-tabs {
  display: flex;
  justify-content: center;
  gap: 3rem; /* Separa los botones hacia los extremos */
  margin-top: 1.25rem;
  flex-wrap: wrap; /* Permite que se adapten bien en móviles */
}

.lang-tab {
  border: 1.5px solid transparent; /* Borde invisible para mantener la estructura */
  background: transparent; /* Toma el mismo color crema del fondo */
  border-radius: 99px;
  padding: 5px 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px; /* Ligeramente más grande para compensar la falta de caja */
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.lang-tab:hover { 
  color: var(--ink); 
}

.lang-tab.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--white);
}

/* ── AUTOCOMPLETADO ── */
.autocomplete-list {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background-color: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  z-index: 9999;
  max-height: 250px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(26,26,24,0.10);
  display: none;
  text-align: left;
}

.autocomplete-item {
  padding: 14px 20px;
  cursor: pointer;
  font-size: 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover {
  background-color: var(--accent-light);
  color: var(--accent);
}

/* ── STATS RIBBON ── */
.stats-ribbon {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--white);
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: center;
  gap: 0;
  margin-top: 5rem;
  overflow: hidden;
}

.stat-item {
  flex: 1;
  max-width: 200px;
  text-align: center;
  padding: 0 2rem;
  border-right: 1px solid var(--border);
}

.stat-item:last-child { border-right: none; }

.stat-num {
  font-family: 'Cormorant Garamond', serif;
  font-size: 36px;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 4px;
  letter-spacing: 0.02em;
}

/* ── MAIN LAYOUT ── */
.main-layout {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
  display: none;
  animation: fadeIn 0.6s ease forwards;
  position: relative;
  z-index: 1;
}

/* ── SECTION HEADER ── */
.section-eyebrow {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 1.5rem;
  font-family: 'DM Sans', sans-serif;
}

/* ── WORD CARDS ── */
.word-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 800px;
  margin: 0 auto;
}

.word-card {
  width: 100%;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.word-card:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 28px rgba(212,84,26,0.08);
  transform: translateY(-2px);
}

.word-card.featured {
  border-color: #2E3A4E;
  background: #2E3A4E;
}

.word-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.word-primary {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.word-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 30px;
  font-weight: 500;
  letter-spacing: 0em;
  color: var(--ink);
}

.word-card.featured .word-name { color: #FDF0E8; }

.word-pos {
  font-size: 12px;
  color: var(--ink-faint);
  font-style: italic;
}

.word-card.featured .word-pos { color: rgba(255,255,255,0.4); }

.word-audio {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--ink-muted);
  flex-shrink: 0;
}

.word-audio:hover { border-color: var(--ink); color: var(--ink); }
.word-card.featured .word-audio { border-color: rgba(255,255,255,0.2); color: rgba(255,255,255,0.6); }

.word-translations {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.word-card.featured .word-translations {
  border-color: rgba(255,255,255,0.1);
}

.trans-lang {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin-bottom: 3px;
}

.word-card.featured .trans-lang { color: rgba(255,255,255,0.3); }

.trans-word {
  font-size: 15px;
  font-weight: 400;
  color: var(--ink);
}

.word-card.featured .trans-word { color: var(--white); }

.word-example {
  margin-top: 0.9rem;
  font-size: 13.5px;
  color: var(--ink-muted);
  font-style: italic;
  line-height: 1.55;
  padding-left: 14px;
  border-left: 2px solid var(--border);
}

.word-card.featured .word-example {
  color: rgba(255,255,255,0.5);
  border-left-color: rgba(255,255,255,0.25);
}

.word-badges {
  display: flex;
  gap: 6px;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid;
}

.badge-aragon { color: #8B3A1A; border-color: #EDCCC3; background: #FBF0EC; }
.badge-gastro { color: #1F5C2A; border-color: #B8DCBC; background: #EDF7EE; }
.badge-trad   { color: #4A3A88; border-color: #C9C3E8; background: #F2F0FC; }

.word-card.featured .badge {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.6);
}

/* ── SIDEBAR ── */
.sidebar { display: flex; flex-direction: column; gap: 20px; }

.sidebar-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.sidebar-card-header {
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-card-title {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.sidebar-card-body { padding: 1.25rem; }

/* word of day */
.wod-inner { text-align: center; }

.wod-word {
  font-family: 'Cormorant Garamond', serif;
  font-size: 38px;
  font-weight: 400;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 4px;
}

.wod-cast { font-size: 15px; color: var(--ink-muted); margin-bottom: 10px; }

.wod-desc {
  font-size: 13px;
  color: var(--ink-muted);
  line-height: 1.6;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 12px;
}

.wod-share {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

.wod-share button {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  color: var(--ink-muted);
  background: var(--cream);
  border: 1.5px solid var(--border);
  border-radius: 99px;
  padding: 5px 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.wod-share button:hover { border-color: var(--ink-faint); color: var(--ink); }

/* news */
.news-list { display: flex; flex-direction: column; }

.news-item {
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.news-item:last-child { border-bottom: none; }
.news-item:hover { background: var(--cream); }

.news-category {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 3px;
}

.news-title {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.45;
  margin-bottom: 3px;
}

.news-date { font-size: 11px; color: var(--ink-faint); }

/* contribute */
.contribute-card {
  background: var(--accent);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}

.contribute-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 20px;
  color: var(--white);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.contribute-desc {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 1.25rem;
  line-height: 1.6;
}

.contribute-btn {
  background: var(--white);
  color: var(--ink);
  border: none;
  border-radius: 99px;
  padding: 10px 22px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
  width: 100%;
}

.contribute-btn:hover { opacity: 0.85; }

/* ── CATEGORIES ── */
.categories-section {
  background: var(--white);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 4rem 2rem;
}

.categories-inner { max-width: 1100px; margin: 0 auto; }

.categories-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.section-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.see-all {
  font-size: 13px;
  color: var(--ink-muted);
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
  transition: color 0.15s;
}

.see-all:hover { color: var(--ink); }

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.category-card {
  background: var(--cream);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.category-card:hover {
  border-color: var(--ink);
  background: var(--ink);
}

.category-card:hover .cat-emoji { filter: grayscale(0); }
.category-card:hover .cat-name { color: var(--white); }
.category-card:hover .cat-count { color: rgba(255,255,255,0.4); }

.cat-emoji { font-size: 24px; margin-bottom: 10px; display: block; }
.cat-name { font-size: 14px; font-weight: 500; color: var(--ink); margin-bottom: 4px; }
.cat-count { font-size: 12px; color: var(--ink-faint); }

/* ── FOOTER ── */
footer {
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: 1.5rem 2rem;
  margin-top: auto;
  flex-shrink: 0;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-brand {
  font-family: 'Cormorant Garamond', serif;
  font-size: 19px;
  font-weight: 500;
  color: var(--ink);
}

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

.footer-copy { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }

.footer-links {
  display: flex;
  gap: 20px;
}

.footer-links a {
  font-size: 13px;
  color: var(--ink-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.footer-links a:hover { color: var(--ink); }

/* ── RESPONSIVE ── */

/* Tablet y móvil grande */
@media (max-width: 768px) {
  .word-list { width: 100%; }
  nav { padding: 0 1rem; }
  .nav-links { display: none; }
  .compact-search { padding: 2rem 1rem; }
  .word-card { padding: 1.25rem; }
  .word-translations { grid-template-columns: repeat(2, 1fr); }
  .footer-inner { flex-direction: column; gap: 1rem; text-align: center; }
  .footer-links { justify-content: center; }
}

/* Móvil */
@media (max-width: 480px) {
  .word-list { width: 100%; }
  nav { height: 52px; padding: 0 1rem; }
  .nav-wordmark { font-size: 16px; }

  .compact-search {
    height: 80vh;
    padding: 1.5rem 1rem;
  }

  body.is-searching .compact-search {
    height: auto;
    padding: 1.25rem 1rem 0.75rem;
  }

  .main-layout { padding: 1.5rem 1rem 3rem; }

  .word-card { padding: 1rem 1.1rem; border-radius: 12px; }
  .word-name { font-size: 22px; }
  .word-pos { font-size: 11px; }
  .word-translations {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    padding: 0.75rem 0;
  }
  .trans-word { font-size: 14px; }
  .word-example { font-size: 13px; padding-left: 10px; }

  .search-wrap { padding: 5px 5px 5px 16px; }
  .search-wrap input { font-size: 16px; /* prevents iOS zoom on focus */ }
  .search-btn { padding: 10px 16px; font-size: 13px; }

  .autocomplete-list { border-radius: 10px; }
  .autocomplete-item { padding: 15px 16px; font-size: 16px; }

  .section-eyebrow { font-size: 10px; margin-bottom: 1rem; }

  footer { padding: 1.25rem 1rem; }
  .footer-inner { gap: 0.75rem; }
  .footer-brand { font-size: 15px; }
  .footer-copy { font-size: 11px; }
  .footer-links { gap: 16px; }
  .footer-links a { font-size: 12px; }
}

/* Móvil muy pequeño (SE, Galaxy A series) */
@media (max-width: 360px) {
  .search-btn { padding: 10px 12px; }
  .word-translations { grid-template-columns: 1fr; }
}

/* ── ANIMATIONS ── */
@media (prefers-reduced-motion: no-preference) {
  .word-card { animation: fadeUp 0.4s ease both; }
  .word-card:nth-child(2) { animation-delay: 0.07s; }
  .word-card:nth-child(3) { animation-delay: 0.14s; }
  .hero-title { animation: fadeUp 0.5s ease both; }
  .hero-subtitle { animation: fadeUp 0.5s 0.08s ease both; }
  .search-container { animation: fadeUp 0.5s 0.15s ease both; }

  @keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}

/* Estado inicial del buscador */
.compact-search {
  height: 75vh; 
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem 1rem;
  text-align: center;
  transition: height 0.5s cubic-bezier(0.25, 1, 0.5, 1);
  overflow: visible;
  position: relative;
  z-index: 10;
}

/* Mostrar resultados tras la búsqueda */
body.is-searching .main-layout {
  display: block;
  flex-grow: 1;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mostrar resultados tras la búsqueda - altura ajustada */
body.is-searching .compact-search {
  height: auto;
  min-height: auto;
  padding: 1.5rem 1rem 1rem;
}