@layer base, layout, components, utilities;

@layer base {
  :root {
    --bg-color: #f8fafc;
    --text-color: #1e293b;
    --primary-color: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.5);
    --secondary-color: #64748b;
    
    /* Lotto Ball Colors */
    --lotto-1: #facc15; /* yellow */
    --lotto-11: #3b82f6; /* blue */
    --lotto-21: #ef4444; /* red */
    --lotto-31: #94a3b8; /* grey */
    --lotto-41: #22c55e; /* green */
    
    --shadow-soft: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-deep: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  }

  html {
    scroll-behavior: smooth;
  }

  body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    line-height: 1.5;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 150px;
    opacity: 0.98;
  }
}

@layer layout {
  .navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0.75rem 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  }

  .nav-content {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    gap: 2rem;
  }

  .nav-link {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.2s ease;
    padding: 0.5rem 1rem;
    border-radius: 8px;
  }

  .nav-link:hover {
    color: var(--primary-color);
    background: rgba(59, 130, 246, 0.1);
  }

  .app-container {
    max-width: 600px;
    margin: 2rem auto;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 24px;
    box-shadow: var(--shadow-deep);
    border: 1px solid rgba(255, 255, 255, 0.3);
    container-type: inline-size;
  }

  header {
    text-align: center;
    margin-bottom: 3rem;
  }

  header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0;
    background: linear-gradient(135deg, #1e293b 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  header p {
    color: var(--secondary-color);
    font-size: 1.1rem;
    margin-top: 0.5rem;
  }

  main {
    display: flex;
    flex-direction: column;
    gap: 3rem;
  }

  footer {
    text-align: center;
    margin-top: 4rem;
    font-size: 0.875rem;
    color: var(--secondary-color);
  }
}

@layer components {
  .balls-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    min-height: 80px;
    margin-bottom: 2rem;
  }

  .generator-section {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .glow-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 14px 0 var(--primary-glow);
  }

  .glow-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 var(--primary-glow);
    background-color: #2563eb;
  }

  .glow-button:active {
    transform: translateY(0);
  }

  .history-section {
    border-top: 1px solid #e2e8f0;
    padding-top: 2rem;
  }

  .history-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--text-color);
  }

  .history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 0.5rem;
  }

  .history-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    animation: slideIn 0.3s ease-out forwards;
  }

  .text-button {
    background: none;
    border: none;
    color: var(--secondary-color);
    font-size: 0.875rem;
    cursor: pointer;
    margin-top: 1rem;
    text-decoration: underline;
  }

  .animal-test-section {
    margin-top: 1rem;
  }

  .test-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
  }

  .upload-wrapper label {
    display: inline-block;
    cursor: pointer;
  }

  .image-preview-wrapper {
    width: 250px;
    height: 250px;
    border: 2px dashed #cbd5e1;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    position: relative;
    box-shadow: var(--shadow-soft);
  }

  .image-preview-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .placeholder-text {
    color: var(--secondary-color);
    font-size: 0.875rem;
    text-align: center;
  }

  .label-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .label-wrapper div {
    padding: 0.5rem 1rem;
    background: white;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-soft);
    display: flex;
    justify-content: space-between;
  }

  .content-rich-section {
    padding: 2rem;
    background: white;
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
  }

  .guide-content h3 {
    font-size: 1.15rem;
    margin: 1.5rem 0 0.75rem;
    color: var(--primary-color);
  }

  .guide-content p {
    font-size: 0.95rem;
    color: var(--secondary-color);
    line-height: 1.7;
  }

  .faq-item {
    margin-bottom: 1.5rem;
  }

  .faq-item h4 {
    margin-bottom: 0.5rem;
    color: var(--text-color);
  }

  .faq-item p {
    font-size: 0.9rem;
    color: var(--secondary-color);
  }

  .footer-links {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
    font-size: 0.8rem;
  }

  .footer-links a {
    color: var(--secondary-color);
    text-decoration: none;
  }

  .footer-links a:hover {
    color: var(--primary-color);
  }

  .partnership-section {
    margin-top: 1rem;
  }

  .glass-card {
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
  }

  .glass-card h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
  }

  .glass-card p {
    color: var(--secondary-color);
    margin-bottom: 1.5rem;
  }

  .contact-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
  }

  .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .form-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
  }

  .form-group input,
  .form-group textarea {
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.8);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s ease;
  }

  .form-group input:focus,
  .form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-glow);
  }

  .glow-button.small {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    align-self: flex-start;
  }
}

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

@container (max-width: 450px) {
  header h1 {
    font-size: 1.8rem;
  }
  
  .glow-button {
    width: 100%;
    padding: 0.75rem 1.5rem;
  }
}
