/*
  CREATE SOMETHING Vertical Template Base

  Shared base styles for all vertical templates (professional-services, law-firm, etc.)

  Philosophy: "Weniger, aber besser" - Dieter Rams
  DRY: Extract common patterns from vertical app.css files into shared base.

  This file provides:
  - Base HTML/body styles with Canon tokens
  - Typography hierarchy (h1-h6, p, code)
  - Custom scrollbar styling
  - Component layer patterns (containers, sections, cards, buttons, grids)
  - Utility patterns (gradients, transitions, line-clamps)
  - Accessibility patterns (skip-link, focus states, sr-only, touch targets)
  - View transitions and Canon motion animations
  - Reduced motion support

  Import after tokens.css and Tailwind in vertical templates:

  @import '@create-something/components/styles/tokens.css';
  @tailwind base;
  @tailwind components;
  @tailwind utilities;
  @import '@create-something/components/styles/vertical-base.css';
*/

/* ==========================================================================
   Base Styles
   ========================================================================== */

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--color-bg-pure);
  color: var(--color-fg-primary);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  letter-spacing: var(--tracking-tight);
}

/* ==========================================================================
   Typography - Canon Hierarchy
   ========================================================================== */

h1 {
  font-size: var(--text-display-xl);
  font-weight: var(--font-semibold);
  line-height: 1.05;
  letter-spacing: var(--tracking-tighter);
}

h2 {
  font-size: var(--text-h1);
  font-weight: var(--font-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tighter);
}

h3 {
  font-size: var(--text-h2);
  font-weight: var(--font-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
}

h4 {
  font-size: var(--text-h3);
  font-weight: var(--font-semibold);
  line-height: var(--leading-snug);
}

h5 {
  font-size: var(--text-h4);
  font-weight: var(--font-semibold);
}

h6 {
  font-size: var(--text-h5);
  font-weight: var(--font-semibold);
}

p {
  line-height: var(--leading-relaxed);
}

code, pre, .font-mono {
  font-family: var(--font-mono);
}

/* ==========================================================================
   Custom Scrollbar - Canon Minimal
   ========================================================================== */

::-webkit-scrollbar {
  width: 10px;
  background-color: var(--color-bg-pure);
}

::-webkit-scrollbar-track {
  background-color: var(--color-bg-pure);
}

::-webkit-scrollbar-thumb {
  background-color: var(--color-border-strong);
  border-radius: 5px;
  border: 2px solid var(--color-bg-pure);
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-fg-muted);
}

/* ==========================================================================
   Component Patterns - DRY Extraction
   Shared patterns extracted from vertical templates.
   Note: Not using @layer to avoid PostCSS @import ordering issues.
   ========================================================================== */

/* ==========================================================================
   Layout Components
   ========================================================================== */

/* Standard container - max-width with horizontal padding */
.container {
  max-width: var(--container-xl);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

/* Section header - centered title + subtitle pattern */
.section-header {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.section-header--spaced {
  margin-bottom: var(--space-2xl);
  max-width: var(--width-prose);
  margin-left: auto;
  margin-right: auto;
}

.section-title {
  font-size: var(--text-h1);
  font-weight: var(--font-bold);
  color: var(--color-fg-primary);
  margin-bottom: var(--space-sm);
}

.section-subtitle {
  font-size: var(--text-body-lg);
  color: var(--color-fg-secondary);
  line-height: var(--leading-relaxed);
}

/* Section padding - golden ratio vertical rhythm */
.section {
  padding: var(--space-3xl) 0;
}

.section--elevated {
  background: var(--color-bg-elevated);
}

.section--pure {
  background: var(--color-bg-pure);
}

/* ==========================================================================
   Animation Components
   ========================================================================== */

.fade-in {
  animation: fadeIn var(--duration-complex) ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card-lift {
  transition: all var(--duration-standard) var(--ease-standard);
}

.card-lift:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-2xl);
}

.page-transition {
  animation: pageEnter 0.4s ease-out;
}

@keyframes pageEnter {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ==========================================================================
   Card Components
   ========================================================================== */

.service-card {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--duration-standard) var(--ease-standard);
}

.service-card:hover {
  border-color: var(--color-border-emphasis);
  transform: translateY(-4px);
}

/* ==========================================================================
   Button Components
   ========================================================================== */

.cta-primary {
  background: var(--color-fg-primary);
  color: var(--color-bg-pure);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-full);
  font-weight: var(--font-semibold);
  transition: all var(--duration-micro) var(--ease-standard);
}

.cta-primary:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow-glow-md);
}

.cta-secondary {
  background: transparent;
  color: var(--color-fg-primary);
  border: 1px solid var(--color-border-emphasis);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-full);
  font-weight: var(--font-medium);
  transition: all var(--duration-micro) var(--ease-standard);
}

.cta-secondary:hover {
  background: var(--color-hover);
  border-color: var(--color-border-strong);
}

/* ==========================================================================
   Grid Components - Responsive layouts
   ========================================================================== */

.grid-responsive {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
}

@media (min-width: 768px) {
  .grid-responsive--2 {
    grid-template-columns: repeat(2, 1fr);
  }

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

@media (min-width: 1024px) {
  .grid-responsive--4 {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
  }
}

/* ==========================================================================
   Utility Patterns
   ========================================================================== */

.text-shadow-soft {
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.bg-gradient-dark {
  background: linear-gradient(180deg, var(--color-bg-pure) 0%, var(--color-bg-elevated) 100%);
}

.bg-gradient-subtle {
  background: linear-gradient(135deg, var(--color-bg-elevated) 0%, var(--color-bg-surface) 100%);
}

.border-gradient {
  border: 1px solid transparent;
  background-image: linear-gradient(var(--color-bg-surface), var(--color-bg-surface)),
                    linear-gradient(135deg, var(--color-border-emphasis), var(--color-border-default));
  background-origin: border-box;
  background-clip: padding-box, border-box;
}

.transition-smooth {
  transition: all var(--duration-standard) var(--ease-standard);
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ==========================================================================
   Accessibility & Focus States
   ========================================================================== */

/* Skip link for keyboard navigation */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-fg-primary);
  color: var(--color-bg-pure);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-weight: var(--font-semibold);
  z-index: var(--z-tooltip);
  transition: top var(--duration-micro) var(--ease-standard);
}

.skip-link:focus {
  top: var(--space-sm);
}

/* Selection state */
::selection {
  background-color: var(--color-focus);
  color: var(--color-fg-primary);
}

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

/* Ensure buttons and links have adequate touch targets (44x44px) */
button, a {
  min-height: 44px;
  min-width: 44px;
}

/* Exception for inline links */
p a, li a, span a {
  min-height: auto;
  min-width: auto;
}

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

* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   View Transitions - Canon Navigation
   Philosophy: Navigation transitions reveal spatial relationships between pages.
   ========================================================================== */

::view-transition-old(root) {
  animation: view-transition-exit var(--view-transition-duration) var(--ease-accelerate);
}

::view-transition-new(root) {
  animation: view-transition-enter var(--view-transition-duration) var(--ease-decelerate);
}

@keyframes view-transition-exit {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.98);
  }
}

@keyframes view-transition-enter {
  from {
    opacity: 0;
    transform: scale(1.02);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ==========================================================================
   Canon Motion - Disclosure Animations
   These animations reveal state changes, not decorate.
   ========================================================================== */

/* Page entrance - reveals content hierarchy */
@keyframes page-enter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-enter {
  animation: page-enter var(--duration-standard) var(--ease-decelerate);
}

/* Staggered reveal - discloses content order/hierarchy */
@keyframes stagger-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stagger-children > * {
  animation: stagger-in var(--duration-standard) var(--ease-decelerate) backwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 100ms; }
.stagger-children > *:nth-child(4) { animation-delay: 150ms; }
.stagger-children > *:nth-child(5) { animation-delay: 200ms; }
.stagger-children > *:nth-child(6) { animation-delay: 250ms; }

/* Card hover - reveals interactivity (functional, not decorative) */
.card-interactive {
  transition:
    transform var(--duration-fast) var(--ease-standard),
    box-shadow var(--duration-fast) var(--ease-standard),
    border-color var(--duration-micro) var(--ease-standard);
}

.card-interactive:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-border-emphasis);
}

.card-interactive:active {
  transform: translateY(-2px);
  transition-duration: var(--duration-instant);
}

/* Button state transitions - confirms user action */
.btn-canon {
  transition:
    transform var(--duration-micro) var(--ease-standard),
    background-color var(--duration-micro) var(--ease-standard),
    box-shadow var(--duration-fast) var(--ease-standard);
}

.btn-canon:hover {
  transform: translateY(-1px);
}

.btn-canon:active {
  transform: translateY(0) scale(0.98);
  transition-duration: var(--duration-instant);
}

/* Focus ring animation - reveals keyboard focus (accessibility) */
@keyframes focus-ring-pulse {
  0%, 100% {
    box-shadow: 0 0 0 2px var(--color-fg-muted);
  }
  50% {
    box-shadow: 0 0 0 4px var(--color-fg-subtle);
  }
}

.focus-ring-animated:focus-visible {
  animation: focus-ring-pulse 1.5s var(--ease-standard) infinite;
}

/* Expand/collapse - reveals hidden content */
@keyframes expand-down {
  from {
    opacity: 0;
    max-height: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    max-height: 500px;
    transform: translateY(0);
  }
}

@keyframes collapse-up {
  from {
    opacity: 1;
    max-height: 500px;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    max-height: 0;
    transform: translateY(-8px);
  }
}

/* Scroll-triggered reveal - use sparingly, only for content hierarchy */
@keyframes scroll-reveal {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.scroll-reveal {
  animation: scroll-reveal var(--duration-complex) var(--ease-decelerate) backwards;
}

/* ==========================================================================
   Reduced Motion - Accessibility First
   Canon respects user preferences absolutely.
   ========================================================================== */

@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;
  }

  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }

  .card-interactive:hover {
    transform: none;
  }

  .btn-canon:hover,
  .btn-canon:active {
    transform: none;
  }
}
