@tailwind base;
@tailwind components;
@tailwind utilities;

/* STEaM LOGIC Studio AB Brand Identity - Mobile First */

@layer base {
  :root {
    /* STEaM LOGIC Brand Colors */
    --brass: #B18A46;
    --teal: #2E646B;
    --parchment: #F5E6C5;
    --iron: #373A40;
    --cyan: #21F0FF;
    
    /* Mobile-first breakpoints */
    --breakpoint-sm: 768px;
    --breakpoint-md: 1024px;
    --breakpoint-lg: 1440px;
    
    /* Design System Mapping */
    --background: 36 26% 91%;  /* Parchment */
    --foreground: 200 8% 22%;  /* Iron */

    --card: 36 26% 91%;        /* Parchment */
    --card-foreground: 200 8% 22%;

    --popover: 36 26% 91%;
    --popover-foreground: 200 8% 22%;

    --primary: 195 40% 29%;    /* Teal */
    --primary-foreground: 36 26% 91%;

    --secondary: 42 43% 49%;   /* Brass */
    --secondary-foreground: 36 26% 91%;

    --muted: 36 20% 85%;
    --muted-foreground: 200 8% 45%;

    --accent: 187 100% 56%;    /* Cyan */
    --accent-foreground: 200 8% 22%;

    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 36 26% 91%;

    --border: 42 43% 49%;      /* Brass for borders */
    --input: 36 20% 85%;
    --ring: 195 40% 29%;

    --radius: 0.5rem;

    --sidebar-background: 36 26% 91%;
    --sidebar-foreground: 200 8% 22%;
    --sidebar-primary: 195 40% 29%;
    --sidebar-primary-foreground: 36 26% 91%;
    --sidebar-accent: 36 20% 85%;
    --sidebar-accent-foreground: 200 8% 22%;
    --sidebar-border: 42 43% 49%;
    --sidebar-ring: 195 40% 29%;

    /* Fluid type scale - Mobile first responsive typography */
    --step--1: clamp(0.8rem, 0.76rem + 0.2vw, 0.9rem);
    --step-0: clamp(0.9rem, 0.85rem + 0.5vw, 1rem);
    --step-1: clamp(1.125rem, 1rem + 0.8vw, 1.25rem);
    --step-2: clamp(1.5rem, 1.2rem + 1.5vw, 2rem);
    --step-3: clamp(2rem, 1.5rem + 2.5vw, 3rem);
    --step-4: clamp(2.5rem, 1.8rem + 3.5vw, 4rem);
    
    /* Mobile touch targets */
    --touch-target: 44px;
  }

  .dark {
    --background: 222.2 84% 4.9%;
    --foreground: 210 40% 98%;

    --card: 222.2 84% 4.9%;
    --card-foreground: 210 40% 98%;

    --popover: 222.2 84% 4.9%;
    --popover-foreground: 210 40% 98%;

    --primary: 210 40% 98%;
    --primary-foreground: 222.2 47.4% 11.2%;

    --secondary: 217.2 32.6% 17.5%;
    --secondary-foreground: 210 40% 98%;

    --muted: 217.2 32.6% 17.5%;
    --muted-foreground: 215 20.2% 65.1%;

    --accent: 217.2 32.6% 17.5%;
    --accent-foreground: 210 40% 98%;

    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 210 40% 98%;

    --border: 217.2 32.6% 17.5%;
    --input: 217.2 32.6% 17.5%;
    --ring: 212.7 26.8% 83.9%;
    --sidebar-background: 240 5.9% 10%;
    --sidebar-foreground: 240 4.8% 95.9%;
    --sidebar-primary: 224.3 76.3% 48%;
    --sidebar-primary-foreground: 0 0% 100%;
    --sidebar-accent: 240 3.7% 15.9%;
    --sidebar-accent-foreground: 240 4.8% 95.9%;
    --sidebar-border: 240 3.7% 15.9%;
    --sidebar-ring: 217.2 91.2% 59.8%;
  }
}

@layer base {
  * {
    @apply border-border;
  }

  /* Base font family: Inter as default (clean sans for mobile) */
  body, html {
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'Liberation Sans', sans-serif;
  }

  /* Utility class remains for explicit Playfair usage */
  .font-playfair {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
  }

  body {
    background: var(--parchment);
    color: var(--iron);
    line-height: 1.6;
  }
  
  h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    letter-spacing: -0.01em;
  }

  /* Mobile-first responsive typography */
  h1 {
    font-size: var(--step-3);
    line-height: 1.2;
    letter-spacing: -0.02em;
  }
  
  h2 {
    font-size: var(--step-2);
    line-height: 1.3;
    letter-spacing: -0.01em;
  }
  
  h3 {
    font-size: var(--step-1);
    line-height: 1.4;
  }

  p {
    font-size: var(--step-0);
    line-height: 1.8; /* Increased for mobile readability */
  }
  
  /* Mobile line height adjustments */
  @media (min-width: 768px) {
    p {
      line-height: 1.6;
    }
  }

  .font-playfair {
    font-weight: 700;
  }
}

/* STEaM LOGIC Brand Animations */
@keyframes gearSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes gearSpinReverse {
  from { transform: rotate(360deg); }
  to { transform: rotate(0deg); }
}

@keyframes puff {
  0% { opacity: 0; transform: translateY(0) scale(0.3); }
  40% { opacity: 0.8; }
  100% { opacity: 0; transform: translateY(-40px) scale(1); }
}

@keyframes steamRise {
  0% { opacity: 0; transform: translateY(20px) scale(0.8); }
  50% { opacity: 0.6; transform: translateY(-10px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-30px) scale(1.3); }
}

@keyframes mechanicalTick {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(2deg); }
  75% { transform: rotate(-2deg); }
}

@keyframes vintageGlow {
  0%, 100% { box-shadow: 0 0 5px var(--brass), 0 0 10px var(--brass), 0 0 15px var(--brass); }
  50% { box-shadow: 0 0 10px var(--brass), 0 0 20px var(--brass), 0 0 30px var(--brass); }
}

@keyframes scrollFadeIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes cardHover {
  0% { transform: scale(1) rotateY(0deg); }
  100% { transform: scale(1.02) rotateY(2deg); }
}

@media (prefers-reduced-motion: no-preference) {
  .logo svg.gear {
    animation: gearSpin 25s linear infinite;
  }
  
  .gear-clockwise {
    animation: gearSpin 15s linear infinite;
  }
  
  .gear-counter {
    animation: gearSpinReverse 20s linear infinite;
  }
  
  .steam-effect {
    animation: steamRise 2s ease-out infinite;
  }
  
  .mechanical-tick {
    animation: mechanicalTick 4s ease-in-out infinite;
  }
  
  .scroll-fade-in {
    animation: scrollFadeIn 0.6s ease-out forwards;
  }
  
  .vintage-glow:hover {
    animation: vintageGlow 2s ease-in-out infinite;
  }
}

.hero:hover .steam {
  animation: puff 1.8s ease-out forwards;
}

/* STEaM LOGIC Card Styling */
.card {
  border: 1px solid var(--brass);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    radial-gradient(circle at 25% 25%, rgba(177, 138, 70, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(46, 100, 107, 0.1) 0%, transparent 50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card:hover::before {
  opacity: 1;
}

/* Vintage Paper Texture Background */
.vintage-paper {
  background-image: 
    /* Paper grain texture */
    radial-gradient(circle at 1px 1px, rgba(177, 138, 70, 0.15) 1px, transparent 0),
    radial-gradient(circle at 3px 2px, rgba(46, 100, 107, 0.08) 1px, transparent 0),
    /* Age stains */
    radial-gradient(ellipse at 20% 80%, rgba(177, 138, 70, 0.2) 0%, transparent 35%),
    radial-gradient(ellipse at 80% 20%, rgba(139, 111, 51, 0.15) 0%, transparent 40%),
    radial-gradient(ellipse at 60% 60%, rgba(55, 58, 64, 0.05) 0%, transparent 30%),
    /* Base paper color with subtle variations */
    linear-gradient(45deg, rgba(245, 230, 197, 0.95) 0%, rgba(240, 225, 190, 0.98) 25%, rgba(245, 230, 197, 0.95) 50%, rgba(250, 235, 200, 0.97) 75%, rgba(245, 230, 197, 0.95) 100%);
  background-size: 
    2px 2px, 4px 3px,
    200px 150px, 180px 120px, 250px 200px,
    100% 100%;
  background-position: 
    0 0, 1px 1px,
    0 0, 100px 50px, 150px 100px,
    0 0;
}

.vintage-paper-light {
  background-image: 
    /* Subtle grain */
    radial-gradient(circle at 1px 1px, rgba(177, 138, 70, 0.08) 1px, transparent 0),
    /* Light age spots */
    radial-gradient(ellipse at 30% 70%, rgba(177, 138, 70, 0.1) 0%, transparent 25%),
    radial-gradient(ellipse at 70% 30%, rgba(139, 111, 51, 0.08) 0%, transparent 30%),
    /* Base */
    linear-gradient(135deg, rgba(245, 230, 197, 0.6) 0%, rgba(250, 235, 200, 0.8) 100%);
  background-size: 
    3px 3px,
    120px 100px, 100px 80px,
    100% 100%;
}

.vintage-paper-dark {
  background-image: 
    /* Heavy grain */
    radial-gradient(circle at 1px 1px, rgba(55, 58, 64, 0.2) 1px, transparent 0),
    radial-gradient(circle at 2px 2px, rgba(177, 138, 70, 0.1) 1px, transparent 0),
    /* Dark stains */
    radial-gradient(ellipse at 15% 85%, rgba(139, 111, 51, 0.3) 0%, transparent 40%),
    radial-gradient(ellipse at 85% 15%, rgba(55, 58, 64, 0.2) 0%, transparent 35%),
    radial-gradient(ellipse at 50% 50%, rgba(177, 138, 70, 0.15) 0%, transparent 50%),
    /* Aged base */
    linear-gradient(45deg, rgba(235, 220, 187, 0.9) 0%, rgba(230, 215, 180, 0.95) 100%);
  background-size: 
    2px 2px, 3px 3px,
    150px 120px, 160px 140px, 200px 180px,
    100% 100%;
}

/* STEaM LOGIC Button Styling */
.btn-steam {
  background: linear-gradient(180deg, #B18A46 0%, #8B6F33 100%);
  border: 2px solid var(--teal);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.btn-steam::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
  transition: all 0.3s ease;
  transform: translate(-50%, -50%);
}
  
  /* Weathered Paper Edges */
  .weathered-edges {
    position: relative;
  }
  
  .weathered-edges::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, 
      rgba(139, 111, 51, 0.3) 0%, 
      transparent 10%, 
      transparent 90%, 
      rgba(139, 111, 51, 0.3) 100%);
    border-radius: inherit;
    z-index: -1;
  }
  
  .weathered-edges::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
      linear-gradient(90deg, rgba(177, 138, 70, 0.1) 0px, transparent 1px),
      linear-gradient(180deg, rgba(177, 138, 70, 0.1) 0px, transparent 1px);
    background-size: 8px 8px;
    border-radius: inherit;
    pointer-events: none;
  }
  
  /* Parchment Scroll Effect */
  .parchment-scroll {
    background: 
      /* Top shadow */
      linear-gradient(to bottom, rgba(139, 111, 51, 0.2) 0%, transparent 10%),
      /* Bottom shadow */
      linear-gradient(to top, rgba(139, 111, 51, 0.2) 0%, transparent 10%),
      /* Paper texture */
      radial-gradient(ellipse at 25% 25%, rgba(177, 138, 70, 0.1) 0%, transparent 50%),
      radial-gradient(ellipse at 75% 75%, rgba(139, 111, 51, 0.08) 0%, transparent 40%),
      /* Base parchment */
      linear-gradient(135deg, #F5E6C5 0%, #F0E1C0 50%, #F5E6C5 100%);
    border-top: 3px solid rgba(177, 138, 70, 0.3);
    border-bottom: 3px solid rgba(177, 138, 70, 0.3);
    box-shadow: 
      inset 0 2px 4px rgba(177, 138, 70, 0.2),
      inset 0 -2px 4px rgba(177, 138, 70, 0.2);
  }
  
  /* Burnt Paper Edges */
  .burnt-edges {
    position: relative;
    border-radius: 8px;
  }
  
  .burnt-edges::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    background: radial-gradient(ellipse at center, transparent 60%, rgba(139, 111, 51, 0.4) 70%, rgba(55, 58, 64, 0.6) 85%, transparent 100%);
    border-radius: 12px;
    z-index: -1;
  }
  
  /* Ink Stains */
  .ink-stains::before {
    content: '';
    position: absolute;
    top: 10%;
    right: 15%;
    width: 20px;
    height: 20px;
    background: radial-gradient(circle, rgba(46, 100, 107, 0.3) 0%, rgba(46, 100, 107, 0.1) 40%, transparent 70%);
    border-radius: 50% 40% 60% 30%;
    transform: rotate(45deg);
  }
  
  .ink-stains::after {
    content: '';
    position: absolute;
    bottom: 20%;
    left: 10%;
    width: 15px;
    height: 25px;
    background: radial-gradient(ellipse, rgba(55, 58, 64, 0.2) 0%, rgba(55, 58, 64, 0.05) 50%, transparent 70%);
    border-radius: 60% 40% 30% 70%;
    transform: rotate(-30deg);
  }
@media (hover: hover) and (pointer: fine) {
  .btn-steam:hover {
    box-shadow: 0 0 15px var(--cyan), 0 0 30px rgba(33, 240, 255, 0.3);
    transform: translateY(-2px);
  }
  
  .btn-steam:hover::before {
    width: 100%;
    height: 100%;
  }
}

/* Mobile-first responsive utilities */
@layer utilities {
  /* Touch-friendly interactive elements */
  .touch-target {
    min-height: var(--touch-target);
    min-width: var(--touch-target);
  }
  
  /* Mobile-first grid layouts */
  .grid-responsive {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  @media (min-width: 768px) {
    .grid-responsive {
      grid-template-columns: repeat(2, 1fr);
      gap: 1.5rem;
    }
  }
  
  @media (min-width: 1024px) {
    .grid-responsive {
      grid-template-columns: repeat(3, 1fr);
      gap: 2rem;
    }
  }
  
  @media (min-width: 1440px) {
    .grid-responsive {
      grid-template-columns: repeat(4, 1fr);
    }
  }
  
  /* Performance optimization - critical CSS */
  .hero-title {
    font-size: clamp(2rem, 5vw, 4rem);
    line-height: 1.1;
  }
  
  .hero-subtitle {
    font-size: clamp(1.125rem, 3vw, 1.5rem);
    line-height: 1.4;
  }
  
  /* Victorian Typography Enhancements */
  .victorian-heading {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    text-shadow: 3px 3px 6px rgba(177, 138, 70, 0.4), 1px 1px 2px rgba(55, 58, 64, 0.3);
    letter-spacing: 0.03em;
    position: relative;
    background: linear-gradient(135deg, hsl(var(--primary)) 0%, hsl(var(--secondary)) 50%, hsl(var(--primary)) 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-size: 200% 100%;
    animation: victorianShimmer 4s ease-in-out infinite;
  }
  
  .victorian-heading::before {
    content: '❦';
    position: absolute;
    left: -2em;
    top: 50%;
    transform: translateY(-50%) rotate(15deg);
    color: hsl(var(--secondary));
    opacity: 0.8;
    font-size: 0.6em;
    text-shadow: 2px 2px 4px rgba(177, 138, 70, 0.3);
    animation: ornamentFloat 3s ease-in-out infinite;
  }
  
  .victorian-heading::after {
    content: '❦';
    position: absolute;
    right: -2em;
    top: 50%;
    transform: translateY(-50%) rotate(-15deg);
    color: hsl(var(--secondary));
    opacity: 0.8;
    font-size: 0.6em;
    text-shadow: 2px 2px 4px rgba(177, 138, 70, 0.3);
    animation: ornamentFloat 3s ease-in-out infinite reverse;
  }

  .victorian-subheading {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 600;
    font-style: italic;
    letter-spacing: 0.02em;
    position: relative;
    color: hsl(var(--muted-foreground));
    text-shadow: 1px 1px 2px rgba(177, 138, 70, 0.2);
  }

  .victorian-subheading::before,
  .victorian-subheading::after {
    content: '◆';
    color: hsl(var(--secondary));
    opacity: 0.6;
    font-size: 0.7em;
    margin: 0 0.5em;
  }

  @keyframes victorianShimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
  }

  @keyframes ornamentFloat {
    0%, 100% { transform: translateY(-50%) rotate(15deg) translateY(0px); }
    50% { transform: translateY(-50%) rotate(15deg) translateY(-3px); }
  }
  
  /* Steampunk Interactive Elements */
  .steampunk-card {
    background: linear-gradient(135deg, rgba(245, 230, 197, 0.95) 0%, rgba(245, 230, 197, 0.8) 100%);
    border: 2px solid var(--brass);
    border-radius: 12px;
    position: relative;
    z-index: 0;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .steampunk-card::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, var(--brass), var(--teal), var(--brass));
    border-radius: 14px;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  @media (hover: hover) and (pointer: fine) {
    .steampunk-card:hover {
      transform: translateY(-8px);
      box-shadow:
        0 20px 40px rgba(177, 138, 70, 0.3),
        0 0 20px rgba(33, 240, 255, 0.2);
    }

    .steampunk-card:hover::before {
      opacity: 0;
    }
  }

  @media (hover: none), (pointer: coarse) {
    .steampunk-card:hover::before {
      opacity: 0;
    }
  }

  /* Mobile drawer animation */
  .drawer-enter {
    transform: translateX(-100%);
    opacity: 0;
  }
  
  .drawer-enter-active {
    transform: translateX(0);
    opacity: 1;
    transition: all 0.3s ease-out;
  }
  
  .drawer-exit {
    transform: translateX(0);
    opacity: 1;
  }
  
  .drawer-exit-active {
    transform: translateX(-100%);
    opacity: 0;
    transition: all 0.3s ease-in;
  }
  
  /* Backdrop blur optimization */
  @supports (backdrop-filter: blur(10px)) {
    .backdrop-blur-mobile {
      backdrop-filter: blur(10px);
    }
  }
  
  @supports not (backdrop-filter: blur(10px)) {
    .backdrop-blur-mobile {
      background: rgba(245, 230, 197, 0.96);
    }
  }
}