/**
 * Swiss International Design System
 * Based on the International Typographic Style
 *
 * Principles:
 * - Strict grid system (8px base unit)
 * - Limited color palette (black, white, accent)
 * - Sans-serif typography (Helvetica/system fonts)
 * - Asymmetric layouts with mathematical precision
 * - Generous whitespace
 * - Clear hierarchy
 *
 * Credits: Luke Steuber
 */

/* ============================================
   1. CSS VARIABLES - SWISS DESIGN TOKENS
   ============================================ */

:root {
  /* Grid System - 8px base unit */
  --swiss-unit: 8px;
  --swiss-unit-2: calc(var(--swiss-unit) * 2);    /* 16px */
  --swiss-unit-3: calc(var(--swiss-unit) * 3);    /* 24px */
  --swiss-unit-4: calc(var(--swiss-unit) * 4);    /* 32px */
  --swiss-unit-6: calc(var(--swiss-unit) * 6);    /* 48px */
  --swiss-unit-8: calc(var(--swiss-unit) * 8);    /* 64px */
  --swiss-unit-12: calc(var(--swiss-unit) * 12);  /* 96px */

  /* Typography Scale (Perfect Fourth - 1.333) */
  --swiss-text-xs: 0.75rem;      /* 12px */
  --swiss-text-sm: 0.875rem;     /* 14px */
  --swiss-text-base: 1rem;       /* 16px */
  --swiss-text-md: 1.125rem;     /* 18px */
  --swiss-text-lg: 1.333rem;     /* ~21px */
  --swiss-text-xl: 1.777rem;     /* ~28px */
  --swiss-text-2xl: 2.369rem;    /* ~38px */
  --swiss-text-3xl: 3.157rem;    /* ~50px */

  /* Swiss Color Palette */
  --swiss-black: #000000;
  --swiss-white: #FFFFFF;
  --swiss-gray-100: #F5F5F5;
  --swiss-gray-200: #E5E5E5;
  --swiss-gray-300: #D4D4D4;
  --swiss-gray-400: #A3A3A3;
  --swiss-gray-500: #737373;
  --swiss-gray-600: #525252;
  --swiss-gray-700: #404040;
  --swiss-gray-800: #262626;
  --swiss-gray-900: #171717;

  /* Accent Colors (Classic Swiss Red) */
  --swiss-red: #E60000;
  --swiss-red-light: #FF3333;
  --swiss-red-dark: #B30000;

  /* Typography */
  --swiss-font-sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue",
                     "Helvetica", "Arial", sans-serif;
  --swiss-font-mono: "SF Mono", "Monaco", "Inconsolata", "Fira Mono",
                     "Droid Sans Mono", "Source Code Pro", monospace;

  /* Font Weights */
  --swiss-weight-light: 300;
  --swiss-weight-normal: 400;
  --swiss-weight-medium: 500;
  --swiss-weight-bold: 700;

  /* Line Heights (1.5x recommended for readability) */
  --swiss-leading-tight: 1.25;
  --swiss-leading-normal: 1.5;
  --swiss-leading-relaxed: 1.75;

  /* Letter Spacing */
  --swiss-tracking-tight: -0.025em;
  --swiss-tracking-normal: 0;
  --swiss-tracking-wide: 0.025em;

  /* Borders */
  --swiss-border-width: 1px;
  --swiss-border-width-thick: 2px;
  --swiss-border-radius: 0;  /* Swiss design uses sharp corners */

  /* Shadows (minimal, used sparingly) */
  --swiss-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --swiss-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  --swiss-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);

  /* Transitions */
  --swiss-transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-Index Scale */
  --swiss-z-base: 0;
  --swiss-z-dropdown: 1000;
  --swiss-z-sticky: 1020;
  --swiss-z-fixed: 1030;
  --swiss-z-modal: 1040;
  --swiss-z-popover: 1050;
  --swiss-z-tooltip: 1060;
}

/* Dark Theme */
[data-theme="dark"] {
  --swiss-bg: var(--swiss-black);
  --swiss-fg: var(--swiss-white);
  --swiss-bg-secondary: var(--swiss-gray-900);
  --swiss-bg-tertiary: var(--swiss-gray-800);
  --swiss-border: var(--swiss-gray-700);
  --swiss-text-primary: var(--swiss-white);
  --swiss-text-secondary: var(--swiss-gray-300);
  --swiss-text-tertiary: var(--swiss-gray-500);
}

/* Light Theme */
[data-theme="light"],
:root {
  --swiss-bg: var(--swiss-white);
  --swiss-fg: var(--swiss-black);
  --swiss-bg-secondary: var(--swiss-gray-100);
  --swiss-bg-tertiary: var(--swiss-gray-200);
  --swiss-border: var(--swiss-gray-300);
  --swiss-text-primary: var(--swiss-black);
  --swiss-text-secondary: var(--swiss-gray-700);
  --swiss-text-tertiary: var(--swiss-gray-500);
}

/* ============================================
   2. 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(--swiss-font-sans);
  font-size: var(--swiss-text-base);
  font-weight: var(--swiss-weight-normal);
  line-height: var(--swiss-leading-normal);
  color: var(--swiss-text-primary);
  background-color: var(--swiss-bg);
  letter-spacing: var(--swiss-tracking-normal);
}

/* ============================================
   3. TYPOGRAPHY
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--swiss-weight-bold);
  line-height: var(--swiss-leading-tight);
  letter-spacing: var(--swiss-tracking-tight);
  margin-bottom: var(--swiss-unit-2);
}

h1 {
  font-size: var(--swiss-text-3xl);
  margin-bottom: var(--swiss-unit-4);
}

h2 {
  font-size: var(--swiss-text-2xl);
  margin-bottom: var(--swiss-unit-3);
}

h3 {
  font-size: var(--swiss-text-xl);
}

h4 {
  font-size: var(--swiss-text-lg);
}

h5 {
  font-size: var(--swiss-text-md);
}

h6 {
  font-size: var(--swiss-text-base);
  font-weight: var(--swiss-weight-medium);
}

p {
  margin-bottom: var(--swiss-unit-2);
  max-width: 65ch; /* Optimal reading width */
}

a {
  color: var(--swiss-red);
  text-decoration: none;
  transition: var(--swiss-transition);
}

a:hover {
  color: var(--swiss-red-light);
  text-decoration: underline;
}

a:focus {
  outline: var(--swiss-border-width-thick) solid var(--swiss-red);
  outline-offset: 2px;
}

/* ============================================
   4. GRID SYSTEM
   ============================================ */

.swiss-grid {
  display: grid;
  gap: var(--swiss-unit-3);
}

.swiss-grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.swiss-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.swiss-grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.swiss-grid-12 {
  grid-template-columns: repeat(12, 1fr);
}

/* Asymmetric Grid (Classic Swiss) */
.swiss-grid-asymmetric {
  display: grid;
  grid-template-columns: 2fr 3fr;
  gap: var(--swiss-unit-4);
}

/* ============================================
   5. LAYOUT UTILITIES
   ============================================ */

.swiss-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--swiss-unit-3);
}

.swiss-section {
  padding: var(--swiss-unit-8) 0;
}

.swiss-stack {
  display: flex;
  flex-direction: column;
  gap: var(--swiss-unit-2);
}

.swiss-inline {
  display: flex;
  align-items: center;
  gap: var(--swiss-unit-2);
}

.swiss-split {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--swiss-unit-2);
}

/* ============================================
   6. COMPONENTS
   ============================================ */

/* Buttons */
.swiss-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--swiss-unit);
  padding: var(--swiss-unit-2) var(--swiss-unit-4);
  font-family: var(--swiss-font-sans);
  font-size: var(--swiss-text-base);
  font-weight: var(--swiss-weight-medium);
  line-height: 1;
  color: var(--swiss-white);
  background-color: var(--swiss-black);
  border: var(--swiss-border-width) solid var(--swiss-black);
  border-radius: var(--swiss-border-radius);
  cursor: pointer;
  transition: var(--swiss-transition);
  text-transform: uppercase;
  letter-spacing: var(--swiss-tracking-wide);
}

.swiss-btn:hover {
  background-color: var(--swiss-gray-800);
  border-color: var(--swiss-gray-800);
}

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

.swiss-btn-outline {
  background-color: transparent;
  color: var(--swiss-black);
}

.swiss-btn-outline:hover {
  background-color: var(--swiss-black);
  color: var(--swiss-white);
}

.swiss-btn-accent {
  background-color: var(--swiss-red);
  border-color: var(--swiss-red);
}

.swiss-btn-accent:hover {
  background-color: var(--swiss-red-dark);
  border-color: var(--swiss-red-dark);
}

/* Cards */
.swiss-card {
  background-color: var(--swiss-bg-secondary);
  border: var(--swiss-border-width) solid var(--swiss-border);
  padding: var(--swiss-unit-4);
}

.swiss-card-header {
  margin-bottom: var(--swiss-unit-3);
  padding-bottom: var(--swiss-unit-2);
  border-bottom: var(--swiss-border-width) solid var(--swiss-border);
}

/* Input Fields */
.swiss-input {
  width: 100%;
  padding: var(--swiss-unit-2);
  font-family: var(--swiss-font-sans);
  font-size: var(--swiss-text-base);
  color: var(--swiss-text-primary);
  background-color: var(--swiss-bg);
  border: var(--swiss-border-width) solid var(--swiss-border);
  border-radius: var(--swiss-border-radius);
  transition: var(--swiss-transition);
}

.swiss-input:focus {
  outline: none;
  border-color: var(--swiss-black);
  box-shadow: 0 0 0 var(--swiss-border-width-thick) var(--swiss-black);
}

/* Dividers */
.swiss-divider {
  height: var(--swiss-border-width);
  background-color: var(--swiss-border);
  border: none;
  margin: var(--swiss-unit-4) 0;
}

.swiss-divider-thick {
  height: var(--swiss-border-width-thick);
  background-color: var(--swiss-black);
}

/* ============================================
   7. UTILITY CLASSES
   ============================================ */

/* Spacing */
.swiss-mb-1 { margin-bottom: var(--swiss-unit); }
.swiss-mb-2 { margin-bottom: var(--swiss-unit-2); }
.swiss-mb-3 { margin-bottom: var(--swiss-unit-3); }
.swiss-mb-4 { margin-bottom: var(--swiss-unit-4); }
.swiss-mb-6 { margin-bottom: var(--swiss-unit-6); }
.swiss-mb-8 { margin-bottom: var(--swiss-unit-8); }

.swiss-mt-1 { margin-top: var(--swiss-unit); }
.swiss-mt-2 { margin-top: var(--swiss-unit-2); }
.swiss-mt-3 { margin-top: var(--swiss-unit-3); }
.swiss-mt-4 { margin-top: var(--swiss-unit-4); }

.swiss-p-2 { padding: var(--swiss-unit-2); }
.swiss-p-3 { padding: var(--swiss-unit-3); }
.swiss-p-4 { padding: var(--swiss-unit-4); }

/* Text Alignment */
.swiss-text-left { text-align: left; }
.swiss-text-center { text-align: center; }
.swiss-text-right { text-align: right; }

/* Text Colors */
.swiss-text-primary { color: var(--swiss-text-primary); }
.swiss-text-secondary { color: var(--swiss-text-secondary); }
.swiss-text-accent { color: var(--swiss-red); }

/* Backgrounds */
.swiss-bg-primary { background-color: var(--swiss-bg); }
.swiss-bg-secondary { background-color: var(--swiss-bg-secondary); }
.swiss-bg-black { background-color: var(--swiss-black); color: var(--swiss-white); }
.swiss-bg-white { background-color: var(--swiss-white); color: var(--swiss-black); }
.swiss-bg-accent { background-color: var(--swiss-red); color: var(--swiss-white); }

/* Borders */
.swiss-border { border: var(--swiss-border-width) solid var(--swiss-border); }
.swiss-border-t { border-top: var(--swiss-border-width) solid var(--swiss-border); }
.swiss-border-b { border-bottom: var(--swiss-border-width) solid var(--swiss-border); }
.swiss-border-l { border-left: var(--swiss-border-width) solid var(--swiss-border); }
.swiss-border-r { border-right: var(--swiss-border-width) solid var(--swiss-border); }

.swiss-border-thick { border-width: var(--swiss-border-width-thick); }
.swiss-border-black { border-color: var(--swiss-black); }

/* Responsive Design */
@media (max-width: 768px) {
  :root {
    font-size: 14px;
  }

  .swiss-grid-2,
  .swiss-grid-3,
  .swiss-grid-4,
  .swiss-grid-asymmetric {
    grid-template-columns: 1fr;
  }

  .swiss-split {
    flex-direction: column;
    align-items: flex-start;
  }
}

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

/* ============================================
   8. ANIMATIONS
   ============================================ */

@keyframes swiss-fade-in {
  from {
    opacity: 0;
    transform: translateY(var(--swiss-unit));
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.swiss-fade-in {
  animation: swiss-fade-in 200ms ease-out;
}

/* ============================================
   9. PRINT STYLES
   ============================================ */

@media print {
  body {
    color: var(--swiss-black);
    background: var(--swiss-white);
  }

  .swiss-btn,
  .swiss-input {
    border: 1pt solid var(--swiss-black);
  }
}
