/* ==========================================================================
   AltKeyHub — shared design system
   Every symbol, one click away.
   ========================================================================== */

:root {
  /* Brand */
  --brand-50:  #f2f0fd;
  --brand-100: #e4e0fb;
  --brand-200: #c9c1f7;
  --brand-300: #a99def;
  --brand-400: #8b7ef0;
  --brand-500: #6c5ce7;
  --brand-600: #5b4fe0;
  --brand-700: #4a3fc4;
  --brand-800: #3b329c;

  --accent-500: #00c2a8;
  --accent-600: #00a892;
  --accent-100: #d6f7f2;

  --warn-500: #ff6b6b;

  /* Neutrals (light theme) */
  --bg: #fbfaff;
  --bg-elevated: #ffffff;
  --bg-inset: #f3f1fb;
  --border: #e6e2f5;
  --text: #201c34;
  --text-muted: #635d7d;
  --text-faint: #948eae;

  --shadow-color: 240 30% 60%;
  --shadow-sm: 0 1px 2px hsl(var(--shadow-color) / 0.08);
  --shadow-md: 0 6px 16px hsl(var(--shadow-color) / 0.12);
  --shadow-lg: 0 16px 40px hsl(var(--shadow-color) / 0.16);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --font-sans: "Inter", "Noto Sans Arabic", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", ui-monospace, "Menlo", "Consolas", monospace;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #15121f;
  --bg-elevated: #1d1930;
  --bg-inset: #241f39;
  --border: #332c50;
  --text: #f2f0fb;
  --text-muted: #b6aed4;
  --text-faint: #837aa6;
  --brand-50: #241f39;
  --brand-100: #2d2650;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15121f;
    --bg-elevated: #1d1930;
    --bg-inset: #241f39;
    --border: #332c50;
    --text: #f2f0fb;
    --text-muted: #b6aed4;
    --text-faint: #837aa6;
    --brand-50: #241f39;
    --brand-100: #2d2650;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a { color: var(--brand-600); }
:root[data-theme="dark"] a, @media (prefers-color-scheme: dark) { }

img, svg { display: block; }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------------------------------- Header ---------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 68px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand__mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-500), var(--accent-500));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: -0.02em;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.main-nav {
  display: flex;
  gap: 4px;
  margin-left: 8px;
  flex: 1;
}

.main-nav a {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  transition: background-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.main-nav a:hover {
  color: var(--text);
  background: var(--bg-inset);
}

.main-nav a[aria-current="page"] {
  color: var(--brand-700);
  background: var(--brand-100);
}

:root[data-theme="dark"] .main-nav a[aria-current="page"],
@media (prefers-color-scheme: dark) {
  .main-nav a[aria-current="page"] { color: var(--brand-200); }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease, color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover { color: var(--brand-600); border-color: var(--brand-300); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 18px; height: 18px; }

.mobile-nav-toggle { display: none; }

/* ---------------------------------- Hero ---------------------------------- */

.hero {
  padding: 56px 0 32px;
  text-align: center;
}

.hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-600);
  background: var(--accent-100);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  margin-bottom: 18px;
}

.hero h1 {
  font-size: clamp(1.9rem, 4vw, 2.75rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  font-weight: 800;
}

.hero h1 em {
  font-style: normal;
  background: linear-gradient(135deg, var(--brand-600), var(--accent-500));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 560px;
  margin: 0 auto;
}

/* ---------------------------------- Search ---------------------------------- */

.search-bar {
  max-width: 560px;
  margin: 28px auto 0;
  position: relative;
}

.search-bar input {
  width: 100%;
  padding: 15px 20px 15px 48px;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-bar input:focus {
  border-color: var(--brand-400);
  box-shadow: 0 0 0 4px var(--brand-100);
}

.search-bar .search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-faint);
  pointer-events: none;
}

.search-bar .clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--bg-inset);
  color: var(--text-muted);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

.search-bar .clear-btn.visible { display: flex; }

.result-count {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.85rem;
  margin-top: 12px;
  min-height: 1.2em;
}

/* ---------------------------------- Category tabs ---------------------------------- */

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 28px 0 8px;
}

.category-tabs button {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.15s ease;
}

.category-tabs button:hover {
  border-color: var(--brand-300);
  color: var(--brand-600);
}

.category-tabs button.active {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: white;
}

/* ---------------------------------- Symbol grid ---------------------------------- */

.symbol-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  margin: 24px 0 64px;
}

.symbol-tile {
  position: relative;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 16px 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.symbol-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--brand-300);
}

.symbol-tile:active { transform: translateY(0) scale(0.97); }

.symbol-tile .glyph {
  font-size: 1.9rem;
  line-height: 1;
  color: var(--text);
}

.symbol-tile .label {
  font-size: 0.68rem;
  color: var(--text-faint);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.symbol-tile.copied {
  border-color: var(--accent-500);
  background: var(--accent-100);
}

.symbol-tile.copied::after {
  content: "Copié !";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-500);
  color: white;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: var(--radius-md);
}

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-faint);
}

.empty-state .glyph {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.6;
}

/* ---------------------------------- Sections / cards ---------------------------------- */

.section-title {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}

.section-sub {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0 0 20px;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

/* ---------------------------------- Accent keyboard ---------------------------------- */

.language-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.language-tabs button {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.language-tabs button.active {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: white;
}

.accent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  margin-bottom: 48px;
}

/* ---------------------------------- Alt code lookup ---------------------------------- */

.lookup-result {
  display: none;
  gap: 20px;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin: 24px 0;
}

.lookup-result.visible { display: flex; }

.lookup-result .glyph-big {
  font-size: 3.2rem;
  width: 90px;
  height: 90px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-inset);
  border-radius: var(--radius-md);
}

.lookup-result .details { flex: 1; min-width: 0; }
.lookup-result .details h3 { margin: 0 0 4px; font-size: 1.15rem; }

.code-rows { display: grid; gap: 8px; margin-top: 10px; }

.code-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.code-row .platform {
  color: var(--text-faint);
  width: 130px;
  flex-shrink: 0;
  font-weight: 600;
}

.code-row code {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.code-row .copy-mini {
  border: none;
  background: none;
  color: var(--brand-600);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 6px;
}

.results-list {
  display: grid;
  gap: 10px;
}

.result-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.result-row:hover { border-color: var(--brand-300); transform: translateX(2px); }

.result-row .glyph { font-size: 1.6rem; width: 40px; text-align: center; }
.result-row .meta { flex: 1; min-width: 0; }
.result-row .meta .name { font-weight: 700; font-size: 0.92rem; }
.result-row .meta .sub { color: var(--text-faint); font-size: 0.78rem; margin-top: 2px; }
.result-row .chip {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--bg-inset);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

/* ---------------------------------- Recently copied ---------------------------------- */

.recent-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 18px;
  min-height: 32px;
}

.recent-strip .recent-label {
  font-size: 0.78rem;
  color: var(--text-faint);
  font-weight: 600;
}

.recent-strip button {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 1.05rem;
  cursor: pointer;
}

.recent-strip button:hover { border-color: var(--brand-300); }

/* ---------------------------------- Toast ---------------------------------- */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast .glyph { font-size: 1.1rem; }

/* ---------------------------------- Footer ---------------------------------- */

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding: 36px 0 48px;
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 24px;
}

.site-footer .brand { margin-bottom: 8px; }

.site-footer p {
  color: var(--text-faint);
  font-size: 0.85rem;
  max-width: 320px;
  margin: 8px 0 0;
}

.footer-links {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}

.footer-links div { display: flex; flex-direction: column; gap: 10px; }

.footer-links h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin: 0 0 4px;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
}

.footer-links a:hover { color: var(--brand-600); }

/* ---------------------------------- Page intro (accents/alt-codes) ---------------------------------- */

.page-intro { padding: 44px 0 24px; text-align: center; }
.page-intro h1 { font-size: clamp(1.6rem, 3.2vw, 2.2rem); margin: 0 0 10px; letter-spacing: -0.02em; }
.page-intro p { color: var(--text-muted); max-width: 560px; margin: 0 auto; }

.tip-banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin: 0 0 32px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.tip-banner strong { color: var(--text); }

/* ---------------------------------- Language switcher ---------------------------------- */

.lang-switcher { position: relative; }

.lang-switcher__menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 160px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 50;
  flex-direction: column;
  gap: 2px;
}

.lang-switcher__menu.open { display: flex; }

.lang-switcher__menu a {
  display: block;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
}

.lang-switcher__menu a:hover { background: var(--bg-inset); color: var(--text); }
.lang-switcher__menu a.active { background: var(--brand-100); color: var(--brand-700); }

/* ---------------------------------- RTL (Arabic) ---------------------------------- */

html[dir="rtl"] .lang-switcher__menu { right: auto; left: 0; }

html[dir="rtl"] .search-bar .search-icon { left: auto; right: 18px; }
html[dir="rtl"] .search-bar input { padding: 15px 48px 15px 20px; }
html[dir="rtl"] .search-bar .clear-btn { right: auto; left: 10px; }

html[dir="rtl"] .sr-skip-link { left: auto; right: -9999px; border-radius: 0 0 0 8px; }
html[dir="rtl"] .sr-skip-link:focus { right: 0; }

html[dir="rtl"] .result-row:hover { transform: translateX(-2px); }

html[dir="rtl"] .code-row .platform { text-align: right; }

html[dir="rtl"] .mobile-nav a,
html[dir="rtl"] .footer-links a { text-align: right; }

/* ---------------------------------- Responsive ---------------------------------- */

@media (max-width: 720px) {
  .main-nav { display: none; }
  .mobile-nav-toggle {
    display: flex;
  }
  .site-footer__inner { flex-direction: column; }
  .symbol-grid { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
  .lookup-result { flex-direction: column; align-items: flex-start; }
}

.mobile-nav {
  display: none;
  flex-direction: column;
  padding: 8px 0 16px;
  border-top: 1px solid var(--border);
}

.mobile-nav.open { display: flex; }

.mobile-nav a {
  padding: 12px 4px;
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.mobile-nav a[aria-current="page"] { color: var(--brand-600); }

/* ---------------------------------- Utility ---------------------------------- */

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.sr-skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand-600);
  color: white;
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  z-index: 200;
}
.sr-skip-link:focus { left: 0; }
