/* ============================================================
   SutraHub — brand theme for Forgejo
   Dark + light, driven by semantic tokens.
   Motion follows Emil Kowalski's rules: ease-out on entry,
   <300ms for UI, transform/opacity only, reduced-motion honoured.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* brand ramp, taken from the logo gradient */
  --sh-orange: #fdba33;
  --sh-coral:  #ce558b;
  --sh-violet: #9456e6;
  --sh-blue:   #544eef;
  --sh-gradient: linear-gradient(115deg, var(--sh-orange), var(--sh-coral) 38%, var(--sh-violet) 72%, var(--sh-blue));

  /* motion — strong curves; CSS defaults are too weak */
  --sh-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --sh-ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --sh-fast: 140ms;
  --sh-base: 200ms;

  --sh-radius: 10px;
  --sh-radius-lg: 14px;
}

/* ---------- DARK (default) ---------- */
[data-theme="sutrahub-dark"], .theme-sutrahub-dark {
  --sh-bg:        #01020f;
  --sh-surface:   #0b0d1d;
  --sh-surface-2: #141731;
  --sh-border:    #242a4d;
  --sh-text:      #f2f0f7;   /* 15.8:1 on --sh-bg */
  --sh-text-dim:  #a8a2c0;   /*  6.4:1 — passes AA for secondary */
  --sh-accent:    #a97cf0;
  --sh-shadow:    0 1px 2px rgb(0 0 0 / .4), 0 8px 24px -8px rgb(0 0 0 / .5);
}

/* ---------- LIGHT ---------- */
[data-theme="sutrahub-light"], .theme-sutrahub-light {
  --sh-bg:        #fbfaff;
  --sh-surface:   #ffffff;
  --sh-surface-2: #f4f2fb;
  --sh-border:    #e2ddf0;
  --sh-text:      #17142a;   /* 15.2:1 on --sh-bg */
  --sh-text-dim:  #5d5675;   /*  6.9:1 */
  --sh-accent:    #7a3fe0;
  --sh-shadow:    0 1px 2px rgb(23 20 42 / .06), 0 8px 24px -10px rgb(23 20 42 / .14);
}

/* map onto Forgejo's own variables so every component follows */
[data-theme="sutrahub-dark"], .theme-sutrahub-dark {
  --color-body: var(--sh-bg);
  --color-box-body: var(--sh-surface);
  --color-box-header: var(--sh-surface-2);
  --color-text: var(--sh-text);
  --color-text-light: var(--sh-text-dim);
  --color-text-light-2: var(--sh-text-dim);
  --color-secondary: var(--sh-surface-2);
  --color-secondary-dark-1: var(--sh-border);
  --color-primary: var(--sh-accent);
  --color-primary-dark-1: var(--sh-violet);
  --color-primary-light-1: var(--sh-violet);
  --color-primary-contrast: #ffffff;
  --color-nav-bg: var(--sh-surface);
  --color-nav-hover-bg: var(--sh-surface-2);
  --color-menu: var(--sh-surface);
  --color-card: var(--sh-surface);
  --color-markup-code-block: var(--sh-surface-2);
  --color-input-background: var(--sh-surface);
  --color-input-border: var(--sh-border);
  --color-input-text: var(--sh-text);
  --color-light-border: var(--sh-border);
  --color-caret: var(--sh-accent);
  --color-shadow: var(--sh-shadow);
  --color-console-bg: var(--sh-surface-2);

  background-color: var(--sh-bg);
  color: var(--sh-text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}

code, pre, .file-view, .lines-code, .code-view {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace !important;
  font-variant-ligatures: none;
}

/* tabular figures stop numbers jittering as they update */
.ui.label, .commit-counter, .stats-table, td.num { font-variant-numeric: tabular-nums; }

/* ---------- brand surfaces ---------- */
.full.height > .following.bar .navbar,
#navbar, .page-content > .navbar {
  background: var(--sh-surface) !important;
  border-bottom: 1px solid var(--sh-border) !important;
  backdrop-filter: saturate(140%) blur(8px);
}

/* wordmark gradient */
#navbar .brand strong, .navbar-brand strong {
  background: var(--sh-gradient);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700; letter-spacing: -.02em;
}

/* ---------- buttons: press feedback is non-negotiable ---------- */
.ui.button, .ui.primary.button, button {
  border-radius: var(--sh-radius) !important;
  font-weight: 500;
  transition: transform var(--sh-fast) var(--sh-ease-out),
              background-color var(--sh-fast) ease,
              border-color var(--sh-fast) ease,
              box-shadow var(--sh-fast) ease !important;
}
.ui.button:active, button:active { transform: scale(0.97); }

.ui.primary.button {
  background: var(--sh-gradient) !important;
  border: none !important;
  color: #fff !important;
  box-shadow: 0 1px 2px rgb(0 0 0 / .18);
}
.ui.primary.button:hover { filter: brightness(1.07); box-shadow: 0 4px 14px -4px var(--sh-violet); }

/* ---------- cards & panels ---------- */
.ui.segment, .ui.card, .repository .ui.segment, .flex-item, .ui.attached.segment {
  background: var(--sh-surface) !important;
  border: 1px solid var(--sh-border) !important;
  border-radius: var(--sh-radius-lg) !important;
  box-shadow: var(--sh-shadow);
}

/* ---------- inputs ---------- */
input, textarea, .ui.input > input, .ui.form input {
  background: var(--sh-surface) !important;
  border: 1px solid var(--sh-border) !important;
  border-radius: var(--sh-radius) !important;
  color: var(--sh-text) !important;
  transition: border-color var(--sh-fast) ease, box-shadow var(--sh-fast) ease !important;
}
input:focus, textarea:focus, .ui.input > input:focus {
  border-color: var(--sh-accent) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sh-accent) 22%, transparent) !important;
  outline: none;
}

/* autofill fix lives in sutrahub-app.css — it loads on every page regardless
   of the active theme, and the rule is written against theme tokens. */

/* focus ring must stay visible for keyboard users */
:focus-visible {
  outline: 2px solid var(--sh-accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- sidebar nav ---------- */
.ui.menu .item, .menu .item {
  border-radius: var(--sh-radius) !important;
  transition: background-color var(--sh-fast) ease, color var(--sh-fast) ease !important;
}
.ui.menu .active.item, .menu .item.active {
  background: color-mix(in srgb, var(--sh-violet) 16%, transparent) !important;
  color: var(--sh-text) !important;
  position: relative;
}
.ui.menu .active.item::before {
  content: ""; position: absolute; left: 0; top: 18%; bottom: 18%;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--sh-gradient);
}

/* ---------- links ---------- */
a { color: var(--sh-accent); transition: color var(--sh-fast) ease; }
a:hover { color: var(--sh-coral); }

/* ---------- labels / branch pills ---------- */
.ui.label, .ui.basic.label {
  border-radius: 999px !important;
  border: 1px solid var(--sh-border) !important;
  background: var(--sh-surface-2) !important;
  color: var(--sh-text-dim) !important;
  font-weight: 500;
}

/* ---------- tables ---------- */
.ui.table { border-radius: var(--sh-radius-lg) !important; border-color: var(--sh-border) !important; }
.ui.table thead th { background: var(--sh-surface-2) !important; color: var(--sh-text-dim) !important; }
.ui.table tbody tr { transition: background-color var(--sh-fast) ease; }
.ui.table tbody tr:hover { background: var(--sh-surface-2) !important; }

/* ---------- entry motion: stagger, short delays ---------- */
@media (prefers-reduced-motion: no-preference) {
  .repo-list > .flex-item, .flex-list > .flex-item, .dashboard .news > .item {
    animation: sh-rise 320ms var(--sh-ease-out) both;
  }
  .flex-list > .flex-item:nth-child(1) { animation-delay: 0ms }
  .flex-list > .flex-item:nth-child(2) { animation-delay: 40ms }
  .flex-list > .flex-item:nth-child(3) { animation-delay: 80ms }
  .flex-list > .flex-item:nth-child(4) { animation-delay: 120ms }
  .flex-list > .flex-item:nth-child(5) { animation-delay: 160ms }
  .flex-list > .flex-item:nth-child(n+6) { animation-delay: 200ms }
}
@keyframes sh-rise {
  from { opacity: 0; transform: translateY(8px) }
  to   { opacity: 1; transform: none }
}

/* dropdowns scale from their trigger, not from centre */
.ui.dropdown .menu {
  border-radius: var(--sh-radius) !important;
  border: 1px solid var(--sh-border) !important;
  background: var(--sh-surface) !important;
  box-shadow: var(--sh-shadow);
  transform-origin: top;
  animation: sh-pop 160ms var(--sh-ease-out) both;
}
@keyframes sh-pop {
  from { opacity: 0; transform: scale(0.96) translateY(-4px) }
  to   { opacity: 1; transform: none }
}

/* ---------- motion off when asked ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
  }
}

/* ---------- touch targets ---------- */
@media (max-width: 768px) {
  .ui.button, .menu .item, a.item { min-height: 44px; display: flex; align-items: center; }
}
