/* ==========================================================================
   Calgine Sites — base design tokens, header, footer, shared components
   Shared by the landing page (/index.html) and the docs (/docs/**).
   ========================================================================== */

:root {
  --ink: #0f172a;
  --ink-2: #334155;
  --ink-3: #475569;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e5e7eb;
  --line-soft: #eef0f3;
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --bg-mute: #f1f5f9;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #eff6ff;
  --ok: #059669;
  --warn: #b45309;
  --danger: #dc2626;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.07), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 10px 30px -12px rgba(15, 23, 42, 0.18);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --header-h: 64px;
  --container: 1200px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 24px);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-2);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img,
svg {
  display: block;
  max-width: 100%;
}

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

a:hover {
  color: var(--accent-strong);
}

h1,
h2,
h3,
h4 {
  color: var(--ink);
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin: 0;
}

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

::selection {
  background: #dbeafe;
  color: var(--ink);
}

.skip-link {
  position: absolute;
  top: -48px;
  left: 16px;
  z-index: 100;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 12px;
  color: #fff;
}

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-xs);
}

.btn-primary:hover {
  background: #1f2a3d;
  color: #fff;
}

.btn-outline {
  background: #fff;
  border-color: var(--line);
  color: var(--ink-2);
}

.btn-outline:hover {
  border-color: #cbd5e1;
  color: var(--ink);
}

.btn-ghost {
  color: var(--ink-2);
}

.btn-ghost:hover {
  background: var(--bg-mute);
  color: var(--ink);
}

.btn-sm {
  height: 34px;
  padding: 0 13px;
  font-size: 13px;
  border-radius: 9px;
}

.btn-lg {
  height: 46px;
  padding: 0 24px;
  font-size: 15px;
  border-radius: 12px;
}

.btn-block {
  width: 100%;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid var(--line-soft);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
}

.site-header-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  width: 100%;
  max-width: none;
  height: var(--header-h);
  margin: 0;
  padding: 0 clamp(16px, 2.5vw, 40px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  color: var(--ink);
  text-decoration: none;
}

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

.brand img {
  width: 26px;
  height: 26px;
}

.brand-name {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-name em {
  font-style: normal;
  font-weight: 600;
  color: var(--muted);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.site-nav a {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--ink-3);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.site-nav a:hover {
  background: var(--bg-mute);
  color: var(--ink);
}

.site-nav a[aria-current="page"] {
  background: var(--bg-mute);
  color: var(--ink);
  font-weight: 600;
}

.site-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* Language switch ---------------------------------------------------------- */

.lang {
  position: relative;
}

.lang-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-3);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.lang-trigger:hover {
  background: var(--bg-mute);
  color: var(--ink);
}

.lang-trigger svg {
  width: 15px;
  height: 15px;
  flex: none;
}

.lang-trigger .chevron {
  width: 12px;
  height: 12px;
  color: var(--faint);
  transition: transform 0.15s ease;
}

.lang[data-open="true"] .chevron {
  transform: rotate(180deg);
}

.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 156px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  z-index: 60;
}

.lang-menu[hidden] {
  display: none;
}

.lang-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}

.lang-menu button:hover {
  background: var(--bg-mute);
  color: var(--ink);
}

.lang-menu button[aria-checked="true"] {
  color: var(--accent);
  font-weight: 600;
}

.lang-menu .check {
  width: 14px;
  height: 14px;
  opacity: 0;
}

.lang-menu button[aria-checked="true"] .check {
  opacity: 1;
}

/* Login state -------------------------------------------------------------- */

.auth {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
}

.auth[data-loading="true"] {
  opacity: 0.65;
}

.user-menu {
  position: relative;
}

.user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 10px 0 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.user-trigger:hover {
  border-color: #cbd5e1;
  background: var(--bg-soft);
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e293b, #475569);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  flex: none;
}

.user-name {
  max-width: 132px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-caret {
  width: 12px;
  height: 12px;
  color: var(--faint);
}

.user-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 232px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  z-index: 60;
}

.user-popover[hidden] {
  display: none;
}

.user-popover-head {
  padding: 10px 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 6px;
}

.user-popover-name {
  display: block;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-popover-role {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.user-popover a,
.user-popover button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13.5px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.user-popover a:hover,
.user-popover button:hover {
  background: var(--bg-mute);
  color: var(--ink);
}

.user-popover svg {
  width: 15px;
  height: 15px;
  color: var(--muted);
}

/* Mobile navigation -------------------------------------------------------- */

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink-2);
  cursor: pointer;
}

.nav-toggle svg {
  width: 18px;
  height: 18px;
}

.mobile-panel {
  display: none;
  border-top: 1px solid var(--line-soft);
  background: #fff;
  padding: 10px 24px 18px;
}

.mobile-panel[data-open="true"] {
  display: block;
}

.mobile-panel a {
  display: block;
  padding: 11px 10px;
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
}

.mobile-panel a:hover,
.mobile-panel a[aria-current="page"] {
  background: var(--bg-mute);
  color: var(--ink);
}

@media (max-width: 900px) {
  .site-header-inner {
    gap: 12px;
    padding: 0 16px;
  }

  .site-nav {
    display: none;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .lang-trigger span {
    display: none;
  }

  .lang-trigger {
    padding: 0 8px;
    border-color: var(--line);
    background: #fff;
  }

  .lang-trigger .chevron {
    display: none;
  }
}

@media (max-width: 560px) {
  .brand-name em {
    display: none;
  }

  .site-actions {
    gap: 4px;
  }

  .auth .btn-sm {
    padding: 0 11px;
  }
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--line-soft);
  background: var(--bg-soft);
  margin-top: 96px;
}

.footer-inner {
  display: grid;
  grid-template-columns: minmax(240px, 1.1fr) 2fr;
  gap: 56px;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 56px clamp(16px, 2.5vw, 40px) 40px;
}

.footer-brand .brand {
  margin-bottom: 14px;
}

.footer-brand p {
  max-width: 320px;
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.75;
}

.footer-cols {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
}

.footer-col h4 {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.footer-col a {
  display: block;
  padding: 5px 0;
  color: var(--ink-2);
  font-size: 13.5px;
  text-decoration: none;
}

.footer-col a:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 18px clamp(16px, 2.5vw, 40px) 28px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
}

.footer-bottom a {
  color: var(--muted);
  text-decoration: none;
}

.footer-bottom a:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer-legal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
}

.footer-dot {
  color: #cbd5e1;
}

@media (max-width: 820px) {
  .footer-inner {
    grid-template-columns: 1fr;
    gap: 36px;
    padding: 44px 20px 32px;
  }

  .footer-cols {
    gap: 20px;
  }

  .footer-bottom {
    padding: 16px 20px 26px;
  }
}

@media (max-width: 480px) {
  .footer-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 28px;
  }
}

/* --------------------------------------------------------------------------
   Misc
   -------------------------------------------------------------------------- */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
