/* =========================================================
   Clavier Arabe phonétique — Compact + clavier visible
   ========================================================= */

:root {
  --bg-0: #faf8f3;
  --bg-1: #f4efe4;
  --bg-2: #efe8d8;
  --card: #ffffffee;
  --card-border: rgba(20, 28, 55, 0.08);
  --card-glow: rgba(255, 255, 255, 0.6);
  --shadow: 0 12px 42px rgba(60, 50, 20, 0.09), 0 2px 8px rgba(60, 50, 20, 0.04);
  --shadow-sm: 0 4px 14px rgba(60, 50, 20, 0.07);
  --shadow-xl: 0 24px 60px rgba(60, 50, 20, 0.13);
  --text: #1c2639;
  --text-2: #384358;
  --dim: #7c839a;
  --teal: #0891b2;
  --teal-bg: #ecf9fb;
  --teal-2: #0e7490;
  --gold: #b8860b;
  --gold-bg: #fef9ec;
  --key-bg: linear-gradient(180deg, #ffffff, #f6f3ed);
  --key-border: #e2ddd3;
  --key-shadow: 0 3px 0 #d6cfbf;
  --key-hover: linear-gradient(180deg, #f0fafb, #e0f5f2);
  --chip-bg: #f4efe4;
  --danger: #dc2626;
  --font: 'Cairo', 'Segoe UI', sans-serif;
}

body[data-theme="dark"] {
  --bg-0: #0c1220;
  --bg-1: #111832;
  --bg-2: #0e1629;
  --card: rgba(255,255,255,0.045);
  --card-border: rgba(255,255,255,0.08);
  --card-glow: rgba(255,255,255,0.03);
  --shadow: 0 12px 42px rgba(0,0,0,0.4);
  --shadow-sm: 0 4px 14px rgba(0,0,0,0.3);
  --shadow-xl: 0 24px 60px rgba(0,0,0,0.5);
  --text: #eaecf4;
  --text-2: #b8bcd4;
  --dim: #8890b0;
  --teal: #22d3ee;
  --teal-bg: rgba(34,211,238,0.08);
  --teal-2: #06b6d4;
  --gold: #f0c75e;
  --gold-bg: rgba(240,199,94,0.10);
  --key-bg: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
  --key-border: rgba(255,255,255,0.10);
  --key-shadow: 0 3px 0 rgba(0,0,0,0.45);
  --key-hover: linear-gradient(180deg, rgba(34,211,238,0.12), rgba(34,211,238,0.03));
  --chip-bg: rgba(255,255,255,0.06);
  --danger: #f87171;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-0);
  min-height: 100dvh;
  transition: background 0.4s, color 0.3s;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 900px 500px at 8% -8%, rgba(8,145,178,0.11), transparent 55%),
    radial-gradient(ellipse 700px 450px at 102% 4%, rgba(184,134,11,0.09), transparent 50%),
    linear-gradient(168deg, var(--bg-0) 0%, var(--bg-1) 45%, var(--bg-2) 100%);
  background-attachment: fixed;
  pointer-events: none;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cg fill='none' stroke='%230891b2' stroke-opacity='0.045' stroke-width='.7'%3E%3Cpath d='M40 0L48 32 80 40 48 48 40 80 32 48 0 40 32 32Z'/%3E%3Ccircle cx='40' cy='40' r='8'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 80px 80px;
  pointer-events: none;
}

/* ---------- Coque : tout doit tenir à l'écran ---------- */
.shell {
  position: relative;
  z-index: 1;
  max-width: 1060px;
  margin: 0 auto;
  padding: 6px 10px 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ---------- Bilingual show/hide ---------- */
body[data-lang="fr"] .en { display: none !important; }
body[data-lang="fr"] .ar { display: none !important; }
body[data-lang="en"] .fr { display: none !important; }
body[data-lang="en"] .ar { display: none !important; }
body[data-lang="ar"] .fr { display: none !important; }
body[data-lang="ar"] .en { display: none !important; }

/* ---------- Navigation ---------- */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 4px 10px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--text);
  font-weight: 900;
  font-size: 0.85rem;
  font-family: var(--font);
}

.nav-brand svg { color: var(--teal); width: 18px; height: 18px; }

.nav-site-name {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--teal);
  letter-spacing: 0.3px;
  opacity: 0.8;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  gap: 2px;
}

.nav-links a {
  padding: 3px 8px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--dim);
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 700;
  transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--teal);
  background: var(--teal-bg);
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.size-control {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--dim);
  box-shadow: var(--shadow-sm);
}

.size-control svg { width: 14px; height: 14px; flex-shrink: 0; }
.size-control input[type="range"] { width: 72px; accent-color: var(--teal); cursor: pointer; }

.icon-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--dim);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.icon-btn:hover { color: var(--teal); border-color: var(--teal); transform: translateY(-1px); }
.icon-btn svg { width: 14px; height: 14px; }
.icon-btn svg path,
.icon-btn svg circle,
.icon-btn svg line { stroke: currentColor; }

/* Language pill button — compact */
.lang-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 10px;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  border-radius: 7px;
  border: 1.5px solid var(--card-border);
  background: var(--bg-1);
  color: var(--teal);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.lang-pill:hover {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(8,145,178,0.25);
}

#btnSound .ic-sound-off { display: none; }
#btnSound.muted .ic-sound-on { display: none; }
#btnSound.muted .ic-sound-off { display: block; color: var(--gold); }
body[data-theme="dark"] #btnTheme .ic-sun { display: none; }
body[data-theme="light"] #btnTheme .ic-moon { display: none; }

/* ---------- Corps ---------- */
.app {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 8px 12px;
  backdrop-filter: blur(14px);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.card-head h2 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
}

.card-head h2::before {
  content: "";
  width: 7px;
  height: 18px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--teal), var(--gold));
  flex-shrink: 0;
}

.head-arb { color: var(--gold); font-weight: 800; font-size: 0.88rem; }

.kb-hint { margin: 0; font-size: 0.68rem; font-weight: 600; color: var(--dim); }

.stats { display: flex; gap: 8px; color: var(--dim); font-size: 0.78rem; font-weight: 700; }
.stats .dot { opacity: 0.45; }

/* ---------- Éditeur compact ---------- */
textarea {
  width: 100%;
  min-height: 60px;
  max-height: 120px;
  resize: vertical;
  border-radius: 10px;
  border: 1.5px solid var(--card-border);
  background: linear-gradient(135deg, var(--card-glow), rgba(255,255,255,0.4));
  color: var(--text);
  font-size: 22px;
  line-height: 1.7;
  padding: 8px 12px;
  outline: none;
  font-family: var(--font);
  transition: border-color 0.25s, box-shadow 0.3s;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.04);
}

body[data-theme="dark"] textarea {
  background: linear-gradient(135deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.2);
}

textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,145,178,0.14); }
textarea::placeholder { color: var(--dim); opacity: 0.5; }

/* ---------- Actions ---------- */
.actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.actions-spacer { flex: 1; }

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--card-border);
  background: var(--card);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.action-btn svg { width: 13px; height: 13px; }
.action-btn:hover { transform: translateY(-1px); border-color: var(--teal); color: var(--teal); }

.action-btn.primary {
  background: linear-gradient(135deg, var(--teal), var(--teal-2));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(8,145,178,0.3);
}

.action-btn.primary:hover { color: #fff; filter: brightness(1.08); }
.action-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- Partage ---------- */
.share-buttons { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

.share-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--dim);
  font-weight: 800;
  font-size: 0.78rem;
  margin-right: 2px;
}

.share-label svg { color: var(--gold); }

.share-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.share-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,0.15), transparent 60%);
  pointer-events: none;
}

.share-btn svg { width: 18px; height: 18px; position: relative; z-index: 1; }
.share-btn:hover { transform: translateY(-2px) scale(1.05); }

.share-btn.wa { background: linear-gradient(140deg, #25d366, #128c4b); }
.share-btn.tg { background: linear-gradient(140deg, #2aabee, #0088cc); }
.share-btn.fb { background: linear-gradient(140deg, #5a82f7, #1877f2); }
.share-btn.x  { background: linear-gradient(140deg, #444b55, #1a1d24); }
.share-btn.em { background: linear-gradient(140deg, #e89b1a, #c47d0e); }
.share-btn.ns { background: linear-gradient(140deg, #22d3ee, #0891b2); }

/* ---------- Clavier phonétique ---------- */
.keyboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  user-select: none;
}

.kb-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.key {
  flex: 1 1 0;
  min-width: 44px;
  max-width: 72px;
  height: 52px;
  border-radius: 12px;
  border: 1.5px solid var(--key-border);
  background: var(--key-bg);
  color: var(--text);
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
  box-shadow: var(--key-shadow);
  transition: all 0.13s;
  padding: 3px;
  position: relative;
  overflow: hidden;
}

.key::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,0.25), transparent 50%);
  pointer-events: none;
}

.key .shift-hint {
  position: absolute;
  top: 2px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.5rem;
  font-weight: 900;
  color: var(--teal);
  letter-spacing: 0.5px;
  z-index: 1;
  line-height: 1;
}

.key .key-label {
  position: absolute;
  top: 2px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.5rem;
  font-weight: 800;
  color: var(--dim);
  letter-spacing: 0.4px;
  z-index: 1;
  line-height: 1;
}

.key .key-label.shift {
  color: var(--teal);
  font-weight: 900;
}

.key .lat {
  font-size: 0.62rem;
  font-weight: 900;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  position: relative;
  z-index: 1;
}

.key .arb {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  position: relative;
  z-index: 1;
  transition: color 0.13s;
}

.key:hover { background: var(--key-hover); border-color: var(--teal); transform: translateY(-2px); box-shadow: 0 5px 0 var(--key-border); }
.key:hover .arb { color: var(--teal); }
.key:active, .key.press { transform: translateY(2px); box-shadow: 0 1px 0 var(--key-border); }
.key.press { background: var(--key-hover); border-color: var(--gold); }
.key.press .arb { color: var(--gold); }

.key.dig {
  background: linear-gradient(180deg, var(--teal-bg), rgba(8,145,178,0.03));
  border-color: rgba(8,145,178,0.18);
}

.key.dig .arb { color: var(--teal); font-weight: 800; }
.key.dig:hover { background: var(--key-hover); border-color: var(--teal); }

body[data-theme="dark"] .key.dig {
  background: linear-gradient(180deg, rgba(34,211,238,0.10), rgba(34,211,238,0.02));
  border-color: rgba(34,211,238,0.15);
}

.key.ctrl {
  flex: 1 1 0;
  max-width: none;
  min-width: 80px;
  flex-direction: row;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--dim);
  background: linear-gradient(180deg, var(--card-glow), var(--chip-bg));
}

body[data-theme="dark"] .key.ctrl {
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
}

.key.ctrl svg { width: 17px; height: 17px; position: relative; z-index: 1; }

.key.space {
  flex: 3 1 0;
  min-width: 180px;
  flex-direction: row;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--dim);
}

/* ---------- Diacritiques compact ---------- */
.mini-row {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1.5px dashed var(--card-border);
}

.mini-block { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }

.mini-label {
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--gold);
  white-space: nowrap;
}

.tkey {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1.5px solid var(--card-border);
  background: var(--key-bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 2px 0 var(--key-border);
  position: relative;
  overflow: hidden;
}

.tkey::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,0.25), transparent 50%);
  pointer-events: none;
}

.tkey:hover { background: var(--key-hover); color: var(--gold); transform: translateY(-1px); }

/* ---------- Phrases compact ---------- */
.phrases { padding: 6px 12px !important; overflow: hidden; }

.phrases .card-head { margin-bottom: 4px; }

.chips { display: flex; gap: 8px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--teal) transparent; padding-bottom: 2px; }

.chip {
  flex: 0 0 auto;
  border: 1.5px solid var(--card-border);
  background: var(--chip-bg);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s;
}

.chip:hover { background: var(--key-hover); border-color: var(--gold); color: var(--gold); transform: translateY(-1px); }

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 6px 12px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.footer-links a {
  text-decoration: none;
  color: var(--dim);
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 700;
  transition: color 0.2s;
}

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

.footer-social {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.footer-social a {
  color: var(--dim);
  transition: color 0.2s, transform 0.2s;
}

.footer-social a:hover { color: var(--teal); transform: translateY(-2px); }
.footer-social svg { width: 20px; height: 20px; }

.footer-copy {
  margin: 0;
  color: var(--dim);
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--card);
  border: 1.5px solid var(--teal);
  color: var(--text);
  padding: 10px 22px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.85rem;
  box-shadow: var(--shadow-xl);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 99;
  backdrop-filter: blur(10px);
}

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

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--teal); border-radius: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .key { height: 48px; min-width: 38px; }
  .key .arb { font-size: 1.35rem; }
}

@media (max-width: 560px) {
  .shell { padding: 8px 10px 6px; gap: 8px; }
  .nav { flex-direction: column; gap: 8px; padding: 8px 12px; }
  .nav-links { flex-wrap: wrap; justify-content: center; }
  .nav-controls { justify-content: center; flex-wrap: wrap; }
  .card { padding: 10px 12px; border-radius: 16px; }
  .card-head { flex-direction: column; align-items: flex-start; gap: 4px; }
  .key { height: 44px; min-width: 0; max-width: none; border-radius: 10px; }
  .key .lat { font-size: 0.55rem; }
  .key .arb { font-size: 1.15rem; }
  .key.ctrl { min-width: 50px; font-size: 0.7rem; }
  .key.space { min-width: 100px; }
  .actions { gap: 6px; }
  .actions-spacer { display: none; }
  .action-btn { flex: 1 1 42%; justify-content: center; padding: 7px 10px; font-size: 0.74rem; }
  .share-btn { width: 34px; height: 34px; }
  .share-btn svg { width: 16px; height: 16px; }
  textarea { min-height: 70px; font-size: 20px; }
  .footer-links { gap: 10px; }
  .footer-social { gap: 8px; }
}
