/* rc.css: ratcloud's shared base. Tokens for light and dark, a type scale, spacing, focus rings,
   buttons, inputs, cards, the one header, empty and error blocks. CSS only, no script: home
   serves it to every origin, so it must never be able to run anything there. Link it as
   https://<apex>/rc.css?v=N (the shim's rc_head() does). Apps may link it, copy it, or ignore it.
   Theme: follows the system; <html data-theme="light|dark"> overrides it. */

:root {
  color-scheme: light dark;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --t-small: 0.875rem; --t-body: 1rem; --t-h2: 1.125rem; --t-h1: 1.5rem; --t-big: 2rem;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s6: 24px; --s8: 32px;
  --radius: 10px; --radius-sm: 6px;
  --measure: 640px;
  --bg: #f7f6f3; --surface: #ffffff; --sunk: #efede8; --fg: #1f1e1c; --muted: #67645f;
  --line: #e4e1da; --accent: #2f6f55; --on-accent: #ffffff; --focus: #2f6f55;
  --ok: #2f8a5b; --warn: #94650b; --bad: #c0392f;
  --ok-bg: #e5f3ea; --warn-bg: #faf0d9; --bad-bg: #fbe7e4;
}
:root[data-theme="light"] { color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161615; --surface: #1f1f1d; --sunk: #121211; --fg: #ecebe6; --muted: #a09e97;
    --line: #34332f; --accent: #6cc79a; --on-accent: #0f1a14; --focus: #6cc79a;
    --ok: #5fcf9c; --warn: #f0b443; --bad: #ef7a70;
    --ok-bg: #18301f; --warn-bg: #362a12; --bad-bg: #3a1d1a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161615; --surface: #1f1f1d; --sunk: #121211; --fg: #ecebe6; --muted: #a09e97;
  --line: #34332f; --accent: #6cc79a; --on-accent: #0f1a14; --focus: #6cc79a;
  --ok: #5fcf9c; --warn: #f0b443; --bad: #ef7a70;
  --ok-bg: #18301f; --warn-bg: #362a12; --bad-bg: #3a1d1a;
}

/* base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: var(--t-body)/1.5 var(--font); }
h1 { font-size: var(--t-h1); line-height: 1.25; margin: 0 0 var(--s3); letter-spacing: -0.01em; }
h2 { font-size: var(--t-h2); line-height: 1.3; margin: 0 0 var(--s2); }
p { margin: 0 0 var(--s3); }
a { color: var(--accent); text-underline-offset: 2px; }
code, pre, kbd { font-family: var(--mono); font-size: 0.9em; }
small, .small { font-size: var(--t-small); }
.muted { color: var(--muted); }
.rc-main { max-width: var(--measure); margin: 0 auto; padding: var(--s6) var(--s4) var(--s8); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* buttons: ghost by default, .primary is the one filled button on a screen */
button, .button {
  font: inherit; font-size: var(--t-body); line-height: 1.25; display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s2); padding: 9px 16px; min-height: 40px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg); text-decoration: none;
}
button:hover, .button:hover { border-color: var(--muted); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button.primary:hover, .button.primary:hover { filter: brightness(1.06); }
button.ghost, .button.ghost { background: transparent; }
button.danger, .button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
button.link, .link { background: none; border: 0; padding: 0; min-height: 0; color: var(--accent); text-decoration: underline; font-weight: normal; font-size: inherit; }
button:disabled { opacity: 0.55; cursor: default; }

/* inputs */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea, select {
  font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 10px; min-height: 40px; width: 100%;
}
input:focus-visible, textarea:focus-visible, select:focus-visible { border-color: var(--focus); }
label { display: block; font-size: var(--t-small); margin: 0 0 var(--s1); }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4); margin: 0 0 var(--s4); }

/* the header: home mark, app name, then sign-in or the person with sign-out */
.rc-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.rc-header-in { max-width: var(--rc-header-width, var(--measure)); margin: 0 auto; padding: var(--s2) var(--s4);
  display: flex; align-items: center; gap: var(--s3); min-height: 56px; }
.rc-mark { display: inline-flex; flex: none; width: 28px; height: 28px; border-radius: 7px; }
.rc-mark svg { width: 28px; height: 28px; display: block; }
.rc-app { font-size: var(--t-h2); font-weight: 650; margin: 0; color: var(--fg); text-decoration: none; letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.rc-app a { color: inherit; text-decoration: none; }
.rc-env { font-size: 0.75rem; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--warn-bg); color: var(--warn); }
.rc-me { margin-left: auto; display: flex; align-items: center; gap: var(--s3); flex: none; }
.rc-who { display: inline-flex; align-items: center; gap: var(--s2); color: var(--fg); text-decoration: none; font-size: var(--t-small); max-width: 14em; }
.rc-who span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-who img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--sunk); flex: none; }
.rc-who:hover span { text-decoration: underline; }
.rc-signout { font-size: var(--t-small); color: var(--muted); }
.rc-me .button { min-height: 36px; padding: 6px 14px; }
@media (max-width: 480px) { .rc-who span { display: none; } }

/* empty and error states: what is (not) here, and the next step */
.rc-empty, .rc-error { text-align: center; padding: var(--s8) var(--s4); color: var(--muted); }
.rc-empty b, .rc-error b { display: block; color: var(--fg); font-size: var(--t-h2); margin-bottom: var(--s1); }
.rc-empty p, .rc-error p { margin: 0 auto var(--s3); max-width: 36ch; }
.rc-error { border: 1px solid color-mix(in srgb, var(--bad) 40%, var(--line)); background: var(--bad-bg); border-radius: var(--radius); }
.rc-error b { color: var(--bad); }
.rc-note { padding: var(--s2) var(--s3); border-radius: var(--radius-sm); background: var(--sunk); font-size: var(--t-small); }
.rc-note.bad { background: var(--bad-bg); color: var(--bad); }
.rc-note.ok { background: var(--ok-bg); color: var(--ok); }
