/* MealDealz shared brand layer: design tokens, base, components.
 *
 * Canonical source of the look shared by both public web surfaces: the
 * marketing site (web/landing/, served by Caddy) and the account-action page
 * (web/public/, served by Firebase Hosting). Neither host can reach this
 * directory, so byte-identical copies are committed as web/landing/brand.css
 * and web/public/brand.css. Edit this file only, then run
 *
 *     python scripts/check_web_shared_styles.py --write
 *
 * to refresh the copies. CI fails while a copy differs (same script without
 * --write).
 *
 * Every page links brand.css first and its own styles.css second, so page
 * layout stays per site and may override a token. This layer holds no page
 * layout and no fixed widths. Components are prefixed `md-` so they cannot
 * collide with the page classes of either site.
 *
 * Self-contained by design: system fonts only, no @import, no remote url(),
 * so both Content Security Policies (style-src 'self') hold unchanged.
 *
 * Brand palette matches the app theme (mobile/lib/src/theme/app_theme.dart):
 * forest green #2E7D32 seed, bright green #74D67E in the dark scheme. */

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  color-scheme: light dark;

  --brand: #2e7d32;
  --brand-bright: #43a047;
  --brand-dark: #1b5e20;
  --on-brand: #ffffff;
  /* Brand green for text and outlines on --bg, --surface and the glow
     (--brand itself drops below 4.5:1 on the light glow). */
  --brand-ink: #24692a;
  /* Primary button fill; white label at least 5:1 across the gradient. */
  --button-from: #2e7d32;
  --button-to: #276c2b;

  /* Warm accent. Reserved for the primary app-store call to action
     (.md-button-store) and nothing else; label at least 4.5:1. */
  --accent: #c2410c;
  --accent-hover: #9a3412;
  --on-accent: #ffffff;

  --bg: #f2f8f2;
  --surface: #ffffff;
  --surface-2: #f7faf7;
  --text: #12241a;
  --muted: #4c5c50;
  --border: #d8e6d8;
  /* Boundary of form fields; at least 3:1 against --surface and --surface-2
     (WCAG 1.4.11). --border is decorative and too faint for that. */
  --input-border: #738377;
  --error: #c62828;
  --error-bg: #fdecea;
  --ok: #2e7d32;

  /* Keyboard focus indicator; at least 3:1 against --surface and --bg. */
  --focus: #2e7d32;
  /* Soft halo for text fields, which show focus through border + halo. */
  --ring: 0 0 0 3px rgba(46, 125, 50, 0.28);

  --radius-lg: 24px;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 10px 40px -12px rgba(18, 36, 26, 0.22),
    0 2px 8px -2px rgba(18, 36, 26, 0.08);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #74d67e;
    --brand-bright: #8ee397;
    --brand-dark: #205227;
    --on-brand: #0f1311;
    --brand-ink: #74d67e;
    --button-from: #8ee397;
    --button-to: #74d67e;

    --accent: #fb923c;
    --accent-hover: #fdba74;
    --on-accent: #0f1311;

    --bg: #0f1311;
    --surface: #1c2220;
    --surface-2: #232a26;
    --text: #e4e6e2;
    --muted: #bcc4bd;
    --border: #313833;
    --input-border: #7c877f;
    --error: #f28b82;
    --error-bg: #2a1b1a;
    --ok: #74d67e;

    --focus: #74d67e;
    --ring: 0 0 0 3px rgba(116, 214, 126, 0.3);

    --shadow: 0 16px 48px -12px rgba(0, 0, 0, 0.6),
      0 2px 8px -2px rgba(0, 0, 0, 0.4);
  }
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Ambient brand light over the base: depth without a flat grey slab. */
  background-color: var(--bg);
  background-image: radial-gradient(
    120% 90% at 50% -10%,
    color-mix(in srgb, var(--brand) 16%, var(--bg)),
    var(--bg) 60%
  );
  background-repeat: no-repeat;
}

/* One visible keyboard focus indicator for every interactive element. A page
   may restyle it, but never remove it without a replacement. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ── Components ─────────────────────────────────────────────────────────── */

/* Elevated content card with the thin brand ribbon along its top edge.
   Width and padding belong to the page. */
.md-panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: md-rise 0.4s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.md-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--brand-bright));
}

@keyframes md-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

/* The app logo inside <picture> (light and dark variant). The width/height
   attributes reserve the aspect ratio; the page sets the rendered height. */
.md-logo {
  display: block;
  width: auto;
  max-width: 100%;
}

/* Full-width, rounded, brand-green primary action (button or link). */
.md-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  padding: 0 20px;
  font: inherit;
  font-size: 16px;
  font-weight: 650;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  color: var(--on-brand);
  background: linear-gradient(180deg, var(--button-from), var(--button-to));
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--brand) 70%, transparent);
  transition:
    filter 0.18s ease,
    transform 0.06s ease,
    box-shadow 0.18s ease;
}

.md-button:hover:not(:disabled) {
  filter: brightness(1.05);
  text-decoration: none;
  box-shadow: 0 8px 22px -6px color-mix(in srgb, var(--brand) 75%, transparent);
}

.md-button:active:not(:disabled) {
  transform: translateY(1px);
}

.md-button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Quiet companion action: surface fill with a brand-green outline and label
   (both at least 3:1 and 4.5:1 against the surface). */
.md-button-secondary {
  color: var(--brand-ink);
  background: var(--surface);
  border: 1.5px solid var(--brand-ink);
  box-shadow: none;
}

.md-button-secondary:hover:not(:disabled) {
  filter: none;
  background: color-mix(in srgb, var(--brand) 10%, var(--surface));
  box-shadow: none;
}

/* The primary app-store call to action: the only place the warm accent
   appears on either site. */
.md-button-store {
  color: var(--on-accent);
  background: var(--accent);
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent);
}

.md-button-store:hover:not(:disabled) {
  filter: none;
  background: var(--accent-hover);
  box-shadow: 0 8px 22px -6px color-mix(in srgb, var(--accent) 75%, transparent);
}

/* ── Reduced motion ─────────────────────────────────────────────────────── */
/* Ends every animation and transition at once (their end state stays), and
   turns smooth scrolling off. No element is exempt: a progress indicator
   pairs its graphic with a text or role="status" message, which stays the
   signal while the graphic stands still. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }
}
