/* ==========================================================================
   MICROINTERACTIVO • Coming Soon - Modern, Eye-Friendly & iPhone 17 / Pro Optimized
   ========================================================================== */

/* Modern Cascade Layers */
@layer reset, base, theme, components, utilities;

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

  html {
    -webkit-text-size-adjust: 100%;
    tab-size: 4;
    scroll-behavior: smooth;
    overflow-x: hidden;
  }

  body {
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.6;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
  }

  input, button, textarea, select {
    font: inherit;
    color: inherit;
    border: none;
    background: transparent;
  }

  button {
    cursor: pointer;
    user-select: none;
  }

  img, svg {
    display: block;
    max-width: 100%;
  }

  a {
    color: inherit;
    text-decoration: none;
  }
}

@layer theme {
  :root {
    /* Base Typography */
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', system-ui, sans-serif;
    --font-mono: 'Space Grotesk', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

    /* Theme: Aurora (Default - Calming Cyan & Emerald) */
    --bg-deep: #070a12;
    --bg-surface: rgba(13, 20, 36, 0.65);
    --bg-surface-elevated: rgba(22, 33, 58, 0.5);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(56, 189, 248, 0.5);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-1: #38bdf8;        /* Calming sky/cyan */
    --accent-2: #34d399;        /* Soothing mint/emerald */
    --accent-glow: rgba(56, 189, 248, 0.22);
    --accent-gradient: linear-gradient(135deg, #38bdf8 0%, #34d399 100%);
    
    --btn-bg: #f8fafc;
    --btn-text: #070a12;
    --btn-hover-bg: #e2e8f0;

    --card-shadow: 0 20px 45px -15px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--border-subtle);
    --transition-smooth: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }

  /* Theme: Midnight Indigo (Ultra-relaxing for night time) */
  [data-theme="indigo"] {
    --bg-deep: #080a16;
    --bg-surface: rgba(17, 19, 41, 0.68);
    --bg-surface-elevated: rgba(30, 34, 71, 0.55);
    --border-subtle: rgba(255, 255, 255, 0.09);
    --border-focus: rgba(129, 140, 248, 0.55);

    --accent-1: #818cf8;        /* Soft iris */
    --accent-2: #c084fc;        /* Ethereal lavender */
    --accent-glow: rgba(129, 140, 248, 0.24);
    --accent-gradient: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
  }

  /* Theme: Twilight Warmth (Zero blue light, cozy amber & warm slate) */
  [data-theme="twilight"] {
    --bg-deep: #120e0d;
    --bg-surface: rgba(36, 25, 22, 0.68);
    --bg-surface-elevated: rgba(56, 38, 33, 0.55);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(251, 191, 36, 0.55);

    --accent-1: #fbbf24;        /* Warm amber */
    --accent-2: #fb923c;        /* Soft tangerine */
    --accent-glow: rgba(251, 191, 36, 0.22);
    --accent-gradient: linear-gradient(135deg, #fbbf24 0%, #fb923c 100%);
  }
}

@layer base {
  body {
    font-family: var(--font-sans);
    background-color: var(--bg-deep);
    color: var(--text-primary);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: background-color 0.6s ease;
  }

  /* Focus visible accessibility guidelines */
  :focus-visible {
    outline: 2px solid var(--accent-1);
    outline-offset: 3px;
  }
}

@layer components {
  /* =========================================
     Ambient Animation & Background Layers
     ========================================= */
  #ambient-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: auto; /* Allows smooth touch reaction on canvas */
  }

  .ambient-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(90px);
    pointer-events: none;
    z-index: 1;
    opacity: 0.45;
    mix-blend-mode: screen;
    will-change: transform, opacity;
    transition: background 0.8s ease, opacity 0.8s ease;
  }

  .glow-1 {
    top: 5%;
    left: 15%;
    width: clamp(260px, 45vw, 550px);
    height: clamp(260px, 45vw, 550px);
    background: radial-gradient(circle, var(--accent-1) 0%, transparent 70%);
    animation: floatGlow1 18s ease-in-out infinite alternate;
  }

  .glow-2 {
    bottom: 10%;
    right: 15%;
    width: clamp(240px, 40vw, 500px);
    height: clamp(240px, 40vw, 500px);
    background: radial-gradient(circle, var(--accent-2) 0%, transparent 70%);
    animation: floatGlow2 22s ease-in-out infinite alternate;
  }

  .glow-3 {
    top: 45%;
    left: 45%;
    transform: translate(-50%, -50%);
    width: clamp(200px, 35vw, 420px);
    height: clamp(200px, 35vw, 420px);
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 65%);
    animation: floatGlow3 15s ease-in-out infinite alternate;
  }

  .ambient-vignette {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    background: radial-gradient(circle at 50% 50%, transparent 40%, rgba(7, 10, 18, 0.75) 100%);
  }

  @keyframes floatGlow1 {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(40px, 30px) scale(1.1); }
    100% { transform: translate(-30px, 50px) scale(0.95); }
  }

  @keyframes floatGlow2 {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-50px, -40px) scale(1.15); }
    100% { transform: translate(30px, -20px) scale(0.92); }
  }

  @keyframes floatGlow3 {
    0% { transform: translate(-50%, -50%) scale(0.9); opacity: 0.3; }
    50% { transform: translate(-45%, -55%) scale(1.15); opacity: 0.6; }
    100% { transform: translate(-55%, -45%) scale(1); opacity: 0.35; }
  }

  /* =========================================
     Layout & Safe Areas (iPhone 17 / Pro)
     ========================================= */
  .page-wrapper {
    position: relative;
    z-index: 10;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    
    /* Apple Safe Area Insets for Dynamic Island, Home Indicator & Bevels */
    padding-top: max(1.25rem, env(safe-area-inset-top));
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
    padding-left: max(1.25rem, env(safe-area-inset-left));
    padding-right: max(1.25rem, env(safe-area-inset-right));
  }

  /* Header */
  .app-header {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    gap: 1rem;
  }

  .brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
  }

  .brand-glyph {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--accent-1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform var(--transition-smooth), border-color var(--transition-smooth);
  }

  .brand:hover .brand-glyph {
    transform: scale(1.05);
    border-color: var(--accent-1);
  }

  .brand-glyph svg {
    width: 20px;
    height: 20px;
  }

  .brand-text {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  .header-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.85rem;
  }

  /* Palette Switcher */
  .palette-picker {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 4px 6px;
    border-radius: 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  .palette-btn {
    min-width: 28px;
    min-height: 28px;
    padding: 2px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    border: 1.5px solid transparent;
    transition: transform 0.2s ease, border-color 0.2s ease;
  }

  .palette-btn:hover {
    transform: scale(1.15);
  }

  .palette-btn.active {
    border-color: var(--text-primary);
  }

  .dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
  }

  .dot-aurora { background: linear-gradient(135deg, #38bdf8, #34d399); }
  .dot-indigo { background: linear-gradient(135deg, #818cf8, #c084fc); }
  .dot-twilight { background: linear-gradient(135deg, #fbbf24, #fb923c); }

  /* =========================================
     Hero Section
     ========================================= */
  .main-content {
    width: 100%;
    max-width: 780px;
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 2rem 1rem;
  }

  .hero-title {
    font-family: var(--font-sans);
    font-size: clamp(3rem, 7.5vw + 1rem, 5.75rem);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.035em;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    text-wrap: balance;
  }

  .gradient-text {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
  }

  .hero-subtitle {
    font-size: clamp(1rem, 1.8vw + 0.3rem, 1.25rem);
    line-height: 1.65;
    color: var(--text-secondary);
    max-width: 580px;
    margin-bottom: 2.75rem;
    text-wrap: pretty;
  }

  /* =========================================
     Countdown Section
     ========================================= */
  .countdown-section {
    width: 100%;
    margin-bottom: 0;
  }

  .countdown-grid {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: clamp(0.5rem, 2vw, 1.25rem);
    padding: clamp(0.85rem, 2.2vw, 1.35rem) clamp(1.2rem, 3.5vw, 2.25rem);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 24px;
    box-shadow: var(--card-shadow);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
  }

  .countdown-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: clamp(52px, 12vw, 76px);
  }

  .countdown-value {
    font-family: var(--font-mono);
    font-size: clamp(1.85rem, 4.8vw, 3rem);
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s ease;
  }

  .countdown-label {
    font-size: clamp(0.7rem, 1.5vw, 0.8rem);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin-top: 0.25rem;
  }

  .countdown-separator {
    font-family: var(--font-mono);
    font-size: clamp(1.5rem, 3vw, 2.25rem);
    font-weight: 300;
    color: var(--text-muted);
    opacity: 0.5;
    margin-top: -0.85rem;
  }

  /* =========================================
     Footer & Social Links
     ========================================= */
  .app-footer {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    padding: 1rem 0.5rem 0.5rem;
  }

  .social-links {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
  }

  .social-link {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px; /* 44px minimum touch target for iPhone */
    border-radius: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: color var(--transition-smooth), transform var(--transition-smooth), border-color var(--transition-smooth);
  }

  .social-link:hover {
    color: var(--text-primary);
    border-color: var(--accent-1);
    transform: translateY(-2px);
  }

  .social-link:active {
    transform: scale(0.95);
  }

  .social-link svg {
    width: 18px;
    height: 18px;
  }

  .footer-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
  }

  /* =========================================
     Animations & Entrance
     ========================================= */
  .animate-fade-in {
    opacity: 0;
    transform: translateY(18px);
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

  .delay-1 { animation-delay: 0.1s; }
  .delay-2 { animation-delay: 0.2s; }
  .delay-3 { animation-delay: 0.3s; }

  @keyframes fadeInUp {
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  /* =======================================================
     Mobile Media Queries (iPhone 17, iPhone 17 Pro, Safari)
     ======================================================= */
  @media (max-width: 600px) {
    .page-wrapper {
      padding-left: max(1rem, env(safe-area-inset-left));
      padding-right: max(1rem, env(safe-area-inset-right));
    }

    .app-header {
      padding: 0.25rem 0;
    }

    .main-content {
      margin: auto;
      padding: 1.5rem 0;
    }

    .hero-title {
      font-size: clamp(2.6rem, 12vw, 3.5rem);
      margin-bottom: 1rem;
    }

    .hero-subtitle {
      font-size: 0.98rem;
      margin-bottom: 2.25rem;
      padding: 0 0.5rem;
    }

    .countdown-grid {
      gap: 0.45rem;
      padding: 0.85rem 1rem;
      border-radius: 18px;
    }

    .countdown-card {
      min-width: 48px;
    }

    .countdown-value {
      font-size: 1.75rem;
    }

    .countdown-label {
      font-size: 0.68rem;
    }

    .countdown-separator {
      font-size: 1.4rem;
    }

    .footer-meta {
      flex-direction: column;
      gap: 0.35rem;
    }
  }

  /* Accessibility: Prefers Reduced Motion */
  @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;
    }

    .ambient-glow {
      animation: none !important;
    }
  }
}
