/* ==========================================================================
   Habitly — Official Design System & Static Website Stylesheet
   Follows the authoritative Habitly design tokens, colors, and layout rules.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design Tokens & CSS Variables
   -------------------------------------------------------------------------- */
:root {
  /* Brand Core Palette */
  --primary: #5B67F1;
  --primary-light: #7C83F7;
  --primary-dark: #4550D6;
  --primary-rgb: 91, 103, 241;

  /* Status Colors */
  --success: #43B581;
  --success-light: #E8F7F0;
  --warning: #F2B84B;
  --warning-light: #FEF8ED;
  --error: #E85D75;
  --error-light: #FDECEF;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  /* Border Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Layout */
  --container-max: 1120px;
  --header-height: 72px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Light Theme (Default) */
:root,
[data-theme="light"] {
  --bg-canvas: #F7F8FC;
  --surface: #FFFFFF;
  --surface-card: #FFFFFF;
  --surface-muted: #F0F2F8;
  --surface-elevated: #FFFFFF;

  --text-primary: #1F2430;
  --text-secondary: #73798A;
  --text-tertiary: #A5ABC0;

  --border: #EAECEF;
  --divider: #E7E9F2;
  --header-bg: rgba(247, 248, 252, 0.85);

  --card-shadow: 0 4px 20px -2px rgba(91, 103, 241, 0.05), 0 2px 8px -1px rgba(31, 36, 48, 0.03);
  --card-shadow-hover: 0 12px 30px -4px rgba(91, 103, 241, 0.12), 0 4px 12px -2px rgba(31, 36, 48, 0.05);
  --badge-bg: rgba(91, 103, 241, 0.08);
  --badge-text: #5B67F1;
}

/* Dark Theme */
[data-theme="dark"] {
  --bg-canvas: #12141A;
  --surface: #1C2029;
  --surface-card: #242936;
  --surface-muted: #1A1E27;
  --surface-elevated: #282E3C;

  --text-primary: #F1F3F7;
  --text-secondary: #8E95A5;
  --text-tertiary: #676E80;

  --border: #2E3444;
  --divider: #2E3444;
  --header-bg: rgba(18, 20, 26, 0.85);

  --card-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.45);
  --card-shadow-hover: 0 12px 32px -4px rgba(0, 0, 0, 0.65);
  --badge-bg: rgba(91, 103, 241, 0.2);
  --badge-text: #7C83F7;
}

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

html {
  font-family: var(--font-family);
  font-size: 16px;
  line-height: 1.6;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color var(--transition-base), color var(--transition-base);
}

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

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-light);
}

a:focus-visible, button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* --------------------------------------------------------------------------
   3. Layout & Container
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 24px;
}

main {
  flex: 1;
}

/* --------------------------------------------------------------------------
   4. Shared Header
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background-color: var(--header-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--divider);
  transition: background-color var(--transition-base), border-color var(--transition-base);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

/* Logo */
.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  transition: transform var(--transition-fast);
}

.brand-link:hover {
  color: var(--text-primary);
  transform: translateY(-1px);
}

.logo-badge {
  width: 36px;
  height: 36px;
  background-color: var(--primary);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(91, 103, 241, 0.3);
}

.logo-badge img {
  width: 36px;
  height: 36px;
}

/* Navigation */
.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  padding: 8px 14px;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.nav-link:hover {
  color: var(--text-primary);
  background-color: var(--surface-muted);
}

.nav-link.active {
  color: var(--primary);
  font-weight: 600;
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-github {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.btn-github:hover {
  color: var(--text-primary);
  border-color: var(--text-tertiary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.btn-github svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Theme Switcher */
.theme-switch-group {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  background-color: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
}

.theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.theme-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.theme-btn:hover {
  color: var(--text-primary);
}

.theme-btn.active {
  background-color: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Mobile Menu Toggle */
.mobile-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  background-color: var(--surface);
  border: 1px solid var(--border);
}

.mobile-menu-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* --------------------------------------------------------------------------
   5. Mobile Drawer
   -------------------------------------------------------------------------- */
.mobile-drawer {
  display: none;
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  background-color: var(--surface);
  border-bottom: 1px solid var(--divider);
  padding: 20px 24px 28px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  z-index: 99;
}

.mobile-drawer.open {
  display: block;
}

.mobile-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.mobile-nav-link {
  display: block;
  padding: 12px 14px;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
}

.mobile-nav-link.active,
.mobile-nav-link:hover {
  color: var(--primary);
  background-color: var(--surface-muted);
}

.mobile-drawer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  border-top: 1px solid var(--divider);
}

/* --------------------------------------------------------------------------
   6. Buttons & Badges
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  min-height: 46px;
}

.btn-primary {
  background-color: var(--primary);
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(91, 103, 241, 0.35);
}

.btn-primary:hover {
  background-color: var(--primary-light);
  color: #FFFFFF;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(91, 103, 241, 0.45);
}

.btn-secondary {
  background-color: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--text-tertiary);
  color: var(--text-primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--badge-text);
  background-color: var(--badge-bg);
  border-radius: var(--radius-full);
}

/* --------------------------------------------------------------------------
   7. Hero Section
   -------------------------------------------------------------------------- */
.hero-section {
  padding: 72px 0 64px;
  text-align: center;
}

.hero-content {
  max-width: 800px;
  margin: 0 auto;
}

.hero-badge-wrap {
  margin-bottom: 24px;
}

.hero-title {
  font-size: 3.25rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.hero-title .gradient-text {
  color: var(--primary);
}

.hero-desc {
  font-size: 1.25rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 36px;
}

.hero-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 56px;
}

/* SEE TAP DONE Cards */
.workflow-section {
  margin-top: 12px;
}

.workflow-header {
  margin-bottom: 32px;
}

.workflow-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.workflow-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.workflow-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--card-shadow);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.workflow-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--card-shadow-hover);
}

.workflow-card-img-wrap {
  width: 100%;
  aspect-ratio: 677 / 369;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 22px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--bg-canvas) 0%, var(--surface-muted) 100%);
  border: 1px solid var(--border);
  padding: 10px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
}

.workflow-card-img-wrap img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  border-radius: calc(var(--radius-md) - 4px);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  display: block;
}

.workflow-card:hover .workflow-card-img-wrap img {
  transform: scale(1.04);
}

.workflow-step-tag {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 6px;
}

.workflow-card h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.workflow-card p {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   8. Feature Sections & Grids
   -------------------------------------------------------------------------- */
.section {
  padding: 80px 0;
}

.section-alt {
  background-color: var(--surface);
  border-top: 1px solid var(--divider);
  border-bottom: 1px solid var(--divider);
}

.section-header {
  text-align: center;
  max-width: 720px;
  margin: 0 auto 52px;
}

.section-header .section-tag {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 12px;
  display: block;
}

.section-header h2 {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.025em;
  margin-bottom: 16px;
}

.section-header p {
  font-size: 1.125rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Grid cards */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 28px;
}

.card {
  background-color: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--card-shadow);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--card-shadow-hover);
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background-color: var(--badge-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.card-icon svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: -0.015em;
}

.card-text {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.card-example {
  margin-top: 16px;
  padding: 8px 12px;
  background-color: var(--surface-muted);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Widgets Matrix Table */
.table-responsive {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--surface-card);
  box-shadow: var(--card-shadow);
}

.table-custom {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table-custom th {
  background-color: var(--surface-muted);
  padding: 16px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}

.table-custom td {
  padding: 16px 20px;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table-custom tr:last-child td {
  border-bottom: none;
}

.table-custom .widget-name {
  font-weight: 600;
  color: var(--text-primary);
}

.pill-size {
  display: inline-block;
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background-color: var(--surface-muted);
  color: var(--text-primary);
}

.status-check {
  color: var(--success);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* --------------------------------------------------------------------------
   9. Information & Policy Content Layout
   -------------------------------------------------------------------------- */
.policy-header {
  padding: 60px 0 40px;
  border-bottom: 1px solid var(--divider);
  background-color: var(--surface);
}

.policy-header-inner {
  max-width: 800px;
  margin: 0 auto;
}

.policy-header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
}

.policy-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.policy-body {
  padding: 56px 0 80px;
}

.policy-content {
  max-width: 800px;
  margin: 0 auto;
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--text-secondary);
}

.policy-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 44px 0 16px;
  letter-spacing: -0.02em;
  border-bottom: 1px solid var(--divider);
  padding-bottom: 10px;
}

.policy-content h2:first-child {
  margin-top: 0;
}

.policy-content h3 {
  font-size: 1.1875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 28px 0 12px;
}

.policy-content p {
  margin-bottom: 18px;
}

.policy-content ul, .policy-content ol {
  margin: 16px 0 24px 24px;
}

.policy-content li {
  margin-bottom: 8px;
}

.policy-callout {
  padding: 20px 24px;
  background-color: var(--surface-muted);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin: 28px 0;
  font-size: 0.9375rem;
  color: var(--text-primary);
}

.policy-callout strong {
  color: var(--primary);
}

/* --------------------------------------------------------------------------
   10. Contact Page
   -------------------------------------------------------------------------- */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 28px;
  margin-top: 36px;
}

.contact-card {
  background-color: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
}

.contact-card h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.contact-card p {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
  flex: 1;
}

/* --------------------------------------------------------------------------
   11. 404 Page
   -------------------------------------------------------------------------- */
.error-page {
  padding: 100px 0;
  text-align: center;
}

.error-card {
  max-width: 520px;
  margin: 0 auto;
  padding: 48px 36px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--card-shadow);
}

.error-code {
  font-size: 4rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 16px;
}

.error-card h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.error-card p {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

/* --------------------------------------------------------------------------
   12. Shared Footer
   -------------------------------------------------------------------------- */
.site-footer {
  background-color: var(--surface);
  border-top: 1px solid var(--divider);
  padding: 64px 0 36px;
  margin-top: auto;
  transition: background-color var(--transition-base), border-color var(--transition-base);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 48px;
}

.footer-brand p {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: 16px;
  max-width: 320px;
}

.footer-col h4 {
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  margin-bottom: 18px;
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

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

.footer-bottom {
  padding-top: 32px;
  border-top: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.875rem;
  color: var(--text-tertiary);
  flex-wrap: wrap;
  gap: 16px;
}

/* --------------------------------------------------------------------------
   13. Responsive Media Queries
   -------------------------------------------------------------------------- */
@media (max-width: 992px) {
  .hero-title {
    font-size: 2.75rem;
  }
  .workflow-grid {
    grid-template-columns: 1fr;
    max-width: 440px;
    margin: 0 auto;
  }
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: 64px;
  }
  .header-nav,
  .btn-github {
    display: none;
  }
  .mobile-menu-btn {
    display: inline-flex;
  }
  .hero-section {
    padding: 48px 0 44px;
  }
  .hero-title {
    font-size: 2.25rem;
  }
  .hero-desc {
    font-size: 1.0625rem;
  }
  .grid-3, .grid-2, .contact-grid {
    grid-template-columns: 1fr;
  }
  .section {
    padding: 56px 0;
  }
  .section-header h2 {
    font-size: 1.875rem;
  }
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .policy-header h1 {
    font-size: 2rem;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 16px;
  }
  .hero-title {
    font-size: 1.875rem;
  }
  .hero-actions {
    flex-direction: column;
    width: 100%;
  }
  .hero-actions .btn {
    width: 100%;
  }
  .card {
    padding: 24px 20px;
  }
}

/* --------------------------------------------------------------------------
   14. Scroll Reveal Animation
   -------------------------------------------------------------------------- */
.reveal-init {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.65s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.65s cubic-bezier(0.16, 1, 0.3, 1);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}

.reveal-init.is-revealed {
  opacity: 1;
  transform: translateY(0);
}

/* --------------------------------------------------------------------------
   15. Reduced Motion Preference
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .reveal-init {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

