/* ===================================================
   WebToNative – Shared Design System
   • iOS input-zoom fix  (font-size ≥ 16px)
   • Unified back-home bar
   • Clean typography & inputs
   • Responsive helpers
   =================================================== */

:root {
  --brand:        #FF5A5A;
  --brand-dk:     #e03a3a;
  --brand-lt:     #fff0f0;
  --blue:         #2563eb;
  --blue-dk:      #1d4ed8;
  --green:        #16a34a;
  --green-lt:     #f0fdf4;
  --bg:           #f8f9fa;
  --surface:      #ffffff;
  --border:       #e2e8f0;
  --text:         #1e293b;
  --muted:        #64748b;
  --r-sm:         6px;
  --r:            10px;
  --r-lg:         14px;
  --shadow:       0 1px 4px rgba(0,0,0,0.08);
  --shadow-md:    0 4px 14px rgba(0,0,0,0.13);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ── iOS zoom fix ──────────────────────────────────
   iOS Safari zooms any focused input whose computed
   font-size is < 16px. Force 16px across the board.
   ─────────────────────────────────────────────── */
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]):not([type=button]):not([type=submit]):not([type=reset]),
select,
textarea {
  font-size: 16px !important;
}

/* ── Back-home bar (overrides inline body <style>) ── */
.back-home-bar {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  height: 52px !important;
  z-index: 9000 !important;
  display: flex !important;
  align-items: center !important;
  padding: 0 16px !important;
  background: #ffffff !important;
  border-bottom: 1px solid var(--border) !important;
  box-shadow: var(--shadow) !important;
  gap: 10px;
}

.back-home-btn {
  background: var(--brand) !important;
  color: #fff !important;
  border-radius: var(--r-sm) !important;
  padding: 7px 15px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  text-decoration: none !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  line-height: 1 !important;
  border: none !important;
  cursor: pointer !important;
  font-family: inherit !important;
  transition: background 0.15s !important;
  -webkit-tap-highlight-color: transparent;
}

.back-home-btn:hover,
.back-home-btn:active {
  background: var(--brand-dk) !important;
  color: #fff !important;
  text-decoration: none !important;
}

/* Push body down when back bar is present */
body:has(.back-home-bar) {
  padding-top: 56px !important;
}

/* Raw content pages (no wrapper) — give the page some breathing room */
body:has(.back-home-bar) > h1:first-of-type,
body:has(.back-home-bar) > h2:first-of-type,
body:has(.back-home-bar) > h3:first-of-type,
body:has(.back-home-bar) > p:first-of-type {
  padding-left: 16px;
  padding-right: 16px;
}

body:has(.back-home-bar) > label,
body:has(.back-home-bar) > input,
body:has(.back-home-bar) > button,
body:has(.back-home-bar) > select,
body:has(.back-home-bar) > textarea {
  margin-left: 16px;
  margin-right: 16px;
}

/* ── Input / Select / Textarea visuals ── */
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]):not([type=button]):not([type=submit]):not([type=reset]),
select,
textarea {
  border-radius: var(--r-sm);
  border: 1.5px solid #d1d5db;
  padding: 9px 12px;
  background: var(--surface);
  color: var(--text);
  line-height: 1.45;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}

input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]):not([type=button]):not([type=submit]):not([type=reset]):focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255,90,90,0.13);
}

/* ── .button class (used in frontend.html & others) ── */
.button {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 9px 18px !important;
  min-height: 40px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  border-radius: var(--r-sm) !important;
  border: none !important;
  cursor: pointer !important;
  text-decoration: none !important;
  font-family: inherit !important;
  transition: filter 0.15s, transform 0.1s !important;
  -webkit-tap-highlight-color: transparent;
}

.button:active {
  transform: scale(0.97) !important;
}

/* ── Generic button baseline (pages with unstyled buttons) ── */
button:not(.back-home-btn):not(.copy-btn):not([class]) {
  border-radius: var(--r-sm);
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

button:not(.back-home-btn):not(.copy-btn):not([class]):active {
  transform: scale(0.97);
}

/* ── Container ── */
.container {
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 16px;
  padding-right: 16px;
}

/* ── Log / terminal result boxes ── */
.log,
#log {
  border-radius: var(--r-sm) !important;
  font-family: "SF Mono", Menlo, Monaco, "Cascadia Code", Consolas, monospace !important;
  font-size: 12px !important;
  line-height: 1.55 !important;
}

/* ── Section / box borders ── */
:where([style*="border: 2px solid"]),
:where([style*="border: 3px solid"]),
:where([style*="border: 4px solid"]),
:where([style*="border: 5px solid"]) {
  border-radius: var(--r) !important;
}

/* ── Headings ── */
h1 { font-size: clamp(1.2rem, 4vw, 1.75rem); line-height: 1.3; }
h2 { font-size: clamp(1rem, 3vw, 1.35rem); line-height: 1.3; }
h3 { font-size: clamp(0.9rem, 2.5vw, 1.1rem); line-height: 1.4; }

/* ── Scrollbar (WebKit) ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .container {
    padding-left: 12px;
    padding-right: 12px;
  }

  h1 { font-size: 1.2rem; }
  h2 { font-size: 1rem; }
  h3 { font-size: 0.9rem; }
}

/* ── Focus visible (accessibility) ── */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
