/* ============================================================
   Sorteios AAQ — Design tokens & base
   Brand-aligned with andreyquadros.com.br:
   cream paper (#f4ede4), graphite ink (#08080c) and an
   emerald-green accent (#3a8f6a → #54b585), with a warm gold
   reserved for winners/celebration. Fraunces (display) + Inter.
   ============================================================ */

:root {
  /* Neutrals — matched to the official brand */
  --paper:        #f4ede4;
  --paper-2:      #ece5d8;
  --ink:          #08080c;
  --ink-soft:     #45434b;
  --ink-faint:    #6f6c75;
  --line:         #ddd2c2;

  /* Brand accent: emerald green (primary).
     Legacy --amber* names are kept and repointed to green so every
     accent surface inherits the brand without per-component edits. */
  --green:        #54b585;
  --green-deep:   #3a8f6a;
  --amber:        #54b585;
  --amber-deep:   #3a8f6a;
  --emerald:      #54b585;
  --emerald-deep: #3a8f6a;
  --gold:         #e6b745;          /* winners / celebration only */
  --coral:        oklch(67% 0.18 28); /* error states */

  --surface:      #faf6f0;
  --surface-ink:  #0e0e14;   /* dark surface for footer/admin chrome */

  /* Typography */
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body:    "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  --text-xs:   0.78rem;
  --text-sm:   0.88rem;
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.1rem);
  --text-lg:   clamp(1.15rem, 1.05rem + 0.5vw, 1.4rem);
  --text-xl:   clamp(1.5rem, 1.2rem + 1.4vw, 2.2rem);
  --text-display: clamp(2.6rem, 1.4rem + 5.4vw, 5.2rem);

  /* Spacing rhythm */
  --space-1: 0.4rem;
  --space-2: 0.75rem;
  --space-3: 1.15rem;
  --space-4: 1.75rem;
  --space-5: 2.75rem;
  --space-section: clamp(3rem, 2rem + 5vw, 7rem);

  /* Shape & depth */
  --radius-sm: 0.5rem;
  --radius:    0.9rem;
  --radius-lg: 1.5rem;
  --shadow-sm: 0 1px 2px oklch(22% 0.03 65 / 0.08);
  --shadow:    0 12px 30px -12px oklch(22% 0.03 65 / 0.28);
  --shadow-lg: 0 30px 60px -20px oklch(22% 0.03 65 / 0.32);

  /* Motion */
  --dur-fast:   140ms;
  --dur:        300ms;
  --ease:       cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

/* The [hidden] attribute must always win over component display rules
   (e.g. #auth-view{display:grid}); otherwise toggled views stack. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.05; margin: 0; }
p { margin: 0; }
a { color: inherit; }

/* Paper grain / atmosphere — compositor-friendly, very subtle */
.grain::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.045'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

/* Buttons */
.btn {
  --bg: var(--ink);
  --fg: var(--paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.4rem;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg);
  background: var(--bg);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease),
              box-shadow var(--dur) var(--ease),
              filter var(--dur-fast) var(--ease);
  box-shadow: var(--shadow-sm);
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0) scale(0.99); }
.btn:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }

.btn--accent { --bg: var(--amber-deep); --fg: oklch(99% 0.01 90); }
.btn--emerald { --bg: var(--emerald-deep); --fg: oklch(99% 0.01 90); }
.btn--ghost {
  --bg: transparent; --fg: var(--ink);
  border: 1.5px solid var(--line);
  box-shadow: none;
}
.btn--gold { --bg: var(--gold); --fg: #2a2010; }
.btn--ghost:hover { border-color: var(--ink); }
.btn--sm { padding: 0.5rem 0.9rem; font-size: var(--text-sm); border-radius: var(--radius-sm); }

/* Form fields */
.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}
.field input, .field textarea, .field select {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.95rem;
  transition: border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--green-deep);
  box-shadow: 0 0 0 3px rgba(58, 143, 106, 0.24);
}
.field input::placeholder, .field textarea::placeholder { color: var(--ink-faint); }

.pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  font-size: var(--text-xs); font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  border-radius: 999px;
}
.pill--open    { background: rgba(58, 143, 106, 0.16); color: var(--green-deep); }
.pill--drawn   { background: rgba(230, 183, 69, 0.22); color: #9a7416; }
.pill--closed  { background: rgba(111, 108, 117, 0.16); color: var(--ink-soft); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* LGPD cookie notice */
.cookiebar {
  position: fixed;
  left: 50%;
  bottom: clamp(0.75rem, 2vw, 1.5rem);
  transform: translateX(-50%);
  z-index: 50;
  width: min(46rem, calc(100% - 1.5rem));
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: 0.95rem 1.15rem;
  background: var(--surface-ink);
  color: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: cookiebar-in var(--dur) var(--ease) both;
}
@keyframes cookiebar-in {
  from { opacity: 0; transform: translateX(-50%) translateY(14px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.cookiebar.is-leaving { opacity: 0; transform: translateX(-50%) translateY(14px); transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); }
.cookiebar__text { flex: 1 1 18rem; font-size: var(--text-sm); line-height: 1.5; color: rgba(244, 237, 228, 0.86); }
.cookiebar__text strong { color: var(--paper); }
.cookiebar__text a { color: var(--green); font-weight: 600; }
.cookiebar__actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.cookiebar .btn--sm { white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .cookiebar { animation: none; } }

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