/* Pujoy Pulse - shared styles.
   Written phone first: promoters work on a 360px screen in daylight, so touch
   targets are 48px, body text never drops below 16px (Android zooms the page
   in when a focused input is smaller), and nothing is allowed to push the page
   sideways. */

*, *::before, *::after { box-sizing: border-box; }

:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  --gold: #c28a00;
  --gold-dark: #8a6500;
  --line: #e6dfd0;
  --panel: #fffdf8;
  --ink: #222222;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #ffffff;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

img { max-width: 100%; }
[hidden] { display: none !important; }

/* ---------- public page: Season 4 artwork + Shobar Mazaa Meter ----------

   Two pieces of artwork, one for each screen shape: a tall 1125x2000 for
   phones and a wide 2000x1125 for desktops. The browser picks by aspect
   ratio, and the stage takes the matching shape, so neither is ever
   stretched or cropped. The meter is placed as a percentage of the artwork
   and sized in container units, so it lands in the same spot at any size. */

body.season {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  background: #e9f3fa;
  overflow: hidden;
}

/* Fills the space beside the artwork with the artwork's own colours rather
   than dead blue, on screens whose shape does not match it exactly. */
body.season::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: url("/season4-tall.jpg") center / cover no-repeat;
  filter: blur(48px) saturate(1.15);
  transform: scale(1.15);
  opacity: .55;
}
body.season::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: #e9f3facc;
}

.stage {
  position: relative;
  z-index: 1;
  container-type: inline-size;
  width: min(100vw, calc(100dvh * 1125 / 2000));
  aspect-ratio: 1125 / 2000;
  max-height: 100dvh;
}

.stage-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* The tall artwork's headline ends at 75.2%; below that is clear until the
   decorative border at 96%. */
.meter {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 78%;
  text-align: center;
}

.meter-title {
  margin: 0;
  color: #844f25;                /* the brown of SHOBAR PUJO */
  font-size: clamp(1.1rem, 5.4cqw, 2.6rem);
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
  line-height: 1.1;
}

.meter-count {
  margin-top: .2em;
  color: #159852;                /* DS Group logo green, sampled from the artwork */
  font-size: clamp(3rem, 17cqw, 9rem);
  font-weight: 900;
  line-height: .95;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 #ffffff, 0 6px 18px #15985226;
}

/* Landscape screens get the wide artwork. Its headline ends at 73%, and the
   band from 78% to 93% is clear right across. */
@media (min-aspect-ratio: 1/1) {
  body.season::before { background-image: url("/season4-wide.jpg"); }

  .stage {
    width: min(100vw, calc(100dvh * 2000 / 1125));
    aspect-ratio: 2000 / 1125;
  }

  /* Keep clear of the decorative border, which starts at 95%. */
  .meter { top: 75.5%; left: 4%; right: 4%; }
  .meter-title { font-size: clamp(1rem, 1.9cqw, 2rem); }
  .meter-count { font-size: clamp(2.2rem, 5.6cqw, 6.5rem); }
}

/* ---------- promoter and admin pages ---------- */

body.app {
  padding: 1rem max(.75rem, env(safe-area-inset-left)) max(1rem, env(safe-area-inset-bottom));
}

.app-shell { max-width: 720px; margin: 0 auto; }
.admin-shell { max-width: 960px; margin: 0 auto; }

.app-shell h1, .admin-shell h1 { font-size: 1.35rem; margin: .4rem 0 .5rem; }
.app-shell h2, .admin-shell h2 { font-size: 1.1rem; margin: 0 0 .75rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  margin: .75rem 0;
}

#message { min-height: 1.4em; margin: .25rem 0 .5rem; color: var(--gold-dark); font-size: .95rem; }

/* Fields: full width, never wider than their panel, 16px so Android does not
   zoom the page in when one is focused. */
input, select, textarea {
  font: inherit;
  font-size: 1rem;
  width: 100%;
  min-height: 48px;
  padding: .6rem .75rem;
  border: 1px solid #d9d0bd;
  border-radius: 10px;
  background: #fff;
}

form { display: grid; gap: .7rem; }

/* Buttons: text sized to the button, not lost inside it. Full width only
   where the button is the main action of a form. */
button {
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  min-height: 48px;
  padding: .65rem 1.1rem;
  border: 0;
  border-radius: 10px;
  background: var(--gold);
  color: #fff;
  cursor: pointer;
  line-height: 1.2;
}
button:active { filter: brightness(.94); }

.ghost, .secondary {
  background: #fff;
  color: var(--gold-dark);
  border: 1px solid var(--gold);
}
.link-button {
  background: transparent;
  color: var(--gold-dark);
  border: 0;
  min-height: 0;
  padding: .35rem 0;
  text-align: left;
  text-decoration: underline;
  font-weight: 500;
}

/* Any group of side-by-side buttons. Wraps instead of running off the screen. */
.row-buttons { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.row-buttons button { flex: 0 1 auto; }

.password-field { display: flex; gap: .5rem; align-items: stretch; }
.password-field input { flex: 1; min-width: 0; }
.toggle-password {
  background: #fff7df;
  color: var(--gold-dark);
  border: 1px solid #d9d0bd;
  white-space: nowrap;
  padding: .65rem .9rem;
  flex: 0 0 auto;
}

/* ---------- tables ---------- */

/* Five columns never fit a phone. The table keeps its own scrollbar so the
   page itself never moves sideways, and the header stays put while the rows
   move under it. */
.table-scroll {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 55vh;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
table { width: 100%; border-collapse: collapse; min-width: 34rem; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid #eee4d4; font-size: .95rem; white-space: nowrap; }
thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff7df;
  color: var(--gold-dark);
}
td button { min-height: 38px; padding: .35rem .7rem; font-size: .85rem; }
tbody tr:last-child td { border-bottom: 0; }

/* The promoter's four columns fit a phone once the name is allowed to wrap,
   so that table needs no sideways scroll at all - only the admin's six do. */
.entries-panel table { min-width: 0; }
.entries-panel th, .entries-panel td { padding: .55rem .4rem; }
.entries-panel td:first-child { white-space: normal; overflow-wrap: anywhere; }
.entries-panel td:last-child { white-space: nowrap; }
.entries-panel td button { padding: .3rem .55rem; }

/* ---------- promoter page: form stays, list scrolls ---------- */

/* The entry form is the thing a promoter uses all day, so it holds its place
   at the top and only the list of entries moves. */
@media (min-height: 520px) {
  body.promoter { height: 100dvh; overflow: hidden; }
  body.promoter .app-shell { height: 100%; display: flex; flex-direction: column; }
  body.promoter #app-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  body.promoter .entry-panel { flex: 0 0 auto; }
  body.promoter .entries-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  body.promoter .entries-panel .table-scroll { flex: 1; min-height: 0; max-height: none; }
}

/* ---------- login details card ---------- */

.credentials {
  margin-top: 1rem;
  border: 2px solid #c98a00;
  border-radius: 12px;
  padding: 1rem;
  background: #fffdf5;
}
.credentials h3 { margin: 0 0 .75rem; font-size: 1.05rem; }
.credentials .rows { display: grid; grid-template-columns: max-content 1fr; gap: .4rem .9rem; margin: 0; }
.credentials dt { font-weight: 600; color: var(--gold-dark); }
.credentials dd { margin: 0; min-width: 0; }
.credentials code {
  background: #fff3cd;
  padding: .15rem .4rem;
  border-radius: 4px;
  font-size: 1rem;
  overflow-wrap: anywhere;
}
.credentials .warn { color: #a33; font-weight: 600; margin: .75rem 0; font-size: .95rem; }
.credentials .muted { color: var(--gold-dark); }
.credentials .small { font-size: .85rem; }

/* ---------- admin submissions filter ---------- */

#filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
}
#filter-form select, #filter-form input { flex: 1 1 10rem; width: auto; min-width: 0; }
#filter-form button { flex: 0 0 auto; }
#submission-total { margin: .75rem 0 .25rem; font-weight: 600; }

@media print {
  body * { visibility: hidden; }
  .credentials .printable, .credentials .printable * { visibility: visible; }
  .credentials .printable { position: absolute; left: 0; top: 0; }
}

/* Consent tick - sits between the mobile number and the score, and unlocks it.
   Deliberately unmissable: a promoter should not be able to tick it by accident. */
.consent {
  display: flex;
  gap: .7rem;
  align-items: flex-start;
  padding: .75rem .8rem;
  border: 1px solid #d9d0bd;
  border-left: 4px solid var(--gold);
  border-radius: 10px;
  background: #fff7df;
  font-size: .9rem;
  line-height: 1.45;
  color: #4a3c1a;
  cursor: pointer;
}
.consent input[type="checkbox"] {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  min-height: 0;
  margin: 0;
  padding: 0;
  accent-color: var(--gold);
}
.consent span { min-width: 0; }
input:disabled {
  background: #f4f1ea;
  color: #9a9384;
  cursor: not-allowed;
}

/* Link to the Terms sits just under the consent tick. Outside the label, so
   tapping it opens the document instead of ticking the box. */
.consent-link { margin: -.2rem 0 0; text-align: right; }
.consent-link a { color: var(--gold-dark); font-size: .9rem; font-weight: 600; }

/* ---------- Terms & Conditions page ---------- */
.legal h1 { margin-bottom: .25rem; }
.legal h2 {
  font-size: 1rem;
  margin: 1.25rem 0 .35rem;
  color: var(--gold-dark);
}
.legal p { margin: 0 0 .75rem; line-height: 1.6; font-size: .95rem; }
.legal .panel > p:first-child { margin-top: 0; }
.legal-meta { color: #6b6255; font-size: .85rem; margin: 0 0 2rem; }

/* Small Terms link in the corner of the public page. Deliberately quiet - the
   artwork is the page - but always reachable, and clear of the phone's own
   gesture bar. */
.terms-chip {
  position: fixed;
  z-index: 2;
  right: max(.6rem, env(safe-area-inset-right));
  bottom: max(.6rem, env(safe-area-inset-bottom));
  padding: .35rem .7rem;
  border-radius: 999px;
  border: 1px solid #844f2540;
  background: #ffffffd9;
  color: #844f25;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .01em;
  text-decoration: none;
  backdrop-filter: blur(4px);
}
.terms-chip:hover, .terms-chip:focus-visible { background: #fff; border-color: #844f25; }
