/* ============================================================
   StickerHub — styles.css
   Light/dark theme via CSS variables. Mobile-first.
   ============================================================ */

/* Las fuentes ya no se cargan con @import: eso encadenaba CSS -> @import ->
   fuente y retrasaba el primer render. Ahora van con preconnect + <link> en el
   <head> de cada plantilla. Si el <link> falla, estas pilas siguen sirviendo. */

/* ---------- Tokens ---------- */
:root {
  --font-display: "Baloo 2", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, sans-serif;

  /* Light theme */
  --bg: #f2f4f8;
  --bg-elevated: #ffffff;
  --bg-soft: #e7eaf1;
  --text: #1c2030;
  --text-muted: #5b6172;
  --border: #d8dce6;
  --accent: #e84e8a;
  --accent-contrast: #ffffff;
  --accent-2: #ffc53d;
  --shadow: 0 2px 10px rgba(28, 32, 48, 0.08);
  --sticker-bg: #eef0f6;
  --radius: 14px;
}

[data-theme="dark"] {
  --bg: #14161f;
  --bg-elevated: #1e2130;
  --bg-soft: #262a3c;
  --text: #eef0f6;
  --text-muted: #9aa1b5;
  --border: #33384c;
  --accent: #f2679c;
  --accent-contrast: #14161f;
  --accent-2: #ffcf57;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  --sticker-bg: #2b3044;
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  transition: background 0.25s ease, color 0.25s ease;
}

h1, h2, h3, .logo { font-family: var(--font-display); line-height: 1.2; }

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

.container {
  width: min(1120px, 100% - 2rem);
  margin-inline: auto;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0;
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.logo-badge {
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: 10px;
  padding: 0.05rem 0.5rem;
  transform: rotate(-4deg);
  display: inline-block;
}

.main-nav {
  display: none;
  gap: 1.1rem;
  margin-left: 1rem;
  font-weight: 600;
}

.main-nav a { color: var(--text-muted); }
.main-nav a:hover,
.main-nav a[aria-current="page"] { color: var(--accent); }

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 1.1rem;
  display: grid;
  place-items: center;
  transition: background 0.15s ease;
}
.icon-btn:hover { background: var(--border); }

/* ---------- Language switcher ----------
   Icon-only when space is tight (mobile); icon + language name when
   there is room (desktop, see media query at the bottom). A transparent
   native <select> overlays the control, so a tap opens the OS picker. */
.lang-wrap { position: relative; }
.lang-display {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 40px;
  min-width: 40px;
  justify-content: center;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  font-size: 1.05rem;
  font-weight: 600;
}
.lang-label { display: none; font-size: 0.85rem; }
.lang-select-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 16px; /* avoids iOS zoom on focus */
}

/* ---------- Header account/theme buttons ----------
   Hidden when space is tight (they live inside the dropdown menu);
   shown as icon + title when there is room (media query below). */
.header-btn {
  display: none;
  align-items: center;
  gap: 0.45rem;
  height: 40px;
  padding: 0 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.header-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Dropdown menu ---------- */
.menu-wrap { position: relative; }

.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  width: min(320px, 88vw);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.75rem;
  display: none;
}
.menu-panel.open { display: block; }

.menu-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0.5rem 0.5rem 0.25rem;
  font-weight: 700;
}

.menu-list { list-style: none; margin: 0; padding: 0; }

.menu-list a,
.menu-item-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.55rem 0.6rem;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  text-align: left;
}
.menu-list a:hover,
.menu-item-btn:hover { background: var(--bg-soft); }

.menu-sep { border: none; border-top: 1px solid var(--border); margin: 0.5rem 0; }

/* ---------- Hero ---------- */
.hero {
  padding: 2.2rem 0 1rem;
  text-align: center;
}
.hero h1 {
  font-size: clamp(1.7rem, 5vw, 2.6rem);
  margin: 0 0 0.4rem;
}
.hero h1 em {
  font-style: normal;
  color: var(--accent);
  display: inline-block;
  transform: rotate(-2deg);
}
.hero p { color: var(--text-muted); margin: 0 auto; max-width: 46ch; }

/* ---------- Sections ---------- */
.section { padding: 1.6rem 0; }

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.section-header h2 { margin: 0; font-size: 1.4rem; }
.section-header a { color: var(--accent); font-weight: 600; font-size: 0.9rem; }

/* ---------- Pack cards ---------- */
.pack-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.pack-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}
.pack-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 18px rgba(28, 32, 48, 0.14);
}

.rank-badge {
  position: absolute;
  top: -10px;
  left: -8px;
  background: var(--accent-2);
  color: #3a2c00;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.95rem;
  border-radius: 10px;
  padding: 0.1rem 0.6rem;
  transform: rotate(-6deg);
  box-shadow: var(--shadow);
  z-index: 1;
}

/* Reduced sticker preview (5 per card) */
.sticker-preview {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.sticker-thumb {
  width: 52px;
  height: 52px;
  background: var(--sticker-bg);
  border-radius: 14px;
  display: grid;
  place-items: center;
  padding: 3px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.sticker-thumb img { width: 100%; height: 100%; object-fit: contain; }
.sticker-thumb:nth-child(odd)  { transform: rotate(-4deg); }
.sticker-thumb:nth-child(even) { transform: rotate(3deg); }

.sticker-thumb--more {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.pack-card h3 { margin: 0 0 0.15rem; font-size: 1.1rem; }
.pack-card h3 a:hover { color: var(--accent); }

/* Stretched link: the ::after of the title anchor covers the whole
   card, making the full card clickable with semantic markup. */
.card-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.pack-author {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 0;
}
.pack-author strong { color: var(--text); font-weight: 600; }

.pack-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---------- Category chips ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  padding: 1rem 0 0.4rem;
}
.chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Pack page ---------- */
.pack-header {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
  margin-top: 1.4rem;
}
.pack-header h1 { margin: 0 0 0.2rem; font-size: clamp(1.5rem, 4vw, 2.1rem); }

.pack-details {
  margin-top: 0.9rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.7rem; }
.tag {
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  border-radius: 12px;
  padding: 0.65rem 1.3rem;
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-display);
  margin-top: 1rem;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn-primary:hover { transform: scale(1.03); filter: brightness(1.05); }

/* Full grid of ~30 stickers */
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.7rem;
  margin-top: 1.4rem;
}
.sticker-item {
  aspect-ratio: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 18px;
  display: grid;
  place-items: center;
  padding: 6px;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
}
.sticker-item img { width: 100%; height: 100%; object-fit: contain; }
.sticker-item:hover { transform: rotate(-5deg) scale(1.08); }

/* ---------- Pagination (static links) ---------- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  padding: 1.6rem 0;
  flex-wrap: wrap;
}
.page-btn {
  display: inline-grid;
  place-items: center;
  min-width: 40px;
  height: 40px;
  padding: 0 0.6rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-weight: 600;
}
a.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn[aria-current="page"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.page-btn.is-disabled { opacity: 0.4; }

/* ---------- Blog ---------- */
.article-list { display: grid; gap: 1rem; margin-top: 1.2rem; }

.article-card {
  position: relative; /* required by .card-link */
  display: flex;
  gap: 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
}
.article-card:hover { transform: translateY(-3px); }

.article-icon {
  flex-shrink: 0;
  width: 58px;
  height: 58px;
  background: var(--bg-soft);
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 1.7rem;
  transform: rotate(-3deg);
}
.article-card h3 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.article-card p { margin: 0; color: var(--text-muted); font-size: 0.92rem; }
.article-meta { margin-top: 0.45rem !important; font-size: 0.8rem !important; }

/* ---------- Single article ---------- */
.article-page {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.6rem;
  margin-top: 1.4rem;
  max-width: 760px;
  margin-inline: auto;
}
.article-page h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  margin: 0.4rem 0 0.3rem;
}
.article-page .article-icon {
  width: 68px;
  height: 68px;
  font-size: 2rem;
}
.article-byline {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 1rem;
}
.article-body p {
  margin: 0 0 1rem;
  font-size: 1.02rem;
}
.article-back {
  display: inline-block;
  margin-top: 0.6rem;
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Account / Settings ---------- */
.account-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem;
  margin-top: 1.4rem;
  max-width: 620px;
  margin-inline: auto;
}

.avatar-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.2rem;
}
.avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent-2);
  display: grid;
  place-items: center;
  font-size: 2rem;
}

.field { margin-bottom: 1rem; }
.field label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--border);
}
.setting-row .setting-desc { font-size: 0.85rem; color: var(--text-muted); margin: 0.1rem 0 0; }

/* Toggle switch */
.switch { position: relative; width: 48px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute;
  inset: 0;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background 0.2s ease;
}
.switch .track::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: var(--bg-elevated);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 0.2s ease;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::before { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 3px solid var(--accent-2); }

/* ---------- Breadcrumbs / states ---------- */
.breadcrumbs {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding-top: 1.2rem;
}
.breadcrumbs a:hover { color: var(--accent); }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
}

.save-notice { color: var(--accent); font-weight: 600; }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 2.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 1.6rem 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
}
.site-footer nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.site-footer a:hover { color: var(--accent); }

/* ---------- Platform icons (card preview: icon only, in meta row) ---------- */
.platform-icons {
  display: inline-flex;
  gap: 0.3rem;
  margin-inline-start: auto; /* pushed to the end of the meta row */
}
.app-icon {
  width: 20px;
  height: 20px;
  border-radius: 6px;
}

/* ---------- Platform & installer badges (pack page, full view) ---------- */
.app-block { margin-top: 1rem; }
.app-block-label {
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.app-badges { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.app-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.7rem 0.25rem 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
}
.app-badge img { border-radius: 6px; }

/* ---------- Download buttons (one per installer app) ---------- */
.pack-header-side { flex-shrink: 0; }
.download-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 200px;
}
.btn-download {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: 12px;
  padding: 0.6rem 1rem;
  font-weight: 700;
  font-family: var(--font-display);
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn-download:hover { transform: translateY(-2px); filter: brightness(1.05); }
.btn-download img { border-radius: 6px; background: rgba(255,255,255,0.9); padding: 2px; }

/* ---------- RTL support (e.g. Arabic) ---------- */
[dir="rtl"] .rank-badge { left: auto; right: -8px; transform: rotate(6deg); }
[dir="rtl"] .sticker-thumb:nth-child(odd)  { transform: rotate(4deg); }
[dir="rtl"] .sticker-thumb:nth-child(even) { transform: rotate(-3deg); }
[dir="rtl"] .breadcrumbs,
[dir="rtl"] .pack-meta,
[dir="rtl"] .article-byline { direction: rtl; }
[dir="rtl"] .app-badge { padding: 0.25rem 0.35rem 0.25rem 0.7rem; }

/* ---------- Desktop ---------- */
@media (min-width: 640px) {
  .pack-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 900px) {
  .main-nav { display: flex; }
  .pack-grid { grid-template-columns: repeat(3, 1fr); }
  .pack-header { display: flex; justify-content: space-between; gap: 2rem; align-items: flex-start; }
  .sticker-thumb { width: 56px; height: 56px; }

  /* Enough space in the top bar: show icon + title/name... */
  .header-btn { display: inline-flex; }
  .lang-display { padding: 0 0.8rem; }
  .lang-label { display: inline; }
  /* ...and remove the account/theme duplicates from the dropdown menu. */
  .menu-mobile-only { display: none; }
}


/* ============================================================
   Bloques de instalación
   Los botones del pack enlazaban a #install-sticker-maker,
   #install-stickerly y #install-stickerscloud, pero esos destinos
   no existían en la página. Estos son los estilos de las secciones.
   ============================================================ */
.install-section {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  scroll-margin-top: 5rem;   /* el header es sticky: evita que lo tape */
}

.install-section-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.install-section-head img { width: 28px; height: 28px; }

.install-section-head h2 {
  font-size: 1.15rem;
  margin: 0;
}

.install-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: install-step;
  display: grid;
  gap: 0.7rem;
}

.install-steps li {
  position: relative;
  padding-inline-start: 2.1rem;
  color: var(--text-muted);
}

.install-steps li::before {
  counter-increment: install-step;
  content: counter(install-step);
  position: absolute;
  inset-inline-start: 0;
  top: 0.15rem;
  width: 1.5rem;
  height: 1.5rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.8rem;
  font-weight: 700;
}

.install-steps strong { color: var(--text); }

.install-code {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.75rem;
  padding: 0.45rem 0.8rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-weight: 700;
  letter-spacing: 0.08em;
}

/* ============================================================
   Menú desplegable: el panel no debe ser alcanzable con Tab
   mientras está cerrado. `visibility` lo saca del orden de foco
   sin perder la transición.
   ============================================================ */
.menu-panel:not(.open) {
  visibility: hidden;
}

/* Huecos de publicidad inyectados por el Worker */
.ad-slot { margin: 1rem auto; text-align: center; }
.ad-slot:empty { display: none; }
