/* Komunitní chat ADHD mapy Česka – vzhled okna chatu.
   Klidné rozhraní: písmo aspoň 16 px, řádkování 1,5, bez animací, přechodů a obrázků.
   Barvy vycházejí z mapy (adhd-cesko.cz), světlý i tmavý režim podle systému. */

:root {
  --bg: #f3f4f0;
  --surface: #fbfbf8;
  --surface-2: #eef0ea;
  --ink: #17201c;
  --ink-2: #3f4a45;
  --muted: #56615b;
  --line: #d9ded6;
  --line-2: #b6beb3;
  --own: #e6f2e5;
  --target: #fff3c4;
  --warn-bg: #fdf3dc;
  --warn-line: #e9d49c;
  --mod-ink: #0b6b12;
  --err: #a32525;
  --btn-bg: #17201c;
  --btn-ink: #fbfbf8;
  --danger-bg: #a32525;
  --danger-ink: #ffffff;
  --focus: #1f5fbf;
  --backdrop: rgba(16, 20, 18, 0.55);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101412;
    --surface: #171c19;
    --surface-2: #1e2420;
    --ink: #ecf0ea;
    --ink-2: #c3cbc4;
    --muted: #a3ada5;
    --line: #2a322d;
    --line-2: #4a554d;
    --own: #17291b;
    --target: #3b3514;
    --warn-bg: #2e2716;
    --warn-line: #5a4b22;
    --mod-ink: #7ddc7d;
    --err: #f19a9a;
    --btn-bg: #ecf0ea;
    --btn-ink: #101412;
    --danger-bg: #f19a9a;
    --danger-ink: #101412;
    --focus: #8fb8ff;
    --backdrop: rgba(0, 0, 0, 0.65);
    color-scheme: dark;
  }
}

/* ===== Základ ===== */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

button, input, textarea { font: inherit; color: inherit; line-height: 1.5; }
a { color: inherit; text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Jen pro čtečky obrazovky */
.sr {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0.5rem;
  z-index: 30;
  padding: 0.5rem 1rem;
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--focus);
  border-radius: 8px;
}
.skip:focus { left: 0.5rem; }

/* Skryté pole proti robotům – lidé ho nevidí ani čtečka neohlásí */
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

.noscript { margin: 0; padding: 1rem; }

/* ===== Rozvržení: záhlaví, zprávy, psaní ===== */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 48rem;
  margin: 0 auto;
  background: var(--surface);
}
@media (min-width: 50rem) {
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

.top { flex: none; }

/* Název a „Poslední zpráva…“ tečou jako jeden řádek textu (na telefonu ušetří řádek) */
.bar {
  padding: 0.375rem 1rem;
  border-bottom: 1px solid var(--line);
}
.title { display: inline; margin: 0 0.625rem 0 0; font-size: 1rem; font-weight: 700; }
.meta { display: inline; margin: 0; color: var(--ink-2); overflow-wrap: anywhere; }
.meta strong { color: var(--ink); }
/* V okně na mapě má okno vlastní nadpis, tady zůstane jen pro čtečky */
.in-frame .title {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.crisis {
  margin: 0;
  padding: 0.5rem 1rem;
  background: var(--warn-bg);
  border-bottom: 1px solid var(--warn-line);
  color: var(--ink);
}
.crisis a { font-weight: 700; white-space: nowrap; }

.feed {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  background: var(--bg);
}
.feed:focus { outline: none; }

.pinned { background: var(--surface-2); border-bottom: 2px solid var(--line-2); }

.older-wrap { padding: 0.5rem 1rem 0; text-align: center; }
.older-wrap:has(> [hidden] + [hidden]) { display: none; }
.older-end { margin: 0 0 0.5rem; color: var(--muted); }
.older-end:focus { outline: none; }
.older-wrap .btn { margin-bottom: 0.5rem; }

.list { list-style: none; margin: 0; padding: 0; }
.empty { margin: 0; padding: 1.5rem 1rem; text-align: center; color: var(--ink-2); }

/* ===== Zpráva ===== */
.msg {
  padding: 0.5rem 1rem 0.375rem;
  border-bottom: 1px solid var(--line);
}
.msg:focus { outline: none; }
.msg:focus-visible, .msg.is-target { outline: 3px solid var(--focus); outline-offset: -3px; }
.msg.is-own { background: var(--own); }
.msg.is-target { background: var(--target); }

.msg-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.5rem;
  margin: 0;
}
.nick { font-weight: 700; overflow-wrap: anywhere; }
.badge {
  padding: 0 0.375rem;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  color: var(--ink-2);
}
.badge-mod { color: var(--mod-ink); border-color: currentColor; font-weight: 700; }
.time { color: var(--muted); }

.text {
  margin: 0.125rem 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.note { margin: 0.25rem 0 0; color: var(--ink-2); font-style: italic; }

.quote {
  display: block;
  width: 100%;
  margin: 0.25rem 0 0;
  padding: 0.125rem 0.5rem;
  text-align: left;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 0;
  border-left: 3px solid var(--line-2);
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.quote:hover { color: var(--ink); text-decoration: underline; }
.quote-gone { font-style: italic; cursor: default; }
.quote-gone:hover { color: var(--ink-2); text-decoration: none; }
.q-nick { font-weight: 700; }
/* citace nejvýš na dva řádky, ať neodvádí pozornost */
.q-line, .reply-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.25rem;
  margin: 0.125rem 0 0 -0.5rem;
}
.act {
  min-height: 2rem;
  padding: 0.125rem 0.5rem;
  background: none;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.act:hover { color: var(--ink); }
.act[aria-disabled="true"] { text-decoration: none; cursor: default; }
.no-write .act-reply { display: none; }

.divider {
  padding: 0.25rem 1rem;
  text-align: center;
  font-weight: 700;
  color: var(--ink);
  background: var(--surface-2);
  border-bottom: 2px solid var(--line-2);
}
.divider:focus { outline: none; }
.divider:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }

/* ===== Lišta s upozorněními nad psaním ===== */
.notices {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.375rem 0.75rem;
  padding: 0.375rem 1rem;
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.25rem 0.75rem;
  margin: 0;
  text-align: center;
}
.notice-warn {
  padding: 0.25rem 0.75rem;
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: 8px;
}
.notices .btn { min-height: 2.5rem; padding: 0.25rem 0.875rem; }

/* ===== Tlačítka ===== */
.btn {
  min-height: 2.75rem;
  padding: 0.375rem 1rem;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--btn-bg); color: var(--btn-ink); border-color: var(--btn-bg); }
.btn-primary:hover { background: var(--btn-bg); text-decoration: underline; }
.btn-danger { background: var(--danger-bg); color: var(--danger-ink); border-color: var(--danger-bg); }
.btn-danger:hover { background: var(--danger-bg); text-decoration: underline; }
.btn-pill { border-radius: 999px; }
.btn[aria-disabled="true"] { cursor: progress; }

.link {
  min-height: 1.5rem;
  padding: 0;
  background: none;
  border: 0;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* ===== Psaní zprávy ===== */
.mode-note {
  flex: none;
  margin: 0;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.mode-note:focus { outline: none; }

.composer {
  flex: none;
  padding: 0.5rem 1rem 0.625rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.me-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.75rem;
  margin: 0 0 0.375rem;
  color: var(--ink-2);
}
.me-row strong { color: var(--ink); overflow-wrap: anywhere; }

.me-panel {
  margin: 0 0 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.field-label { display: block; font-weight: 700; }
.input {
  width: 100%;
  max-width: 20rem;
  min-height: 2.75rem;
  padding: 0.375rem 0.625rem;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
}
.help { margin: 0.25rem 0 0; color: var(--ink-2); }
.err { margin: 0.25rem 0 0; color: var(--err); font-weight: 700; }

.check { display: flex; align-items: flex-start; gap: 0.5rem; margin: 0.5rem 0 0; }
.check input {
  flex: none;
  width: 1.25rem; height: 1.25rem;
  margin: 0.125rem 0 0;
  accent-color: var(--btn-bg);
}

.premod {
  margin: 0 0 0.375rem;
  padding: 0.25rem 0.5rem;
  background: var(--warn-bg);
  border-radius: 6px;
}

.reply-box {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.75rem;
  margin: 0 0 0.375rem;
  padding: 0.25rem 0.5rem;
  background: var(--surface-2);
  border-left: 3px solid var(--line-2);
  border-radius: 0 6px 6px 0;
}
.reply-text { min-width: 0; overflow-wrap: anywhere; color: var(--ink-2); }
.reply-text strong { color: var(--ink); }

.write { display: flex; align-items: flex-end; gap: 0.5rem; }
.write textarea {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 2.75rem;
  max-height: 40vh;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--bg);
  resize: none;
  overflow-y: auto;
}
.write textarea::placeholder { color: var(--muted); opacity: 1; }
.write .btn-primary { flex: none; }

.under {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 0.75rem;
  margin: 0.125rem 0 0;
  color: var(--muted);
}
.counter { margin-left: auto; }
.counter.is-warn { color: var(--err); font-weight: 700; }

.ts-box { margin-top: 0.375rem; }
.ts-box:empty { display: none; }

.status { margin: 0.25rem 0 0; }
.status:empty { display: none; }
.status.is-error { color: var(--err); font-weight: 700; }

/* Na dotykových zařízeních Enter dělá nový řádek, nápověda by mátla */
@media (hover: none), (pointer: coarse) {
  .hint { display: none; }
}

/* Nízké okno (telefon s klávesnicí, malé okno na mapě): méně místa pro záhlaví */
@media (max-height: 34rem) {
  .title {
    position: absolute !important;
    width: 1px; height: 1px;
    margin: -1px; padding: 0; border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .bar { padding-top: 0.125rem; padding-bottom: 0.125rem; }
  .crisis { padding-top: 0.25rem; padding-bottom: 0.25rem; }
  .composer { padding-top: 0.375rem; padding-bottom: 0.375rem; }
  .me-row { margin-bottom: 0.25rem; }
  .hint { display: none; }
}

/* ===== Okna (dialogy) ===== */
.dlg {
  --dlg-pad: 1.25rem;
  width: min(34rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 1rem var(--dlg-pad) 0;
  overflow-y: auto;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
}
@media (max-width: 26rem) {
  .dlg { --dlg-pad: 1rem; width: calc(100vw - 1rem); max-height: calc(100dvh - 1rem); }
}
.dlg::backdrop { background: var(--backdrop); }
/* náhrada pro prohlížeče bez <dialog> (třídu no-dialog přidá chat.js) */
dialog:not([open]) { display: none; }
.no-dialog dialog[open] { position: fixed; inset: 0; z-index: 50; height: fit-content; box-shadow: 0 0 0 100vmax var(--backdrop); }
.dlg h2 { margin: 0 0 0.5rem; font-size: 1.25rem; line-height: 1.3; }
.dlg h2:focus { outline: none; }
.dlg p { margin: 0 0 0.5rem; }
.dlg .err { margin-top: 0.25rem; }
/* poučení o údajích v okně pravidel (odkaz na stránku O projektu mapy) */
.dlg .privacy { margin: 0.75rem 0 0.5rem; color: var(--muted); }

.rules { margin: 0 0 0.75rem; padding-left: 1.75rem; }
.rules li { margin: 0.125rem 0; }

.lines { list-style: none; margin: 0.5rem 0 0.75rem; padding: 0; }
.lines li {
  margin: 0.375rem 0;
  padding: 0.375rem 0.625rem;
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: 6px;
}
.lines a { font-weight: 700; white-space: nowrap; }

/* Tlačítka okna zůstanou vidět i na malém telefonu, kde se obsah okna posouvá */
.dlg-buttons {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  margin: 1rem calc(-1 * var(--dlg-pad)) 0;
  padding: 0.75rem var(--dlg-pad) 1rem;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.reasons { margin: 0; padding: 0; border: 0; min-width: 0; }
.reasons legend { margin: 0 0 0.25rem; padding: 0; font-weight: 700; }
.radio { display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.375rem 0; cursor: pointer; }
.radio input {
  flex: none;
  width: 1.25rem; height: 1.25rem;
  margin: 0.125rem 0 0;
  accent-color: var(--btn-bg);
}
