/* FlareDays site: shared tokens, type, components and the sign-up form.
   Mobile first: base styles are for phones, then min-width 600px (md) and 960px (lg). */

/* ---------- Fonts (self-hosted, SIL Open Font License, see fonts/OFL.txt) ---------- */

@font-face {
  font-family: "Manrope";
  src: url("fonts/manrope-latin-wght.woff2") format("woff2");
  font-weight: 500 800;
  font-style: normal;
  font-display: swap;
}

/* ---------- Color tokens ---------- */

:root, [data-theme="dusk"] {
  color-scheme: dark;
  --bg: #15172c;
  --bg-deep: #0f1022;
  --glow: #2a2557;
  --surface: #20244a;
  --surface-2: #2a2f5c;
  --line: #363c70;
  --field-line: #8b88c2;
  --ink: #f4f1fb;
  --ink-2: #bdb8dc;
  --accent: #ffb38a;
  --accent-hover: #ffc4a3;
  --on-accent: #2b1a10;
  --error: #ff8a7a;
  --error-tint: #312535;
  --error-line: rgba(255, 138, 122, .45);
  --success: #6fd6a8;
  --success-tint: rgba(111, 214, 168, .16);
  --peach-tint: rgba(255, 179, 138, .16);
  --lilac: #b9a6ff;  --lilac-tint: rgba(185, 166, 255, .16);
  --coral: #ff8a7a;  --on-coral: #2a0f0b;
  --care: #c3b1ff;   --on-care: #1b1446;
  --work: #8ea2ff;   --blk-work: #282d4e;
  --home: #f4c06a;   --blk-home: #393236;
  --rest: #6fd6a8;   --blk-rest: #23363f;
  --plan: #ffb38a;
  --cell-used: #4a5190;
  --card-border: 1px solid var(--line);
  --card-shadow: none;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #fbf7f1;
  --bg-deep: #f1e9dd;
  --glow: #f3e6d6;
  --surface: #ffffff;
  --surface-2: #f4ede3;
  --line: #e7ded2;
  --field-line: #857a6e;
  --ink: #2e2a33;
  --ink-2: #5f5866;
  --accent: #4f7461;
  --accent-hover: #446554;
  --on-accent: #ffffff;
  --error: #a3452e;
  --error-tint: #f4e9e1;
  --error-line: rgba(163, 69, 46, .45);
  --success: #3d6b55;
  --success-tint: #e1eee6;
  --peach-tint: #f6e3da;
  --lilac: #6a4f8a;  --lilac-tint: #efe8f6;
  --coral: #b4553c;  --on-coral: #ffffff;
  --care: #6a4f8a;   --on-care: #ffffff;
  --work: #4f62a8;   --blk-work: #e4e8f6;
  --home: #8a6420;   --blk-home: #f5ead5;
  --rest: #3d6b55;   --blk-rest: #e1eee6;
  --plan: #a9553b;
  --cell-used: #d6c9b8;
  --card-border: 1px solid transparent;
  --card-shadow: 0 1px 2px rgba(46, 42, 51, .05), 0 8px 24px rgba(46, 42, 51, .06);
}

/* ---------- Type and layout variables ---------- */

:root {
  --font-sans: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Options override these three. */
  --font-heading: var(--font-sans);
  --heading-weight: 800;
  --heading-tracking: -0.02em;

  --text-body: 1.0625rem;
  --text-lead: 1.125rem;
  --text-small: 0.9375rem;
  --text-h3: 1.125rem;
  --gutter: 20px;
}

@media (min-width: 600px) {
  :root {
    --text-body: 1.125rem;
    --text-lead: 1.25rem;
    --text-h3: 1.1875rem;
    --gutter: 32px;
  }
}

@media (min-width: 960px) {
  :root { --gutter: 48px; }
}

/* ---------- Reset and base ---------- */

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

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: 500;
  line-height: 1.6;
  letter-spacing: 0.01em;
  word-spacing: 0.04em;
  font-synthesis: none;
  hyphens: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
}

h1, h2, h3, p, ul, ol, figure, blockquote { margin: 0; }
ul, ol { padding: 0; }

p, li, figcaption { text-wrap: pretty; }

h1, h2 {
  font-family: var(--font-heading);
  font-weight: var(--heading-weight);
  letter-spacing: var(--heading-tracking);
  word-spacing: normal;
  color: var(--ink);
  text-wrap: balance;
}

h1 { line-height: 1.08; }
h2 { line-height: 1.2; }

h3 {
  font-family: var(--font-sans);
  font-size: var(--text-h3);
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: 0;
  word-spacing: normal;
  color: var(--ink);
  text-wrap: balance;
}

b, strong { font-weight: 800; }

img, svg { display: block; }

button, input { font: inherit; letter-spacing: inherit; word-spacing: inherit; color: inherit; }

.lead {
  font-size: var(--text-lead);
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 32rem;
}

.small {
  font-size: var(--text-small);
  line-height: 1.5;
  color: var(--ink-2);
}

.wrap {
  padding-inline: var(--gutter);
}

/* ---------- Icons (inline Material Symbols Rounded, Apache 2.0) ---------- */

.icon {
  width: 1em;
  height: 1em;
  flex: none;
  fill: currentColor;
}

/* ---------- Utilities ---------- */

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ---------- Focus ---------- */

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Links ---------- */

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

a:focus-visible { border-radius: 4px; }

/* An <a> without href (the contact address before it is filled in) is not a link, so don't style it as one. */
a:not([href]) { color: inherit; text-decoration: none; }

@media (hover: hover) {
  a:hover { color: var(--accent); }
}

/* ---------- Wordmark ---------- */

.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* On subpages the wordmark links home. */
a.wordmark {
  display: inline-flex;
  min-height: 44px;
  text-decoration: none;
  border-radius: 12px;
}

@media (hover: hover) {
  a.wordmark:hover .wordmark-name { color: var(--accent); }
}

.wordmark-mark {
  width: 36px;
  height: 36px;
}

.wordmark-name {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 1.25rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
  word-spacing: normal;
  color: var(--ink);
}

@media (min-width: 600px) {
  .wordmark-mark { width: 40px; height: 40px; }
  .wordmark-name { font-size: 1.375rem; }
}

.wordmark-small { gap: 8px; }
.wordmark-small .wordmark-mark { width: 28px; height: 28px; }
.wordmark-small .wordmark-name { font-size: 1.0625rem; }

/* ---------- Kicker ---------- */

.kicker {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  max-width: 100%;
  padding: 6px 14px 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  color: var(--ink);
  font-size: var(--text-small);
  font-weight: 700;
  line-height: 1.4;
}

.kicker-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: 20px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  padding: 0 24px;
  border-radius: 18px;
  border: 2px solid transparent;
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.01em;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}

.btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 18px;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-secondary {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}

@media (hover: hover) {
  .btn-primary:hover { background: var(--accent-hover); color: var(--on-accent); }
  .btn-secondary:hover { background: var(--accent); color: var(--on-accent); }
}

/* A <button> that looks like a link. */
.link-button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 1rem;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  cursor: pointer;
}

.link-button:focus-visible { border-radius: 4px; }

@media (hover: hover) {
  .link-button:hover { color: var(--ink); }
}

/* ---------- Privacy line (about the app) ---------- */

.privacy-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: var(--text-small);
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 36rem;
}

.privacy-line > span { min-width: 0; }

.privacy-line .icon {
  width: 20px;
  height: 20px;
  margin-top: 1px;
  color: var(--success);
}

/* ---------- Closing band (B and C) ---------- */

.closing h2 { margin-bottom: 12px; }
.closing p { max-width: 32rem; }
.closing .btn { margin-top: 24px; }

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding-top: 32px;
  padding-bottom: 40px;
}

.site-footer .wordmark { margin-bottom: 8px; }

.site-footer p {
  font-size: var(--text-small);
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 36rem;
}

.site-footer p + p { margin-top: 4px; }

.footer-links {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0 24px;
  margin-bottom: 12px;
}

/* At least 44px tall (WCAG 2.5.8). */
.footer-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: var(--text-small);
  font-weight: 700;
}

.site-footer p a { color: var(--ink); }

@media (min-width: 960px) {
  .site-footer { padding-bottom: 56px; }
}

/* ---------- Sign-up form ---------- */

.signup {
  max-width: 34rem;
  scroll-margin-top: 24px;
  text-align: left;
}

.signup-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.signup-label {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.4;
  color: var(--ink);
}

.signup-input {
  display: block;
  width: 100%;
  height: 56px;
  margin: 8px 0 0;
  padding: 0 16px;
  border-radius: 14px;
  border: 2px solid var(--field-line);
  background: var(--surface);
  color: var(--ink);
  caret-color: var(--accent);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  word-spacing: normal;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .15s ease;
}

.signup-input:-webkit-autofill,
.signup-input:-webkit-autofill:hover,
.signup-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  box-shadow: 0 0 0 100px var(--surface) inset;
}

@media (hover: hover) {
  .signup-input:hover { border-color: var(--ink-2); }
}

.signup-input:focus {
  border-color: var(--accent);
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.signup-input[aria-invalid="true"],
.signup-input[aria-invalid="true"]:hover,
.signup-input[aria-invalid="true"]:focus {
  border-color: var(--error);
}

.signup-input[readonly] { color: var(--ink-2); }

.signup-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 8px;
  color: var(--error);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.45;
}

.signup-error .icon {
  width: 20px;
  height: 20px;
  margin-top: 2px;
}

.signup-error-text { min-width: 0; overflow-wrap: anywhere; }

/* Both labels sit in the same grid cell, so the button keeps the width of the wider
   ("Join the waiting list") while sending, without a fixed pixel width. Only the visible
   label is part of the button's accessible name. */
.signup-button {
  display: grid;
  grid-template-areas: "label";
  place-items: center;
  width: 100%;
  margin-top: 12px;
}

.signup-button > .btn-label,
.signup-button > .btn-busy { grid-area: label; }

.btn-busy {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  visibility: hidden;
}

.signup-button.is-busy .btn-label { visibility: hidden; }
.signup-button.is-busy .btn-busy { visibility: visible; }

.signup-button[aria-disabled="true"] { cursor: progress; }
.signup-button[aria-disabled="true"]:active { transform: none; }

.btn-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--on-accent);
  border-right-color: transparent;
  flex: none;
  animation: fd-spin .8s linear infinite;
}

.signup-button:not(.is-busy) .btn-spinner { animation: none; }

@keyframes fd-spin { to { transform: rotate(360deg); } }

.signup-hint {
  margin-top: 12px;
  font-size: var(--text-small);
  line-height: 1.5;
  color: var(--ink-2);
}

/* Shown only without JavaScript (noscript.css). It is a normal element, not <noscript>, so the
   Worker can fill in the contact address. */
.signup-nojs {
  display: none;
  grid-column: 1 / -1;
  margin-top: 12px;
  font-size: var(--text-small);
  line-height: 1.5;
  color: var(--ink-2);
}

.signup-alert {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--error-tint);
  border: 1px solid var(--error-line);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.5;
}

.signup-alert .icon {
  width: 24px;
  height: 24px;
  color: var(--error);
}

.signup-alert b { font-weight: 800; }

@media (min-width: 600px) {
  .signup-form {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "label label"
      "input button"
      "error error"
      "hint hint"
      "alert alert";
    column-gap: 10px;
  }
  .signup-label { grid-area: label; }
  .signup-input { grid-area: input; }
  .signup-error { grid-area: error; }
  .signup-button { grid-area: button; width: auto; margin-top: 8px; }
  .signup-hint { grid-area: hint; }
  .signup-alert { grid-area: alert; }
  /* Without JavaScript there is no alert, so its row holds the note, after the hint as in the markup. */
  .signup-nojs { grid-row: 5; }
}

/* Success panel */

.signup-done {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 16px;
  padding: 20px;
  background: var(--surface);
  border: var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: 20px;
}

.signup-done.is-entering { animation: fd-enter .2s ease-out; }

@keyframes fd-enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.signup-done-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--success-tint);
  color: var(--success);
}

.signup-done-icon .icon { width: 28px; height: 28px; }

.signup-done-title {
  font-family: var(--font-heading);
  font-weight: var(--heading-weight);
  letter-spacing: var(--heading-tracking);
  font-size: 1.375rem;
  line-height: 1.25;
  color: var(--ink);
  outline: none;
}

.signup-done-text {
  margin-top: 4px;
  color: var(--ink-2);
}

.signup-done-email {
  color: var(--ink);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.signup-again { margin-top: 4px; }

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html:focus-within { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .btn-spinner { display: none !important; }
  .btn:active { transform: none; }
}

/* ---------- Forced colors (Windows contrast themes) ---------- */

@media (forced-colors: active) {
  .btn, .signup-input, .kicker, .card, .signup-done, .signup-alert { border-color: CanvasText; }
  .btn { border: 2px solid ButtonText; }
  .btn-spinner { border-color: ButtonText; border-right-color: transparent; }
  :focus-visible, .signup-input:focus, .btn:focus-visible { outline-color: Highlight; }
  .kicker-dot { background: CanvasText; }
  .icon { fill: currentColor; }
}
