@layer base, components, animations;

@layer base {
  :root {
    --font-timer: 'Space Grotesque', sans-serif;
    --font-text: 'Pretendard', 'Inter', system-ui, sans-serif;
    --bg-base: oklch(98% 0.01 240);
    --text-main: oklch(20% 0.02 240);
    --text-muted: oklch(40% 0.02 240);
    --glass-bg: oklch(100% 0 0 / 40%);
    --glass-border: oklch(100% 0 0 / 50%);
    --accent-focus: oklch(55% 0.15 250);
    --accent-break: oklch(75% 0.15 40);
    --accent-long: oklch(70% 0.12 150);
    --aura-1: oklch(85% 0.1 240);
    --aura-2: oklch(85% 0.1 200);
    --aura-3: oklch(90% 0.05 280);
  }

  [data-theme="dark"] {
    --bg-base: oklch(15% 0.02 240);
    --text-main: oklch(95% 0.01 240);
    --text-muted: oklch(75% 0.01 240);
    --glass-bg: oklch(20% 0.03 240 / 40%);
    --glass-border: oklch(100% 0 0 / 10%);
    --aura-1: oklch(25% 0.08 240);
    --aura-2: oklch(25% 0.08 200);
    --aura-3: oklch(20% 0.05 280);
  }

  [data-mode="focus"] { --current-accent: var(--accent-focus); }
  [data-mode="short-break"] { --current-accent: var(--accent-break); --aura-1: oklch(85% 0.1 40); --aura-2: oklch(85% 0.1 60); }
  [data-mode="long-break"] { --current-accent: var(--accent-long); --aura-1: oklch(85% 0.1 150); --aura-2: oklch(85% 0.1 130); }

  * { box-sizing: border-box; margin: 0; padding: 0; }
  
  html { scroll-behavior: smooth; }

  body {
    font-family: var(--font-text);
    background-color: var(--bg-base);
    color: var(--text-main);
    min-height: 100vh;
    transition: background-color 1s ease, color 0.5s ease;
    line-height: 1.6;
  }
}

@layer components {
  /* Layout Containers */
  .app-container {
    position: relative;
    z-index: 10;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1.5rem;
  }

  /* Header */
  .main-header {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    background: var(--glass-bg);
  }

  .header-inner {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .desktop-nav {
    display: flex;
    gap: 2rem;
  }

  .desktop-nav a {
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.9rem;
    opacity: 0.7;
    transition: opacity 0.3s;
  }

  .desktop-nav a:hover { opacity: 1; }

  .logo { font-weight: 700; letter-spacing: 0.2em; font-size: 0.9rem; }

  /* Hero Section (Timer) */
  .hero-section {
    min-height: calc(100vh - 70px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 0;
  }

  .content-viewport {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
  }

  .timer-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
    width: 100%;
  }

  .mode-selector {
    display: flex;
    gap: 0.25rem;
    background: var(--glass-bg);
    padding: 0.4rem;
    border-radius: 2rem;
    border: 1px solid var(--glass-border);
  }

  .mode-btn {
    padding: 0.6rem 1.2rem;
    border-radius: 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-main);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    opacity: 0.5;
  }

  .mode-btn.active {
    background: var(--current-accent);
    color: white;
    opacity: 1;
    box-shadow: 0 4px 15px var(--current-accent);
  }

  .timer-display {
    position: relative;
    width: min(340px, 80vw);
    height: min(340px, 80vw);
    display: flex;
    justify-content: center;
    align-items: center;
  }

  #timer-text {
    font-family: var(--font-timer);
    font-size: min(6.5rem, 20vw);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }

  .progress-ring-container {
    position: absolute;
    inset: 0;
    transform: rotate(-90deg);
  }

  .progress-ring { width: 100%; height: 100%; }
  .progress-ring__circle {
    transition: stroke-dashoffset 0.1s linear, stroke 0.5s ease;
    color: var(--current-accent);
    stroke-dasharray: 1005.31;
    stroke-dashoffset: 0;
  }

  .bottom-controls {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  /* Info Sections */
  .info-section {
    padding: 4rem 0;
  }

  .article-card {
    padding: 3rem;
    border-radius: 2rem;
    margin-bottom: 2rem;
  }

  .article-card h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    color: var(--current-accent);
  }

  .article-card p {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    opacity: 0.9;
  }

  .info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
  }

  .info-item h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--current-accent);
  }

  .two-column-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
  }

  @media (max-width: 768px) {
    .two-column-grid { grid-template-columns: 1fr; }
    .desktop-nav { display: none; }
    .article-card { padding: 2rem; }
  }

  /* FAQ */
  .faq-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
  }

  .faq-item h4 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
  }

  /* Ad Placeholder */
  .ad-placeholder {
    width: 100%;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.5;
    border: 1px dashed var(--glass-border);
    margin: 2rem 0;
  }

  /* Footer */
  .main-footer {
    margin-top: 4rem;
    padding: 4rem 1.5rem;
    border-top: 1px solid var(--glass-border);
  }

  .footer-content {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 2rem;
  }

  .footer-info p {
    font-size: 0.9rem;
    opacity: 0.7;
  }

  .footer-links {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .footer-links a {
    text-decoration: none;
    color: var(--text-main);
    font-size: 0.9rem;
    opacity: 0.6;
    transition: opacity 0.3s;
  }

  .footer-links a:hover { opacity: 1; }

  /* Utilities */
  .glass { background: var(--glass-bg); backdrop-filter: blur(30px); border: 1px solid var(--glass-border); border-radius: 1.5rem; }
  .main-btn { padding: 1.2rem 3.5rem; border-radius: 3.5rem; border: none; background: var(--current-accent); color: white; font-weight: 700; cursor: pointer; transition: all 0.3s; box-shadow: 0 8px 20px oklch(0% 0 0 / 15%); font-size: 1.2rem; }
  .secondary-btn { background: none; border: none; color: var(--text-main); font-weight: 600; cursor: pointer; opacity: 0.5; font-size: 1rem; }
  .icon-button { background: none; border: none; color: var(--text-main); cursor: pointer; padding: 0.6rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: background 0.2s; }
  .icon-button:hover { background: var(--glass-border); }
  
  .sound-mixer { padding: 1.5rem; }
  .sound-btn { width: 3rem; height: 3rem; border-radius: 1rem; border: none; background: var(--glass-border); font-size: 1.2rem; cursor: pointer; transition: all 0.3s; }
  .sound-btn.active { background: var(--current-accent); color: white; transform: scale(1.1); }
  #volume-slider { width: 100%; accent-color: var(--current-accent); height: 6px; }
  
  #task-input { width: 100%; background: transparent; border: none; color: var(--text-main); font-size: 1.1rem; text-align: center; outline: none; font-weight: 600; padding: 0.5rem; }
}

@layer animations {
  .aura-bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; filter: blur(100px); }
  .aura { position: absolute; border-radius: 50%; mix-blend-mode: soft-light; animation: drift 30s infinite alternate; }
  .aura-1 { width: 90vw; height: 90vw; background: var(--aura-1); top: -30%; left: -30%; }
  .aura-2 { width: 80vw; height: 80vw; background: var(--aura-2); bottom: -20%; right: -20%; animation-delay: -5s; }
  .aura-3 { width: 60vw; height: 60vw; background: var(--aura-3); top: 40%; left: 50%; animation-delay: -10s; }
  @keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(15%, 20%) scale(1.2); } }
}

.hidden { display: none !important; }
