/* Visuality ONE Design System */
/* Shared across all modules: ONE, Apps, Projects, Websites, Users */

:root {
  color-scheme: light;

  --bg: #f6f7fb;
  --surface: #ffffff;
  --card: #ffffff;
  --raised: #f1f3f9;
  --border: #e3e7ef;
  --border-strong: #ccd3e0;
  --text: #0f1626;
  --dim: #5a6478;
  --dim-2: #8b93a4;

  --platform-accent: #0b6bcb;
  --platform-accent-hover: #0a5cab;
  --platform-accent-soft: rgba(11, 107, 203, 0.09);
  --platform-accent-ring: rgba(11, 107, 203, 0.35);

  /* Module accent: a module sets --module-accent (with -hover, -ink,
     -soft) once; these derive from it, so a module never has to
     out-specify a scheme block to keep its own accent. */
  --accent: var(--module-accent, var(--platform-accent));
  --accent-hover: var(--module-accent-hover, var(--platform-accent-hover));
  --accent-soft: var(--module-accent-soft, var(--platform-accent-soft));
  --accent-ring: var(--platform-accent-ring);

  /* Ink that sits ON an accent surface. Light mode needs white ink on the
     darker accent; dark mode needs near-black ink on the lighter accent. This
     is the token whose absence made primary buttons unreadable in light mode. */
  --platform-accent-ink: #ffffff;
  --accent-ink: var(--module-accent-ink, var(--platform-accent-ink));
  --accent-ink-hover: var(--accent-ink);
  --on-danger: #ffffff;

  /* Form controls: one place to change every input in every module. */
  --field: #ffffff;
  --field-border: #ccd3e0;
  --field-placeholder: #8b93a4;
  --focus-ring: 0 0 0 3px rgba(11, 107, 203, 0.28);

  --ok: #0f8a5f;
  --ok-soft: rgba(15, 138, 95, 0.10);

  --danger: #c2333b;
  --danger-soft: rgba(194, 51, 59, 0.09);

  --warn: #9a6a00;
  --warn-soft: rgba(154, 106, 0, 0.10);

  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 4px;

  --tap: 40px;
  --page: 1080px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #090d16;
  --surface: #0d131f;
  --card: #111827;
  --raised: #1a2336;
  --border: #1f293d;
  --border-strong: #2c3a52;
  --text: #f1f5f9;
  --dim: #94a3b8;
  --dim-2: #6b7688;
  --platform-accent: #38bdf8;
  --platform-accent-hover: #7dd3fc;
  --platform-accent-soft: rgba(56, 189, 248, 0.12);
  --platform-accent-ring: rgba(56, 189, 248, 0.45);

  /* Module accent: a module sets --module-accent (with -hover, -ink,
     -soft) once; these derive from it, so a module never has to
     out-specify a scheme block to keep its own accent. */
  --accent: var(--module-accent, var(--platform-accent));
  --accent-hover: var(--module-accent-hover, var(--platform-accent-hover));
  --accent-soft: var(--module-accent-soft, var(--platform-accent-soft));
  --accent-ring: var(--platform-accent-ring);

  --platform-accent-ink: #04121f;
  --accent-ink: var(--module-accent-ink, var(--platform-accent-ink));
  --accent-ink-hover: var(--accent-ink);
  --on-danger: #04121f;

  --field: #0d131f;
  --field-border: #2c3a52;
  --field-placeholder: #6b7688;
  --focus-ring: 0 0 0 3px rgba(56, 189, 248, 0.38);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #090d16;
    --surface: #0d131f;
    --card: #111827;
    --raised: #1a2336;
    --border: #1f293d;
    --border-strong: #2c3a52;
    --text: #f1f5f9;
    --dim: #94a3b8;
    --dim-2: #6b7688;
    --platform-accent: #38bdf8;
    --platform-accent-hover: #7dd3fc;
    --platform-accent-soft: rgba(56, 189, 248, 0.12);
    --platform-accent-ring: rgba(56, 189, 248, 0.45);

    /* Module accent: a module sets --module-accent (with -hover, -ink,
       -soft) once; these derive from it, so a module never has to
       out-specify a scheme block to keep its own accent. */
    --accent: var(--module-accent, var(--platform-accent));
    --accent-hover: var(--module-accent-hover, var(--platform-accent-hover));
    --accent-soft: var(--module-accent-soft, var(--platform-accent-soft));
    --accent-ring: var(--platform-accent-ring);

    --platform-accent-ink: #04121f;
    --accent-ink: var(--module-accent-ink, var(--platform-accent-ink));
    --accent-ink-hover: var(--accent-ink);
    --on-danger: #04121f;

    --field: #0d131f;
    --field-border: #2c3a52;
    --field-placeholder: #6b7688;
    --focus-ring: 0 0 0 3px rgba(56, 189, 248, 0.38);
    --ok: #34d399;
    --ok-soft: rgba(52, 211, 153, 0.12);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.12);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.12);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

h1, h2, h3, h4, h5, h6 {
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0 0 0.5em;
  font-weight: 650;
}

h1 { font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2rem); }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }

p { margin: 0 0 1em; }

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--raised);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  z-index: 50;
}

.skip:focus {
  left: 12px;
  top: 12px;
}

/* ---------- Top Bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px max(16px, calc((100% - var(--page)) / 2));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
  min-height: 60px;
}

.topbar__nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.topbar__nav a {
  color: var(--dim);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.topbar__nav a:hover {
  color: var(--text);
  background: var(--raised);
  text-decoration: none;
}

.topbar__nav a[aria-current="page"] {
  color: var(--text);
  background: var(--raised);
}

.release {
  font-size: 0.7rem;
  color: var(--dim-2);
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 8px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  margin-left: 8px;
  background: var(--surface);
  color: var(--dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

/* ---------- Brand + Module Menu ---------- */

.brandmenu {
  position: relative;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  font-size: 0.98rem;
  padding: 6px 8px;
  cursor: pointer;
}

.brand:hover {
  background: var(--raised);
}

.brand__mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  object-fit: contain;
  background: var(--raised);
}

.brand__name strong {
  color: var(--accent);
  font-weight: 700;
}

.brand__chev {
  color: var(--dim);
  transition: transform 0.15s ease;
}

.brand[aria-expanded="true"] .brand__chev {
  transform: rotate(180deg);
}

.menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  width: 260px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.menu[hidden] {
  display: none;
}

.menu__label {
  margin: 8px 8px 4px;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim-2);
}

.menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  text-decoration: none;
}

.menu__item:hover,
.menu__item:focus-visible {
  background: var(--raised);
  text-decoration: none;
}

.menu__item--home {
  font-weight: 600;
}

.menu__item--soon {
  color: var(--dim-2);
  cursor: default;
}

.menu__item--soon:hover {
  background: transparent;
}

.menu__item em {
  margin-left: auto;
  font-style: normal;
  font-size: 0.7rem;
  color: var(--dim-2);
}

.menu__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.menu__sep {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}

/* ---------- Buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.button:hover {
  background: var(--raised);
  color: var(--text);
  text-decoration: none;
}

.button--primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
}

.button--primary:hover {
  background: var(--accent-hover);
  color: var(--accent-ink-hover);
}

.button--danger {
  background: var(--danger);
  border-color: transparent;
  color: var(--on-danger);
}

.button--danger:hover {
  background: color-mix(in srgb, var(--danger) 86%, #000);
  color: var(--on-danger);
}

.button--secondary {
  background: var(--surface);
  border-color: var(--border-strong);
}

.button--quiet {
  background: transparent;
  border-color: transparent;
  color: var(--dim);
}

.button--quiet:hover {
  background: var(--raised);
  color: var(--text);
}

.button--sm {
  min-height: 32px;
  padding: 0 12px;
  font-size: 0.82rem;
}

.button--md {
  min-height: var(--tap);
  padding: 0 16px;
  font-size: 0.9rem;
}

.button--lg {
  min-height: 48px;
  padding: 0 24px;
  font-size: 1rem;
}

.button:disabled {
  opacity: 0.55;
  cursor: progress;
}

/* ---------- Form controls (shared by every module) ---------- */

input,
select,
textarea {
  font: inherit;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--field-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  min-height: var(--tap);
}

textarea {
  min-height: 84px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--field-placeholder);
  opacity: 1;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: var(--accent);
}

input:disabled,
select:disabled,
textarea:disabled,
.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

/* ---------- Cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card--elevated {
  box-shadow: var(--shadow);
}

.card--outlined {
  box-shadow: none;
  border-color: var(--border-strong);
}

.card--padding-none { padding: 0; }
.card--padding-sm { padding: 12px; }
.card--padding-md { padding: 18px; }
.card--padding-lg { padding: 24px; }

/* ---------- Modal ---------- */

.modal__overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal__title {
  margin: 0;
  font-size: 1.1rem;
}

.modal__close {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--dim);
  border-radius: var(--radius-xs);
}

.modal__close:hover {
  background: var(--raised);
  color: var(--text);
}

.modal__body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* ---------- Avatars ---------- */

.avatar {
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar__fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: white;
  font-weight: 600;
  font-size: 0.85em;
  text-transform: uppercase;
}

.avatar--sm .avatar__fallback { font-size: 0.7rem; }
.avatar--md .avatar__fallback { font-size: 0.8rem; }
.avatar--lg .avatar__fallback { font-size: 0.9rem; }
.avatar--xl .avatar__fallback { font-size: 1rem; }

/* ---------- Status Dots ---------- */

.status__dot {
  border-radius: 50%;
  flex: 0 0 auto;
}

.status__dot--ok {
  background: var(--ok);
}

.status__label {
  margin-left: 6px;
  font-size: 0.82rem;
  color: var(--dim);
}

/* ---------- Utility Classes ---------- */

.text--dim { color: var(--dim); }
.text--dim-2 { color: var(--dim-2); }
.text--accent { color: var(--accent); }
.text--ok { color: var(--ok); }
.text--danger { color: var(--danger); }

.text--sm { font-size: 0.82rem; }
.text--xs { font-size: 0.72rem; }

.font--mono { font-family: var(--mono); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

/* ---------- Media Queries ---------- */

@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    row-gap: 6px;
    padding: 8px 14px;
  }

  .topbar__nav {
    order: 3;
    width: 100%;
    margin-left: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }

  .topbar__nav a {
    padding: 7px 9px;
  }

  .release {
    display: none;
  }

  .brand__name {
    font-size: 0.92rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
