/* YugmaLink dashboard. Color, type and motion tokens match yugmalink.com. */

:root {
  color-scheme: dark;

  --paper: #090909;
  --panel: #141414;
  --surface: #181716;
  --panel-glass: rgb(20 20 20 / 0.86); /* panels over the 3D scene */
  --surface-glass: rgb(24 23 22 / 0.94);
  --line: #292827;
  --line-strong: #45423f;
  --ink: #f3f1ee;
  --graphite: #cecbc7;
  --slate: #a5a29e;
  --mist: #92908d;
  --signal: #ff9d68;
  --signal-hover: #ffb48c;
  --signal-soft: #2b211b;
  --warn: #ffa39d;

  --font-sans: "Geist Variable", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono Variable", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);

  --sidebar-width: 15rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 10;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  background: var(--ink);
  color: var(--paper);
  font-weight: 500;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* ---------- Shell ---------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.sidebar {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 2.25rem;
  padding: 1.5rem 0.875rem 1.25rem;
  border-right: 1px solid var(--line);
  background: var(--paper);
}

.brand {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-md);
  font-size: 1.3125rem;
  font-weight: 650;
  letter-spacing: -0.04em;
  line-height: 1;
}

.brand-mark {
  width: auto;
  height: 1.125rem;
  filter: invert(1);
}

.brand-period {
  color: var(--signal);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-md);
  color: var(--slate);
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.15s, background-color 0.15s;
}

.nav-link svg {
  flex: none;
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-link:hover {
  color: var(--ink);
  background: var(--panel);
}

/* aria-current is "page" on the current page's item and "true" on its section's item */
.nav-link[aria-current] {
  color: var(--ink);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.nav-link[aria-current] svg {
  color: var(--signal);
}

/* Sidebar footer: who is signed in, and the Core API status */

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  margin-top: auto;
  padding-top: 0.875rem;
  border-top: 1px solid var(--line);
}

.account {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.625rem;
}

.account[hidden] {
  display: none;
}

.account-email {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--graphite);
  font-size: 0.8125rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-sign-out {
  flex: none;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--slate);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.account-sign-out:hover {
  border-color: var(--mist);
  color: var(--ink);
}

.api-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.625rem;
  color: var(--mist);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.api-status-label {
  margin-left: auto;
}

.api-status-dot {
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 50%;
  background: var(--mist);
}

.api-status[data-state="online"] .api-status-dot {
  background: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-soft);
}

.api-status[data-state="online"] .api-status-label {
  color: var(--graphite);
}

.api-status[data-state="offline"] .api-status-dot {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--warn);
}

.api-status[data-state="offline"] .api-status-label {
  color: var(--warn);
}

/* ---------- Stage: the three.js scene sits behind the current page ---------- */

.stage {
  position: relative;
  overflow: hidden;
  outline: none;
}

.scene {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 1.6s var(--ease-out-expo);
}

.scene.is-ready {
  opacity: 1;
}

.view {
  position: relative;
  height: 100%;
  overflow-y: auto;
  padding: clamp(1.5rem, 0.75rem + 3vw, 3.5rem);
}

/* ---------- Pages ---------- */

.page {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 56rem;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.page-heading {
  min-width: 0;
}

.page-description {
  margin: 0.5rem 0 0;
  color: var(--slate);
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  padding: 0;
  list-style: none;
  color: var(--mist);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.breadcrumb li + li::before {
  content: "/";
  margin-right: 0.5rem;
  color: var(--line-strong);
}

.breadcrumb a:hover {
  color: var(--ink);
}

.breadcrumb [aria-current] {
  color: var(--graphite);
}

.page-title {
  margin: 0;
  font-size: clamp(1.75rem, 1.1rem + 1.7vw, 2.5rem);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.1;
  outline: none;
}

.page-empty {
  margin: 0;
  color: var(--mist);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.page-empty a {
  color: var(--signal);
  text-underline-offset: 3px;
}

.page-empty a:hover {
  text-decoration: underline;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Buttons and icons ---------- */

.icon {
  flex: none;
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.25rem;
  padding: 0 0.875rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: none;
  color: inherit;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}

.button-primary {
  background: var(--signal);
  color: var(--paper);
}

.button-primary:hover {
  background: var(--signal-hover);
}

.button-secondary {
  border-color: var(--line-strong);
  background: var(--panel-glass);
  color: var(--ink);
}

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

.button-quiet {
  color: var(--slate);
}

.button-quiet:hover {
  background: var(--panel);
  color: var(--ink);
}

/* ---------- Shared blocks ---------- */

.async-content,
.wizard-step {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel,
.notice {
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel-glass);
}

.panel-title {
  margin: 0 0 0.75rem;
  color: var(--mist);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.notice p {
  margin: 0;
  color: var(--graphite);
}

.notice-error {
  border-color: rgb(255 163 157 / 0.35);
}

.notice-error p {
  color: var(--warn);
}

/* ---------- Connections ---------- */

/* Provider logos are single-color SVGs used as masks, so they take the text color. */
.type-logo {
  display: block;
  flex: none;
  width: 4.5rem;
  height: 1.75rem;
  background-color: currentColor;
  -webkit-mask: var(--logo) left center / contain no-repeat;
  mask: var(--logo) left center / contain no-repeat;
  transition: color 0.15s;
}

.connection-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel-glass);
}

.connection-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
}

.connection-row + .connection-row {
  border-top: 1px solid var(--line);
}

.connection-row .type-logo {
  width: 3rem;
  height: 1.25rem;
  color: var(--graphite);
}

.connection-name {
  font-weight: 500;
}

.connection-type {
  margin-left: auto;
  color: var(--mist);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

/* New-connection flow: progress */

.stepper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--mist);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.step + .step::before {
  content: "";
  width: 2.5rem;
  height: 1px;
  background: var(--line-strong);
}

.step > a,
.step > span {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.step.is-done {
  color: var(--graphite);
}

.step.is-current {
  color: var(--ink);
}

.step.is-done .step-number,
.step.is-current .step-number {
  color: var(--signal);
}

.step > a:hover .step-label {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.step-value {
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  background: var(--signal-soft);
  color: var(--signal);
}

.step-lead {
  margin: 0;
  color: var(--slate);
}

.wizard-footer {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

/* New-connection flow: connection type tiles */

.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.type-tile {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "logo arrow"
    "text text"
    "status status";
  grid-template-rows: auto 1fr auto; /* status lines up along the bottom of every tile */
  height: 100%;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel-glass);
  color: var(--ink);
  transition: border-color 0.15s, background-color 0.15s;
}

.type-tile .type-logo {
  grid-area: logo;
  color: var(--graphite);
}

.type-tile > .icon {
  grid-area: arrow;
  color: var(--mist);
  transition: color 0.15s, transform 0.3s var(--ease-out-expo);
}

.type-text {
  grid-area: text;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  margin-top: 1.5rem;
}

.type-name {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.type-description {
  color: var(--mist);
  font-size: 0.8125rem;
}

/* ● Available / ○ Coming soon, same language as the Core API status */
.type-status {
  grid-area: status;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.875rem;
  color: var(--mist);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
}

.type-status::before {
  content: "";
  flex: none;
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.25px currentColor;
}

a.type-tile .type-status {
  color: var(--graphite);
}

a.type-tile .type-status::before {
  background: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-soft);
}

a.type-tile:hover {
  border-color: var(--line-strong);
  background: var(--surface-glass);
}

a.type-tile:hover .type-logo,
a.type-tile:focus-visible .type-logo {
  color: var(--signal);
}

a.type-tile:hover > .icon {
  color: var(--ink);
  transform: translateX(3px);
}

.type-tile.is-disabled {
  background: rgb(14 14 14 / 0.82);
  color: var(--slate);
  cursor: not-allowed;
}

.type-tile.is-disabled .type-logo {
  color: var(--mist);
  opacity: 0.5;
}

/* ---------- Sign-in ---------- */

/* While the session is being checked on load, show only the 3D scene. */
.is-starting .sidebar,
.is-starting .view {
  visibility: hidden;
}

.is-signed-out .app {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}

.is-signed-out .sidebar {
  display: none;
}

.sign-in {
  display: grid;
  place-items: center;
  min-height: 100%;
}

.sign-in-card {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: min(100%, 24rem);
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel-glass);
}

.sign-in-brand {
  padding: 0;
}

.sign-in-card .page-title {
  font-size: 1.75rem;
}

.sign-in-card .page-description {
  margin-top: 0.375rem;
  font-size: 0.875rem;
}

.sign-in-notice {
  margin: 0;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--graphite);
  font-size: 0.8125rem;
}

.sign-in-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.field label {
  color: var(--graphite);
  font-size: 0.8125rem;
  font-weight: 500;
}

.input {
  height: 2.5rem;
  padding: 0 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: rgb(9 9 9 / 0.7);
  color: var(--ink);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:hover {
  border-color: var(--mist);
}

.input:focus {
  outline: none;
  border-color: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-soft);
}

/* Browsers paint autofilled fields light; keep them dark. */
.input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--ink);
  box-shadow: 0 0 0 100px var(--panel) inset;
}

.input:-webkit-autofill:focus {
  box-shadow: 0 0 0 100px var(--panel) inset, 0 0 0 3px var(--signal-soft);
}

.form-error {
  margin: 0;
  color: var(--warn);
  font-size: 0.8125rem;
}

.form-error:empty {
  display: none;
}

.button-block {
  width: 100%;
  height: 2.5rem;
}

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

/* ---------- Small screens: the sidebar becomes a top bar ---------- */

@media (max-width: 767px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    order: 3;
    flex-direction: row;
    width: 100%;
  }

  .nav-link {
    flex: 1;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem 0.25rem;
    font-size: 0.75rem;
  }

  .sidebar-footer {
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0 0 auto;
    padding: 0;
    border-top: 0;
  }

  .account,
  .api-status {
    padding: 0;
  }

  .account-email {
    display: none;
  }

  /* Screen readers still hear "Core API"; on screen the dot and Online/Offline are enough. */
  .api-status-name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .api-status-label {
    margin-left: 0;
  }

  /* Header actions wrap under the title here, so a quiet button reads as a flush-left link. */
  .page-actions .button-quiet {
    height: auto;
    padding-inline: 0;
  }

  .page-actions .button-quiet:hover {
    background: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
