/* Proximot — design original «thermomètre sémantique»
   MOBILE-FIRST : joué au pouce. Desktop = agrandissement gracieux.
   Palette : glacier → ambre → braise. Zéro dépendance. */

:root {
  --bg: #f7f5f0;
  --bg-2: #fffefb;
  --ink: #1c1a17;
  --ink-2: #57524a;
  --ink-3: #8d867b;
  --line: #e6e1d7;
  --card: #fffefb;
  --accent: #d9481c;
  --accent-ink: #fff;
  --c-cold: #2f7fd1;
  --c-mid: #e0a13a;
  --c-hot: #d9481c;
  --ok: #2c8a5b;
  --shadow: 0 10px 30px -12px rgb(28 26 23 / 0.25);
  --radius: 18px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tap: 48px;                       /* cible tactile min */
  --safe-b: env(safe-area-inset-bottom, 0px);
}
html[data-theme="dark"] {
  --bg: #0e1116;
  --bg-2: #151a21;
  --ink: #eceff4;
  --ink-2: #a8b0ba;
  --ink-3: #6c7681;
  --line: #232a34;
  --card: #151a21;
  --accent: #ff6a3d;
  --accent-ink: #14100e;
  --c-cold: #4f9be8;
  --c-mid: #f0b454;
  --c-hot: #ff6a3d;
  --ok: #4cc98a;
  --shadow: 0 14px 34px -14px rgb(0 0 0 / 0.7);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1100px 480px at 85% -10%, color-mix(in srgb, var(--c-hot) 8%, transparent), transparent 60%),
    radial-gradient(800px 400px at -10% 0%, color-mix(in srgb, var(--c-cold) 9%, transparent), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
  display: flex; flex-direction: column;
}
.wrap { width: 100%; max-width: 720px; margin-inline: auto; padding-inline: 16px; }
.sr-only, .skip {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.skip:focus { position: fixed; inset: auto auto 12px 12px; width: auto; clip-path: none; z-index: 60; background: var(--card); padding: 8px 14px; border-radius: 10px; box-shadow: var(--shadow); }
button { font-family: inherit; }

/* ── header ─────────────────────────────────────────────── */
.topbar { padding-block: 10px 2px; }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); }
.logo { flex: 0 0 auto; }
.logo-p { font: 800 46px var(--sans); fill: var(--ink); }
.brand-name { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; }
.top-actions { display: flex; gap: 7px; }
.chip {
  appearance: none; border: 1px solid var(--line); background: var(--card);
  color: var(--ink-2); border-radius: 999px;
  min-height: 38px; padding: 8px 14px; font-size: 13.5px;
  font-weight: 600; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.chip:hover { border-color: color-mix(in srgb, var(--ink-3) 60%, var(--line)); color: var(--ink); }
.sub { display: flex; gap: 8px; align-items: baseline; color: var(--ink-3); font-size: 12.5px; margin-top: 5px; flex-wrap: wrap; }
.sub .sep { opacity: .6; }
#yesterday a, #yesterday b { color: var(--ink-2); font-weight: 700; }

/* ── hero ───────────────────────────────────────────────── */
.hero { text-align: center; padding: 22px 0 10px; }
.tagline { font-size: clamp(24px, 7vw, 36px); line-height: 1.1; letter-spacing: -0.03em; margin: 0 0 8px; font-weight: 800; }
.tagline em {
  font-style: normal;
  background: linear-gradient(92deg, var(--c-cold), var(--c-mid) 55%, var(--c-hot));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { color: var(--ink-2); font-size: 15px; margin: 0 auto; max-width: 44ch; }
.hero-sub strong { color: var(--ink); }

/* ── board (thermomètre + essais) ────────────────────────── */
.board { margin-top: 14px; }
.board-head {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; box-shadow: var(--shadow);
}
.temp-block { min-width: 74px; }
.temp-num {
  font: 800 clamp(28px, 8vw, 38px) var(--mono);
  letter-spacing: -0.04em; line-height: 1; font-variant-numeric: tabular-nums;
}
.temp-lbl { color: var(--ink-3); font-size: 10px; text-transform: uppercase; letter-spacing: 0.09em; margin-top: 4px; }
.pm-block { margin-left: auto; }
.ring { position: relative; width: 66px; }
.ring svg { width: 66px; height: 66px; transform: rotate(-90deg); display: block; margin-inline: auto; }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 7; }
.ring-val {
  fill: none; stroke: var(--c-mid); stroke-width: 7; stroke-linecap: round;
  stroke-dasharray: 188.5; stroke-dashoffset: 188.5;
  transition: stroke-dashoffset .6s cubic-bezier(.2,.8,.2,1), stroke .3s;
}
.ring-num {
  position: absolute; inset: 0; display: grid; place-items: center;
  font: 700 15px var(--mono); font-variant-numeric: tabular-nums;
}
.ring-num.done { color: var(--ok); }

/* jauge horizontale sous le bloc */
.meter-block { margin-top: 10px; }
.meter {
  position: relative; height: 12px; border-radius: 999px; overflow: hidden;
  background: linear-gradient(90deg, #d7e3f0 0%, #f3e3c6 45%, #f5c9b3 75%, #ee9f88 100%);
}
html[data-theme="dark"] .meter {
  background: linear-gradient(90deg, #1d2c3e 0%, #3a3325 45%, #4a2e24 75%, #5c362a 100%);
}
.meter-fill {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  background: linear-gradient(90deg, var(--c-cold), var(--c-mid) 60%, var(--c-hot));
  border-radius: 999px;
  transition: width .5s cubic-bezier(.2,.8,.2,1);
}
.meter-legend { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--ink-3); margin-top: 4px; font-variant-numeric: tabular-nums; }

.best-line { color: var(--ink-2); font-size: 13.5px; margin: 10px 4px 6px; min-height: 18px; }
.best-line strong { color: var(--ink); font-weight: 700; }

/* liste des essais — le cœur de l'écran */
.history-list {
  list-style: none; margin: 0; padding: 2px;
  display: flex; flex-direction: column; gap: 6px;
}
.guess {
  position: relative;
  display: grid; grid-template-columns: 32px minmax(0,1fr) auto; align-items: center; gap: 10px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 13px;
  padding: 10px 13px; font-size: 15.5px;
  animation: pop .18s ease-out;
}
@keyframes pop { from { transform: translateY(4px); opacity: 0; } to { transform: none; opacity: 1; } }
.g-no { color: var(--ink-3); font: 600 12px var(--mono); font-variant-numeric: tabular-nums; }
.g-word { font-weight: 700; overflow-wrap: anywhere; }
.g-temp { font: 700 14.5px var(--mono); font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; text-align: right; }
.g-temp small { display: block; font-size: 10px; color: var(--ink-3); font-weight: 600; }
.g-temp.has-pm small { color: var(--c-mid); }
.guess.best { border-color: var(--c-mid); background: color-mix(in srgb, var(--c-mid) 10%, var(--bg-2)); }
.guess.found {
  border-color: var(--ok);
  background: color-mix(in srgb, var(--ok) 13%, var(--bg-2));
}
.guess.found .g-word::after { content: " ✔"; color: var(--ok); font-size: 13px; }
.guess.dup { opacity: .5; }
/* fine barre de chaleur sur le bord gauche de chaque essai */
.guess::before {
  content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px;
  border-radius: 3px; background: var(--line);
}
.guess::after { content: ""; }
.guess[data-heat]::before { background: var(--heat, var(--line)); }

/* ── barre de saisie sticky (pattern messagerie) ─────────── */
.input-dock {
  position: sticky; bottom: 0; z-index: 20;
  margin-top: 14px;
  padding: 10px 0 calc(10px + var(--safe-b));
  background: linear-gradient(to top, var(--bg) 78%, transparent);
}
.input-zone { display: flex; gap: 9px; }
.input {
  flex: 1; min-width: 0;
  font-size: 17px; /* ≥16px : évite le zoom auto iOS */
  line-height: 1.2; color: var(--ink);
  background: var(--card); border: 1.5px solid var(--line); border-radius: 14px;
  padding: 12px 15px; min-height: var(--tap); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.input::placeholder { color: var(--ink-3); }
.btn {
  appearance: none; border: none; cursor: pointer;
  font: 700 15.5px var(--sans); color: var(--accent-ink);
  background: linear-gradient(135deg, var(--c-hot), color-mix(in srgb, var(--c-hot) 70%, var(--c-mid)));
  border-radius: 14px; min-height: var(--tap); padding: 12px 20px;
  transition: filter .15s, transform .05s;
  box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--c-hot) 80%, transparent);
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn-ghost {
  appearance: none; cursor: pointer; background: none; border: none;
  color: var(--ink-2); font: 600 13.5px var(--sans); text-decoration: underline dotted;
  padding: 8px 4px; min-height: 40px;
}
.btn-ghost:hover { color: var(--ink); }
.input-msg { min-height: 20px; margin: 6px 2px 0; font-size: 13.5px; color: var(--ink-2); text-align: center; }
.input-msg.err { color: var(--c-hot); font-weight: 600; }
.input-msg.win { color: var(--ok); font-weight: 700; }

/* ── mots proches / partage ──────────────────────────────── */
.near-zone, .share-zone { margin-top: 20px; padding-bottom: 6px; }
.near-zone h2 { font-size: 16.5px; margin: 0 0 4px; letter-spacing: -0.01em; }
.near-sub { color: var(--ink-3); font-size: 13px; margin: 0 0 10px; }
.near-list {
  list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 7px;
}
.near-item {
  display: flex; justify-content: space-between; gap: 6px; align-items: baseline;
  border: 1px solid var(--line); background: var(--bg-2); border-radius: 11px;
  padding: 8px 11px; font-size: 14px;
}
.near-item .n-word { font-weight: 700; }
.near-item .n-temp { font: 700 12px var(--mono); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.near-item.first { border-color: var(--c-mid); }
.share-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; font: 12.5px/1.7 var(--mono); white-space: pre; overflow-x: auto;
  box-shadow: var(--shadow);
}
.share-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* ── hint ────────────────────────────────────────────────── */
.hint-zone { margin: 18px 0 10px; }
.hint {
  border: 1px dashed var(--line); border-radius: 14px; padding: 2px 15px;
  color: var(--ink-2); font-size: 14px;
}
.hint summary { cursor: pointer; font-weight: 600; color: var(--ink); padding-block: 12px; min-height: var(--tap); display: flex; align-items: center; }
.hint p { margin: 0 0 12px; }

/* ── footer ──────────────────────────────────────────────── */
.foot { margin-top: 28px; padding-bottom: 8px; color: var(--ink-3); font-size: 12px; }
.foot .wrap { display: flex; flex-wrap: wrap; gap: 4px 14px; justify-content: center; text-align: center; }
.foot a { color: var(--ink-2); }

/* ── dialog (règles / stats / historique) ─────────────────── */
.dlg {
  border: 1px solid var(--line); border-radius: 22px; padding: 0;
  background: var(--bg); color: var(--ink);
  width: min(94vw, 560px); max-height: 86dvh;
  box-shadow: 0 30px 80px -20px rgb(0 0 0 / 0.5);
}
.dlg::backdrop { background: rgb(10 12 16 / 0.55); backdrop-filter: blur(3px); }
.dlg-x {
  position: absolute; top: 12px; right: 12px; appearance: none; cursor: pointer;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--ink-2);
  width: 36px; height: 36px; border-radius: 999px; font-size: 16px; line-height: 1;
}
.dlg-title { font-size: 18px; margin: 20px 20px 6px; letter-spacing: -0.01em; padding-right: 44px; }
.dlg-body { padding: 0 20px 22px; font-size: 14.5px; color: var(--ink-2); max-height: 60dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.dlg-body h3 { color: var(--ink); font-size: 14.5px; margin: 16px 0 6px; }
.dlg-body p { margin: 8px 0; }
.dlg-body ul, .dlg-body ol { padding-left: 20px; margin: 8px 0; }
.dlg-body li { margin: 6px 0; }
.dlg-body .hist-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.dlg-body .hist-row span:first-child { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.dlg-body .hist-row span:last-child { font-weight: 700; }
.dlg-body table { border-collapse: collapse; width: 100%; margin: 10px 0; font-variant-numeric: tabular-nums; }
.dlg-body td, .dlg-body th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.dlg-body th { color: var(--ink-3); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; }
.dlg-body .stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 9px; margin: 14px 0; }
.dlg-body .stat-cell { background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 8px; text-align: center; }
.dlg-body .stat-cell .v { font: 800 21px var(--mono); color: var(--ink); display: block; }
.dlg-body .stat-cell .k { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 90px; margin: 14px 0 4px; }
.bars i {
  flex: 1; min-width: 4px; border-radius: 3px 3px 0 0;
  background: color-mix(in srgb, var(--c-hot) 55%, var(--bg-2));
  position: relative;
}
.bars i.max { background: var(--c-hot); }
.bars i::after {
  content: attr(data-n); position: absolute; bottom: 105%; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); font-size: 10.5px; padding: 2px 6px; border-radius: 6px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .12s;
}
.bars i.max::after, .bars i:active::after { opacity: 1; }

/* ── desktop ≥ 640px : élargissements seulement ───────────── */
@media (min-width: 640px) {
  .wrap { padding-inline: 20px; }
  .board-head { padding: 16px 20px; gap: 20px; }
  .temp-block { min-width: 96px; }
  .ring { width: 74px; }
  .ring svg { width: 74px; height: 74px; }
  .ring-num { font-size: 17px; }
  .guess { grid-template-columns: 36px minmax(0,1fr) auto auto; padding: 9px 14px; }
  .history-list { max-height: min(48vh, 430px); overflow-y: auto; scrollbar-width: thin; }
  .hero { padding: 34px 0 14px; }
  .near-list { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}