/*
  Telepop - télécommande : styles

  Auteur : Laurent Abbal (© 2026)
  Site : https://telepop.codeberg.page/telecommande/
  Code source : https://codeberg.org/telepop/telecommande

  Licence(s) :
  - Code : AGPL-3.0
  - PeerJS : MIT
  - Polices Archivo Black et Rubik : SIL Open Font License 1.1
*/

/* ---------- Polices (hébergées avec la page, aucune requête externe) ---------- */
@font-face {
  font-family: 'Archivo Black';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/archivo-black-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Rubik';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../fonts/rubik-latin-var.woff2') format('woff2');
}

/* ---------- Jetons ---------- */
:root {
  --bg: #fff3e3;
  --paper: #fffdf8;
  --fg: #141414;
  --muted: #5a5550;
  --ink: #141414;
  --dots: #ffc9e2;

  --yellow: #ffc83d;
  --pink: #ff8ec4;
  --sky: #8fd3ff;
  --lilac: #c5b5ff;
  --green: #4ade80;
  --red: #ff6b5b;
  --blue: #3b5bff;

  --ok: #22c55e;
  --warn: #ffc83d;
  --err: #ff4d4d;

  --key-shadow: 0 4px 0 var(--ink);
  --display: 'Archivo Black', 'Arial Black', system-ui, sans-serif;
  --body: 'Rubik', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e1b2e;
    --paper: #2b2742;
    --fg: #fff3e3;
    --muted: #c9c2dd;
    --ink: #0b0a12;
    --dots: #3d3760;
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.3 var(--body);
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
[hidden] {
  display: none !important;
}

#app {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  padding: max(12px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
}

/* ---------- En-tête : onglet affiché ---------- */
.topcard {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 8px;
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--key-shadow);
}
.logo {
  flex: none;
  display: block;
}
.topcard-text {
  min-width: 0;
  flex: 1;
}
.title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 700;
}
#tabTitle {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.meta {
  padding-left: 22px;
  color: var(--muted);
  font-size: 13px;
}
.meta:empty,
.meta:has(span:empty + span:empty) {
  display: none;
}
.dot {
  flex: none;
  width: 14px;
  height: 14px;
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  background: #b8b2aa;
}
.dot.connecting {
  background: var(--warn);
  animation: pulse 1s ease-in-out infinite alternate;
}
.dot.connected {
  background: var(--ok);
}
.dot.error {
  background: var(--err);
}
@keyframes pulse {
  to {
    transform: scale(0.7);
  }
}

.message {
  padding: 10px 14px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: var(--pink);
  color: #141414;
  font-size: 14px;
  font-weight: 500;
}

/* ---------- Choix du mode ---------- */
.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--ink);
}
.segmented button {
  min-height: 38px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  box-shadow: none;
  color: #fff3e3;
  font: 14px var(--display);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.segmented button:active {
  transform: none;
}
#modeScroll.selected {
  background: var(--yellow);
  color: #141414;
}
#modePointer.selected {
  background: var(--pink);
  color: #141414;
}

/* ---------- Pavé tactile ---------- */
.pad {
  flex: 1;
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--ink);
  border-radius: 22px;
  background-color: var(--paper);
  background-image: radial-gradient(circle, var(--dots) 2px, transparent 2.6px);
  background-size: 16px 16px;
  box-shadow: var(--key-shadow);
  touch-action: none;
  transition: background-color 0.15s;
}
.pad.active {
  background-color: color-mix(in srgb, var(--sky) 35%, var(--paper));
}
.pad.selecting {
  background-color: color-mix(in srgb, var(--yellow) 45%, var(--paper));
}
.pad-hint {
  padding: 6px 14px;
  border-radius: 12px;
  background: var(--paper);
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  pointer-events: none;
}

/* ---------- Boutons ---------- */
.row {
  display: flex;
  gap: 8px;
}
button {
  flex: 1;
  min-width: 0;
  min-height: 54px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: var(--key-shadow);
  color: #141414;
  font: 700 22px var(--body);
  touch-action: manipulation;
  transition: transform 0.06s, box-shadow 0.06s;
}
button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}
button.wide {
  flex: 2;
  font-size: 17px;
}
button:disabled {
  opacity: 0.45;
  filter: saturate(0.5);
}
button:disabled:active {
  transform: none;
  box-shadow: var(--key-shadow);
}

/* Une couleur par groupe de boutons */
.row-scroll button,
.row-tools button {
  background: var(--yellow);
}
.row-tabs button {
  background: var(--pink);
}
.row-tabs button:nth-child(2) {
  background: var(--paper);
  color: var(--fg);
}
.row-zoom button {
  background: var(--sky);
}
.row-zoom button:nth-child(4) {
  background: var(--lilac);
}
.row-nav button {
  background: var(--green);
}
.row-nav button:nth-child(4) {
  background: var(--paper);
  color: var(--fg);
}
.row-nav button.danger {
  background: var(--red);
}

/* ---------- Fenêtres (liste des onglets, texte copié) ---------- */
dialog {
  width: calc(100% - 28px);
  max-height: 80vh;
  padding: 18px;
  border: 3px solid var(--ink);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 6px 6px 0 var(--ink);
  color: var(--fg);
}
dialog::backdrop {
  background: rgb(20 20 20 / 0.55);
}
dialog h2 {
  margin: 0 0 12px;
  font: 22px var(--display);
  text-transform: uppercase;
}
#tabList {
  max-height: 60vh;
  margin: 0 0 14px;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}
#tabList li {
  margin-bottom: 8px;
  padding: 12px 14px;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  background: var(--bg);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
#tabList li.active {
  background: var(--yellow);
  color: #141414;
  font-weight: 700;
}
#closeTabs,
#closeText {
  background: var(--pink);
  font-size: 16px;
}
#closeTabs {
  width: 100%;
}
#copyPhone {
  background: var(--yellow);
  font-size: 16px;
}
.note {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
}
#selectedText {
  width: 100%;
  height: 30vh;
  margin-bottom: 14px;
  padding: 10px;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.4 var(--body);
  user-select: text;
  -webkit-user-select: text;
}

/* ---------- Écrans peu hauts ---------- */
@media (max-height: 680px) {
  #app {
    gap: 8px;
  }
  button {
    min-height: 46px;
    font-size: 20px;
  }
  .segmented button {
    min-height: 32px;
  }
  .logo {
    width: 32px;
    height: 32px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dot.connecting {
    animation: none;
  }
  button,
  .pad {
    transition: none;
  }
}
