/* ==========================================================================
   styles.css: the look of the form.

   Colors are var(--name) placeholders. The script in index.html fills them
   in from the theme in form-config.js. The values in :root are only a
   fallback. To change colors, edit the theme, not this file.
   ========================================================================== */

:root {
  --brand: #1F4F9E;
  --brand-light: #7AAADF;
  --accent: #163D7A;
  --bg: #EEF4FB;
  --text: #0E2A52;
  --border: #B7CDE8;
  --error: #B42318;
  --button-text: #fff;
  --button-radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

/* The page stays hidden while main.js loads the events marketing has published, so
   visitors never see the default colors flash before an event's own. main.js sets
   data-ready on <html> when the page is dressed. It waits up to 15 s for the events
   (bad signal at a show); if anything goes wrong the page still appears by itself
   after 16 s. Keep 16 s just above EVENTS_WAIT_MS in main.js. */
html:not([data-ready]) body { visibility: hidden; animation: reveal 0s 16s forwards; }
@keyframes reveal { to { visibility: visible; } }

/* A grey spinner while waiting. Only appears after 0.4 s, so a fast phone never sees it
   flash; gone once the page is ready (or at 16 s). */
html:not([data-ready]) body::before {
  content: "";
  position: fixed;
  top: 50%;
  left: 50%;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border: 3px solid #D0D5DD;
  border-top-color: #667085;
  border-radius: 50%;
  visibility: visible;
  opacity: 0;
  animation: spin 0.8s linear infinite, appear 0s 0.4s forwards, gone 0s 16s forwards;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes appear { to { opacity: 1; } }
@keyframes gone { to { visibility: hidden; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Header band with logo (or company name if no logo) */
.top {
  background: var(--brand);
  border-bottom: 6px solid var(--brand-light);
  padding: 16px;
  text-align: center;
}
.top img { width: 100%; max-width: 260px; height: auto; }
.company { margin: 0; color: #fff; font-weight: 700; font-size: 1.15rem; }

/* Header decorations, picked per event (headerDecoration in form-config.js, or the
   designer's "Header decoration"). The header keeps its color underneath. On top sits a
   layer painted in --decoration-color, cut to the decoration's shapes like a stencil
   (the SVG's black parts show the color; their opacity sets how strongly). So any
   decoration works in any color. -webkit-mask is what iOS 13.4+ understands.
   To add one: copy the sprinkles block below with your own SVG shapes, then add its
   name to DECORATIONS in js/eventrules.js and to the designer's list. */
.top[data-decoration] { position: relative; padding: 24px 16px; }
.top[data-decoration]::before {
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background-color: var(--decoration-color, #fff);
  -webkit-mask-size: 120px 120px;
  mask-size: 120px 120px;
  pointer-events: none;
}
.top[data-decoration] > * { position: relative; } /* logo and name stay above the pattern */
/* Soft shadow so the company name stays readable over a pattern */
.top[data-decoration] .company { text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); }

/* Sprinkles: a 120px tile of little rounded sticks, repeated across the header. */
.top[data-decoration="sprinkles"]::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Crect x='10' y='12' width='3.5' height='12' rx='1.75' fill-opacity='1' transform='rotate(35 12 18)'/%3E%3Crect x='42' y='6' width='3.5' height='12' rx='1.75' fill-opacity='0.75' transform='rotate(-50 44 12)'/%3E%3Crect x='78' y='16' width='3.5' height='12' rx='1.75' fill-opacity='0.45' transform='rotate(80 80 22)'/%3E%3Crect x='104' y='4' width='3.5' height='12' rx='1.75' fill-opacity='1' transform='rotate(-20 106 10)'/%3E%3Crect x='24' y='44' width='3.5' height='12' rx='1.75' fill-opacity='0.6' transform='rotate(-70 26 50)'/%3E%3Crect x='60' y='40' width='3.5' height='12' rx='1.75' fill-opacity='1' transform='rotate(15 62 46)'/%3E%3Crect x='96' y='50' width='3.5' height='12' rx='1.75' fill-opacity='0.75' transform='rotate(55 98 56)'/%3E%3Crect x='6' y='78' width='3.5' height='12' rx='1.75' fill-opacity='0.45' transform='rotate(-35 8 84)'/%3E%3Crect x='40' y='82' width='3.5' height='12' rx='1.75' fill-opacity='1' transform='rotate(65 42 88)'/%3E%3Crect x='72' y='74' width='3.5' height='12' rx='1.75' fill-opacity='0.6' transform='rotate(-10 74 80)'/%3E%3Crect x='106' y='86' width='3.5' height='12' rx='1.75' fill-opacity='1' transform='rotate(40 108 92)'/%3E%3Crect x='22' y='104' width='3.5' height='12' rx='1.75' fill-opacity='0.75' transform='rotate(85 24 110)'/%3E%3Crect x='58' y='100' width='3.5' height='12' rx='1.75' fill-opacity='0.45' transform='rotate(-60 60 106)'/%3E%3Crect x='88' y='104' width='3.5' height='10' rx='1.75' fill-opacity='1' transform='rotate(20 90 109)'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Crect x='10' y='12' width='3.5' height='12' rx='1.75' fill-opacity='1' transform='rotate(35 12 18)'/%3E%3Crect x='42' y='6' width='3.5' height='12' rx='1.75' fill-opacity='0.75' transform='rotate(-50 44 12)'/%3E%3Crect x='78' y='16' width='3.5' height='12' rx='1.75' fill-opacity='0.45' transform='rotate(80 80 22)'/%3E%3Crect x='104' y='4' width='3.5' height='12' rx='1.75' fill-opacity='1' transform='rotate(-20 106 10)'/%3E%3Crect x='24' y='44' width='3.5' height='12' rx='1.75' fill-opacity='0.6' transform='rotate(-70 26 50)'/%3E%3Crect x='60' y='40' width='3.5' height='12' rx='1.75' fill-opacity='1' transform='rotate(15 62 46)'/%3E%3Crect x='96' y='50' width='3.5' height='12' rx='1.75' fill-opacity='0.75' transform='rotate(55 98 56)'/%3E%3Crect x='6' y='78' width='3.5' height='12' rx='1.75' fill-opacity='0.45' transform='rotate(-35 8 84)'/%3E%3Crect x='40' y='82' width='3.5' height='12' rx='1.75' fill-opacity='1' transform='rotate(65 42 88)'/%3E%3Crect x='72' y='74' width='3.5' height='12' rx='1.75' fill-opacity='0.6' transform='rotate(-10 74 80)'/%3E%3Crect x='106' y='86' width='3.5' height='12' rx='1.75' fill-opacity='1' transform='rotate(40 108 92)'/%3E%3Crect x='22' y='104' width='3.5' height='12' rx='1.75' fill-opacity='0.75' transform='rotate(85 24 110)'/%3E%3Crect x='58' y='100' width='3.5' height='12' rx='1.75' fill-opacity='0.45' transform='rotate(-60 60 106)'/%3E%3Crect x='88' y='104' width='3.5' height='10' rx='1.75' fill-opacity='1' transform='rotate(20 90 109)'/%3E%3C/svg%3E");
}

main { max-width: 480px; margin: 0 auto; padding: 20px 16px 40px; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 4px 0 6px; }
.sub { margin: 0 0 20px; }

/* The white card the fields sit on */
form {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 16px;
}

/* Two fields side by side (first/last name, state/ZIP) */
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.row.state-zip { grid-template-columns: 1fr 2fr; }

.field { margin-bottom: 14px; }
label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 4px; }

/* 16px text stops iPhones from zooming in when a field is tapped */
input:not([type="checkbox"]) {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 12px;
  color: var(--text);
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 8px;
}
input:focus { outline: 3px solid var(--brand-light); outline-offset: 1px; border-color: var(--brand); }
input[aria-invalid="true"] { border-color: var(--error); }

.error { color: var(--error); font-size: 0.9rem; margin: 4px 0 0; }
.error:empty { display: none; }
.form-error { margin: 0 0 12px; font-weight: 600; }

/* Optional address group */
fieldset { border: 0; padding: 0; margin: 8px 0 0; }
legend { font-weight: 700; padding: 0; margin-bottom: 8px; }

/* Checkbox rows */
.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-weight: 400;
  font-size: 0.9rem;
  margin: 6px 0 14px;
}
.check input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }

/* The submit button. Its colors, corners and fill come from the event's theme
   (theme.js): --accent, --button-text, --button-radius and data-button-fill. */
button {
  width: 100%;
  padding: 12px;
  margin-top: 6px;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--button-text);
  background: var(--accent);
  border: 2px solid var(--accent);
  border-radius: var(--button-radius);
  cursor: pointer;
}
:root[data-button-fill="outline"] button { background: transparent; color: var(--accent); }
button:disabled { opacity: 0.7; cursor: wait; }

/* Spam trap: moved off-screen so people never see it, but bots do */
.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

#thanks-screen { text-align: center; padding-top: 24px; }
#thanks-headline:focus { outline: none; }

/* ==========================================================================
   One event's own look (written by hand; marketing can't do this in the designer).
   main.js labels the page with the event shown: <html data-event="fall-gala-2027">.
   Start every rule with that label so it touches only that event, put pictures in
   public/images/, check it at /?src=fall-gala-2027 (the designer's preview doesn't
   show it), then push. Delete the rules once the event is over. Example:

   html[data-event="fall-gala-2027"] .top { background: url(images/leaves.jpg) center / cover; }
   html[data-event="fall-gala-2027"] body { font-family: Georgia, serif; }

   Event labels are lowercase. Fields can't be added or removed this way, only restyled.
   ========================================================================== */
