/* ==========================================================================
   AIOS Web Dashboard
   Design system inherited from szha.ai — navy, white, camel, olive palette.
   ========================================================================== */

/* --- Custom Properties --- */
:root {
  --bg: #FAFAFA;
  --bg-card: #FFFFFF;
  --text: #1C2541;
  --text-heading: #111111;
  --text-secondary: #6B7280;
  --accent: #C4A77D;
  --accent-hover: #A8895F;
  --accent-secondary: #5B6B4A;
  --border: #E5E5E5;
  --rule: #1C2541;
  --nav-bg: rgba(250, 250, 250, 0.85);
  --font-heading: 'DM Serif Display', Georgia, 'Times New Roman', serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow-card: 0 1px 3px rgba(28, 37, 65, 0.06), 0 1px 2px rgba(28, 37, 65, 0.04);
  --shadow-card-hover: 0 8px 25px rgba(28, 37, 65, 0.1), 0 3px 8px rgba(28, 37, 65, 0.06);
  --status-ok: #22C55E;
  --status-warn: #F59E0B;
  --status-off: #9CA3AF;
}

[data-theme="dark"] {
  --bg: #0D1B2A;
  --bg-card: #162638;
  --text: #F5F5F5;
  --text-heading: #FFFFFF;
  --text-secondary: #9CA3AF;
  --accent: #D4B896;
  --accent-hover: #E0CAA8;
  --accent-secondary: #8FA87E;
  --border: #2A3F55;
  --rule: #3B5068;
  --nav-bg: rgba(13, 27, 42, 0.75);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.15);
  --shadow-card-hover: 0 8px 25px rgba(0, 0, 0, 0.3), 0 3px 8px rgba(0, 0, 0, 0.2);
  --status-ok: #4ADE80;
  --status-warn: #FBBF24;
  --status-off: #6B7280;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  background-image: linear-gradient(180deg, var(--bg) 0%, color-mix(in srgb, var(--accent) 3%, var(--bg)) 100%);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

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

/* --- Typography --- */
h1, h2 {
  font-family: var(--font-heading);
  color: var(--text-heading);
  line-height: 1.15;
  font-weight: 400;
}

h3 {
  font-family: var(--font-body);
  color: var(--text-heading);
  line-height: 1.3;
  font-weight: 600;
}

h1 {
  font-size: clamp(2.5rem, 6vw, 4rem);
  letter-spacing: -0.01em;
}

h2 {
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  margin-bottom: 1.5rem;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

p {
  margin-bottom: 1rem;
}

p:last-child {
  margin-bottom: 0;
}

/* --- Layout --- */
.section {
  max-width: 48rem;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

.section-rule {
  max-width: 48rem;
  margin: 0 auto;
  border: none;
  border-top: 2px solid var(--rule);
  opacity: 0.2;
}

/* --- Navigation --- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s ease;
}

.nav-inner {
  max-width: 48rem;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav.scrolled {
  box-shadow: 0 2px 12px rgba(28, 37, 65, 0.08);
}

.nav-name {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-heading);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.nav-name:hover {
  color: var(--text-heading);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-links a {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
  transition: color 0.2s ease;
}

.nav-links a:hover {
  color: var(--text);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.nav-toggle.active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle.active span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* --- Theme Toggle --- */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, border-color 0.2s ease;
  min-width: 34px;
  min-height: 34px;
}

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

.icon-sun, .icon-moon, .icon-auto { display: none; }
[data-mode="light"] .icon-sun { display: block; }
[data-mode="dark"] .icon-moon { display: block; }
[data-mode="auto"] .icon-auto { display: block; }

/* --- Hero --- */
.hero {
  max-width: 48rem;
  margin: 0 auto;
  padding: 4rem 1.5rem 3rem;
}

.hero-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.5rem;
}

.hero-text {
  flex: 1;
}

.hero-tagline {
  font-size: clamp(1.05rem, 2.5vw, 1.2rem);
  color: var(--text);
  margin: 0.75rem 0 1rem;
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.6;
  font-weight: 500;
}

.hero-sub {
  font-size: 0.925rem;
  color: var(--text-secondary);
  margin: 0 0 1.5rem;
}

/* CTA button */
.cta-btn {
  display: inline-block;
  padding: 0.75rem 2rem;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 6px;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.cta-btn:hover {
  background: var(--accent-hover);
  color: var(--bg);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 30%, transparent);
}

/* --- Card Grid --- */
.built-grid {
  display: grid;
  gap: 1.5rem;
}

.built-item {
  position: relative;
  padding: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.built-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.built-item h3 {
  color: var(--text-heading);
}

.built-item p:last-of-type {
  color: var(--text-secondary);
  font-size: 0.925rem;
}

/* --- Section heading centered --- */
.aios-section h2 {
  text-align: center;
}

/* --- Numbered steps --- */
.steps-list {
  list-style: none;
  padding: 0;
  counter-reset: step;
  display: grid;
  gap: 1.5rem;
  margin-top: 1.25rem;
}

.steps-list li {
  counter-increment: step;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.steps-list li::before {
  content: counter(step);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: 50%;
}

.steps-list li div {
  flex: 1;
}

.steps-list li strong {
  display: block;
  color: var(--text-heading);
  margin-bottom: 0.15rem;
}

.steps-list li span {
  font-size: 0.925rem;
  color: var(--text-secondary);
}

/* --- Privacy list --- */
.privacy-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: grid;
  gap: 0.6rem;
}

.privacy-list li {
  position: relative;
  padding-left: 1.5rem;
  font-size: 0.95rem;
  color: var(--text);
}

.privacy-list li::before {
  content: '\1F512';
  position: absolute;
  left: 0;
  font-size: 0.8rem;
}

/* --- Integration categories --- */
.integration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.integration-item {
  padding: 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.integration-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.integration-item h3 {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.integration-item p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 0;
}

/* --- Contact --- */
.contact-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.contact-links a {
  font-weight: 500;
}

/* --- Dashboard-specific --- */
.dashboard-panels {
  display: grid;
  gap: 2rem;
}

.dashboard-panel h2 {
  text-align: left;
  margin-bottom: 1rem;
}

.connection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.connection-card {
  border-left: 3px solid var(--border);
}

.connection-card:has(.status-fresh) {
  border-left-color: var(--status-ok);
}

.connection-card:has(.status-expired) {
  border-left-color: var(--status-warn);
}

.connection-header h3 {
  margin-bottom: 0;
}

.status-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  white-space: nowrap;
}

.status-fresh {
  background: color-mix(in srgb, var(--status-ok) 15%, transparent);
  color: var(--status-ok);
}

.status-expired {
  background: color-mix(in srgb, var(--status-warn) 15%, transparent);
  color: var(--status-warn);
}

.connection-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.connection-scopes {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-family: monospace;
  word-break: break-all;
}

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 2rem 1rem;
  font-style: italic;
}

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, color-mix(in srgb, var(--border) 50%, var(--bg-card)) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: 6px;
  height: 1rem;
  margin-bottom: 0.5rem;
}

.skeleton-card {
  padding: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.skeleton-card .skeleton:first-child { width: 40%; height: 1.2rem; }
.skeleton-card .skeleton:nth-child(2) { width: 25%; height: 0.8rem; }
.skeleton-card .skeleton:last-child { width: 60%; }

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Staggered card reveal */
@keyframes card-appear {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dashboard-panels .built-item {
  animation: card-appear 0.4s ease both;
}

.dashboard-panels .built-item:nth-child(1) { animation-delay: 0s; }
.dashboard-panels .built-item:nth-child(2) { animation-delay: 0.08s; }
.dashboard-panels .built-item:nth-child(3) { animation-delay: 0.16s; }
.dashboard-panels .built-item:nth-child(4) { animation-delay: 0.24s; }
.dashboard-panels .built-item:nth-child(5) { animation-delay: 0.32s; }

#dashboard-content {
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* --- Footer --- */
.footer {
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

.footer-inner {
  max-width: 48rem;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-links {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.footer-links a {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-copy {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* --- Scroll Animations --- */
/* Content visible by default; JS adds html.js to enable animated reveals */
.section, .hero {
  transition: opacity 0.5s ease, transform 0.5s ease;
}

html.js .section,
html.js .hero {
  opacity: 0;
  transform: translateY(20px);
}

html.js .section.visible,
html.js .hero.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Screen Reader Only --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 639px) {
  .nav-toggle {
    display: flex;
  }

  .nav-links {
    position: fixed;
    top: 0;
    right: -100%;
    width: 70%;
    max-width: 280px;
    height: 100vh;
    background: var(--bg);
    flex-direction: column;
    align-items: flex-start;
    padding: 4rem 1.5rem 2rem;
    gap: 1.25rem;
    border-left: 1px solid var(--border);
    transition: right 0.3s ease;
    z-index: 200;
  }

  .nav-links.open {
    right: 0;
  }

  .nav-links a {
    font-size: 1rem;
  }

  .hero {
    padding: 2.5rem 1.5rem 2rem;
  }

  .section {
    padding: 2rem 1.5rem;
  }

  .footer-inner {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .footer-links {
    justify-content: center;
  }

  .integration-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1024px) {
  .hero {
    padding-top: 5rem;
  }

  .section {
    padding: 4rem 1.5rem;
  }
}
