/* ============================================
   HEXRGB.COM — Color Conversion Tool
   Design: Dark workspace + vivid color accents
   ============================================ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #08080c;
  --bg-card: #111118;
  --bg-input: #1a1a24;
  --bg-hover: #22222e;
  --border: #2a2a3a;
  --border-focus: #6C5CE7;
  --text: #e8e8f0;
  --text-dim: #8888a0;
  --text-muted: #555568;
  --accent: #6C5CE7;
  --accent-glow: rgba(108, 92, 231, .25);
  --pink: #FF3366;
  --cyan: #00D2FF;
  --green: #00E676;
  --orange: #FF9100;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'SF Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', ui-monospace, monospace;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --transition: .2s cubic-bezier(.4, 0, .2, 1);
}

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- AMBIENT BACKGROUND ---- */
.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.ambient::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  top: -200px; left: -100px;
  background: radial-gradient(circle, rgba(108,92,231,.08) 0%, transparent 70%);
  animation: float 20s ease-in-out infinite;
}
.ambient::after {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  bottom: -150px; right: -100px;
  background: radial-gradient(circle, rgba(255,51,102,.06) 0%, transparent 70%);
  animation: float 25s ease-in-out infinite reverse;
}
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.05); }
  66% { transform: translate(-20px, 15px) scale(.95); }
}

/* ---- LAYOUT ---- */
.container { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

/* ---- HEADER ---- */
header {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  position: sticky; top: 0;
  z-index: 100;
  background: rgba(8,8,12,.85);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.logo-mark {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--pink), var(--accent), var(--cyan));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font);
  font-weight: 700;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
}
.logo-text {
  font-family: var(--font);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.5px;
}
.logo-text span { color: var(--text-dim); font-weight: 400; }

nav { display: flex; gap: 4px; }
nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  padding: 6px 14px;
  border-radius: 99px;
  transition: var(--transition);
}
nav a:hover, nav a:focus-visible { color: var(--text); background: var(--bg-hover); }

/* ---- HERO ---- */
.hero {
  padding: 72px 0 48px;
  text-align: center;
}
.hero h1 {
  font-family: var(--font-body);
  font-size: clamp(32px, 5vw, 56px);
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.15;
  margin-bottom: 16px;
}
.hero h1 .gradient {
  background: linear-gradient(135deg, var(--pink), var(--accent), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p {
  color: var(--text-dim);
  font-size: clamp(16px, 2vw, 19px);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ---- CONVERTER CARD ---- */
.converter {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px;
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}
.converter::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--pink), var(--accent), var(--cyan));
  opacity: .6;
}

.converter-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 32px;
  align-items: start;
}

.input-group { display: flex; flex-direction: column; gap: 12px; }
.input-group label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
}

.hex-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0 16px;
  transition: var(--transition);
  height: 56px;
}
.hex-input-wrap:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--accent-glow);
}
.hex-prefix {
  font-family: var(--font);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-muted);
  margin-right: 4px;
  user-select: none;
}
.hex-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  width: 100%;
}
.hex-input::placeholder { color: var(--text-muted); text-transform: none; letter-spacing: 0; }

.rgb-inputs { display: flex; gap: 10px; }
.rgb-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rgb-field small {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  text-align: center;
}
.rgb-field .r-label { color: #ff6b6b; }
.rgb-field .g-label { color: #51cf66; }
.rgb-field .b-label { color: #339af0; }

.rgb-input {
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0 8px;
  height: 56px;
  text-align: center;
  color: var(--text);
  font-family: var(--font);
  font-size: 20px;
  font-weight: 600;
  outline: none;
  width: 100%;
  transition: var(--transition);
}
.rgb-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.swap-btn {
  align-self: center;
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-input);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  margin-top: 24px;
  flex-shrink: 0;
}
.swap-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-hover);
  transform: rotate(180deg);
}
.swap-btn svg { width: 20px; height: 20px; }

/* ---- COLOR PREVIEW ---- */
.preview-bar {
  margin-top: 32px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.color-swatch {
  height: 80px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  position: relative;
  transition: background-color .3s ease;
  overflow: hidden;
}
.swatch-info {
  position: absolute;
  bottom: 8px; left: 12px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  color: #fff;
}

.output-row {
  margin-top: 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.output-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
  user-select: all;
}
.output-chip:hover { border-color: var(--accent); background: var(--bg-hover); }
.output-chip small { color: var(--text-muted); font-weight: 600; text-transform: uppercase; font-size: 10px; letter-spacing: .06em; }

.copy-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 24px;
  border-radius: 99px;
  opacity: 0;
  pointer-events: none;
  transition: .3s ease;
  z-index: 999;
}
.copy-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- TOOLS GRID ---- */
.tools { padding: 48px 0; }
.section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.section-title {
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 800;
  letter-spacing: -.01em;
  margin-bottom: 32px;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  transition: var(--transition);
  cursor: default;
  text-decoration: none;
  color: var(--text);
  display: block;
}
.tool-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(108,92,231,.1);
}
.tool-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
  font-size: 20px;
}
.tool-card h3 { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.tool-card p { font-size: 14px; color: var(--text-dim); line-height: 1.5; }

/* ---- PALETTE GENERATOR ---- */
.palette-section { padding: 16px 0 48px; }
.palette-bar {
  display: flex;
  border-radius: var(--radius);
  overflow: hidden;
  height: 72px;
  border: 1px solid var(--border);
  margin-top: 16px;
}
.palette-swatch {
  flex: 1;
  cursor: pointer;
  position: relative;
  transition: flex .3s ease;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
}
.palette-swatch:hover { flex: 1.8; }
.palette-swatch span {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
  padding: 2px 8px;
  border-radius: 4px;
  opacity: 0;
  transition: var(--transition);
}
.palette-swatch:hover span { opacity: 1; }
.palette-actions { margin-top: 16px; display: flex; gap: 10px; }
.btn {
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-body);
}
.btn:hover { border-color: var(--accent); background: var(--bg-hover); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #5a4bd6; }

/* ---- CONTRAST CHECKER ---- */
.contrast-section { padding: 16px 0 48px; }
.contrast-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 16px;
  align-items: end;
  margin-top: 16px;
}
.contrast-preview {
  grid-column: 1 / -1;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 32px;
  text-align: center;
  transition: .3s ease;
  margin-top: 8px;
}
.contrast-preview .big { font-size: 28px; font-weight: 800; }
.contrast-preview .small { font-size: 14px; margin-top: 4px; }
.contrast-result {
  display: flex;
  gap: 16px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.contrast-badge {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.contrast-badge.pass { background: rgba(0,230,118,.12); color: var(--green); border: 1px solid rgba(0,230,118,.25); }
.contrast-badge.fail { background: rgba(255,51,102,.12); color: var(--pink); border: 1px solid rgba(255,51,102,.25); }

/* ---- CSS COLORS TABLE ---- */
.colors-section { padding: 16px 0 48px; }
.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 16px;
}
.css-color {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  transition: var(--transition);
  font-size: 13px;
}
.css-color:hover { border-color: var(--accent); transform: translateY(-1px); }
.css-color-dot {
  width: 24px; height: 24px;
  border-radius: 6px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,.1);
}
.css-color-name { font-weight: 600; }

/* ---- FAQ ---- */
.faq-section { padding: 48px 0; }
.faq-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
}
.faq-q {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  padding: 18px 20px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-body);
  transition: var(--transition);
}
.faq-q:hover { background: var(--bg-hover); }
.faq-q svg { width: 18px; height: 18px; color: var(--text-muted); transition: transform .3s ease; flex-shrink: 0; margin-left: 12px; }
.faq-item.open .faq-q svg { transform: rotate(180deg); }
.faq-a {
  max-height: 0;
  overflow: hidden;
  transition: max-height .35s ease, padding .35s ease;
}
.faq-item.open .faq-a { max-height: 300px; }
.faq-a-inner {
  padding: 0 20px 18px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.7;
}

/* ---- FOOTER ---- */
footer {
  border-top: 1px solid var(--border);
  padding: 40px 0;
  margin-top: 32px;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}
.footer-inner p { font-size: 13px; color: var(--text-muted); }
.footer-links { display: flex; gap: 20px; }
.footer-links a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  transition: var(--transition);
}
.footer-links a:hover { color: var(--text); }

/* ---- COLOR PICKER INLINE ---- */
.picker-wrap {
  position: relative;
  display: inline-flex;
}
.native-picker {
  position: absolute;
  width: 44px; height: 44px;
  opacity: 0;
  cursor: pointer;
  top: 0; left: 0;
}
.picker-btn {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.picker-btn:hover { border-color: var(--accent); }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .converter { padding: 24px; }
  .converter-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .swap-btn {
    margin-top: 0;
    justify-self: center;
    transform: rotate(90deg);
  }
  .swap-btn:hover { transform: rotate(270deg); }
  .preview-bar { grid-template-columns: 1fr; }
  .contrast-grid { grid-template-columns: 1fr; }
  nav { display: none; }
  .hero { padding: 48px 0 32px; }
}

@media (max-width: 480px) {
  .converter { padding: 18px; border-radius: 14px; }
  .rgb-inputs { gap: 6px; }
  .output-row { gap: 6px; }
  .color-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

/* ---- PRINT ---- */
@media print {
  .ambient, nav, .btn, .swap-btn, .copy-toast { display: none !important; }
  body { background: #fff; color: #111; }
}

/* ---- ACCESSIBILITY ---- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* ---- REDUCED MOTION ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
