/* ==========================================================================
   TX4Tech — /templates gallery (extends styles.css)
   ========================================================================== */

/* Bilingual text: default EN; <html lang="es"> flips. */
body [lang="es"] { display: none; }
html[lang="es"] body [lang="es"] { display: revert; }
html[lang="es"] body [lang="en"] { display: none; }
html[lang="es"] body span[lang="es"] { display: inline; }

.lang-switch { display: inline-flex; border: 1px solid rgba(255,255,255,.3); border-radius: 999px; overflow: hidden; }
.lang-switch button { background: transparent; border: 0; color: rgba(255,255,255,.8); padding: 6px 11px; cursor: pointer; font: 600 .8rem var(--font-display); }
.lang-switch button[aria-pressed="true"] { background: #fff; color: var(--ink); }
.nav-links .lang-item { display: flex; align-items: center; }
@media (max-width: 860px) { .nav-links .lang-item { padding: 12px 0; } }

.on-dark-ghost { color: #fff; border-color: rgba(255,255,255,.35); }
.on-dark-ghost:hover { color: #fff; border-color: #fff; }

/* Hero */
.gal-hero { background: var(--ink); color: #fff; padding: clamp(56px, 8vw, 104px) 0 clamp(40px, 6vw, 72px); position: relative; overflow: hidden; }
.gal-hero::before {
  content: ""; position: absolute; inset: -20% -10% auto auto; width: 60%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(36,70,245,.55), rgba(36,70,245,0)); pointer-events: none;
}
.gal-hero .container { position: relative; }
.gal-kicker { color: var(--mint); font-family: var(--font-display); font-weight: 600; margin: 0 0 16px; font-size: .98rem; }
.gal-hero h1 { color: #fff; max-width: 18ch; }
.gal-lead { color: rgba(255,255,255,.8); font-size: var(--step-1); max-width: 62ch; margin: 0 0 28px; }
.gal-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.gal-facts { list-style: none; margin: 40px 0 0; padding: 28px 0 0; border-top: 1px solid var(--line-dark); display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px 32px; color: rgba(255,255,255,.72); font-size: .95rem; }
.gal-facts strong { display: block; color: #fff; font-family: var(--font-display); font-size: 1.2rem; margin-bottom: 4px; }
@media (max-width: 760px) { .gal-facts { grid-template-columns: 1fr; gap: 14px; } }

/* Toolbar */
.gal-grid-section { padding-top: clamp(32px, 5vw, 56px); }
.gal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 28px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font: 600 .9rem var(--font-display); color: var(--ink); background: var(--paper-2); border: 1px solid var(--line);
  padding: 9px 14px; border-radius: 999px; cursor: pointer; transition: background-color .15s, color .15s, border-color .15s;
}
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.gal-count { margin: 0; color: var(--muted); font-size: .95rem; }

/* Grid of templates */
.tpl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px 24px; }
.tpl { display: flex; flex-direction: column; }
.tpl.is-hidden { display: none; }
.tpl-frame {
  position: relative; border-radius: 14px; overflow: hidden; background: #fff; border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(14,27,58,.06), 0 24px 40px -32px rgba(14,27,58,.35);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.tpl-frame:hover, .tpl-frame:focus-within { transform: translateY(-3px); box-shadow: 0 1px 2px rgba(14,27,58,.06), 0 32px 48px -28px rgba(14,27,58,.45); }
.tpl-chrome { height: 30px; background: #eef0f4; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 6px; padding: 0 12px; }
.tpl-chrome span { width: 9px; height: 9px; border-radius: 50%; background: #d3d7df; }
.tpl-chrome i { margin-left: 10px; font-style: normal; font-size: .72rem; color: var(--muted); background: #fff; border-radius: 6px; padding: 3px 10px; flex: 1; text-align: center; font-family: var(--font-text); }
.tpl-view { position: relative; aspect-ratio: 16 / 11; overflow: hidden; background: var(--sand); }
.tpl-poster { position: absolute; inset: 0; background-size: cover; background-position: center; filter: saturate(.9); transition: opacity .4s ease; }
.tpl-view iframe {
  position: absolute; top: 0; left: 0; width: 1280px; height: 880px; border: 0; transform-origin: 0 0;
  pointer-events: none; opacity: 0; transition: opacity .5s ease; background: #fff;
}
.tpl-view.is-live iframe { opacity: 1; }
.tpl-view.is-live .tpl-poster { opacity: 0; }
.tpl-actions {
  position: absolute; inset: 30px 0 0; display: flex; align-items: center; justify-content: center; gap: 10px;
  background: rgba(14,27,58,.55); opacity: 0; transition: opacity .2s ease;
}
.tpl-frame:hover .tpl-actions, .tpl-frame:focus-within .tpl-actions { opacity: 1; }
@media (hover: none) { .tpl-actions { position: static; opacity: 1; background: none; padding: 12px; border-top: 1px solid var(--line); justify-content: stretch; } .tpl-actions .btn { flex: 1; } }
.btn-light { background: #fff; color: var(--ink); }
.btn-light:hover { background: #f1f1f1; color: var(--ink); }
.btn-sm { padding: 10px 16px; font-size: .9rem; }
.tpl-body { padding: 16px 4px 0; }
.tpl-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.tpl-title h3 { font-size: 1.12rem; margin: 0; }
.tpl-title span { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.tpl-body p { color: var(--muted); font-size: .95rem; margin: 6px 0 10px; max-width: none; }
.tpl-tags { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; flex-wrap: wrap; }
.tpl-tags li { font-size: .78rem; font-weight: 500; color: var(--ink-3); background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; }
@media (max-width: 1000px) { .tpl-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 620px) { .tpl-grid { grid-template-columns: 1fr; } }

.gal-note { margin: 40px auto 0; max-width: 72ch; color: var(--muted); text-align: center; font-size: .98rem; }
.gal-note a { font-weight: 600; }

/* How it works */
.gal-how { background: var(--paper-2); border-top: 1px solid var(--line); }
.gal-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; counter-reset: s; }
.gal-steps li { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; background: var(--paper); color: var(--muted); font-size: .97rem; }
.gal-steps li::before { counter-increment: s; content: counter(s); display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--cobalt); color: #fff; font: 700 .95rem var(--font-display); margin-bottom: 14px; }
.gal-steps strong { display: block; color: var(--ink); font-family: var(--font-display); font-weight: 600; margin-bottom: 6px; }
@media (max-width: 900px) { .gal-steps { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .gal-steps { grid-template-columns: 1fr; } }

/* CTA */
.gal-cta { background: var(--ink); color: #fff; padding: clamp(48px, 7vw, 88px) 0; }
.gal-cta .container { display: grid; grid-template-columns: minmax(0, 1.4fr) auto; gap: 24px; align-items: center; }
.gal-cta h2 { color: #fff; margin-bottom: 8px; }
.gal-cta p { color: rgba(255,255,255,.75); margin: 0; }
@media (max-width: 760px) { .gal-cta .container { grid-template-columns: 1fr; } }

/* Modal */
.tpl-modal { position: fixed; inset: 0; z-index: 90; background: #0b1430; display: flex; flex-direction: column; }
.tpl-modal[hidden] { display: none; }
.tpl-modal-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px var(--gutter); background: var(--ink); color: #fff; border-bottom: 1px solid var(--line-dark); flex-wrap: wrap; }
.tpl-modal-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.tpl-modal-title h2 { color: #fff; font-size: 1.1rem; margin: 0; }
.tpl-modal-industry { color: rgba(255,255,255,.65); font-size: .9rem; }
.tpl-devices { display: inline-flex; gap: 4px; background: rgba(255,255,255,.08); border-radius: 10px; padding: 4px; }
.tpl-devices button { background: transparent; border: 0; color: rgba(255,255,255,.7); width: 38px; height: 34px; border-radius: 7px; cursor: pointer; display: grid; place-items: center; }
.tpl-devices button svg { width: 20px; height: 20px; }
.tpl-devices button[aria-pressed="true"] { background: #fff; color: var(--ink); }
.tpl-modal-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tpl-modal-close { background: transparent; border: 0; color: rgba(255,255,255,.7); cursor: pointer; padding: 8px; display: grid; place-items: center; border-radius: 8px; }
.tpl-modal-close:hover { color: #fff; background: rgba(255,255,255,.1); }
.tpl-modal-close svg { width: 20px; height: 20px; }
.tpl-modal-stage { flex: 1; min-height: 0; display: flex; justify-content: center; align-items: stretch; padding: 16px; overflow: auto; }
.tpl-device { background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 40px 80px -40px rgba(0,0,0,.8); transition: width .3s var(--ease), border-radius .3s var(--ease); width: 100%; max-width: 1600px; height: 100%; }
.tpl-device iframe { width: 100%; height: 100%; border: 0; display: block; }
.tpl-device.tablet { width: 820px; border-radius: 22px; border: 10px solid #1d2a4d; }
.tpl-device.mobile { width: 400px; border-radius: 32px; border: 12px solid #1d2a4d; }
@media (max-width: 760px) {
  .tpl-devices { display: none; }
  .tpl-modal-stage { padding: 0; }
  .tpl-device, .tpl-device.tablet, .tpl-device.mobile { width: 100%; border: 0; border-radius: 0; }
}
body.modal-open { overflow: hidden; }
.tpl-kind { font-size: .8rem; color: var(--mint-ink); font-weight: 600; margin-top: 2px; }
