/* =====================================================
 * Estafeta Play · styles.css
 * Design system premium (vinho). Variáveis de marca
 * sobreponíveis por evento (applyBrand no core.js).
 * Prioridade: iPad Air 11" Safari · quiosque · a11y.
 * ===================================================== */

:root {
  --ep-bg: #070405;
  --ep-primary: #72243E;
  --ep-accent: #BA7517;
  --ep-cream: #F4EFE6;

  --ep-bg-2: #100a0c;
  --ep-line: rgba(244, 239, 230, 0.12);
  --ep-line-strong: rgba(244, 239, 230, 0.22);
  --ep-muted: rgba(244, 239, 230, 0.62);
  --ep-ok: #3f9d6b;
  --ep-no: #b8434f;

  --ep-radius: 18px;
  --ep-radius-lg: 26px;
  --ep-tap: 56px;             /* alvo de toque mínimo confortável */
  --ep-maxw: 900px;

  --ep-font-display: "Cormorant Garamond", Georgia, serif;
  --ep-font-body: "Jost", system-ui, -apple-system, "Segoe UI", sans-serif;

  --ep-safe-t: env(safe-area-inset-top, 0px);
  --ep-safe-b: env(safe-area-inset-bottom, 0px);
  --ep-safe-l: env(safe-area-inset-left, 0px);
  --ep-safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--ep-bg);
  color: var(--ep-cream);
  font-family: var(--ep-font-body);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(114, 36, 62, 0.28), transparent 60%),
    radial-gradient(80% 60% at 100% 110%, rgba(186, 117, 23, 0.14), transparent 55%),
    var(--ep-bg);
  min-height: 100dvh;
}

.ep-app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    calc(var(--ep-safe-t) + 8px)
    calc(var(--ep-safe-r) + 16px)
    calc(var(--ep-safe-b) + 16px)
    calc(var(--ep-safe-l) + 16px);
}

/* ---------- HEADER ---------- */
.ep-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 4px 14px;
  min-height: 52px;
}
.ep-brand { display: flex; align-items: center; gap: 10px; }
.ep-brand-mark { width: 26px; height: 30px; display: inline-flex; }
.ep-brand-mark svg { width: 100%; height: 100%; }
.ep-brand-name {
  font-family: var(--ep-font-display);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
  color: var(--ep-cream);
}
.ep-header-actions { display: flex; align-items: center; gap: 8px; }

.ep-langswitch { display: flex; gap: 4px; background: rgba(255,255,255,0.05); border-radius: 999px; padding: 4px; }
.ep-lang-btn {
  min-width: 40px; min-height: 40px;
  border: 0; border-radius: 999px;
  background: transparent; color: var(--ep-muted);
  font-family: var(--ep-font-body); font-weight: 600; font-size: 0.85rem;
  cursor: pointer;
}
.ep-lang-btn.on { background: var(--ep-accent); color: #1a1206; }

.ep-icon-btn {
  width: var(--ep-tap); height: var(--ep-tap);
  min-width: var(--ep-tap); min-height: var(--ep-tap);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--ep-line); border-radius: 999px;
  background: rgba(255,255,255,0.03); color: var(--ep-cream);
  cursor: pointer;
}
.ep-icon-btn svg { width: 24px; height: 24px; }
.ep-icon-btn[aria-pressed="false"] { color: var(--ep-muted); }

/* ---------- ECRÃ / LAYOUT ---------- */
.ep-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  width: 100%;
  max-width: var(--ep-maxw);
  margin: 0 auto;
  text-align: center;
  padding: 8px 0 24px;
}

.ep-hero { display: flex; flex-direction: column; gap: 8px; }
.ep-eyebrow {
  margin: 0; text-transform: uppercase; letter-spacing: 0.18em;
  font-size: 0.72rem; font-weight: 600; color: var(--ep-accent);
}
.ep-title {
  margin: 0;
  font-family: var(--ep-font-display);
  font-weight: 600;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.05;
  color: var(--ep-cream);
}
.ep-sub { margin: 0; color: var(--ep-muted); font-size: 1.02rem; max-width: 34ch; }

/* ---------- BOTÕES ---------- */
.ep-btn {
  min-height: var(--ep-tap);
  padding: 0 26px;
  border-radius: 999px;
  border: 1px solid var(--ep-line-strong);
  background: rgba(255,255,255,0.04);
  color: var(--ep-cream);
  font-family: var(--ep-font-body);
  font-weight: 600;
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease;
}
.ep-btn:active { transform: scale(0.97); }
.ep-btn-primary {
  background: linear-gradient(180deg, var(--ep-accent), #96600f);
  border-color: transparent; color: #1a1206;
}
.ep-btn-ghost { background: transparent; color: var(--ep-muted); }

/* ---------- IDIOMA ---------- */
.ep-lang-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  width: min(560px, 100%);
}
.ep-lang-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-height: 96px;
  border: 1px solid var(--ep-line);
  border-radius: var(--ep-radius);
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01));
  color: var(--ep-cream);
  cursor: pointer;
  padding: 18px;
}
.ep-lang-card:active { transform: scale(0.98); }
.ep-lang-code { font-family: var(--ep-font-display); font-size: 1.7rem; font-weight: 700; color: var(--ep-accent); }
.ep-lang-name { color: var(--ep-muted); font-size: 0.95rem; }

/* ---------- NOME ---------- */
.ep-form { display: flex; flex-direction: column; gap: 16px; width: min(460px, 100%); }
.ep-input {
  width: 100%;
  min-height: var(--ep-tap);
  padding: 0 20px;
  border-radius: var(--ep-radius);
  border: 1px solid var(--ep-line-strong);
  background: rgba(0,0,0,0.25);
  color: var(--ep-cream);
  font-family: var(--ep-font-body);
  font-size: 1.15rem;
  text-align: center;
}
.ep-input::placeholder { color: rgba(244,239,230,0.4); }
.ep-form-actions { display: flex; flex-direction: column; gap: 10px; }

/* ---------- MENU / CARTÕES ---------- */
.ep-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  width: 100%;
}
.ep-card {
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
  padding: 20px;
  border: 1px solid var(--ep-line);
  border-radius: var(--ep-radius-lg);
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.015));
  color: var(--ep-cream);
  cursor: pointer;
  position: relative;
  min-height: 128px;
}
.ep-card:active { transform: scale(0.99); }
.ep-card-icon {
  flex: 0 0 auto; width: 60px; height: 60px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 16px; background: rgba(186,117,23,0.14); color: var(--ep-accent);
}
.ep-card-icon svg { width: 34px; height: 34px; }
.ep-card-icon-img { width: 34px; height: 34px; }
.ep-card-body { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.ep-card-title { margin: 0; font-family: var(--ep-font-display); font-weight: 600; font-size: 1.5rem; }
.ep-card-desc { margin: 0; color: var(--ep-muted); font-size: 0.95rem; line-height: 1.35; }
.ep-card-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.ep-chip {
  font-size: 0.78rem; font-weight: 600; color: var(--ep-muted);
  border: 1px solid var(--ep-line); border-radius: 999px; padding: 4px 10px;
}
.ep-chip-diff.diff-facil { color: #79c99a; border-color: rgba(121,201,154,0.4); }
.ep-chip-diff.diff-medio { color: var(--ep-accent); border-color: rgba(186,117,23,0.4); }
.ep-chip-diff.diff-dificil { color: #d9727d; border-color: rgba(217,114,125,0.4); }
.ep-card-cta {
  position: absolute; top: 18px; right: 20px;
  font-weight: 700; color: var(--ep-accent); font-size: 0.9rem;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.ep-empty { color: var(--ep-muted); }

/* ---------- RESULTADO ---------- */
.ep-result { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }
.ep-score { display: flex; flex-direction: column; align-items: center; margin: 4px 0; }
.ep-score-num { font-family: var(--ep-font-display); font-weight: 700; font-size: clamp(3.4rem, 12vw, 6rem); color: var(--ep-accent); line-height: 1; }
.ep-score-label { text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.72rem; color: var(--ep-muted); }
.ep-result-line { color: var(--ep-cream); font-size: 1.1rem; margin: 0; }
.ep-final-msg { color: var(--ep-muted); max-width: 40ch; margin: 4px 0 0; }
.ep-result-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 10px; }

/* voto no vinho preferido */
.ep-fav { width: min(560px, 100%); margin-top: 12px; border-top: 1px solid var(--ep-line); padding-top: 18px; }
.ep-fav-title { margin: 0; font-family: var(--ep-font-display); font-size: 1.3rem; }
.ep-fav-sub { margin: 4px 0 12px; color: var(--ep-muted); font-size: 0.9rem; }
.ep-fav-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.ep-fav-chip {
  display: flex; align-items: center; gap: 10px;
  min-height: 54px; padding: 8px 14px; text-align: left;
  border: 1px solid var(--ep-line); border-radius: 14px;
  background: rgba(255,255,255,0.03); color: var(--ep-cream); cursor: pointer;
}
.ep-fav-chip.on { border-color: var(--ep-accent); background: rgba(186,117,23,0.16); }
.ep-fav-dot { width: 14px; height: 14px; border-radius: 50%; flex: 0 0 auto; }
.ep-fav-name { font-weight: 600; font-size: 0.95rem; }
.ep-fav-region { color: var(--ep-muted); font-size: 0.8rem; margin-left: auto; }

/* ---------- ERRO ---------- */
.ep-error { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.ep-error-detail {
  font-size: 0.8rem; color: var(--ep-muted); background: rgba(0,0,0,0.3);
  padding: 10px 14px; border-radius: 10px; max-width: 90vw; overflow: auto;
}

/* ---------- MODAL ---------- */
.ep-modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.ep-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(3px); }
.ep-modal-card {
  position: relative; z-index: 1;
  width: min(460px, 100%);
  background: var(--ep-bg-2);
  border: 1px solid var(--ep-line-strong);
  border-radius: var(--ep-radius-lg);
  padding: 26px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}
.ep-modal-title { margin: 0 0 10px; font-family: var(--ep-font-display); font-size: 1.7rem; }
.ep-modal-body { color: var(--ep-muted); font-size: 1rem; line-height: 1.5; }
.ep-modal-body p { margin: 0 0 8px; }
.ep-modal-actions { margin-top: 20px; }

/* ---------- TIMER (barra) ---------- */
.ep-timer { width: 100%; height: 8px; border-radius: 999px; background: rgba(255,255,255,0.08); overflow: hidden; }
.ep-timer-bar { height: 100%; width: 100%; background: linear-gradient(90deg, var(--ep-accent), var(--ep-primary)); border-radius: 999px; }

/* ---------- TOAST ---------- */
.ep-toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--ep-safe-b)); transform: translateX(-50%) translateY(20px);
  background: rgba(20,12,14,0.96); color: var(--ep-cream);
  border: 1px solid var(--ep-line-strong); border-radius: 999px;
  padding: 12px 22px; font-weight: 600; font-size: 0.95rem;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 60; max-width: 90vw;
}
.ep-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- EXPERIÊNCIAS (Experience Engine) ---------- */
.xp {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  text-align: center; padding: 16px 12px;
  width: min(560px, 100%); margin: 0 auto;
}
.xp-emoji { font-size: 3.4rem; line-height: 1; }
.xp-title { font-family: var(--ep-font-display); font-weight: 700; font-size: 1.9rem; color: var(--ep-accent); margin: 0; }
.xp-msg { color: var(--ep-cream); font-size: 1.05rem; line-height: 1.45; max-width: 46ch; margin: 0; }
.xp-sub { color: var(--ep-muted); font-size: 0.9rem; margin: 0; }
.xp-code {
  font-family: var(--ep-font-body); font-weight: 700; font-size: 1.7rem; letter-spacing: 0.22em;
  padding: 10px 22px; border: 1px dashed var(--ep-accent); border-radius: 12px; color: var(--ep-accent);
}
.xp-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.xp-img { max-width: 150px; max-height: 150px; object-fit: contain; }
.xp-video { width: 100%; max-width: 640px; border-radius: 12px; background: #000; }

/* ---------- MODO DE TESTE (selo discreto) ---------- */
.ep-testmode {
  position: fixed; top: calc(6px + var(--ep-safe-t)); left: 50%; transform: translateX(-50%);
  z-index: 40; pointer-events: none;
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: #1a1206; background: var(--ep-accent); border-radius: 999px; padding: 4px 12px;
  opacity: 0.9;
}

/* ---------- MARCA / VERSÃO / FUNDO ---------- */
.ep-brand-logo { height: 30px; width: auto; max-width: 150px; object-fit: contain; display: block; }
.ep-version-stamp {
  position: fixed;
  bottom: calc(6px + var(--ep-safe-b)); right: calc(10px + var(--ep-safe-r));
  font-size: 0.62rem; letter-spacing: 0.04em;
  color: rgba(244, 239, 230, 0.32);
  pointer-events: none; z-index: 5; user-select: none;
}
/* imagem de fundo opcional por campanha (com escurecimento para legibilidade) */
body.ep-has-bg { background-image: var(--ep-bg-image); background-size: cover; background-position: center; background-attachment: fixed; }
body.ep-has-bg::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: linear-gradient(180deg, rgba(7,4,5,0.82), rgba(7,4,5,0.92));
}

/* ---------- ACESSIBILIDADE ---------- */
:focus-visible { outline: 3px solid var(--ep-accent); outline-offset: 3px; border-radius: 6px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* landscape baixo (iPad em apresentação) — compacta o vertical */
@media (orientation: landscape) and (max-height: 640px) {
  .ep-screen { gap: 14px; }
  .ep-title { font-size: clamp(1.6rem, 4vw, 2.4rem); }
}
