/* Palette lifted from the aerial photo of the lake. */
:root {
  --lake: #12263a;
  --lake-soft: #2a4560;
  --leaf: #c4dc4a;
  --leaf-pale: #e6f0b4;
  --sand: #e9dfc4;
  --shore: #9a5b34;
  --wake: #f6f8f3;
  --barn: #b23a2e;
  --ink: #16212e;
  --muted: #5b6b79;
  --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

@font-face {
  font-family: 'Fraunces';
  font-weight: 500 800;
  font-display: swap;
  src: url(/assets/fraunces.woff2) format('woff2');
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 18px/1.45 var(--sans); color: var(--ink); background: var(--lake); }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--leaf); outline-offset: 2px; }

.primary {
  min-height: 48px; padding: 0 26px; border: 0; border-radius: 999px;
  background: var(--lake); color: var(--wake); font-weight: 650;
  transition: background .15s, transform .1s;
}
.primary:hover { background: var(--lake-soft); }
.primary:active { transform: translateY(1px); }

/* ---------- Login ---------- */

#login { height: 100%; display: grid; grid-template-columns: 1fr minmax(380px, 30vw); background: var(--wake); }

.shore {
  background: var(--lake) url(/assets/lake.jpg) 62% 72% / cover;
}

.sheet { display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(28px, 4vw, 64px); }
.sheet h1 { font: 700 clamp(40px, 4.4vw, 60px)/1.02 var(--serif); font-variation-settings: 'SOFT' 100; letter-spacing: -.01em; color: var(--lake); }
.lede { margin-top: 14px; color: var(--muted); font-size: 19px; max-width: 28ch; }

#login-form { margin-top: 36px; display: grid; gap: 6px; max-width: 360px; }
#login-form label:not(.check) { font-weight: 650; margin-top: 12px; }
#login-form input:not([type=checkbox]) {
  min-height: 52px; padding: 0 16px; border: 2px solid #c7d0d6; border-radius: 14px; background: #fff;
}
#login-form input:not([type=checkbox]):focus { border-color: var(--lake); outline: 3px solid var(--leaf); outline-offset: 0; }
.check { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 16px; margin-top: 4px; }
.check input { width: 22px; height: 22px; accent-color: var(--lake); margin: 0; }
#login-form .primary { margin-top: 18px; justify-self: start; min-width: 140px; }
#login-error { min-height: 3em; margin-top: 6px; color: var(--barn); font-weight: 600; font-size: 16px; }

@media (max-width: 820px) {
  #login { grid-template-columns: 1fr; grid-template-rows: 34dvh 1fr; overflow-y: auto; height: auto; min-height: 100%; }
  .shore { background-image: url(/assets/lake-small.jpg); background-position: 58% 70%; }
  .sheet { padding: 28px 24px 40px; border-radius: 28px 28px 0 0; margin-top: -28px; position: relative; background: var(--wake); }
  .sheet h1 { font-size: 40px; }
}

/* ---------- Chat ---------- */

#chat {
  height: 100%; max-width: 760px; margin: 0 auto; display: flex; flex-direction: column;
  background: var(--wake); position: relative;
}
@media (min-width: 900px) {
  body { background: linear-gradient(rgba(18,38,58,.78), rgba(18,38,58,.78)), url(/assets/lake.jpg) center / cover fixed; }
  #chat { box-shadow: 0 0 80px rgba(0,0,0,.45); }
}

header {
  flex: none; position: relative; color: var(--wake); display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap;
  padding: calc(env(safe-area-inset-top) + 18px) 20px 14px; min-height: 112px;
  background:
    linear-gradient(90deg, rgba(18,38,58,.92) 0%, rgba(18,38,58,.65) 55%, rgba(18,38,58,.45) 100%),
    url(/assets/lake.jpg) 20% 66% / 190% auto;
}
.who { flex: 1 1 auto; min-width: 0; }
header h1 { font: 700 30px/1.05 var(--serif); font-variation-settings: 'SOFT' 100; }
#subtitle { margin-top: 4px; font-size: 15px; opacity: .85; }

#tabs { display: flex; gap: 8px; order: 3; flex-basis: 100%; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 4px; margin: 0 -2px; }
#tabs::-webkit-scrollbar { display: none; }
#tabs button {
  flex: none; white-space: nowrap; min-height: 40px; padding: 0 18px; border: 2px solid rgba(246,248,243,.5); border-radius: 999px;
  background: rgba(18,38,58,.35); color: var(--wake); font-weight: 600; display: inline-flex; align-items: center; gap: 8px;
}
#tabs button[aria-selected=true] { background: var(--wake); border-color: var(--wake); color: var(--lake); }
#tabs .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--leaf); box-shadow: 0 0 0 2px var(--lake); }

.actions { display: flex; gap: 8px; }
.actions button {
  min-height: 40px; padding: 0 16px; border: 2px solid rgba(246,248,243,.6); border-radius: 999px;
  background: transparent; color: var(--wake); font-weight: 600;
}
.actions button:hover { background: var(--lake-soft); border-color: var(--wake); }
#stop:not(.resume):hover { background: var(--barn); border-color: var(--barn); }

#closed {
  flex: none; margin: 0; padding: 12px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--sand); color: #4a3a1c; font-weight: 600; font-size: 16px; border-top: 1px solid #d8cba6;
}
#stop-menu {
  flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 12px 16px;
  background: var(--sand); border-top: 1px solid #d8cba6; font-weight: 600; color: #4a3a1c;
}
#stop-menu span { margin-right: 4px; }
#stop-menu button { min-height: 40px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--lake); color: var(--wake); font-weight: 650; }
#stop-menu button.quiet { background: transparent; color: #4a3a1c; text-decoration: underline; }
#send-form[hidden] { display: none; }

#scroller { flex: 1; overflow-y: auto; padding: 18px 16px 8px; overscroll-behavior: contain; }
#messages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }

.day { align-self: center; color: var(--muted); font-size: 14px; font-weight: 600; padding-top: 6px; }

.group { display: flex; flex-direction: column; gap: 3px; max-width: min(80%, 34em); align-self: flex-start; }
.group.mine { align-self: flex-end; align-items: flex-end; }
.group .name { font: 600 15px var(--serif); font-variation-settings: 'SOFT' 100; color: var(--shore); margin: 0 4px 1px; }
.bubble {
  padding: 10px 15px; border-radius: 20px 20px 20px 6px; background: var(--leaf-pale); color: var(--ink);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.mine .bubble { border-radius: 20px 20px 6px 20px; background: var(--lake); color: var(--wake); }
.group time { font-size: 13px; color: var(--muted); margin: 1px 6px 0; }

#empty { margin: 18vh auto 0; max-width: 24ch; text-align: center; font: 600 24px/1.25 var(--serif); font-variation-settings: 'SOFT' 100; color: var(--lake-soft); }

#send-form {
  flex: none; display: flex; align-items: flex-end; gap: 10px;
  padding: 10px 14px calc(env(safe-area-inset-bottom) + 12px); border-top: 1px solid #dfe5e0; background: #fff;
}
#text {
  flex: 1; min-height: 48px; max-height: 140px; resize: none; padding: 11px 16px; line-height: 1.35;
  border: 2px solid #c7d0d6; border-radius: 24px; background: var(--wake);
}
#text:focus { border-color: var(--lake); outline: 3px solid var(--leaf); outline-offset: 0; }

@media (prefers-reduced-motion: no-preference) {
  .group { animation: drift .28s ease-out both; }
  @keyframes drift { from { opacity: 0; transform: translateY(6px); } }
}
