/**
 * Silavdoha Premium Web App - Shared Styles
 * Following the Silavdoha Design System (docs/03-design/design-system.md)
 *
 * Design Principles:
 * - Golden Ratio (φ ≈ 1.618) for spacing, typography, shadows
 * - Silavdoha brand colors (Dark Green, Coral, Sage)
 * - PT Serif (headings) and PT Sans (body) fonts
 * - Progressive responsive scaling
 */

/* ===========================================
   DESIGN SYSTEM TOKENS
   =========================================== */

:root {
  /* Colors - Silavdoha Brand */
  --color-primary: #1a3a2e;        /* Dark Green */
  --color-accent: #d4654a;         /* Coral/Orange */
  --color-secondary: #7e968a;      /* Sage Green */
  --color-light: #f5f5f5;          /* Off-White */
  --color-white: #ffffff;
  --color-black: #000000;

  /* Semantic Colors */
  --color-background: var(--color-primary);
  --color-surface: #2d5a4a;        /* Lighter green for cards */
  --color-text: var(--color-light);
  --color-text-secondary: #c0c0c0;
  --color-border: rgba(126, 150, 138, 0.3);

  /* Typography - Golden Ratio Scale */
  --font-display-1: 4.235rem;      /* φ^4 */
  --font-display-2: 2.618rem;      /* φ^3 */
  --font-title-1: 2.058rem;        /* φ^2.5 */
  --font-title-2: 1.618rem;        /* φ^2 */
  --font-title-3: 1.272rem;        /* φ^1.5 */
  --font-body-lg: 1.272rem;        /* φ^1.5 */
  --font-body: 1rem;               /* Base */
  --font-body-sm: 0.786rem;        /* φ^-0.5 */
  --font-caption: 0.618rem;        /* φ^-1 */

  /* Font Families */
  --font-serif: 'PT Serif', Georgia, serif;
  --font-sans: 'PT Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Spacing - Golden Ratio Scale */
  --space-5xs: 0.146rem;           /* φ^-3 */
  --space-4xs: 0.236rem;           /* φ^-2.5 */
  --space-3xs: 0.382rem;           /* φ^-2 */
  --space-2xs: 0.472rem;           /* φ^-1.5 */
  --space-xs: 0.618rem;            /* φ^-1 */
  --space-sm: 0.786rem;            /* φ^-0.5 */
  --space-base: 1rem;              /* Base */
  --space-md: 1.272rem;            /* φ^0.5 */
  --space-lg: 1.618rem;            /* φ */
  --space-xl: 2.058rem;            /* φ^1.5 */
  --space-2xl: 2.618rem;           /* φ^2 */
  --space-3xl: 4.236rem;           /* φ^3 */
  --space-4xl: 6.854rem;           /* φ^4 */

  /* Shadows - Golden Ratio Progression */
  --shadow-sm: 0 0.146rem 0.382rem rgba(0, 0, 0, 0.1);
  --shadow-base: 0 0.236rem 0.618rem rgba(0, 0, 0, 0.15);
  --shadow-md: 0 0.382rem 1rem rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 0.618rem 1.618rem rgba(0, 0, 0, 0.25);
  --shadow-xl: 0 1rem 2.618rem rgba(0, 0, 0, 0.3);

  /* Border Radius - Golden Ratio */
  --radius-sm: 0.382rem;           /* φ^-2 */
  --radius-base: 0.618rem;         /* φ^-1 */
  --radius-md: 1rem;               /* Base */
  --radius-lg: 1.618rem;           /* φ */
  --radius-xl: 2.618rem;           /* φ^2 */
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-Index Scale */
  --z-base: 1;
  --z-dropdown: 10;
  --z-sticky: 100;
  --z-fixed: 1000;
  --z-modal-backdrop: 10000;
  --z-modal: 10001;
  --z-tooltip: 100000;
}

/* Progressive Responsive Font Scaling */
@media (min-width: 23.5rem) {  /* xs: 376px */
  :root { font-size: 14px; }
}

@media (min-width: 38.2rem) {  /* sm: 611px */
  :root { font-size: 15px; }
}

@media (min-width: 61.8rem) {  /* md: 989px */
  :root { font-size: 16px; }
}

@media (min-width: 100rem) {   /* lg: 1600px */
  :root { font-size: 18px; }
}

/* ===========================================
   RESET & BASE STYLES
   =========================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: var(--font-body);
  line-height: 1.618; /* Golden ratio */
  color: var(--color-text);
  background: var(--color-background);
  min-height: 100vh;
}

/* ===========================================
   TYPOGRAPHY
   =========================================== */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-weight: 700;
  line-height: 1.272; /* φ^0.5 for headings */
  margin-bottom: var(--space-md);
  color: var(--color-light);
}

h1 { font-size: var(--font-display-1); }
h2 { font-size: var(--font-display-2); }
h3 { font-size: var(--font-title-1); }
h4 { font-size: var(--font-title-2); }
h5 { font-size: var(--font-title-3); }
h6 { font-size: var(--font-body-lg); }

p {
  margin-bottom: var(--space-base);
  line-height: 1.618;
}

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

a:hover {
  color: #e07a5f; /* Lighter coral on hover */
}

strong, b {
  font-weight: 700;
}

em, i {
  font-style: italic;
}

/* ===========================================
   LAYOUT UTILITIES
   =========================================== */

.container {
  width: 100%;
  max-width: 100rem; /* 1600px at base font size */
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.container-narrow {
  max-width: 61.8rem; /* 989px - md breakpoint */
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

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

.justify-between {
  justify-content: space-between;
}

.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-base { gap: var(--space-base); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }
.gap-2xl { gap: var(--space-2xl); }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

/* ===========================================
   COMPONENTS
   =========================================== */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  font-family: var(--font-sans);
  font-size: var(--font-body);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  border: none;
  border-radius: var(--radius-base);
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-white);
  box-shadow: var(--shadow-base);
}

.btn-primary:hover {
  background: #e07a5f;
  box-shadow: var(--shadow-md);
  transform: translateY(-0.146rem); /* φ^-3 */
}

.btn-secondary {
  background: var(--color-secondary);
  color: var(--color-white);
  box-shadow: var(--shadow-base);
}

.btn-secondary:hover {
  background: #8fa99d;
  box-shadow: var(--shadow-md);
  transform: translateY(-0.146rem);
}

.btn-ghost {
  background: transparent;
  color: var(--color-light);
  border: 2px solid var(--color-border);
}

.btn-ghost:hover {
  background: rgba(126, 150, 138, 0.1);
  border-color: var(--color-secondary);
}

.btn-lg {
  padding: var(--space-lg) var(--space-2xl);
  font-size: var(--font-body-lg);
}

.btn-sm {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-body-sm);
}

/* Cards */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
  box-shadow: var(--shadow-base);
  transition: all var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-0.236rem); /* φ^-2.5 */
}

.card-glass {
  background: rgba(45, 90, 74, 0.6);
  backdrop-filter: blur(10px);
  border: 1px solid var(--color-border);
}

/* Grid */
.grid {
  display: grid;
  gap: var(--space-lg);
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

@media (max-width: 38.2rem) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  font-size: var(--font-body-sm);
  font-weight: 600;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  color: var(--color-white);
}

.badge-secondary {
  background: var(--color-secondary);
}

.badge-outline {
  background: transparent;
  border: 2px solid var(--color-accent);
  color: var(--color-accent);
}

/* Loading Spinner */
.spinner {
  width: 2.618rem; /* φ^2 */
  height: 2.618rem;
  border: 0.236rem solid var(--color-border); /* φ^-2.5 */
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Avatar */
.avatar {
  width: 2.618rem; /* φ^2 */
  height: 2.618rem;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-border);
}

.avatar-lg {
  width: 4.236rem; /* φ^3 */
  height: 4.236rem;
}

.avatar-sm {
  width: 1.618rem; /* φ */
  height: 1.618rem;
}

/* ===========================================
   PAGE LAYOUTS
   =========================================== */

/* Centered Auth Layout */
.auth-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  background: linear-gradient(135deg, var(--color-primary) 0%, #0f241d 100%);
}

.auth-card {
  width: 100%;
  max-width: 32rem;
  padding: var(--space-3xl);
  text-align: center;
}

/* App Layout with Header */
.app-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-lg) 0;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.app-main {
  flex: 1;
  padding: var(--space-2xl) 0;
}

.app-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--space-lg) 0;
  text-align: center;
  color: var(--color-text-secondary);
  font-size: var(--font-body-sm);
}

/* ===========================================
   UTILITIES
   =========================================== */

.hidden { display: none; }
.visible { display: block; }

.opacity-0 { opacity: 0; }
.opacity-50 { opacity: 0.5; }
.opacity-100 { opacity: 1; }

.mb-xs { margin-bottom: var(--space-xs); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-base { margin-bottom: var(--space-base); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.mb-2xl { margin-bottom: var(--space-2xl); }
.mb-3xl { margin-bottom: var(--space-3xl); }

.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-base { margin-top: var(--space-base); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mt-2xl { margin-top: var(--space-2xl); }
.mt-3xl { margin-top: var(--space-3xl); }

/* Responsive Utilities */
@media (max-width: 38.2rem) {
  .hidden-mobile { display: none; }
}

@media (min-width: 38.2rem) {
  .hidden-desktop { display: none; }
}
