/* ─────────────────────────────────────────────
   lotto.css — 커스텀 컴포넌트 스타일
   Tailwind 유틸리티로 커버되지 않는 부분만 작성
   테마 변수는 CSS custom properties로 관리
───────────────────────────────────────────── */

/* ── Semantic theme tokens ──────────────────── */
:root,
[data-theme="light"] {
  --bg: #faf7f2;
  --bg-alt: #f0ebe0;
  --surface: #ffffff;
  --ink: #1a1610;
  --ink-muted: #7a6f5e;
  --gold: #c9922a;
  --gold-light: #f0d080;
  --border: #e0d8c8;
  --shadow-md: 0 8px 32px rgba(26, 22, 16, 0.1);
  --btn-bg: #1a1610;
  --btn-fg: #faf7f2;
  --btn-hover-bg: #c9922a;
  --btn-hover-fg: #1a1610;
  --error-bg: #fff0f0;
  --error-border: #f5c0c0;
  --error-fg: #b82020;
  --placeholder: #e0d8c8;
  --history-div: #f0ebe0;
  --circle1: #f0d080;
  --circle2: #d4e8ff;
  --circle3: #ffe0b0;
}

[data-theme="dark"] {
  --bg: #0a0a0f;
  --bg-alt: #111118;
  --surface: #111118;
  --ink: #f0ead8;
  --ink-muted: #9a8f7a;
  --gold: #ffd700;
  --gold-light: #b8961e;
  --border: rgba(255, 215, 0, 0.15);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
  --btn-bg: #ffd700;
  --btn-fg: #1a1000;
  --btn-hover-bg: #fff5a0;
  --btn-hover-fg: #1a1000;
  --error-bg: #2a0000;
  --error-border: #7a2020;
  --error-fg: #ff8080;
  --placeholder: rgba(255, 255, 255, 0.15);
  --history-div: rgba(255, 255, 255, 0.05);
  --circle1: rgba(255, 215, 0, 0.12);
  --circle2: rgba(90, 180, 255, 0.07);
  --circle3: rgba(255, 200, 80, 0.07);
}

/* ── Base ───────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  /* font-family: 'Noto Sans KR', sans-serif; */
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  position: relative;
  overflow-x: hidden;
  transition:
    background 0.35s ease,
    color 0.35s ease;
}

/* ── Theme Toggle ───────────────────────────── */
.theme-toggle {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 100;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  box-shadow: var(--shadow-md);
  transition:
    background 0.35s ease,
    border-color 0.35s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.theme-toggle:hover {
  transform: scale(1.12) rotate(18deg);
  box-shadow: 0 4px 20px rgba(201, 146, 42, 0.3);
}

.theme-toggle .icon-light {
  display: inline;
}
.theme-toggle .icon-dark {
  display: none;
}
[data-theme="dark"] .theme-toggle .icon-light {
  display: none;
}
[data-theme="dark"] .theme-toggle .icon-dark {
  display: inline;
}

/* ── Background circles ─────────────────────── */
.bg-decoration {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.bg-circle {
  position: absolute;
  border-radius: 50%;
  opacity: 0.45;
  filter: blur(60px);
  transition: background 0.35s ease;
}
.bg-circle--1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--circle1), transparent 70%);
  top: -120px;
  right: -120px;
}
.bg-circle--2 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, var(--circle2), transparent 70%);
  bottom: -80px;
  left: -80px;
}
.bg-circle--3 {
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, var(--circle3), transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* ── Layout ─────────────────────────────────── */
.page-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── Header ─────────────────────────────────── */
.page-header {
  text-align: center;
  padding: 1.5rem 0 0.5rem;
}

.eyebrow {
  /* font-size: 0.68rem; font-weight: 500; */

  font-size: 1.2em;
  font-weight: 500;

  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.6rem;

  text-shadow: 1px 0.7px 1px black;
}

.main-title {
  /* font-family: "Nanum Myeongjo", serif; */
  font-weight: 800;
  font-size: clamp(2.4rem, 8vw, 3.6rem);

  line-height: 1;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.3em;
  margin-bottom: 0.5rem;
  transition: color 0.35s ease;
}

.title-divider {
  font-weight: 400;
  color: var(--gold);
  font-size: 0.7em;
}
.title-en {
  font-size: 0.65em;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  font-weight: 700;
}
.subtitle {
  /* font-size: 0.75rem; */
  font-size: 1em;
  color: var(--ink-muted);
  letter-spacing: 0.15em;
}

/* ── Card ───────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  transition:
    background 0.35s ease,
    border-color 0.35s ease,
    box-shadow 0.35s ease;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  border-radius: 0 0 2px 2px;
}

.card-label {
  font-size: 1em; /*0.65rem;*/
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 500;
  margin-bottom: 1.25rem;
  transition: color 0.35s ease;
}

/* ── Balls ──────────────────────────────────── */
.balls-container {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
  min-height: 76px;
  align-items: center;
}

.placeholder-text {
  /* font-size : 0.8rem; font-weight : 300 */
  font-size: 1em;
  font-weight: 400;

  /* color: var(--placeholder); */
  letter-spacing: 0.1em;
}

.ball {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Nanum Myeongjo", serif;
  font-weight: 800;
  font-size: 1.3rem;
  color: #fff;
  position: relative;
  flex-shrink: 0;
  opacity: 0;
  transform: translateY(16px) scale(0.85);
  transition:
    opacity 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.18),
    inset 0 -3px 6px rgba(0, 0, 0, 0.15);

  text-shadow: 1px 1px 1px black;
}

.ball::after {
  content: "";
  position: absolute;
  top: 12%;
  left: 18%;
  width: 32%;
  height: 26%;
  background: rgba(255, 255, 255, 0.38);
  border-radius: 50%;
  filter: blur(2px);
}

.ball.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.ball-yellow {
  background: radial-gradient(circle at 35% 30%, #ffd84d, #c9922a);
}
.ball-blue {
  background: radial-gradient(circle at 35% 30%, #7ab8f5, #1a5fa8);
}
.ball-red {
  background: radial-gradient(circle at 35% 30%, #f58585, #b82020);
}
.ball-gray {
  background: radial-gradient(circle at 35% 30%, #c0b8ad, #6b6258);
}
.ball-green {
  background: radial-gradient(circle at 35% 30%, #82d48a, #276b2e);
}

/* ── Divider ────────────────────────────────── */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: 1.5rem 0;
  transition: background 0.35s ease;
}

/* ── Action / Button ────────────────────────── */
.action-area {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.error-msg {
  font-size: 0.78rem;
  color: var(--error-fg);
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-weight: 500;
  transition:
    background 0.35s ease,
    color 0.35s ease,
    border-color 0.35s ease;
}

.btn-generate {
  width: 100%;
  padding: 0.9rem 1.5rem;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: none;
  border-radius: 0.75rem;
  /* font-family: "Nanum Myeongjo", serif; */
  font-weight: 700;
  font-size: 1.2em; /* 1rem; */
  letter-spacing: 0.08em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition:
    background 0.25s ease,
    color 0.25s ease,
    transform 0.15s ease,
    box-shadow 0.2s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.btn-generate:hover {
  background: var(--btn-hover-bg);
  color: var(--btn-hover-fg);
  box-shadow: 0 6px 24px rgba(201, 146, 42, 0.35);
  transform: translateY(-1px);
}

.btn-generate:active {
  transform: translateY(0);
}
.btn-generate:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.btn-icon {
  font-size: 0.85em;
}

/* ── Spinner ────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── History ────────────────────────────────── */
.history-card {
  padding: 1.5rem 1.75rem;
}
.history-list {
  display: flex;
  flex-direction: column;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--history-div);
  opacity: 0;
  animation: fadeIn 0.3s ease forwards;
  transition: border-color 0.35s ease;
}

.history-item:last-child {
  border-bottom: none;
}

.history-ball {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  /* font-weight :700, font-size : 0.68rem; */
  font-weight: 500;
  font-size: 1em;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);

  /* text-shadow 추가 */
  text-shadow: 1px 1px 1px black;
}

.history-round {
  font-size: 0.65rem;
  color: var(--ink-muted);
  font-weight: 300;
  margin-right: 0.25rem;
  min-width: 2rem;
  text-align: right;
  transition: color 0.35s ease;
}

.history-time {
  font-size: 0.65rem;
  color: var(--ink-muted);
  margin-left: auto;
  font-weight: 300;
  opacity: 0.5;
  transition: color 0.35s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateX(-6px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ── Responsive ─────────────────────────────── */
@media (max-width: 400px) {
  .ball {
    width: 52px;
    height: 52px;
    font-size: 1.05rem;
  }
  .balls-container {
    gap: 0.4rem;
  }
  .theme-toggle {
    top: 0.75rem;
    right: 0.75rem;
    width: 38px;
    height: 38px;
  }
}
