/* ==========================================================================
   Mobile-first UI — tuned for Safari, Chrome, Edge
   - Comfortable gutters (no text hugging edges)
   - Readable type with clamp()
   - Touch-friendly controls (44px minimum)
   - Sticky, translucent header; mobile nav becomes pill links
   - Cards & sections spaced so content "pops"
   ========================================================================== */

:root {
  /* Colors */
  --primary: #0f172a;
  --secondary: #64748b;
  --accent: #3b82f6;
  --muted: #94a3b8;
  --bg: #ffffff;
  --border: #e2e8f0;

  /* Layout */
  --wrap-max: 1200px;
  --gutter: clamp(16px, 5vw, 28px); /* stronger mobile gutters */

  /* Radius & shadows */
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(2, 6, 23, 0.06);
  --shadow-md: 0 2px 6px rgba(2, 6, 23, 0.08), 0 1px 1px rgba(2,6,23,0.04);
  --shadow-lg: 0 10px 30px rgba(2, 6, 23, 0.10), 0 1px 1px rgba(2,6,23,0.04);

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
}

/* --------------------------------------------------------------------------
   Base / Reset
   -------------------------------------------------------------------------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  line-height: 1.65;
  color: var(--primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;

  /* Respect iOS safe areas */
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
  padding-bottom: env(safe-area-inset-bottom);
}

/* Media elements scale down */
img, svg, video, canvas { display: block; max-width: 100%; height: auto; }

/* Links */
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration: underline; }

/* Wrapper keeps content off edges on all screens */
.wrap {
  max-width: var(--wrap-max);
  margin-inline: auto;
  padding-inline: 0; /* gutters are on body; wrap caps width */
}
.inner { padding-block: var(--space-6); }

/* --------------------------------------------------------------------------
   Typography — mobile-first sizes with clamp()
   -------------------------------------------------------------------------- */
.h1 {
  font-size: clamp(1.5rem, 6vw, 2.75rem);
  font-weight: 700; line-height: 1.15; margin-bottom: var(--space-6);
}
.h2 {
  font-size: clamp(1.25rem, 4.8vw, 1.75rem);
  font-weight: 700; line-height: 1.2; margin-bottom: var(--space-4);
}
.lead { font-size: clamp(1rem, 3.8vw, 1.25rem); color: var(--secondary); margin-bottom: var(--space-6); }
.muted { color: var(--muted); font-size: 0.925rem; }
p { margin-bottom: var(--space-4); }

/* Give long text a comfy measure on very wide screens */
@media (min-width: 1024px) {
  p { max-width: 70ch; }
}

/* Vertical rhythm between common blocks */
.h2 + p, .lead + p { margin-top: var(--space-2); }

/* --------------------------------------------------------------------------
   Layout helpers
   -------------------------------------------------------------------------- */
.grid { display: grid; gap: var(--space-7); }
.cols-2 { grid-template-columns: 1fr; }
@media (min-width: 768px) { .cols-2 { grid-template-columns: 1fr 1fr; } }

.row { display: flex; flex-wrap: wrap; gap: var(--space-4); margin-block: var(--space-4); }
.row.cols-2 > * { flex: 1 1 280px; }

/* Sections (optional semantic elements) */
section, article { padding-block: var(--space-7); }

/* --------------------------------------------------------------------------
   Cards & Surfaces
   -------------------------------------------------------------------------- */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-7);
  box-shadow: var(--shadow-md);
}
.card:hover { box-shadow: var(--shadow-lg); }

.gate {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-6) 0;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
label { display: block; font-weight: 600; margin-bottom: var(--space-2); }

input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;          /* prevents Safari zoom on focus */
  min-height: 44px;         /* touch target */
  margin-bottom: var(--space-4);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

textarea { resize: vertical; min-height: 100px; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 999px;               /* pill look = pop */
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  font-size: 16px;
  min-height: 44px;
  transition: transform .06s ease, box-shadow .2s ease, background .2s ease, color .2s ease, border-color .2s ease;
}

.btn {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 16px rgba(59,130,246,0.25);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(59,130,246,0.35); }
.btn:active { transform: translateY(0); }

.btn-ghost {
  background: #f8fafc;
  color: var(--accent);
  border-color: var(--border);
}
.btn-ghost:hover { background: #eef2f7; }

/* Small utility button */
.help-btn {
  padding: 10px 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  min-height: 44px;
  transition: background .2s ease, box-shadow .2s ease;
}
.help-btn:hover { background: #eef2f7; box-shadow: var(--shadow-sm); }

/* --------------------------------------------------------------------------
   Lists
   -------------------------------------------------------------------------- */
.clean { list-style: none; }
.clean li { margin: 10px 0; padding-left: 26px; position: relative; }
.clean li:before { content: '>'; position: absolute; left: 0; top: 0; color: var(--accent); font-weight: 800; }

/* Helpful grid list (auto-fit) */
.help-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding: var(--space-4);
  background: #f8fafc;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   Feedback / Meta
   -------------------------------------------------------------------------- */
.error {
  background: #fef2f2;
  color: #dc2626;
  padding: var(--space-4);
  border-radius: var(--radius);
  border: 1px solid #fecaca;
  margin: var(--space-3) 0;
  box-shadow: var(--shadow-sm);
}

.foot { color: var(--muted); font-size: 0.9rem; line-height: 1.6; }
.foot p { margin: 8px 0; }

/* --------------------------------------------------------------------------
   Header & Navigation
   - Sticky translucent header
   - Mobile: horizontal scrollable "pills" (no cramming)
   -------------------------------------------------------------------------- */
header {
  position: sticky; top: 0; z-index: 100;
  border-bottom: 1px solid var(--border);

  /* Translucent on supported browsers for nice depth */
  background: rgba(255,255,255,0.88);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
}

/* Inner: column on mobile, row on larger screens */
header .inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-block: var(--space-3);
}

/* Mobile nav as scrollable chips */
nav {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;            /* Firefox hide */
}
nav::-webkit-scrollbar { display: none; } /* Safari/Chrome hide */

nav a {
  flex: 0 0 auto;
  scroll-snap-align: start;
  text-decoration: none;
  font-weight: 600;
  color: var(--secondary);
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 14px;
  white-space: nowrap;
}
nav a:hover { color: var(--primary); background: #eef2f7; }

/* Larger layouts: nav goes inline and loses pill background */
@media (min-width: 768px) {
  header .inner { flex-direction: row; align-items: center; justify-content: space-between; }
  nav { overflow: visible; padding-bottom: 0; }
  nav a {
    background: transparent; border: none; border-radius: 8px;
    padding: 8px 6px; white-space: normal;
  }
  nav a:hover { background: #f7fafc; }
}

/* --------------------------------------------------------------------------
   Responsive refinements
   -------------------------------------------------------------------------- */
@media (min-width: 640px) {
  .card { padding: var(--space-7); }
  .inner { padding-block: var(--space-7); }
}

@media (min-width: 768px) {
  body {
    padding-left: max(var(--gutter), env(safe-area-inset-left));
    padding-right: max(var(--gutter), env(safe-area-inset-right));
  }
  .h1 { font-size: clamp(2rem, 3.5vw, 3rem); }
  .h2 { font-size: clamp(1.5rem, 2.2vw, 2rem); }
}

@media (min-width: 1024px) {
  .grid { gap: var(--space-8); }
  .row { gap: var(--space-6); }
}

/* --------------------------------------------------------------------------
   Accessibility: focus rings only when using keyboard
   -------------------------------------------------------------------------- */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid rgba(59,130,246,0.35);
  outline-offset: 2px;
}

/* Misc mobile niceties */
.scrollable { overflow-y: auto; -webkit-overflow-scrolling: touch; }
