/* The Mudbath look, shared by every page: font, colours, buttons, form fields, avatars, badges and
   pop-up menus. Layouts live in auth.css (logged-out pages) and app.css (everything else).
   Change a colour here and it changes everywhere. */

@font-face { font-family: "Geist"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/geist-latin-400-normal.61cc095d4fd4.woff2") format("woff2"); }
@font-face { font-family: "Geist"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/geist-latin-600-normal.942998b91f1c.woff2") format("woff2"); }
@font-face { font-family: "Geist"; font-weight: 700; font-style: normal; font-display: swap; src: url("fonts/geist-latin-700-normal.b16e7527e9a3.woff2") format("woff2"); }

:root, [data-bg="mudbath"], [data-bg="auto"] {
  /* Background: Mudbath, the default (and "Match my device" at night). Black and Light override the
     themed colours below; a data-bg attribute on any element (the Settings previews) works too. */
  --ink: #021816;            /* page */
  --line: #1B3B37;           /* dividers */
  --edge: #3A5C57;           /* input and outline-button borders */
  --text: #EAF6F4;
  --muted: #87A5A0;
  --banner: #0B2B28;         /* profile banner strip */
  --deep: #2E5B55;           /* one of the avatar colours */
  --field: #0A2422;          /* search box */
  --danger: #FFB4A9;
  --danger-edge: #6B3A35;
  --danger-tint: rgba(255, 120, 100, 0.08);
  --warn: #F2C66D;           /* composer: nearly at the limit */
  --hover: rgba(234, 246, 244, 0.06);
  --row-hover: rgba(234, 246, 244, 0.025);
  --well: rgba(234, 246, 244, 0.03);       /* "this post is gone" box */
  --glass: rgba(2, 24, 22, 0.86);          /* sticky page header */
  --glass-strong: rgba(2, 24, 22, 0.94);   /* phone tab bar */
  --primary-hover: #D3E6E3;
  --menu-shadow: 0 0 15px rgba(234, 246, 244, 0.12), 0 0 3px rgba(234, 246, 244, 0.1);

  /* Accent colours as "r, g, b" (links, Post button, likes, tabs, focus rings): shades for dark
     backgrounds; Light has deeper ones. */
  --accent-mint: 126, 228, 217;
  --accent-blue: 29, 155, 240;
  --accent-pink: 249, 24, 128;
  --accent-purple: 164, 139, 255;
  --accent-orange: 255, 122, 26;
  --accent-yellow: 255, 212, 0;

  /* The same in every scheme: shadows, and the dark layers over photos. */
  --shadow: rgba(0, 0, 0, 0.35);
  --shadow-strong: rgba(0, 0, 0, 0.45);
  --scrim: rgba(0, 0, 0, 0.92);            /* full-screen photo viewer */
  --chip: rgba(2, 24, 22, 0.72);           /* round buttons over photos */
  --chip-hover: rgba(2, 24, 22, 0.95);
  --dim: rgba(91, 112, 108, 0.4);          /* behind the crop dialog */
  --photo-stage: #000;
  --on-photo: #EAF6F4;                     /* text and icons over the dark photo layers */
  --on-photo-muted: #87A5A0;

  --font: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

/* Display (Settings): the other backgrounds. core/themes.py lists the choices; core/tests/test_themes.py
   checks each one sets every themed colour and that every background + accent pair is readable. */
[data-bg="black"] {
  --ink: #000000;
  --line: #2F3336;
  --edge: #536471;
  --text: #E7E9EA;
  --muted: #8B9196;
  --banner: #16181C;
  --deep: #3A3E42;
  --field: #202327;
  --danger: #FF9E95;
  --danger-edge: #67282A;
  --danger-tint: rgba(244, 33, 46, 0.1);
  --warn: #FFD400;
  --hover: rgba(231, 233, 234, 0.07);
  --row-hover: rgba(231, 233, 234, 0.03);
  --well: rgba(231, 233, 234, 0.03);
  --glass: rgba(0, 0, 0, 0.86);
  --glass-strong: rgba(0, 0, 0, 0.94);
  --primary-hover: #D7DBDC;
  --menu-shadow: 0 0 15px rgba(255, 255, 255, 0.2), 0 0 3px 1px rgba(255, 255, 255, 0.15);
}

[data-bg="light"] {
  --ink: #FFFFFF;
  --line: #E1E8E7;
  --edge: #C5D3D1;
  --text: #0F1F1D;
  --muted: #566B67;
  --banner: #CFE3E0;
  --deep: #B9DCD7;
  --field: #EEF3F2;
  --danger: #C4301C;
  --danger-edge: #F0B4AC;
  --danger-tint: rgba(196, 48, 28, 0.06);
  --warn: #8F6200;
  --hover: rgba(15, 31, 29, 0.05);
  --row-hover: rgba(15, 31, 29, 0.03);
  --well: rgba(15, 31, 29, 0.03);
  --glass: rgba(255, 255, 255, 0.86);
  --glass-strong: rgba(255, 255, 255, 0.94);
  --primary-hover: #2A3B39;
  --menu-shadow: 0 0 15px rgba(86, 107, 103, 0.2), 0 0 3px 1px rgba(86, 107, 103, 0.15);
  --accent-mint: 14, 112, 102;
  --accent-blue: 10, 107, 192;
  --accent-pink: 194, 24, 91;
  --accent-purple: 106, 63, 224;
  --accent-orange: 179, 71, 0;
  --accent-yellow: 138, 100, 0;
  color-scheme: light;
}

/* Match my device: exactly the Light block when the device is set to light. */
@media (prefers-color-scheme: light) {
  [data-bg="auto"] {
    --ink: #FFFFFF;
    --line: #E1E8E7;
    --edge: #C5D3D1;
    --text: #0F1F1D;
    --muted: #566B67;
    --banner: #CFE3E0;
    --deep: #B9DCD7;
    --field: #EEF3F2;
    --danger: #C4301C;
    --danger-edge: #F0B4AC;
    --danger-tint: rgba(196, 48, 28, 0.06);
    --warn: #8F6200;
    --hover: rgba(15, 31, 29, 0.05);
    --row-hover: rgba(15, 31, 29, 0.03);
    --well: rgba(15, 31, 29, 0.03);
    --glass: rgba(255, 255, 255, 0.86);
    --glass-strong: rgba(255, 255, 255, 0.94);
    --primary-hover: #2A3B39;
    --menu-shadow: 0 0 15px rgba(86, 107, 103, 0.2), 0 0 3px 1px rgba(86, 107, 103, 0.15);
    --accent-mint: 14, 112, 102;
    --accent-blue: 10, 107, 192;
    --accent-pink: 194, 24, 91;
    --accent-purple: 106, 63, 224;
    --accent-orange: 179, 71, 0;
    --accent-yellow: 138, 100, 0;
    color-scheme: light;
  }
}

/* The chosen accent. Declared on any element with data-accent too, so a swatch can show its own colour. */
:root { --accent-rgb: var(--accent-mint); }
[data-accent="mint"] { --accent-rgb: var(--accent-mint); }
[data-accent="blue"] { --accent-rgb: var(--accent-blue); }
[data-accent="pink"] { --accent-rgb: var(--accent-pink); }
[data-accent="purple"] { --accent-rgb: var(--accent-purple); }
[data-accent="orange"] { --accent-rgb: var(--accent-orange); }
[data-accent="yellow"] { --accent-rgb: var(--accent-yellow); }
:root, [data-accent] {
  --accent: rgb(var(--accent-rgb));
  --accent-tint: rgba(var(--accent-rgb), 0.08);
  --accent-wash: rgba(var(--accent-rgb), 0.06);   /* unread notifications */
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ink); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.icon { display: block; flex: none; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 20px;
  border-radius: 999px; border: 0; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { font-size: 16px; color: var(--ink); background: var(--text); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-accent { font-size: 16px; color: var(--ink); background: var(--accent); }
.btn-accent:hover:not(:disabled) { filter: brightness(0.92); }
.btn-outline { font-size: 15px; color: var(--accent); background: transparent; border: 1px solid var(--edge); }
.btn-outline:hover { background: var(--accent-tint); }
.btn-light { font-size: 15px; color: var(--ink); background: var(--text); }
.btn-light:hover { background: var(--primary-hover); }
.btn-sm { height: 32px; padding: 0 16px; font-size: 14px; }

/* Form fields */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field input, .field textarea {
  font: inherit; font-size: 17px; color: var(--text); background: transparent;
  border: 1px solid var(--edge); border-radius: 6px; padding: 0 12px; height: 52px; width: 100%;
}
.field textarea { height: auto; min-height: 96px; padding: 12px; resize: vertical; line-height: 1.4; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.field .help { font-size: 12px; line-height: 1.4; }
.field .help ul { margin: 2px 0 0; padding-left: 18px; }
.field .error { font-size: 13px; color: var(--danger); }
.errors { border: 1px solid var(--danger-edge); background: var(--danger-tint); color: var(--danger); border-radius: 6px; padding: 10px 12px; font-size: 14px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; } /* spam trap */

/* Avatars: initials in a circle; the colour pair follows the member id (see ui.avatar) */
.avatar {
  --size: 40px; width: var(--size); height: var(--size); flex: none; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; overflow: hidden;
  font-weight: 700; font-size: calc(var(--size) * 0.38); line-height: 1; letter-spacing: -0.02em; user-select: none;
}
.avatar-img { object-fit: cover; background: var(--line); }
.avatar-p1 { color: var(--ink); background: var(--accent); }
.avatar-p2 { color: var(--accent); background: var(--line); }
.avatar-p3 { color: var(--text); background: var(--deep); }
.avatar-p0 { color: var(--ink); background: var(--text); }

/* Unread count bubble; empty means nothing unread */
.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--accent); color: var(--ink); font-size: 11px; font-weight: 700; line-height: 1;
}
.badge:empty { display: none; }

/* Pop-up menus: <details class="menu"><summary>…</summary><div class="menu-panel">…</div></details> */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; z-index: 30; min-width: 220px; padding: 6px 0; background: var(--ink);
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--menu-shadow);
}
.menu-panel > a, .menu-panel > form > button:not(.btn), .menu-panel > button:not(.btn) {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 16px; border: 0; background: transparent;
  color: var(--text); font-size: 15px; font-weight: 700; text-align: left; cursor: pointer; text-decoration: none;
}
.menu-panel > a:hover, .menu-panel > form > button:not(.btn):hover, .menu-panel > button:not(.btn):hover { background: var(--hover); }
.menu-panel .danger { color: var(--danger); }
