/**
 * Te Puo Website - Global Styles and Design System
 * 
 * This file defines the core design system inspired by the Japanese dorodango technique,
 * featuring earth tones, spherical shapes, and an artisanal aesthetic.
 * 
 * Requirements: 7.1, 7.2, 7.4
 */

/* ============================================
   CSS VARIABLES - DESIGN TOKENS
   ============================================ */

:root {
  /* Earth Tone Color Palette - Inspired by Dorodango */
  --color-earth-dark: #5D4E37;      /* Deep earth brown */
  --color-earth-medium: #8B7355;    /* Medium earth brown */
  --color-earth-light: #C4A57B;     /* Light earth beige */
  --color-clay: #A0826D;            /* Clay tone */
  --color-sand: #E8DCC4;            /* Sand beige */
  
  /* Accent Colors */
  --color-accent: #8B6F47;          /* Warm accent */
  --color-accent-light: #B8956A;    /* Light accent */
  --color-accent-dark: #6B5437;     /* Dark accent */
  
  /* Text Colors */
  --color-text-dark: #3E2723;       /* Primary text color */
  --color-text-medium: #5D4E37;     /* Secondary text color */
  --color-text-light: #FFFFFF;      /* Light text for dark backgrounds */
  --color-text-muted: #8B7355;      /* Muted text */
  
  /* Background Colors */
  --color-bg-primary: #FFFFFF;      /* Primary background */
  --color-bg-secondary: #F5F1E8;    /* Secondary background */
  --color-bg-tertiary: #E8DCC4;     /* Tertiary background */
  
  /* Spherical Border Radius - Dorodango Inspired */
  --border-radius-sphere: 50%;      /* Perfect sphere */
  --border-radius-soft: 20px;       /* Soft rounded corners */
  --border-radius-medium: 12px;     /* Medium rounded corners */
  --border-radius-small: 8px;       /* Small rounded corners */
  
  /* Spacing Scale */
  --spacing-xs: 0.5rem;    /* 8px */
  --spacing-sm: 1rem;      /* 16px */
  --spacing-md: 2rem;      /* 32px */
  --spacing-lg: 4rem;      /* 64px */
  --spacing-xl: 6rem;      /* 96px */
  --spacing-xxl: 8rem;     /* 128px */
  
  /* Typography Scale */
  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.875rem;   /* 14px */
  --font-size-base: 1rem;     /* 16px */
  --font-size-lg: 1.125rem;   /* 18px */
  --font-size-xl: 1.5rem;     /* 24px */
  --font-size-2xl: 2rem;      /* 32px */
  --font-size-3xl: 2.5rem;    /* 40px */
  --font-size-4xl: 3rem;      /* 48px */
  
  /* Font Weights */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  
  /* Line Heights */
  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;
  
  /* Shadows - Subtle and Natural */
  --shadow-sm: 0 1px 2px rgba(62, 39, 35, 0.05);
  --shadow-md: 0 4px 6px rgba(62, 39, 35, 0.1);
  --shadow-lg: 0 10px 15px rgba(62, 39, 35, 0.15);
  --shadow-xl: 0 20px 25px rgba(62, 39, 35, 0.2);
  
  /* Transitions */
  --transition-fast: 150ms ease-in-out;
  --transition-base: 250ms ease-in-out;
  --transition-slow: 350ms ease-in-out;
  
  /* Z-Index Scale */
  --z-index-dropdown: 1000;
  --z-index-sticky: 1020;
  --z-index-fixed: 1030;
  --z-index-modal-backdrop: 1040;
  --z-index-modal: 1050;
  --z-index-popover: 1060;
  --z-index-tooltip: 1070;
  
  /* Responsive Breakpoints (for use in media queries) */
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-2xl: 1536px;
}

/* ============================================
   RESET AND BASE STYLES
   ============================================ */

/* Box sizing reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* HTML and Body */
html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  color: var(--color-text-dark);
  background-color: var(--color-bg-primary);
  min-height: 100vh;
}

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

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: var(--color-text-dark);
  margin-bottom: var(--spacing-sm);
}

h1 {
  font-size: var(--font-size-4xl);
  margin-bottom: var(--spacing-md);
}

h2 {
  font-size: var(--font-size-3xl);
  margin-bottom: var(--spacing-md);
}

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

h4 {
  font-size: var(--font-size-xl);
}

h5 {
  font-size: var(--font-size-lg);
}

h6 {
  font-size: var(--font-size-base);
}

p {
  margin-bottom: var(--spacing-sm);
  line-height: var(--line-height-relaxed);
}

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

a:hover {
  color: var(--color-accent-dark);
  text-decoration: underline;
}

a:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

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

.container {
  width: 100%;
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--spacing-md);
  padding-right: var(--spacing-md);
}

.section {
  padding-top: var(--spacing-lg);
  padding-bottom: var(--spacing-lg);
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Small devices (landscape phones, 640px and up) */
@media (min-width: 640px) {
  h1 {
    font-size: 3.5rem;
  }
  
  h2 {
    font-size: 2.75rem;
  }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
  .container {
    padding-left: var(--spacing-lg);
    padding-right: var(--spacing-lg);
  }
  
  .section {
    padding-top: var(--spacing-xl);
    padding-bottom: var(--spacing-xl);
  }
}

/* Large devices (desktops, 1024px and up) */
@media (min-width: 1024px) {
  h1 {
    font-size: 4rem;
  }
  
  h2 {
    font-size: 3rem;
  }
}

/* Extra large devices (large desktops, 1280px and up) */
@media (min-width: 1280px) {
  .container {
    max-width: 1280px;
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

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

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

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

/* Display */
.hidden {
  display: none;
}

.block {
  display: block;
}

.inline-block {
  display: inline-block;
}

.flex {
  display: flex;
}

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

.grid {
  display: grid;
}

/* Flexbox Utilities */
.flex-row {
  flex-direction: row;
}

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

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

.items-start {
  align-items: flex-start;
}

.items-end {
  align-items: flex-end;
}

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

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

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

.gap-xs {
  gap: var(--spacing-xs);
}

.gap-sm {
  gap: var(--spacing-sm);
}

.gap-md {
  gap: var(--spacing-md);
}

.gap-lg {
  gap: var(--spacing-lg);
}

/* Spacing Utilities */
.mt-xs { margin-top: var(--spacing-xs); }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }

.mb-xs { margin-bottom: var(--spacing-xs); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }

.pt-xs { padding-top: var(--spacing-xs); }
.pt-sm { padding-top: var(--spacing-sm); }
.pt-md { padding-top: var(--spacing-md); }
.pt-lg { padding-top: var(--spacing-lg); }
.pt-xl { padding-top: var(--spacing-xl); }

.pb-xs { padding-bottom: var(--spacing-xs); }
.pb-sm { padding-bottom: var(--spacing-sm); }
.pb-md { padding-bottom: var(--spacing-md); }
.pb-lg { padding-bottom: var(--spacing-lg); }
.pb-xl { padding-bottom: var(--spacing-xl); }

/* Border Radius Utilities */
.rounded-sphere {
  border-radius: var(--border-radius-sphere);
}

.rounded-soft {
  border-radius: var(--border-radius-soft);
}

.rounded-medium {
  border-radius: var(--border-radius-medium);
}

.rounded-small {
  border-radius: var(--border-radius-small);
}

/* Shadow Utilities */
.shadow-sm {
  box-shadow: var(--shadow-sm);
}

.shadow-md {
  box-shadow: var(--shadow-md);
}

.shadow-lg {
  box-shadow: var(--shadow-lg);
}

.shadow-xl {
  box-shadow: var(--shadow-xl);
}

/* ============================================
   COMPONENT BASE STYLES
   ============================================ */

/* Buttons */
.btn {
  display: inline-block;
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  text-align: center;
  text-decoration: none;
  border: none;
  border-radius: var(--border-radius-soft);
  cursor: pointer;
  transition: all var(--transition-base);
}

.btn-primary {
  background-color: var(--color-accent);
  color: var(--color-text-light);
}

.btn-primary:hover {
  background-color: var(--color-accent-dark);
  text-decoration: none;
}

.btn-secondary {
  background-color: var(--color-earth-light);
  color: var(--color-text-dark);
}

.btn-secondary:hover {
  background-color: var(--color-earth-medium);
  text-decoration: none;
}

/* Cards */
.card {
  background-color: var(--color-bg-primary);
  border-radius: var(--border-radius-soft);
  box-shadow: var(--shadow-md);
  padding: var(--spacing-md);
  transition: box-shadow var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

/* Images */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

.img-sphere {
  border-radius: var(--border-radius-sphere);
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

/* Loading States */
.loading {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid var(--color-sand);
  border-top-color: var(--color-accent);
  border-radius: var(--border-radius-sphere);
  animation: spin 1s linear infinite;
}

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

/* Error Messages */
.error-message {
  background-color: #FEE;
  color: #C33;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--border-radius-small);
  border-left: 4px solid #C33;
  margin-bottom: var(--spacing-md);
}

/* Success Messages */
.success-message {
  background-color: #EFE;
  color: #3C3;
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--border-radius-small);
  border-left: 4px solid #3C3;
  margin-bottom: var(--spacing-md);
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Skip to main content link */
.skip-to-main {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-accent);
  color: var(--color-text-light);
  padding: var(--spacing-sm);
  text-decoration: none;
  z-index: var(--z-index-tooltip);
}

.skip-to-main:focus {
  top: 0;
}

/* Focus visible for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Reduced motion for accessibility */
@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;
  }
}

/* Screen reader only content */
.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;
}
