@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+KR:wght@400;600;700;900&family=Pretendard:wght@300;400;500;600;700&display=swap');

/* ================================================================
   DESIGN SYSTEM — "묵향 (墨香)" Ink & Paper Oriental Minimal
   Completely different from yangban.ai's gold/dark theme.
   Uses warm paper textures, ink-wash aesthetics, vertical rhythm.
   ================================================================ */

:root {
  --ink: #1a1a2e;
  --ink-light: #2d2d44;
  --ink-muted: #6b6b8a;
  --paper: #f5f0e8;
  --paper-warm: #ece4d4;
  --paper-deep: #e0d5c1;
  --accent: #8b4513;
  --accent-light: #a0522d;
  --accent-glow: rgba(139, 69, 19, 0.35);
  --vermillion: #cc3333;
  --vermillion-soft: rgba(204, 51, 51, 0.12);
  --jade: #2d6a4f;
  --jade-soft: rgba(45, 106, 79, 0.12);
  --indigo: #3d405b;

  --font-serif: 'Noto Serif KR', 'Batang', serif;
  --font-sans: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;

  --radius: 16px;
  --radius-sm: 10px;
  --max-w: 480px;

  --shadow-card: 0 2px 24px rgba(26, 26, 46, 0.08);
  --shadow-elevated: 0 8px 40px rgba(26, 26, 46, 0.12);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  -webkit-font-smoothing: antialiased;
}

/* Subtle paper texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(139, 69, 19, 0.03) 0%, transparent 70%),
    radial-gradient(ellipse at 80% 20%, rgba(45, 106, 79, 0.03) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ---- LAYOUT CONTAINER ---- */
.app-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--max-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- TOP BAR ---- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 1.25rem;
  position: relative;
}

.top-bar-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.3px;
}

/* ---- MAIN CONTENT ---- */
.main-content {
  flex: 1;
  padding: 0 1.25rem 2rem;
  display: flex;
  flex-direction: column;
}

/* ---- STEP FLOW (screens) ---- */
.screen {
  display: none;
  flex-direction: column;
  animation: screenIn 0.5s ease-out;
}

.screen.active {
  display: flex;
}

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

/* ================ SCREEN 1: UPLOAD ================ */
.intro-section {
  text-align: center;
  margin-bottom: 1.5rem;
  padding-top: 1rem;
}

.intro-icon {
  font-size: 2.2rem;
  margin-bottom: 0.75rem;
  display: inline-block;
  animation: floatIcon 3s ease-in-out infinite;
}

@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.intro-title {
  font-family: var(--font-serif);
  font-size: 1.65rem;
  font-weight: 900;
  line-height: 1.35;
  margin-bottom: 0.6rem;
  color: var(--ink);
}

.intro-sub {
  font-size: 0.92rem;
  color: var(--ink-muted);
  line-height: 1.55;
}

/* Upload Area */
.upload-area {
  position: relative;
  background: #fff;
  border: 2px dashed var(--paper-deep);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  aspect-ratio: 3 / 3.5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: var(--accent);
  background: rgba(139, 69, 19, 0.03);
}

.upload-area.has-image {
  border-style: solid;
  border-color: var(--accent);
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem;
  user-select: none;
}

.upload-icon-circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--paper-warm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  transition: var(--transition);
}

.upload-area:hover .upload-icon-circle {
  background: rgba(139, 69, 19, 0.1);
  transform: scale(1.05);
}

.upload-label {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}

.upload-hint {
  font-size: 0.82rem;
  color: var(--ink-muted);
  text-align: center;
  line-height: 1.5;
}

.upload-input {
  display: none;
}

/* Preview Image */
.preview-wrapper {
  display: none;
  position: relative;
  width: 100%;
  height: 100%;
}

.upload-area.has-image .upload-placeholder {
  display: none;
}

.upload-area.has-image .preview-wrapper {
  display: block;
}

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

.preview-change-btn {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(26, 26, 46, 0.7);
  color: #fff;
  border: none;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: var(--transition);
}

.preview-change-btn:hover {
  background: rgba(26, 26, 46, 0.9);
}

/* Privacy Note */
.privacy-note {
  text-align: center;
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin-top: 0.75rem;
}

/* Primary CTA Button */
.cta-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 1rem;
  margin-top: 1.25rem;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: -0.3px;
}

.cta-btn:hover {
  background: var(--ink-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-elevated);
}

.cta-btn:disabled {
  background: var(--paper-deep);
  color: var(--ink-muted);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ================ SCREEN 2: ANALYZING ================ */
.analyzing-screen {
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  text-align: center;
  gap: 2rem;
}

.analyze-visual {
  position: relative;
  width: 200px;
  height: 200px;
}

.analyze-photo {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: cover;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 3px solid var(--paper);
  box-shadow: var(--shadow-card);
  z-index: 2;
}

/* Scanning ring animation */
.scan-ring {
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spinRing 1.5s linear infinite;
}

.scan-ring:nth-child(2) {
  inset: 10px;
  border-top-color: var(--vermillion);
  animation-duration: 2s;
  animation-direction: reverse;
}

.scan-ring:nth-child(3) {
  inset: 20px;
  border-top-color: var(--jade);
  animation-duration: 2.5s;
}

@keyframes spinRing {
  to { transform: rotate(360deg); }
}

.analyze-text {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.analyze-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
}

.analyze-step {
  font-size: 0.9rem;
  color: var(--ink-muted);
  transition: opacity 0.3s;
}

.analyze-progress {
  width: 240px;
  height: 4px;
  background: var(--paper-deep);
  border-radius: 2px;
  overflow: hidden;
}

.analyze-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--vermillion), var(--jade));
  border-radius: 2px;
  transition: width 0.3s ease-out;
}

/* ================ SCREEN 3: RESULT ================ */
.result-screen {
  gap: 1.5rem;
  padding-bottom: 3rem;
}

/* Result Face Card */
.result-face-card {
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  position: relative;
}

.result-photo-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
}

.result-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-photo-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 50%, rgba(26, 26, 46, 0.85) 100%);
}

.result-headline {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1.5rem;
  color: #fff;
}

.result-type-badge {
  display: inline-block;
  background: var(--vermillion);
  color: #fff;
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
  letter-spacing: 0.5px;
}

.result-type-name {
  font-family: var(--font-serif);
  font-size: 1.65rem;
  font-weight: 900;
  line-height: 1.3;
  margin-bottom: 0.3rem;
}

.result-type-subtitle {
  font-size: 0.88rem;
  opacity: 0.85;
  line-height: 1.4;
}

/* Score Section */
.score-section {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--paper);
}

.score-ring {
  position: relative;
  width: 68px;
  height: 68px;
  flex-shrink: 0;
}

.score-ring svg {
  transform: rotate(-90deg);
}

.score-ring-bg {
  fill: none;
  stroke: var(--paper);
  stroke-width: 5;
}

.score-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 188;
  stroke-dashoffset: 188;
  transition: stroke-dashoffset 1.5s ease-out;
}

.score-number {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--ink);
}

.score-detail {
  flex: 1;
}

.score-label {
  font-size: 0.82rem;
  color: var(--ink-muted);
  margin-bottom: 0.15rem;
}

.score-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}

/* Summary Card */
.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.card-icon {
  font-size: 1.2rem;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 700;
}

.card-body-text {
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--ink-light);
  word-break: keep-all;
}

/* Fortune Bars */
.fortune-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.fortune-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.fortune-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fortune-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.fortune-value {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
}

.fortune-bar {
  height: 8px;
  background: var(--paper-warm);
  border-radius: 4px;
  overflow: hidden;
}

.fortune-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 1.2s ease-out;
  width: 0%;
}

.fortune-bar-fill.wealth { background: linear-gradient(90deg, #8b4513, #cd853f); }
.fortune-bar-fill.fame { background: linear-gradient(90deg, #3d405b, #6b6b8a); }
.fortune-bar-fill.love { background: linear-gradient(90deg, #cc3333, #e88888); }
.fortune-bar-fill.health { background: linear-gradient(90deg, #2d6a4f, #52b788); }

/* 5 Organs Section */
.organ-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.organ-tabs::-webkit-scrollbar {
  display: none;
}

.organ-tab {
  flex-shrink: 0;
  background: var(--paper);
  border: 1.5px solid var(--paper-deep);
  color: var(--ink-muted);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.organ-tab.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.organ-content {
  display: none;
  animation: screenIn 0.3s ease-out;
}

.organ-content.active {
  display: block;
}

.organ-feature {
  display: inline-block;
  background: var(--jade-soft);
  color: var(--jade);
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.organ-score-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.organ-score-num {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--accent);
}

.organ-score-label {
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.organ-desc {
  font-size: 0.93rem;
  line-height: 1.7;
  color: var(--ink-light);
  word-break: keep-all;
}

/* Animal Face Section */
.animal-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.animal-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.animal-emoji {
  font-size: 1.4rem;
  width: 36px;
  text-align: center;
  flex-shrink: 0;
}

.animal-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.animal-name-row {
  display: flex;
  justify-content: space-between;
}

.animal-name {
  font-size: 0.88rem;
  font-weight: 600;
}

.animal-pct {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
}

.animal-bar {
  height: 6px;
  background: var(--paper-warm);
  border-radius: 3px;
  overflow: hidden;
}

.animal-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 1s ease-out;
}

/* Tips Section */
.tip-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tip-item {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}

.tip-bullet {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 8px;
  flex-shrink: 0;
}

.tip-text {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--ink-light);
}

/* Action Buttons in Result */
.result-actions {
  display: flex;
  gap: 0.75rem;
}

.result-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.9rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: var(--transition);
}

.result-btn-primary {
  background: var(--ink);
  color: #fff;
}

.result-btn-primary:hover {
  background: var(--ink-light);
}

.result-btn-secondary {
  background: #fff;
  color: var(--ink);
  border: 1.5px solid var(--paper-deep);
}

.result-btn-secondary:hover {
  border-color: var(--ink);
}

/* ---- FOOTER ---- */
.app-footer {
  text-align: center;
  padding: 2rem 1.25rem;
  font-size: 0.75rem;
  color: var(--ink-muted);
  line-height: 1.6;
}

.footer-brand {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--ink);
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
}

/* ---- RESPONSIVE ---- */
@media (min-width: 600px) {
  body {
    padding: 2rem 0;
  }

  .app-container {
    background: var(--paper);
    border-radius: 24px;
    box-shadow: var(--shadow-elevated);
    min-height: auto;
  }
}
