/* =========================================================
   Lotto 6/45 조합 분석기 — visual layer
   Concept: Premium Analytical Hybrid (Gemini design pass)
   - Calm, financial-dashboard tone
   - Mobile-first card layout
   - Subtle elevation, restrained color
   ========================================================= */

/* ---------- 1. Design tokens ---------- */
:root {
  /* Surface & text */
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-alt: #f1f5f9;
  --color-text-main: #1e293b;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --color-border-strong: #cbd5e1;

  /* Brand */
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-soft: #eff6ff;
  --color-primary-ring: rgba(37, 99, 235, 0.15);

  /* Status (Financial tone) */
  --status-success: #059669;
  --status-success-soft: #ecfdf5;
  --status-warning: #d97706;
  --status-warning-soft: #fffbeb;
  --status-danger: #dc2626;
  --status-danger-soft: #fef2f2;

  /* Lotto ball ranges (Analytical/Professional) */
  --ball-1-10: #f59e0b;   /* Amber-500 */
  --ball-11-20: #3b82f6;  /* Blue-500 */
  --ball-21-30: #ef4444;  /* Red-500 */
  --ball-31-40: #6b7280;  /* Gray-500 */
  --ball-41-45: #10b981;  /* Green-500 */

  /* Geometry */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 99px;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 48px;

  /* Elevation (Subtle & Clean) */
  --shadow-sm: 0 1px 2px 0 rgb(15 23 42 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(15 23 42 / 0.1),
               0 2px 4px -1px rgb(15 23 42 / 0.06);
  --shadow-lg: 0 10px 15px -3px rgb(15 23 42 / 0.1),
               0 4px 6px -2px rgb(15 23 42 / 0.05);

  /* Layout */
  --container-max: 720px; /* More focused reading width */

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Pretendard",
    "Noto Sans KR", "Apple SD Gothic Neo", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- 2. Base reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text-main);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

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

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  text-decoration: underline;
  color: var(--color-primary-hover);
}

button {
  font: inherit;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

input,
button {
  color: inherit;
}

/* Accessible focus ring */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- 3. Layout helpers ---------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-5);
}

.skip-link {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  width: auto;
  height: auto;
  padding: var(--space-2) var(--space-4);
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-sm);
  z-index: 100;
  text-decoration: none;
}

/* ---------- 4. Header ---------- */
.site-header {
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-main);
  font-weight: 700;
}

.brand:hover {
  text-decoration: none;
}

.brand__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--color-primary);
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
}

.brand__name {
  font-size: 0.9rem;
  letter-spacing: -0.01em;
}

.site-nav__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: var(--space-2);
}

.site-nav a {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

.site-nav a:hover {
  color: var(--color-text-main);
  background: var(--color-surface-alt);
  text-decoration: none;
}

/* ---------- 5. Sections ---------- */
.site-main {
  padding-bottom: var(--space-8);
}

.section {
  padding: var(--space-7) 0;
}

.section--surface {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.section__header {
  margin-bottom: var(--space-5);
}

.section__title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 var(--space-2);
  letter-spacing: -0.02em;
}

.section__lead {
  color: var(--color-text-muted);
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ---------- 6. Hero ---------- */
.hero {
  padding: var(--space-8) 0 var(--space-7);
  text-align: center;
}

.hero__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero__eyebrow {
  display: inline-block;
  margin: 0 0 var(--space-3);
  padding: 2px var(--space-3);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-pill);
}

.hero__title {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.25;
  margin: 0 0 var(--space-4);
  letter-spacing: -0.03em;
  color: var(--color-text-main);
}

.hero__lead {
  color: var(--color-text-muted);
  max-width: 48ch;
  margin: 0 0 var(--space-6);
  font-size: 1rem;
}

.hero__actions {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: var(--space-3);
}

/* ---------- 7. Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: var(--space-2) var(--space-6);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  user-select: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:active {
  transform: scale(0.98);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-ring);
}

.btn--primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
}

.btn--primary:hover {
  background: var(--color-primary-hover);
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.25);
}

.btn--ghost {
  background: var(--color-surface);
  color: var(--color-text-main);
  border-color: var(--color-border-strong);
}

.btn--ghost:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-border-strong);
}

/* Secondary ghost for less important actions */
#regenerate-button.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
  font-size: 0.9rem;
}

#regenerate-button.btn--ghost:hover {
  color: var(--color-text-main);
  background: var(--color-surface-alt);
}

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---------- 8. Recommend form ---------- */
.recommend-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.mode-fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

.mode-fieldset__legend {
  font-weight: 700;
  margin-bottom: var(--space-3);
  padding: 0;
  font-size: 0.95rem;
  color: var(--color-text-main);
}

.mode-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.mode-option {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  column-gap: var(--space-3);
  row-gap: var(--space-1);
  padding: var(--space-4);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-option:hover {
  border-color: var(--color-border-strong);
}

.mode-option[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
}

.mode-option input[type="radio"] {
  grid-column: 1;
  grid-row: 1;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--color-primary);
}

.mode-option:has(input[type="radio"]:checked) {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
}

.mode-option__title {
  grid-column: 2;
  grid-row: 1;
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.4;
  margin: 0;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.mode-option__desc {
  grid-column: 1 / -1;
  grid-row: 2;
  display: block;
  width: 100%;
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
  word-break: keep-all;
  overflow-wrap: break-word;
  white-space: normal;
}

.form-help {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-align: center;
}

.recommend-form__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* ---------- 9. Result cards ---------- */
.results-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.result-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease;
}

.result-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.result-card__label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.result-card__balls {
  display: flex;
  justify-content: space-between; /* Fit 6 balls on 360px */
  gap: var(--space-1);
  margin-bottom: var(--space-5);
}

.result-card__summary {
  margin: 0 0 var(--space-4);
  color: var(--color-text-main);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
}

.result-card__details {
  border-top: 1px solid var(--color-surface-alt);
  padding-top: var(--space-3);
}

.result-card__details summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  list-style: none;
  user-select: none;
}

.result-card__details summary::-webkit-details-marker {
  display: none;
}

.result-card__details summary::after {
  content: "↓";
  font-size: 0.8rem;
  transition: transform 0.2s ease;
}

.result-card__details[open] summary::after {
  transform: rotate(180deg);
}

.result-card__detail-list {
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.result-card__detail-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--color-surface-alt);
}

.result-card__detail-list li:last-child {
  border-bottom: none;
}

.result-card__detail-list strong {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

.result-card__detail-list span {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-main);
  text-align: right;
  word-break: keep-all;
}

/* ---------- 10. Score badge ---------- */
.score-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  padding: 2px var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--color-surface-alt);
  font-size: 0.75rem;
  font-weight: 800;
}

.score-badge__value {
  font-size: 0.9rem;
}

.score-badge__suffix {
  font-weight: 500;
  opacity: 0.6;
}

.score-badge--good { background: var(--status-success-soft); color: var(--status-success); }
.score-badge--mid { background: var(--status-warning-soft); color: var(--status-warning); }
.score-badge--low { background: var(--status-danger-soft); color: var(--status-danger); }

/* ---------- 11. Lotto ball ---------- */
.lotto-ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.9rem;
  color: #fff;
  background: var(--color-text-muted);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.lotto-ball.ball-range-1 { background: var(--ball-1-10); color: #fff; }
.lotto-ball.ball-range-11 { background: var(--ball-11-20); color: #fff; }
.lotto-ball.ball-range-21 { background: var(--ball-21-30); color: #fff; }
.lotto-ball.ball-range-31 { background: var(--ball-31-40); color: #fff; }
.lotto-ball.ball-range-41 { background: var(--ball-41-45); color: #fff; }

/* Statistics view needs specific ball style */
.stat-card .lotto-ball {
  width: 32px;
  height: 32px;
  font-size: 0.85rem;
  box-shadow: none;
}

/* ---------- 12. Analyzer form ---------- */
.analyzer-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.number-inputs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}

.number-input {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.number-input label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-align: center;
}

.number-input input {
  min-height: 52px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  transition: all 0.2s ease;
  background: var(--color-surface);
}

.number-input input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-ring);
}

.analyzer-form__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.form-error {
  padding: var(--space-3);
  background: var(--status-danger-soft);
  color: var(--status-danger);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.5;
}

.analyzer-result {
  margin-top: var(--space-5);
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.form-error[hidden],
.analyzer-result[hidden] {
  display: none;
}

.analyzer-result__title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: var(--space-4);
  text-align: center;
}

.analyzer-result__balls {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.analyzer-result__metrics {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.analyzer-result__metrics li {
  display: flex;
  justify-content: space-between;
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--color-surface-alt);
  font-size: 0.85rem;
}

.analyzer-result__metrics strong {
  font-weight: 500;
  color: var(--color-text-muted);
}

.analyzer-result__metrics span {
  font-weight: 700;
}

/* ---------- 13. Stats grid (Dashboard style) ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.stat-card__count {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--color-text-main);
}

.stat-card__meta {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

/* ---------- 14. Info list & Disclaimer ---------- */
.info-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-4);
}

.info-list li {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-list strong {
  font-size: 0.95rem;
  color: var(--color-text-main);
}

.info-list span {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.disclaimer {
  padding: var(--space-6) 0;
  background: #f1f5f9;
}

.disclaimer .container {
  border-left: 4px solid var(--color-border-strong);
}

.disclaimer__title {
  font-size: 0.9rem;
  font-weight: 800;
  margin-bottom: var(--space-2);
  color: var(--color-text-main);
}

.disclaimer__body {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.6;
  margin: 0;
}

/* ---------- 15. Footer ---------- */
.site-footer {
  padding: var(--space-6) 0;
  background: #fff;
  border-top: 1px solid var(--color-border);
  text-align: center;
}

.site-footer__copy {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.site-footer__note {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  margin: 0;
}

/* ---------- 16. Responsive ---------- */

@media (min-width: 480px) {
  .hero__title { font-size: 2rem; }
  .hero__actions { flex-direction: row; justify-content: center; }
  .hero__actions .btn { width: auto; min-width: 200px; }
  .recommend-form__actions { flex-direction: row; }
  .recommend-form__actions .btn { flex: 1; }
  .analyzer-form__actions { flex-direction: row; }
  .analyzer-form__actions .btn { flex: 1; }
  .number-inputs { grid-template-columns: repeat(6, 1fr); }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 640px) {
  .hero__title { font-size: 2.5rem; }
  .section__title { font-size: 1.5rem; }
  .mode-grid { display: grid; grid-template-columns: repeat(2, 1fr); }
  .results-grid { display: grid; grid-template-columns: repeat(1, 1fr); }
  .stats-grid { grid-template-columns: repeat(6, 1fr); }
  .lotto-ball { width: 40px; height: 40px; font-size: 1rem; }
  .result-card__balls { justify-content: center; gap: var(--space-3); }
}

@media (min-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(9, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
