@layer base, layout, components, utilities;

@layer base {
  :root {
    /* Day Theme (Light) */
    --bg-color: oklch(98% 0.01 200);
    --text-color: oklch(20% 0.02 200);
    --primary-color: oklch(60% 0.2 250);
    --primary-hover: oklch(55% 0.22 250);
    --card-bg: oklch(100% 0 0);
    --card-shadow: 0 20px 40px oklch(0% 0 0 / 5%), 0 1px 3px oklch(0% 0 0 / 5%);
    --border-color: oklch(90% 0.01 200);
    --accent-color: oklch(70% 0.15 320);
    
    --font-main: 'Plus Jakarta Sans', system-ui, sans-serif;
    
    color-scheme: light;
  }

  :root.theme-dark {
    /* Night Theme (Dark) */
    --bg-color: oklch(15% 0.02 250);
    --text-color: oklch(95% 0.01 250);
    --primary-color: oklch(75% 0.15 250);
    --primary-hover: oklch(80% 0.18 250);
    --card-bg: oklch(20% 0.03 250);
    --card-shadow: 0 30px 60px oklch(0% 0 0 / 50%), 0 1px 2px oklch(100% 0 0 / 10%);
    --border-color: oklch(30% 0.03 250);
    --accent-color: oklch(80% 0.12 320);
    
    color-scheme: dark;
  }

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

  body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
  }

  h1 {
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.02em;
  }
}

@layer layout {
  header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem;
    max-width: 1200px;
    margin-inline: auto;
    width: 100%;
  }

  main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    max-width: 1200px;
    margin-inline: auto;
    width: 100%;
    gap: 4rem;
  }

  footer {
    padding: 2rem;
    text-align: center;
    font-size: 0.875rem;
    opacity: 0.6;
  }

  .background-texture {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    opacity: 0.4;
    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");
  }
}

@layer components {
  .logo {
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: 0.1em;
    color: var(--primary-color);
  }

  #theme-toggle {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    width: 48px;
    height: 48px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--card-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  #theme-toggle:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color);
  }

  #theme-toggle .moon-icon,
  :root.theme-dark #theme-toggle .sun-icon {
    display: none;
  }

  :root.theme-dark #theme-toggle .moon-icon {
    display: block;
  }

  #theme-toggle svg {
    width: 24px;
    height: 24px;
  }

  .hero {
    text-align: center;
    max-width: 600px;
  }

  .hero h1 {
    font-size: clamp(3rem, 10vw, 5rem);
    margin-block-end: 1rem;
  }

  .hero h1 span {
    color: var(--primary-color);
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  .hero p {
    font-size: 1.25rem;
    opacity: 0.8;
  }

  .card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 3rem;
    border-radius: 32px;
    box-shadow: var(--card-shadow);
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    transition: all 0.4s ease;
    backdrop-filter: blur(10px);
  }

  .display-container {
    background: oklch(0% 0 0 / 3%);
    border-radius: 20px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
    font-weight: 800;
    color: var(--primary-color);
    text-shadow: 0 10px 20px oklch(var(--primary-color) / 20%);
  }

  #generate-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 1.25rem;
    border-radius: 16px;
    font-family: inherit;
    font-weight: 600;
    font-size: 1.125rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 20px oklch(var(--primary-color) / 30%);
  }

  #generate-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.02);
    box-shadow: 0 15px 30px oklch(var(--primary-color) / 40%);
  }

  #generate-btn:active {
    transform: scale(0.98);
  }

  #generate-btn svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
  }

  #generate-btn:hover svg {
    transform: translateX(4px);
  }
}

@layer utilities {
  /* Scrollbar styles */
  ::-webkit-scrollbar {
    width: 10px;
  }
  ::-webkit-scrollbar-track {
    background: var(--bg-color);
  }
  ::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
  }
  ::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
  }
}

@container (max-width: 500px) {
  .card {
    padding: 2rem;
  }
}
