/* Primavera Pictures brand: copper primary, gold secondary, Roboto headings, Poppins body.
   The scene (blurred grass hero, white grass fringe, animated film grain) is copied from the
   main site's maintenance page: the photo is shown as-is, not tinted. */
:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --fg: #303030;
  --muted: #6b6558;
  --border: #e6dccd;
  --brand: #ca8051;          /* primary: buttons */
  --brand-text: #020101;     /* text on brand buttons */
  --brand-strong: #9e5d2e;   /* links and focus (readable on white) */
  --gold: #e5bd60;           /* secondary: card tops, accents */
  --yellow: #fce340;         /* accent: highlights */
  --page: #ffffff;           /* page background below the scene (maintenance page: white) */
  --sky: #40b2fc;            /* colour behind the grass photo */
  --green: #69e560;          /* section background the photo is laid over */
  --grain-filter: none;      /* dark mode inverts the grain */
  --scene-photo-filter: blur(5px);
  --grain-opacity: 0.5;      /* the main site uses 1; reduced so text stays easier to read */
  --hero: min(55vh, 480px);  /* height of the grass scene */
  --ok-bg: #e8f4ea;
  --ok-fg: #1d5e35;
  --err-bg: #fbe9e7;
  --err-fg: #8a1f11;
  --info-bg: #fdf6d6;
  --info-fg: #4a3f10;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1a17;
    --card: #26231f;
    --fg: #f3efe8;
    --muted: #b9b1a3;
    --border: #3d3830;
    --brand-strong: #e8a57a;
    --page: #1c1a17;
    --green: #1f3b63;
    --grain-filter: invert(1);
    --scene-photo-filter: blur(5px) brightness(0.45) saturate(0.6);
    --ok-bg: #1d3327;
    --ok-fg: #9fe0b5;
    --err-bg: #3a1f1b;
    --err-fg: #ffb8ab;
    --info-bg: #3a3413;
    --info-fg: #fbe9a0;
  }
}

:root[data-theme="dark"] {
  --bg: #1c1a17;
  --card: #26231f;
  --fg: #f3efe8;
  --muted: #b9b1a3;
  --border: #3d3830;
  --brand-strong: #e8a57a;
  --page: #1c1a17;
  --green: #1f3b63;
  --grain-filter: invert(1);
  --scene-photo-filter: blur(5px) brightness(0.45) saturate(0.6);
  --ok-bg: #1d3327;
  --ok-fg: #9fe0b5;
  --err-bg: #3a1f1b;
  --err-fg: #ffb8ab;
  --info-bg: #3a3413;
  --info-fg: #fbe9a0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--fg);
  font: 400 16px/1.6 "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}

/* Signed-in pages keep the grass as a slim band; the login page shows the full scene. */
body.signed-in { --hero: min(26vh, 220px); }

/* ---- Scene: grass hero + white fringe, as on the maintenance page ---- */
.scene {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--hero);
  background: var(--green);
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
}
/* The photo is at 50% opacity over the green, as the main site's section overlay does,
   which is what gives the grass its green tint. */
.scene-photo {
  position: absolute;
  inset: -24px; /* oversize so the blur does not fade the edges */
  background: var(--sky) url("/assets/grass.jpg") center / cover no-repeat;
  filter: var(--scene-photo-filter);
  opacity: 0.5;
}
/* The grass edge is the SVG used as a mask, filled with the page colour, so it is white in
   light mode and the page's dark brown in dark mode. */
/* The mask lives on the child so the blur on the parent softens the masked edge; a filter on
   the masked element itself would be clipped back to the hard edge. */
.scene-fringe {
  position: absolute;
  left: 0;
  right: 0;
  height: clamp(60px, 9vw, 120px);
  /* Hangs 40% of its own height below the hero, so the grass tips stay visible at every width. */
  bottom: calc(clamp(60px, 9vw, 120px) * -0.4);
  filter: blur(1px); /* light softening of the fringe edge */
}
.scene-fringe::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--page);
  -webkit-mask: url("/assets/grass-white.svg") bottom left / auto 100% repeat-x;
  mask: url("/assets/grass-white.svg") bottom left / auto 100% repeat-x;
}

/* Film grain: animated overlay on top of the whole page, as the main site does. */
.grain {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 201;
  background: url("/assets/grain.png");
  background-size: 15em;
  pointer-events: none;
  filter: var(--grain-filter);
  opacity: var(--grain-opacity);
  animation: grain 8s steps(10) infinite;
}
@keyframes grain {
  0%, 100% { background-position: 0% 0%; }
  10% { background-position: -50% -100%; }
  20% { background-position: -150% 50%; }
  30% { background-position: 70% -250%; }
  40% { background-position: -50% 250%; }
  50% { background-position: -150% 100%; }
  60% { background-position: 150% 0%; }
  70% { background-position: 0% 150%; }
  80% { background-position: 30% 350%; }
  90% { background-position: -100% 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
}

/* ---- Header sits on the grass ---- */
.site-header {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
}

.brand { display: inline-flex; align-items: center; }
.brand img { height: 96px; width: auto; display: block; border-radius: 4px; }

/* Light logo (black lettering) in light mode, dark logo (white lettering) in dark mode. */
.brand .logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand .logo-light { display: none; }
  :root:not([data-theme="light"]) .brand .logo-dark { display: block; }
}
:root[data-theme="dark"] .brand .logo-light { display: none; }
:root[data-theme="dark"] .brand .logo-dark { display: block; }

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 8px 14px;
  background: var(--card);
  border-radius: 999px;
  font-family: "Roboto", sans-serif;
  font-weight: 500;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 50%;
}
.theme-toggle:hover { background: var(--bg); }
.theme-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* Moon in light mode, sun in dark mode: each shows the theme the click switches to. */
.theme-toggle .icon-sun { display: none; }
.theme-toggle[aria-pressed="true"] .icon-sun { display: block; }
.theme-toggle[aria-pressed="true"] .icon-moon { display: none; }
.site-header a { color: var(--brand-strong); text-decoration: none; }
.site-header a:hover, .site-header a:focus { text-decoration: underline; }

/* Heading set on the grass hero itself (sign-in page). White reads on the photo in both themes. */
.hero-title {
  position: absolute;
  top: calc(var(--hero) * 0.6);
  left: 0;
  right: 0;
  transform: translateY(-50%);
  margin: 0;
  padding: 0 16px;
  text-align: center;
  font-size: clamp(2rem, 5vw, 3.2rem);
  color: #fff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

/* Content starts below the grass hero: the header (about 90px) sits on the grass, and the
   content begins just past the bottom of the hero, clearing the white fringe. */
main {
  position: relative;
  max-width: 1100px;
  margin: calc(var(--hero) - 70px) auto 0;
  padding: 16px 16px 48px;
}

h1, h2 {
  font-family: "Roboto", system-ui, sans-serif;
  font-weight: 600;
  line-height: 1.2;
}
h1 { font-size: 1.6rem; margin: 8px 0 16px; }
h2 { font-size: 1.2rem; margin: 0 0 12px; }

/* ---- Components ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--gold);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 16px;
}
.card.narrow { max-width: 420px; margin-left: auto; margin-right: auto; }

label { display: block; margin-bottom: 12px; font-weight: 500; }
input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
input:focus, select:focus, textarea:focus, button:focus, a:focus {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

button, .button {
  display: inline-block;
  padding: 9px 16px;
  font: 500 15px "Roboto", sans-serif;
  color: var(--brand-text);
  background: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { background: #b9734a; border-color: #b9734a; }
button.secondary, .button.secondary {
  background: transparent;
  color: var(--brand-strong);
  border-color: var(--brand-strong);
}
button.secondary:hover, .button.secondary:hover { background: var(--bg); }

table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-family: "Roboto", sans-serif; font-weight: 500; font-size: 0.9rem; }

.table-wrap { overflow-x: auto; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; border-left: 4px solid transparent; }
.flash-success { background: var(--ok-bg); color: var(--ok-fg); border-left-color: var(--ok-fg); }
.flash-error { background: var(--err-bg); color: var(--err-fg); border-left-color: var(--err-fg); }
.flash-info { background: var(--info-bg); color: var(--info-fg); border-left-color: var(--yellow); }

.muted { color: var(--muted); font-size: 0.9rem; }
.inline { display: inline; }
.actions form { display: inline-block; margin: 0 6px 6px 0; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }

/* Sizes to the QR image itself (qrcodejs sets its own width/height). A fixed size clipped it. */
.qr { display: table; margin: 0 auto 12px; background: #fff; padding: 12px; border-radius: 6px; }
.qr img, .qr canvas, .qr table { display: block; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom: 3px solid var(--brand);
  border-radius: 8px;
  padding: 14px;
}
.stat strong { display: block; font: 600 1.7rem "Roboto", sans-serif; color: var(--brand-strong); }

@media (max-width: 600px) {
  main { padding: 12px 12px 40px; }
  th, td { padding: 6px; font-size: 0.9rem; }
  .brand img { height: 72px; }
}
