/* ============================================================
   Shout — visual identity
   Signature: the "tab" — a chalkboard pub sign for who's next,
   and beer-tally count badges on each person's card.
   ============================================================ */

:root {
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', monospace;
  --font-body: 'Inter', system-ui, sans-serif;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 9px;

  --shadow-soft: 0 10px 30px rgba(0,0,0,0.25);
  --shadow-lift: 0 4px 14px rgba(0,0,0,0.18);

  --ease: cubic-bezier(.22, 1, .36, 1);
}

html[data-theme="dark"] {
  --bg: #12716412;
  --bg: #12181a;
  --bg-elevated: #1b2320;
  --surface: #212a26;
  --surface-2: #283330;
  --ink: #f4efe0;
  --ink-muted: #a9b6ae;
  --accent-gold: #e8a33d;
  --accent-gold-ink: #1b1408;
  --accent-teal: #4aa08a;
  --accent-terracotta: #e08659;
  --border: rgba(244,239,224,0.10);
  --border-strong: rgba(244,239,224,0.18);
  --chalk-dust: rgba(244,239,224,0.06);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f6f0e0;
  --bg-elevated: #fffdf8;
  --surface: #ffffff;
  --surface-2: #fbf5e8;
  --ink: #2a2620;
  --ink-muted: #756b5e;
  --accent-gold: #c17c1c;
  --accent-gold-ink: #fffaf0;
  --accent-teal: #2c6c5d;
  --accent-terracotta: #bf5a34;
  --border: rgba(42,38,32,0.12);
  --border-strong: rgba(42,38,32,0.20);
  --chalk-dust: rgba(42,38,32,0.04);
  color-scheme: light;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, even over classes that set their
   own display (modal overlays, buttons, fields) — same-specificity rules
   loading after the UA stylesheet would otherwise silently override it. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  transition: background 0.35s var(--ease), color 0.35s var(--ease);
}

body {
  min-height: 100vh;
  padding: 28px 20px 80px;
  position: relative;
  overflow-x: hidden;
}

a { color: inherit; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- Ambient background ---------- */
.bg-scene {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 900px 500px at 15% -5%, var(--chalk-dust), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 10%, var(--chalk-dust), transparent 55%);
}
.tab-lines {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 39px,
    var(--border) 40px
  );
  opacity: 0.35;
  mask-image: linear-gradient(to bottom, transparent, black 8%, black 60%, transparent);
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 50;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lift);
  transition: transform 0.25s var(--ease), background 0.25s var(--ease);
}
.theme-toggle:hover { transform: rotate(-12deg) scale(1.05); }
.theme-toggle:active { transform: scale(0.94); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.2s var(--ease), opacity 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--accent-teal); outline-offset: 2px; }

.btn--primary {
  background: var(--accent-gold);
  color: var(--accent-gold-ink);
  box-shadow: 0 6px 18px -6px color-mix(in srgb, var(--accent-gold) 70%, transparent);
}
.btn--primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px -8px color-mix(in srgb, var(--accent-gold) 80%, transparent); }

.btn--ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--border-strong);
}
.btn--ghost:hover { background: var(--surface-2); }

.btn--danger {
  background: transparent;
  color: var(--accent-terracotta);
  border-color: color-mix(in srgb, var(--accent-terracotta) 40%, transparent);
  margin-right: auto;
}
.btn--danger:hover { background: color-mix(in srgb, var(--accent-terracotta) 12%, transparent); }

.btn--block { width: 100%; padding: 14px; font-size: 16px; }
.btn--small { padding: 8px 12px; font-size: 13px; }
.btn__arrow { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2.4; fill: none; transition: transform 0.2s var(--ease); }
.btn--primary:hover .btn__arrow { transform: translateX(3px); }
.icon-sm { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2.2; fill: none; }

/* ============================================================
   HOME PAGE
   ============================================================ */
.home-shell {
  max-width: 460px;
  margin: 0 auto;
  padding-top: 3vh;
}

.brand { text-align: center; margin-bottom: 26px; }
.brand__mark { display: flex; justify-content: center; margin-bottom: 8px; }
.bell-icon { width: 46px; height: 46px; fill: var(--accent-gold); filter: drop-shadow(0 4px 10px color-mix(in srgb, var(--accent-gold) 40%, transparent)); animation: bellSway 4.5s ease-in-out infinite; transform-origin: 32px 12px; }
@keyframes bellSway {
  0%, 100% { transform: rotate(0deg); }
  6% { transform: rotate(-9deg); }
  12% { transform: rotate(7deg); }
  18% { transform: rotate(-4deg); }
  24% { transform: rotate(0deg); }
}
.brand__title {
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}
.brand__tag { color: var(--ink-muted); margin: 0; font-size: 15px; line-height: 1.5; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-soft);
}
.card__eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-teal);
  margin-bottom: 8px;
}
.card__heading { font-family: var(--font-display); font-size: 24px; margin: 0 0 8px; }
.card__sub { color: var(--ink-muted); font-size: 14px; line-height: 1.55; margin: 0 0 22px; }

.legal-body p {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.65;
  margin: 0 0 14px;
}
.legal-body p:last-child { margin-bottom: 0; }
.legal-body strong { color: var(--ink); }
.legal-card { max-width: 640px; margin-left: auto; margin-right: auto; }

.field { display: block; margin-bottom: 16px; }
.field--inline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field__label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.field__hint { font-weight: 400; color: var(--ink-muted); font-size: 12px; }
.field--inline .field__label { margin-bottom: 0; flex-shrink: 0; }

input[type="text"], input[type="number"], input[type="datetime-local"], select {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 15px;
  font-family: var(--font-body);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field--inline input[type="number"] { width: 84px; text-align: center; }
input:focus, select:focus {
  outline: none;
  border-color: var(--accent-teal);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-teal) 22%, transparent);
}

.form-error {
  background: color-mix(in srgb, var(--accent-terracotta) 14%, transparent);
  color: var(--accent-terracotta);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}

.home-note { text-align: center; color: var(--ink-muted); font-size: 13px; margin-top: 22px; }

/* ============================================================
   GROUP PAGE
   ============================================================ */
.group-shell { max-width: 720px; margin: 0 auto; }

.header-top-row {
  display: flex;
  align-items: baseline;
  gap: 28px;
  flex-wrap: wrap;
}
.back-link {
  text-decoration: none;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 14px;
}
.back-link:hover { color: var(--accent-teal); }
.people-count-inline {
  color: var(--ink-muted);
  opacity: 0.7;
  font-size: 12px;
  font-family: var(--font-mono);
}

.group-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.group-title {
  font-family: var(--font-display);
  font-size: 30px;
  margin: 0;
  letter-spacing: -0.01em;
}

.group-title-block { min-width: 0; flex: 1 1 auto; }
.group-title-display { display: flex; align-items: center; gap: 6px; min-width: 0; }
.group-title-display .group-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.title-edit-btn {
  background: transparent;
  border: none;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.title-edit-btn:hover { color: var(--ink); background: var(--surface-2); }

.group-title-edit-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.group-title-edit-form input {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  padding: 8px 12px;
  flex: 1 1 220px;
  min-width: 160px;
  max-width: 340px;
}

/* ---- Next-up banner (signature element) ---- */
.next-banner {
  margin: 26px 0 30px;
  position: relative;
  background:
    linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 26px 26px 24px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}
.next-banner::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, var(--border) 1px, transparent 1px);
  background-size: 14px 14px;
  opacity: 0.5;
  pointer-events: none;
}
.next-banner__eyebrow {
  position: relative;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-teal);
  display: flex;
  align-items: center;
  gap: 8px;
}
.next-banner__eyebrow .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-teal);
  animation: pulseDot 1.8s ease-in-out infinite;
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}
.next-banner__name {
  position: relative;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 6vw, 42px);
  margin: 6px 0 4px;
  letter-spacing: -0.02em;
  display: inline-block;
}
.next-banner__meta {
  position: relative;
  color: var(--ink-muted);
  font-size: 13.5px;
  margin: 0;
}
.next-banner__meta .tie-tag {
  color: var(--accent-terracotta);
  font-family: var(--font-mono);
}
.next-banner__empty { color: var(--ink-muted); font-size: 15px; }

/* ---- People grid ---- */
.people-section { margin-bottom: 34px; }
.people-section__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.people-section__head h2 {
  font-family: var(--font-display); font-size: 18px; margin: 0;
}

.people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.person-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  transition: border-color 0.2s, transform 0.2s var(--ease);
}
.person-card.is-next {
  border-color: color-mix(in srgb, var(--accent-gold) 55%, var(--border-strong));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent-gold) 30%, transparent);
}

.person-card__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.person-card__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  line-height: 1.25;
  word-break: break-word;
}
.person-card__count {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-teal);
  background: color-mix(in srgb, var(--accent-teal) 14%, transparent);
  padding: 2px 8px;
  border-radius: 999px;
  flex-shrink: 0;
  white-space: nowrap;
}

.tally-bar {
  height: 5px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.tally-bar__fill {
  height: 100%;
  background: var(--accent-gold);
  border-radius: 999px;
  transition: width 0.4s var(--ease);
}

.person-card__actions { display: flex; gap: 8px; }
.person-card__shout-btn {
  flex: 1;
  background: var(--accent-gold);
  color: var(--accent-gold-ink);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  padding: 10px;
  cursor: pointer;
  transition: transform 0.15s var(--ease);
}
.person-card__shout-btn:hover { transform: translateY(-1px); }
.person-card__shout-btn:active { transform: scale(0.96); }

.person-card__edit-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--ink-muted);
  border-radius: var(--radius-sm);
  width: 38px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.person-card__edit-btn:hover { color: var(--ink); background: var(--surface-2); }

.person-card__last {
  font-size: 12px;
  color: var(--ink-muted);
  font-family: var(--font-mono);
}

.empty-state {
  color: var(--ink-muted);
  font-size: 14px;
  text-align: center;
  padding: 30px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
}

/* ---- History ---- */
.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.history-item:hover { background: var(--surface-2); }
.history-item__who {
  font-weight: 600;
  font-size: 14.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item__when {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-muted);
  text-align: center;
  white-space: nowrap;
}
.history-item__edit {
  color: var(--ink-muted);
  font-size: 12.5px;
  font-family: var(--font-mono);
  text-align: right;
  white-space: nowrap;
}

.view-all-link {
  display: block;
  text-align: center;
  margin-top: 12px;
  color: var(--accent-teal);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.view-all-link:hover { background: var(--surface-2); }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}
.pagination__info {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-muted);
}
.pagination__disabled { opacity: 0.35; pointer-events: none; }

/* ---- Admin table ---- */
.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.admin-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.admin-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: var(--surface-2); }
.admin-table__mono { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-muted); }
.admin-table__group-link { color: var(--ink); font-weight: 600; text-decoration: none; }
.admin-table__group-link:hover { color: var(--accent-teal); }

/* ---- Footer ---- */
.site-footer {
  max-width: 480px;
  margin: 48px auto 0;
  padding: 20px 20px 4px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.site-footer__links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 10px;
}
.site-footer__links a {
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  text-decoration: none;
}
.site-footer__links a:hover { color: var(--ink); }
.site-footer__copy {
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
  opacity: 0.75;
  margin: 0;
}

/* ---- Modals ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,10,8,0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.18s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 26px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-soft);
  animation: modalPop 0.22s var(--ease);
}
@keyframes modalPop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal h3 { font-family: var(--font-display); margin: 0 0 18px; font-size: 20px; }
.modal__actions { display: flex; gap: 10px; margin-top: 6px; align-items: center; }

/* ---- Toasts ---- */
.toast-root {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-family: var(--font-mono);
  box-shadow: var(--shadow-lift);
  animation: toastIn 0.25s var(--ease);
}
.toast--error { border-color: color-mix(in srgb, var(--accent-terracotta) 60%, transparent); color: var(--accent-terracotta); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Confetti ---- */
.confetti-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 150;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  width: 8px; height: 8px;
  top: -10px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to { transform: translateY(105vh) rotate(540deg); opacity: 0.2; }
}

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  body { padding: 16px 14px 70px; }
  .card { padding: 20px; }
  .home-shell { padding-top: 0; }
  .brand { margin-bottom: 18px; }
  .bell-icon { width: 36px; height: 36px; }
  .brand__title { font-size: 32px; }
  .brand__tag { font-size: 13.5px; }
  .next-banner { padding: 20px 18px; }
  .people-grid { grid-template-columns: 1fr; }
  .theme-toggle { top: 14px; right: 14px; }
  .history-item { grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; padding: 9px 10px; }
  .history-item__when { text-align: right; }
}
