/* ============================================================
   shared.css  —  HTMLTools design system
   All pages import this file. App-specific overrides go in
   a separate <style> block or linked stylesheet per app.
   ============================================================ */

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand palette */
  --accent:     #4f8ef7;
  --accent-dim: #3a74db;
  --bg:         #111214;
  --surface:    #1c1e22;
  --surface2:   #23262d;
  --surface3:   #2a2d35;
  --border:     #2e3138;
  --text:       #e4e6ea;
  --muted:      #7a7f8a;

  /* Nav */
  --nav-h: 52px;

  /* Badge colours */
  --badge-aaa-bg:   rgba(99,102,241,0.18);
  --badge-aaa-fg:   #a5b4fc;
  --badge-aa-bg:    rgba(34,197,94,0.18);
  --badge-aa-fg:    #4ade80;
  --badge-aal-bg:   rgba(251,191,36,0.15);
  --badge-aal-fg:   #fbbf24;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  /* leave room for fixed nav */
  padding-top: var(--nav-h);
  /* push footer to bottom */
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ── Top navigation bar ───────────────────────────────────── */
#site-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: rgba(17,18,20,0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 6px;
  z-index: 1000;
  overflow: hidden;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  margin-right: 10px;
  white-space: nowrap;
  text-decoration: none;
}

.nav-brand svg {
  width: 22px; height: 22px;
  fill: var(--accent);
  flex-shrink: 0;
}

.nav-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 6px;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-behavior: smooth;
  /* Add subtle fade on edges to indicate scroll */
  mask-image: linear-gradient(to right, transparent, black 20px, black calc(100% - 20px), transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, black 20px, black calc(100% - 20px), transparent);
}
.nav-links::-webkit-scrollbar { display: none; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}
.nav-link svg { width: 14px; height: 14px; fill: currentColor; flex-shrink: 0; }
.nav-link:hover { background: var(--surface2); color: var(--text); }
.nav-link.active { background: var(--surface2); color: var(--text); }
.nav-link.active::after {
  content: '';
  display: block;
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}
/* active indicator via underline on nav item */
.nav-link-wrap { position: relative; display: flex; }
.nav-link-wrap.active .nav-link { color: var(--text); }
.nav-link-wrap.active::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 8px; right: 8px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

/* ── Page layout helpers ──────────────────────────────────── */
.page-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 44px 24px 80px;
  width: 100%;
  flex: 1;
}

/* ── Page header ──────────────────────────────────────────── */
.page-header {
  text-align: center;
  margin-bottom: 32px;
}
.page-header h1 {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 5px;
}
.page-header p { color: var(--muted); font-size: 0.92rem; }

/* ── Input row ────────────────────────────────────────────── */
.input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 16px;
  width: 100%;
  max-width: 480px;
  margin-bottom: 8px;
  transition: border-color 0.2s;
}
.input-row:focus-within { border-color: var(--accent); }

.swatch-preview {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  transition: background-color 0.3s;
}

.hash { color: var(--muted); font-size: 1.1rem; font-weight: 600; user-select: none; }

.hex-input {
  flex: 1;
  background: transparent;
  border: none; outline: none;
  font-size: 1.1rem;
  font-family: 'Consolas', 'Fira Code', monospace;
  color: var(--text);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.hex-input::placeholder { color: var(--muted); letter-spacing: 1px; }

/* ── Shared button styles ─────────────────────────────────── */
.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  transition: border-color 0.2s, color 0.2s;
  white-space: nowrap;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn svg { width: 14px; height: 14px; fill: currentColor; }

.hidden-input {
  opacity: 0; width: 0; height: 0;
  position: absolute; pointer-events: none;
}

/* ── Error message ────────────────────────────────────────── */
.error-msg {
  color: #f87171;
  font-size: 0.82rem;
  margin-bottom: 12px;
  height: 16px;
  width: 100%;
  max-width: 480px;
}

/* ── Tab bar ──────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 5px;
  margin-bottom: 32px;
  width: 100%;
  max-width: 560px;
}
.tab-btn {
  flex: 1;
  background: none;
  border: none; outline: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text); background: var(--surface2); }
.tab-btn.active { background: var(--accent); color: #fff; }

/* ── Panels ───────────────────────────────────────────────── */
.panel { display: none; width: 100%; max-width: 1000px; }
.panel.active { display: block; }

/* ── Gradient strip canvas ────────────────────────────────── */
.gradient-strip {
  width: 100%; height: 52px;
  border-radius: 10px;
  margin-bottom: 28px;
  border: 1px solid var(--border);
  display: block;
}

/* ── Palette groups (comp / triadic) ──────────────────────── */
.palette-group { margin-bottom: 36px; }
.palette-group-title {
  font-size: 0.75rem; font-weight: 700;
  letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 10px;
}
.palette-group-title .color-dot {
  width: 14px; height: 14px;
  border-radius: 50%; flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.12);
}

/* ── Swatch grid ──────────────────────────────────────────── */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }

.swatch {
  position: relative;
  width: 90px; height: 90px;
  border-radius: 11px;
  cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end;
  padding-bottom: 9px;
  border: 2px solid transparent;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  overflow: hidden; user-select: none; flex-shrink: 0;
}
.swatch:hover {
  transform: translateY(-4px) scale(1.06);
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  z-index: 2;
}
.swatch.source {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.25);
}
.swatch-hex {
  font-size: 0.65rem;
  font-family: 'Consolas', 'Fira Code', monospace;
  font-weight: 600; letter-spacing: 0.5px;
  padding: 3px 6px; border-radius: 5px;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(4px);
  pointer-events: none;
}
.swatch-label {
  font-size: 0.58rem; margin-top: 3px;
  opacity: 0.75;
  font-family: 'Consolas', 'Fira Code', monospace;
  pointer-events: none;
}
.swatch::after {
  content: 'Copied!';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
  opacity: 0; border-radius: 9px;
  transition: opacity 0.2s; pointer-events: none;
}
.swatch.copied::after { opacity: 1; }

/* ── WCAG Badges ──────────────────────────────────────────── */
.badge {
  font-size: 0.55rem; font-weight: 800;
  letter-spacing: 0.5px; padding: 2px 5px; border-radius: 4px;
}
.badge-aa    { background: var(--badge-aa-bg);  color: var(--badge-aa-fg); }
.badge-aaa   { background: var(--badge-aaa-bg); color: var(--badge-aaa-fg); }
.badge-aa-large { background: var(--badge-aal-bg); color: var(--badge-aal-fg); }

/* ── Accessible tab – toolbar ─────────────────────────────── */
.access-toolbar {
  display: flex; align-items: center;
  gap: 8px; flex-wrap: wrap; margin-bottom: 20px;
}
.access-sub-tabs {
  display: flex; gap: 3px;
  background: var(--surface2); border-radius: 9px;
  padding: 3px; flex-shrink: 0;
}
.access-sub-tab {
  background: none; border: none; cursor: pointer;
  font-size: 0.78rem; font-weight: 600;
  color: var(--muted); padding: 6px 14px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.access-sub-tab.active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.filter-pills { display: flex; gap: 5px; flex-wrap: wrap; }
.filter-pill {
  background: none;
  border: 1px solid var(--border); border-radius: 99px;
  cursor: pointer;
  font-size: 0.71rem; font-weight: 700;
  color: var(--muted); padding: 4px 11px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.filter-pill:hover { border-color: var(--accent); color: var(--accent); }
.filter-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.view-toggle {
  display: flex; gap: 3px;
  background: var(--surface2); border-radius: 9px;
  padding: 3px; margin-left: auto; flex-shrink: 0;
}
.view-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); padding: 5px 7px; border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  display: flex; align-items: center;
}
.view-btn:hover { color: var(--text); }
.view-btn.active { background: var(--surface); color: var(--text); }
.view-btn svg { width: 15px; height: 15px; fill: currentColor; display: block; }
.access-count { font-size: 0.72rem; color: var(--muted); align-self: center; }

/* ── Accessible tab – grid ────────────────────────────────── */
.access-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.access-card {
  border-radius: 11px; overflow: hidden; cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  background: var(--surface);
}
.access-card:hover { transform: translateY(-3px); box-shadow: 0 10px 28px rgba(0,0,0,0.45); }
.access-card.copied { border-color: var(--accent); }
.access-card-color { height: 70px; display: flex; align-items: flex-end; padding: 6px; }
.access-card-preview-lbl {
  font-size: 0.85rem; font-weight: 700;
  padding: 2px 7px; border-radius: 5px;
  background: rgba(0,0,0,0.22);
  backdrop-filter: blur(3px); pointer-events: none;
}
.access-card-info { padding: 7px 9px 9px; }
.access-card-hex {
  font-family: 'Consolas', 'Fira Code', monospace;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 2px;
}
.access-card-ratio { font-size: 0.6rem; color: var(--muted); }
.access-card-badges { display: flex; gap: 3px; margin-top: 5px; flex-wrap: wrap; }

/* ── Accessible tab – list ────────────────────────────────── */
.access-section { margin-bottom: 36px; }
.access-section-title {
  font-size: 0.75rem; font-weight: 700;
  letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--muted); margin-bottom: 8px;
}
.access-section-desc { font-size: 0.78rem; color: var(--muted); margin-bottom: 14px; line-height: 1.5; }
.access-list { display: flex; flex-direction: column; gap: 5px; }
.access-pair {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 11px; margin-bottom: 7px;
  cursor: pointer; border: 2px solid transparent;
  transition: border-color 0.15s, transform 0.15s; min-width: 0;
}
.access-list .access-pair { padding: 9px 14px; margin-bottom: 0; }
.access-pair:hover { border-color: rgba(255,255,255,0.15); transform: translateX(4px); }
.access-pair.copied { border-color: var(--accent); }
.access-pair-swatch {
  width: 44px; height: 44px; border-radius: 8px; flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.08);
}
.access-pair-info { flex: 1; min-width: 0; }
.access-pair-hex {
  font-family: 'Consolas', 'Fira Code', monospace;
  font-size: 0.9rem; font-weight: 600; letter-spacing: 0.5px;
}
.access-pair-ratio { font-size: 0.72rem; color: var(--muted); margin-top: 2px; }
.access-pair-badges { display: flex; gap: 4px; margin-top: 5px; }
.access-pair-preview {
  font-size: 0.88rem; font-weight: 700;
  padding: 7px 14px; border-radius: 7px; white-space: nowrap; flex-shrink: 0;
}
.access-copy-icon { color: var(--muted); width: 16px; height: 16px; flex-shrink: 0; }

/* ── Misc shared ──────────────────────────────────────────── */
.no-results { color: var(--muted); font-size: 0.88rem; padding: 16px 0; }
.divider { width: 100%; height: 1px; background: var(--border); margin: 28px 0; }
.empty-state {
  color: var(--muted); font-size: 0.95rem;
  text-align: center; line-height: 1.7; padding: 40px 0;
}

/* ── Toast ────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 32px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg);
  padding: 10px 22px; border-radius: 99px;
  font-size: 0.85rem; font-weight: 600;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none; z-index: 1100; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Home / hub page cards ────────────────────────────────── */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  width: 100%; max-width: 900px;
  margin-top: 12px;
}
.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  text-decoration: none;
  color: var(--text);
  display: flex; flex-direction: column; gap: 12px;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}
.app-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 12px 36px rgba(0,0,0,0.4);
}
.app-card-icon {
  width: 60px; height: 60px;
  border-radius: 12px;
  background: rgba(79,142,247,0.12);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.app-card-icon svg { width: 32px; height: 32px; fill: var(--accent); }
.app-card h2 { font-size: 1rem; font-weight: 700; }
.app-card p { font-size: 0.82rem; color: var(--muted); line-height: 1.55; }
.app-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.app-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text);
  line-height: 1.3;
}
.app-card-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}
.app-card-tag {
  align-self: flex-start;
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.8px;
  text-transform: uppercase; padding: 3px 9px;
  border-radius: 99px; border: 1px solid var(--border); color: var(--muted);
}
.app-card-tag.new { border-color: var(--accent); color: var(--accent); background: rgba(79,142,247,0.08); }

/* ── Footer ───────────────────────────────────────────────── */
#site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: 48px 24px;
  margin-top: auto;
}

.footer-content {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-link {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 0.2s ease;
  position: relative;
}

.footer-link:hover {
  color: var(--text);
  background: var(--surface2);
}

.footer-link:not(:last-child)::after {
  content: '·';
  position: absolute;
  right: -4px;
  color: var(--border);
  pointer-events: none;
}

.footer-text {
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.footer-brand {
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.2px;
}

@media (max-width: 640px) {
  #site-footer {
    padding: 36px 20px;
  }
  
  .footer-link:not(:last-child)::after {
    content: none;
  }
  
  .footer-links {
    flex-direction: column;
    gap: 4px;
  }
  
  .footer-link {
    width: 100%;
    text-align: center;
  }
}

/* ── Hamburger menu (mobile only) ─────────────────────────── */
.nav-hamburger {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  color: var(--muted);
  transition: border-color 0.2s, color 0.2s;
  margin-left: auto;
  flex-shrink: 0;
}
.nav-hamburger:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.nav-hamburger svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  display: block;
}

.nav-mobile-menu {
  display: none;
  position: fixed;
  top: calc(var(--nav-h) + 1px);
  left: 0;
  right: 0;
  background: rgba(17,18,20,0.98);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  max-height: calc(100vh - var(--nav-h) - 1px);
  overflow-y: auto;
  z-index: 999;
  padding: 12px;
}

.nav-mobile-menu.active {
  display: block;
}

.nav-mobile-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nav-mobile-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  flex-shrink: 0;
}

.nav-mobile-link svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex-shrink: 0;
}

.nav-mobile-link:hover,
.nav-mobile-link.active {
  background: var(--surface2);
  color: var(--text);
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1200px) {
  /* Hide desktop nav links, show hamburger */
  .nav-links {
    display: none;
  }
  
  .nav-divider {
    display: none;
  }
  
  .nav-hamburger {
    display: block;
  }
}

@media (max-width: 640px) {
  #site-footer {
    padding: 36px 20px;
  }
  
  .footer-link:not(:last-child)::after {
    content: none;
  }
  
  .footer-links {
    flex-direction: column;
    gap: 4px;
  }
  
  .footer-link {
    width: 100%;
    text-align: center;
  }
}

@media (max-width: 540px) {
  .swatch { width: 72px; height: 72px; }
  .page-header h1 { font-size: 1.45rem; }
  .tab-btn { font-size: 0.72rem; padding: 7px 6px; }
  .access-toolbar { gap: 6px; }
  .filter-pills { gap: 4px; }
  .filter-pill { font-size: 0.66rem; padding: 3px 8px; }
}
