/* Farming Day - brand palette from guideline v1.0 */
:root {
  --green: #2E4A2E;
  --green-dark: #1F3320;
  --red: #A63A2F;
  --yellow: #F2C14E;
  --brown: #5B3A29;
  --cream: #FAF6E9;
  --paper: #F3EDDB;
  --gray: #8B867E;
  --ink: #1F1F1F;
  --sky: #A9D6E5;
  --rule: #1F1F1F;

  --font-logo: 'Rye', 'Alfa Slab One', Georgia, serif;
  --font-slab: 'Alfa Slab One', Georgia, serif;
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;

  --radius: 10px;
  color-scheme: light;
}

*, *::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(--cream);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3, h4, p { margin: 0; }

/* Paper background with a faint grain */
.page-paper, .page-card {
  background-color: #E9E1CB;
  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='.8' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 .36 0 0 0 0 .23 0 0 0 0 .16 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  min-height: 100vh;
}

/* ---------- Buttons and fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 48px; padding: .75rem 1.4rem;
  border: 2px solid var(--ink); border-radius: 999px;
  font: 700 1rem/1.2 var(--font-body); letter-spacing: .02em; text-decoration: none;
  cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease;
  box-shadow: 0 3px 0 var(--ink);
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.btn:focus-visible, .field input:focus-visible, select:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.btn-primary { background: var(--green); color: var(--cream); }
.btn-primary:hover { background: #375837; }
.btn-secondary { background: var(--yellow); color: var(--ink); }
.btn-secondary:hover { background: #f5cc66; }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: none; }
.btn-ghost:active { transform: none; }
.btn-small { min-height: 38px; padding: .45rem .95rem; font-size: .875rem; box-shadow: 0 2px 0 var(--ink); }
.btn .btn-busy { display: none; }
.btn.is-busy { pointer-events: none; opacity: .8; }
.btn.is-busy .btn-label { display: none; }
.btn.is-busy .btn-busy { display: inline; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--green); text-decoration: underline; cursor: pointer; }
.link-button.danger { color: var(--red); }

.field { display: grid; gap: .4rem; }
.field-label { font: 700 .78rem/1 var(--font-body); letter-spacing: .14em; text-transform: uppercase; color: var(--brown); }
.field input {
  width: 100%; min-height: 50px; padding: .7rem .9rem;
  font: 500 1.0625rem var(--font-body); color: var(--ink);
  background: #fff; border: 2px solid var(--ink); border-radius: var(--radius);
}
.field input::placeholder { color: #b1aca3; }
.has-error input, .has-error .photo-preview { border-color: var(--red); }
.error { color: var(--red); font-size: .875rem; font-weight: 600; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Newspaper sheet ---------- */
.sheet {
  width: min(760px, calc(100% - 24px));
  margin: 12px auto 40px;
  padding: 20px 18px 28px;
  background: var(--cream);
  background-image: radial-gradient(ellipse at 50% 0%, rgba(255,255,255,.6), transparent 70%);
  border: 1px solid #d8cfb6;
  box-shadow: 0 1px 0 #fff inset, 0 18px 40px -18px rgba(60, 40, 20, .45), 6px 6px 0 -1px #efe7d1, 6px 6px 0 0 #d8cfb6;
}
.sheet-narrow { width: min(460px, calc(100% - 24px)); margin-top: 8vh; text-align: center; }

/* ---------- Error and login ---------- */
.error-page, .admin-login { display: grid; gap: 14px; justify-items: center; }
.error-page h1, .admin-login h1 { font: 400 1.8rem/1.1 var(--font-slab); color: var(--green); }
.error-barn { width: 72px; }
.admin-login-logo { width: 260px; }
.admin-login .login-form { width: 100%; }
.login-form { display: grid; gap: 16px; margin-top: 18px; text-align: left; }
.login-form .btn { width: 100%; margin-top: 4px; }

/* ---------- Card page ---------- */
.card-page { width: min(880px, 100%); margin: 0 auto; padding: 16px 16px 40px; }
.back { display: inline-block; margin-bottom: 14px; font-weight: 600; text-decoration: none; color: var(--green); }
.notice { margin-bottom: 18px; padding: 12px 14px; background: var(--green); color: var(--cream); border-radius: var(--radius); font-size: .95rem; }
.notice strong { display: block; font: 400 1.1rem var(--font-slab); color: var(--yellow); }
.card-actions { display: grid; gap: 10px; margin-top: 22px; }
.card-hint { margin-top: 12px; font-size: .85rem; color: #5f5b54; text-align: center; }
@media (min-width: 560px) {
  .card-actions { grid-template-columns: 1fr 1fr; max-width: 560px; margin-inline: auto; }
}

/* ---------- Farm Crew ID card ----------
   Everything is sized in cqw so the card scales as one image at any width. */
.idcard-frame { container-type: inline-size; }
.idcard-wrap { padding: 8.6cqw 1.2cqw 2.4cqw; background: transparent; }
.idcard {
  position: relative; aspect-ratio: 1.68; overflow: visible;
  background: var(--cream); border-radius: 3cqw;
  box-shadow: 0 .4cqw 0 #d9cfb4, 0 1.6cqw 3cqw -1cqw rgba(40, 30, 10, .45);
  font-family: var(--font-body); color: var(--ink);
}
.idc-header { position: absolute; inset: 0 0 auto; height: 13.5cqw; background: var(--green); border-radius: 3cqw 3cqw 0 0; overflow: hidden; }
.idc-landscape { position: absolute; inset: auto 0 0; width: 100%; height: 8cqw; }
.idc-slot { position: absolute; left: 39.5cqw; top: 2.4cqw; width: 11cqw; height: 2.6cqw; border-radius: 2cqw; background: var(--cream); box-shadow: inset 0 .3cqw .5cqw rgba(0,0,0,.35); }
.idc-header-text { position: absolute; right: 2.6cqw; top: 1.9cqw; display: flex; align-items: flex-start; gap: 1.8cqw; color: var(--cream); text-transform: uppercase; letter-spacing: .1em; text-align: center; }
.idc-header-text p { font: 600 1.2cqw/1.45 var(--font-serif); white-space: nowrap; }
.idc-chronicle { display: grid; gap: .5cqw; padding-left: 1.8cqw; border-left: .12cqw solid rgba(250,246,233,.6); }
.idc-chronicle span { padding-bottom: .5cqw; border-bottom: .12cqw solid rgba(250,246,233,.6); }
.idc-chronicle small { font-size: .95cqw; }
.idc-grass { position: absolute; right: 0; top: 13.4cqw; width: 23cqw; height: 2.3cqw; background: #3B5E36; border-bottom-left-radius: 2.4cqw; }
.idc-grass::before { content: ""; position: absolute; left: -2.4cqw; top: 0; width: 2.4cqw; height: 2.4cqw; background: radial-gradient(circle at 0 100%, transparent 2.35cqw, #3B5E36 2.4cqw); }
.idc-logo { position: absolute; left: 1.2cqw; top: -7.2cqw; width: 38cqw; filter: drop-shadow(0 .3cqw .2cqw rgba(0,0,0,.25)); }

.idc-photo {
  position: absolute; left: 3cqw; top: 20.5cqw; width: 33cqw; height: 32.5cqw;
  border: .35cqw solid #fff; border-radius: 2cqw; overflow: hidden;
  box-shadow: 0 0 0 .18cqw var(--gray), 0 .4cqw .8cqw rgba(0,0,0,.15);
  background: var(--sky);
}
.idc-photo img { width: 100%; height: 100%; object-fit: cover; }
.idc-photo-script {
  position: absolute; left: 1.4cqw; bottom: 1.2cqw; transform: rotate(-12deg); transform-origin: left bottom;
  font: italic 700 1.7cqw/1.05 var(--font-serif); color: #fff; text-shadow: 0 .1cqw .4cqw rgba(0,0,0,.75);
}

.idc-info { position: absolute; left: 39.5cqw; top: 15.8cqw; width: 36cqw; }
.idc-title { font: 400 4.9cqw/1 var(--font-slab); color: var(--green); text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; padding-bottom: 1cqw; border-bottom: .15cqw solid #bdb6a6; }
.idc-row { display: grid; gap: .45cqw; padding: 1cqw 0 .95cqw; border-bottom: .15cqw solid #bdb6a6; }
.idc-row span { font: 500 1.45cqw/1 var(--font-body); text-transform: uppercase; letter-spacing: .04em; color: #6d6860; }
.idc-row strong { font: 700 2.8cqw/1.05 var(--font-body); text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.idc-row strong small { font-size: 1.6cqw; font-weight: 600; color: var(--gray); margin-left: .6cqw; letter-spacing: .04em; }
.idc-row .idc-name { font-size: 3.2cqw; }
.idc-row .idc-pending { font-weight: 600; font-size: 2.3cqw; color: var(--gray); text-transform: none; font-style: italic; }
.idc-barcode { margin-top: 1.4cqw; }
.idc-barcode svg { width: 100%; height: 4cqw; }
.idc-barcode span { display: block; margin-top: .6cqw; text-align: center; font: 600 1.25cqw/1 var(--font-body); letter-spacing: .32em; text-transform: uppercase; }

.idc-side { position: absolute; left: 77cqw; top: 15.5cqw; width: 20cqw; display: grid; justify-items: center; gap: 1.6cqw; }
.idc-stamp { width: 16.5cqw; transform: rotate(-9deg); }
.idc-stamp .stamp { width: 100%; height: auto; }
.idc-qr { display: grid; justify-items: center; gap: .6cqw; }
.idc-qr img { width: 9cqw; height: 9cqw; }
.idc-qr span { font: 700 1.05cqw/1.1 var(--font-body); letter-spacing: .06em; text-transform: uppercase; text-align: center; }
.idc-motto {
  position: absolute; right: 0; top: 45.6cqw; width: 19cqw; height: 7cqw;
  display: flex; align-items: center; gap: 1.6cqw; padding-left: 1.8cqw;
  background: var(--green); color: var(--cream); border-radius: 1.6cqw 0 0 1.6cqw;
}
.idc-motto .icon { width: 3.6cqw; height: 3.6cqw; flex: none; }
.idc-motto span { font: 600 1.3cqw/1.45 var(--font-serif); letter-spacing: .2em; text-transform: uppercase; }

.idc-footer {
  position: absolute; inset: auto 0 0; height: 4.6cqw;
  display: flex; align-items: center; gap: 2cqw; padding: 0 4cqw;
  background: linear-gradient(var(--yellow), #e6b23f); border-radius: 0 0 3cqw 3cqw;
  box-shadow: inset 0 .25cqw 0 rgba(255,255,255,.35);
  font: 600 1.3cqw/1 var(--font-serif); text-transform: uppercase; letter-spacing: .3em; color: #2b2410;
}
.idc-footer i { flex: 1; height: .15cqw; background: #2b2410; }

/* ---------- Admin ---------- */
.page-admin { background: #F4F0E3; }
.admin-bar { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; background: var(--green); color: var(--cream); }
.admin-brand { font: 400 1.2rem var(--font-slab); text-decoration: none; }
.admin-brand span { margin-left: 6px; padding: 2px 8px; background: var(--yellow); color: var(--ink); border-radius: 999px; font: 700 .7rem var(--font-body); text-transform: uppercase; letter-spacing: .1em; vertical-align: middle; }
.admin-bar .link-button { color: var(--cream); }
.admin { max-width: 1180px; margin: 0 auto; padding: 18px 16px 48px; display: grid; gap: 16px; }
.flash { padding: 10px 14px; border-radius: 8px; font-weight: 600; background: #e3eddf; color: var(--green); border: 1px solid #b9cdb2; }
.flash-error { background: #f6e1de; color: var(--red); border-color: #e3b6af; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { display: grid; gap: 2px; padding: 12px 14px; background: #fff; border: 1px solid #ddd5c0; border-left: 5px solid var(--crew, var(--brown)); border-radius: 10px; }
.stat span { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #5f5b54; }
.stat small { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--gray); }
.stat strong { font: 400 1.8rem/1.1 var(--font-slab); color: var(--ink); }
.stat em { font-style: normal; font-size: .78rem; color: var(--red); font-weight: 600; }
.stat-total { background: var(--green); border-color: var(--green); }
.stat-total span, .stat-total strong { color: var(--cream); }
.stat-muted strong { color: var(--gray); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; }
.search { display: flex; gap: 8px; align-items: center; flex: 1 1 280px; }
.search input { flex: 1; min-height: 38px; padding: 6px 12px; border: 2px solid var(--ink); border-radius: 999px; font: 500 .95rem var(--font-body); background: #fff; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.toolbar-actions .btn-small:not(.btn-ghost) { background: var(--yellow); }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid #ddd5c0; border-radius: 12px; }
.people { width: 100%; border-collapse: collapse; font-size: .92rem; }
.people th { position: sticky; top: 0; padding: 10px 12px; background: var(--paper); text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: #5f5b54; white-space: nowrap; }
.people td { padding: 8px 12px; border-top: 1px solid #eee7d6; vertical-align: middle; white-space: nowrap; }
.people tr:hover td { background: #fcfaf3; }
.person { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; }
.person img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; border: 1px solid #ddd5c0; }
.mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--gray); }
.people select { min-height: 34px; padding: 4px 8px; border: 1.5px solid #bdb6a6; border-radius: 8px; font: 500 .9rem var(--font-body); background: #fff; }
.role { min-width: 92px; min-height: 32px; padding: 4px 10px; border: 1.5px solid #bdb6a6; border-radius: 999px; background: #fff; font: 600 .82rem var(--font-body); cursor: pointer; }
.role:disabled { opacity: .45; cursor: not-allowed; }
.role-impostor { background: var(--red); border-color: var(--red); color: #fff; }
.empty { padding: 40px; text-align: center; color: var(--gray); background: #fff; border-radius: 12px; border: 1px dashed #ccc3ab; }
/* Roles stay covered until a committee member deliberately reveals them (screen sharing, onlookers).
   A neutral cover rather than blur, since a blurred red pill still gives the impostor away. */
.secret { position: relative; }
.page-admin:not(.show-secret) .secret > * { visibility: hidden; }
.page-admin:not(.show-secret) .secret::after {
  content: "Tersembunyi"; position: absolute; inset: 0; display: grid; place-items: center;
  background: #efe9d9; border-radius: 999px; color: var(--gray); font: 600 .72rem var(--font-body); letter-spacing: .04em;
}
.stat em.secret { min-height: 1.3em; }
.page-admin:not(.show-secret) .stat em.secret::after { inset: 0 auto 0 0; padding: 0 10px; }
.headline-cta { display: flex; width: fit-content; margin: 14px auto 6px; }
