/* ============================================
   19Dev — Free Online Developer Toolkit
   Main stylesheet. Modern, fast, no framework.
   ============================================ */

:root {
  --bg: #ffffff;
  --bg-alt: #f6f8fb;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --border: #e3e8f0;
  --border-strong: #cdd5e2;
  --text: #0b1a2e;
  --text-muted: #4a5b75;
  --text-dim: #74829a;
  --primary: #1c6df2;
  --primary-hover: #155cd1;
  --primary-soft: #e8f0ff;
  --accent: #00b3ff;
  --accent-hover: #0094d6;
  --navy: #0b1a2e;
  --navy-2: #122544;
  --success: #18b15a;
  --warning: #e9a016;
  --danger: #e23838;
  --code-bg: #0f1c33;
  --code-text: #d6e3f5;
  --shadow-sm: 0 1px 2px rgba(11, 26, 46, 0.06);
  --shadow: 0 6px 24px rgba(11, 26, 46, 0.08);
  --shadow-lg: 0 20px 60px rgba(11, 26, 46, 0.12);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
  --maxw: 1240px;
  --header-h: 64px;
}

[data-theme="dark"] {
  --bg: #0a1426;
  --bg-alt: #0f1c33;
  --bg-elev: #142241;
  --surface: #142241;
  --border: #1f3257;
  --border-strong: #2a4373;
  --text: #eaf1fb;
  --text-muted: #aab9d2;
  --text-dim: #7e8ea8;
  --primary: #4a8eff;
  --primary-hover: #6ba3ff;
  --primary-soft: #1a2c52;
  --accent: #38c5ff;
  --code-bg: #050d1c;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

code, pre, .mono { font-family: var(--font-mono); }

pre { margin: 0; }

h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: 1.25; color: var(--text); margin: 0 0 .5em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }

p { margin: 0 0 1em; }

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.center { text-align: center; }
.flex { display: flex; }
.between { justify-content: space-between; }
.center-y { align-items: center; }
.gap-1 { gap: 8px; } .gap-2 { gap: 12px; } .gap-3 { gap: 16px; } .gap-4 { gap: 24px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; } .mb-4 { margin-bottom: 32px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.header-row {
  display: flex;
  align-items: center;
  gap: 24px;
  height: var(--header-h);
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}
.brand img { height: 40px; width: auto; display: block; }
.brand:hover { text-decoration: none; }
.brand-text { display: none; }

.nav { display: flex; gap: 4px; align-items: center; margin-left: auto; }
.nav a {
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.93rem;
  transition: all 0.15s;
}
.nav a:hover { background: var(--bg-alt); color: var(--text); text-decoration: none; }
.nav a.active { color: var(--primary); background: var(--primary-soft); }

.nav-toggle {
  display: none;
  background: none;
  border: 0;
  padding: 8px;
  cursor: pointer;
  color: var(--text);
  font-size: 1.3rem;
}

.theme-toggle {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text);
  font-size: 0.95rem;
}
.theme-toggle:hover { background: var(--primary-soft); border-color: var(--primary); }

@media (max-width: 820px) {
  .nav-toggle { display: inline-flex; }
  .nav {
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--surface);
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s;
  }
  .nav.open { max-height: 600px; }
  .nav a { padding: 10px 12px; }
  .nav-search { width: 100%; }
}

/* ---------- Search ---------- */
.nav-search {
  position: relative;
  flex: 0 1 280px;
  min-width: 0;
}
.nav-search input {
  width: 100%;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px 8px 34px;
  font-size: 0.9rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.nav-search input:focus { border-color: var(--primary); background: var(--surface); }
.nav-search::before {
  content: "🔍";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  pointer-events: none;
  opacity: 0.6;
}
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 360px;
  overflow: auto;
  display: none;
  z-index: 200;
}
.search-results.open { display: block; }
.search-result {
  display: block;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
}
.search-result:last-child { border-bottom: 0; }
.search-result:hover { background: var(--bg-alt); text-decoration: none; }
.search-result .sr-cat { color: var(--text-dim); font-size: 0.78rem; }
.search-result mark { background: #fff3a3; color: var(--text); padding: 0 2px; border-radius: 2px; }

/* ---------- Hero ---------- */
.hero {
  background:
    radial-gradient(1200px 600px at 80% -100px, rgba(28,109,242,0.18), transparent 60%),
    radial-gradient(800px 400px at 0% 100%, rgba(0,179,255,0.12), transparent 60%),
    linear-gradient(180deg, #061229 0%, #0b1a2e 60%, #0a1426 100%);
  color: #fff;
  padding: 56px 0 64px;
  position: relative;
  overflow: hidden;
}
.hero h1 { color: #fff; font-size: clamp(2rem, 5vw, 3.2rem); }
.hero h1 .accent { color: var(--accent); }
.hero p.lead { color: #c7d2e3; font-size: 1.1rem; max-width: 640px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.hero-stats {
  margin-top: 36px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  max-width: 720px;
}
.hero-stat {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 14px 16px;
  backdrop-filter: blur(6px);
}
.hero-stat .num { font-size: 1.4rem; font-weight: 800; color: var(--accent); }
.hero-stat .lbl { color: #aab9d2; font-size: 0.85rem; }

.hero-banner {
  width: 100%;
  border-radius: var(--radius-lg);
  margin-top: 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.05s;
  white-space: nowrap;
  font-family: inherit;
}
.btn:hover { background: var(--primary-hover); color: #fff; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-outline { background: transparent; border: 1.5px solid rgba(255,255,255,0.4); color: #fff; }
.btn-outline:hover { background: rgba(255,255,255,0.1); color: #fff; border-color: #fff; }
.btn-ghost { background: var(--bg-alt); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-lg { padding: 12px 22px; font-size: 1rem; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #c22828; }

/* ---------- Section ---------- */
.section { padding: 56px 0; }
.section-sm { padding: 32px 0; }
.section-title { text-align: center; margin-bottom: 12px; }
.section-sub { text-align: center; color: var(--text-muted); max-width: 700px; margin: 0 auto 36px; }

/* ---------- Tool cards grid ---------- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.tool-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.tool-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
  text-decoration: none;
}
.tool-card .icon {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-weight: 700;
}
.tool-card h3 { font-size: 1rem; margin: 0; }
.tool-card p { color: var(--text-muted); font-size: 0.85rem; margin: 0; line-height: 1.45; }

/* Category group */
.category-section { margin-bottom: 32px; }
.category-header {
  display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}
.category-header h2 { margin: 0; font-size: 1.4rem; }
.category-header .count { color: var(--text-dim); font-size: 0.85rem; }

/* ---------- Tool page layout ---------- */
.tool-wrap { padding: 24px 0 56px; }
.tool-header { margin-bottom: 18px; }
.tool-header .crumbs { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 8px; }
.tool-header .crumbs a { color: var(--text-muted); }
.tool-header h1 { margin-bottom: 6px; }
.tool-header p { color: var(--text-muted); margin: 0; max-width: 720px; }

.tool-actions {
  display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0;
}

.io-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.io-grid > .pane { min-width: 0; }
@media (max-width: 880px) { .io-grid { grid-template-columns: 1fr; } }

.pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.pane-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 0.9rem;
}
.pane-head .pane-actions { display: flex; gap: 6px; }
.pane-body { flex: 1; min-height: 0; }

textarea.io {
  width: 100%;
  min-height: 340px;
  border: 0;
  outline: 0;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.5;
  padding: 14px;
  background: var(--code-bg);
  color: var(--code-text);
  tab-size: 2;
}
textarea.io:focus { background: #0a1530; }

pre.io {
  width: 100%;
  min-height: 340px;
  max-height: 600px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.io.readonly { background: var(--code-bg); }

/* When the output is an image (SVG / data URI) */
pre.io.image-output {
  background: #ffffff;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  white-space: normal;
  word-break: normal;
  font-family: var(--font-sans);
}
pre.io.image-output svg,
pre.io.image-output img {
  max-width: 100%;
  height: auto;
  display: block;
  background: #fff;
}
pre.io.image-output .img-caption {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  background: var(--bg-alt);
  padding: 8px 12px;
  border-radius: 6px;
  max-width: 100%;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  text-align: left;
}

.options {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.options label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }
.options input[type="text"],
.options input[type="number"],
.options select {
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}
.options input:focus, .options select:focus { border-color: var(--primary); }
.options .checkbox { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.options .checkbox input { width: 16px; height: 16px; }

.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--navy);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* Status / info banner */
.notice {
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 18px;
}
.notice.warn { background: #fff7e0; border-color: var(--warning); }
.notice.danger { background: #fde7e7; border-color: var(--danger); }
[data-theme="dark"] .notice.warn { background: #2a1f0a; }
[data-theme="dark"] .notice.danger { background: #2a1010; }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--navy);
  color: #c7d2e3;
  padding: 48px 0 24px;
  margin-top: 56px;
}
.site-footer a { color: #c7d2e3; }
.site-footer a:hover { color: #fff; }
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  gap: 32px;
  margin-bottom: 32px;
}
@media (max-width: 720px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
.footer-col h4 { color: #fff; font-size: 0.95rem; margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col li { padding: 4px 0; }
.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 20px;
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center;
  font-size: 0.85rem; color: #aab9d2;
}
.footer-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.footer-brand img { height: 44px; width: auto; filter: brightness(0) invert(1); }
.footer-brand strong { color: #fff; font-size: 1.1rem; }

.wa-fab {
  position: fixed; right: 20px; bottom: 20px;
  background: #25D366; color: #fff;
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  box-shadow: var(--shadow-lg);
  z-index: 90;
  text-decoration: none;
  transition: transform 0.15s;
}
.wa-fab:hover { transform: scale(1.08); color: #fff; text-decoration: none; }

/* ---------- Reference tables ---------- */
.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.ref-table th, .ref-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.ref-table th { background: var(--bg-alt); color: var(--text); font-weight: 600; }
.ref-table code { background: var(--bg-alt); padding: 2px 6px; border-radius: 4px; font-size: 0.85em; }
.ref-table tr:hover td { background: var(--bg-alt); }

.ref-search {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 1rem;
  margin-bottom: 18px;
  color: var(--text);
}
.ref-search:focus { outline: 0; border-color: var(--primary); }

/* ---------- Color tools ---------- */
.color-swatch {
  display: flex; align-items: center; gap: 12px;
  padding: 10px;
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}
.color-swatch .swatch { width: 40px; height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--border); flex: 0 0 auto; }
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }

.gradient-preview {
  height: 90px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

/* ---------- Drag & drop file area ---------- */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-alt);
  cursor: pointer;
  transition: all 0.15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); color: var(--text); }
.dropzone .big { font-size: 2.4rem; margin-bottom: 10px; }

/* ---------- QR canvas ---------- */
.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 18px; }
.qr-canvas { background: #fff; padding: 12px; border-radius: var(--radius); }

/* ---------- Misc ---------- */
.kbd {
  display: inline-block;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 0.8em;
  color: var(--text);
}

.tag {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.divider { height: 1px; background: var(--border); margin: 28px 0; }

.preview-frame {
  width: 100%;
  min-height: 300px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

/* Tags pill (category chips on home) */
.cat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  margin: 4px;
  transition: all 0.15s;
}
.cat-chip:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); text-decoration: none; }

.cat-chip .num { background: var(--primary); color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 0.7rem; font-weight: 700; }

/* Lighthouse-friendly focus styles */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* Print friendliness */
@media print {
  .site-header, .site-footer, .wa-fab, .tool-actions, .pane-head, .options, .notice { display: none; }
  body { background: #fff; color: #000; }
  pre.io { background: #fff; color: #000; border: 1px solid #000; }
}
