/*
 * cosmos-ui shared theme
 * -----------------------------------------------------------------------
 * Drop this file in alongside any COSMOS subsite and set
 * `data-theme="light"` or `data-theme="dark"` on <html> (a small inline
 * script, see cosmos-ui.js below, keeps it in sync with the visitor's
 * saved preference / OS setting). Everything is driven off the CSS
 * custom properties in :root / [data-theme="dark"] so a subsite can
 * override just the --brand-* tokens without forking the file.
 */

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-alt: #eef0f6;
  --border: #d9dce5;
  --text: #1b1e27;
  --text-muted: #5b6072;
  --brand: #3454d1;
  --brand-contrast: #ffffff;
  --link: #3454d1;
  --danger: #c4314b;
  --shadow: 0 1px 3px rgba(20, 22, 30, 0.08), 0 8px 24px rgba(20, 22, 30, 0.06);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #14161d;
  --surface: #1c1f29;
  --surface-alt: #242836;
  --border: #333748;
  --text: #eef0f6;
  --text-muted: #a3a8ba;
  --brand: #7c93ff;
  --brand-contrast: #101223;
  --link: #7c93ff;
  --danger: #ff7a90;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body.cosmos {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.cosmos-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.cosmos-header img.cosmos-logo { height: 32px; width: auto; }
.cosmos-header .brand-name { font-weight: 600; font-size: 1.05rem; letter-spacing: 0.02em; }

/* The brand mark + name, wrapped as a link back to "/". Only relevant
   to the full topbar (topbar.shtml) — the plain static headers on the
   pre-auth pages (login, auth-start) don't use it. */
.cosmos-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

/* Where a subsite's own extra topbar items land — see the cosmos-ui
   skill's "The top bar" section. Starts empty; cosmos-ui.js populates
   it client-side from the page's [data-cosmos-topbar-mount] children.
   Bare links/buttons get sane default styling here so a subsite isn't
   forced to bring its own CSS just to add one item; anything fancier
   is welcome to override it. */
.cosmos-header-extra {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.cosmos-header-extra a,
.cosmos-header-extra button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.cosmos-header-extra a:hover,
.cosmos-header-extra button:hover { color: var(--brand); }

/* Groups the right-hand controls so they move together; only the group
   as a whole needs to push right, not each control individually. */
.cosmos-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.cosmos-user {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.cosmos-theme-toggle {
  /* Still needed standalone: the plain static headers on the pre-auth
     pages (login, auth-start) use this outside of .cosmos-header-actions
     and rely on it to self-right-align. */
  margin-left: auto;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.cosmos-theme-toggle:hover { background: var(--border); }
.cosmos-header-actions .cosmos-theme-toggle { margin-left: 0; }

.cosmos-btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  text-decoration: none;
  cursor: pointer;
}
.cosmos-btn-logout:hover { border-color: var(--danger); color: var(--danger); }

.cosmos-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

.cosmos-hero {
  /* Matches the sign-in card's own max-width (set inline on that card)
     so the logo reads as at least as prominent as the card below it,
     rather than a small fixed-height icon. */
  max-width: 420px;
  margin: 0 auto 2rem;
}
.cosmos-hero-logo { display: block; width: 100%; height: auto; }

.cosmos-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}

.cosmos-title { margin: 0 0 0.5rem; font-size: 1.5rem; }
.cosmos-subtitle { margin: 0 0 1.75rem; color: var(--text-muted); }

.cosmos-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--brand);
  color: var(--brand-contrast);
  border: none;
  border-radius: 8px;
  padding: 0.7rem 1.4rem;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.cosmos-btn:hover { filter: brightness(1.08); }

.cosmos-site-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.cosmos-site-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.1s ease, border-color 0.1s ease;
}
.cosmos-site-card:hover { border-color: var(--brand); transform: translateY(-2px); }
.cosmos-site-card img { height: 48px; width: auto; max-width: 100%; }
.cosmos-site-card span { font-weight: 600; }
.cosmos-site-card-description {
  margin: -0.5rem 0 0;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-muted);
  text-align: center;
}

.cosmos-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 2rem 1rem;
}

.cosmos-error-code { font-size: 0.9rem; color: var(--text-muted); letter-spacing: 0.05em; }
