/*
  AI EDIT NOTE:
  앞으로 이 파일을 수정할 때마다 초보자도 이해할 수 있도록
  주요 섹션/블록에 설명 주석을 자세히 추가·유지하세요.
*/
@layer base, components, utilities;

@layer base {
  :root {
    color-scheme: light;
    --ink: oklch(20% 0.02 270);
    --muted: oklch(48% 0.02 270);
    --surface: #ffffff;
    --surface-strong: oklch(98% 0.01 270);
    --accent: oklch(65% 0.2 350);
    --accent-strong: oklch(62% 0.22 22);
    --teal: oklch(72% 0.14 195);
    --shadow: 0 20px 50px rgba(26, 16, 44, 0.16);
    --radius: 20px;
    font-size: 16px;
  }

  * {
    box-sizing: border-box;
  }

  [hidden] {
    display: none !important;
  }

  body {
    margin: 0;
    font-family: "Source Sans 3", system-ui, -apple-system, sans-serif;
    color: var(--ink);
    background:
      radial-gradient(circle at 10% 15%, rgba(255, 255, 255, 0.95), transparent 55%),
      radial-gradient(circle at 85% 20%, rgba(255, 220, 250, 0.45), transparent 55%),
      radial-gradient(circle at 75% 80%, rgba(204, 232, 255, 0.55), transparent 60%),
      linear-gradient(135deg, #f7f2ff, #ffeef2);
    min-height: 100vh;
  }

  h1,
  h2 {
    font-family: "Source Sans 3", system-ui, -apple-system, sans-serif;
    margin: 0;
  }

  h1 {
    font-size: clamp(2.2rem, 3vw + 1rem, 3.4rem);
    letter-spacing: -0.02em;
  }

  h2 {
    font-size: 1.6rem;
  }

  p {
    margin: 0;
    line-height: 1.6;
    color: var(--muted);
  }

  button,
  input {
    font-family: inherit;
  }
}

@layer components {
  .ambient {
    position: fixed;
    inset: 0;
    background:
      radial-gradient(circle at 12% 20%, rgba(255, 255, 255, 0.75), transparent 60%),
      radial-gradient(circle at 85% 18%, rgba(255, 169, 232, 0.28), transparent 58%),
      radial-gradient(circle at 70% 85%, rgba(116, 196, 255, 0.26), transparent 60%);
    filter: blur(2px);
    pointer-events: none;
    z-index: 0;
  }

  .shell {
    position: relative;
    z-index: 1;
    max-width: 980px;
    margin: 0 auto;
    padding: 48px 20px 72px;
    display: grid;
    gap: 32px;
    container-type: inline-size;
  }

  .hero {
    display: grid;
    gap: 16px;
    align-items: start;
  }

  .badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.16em;
  }

  .panel {
    background: rgba(255, 255, 255, 0.88);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
    display: grid;
    gap: 24px;
  }

  .panel__top {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 16px;
  }

  .status {
    align-self: center;
    padding: 8px 16px;
    border-radius: 999px;
    background: rgba(240, 235, 255, 0.8);
    color: oklch(38% 0.1 285);
    font-weight: 600;
  }

  .controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
  }

  .btn {
    border: none;
    border-radius: 999px;
    padding: 12px 20px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
  }

  .btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(42, 35, 55, 0.2);
  }

  .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  .btn--primary {
    background: linear-gradient(135deg, oklch(64% 0.22 340), oklch(60% 0.24 20));
    color: white;
  }

  .btn--ghost {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(30, 30, 40, 0.12);
    color: var(--ink);
  }

  .btn--accent {
    background: linear-gradient(120deg, var(--teal), oklch(70% 0.12 150));
    color: var(--ink);
  }

  .btn input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
  }

  .preview {
    position: relative;
    border-radius: 24px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.7);
    min-height: 220px;
    display: grid;
    place-items: center;
    border: 1px dashed rgba(0, 0, 0, 0.08);
  }

  .preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
  }

  .preview.has-image img {
    display: block;
  }

  .preview.has-image .preview__placeholder {
    display: none;
  }

  .preview__placeholder {
    text-align: center;
    padding: 32px;
  }

  .preview__icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255, 130, 205, 0.35), rgba(255, 196, 92, 0.35));
    position: relative;
  }

  .preview__icon::after {
    content: "";
    position: absolute;
    inset: 16px;
    border-radius: 6px;
    border: 2px solid rgba(0, 0, 0, 0.15);
  }

  .feedback {
    min-height: 44px;
  }

  .loading {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    font-weight: 600;
  }

  .spinner {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--accent);
    animation: spin 1s linear infinite;
  }

  .error {
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(255, 120, 120, 0.15);
    color: oklch(35% 0.15 25);
    font-weight: 600;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .result {
    display: grid;
    gap: 16px;
  }

  calorie-result {
    display: block;
  }

  .disclaimer {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--muted);
  }

  @container (min-width: 720px) {
    .panel__top {
      align-items: center;
    }

    .controls {
      justify-content: flex-start;
    }
  }

  @media (max-width: 640px) {
    .shell {
      padding: 36px 16px 60px;
      gap: 24px;
    }

    h1 {
      font-size: clamp(1.9rem, 6vw, 2.6rem);
    }

    .panel {
      padding: 20px;
      gap: 20px;
    }

    .controls {
      flex-direction: column;
    }

    .btn {
      width: 100%;
      text-align: center;
      justify-content: center;
    }

    .status {
      width: 100%;
      text-align: center;
    }

    .preview {
      min-height: 200px;
    }
  }

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

@layer utilities {
  [hidden] {
    display: none !important;
  }

  .hidden {
    display: none;
  }
}
