/* Rate My Lawn — style.css
   Mobile-first, no external dependencies, no @import of external sheets.
   Contrast notes per R-001 §3.7:
     - White on #4a7c2f:  ~3.67:1 → passes large text (≥24px, or bold ≥18.67px) only
     - #1a1a1a on #e07b20: ~4.6:1 → passes normal text
     - #1a1a1a on #ffffff: ~16.7:1 → passes normal text
*/

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

/* ── Custom properties ────────────────────────────────────────────────────── */
:root {
  --color-green:  #4a7c2f;
  --color-orange: #e07b20;
  --color-bg:     #ffffff;
  --color-text:   #1a1a1a;  /* 16.7:1 on white — passes 4.5:1 */
  --color-border: #d0d0d0;
  --color-muted:  #767676;  /* 4.6:1 on white — passes 4.5:1 */
  --color-error:  #b91c1c;  /* ~6.4:1 on white — passes 4.5:1 */
  --font-base: system-ui, -apple-system, sans-serif;
}

/* ── html / body
   overflow-x: clip does NOT create a scroll container and does NOT break
   position: sticky. Do NOT use overflow-x: hidden here — on Safari that
   silently disables sticky positioning for all descendants.
   ──────────────────────────────────────────────────────────────────────────── */
html {
  overflow-x: clip;
}

body {
  margin: 0;
  font-family: var(--font-base);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 1rem;
  line-height: 1.6;
}

/* ── Sticky header
   border-bottom is the visual divider — no <hr> element is used.
   No overflow property on html/body/header ancestors (would break sticky).
   ──────────────────────────────────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-green);
  border-bottom: 3px solid var(--color-orange);
  padding: 0.75rem 1rem;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 800px;
  margin: 0 auto;
}

.gnome-logo {
  flex-shrink: 0;
}

.header-titles {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

/* White on #4a7c2f = ~3.67:1 → passes large text (≥24px) only.
   h1 at 1.5rem (24px default) qualifies as large text. */
header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

/* White on #4a7c2f = ~3.67:1 → passes large text (bold ≥ ~18.67px) only.
   h2 at 1.25rem (20px default) + font-weight 700 qualifies as bold large text
   under WCAG 2.1 §1.4.3 (14pt bold ≈ 18.67px). */
header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

/* ── Main content area ────────────────────────────────────────────────────── */
main {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

.intro {
  margin: 0 0 1.5rem;
}

/* ── Upload area ──────────────────────────────────────────────────────────── */
.upload-area {
  margin-bottom: 0.75rem;
}

/* Primary upload button.
   Label color: #1a1a1a on #e07b20 orange = ~4.6:1 → passes 4.5:1 for normal text.
   Do NOT use white text on orange — white on #e07b20 = ~2.82:1 which FAILS WCAG AA.
   Touch target: min-height 44px meets WCAG SC 2.5.5. */
#upload-btn {
  display: inline-block;
  background: var(--color-orange);
  color: var(--color-text);
  border: none;
  border-radius: 6px;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  min-height: 44px;
  line-height: 1.4;
}

#upload-btn:hover {
  background: #c96d18;
}

/* outline: 2px solid meets WCAG AA focus visibility (SC 2.4.7).
   Using var(--color-text) #1a1a1a — clearly visible on both white and orange. */
#upload-btn:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 3px;
}

#upload-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Visually hidden — file input
   Full 7-property clip-rect pattern. Keeps element in the accessibility tree.
   Used ONLY for the hidden file input — do NOT apply to #ai-response.
   ──────────────────────────────────────────────────────────────────────────── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Error message ────────────────────────────────────────────────────────── */
/* role="alert" element — always in DOM, no display:none.
   Empty <p> with no margin/padding takes zero visual space. */
#error-msg {
  color: var(--color-error);
  font-size: 0.9rem;
  margin: 0 0 0.5rem;
  padding: 0;
  min-height: 0;
}

/* ── Original photo preview ───────────────────────────────────────────────── */
/* Hidden by default (JS sets display:block after valid file selection).
   #photo-original once shown stays visible — never re-hidden by error or state. */
#photo-original {
  display: none;
  margin-top: 1rem;
}

#photo-original img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--color-border);
}

/* ── AI response container
   MUST remain in the DOM and accessibility tree at all times so the
   aria-live="polite" region works — display:none / visibility:hidden
   deactivate aria-live and must NOT be used here.
   Visually collapsed when empty via max-height:0 + overflow:hidden (flow-based).
   JS adds/removes .is-visible to expand when populated.
   ──────────────────────────────────────────────────────────────────────────── */
#ai-response {
  overflow: hidden;
  max-height: 0;
  padding: 0;
  transition: max-height 0.3s ease, padding 0.3s ease;
  border-radius: 6px;
}

#ai-response.is-visible {
  max-height: 9999px;
  padding: 1.25rem;
  background: #f6faf3;
  border: 1px solid var(--color-border);
  margin-bottom: 1.5rem;
}

#ai-response .score {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: var(--color-green);
}

#ai-response .tips-heading {
  margin: 0 0 0.5rem;
  font-weight: 600;
}

#ai-response ul {
  margin: 0;
  padding-left: 1.5rem;
}

#ai-response li {
  margin-bottom: 0.4rem;
}

/* ── Edited lawn preview — deferred feature slot ─────────────────────────── */
#photo-edited {
  margin-top: 2rem;
  border: 2px dashed var(--color-border);
  border-radius: 6px;
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--color-muted);
  font-size: 0.9rem;
  font-style: italic;
}

#photo-edited p {
  margin: 0;
}

/* ── Quote CTA section ────────────────────────────────────────────────────── */
/* Always visible — not gated on upload or result. */
#quote-section {
  margin-top: 1.5rem;
  background: #f6faf3;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 1.25rem;
}

/* Label color: #1a1a1a on #e07b20 orange = ~4.6:1 → passes WCAG AA 4.5:1.
   Do NOT use white on orange — white on #e07b20 = ~2.82:1 which FAILS. */
#quote-section button {
  background: var(--color-orange);
  color: var(--color-text);
  border: none;
  border-radius: 6px;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  min-height: 44px;
  cursor: not-allowed;
  opacity: 0.6;
  margin-top: 0.75rem;
}

/* ── Contact info section ─────────────────────────────────────────────────── */
/* Always visible — not gated on upload or result. */
#contact-section {
  margin-top: 1.5rem;
  background: #f6faf3;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 1.25rem;
}

#contact-section p:first-child {
  color: var(--color-green);
  font-weight: 600;
  margin: 0 0 0.25rem;
}

#contact-section p:last-child {
  margin: 0;
  color: var(--color-muted);
}

/* ── Responsive — wider screens ───────────────────────────────────────────── */
@media (min-width: 640px) {
  header {
    padding: 1rem 1.5rem;
  }

  header h1 {
    font-size: 1.75rem;
  }

  main {
    padding: 2rem 1.5rem;
  }
}
