/* ---------- Fonts (self-hosted, latin subset) ---------- */
@font-face {
  font-family: 'Oswald';
  src: url('../fonts/oswald-latin.woff2') format('woff2');
  font-weight: 200 700;
  font-display: swap;
}
@font-face {
  font-family: 'Poppins';
  src: url('../fonts/poppins-400-latin.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Poppins';
  src: url('../fonts/poppins-500-latin.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Poppins';
  src: url('../fonts/poppins-600-latin.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  /* DFN */
  --dfn-orange: #f0631a;
  --dfn-orange-deep: #c33412; /* white text on this: 5.5:1 */
  --dfn-charcoal: #303030;
  /* CCH */
  --cch-charcoal: #2a2829;
  --cch-crimson: #7a1424;
  --gold: #e8b84a;

  --ink: #1d1b1c;
  --ink-muted: #5c5a5b; /* on white: 6.6:1 */
  --paper: #ffffff;
  --paper-2: #f6f3f1;
  --line: #d9d3cf;
  --ok: #1d7a46;
  --warn: #9a4a00;
  --bad: #b3261e;

  --font-display: 'Oswald', 'Arial Narrow', sans-serif;
  --font-body: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --radius: 10px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
}
img {
  max-width: 100%;
  display: block;
}
[hidden] {
  display: none !important;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.num {
  font-variant-numeric: tabular-nums;
}

/* =========================================================
   DISPLAY (projected)
   ========================================================= */
body.display {
  min-height: 100vh;
  min-height: 100dvh;
  color: #fff;
  background-color: var(--cch-charcoal);
  background-image:
    radial-gradient(ellipse 60% 55% at 0% 0%, rgba(122, 20, 36, 0.75), transparent 70%),
    radial-gradient(ellipse 60% 55% at 100% 100%, rgba(122, 20, 36, 0.65), transparent 70%),
    radial-gradient(ellipse 50% 40% at 50% 55%, rgba(240, 99, 26, 0.08), transparent 70%);
  overflow: hidden;
}
.stage {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: clamp(16px, 3vw, 48px) clamp(16px, 4vw, 72px);
}
.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  padding-bottom: clamp(12px, 2vh, 24px);
  border-bottom: 1px solid rgba(232, 184, 74, 0.45);
}
.brand img {
  height: clamp(44px, 9vh, 104px);
  width: auto;
}
.brand .logo-dfn {
  border-radius: 4px;
}
.brand-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1rem, 2.6vw, 2.4rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  color: var(--gold);
}
.brand-title .star {
  display: inline-block;
  margin: 0 0.4em;
  font-size: 0.7em;
  vertical-align: 0.15em;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: clamp(8px, 2vh, 24px);
  min-width: 0;
}
.hero-label {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.1rem, 3vw, 3rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.88);
}
.total {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: min(20vw, 30vh);
  line-height: 1;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: text-shadow 600ms ease;
}
.total.rising {
  text-shadow: 0 0 0.25em rgba(232, 184, 74, 0.55);
}

.goal {
  width: min(100%, 1100px);
}
.goal-track {
  position: relative;
  height: clamp(14px, 2.6vh, 30px);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}
.goal-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--dfn-orange-deep), var(--dfn-orange));
  transition: width 2200ms cubic-bezier(0.22, 1, 0.36, 1);
}
.goal.reached .goal-fill {
  background: linear-gradient(90deg, var(--dfn-orange), var(--gold));
}
.goal-text {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-2);
  font-size: clamp(0.9rem, 1.8vw, 1.7rem);
  color: rgba(255, 255, 255, 0.88);
}
.goal-text strong {
  color: var(--gold);
  font-weight: 600;
}

.breakdown {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(16px, 4vw, 64px);
  margin: 0;
}
.breakdown div {
  text-align: center;
}
.breakdown dt {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: clamp(0.8rem, 1.4vw, 1.3rem);
  color: rgba(255, 255, 255, 0.75);
}
.breakdown dd {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.2rem, 3vw, 2.8rem);
}

.stage-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  font-size: clamp(0.8rem, 1.3vw, 1.2rem);
  color: rgba(255, 255, 255, 0.78);
}
.stage-footer .dot {
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  border-radius: 50%;
  background: var(--gold);
  margin-right: 0.5em;
}
.stage-footer.offline .dot {
  background: #9a9a9a;
}

.fullscreen-btn {
  position: fixed;
  top: 12px;
  right: 12px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font: 500 0.9rem var(--font-body);
  cursor: pointer;
  opacity: 1;
  transition: opacity 400ms ease;
}
body.idle .fullscreen-btn {
  opacity: 0;
  pointer-events: none;
}
body.idle {
  cursor: none;
}

@media (max-width: 600px) {
  .brand {
    flex-wrap: wrap;
    justify-content: space-between;
    row-gap: var(--space-3);
  }
  .brand img {
    height: 48px;
  }
  .brand-title {
    order: 3;
    flex-basis: 100%;
  }
  .total {
    font-size: 22vw;
  }
  .stage-footer {
    flex-direction: column;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .goal-fill,
  .total {
    transition: none;
  }
}

/* =========================================================
   TOOL PAGES (tally + admin)
   ========================================================= */
body.tool {
  background: var(--paper-2);
}
.tool-header {
  background: var(--cch-charcoal);
  color: #fff;
  border-bottom: 3px solid var(--dfn-orange);
}
.tool-header-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.tool-header img {
  height: 36px;
  width: auto;
  border-radius: 3px;
}
.tool-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.4rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tool-header nav {
  margin-left: auto;
  display: flex;
  gap: var(--space-2);
}
.tool-header nav a {
  color: #fff;
  font-size: 0.9rem;
  padding: 10px 8px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.tool-main {
  max-width: 880px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-7);
  display: grid;
  gap: var(--space-5);
}
.tool-main > * {
  min-width: 0; /* let wide tables scroll inside their card instead of widening the page */
}
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-5);
}
.card h2 {
  margin: 0 0 var(--space-3);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.15rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.big-figure {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.6rem, 10vw, 4.5rem);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.meta {
  margin: var(--space-2) 0 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
}
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 2px 10px;
  border-radius: 999px;
  background: #e6f2ea;
  color: var(--ok);
}
.status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.status.bad {
  background: #fbe9e7;
  color: var(--bad);
}
.status.wait {
  background: #f1ece8;
  color: var(--ink-muted);
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-4);
}
.btn {
  min-height: 44px;
  padding: 0 20px;
  border-radius: 8px;
  border: 1px solid var(--dfn-orange-deep);
  background: var(--dfn-orange-deep);
  color: #fff;
  font: 600 1rem var(--font-body);
  cursor: pointer;
}
.btn:hover {
  background: #a82a0c;
}
.btn.secondary {
  background: var(--paper);
  color: var(--dfn-orange-deep);
}
.btn.secondary:hover {
  background: #fdf1ec;
}
.btn.large {
  min-height: 56px;
  font-size: 1.1rem;
  width: 100%;
}
.btn:disabled {
  opacity: 0.6;
  cursor: progress;
}
.btn:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}
.note {
  margin: var(--space-3) 0 0;
  padding: var(--space-3) var(--space-4);
  border-radius: 8px;
  background: var(--paper-2);
  font-size: 0.95rem;
}
.note.ok {
  background: #e6f2ea;
  color: #14532d;
}
.note.bad {
  background: #fbe9e7;
  color: #7f1d1d;
}
.note.warn {
  background: #fff3e0;
  color: #6b3300;
}

.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
th,
td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th {
  font-weight: 600;
  color: var(--ink-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
td.amount,
th.amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
tr.refunded td {
  color: var(--ink-muted);
}
.empty {
  color: var(--ink-muted);
  padding: var(--space-4) 0;
}

/* Admin form */
.field {
  display: grid;
  gap: 6px;
  margin-bottom: var(--space-4);
}
.field label {
  font-weight: 600;
}
.field .hint {
  color: var(--ink-muted);
  font-size: 0.9rem;
  margin: 0;
}
.money-input {
  display: flex;
  align-items: stretch;
  border: 1px solid #8a8486; /* 3.6:1 on white */
  border-radius: 8px;
  background: var(--paper);
  overflow: hidden;
}
.money-input span {
  display: grid;
  place-items: center;
  padding: 0 12px;
  background: var(--paper-2);
  color: var(--ink-muted);
  font-weight: 600;
}
.money-input input {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  border: 0;
  padding: 0 12px;
  font: 600 1.3rem var(--font-body);
  font-variant-numeric: tabular-nums;
}
.text-input {
  min-height: 52px;
  border: 1px solid #8a8486;
  border-radius: 8px;
  padding: 0 12px;
  font: 500 1.2rem var(--font-body);
  width: 100%;
}
.readonly-figure {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-3) var(--space-4);
  border-radius: 8px;
  background: var(--paper-2);
}
.readonly-figure strong {
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}
.check {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 44px;
  margin-bottom: var(--space-4);
}
.check input {
  width: 24px;
  height: 24px;
  accent-color: var(--dfn-orange-deep);
}
.preview {
  margin: 0 0 var(--space-4);
  padding: var(--space-4);
  border-radius: 8px;
  border: 2px dashed var(--line);
  font-size: 1.05rem;
}
.preview strong {
  font-size: 1.4rem;
  font-variant-numeric: tabular-nums;
}
.pin-card {
  max-width: 420px;
  margin: 10vh auto 0;
}
