/* ============================================================================
   regenteicm — Worship Broadcast
   Shared design system. "Hymnal" aesthetic: warm paper, liturgical red.
   Light only (no dark mode, by design). Fonts: Fraunces (display) + Hanken
   Grotesk (UI). Portuguese (pt-BR) interface.
   ============================================================================ */

:root {
  /* Paper & surfaces — warm whites, like an old hymnal page. */
  --paper:        #faf4ee;
  --paper-2:      #f2e8df;
  --surface:      #ffffff;
  --surface-tint: #fdf7f3;

  /* Ink — warm near-black, never pure #000. */
  --ink:        #2a1614;
  --ink-soft:   #75554f;
  --ink-faint:  #a78d86;

  /* Liturgical reds — the single accent family. */
  --red:        #b21d1d;
  --red-deep:   #7f1212;
  --red-bright: #d8392b;
  --red-tint:   #f6e3df;
  --red-line:   rgba(178, 29, 29, 0.16);

  /* Strokes & shadows. */
  --line:      rgba(42, 22, 20, 0.10);
  --line-2:    rgba(42, 22, 20, 0.16);
  --shadow-sm: 0 1px 2px rgba(90, 22, 18, 0.06);
  --shadow:    0 2px 4px rgba(90, 22, 18, 0.05), 0 18px 40px -22px rgba(90, 22, 18, 0.30);
  --shadow-lg: 0 8px 20px -8px rgba(90, 22, 18, 0.22), 0 40px 70px -40px rgba(90, 22, 18, 0.45);

  --radius:    16px;
  --radius-sm: 11px;
  --radius-pill: 999px;

  --font-display: "Fraunces", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-ui: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background-color: var(--paper);
  /* Layered atmosphere: two faint warm light pools over paper. */
  background-image:
    radial-gradient(120% 80% at 12% -10%, rgba(216, 57, 43, 0.06), transparent 55%),
    radial-gradient(120% 90% at 100% 0%, rgba(178, 29, 29, 0.05), transparent 50%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
}

/* Faint paper grain overlay for texture, kept subtle and non-interactive. */
body::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.035'/%3E%3C/svg%3E");
}

/* ---- Typography ---------------------------------------------------------- */
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; margin: 0; }

.eyebrow {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--red);
}

.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }

/* ---- Brand mark ---------------------------------------------------------- */
.brand { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.brand .seal {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: radial-gradient(120% 120% at 30% 25%, var(--red-bright), var(--red-deep));
  color: #fff;
  font-family: var(--font-display);
  font-size: 1.05rem;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25), var(--shadow-sm);
}
.brand .wordmark { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.brand .wordmark b {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
}
.brand .wordmark small {
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---- Buttons ------------------------------------------------------------- */
button, .btn {
  font-family: var(--font-ui);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  transition: transform 0.12s var(--ease), box-shadow 0.18s var(--ease),
              background 0.18s var(--ease), border-color 0.18s var(--ease), opacity 0.18s;
  display: inline-flex; align-items: center; gap: 0.45rem;
}
button:hover, .btn:hover { border-color: var(--red-line); box-shadow: var(--shadow-sm); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: default; transform: none; box-shadow: none; }
button:focus-visible, .btn:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--red-bright); outline-offset: 2px;
}

.btn-primary, button.primary {
  background: linear-gradient(180deg, var(--red-bright), var(--red));
  border-color: var(--red-deep);
  color: #fff;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.22);
}
.btn-primary:hover, button.primary:hover {
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.22);
  border-color: var(--red-deep);
}

.btn-ghost { background: transparent; border-color: transparent; color: var(--red); }
.btn-ghost:hover { background: var(--red-tint); border-color: transparent; }

.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.82rem; border-radius: 9px; }

/* ---- Inputs & selects ---------------------------------------------------- */
input, select, textarea {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--ink);
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
input::placeholder { color: var(--ink-faint); }
input:focus, select:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-tint); outline: none; }

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23b21d1d' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
}

/* ---- Cards & layout helpers --------------------------------------------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.2rem;
}
/* A thin red rule along the top edge of cards — like a ledger line. */
.card::before {
  content: "";
  position: absolute; left: 1.2rem; right: 1.2rem; top: 0;
  height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, var(--red), transparent 70%);
  opacity: 0.5;
}
.card > .card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 0.5rem; margin-bottom: 0.85rem;
}
.card > .card-head h2 { font-size: 1.18rem; }

.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 0.6rem; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }

/* ---- Status pill (connection state) ------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 0.32rem 0.7rem; border-radius: var(--radius-pill);
  background: var(--surface); border: 1px solid var(--line-2); color: var(--ink-soft);
  white-space: nowrap;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); }
.pill.live { color: var(--red-deep); border-color: var(--red-line); background: var(--red-tint); }
.pill.live .dot { background: var(--red-bright); box-shadow: 0 0 0 0 rgba(216,57,43,0.5); animation: beat 2s var(--ease) infinite; }
.pill.warn .dot { background: #c98a16; animation: blink 1s steps(2) infinite; }
@keyframes beat { 0% { box-shadow: 0 0 0 0 rgba(216,57,43,0.45); } 70% { box-shadow: 0 0 0 7px rgba(216,57,43,0); } 100% { box-shadow: 0 0 0 0 rgba(216,57,43,0); } }
@keyframes blink { 50% { opacity: 0.3; } }

/* ---- Sheet-music overlay (shared by musician & leader) ------------------- */
.sheet {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column;
  background: #1c0f0d; /* dark frame so the white PDF page reads as paper on a stand */
}
.sheet[hidden] { display: none; }
.sheet-bar {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.7rem 0.9rem;
  padding-top: max(0.7rem, env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(127,18,18,0.96), rgba(127,18,18,0.82));
  color: #fff;
  backdrop-filter: blur(6px);
}
.sheet-bar .titles { min-width: 0; flex: 1; }
.sheet-bar .titles .t-song {
  font-family: var(--font-display); font-size: 1.05rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sheet-bar .titles .t-inst {
  font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(255,255,255,0.78);
}
.sheet-bar .close {
  flex: 0 0 auto;
  background: rgba(255,255,255,0.12); color: #fff; border-color: rgba(255,255,255,0.25);
}
.sheet-bar .close:hover { background: rgba(255,255,255,0.22); border-color: rgba(255,255,255,0.4); }
.sheet-frame { flex: 1; width: 100%; border: 0; background: #2a1614; display: block; }

/* Icon + label buttons. The sheet bar collapses them to icon-only on phones so the
   song title keeps its room instead of three text buttons crowding it out. */
.icobtn { gap: 0.4rem; }
.icobtn .ico { font-size: 1rem; line-height: 1; }
@media (max-width: 480px) {
  .sheet-bar { gap: 0.5rem; padding-left: 0.7rem; padding-right: 0.7rem; }
  .sheet-bar .icobtn { padding: 0.55rem 0.62rem; }
  .sheet-bar .icobtn .lbl { display: none; }
}

/* ---- Toast -------------------------------------------------------------- */
.toast-wrap {
  position: fixed; left: 50%; bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 200;
  display: flex; flex-direction: column; gap: 0.5rem; align-items: center;
  width: max-content; max-width: calc(100vw - 2rem); pointer-events: none;
}
.toast {
  background: var(--ink); color: #fff;
  padding: 0.6rem 1rem; border-radius: var(--radius-pill);
  font-size: 0.85rem; font-weight: 600; box-shadow: var(--shadow-lg);
  animation: toast-in 0.25s var(--ease);
}
.toast.err { background: var(--red-deep); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

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