/* 이레가게 공통 스타일 (방문객 앱 + 역할 화면)
   값은 이 :root 한 곳에만 둔다. 출처: Figma "이레가게 UI 시안" 디자인 시스템 변수 (docs/implement-v2.md 2-2) */
:root {
  /* 색 */
  --bg: #FAF6EE;
  --surface: #FFFFFF;
  --ink: #1E2A2F;
  --ink-sub: #55646B;
  --primary: #0F5C63;
  --primary-dark: #0A4248;
  --primary-soft: #D6EBEC;
  --line: #E5DCCB;
  --accent-soft: #FDE9D9;
  --paper: #F1E8D6;
  --glass: #CFE5E8;
  --on-color: #FFFFFF;

  /* 요일 */
  --day-mon: #8B5E3C;
  --day-tue: #3D6B8E;
  --day-wed: #B8466A;
  --day-thu: #8F6414;
  --day-fri: #7A4EA3;
  --day-sat: #C4521C;
  --day-sun: #2F7556;

  /* 신호 (글자 / 배경). 항상 ●▲■ 모양 + 글자와 함께 */
  --sig-green: #2F7556;
  --sig-green-soft: #DDF0E6;
  --sig-yellow: #8F6414;
  --sig-yellow-soft: #FFF1CC;
  --sig-red: #A63A27;
  --sig-red-soft: #F8DDD7;

  /* 간격 (4 단위) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s12: 48px;

  /* 모서리 · 그림자 */
  --radius-sm: 10px;
  --radius-md: 14px;   /* 버튼·칩 */
  --radius-16: 16px;
  --radius: 20px;      /* 카드 */
  --radius-pill: 999px;
  --shadow-card: 0 4px 16px rgba(31, 41, 46, 0.10);

  /* 글자 (크기 / 줄높이) */
  --font: "Noto Sans KR", system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --fs-display: 48px; --lh-display: 56px;
  --fs-h1: 28px; --lh-h1: 36px;
  --fs-h2: 20px; --lh-h2: 28px;
  --fs-h3: 16px; --lh-h3: 24px;
  --fs-body: 15px; --lh-body: 22px;
  --fs-label: 14px; --lh-label: 20px;
  --fs-caption: 12px; --lh-caption: 18px;
  --fs-stat: 32px; --lh-stat: 38px;

  /* 움직임 (필수 7개) */
  --t-tab: 0.25s; --t-card: 0.3s; --t-map: 0.5s; --t-pin: 0.2s; --t-suggest: 0.15s; --t-sheet: 0.3s; --t-signal: 0.3s;
  --ease: 0.3s ease-in-out;

  --touch: 44px;
  --tabbar-h: 64px;

  /* 예전 이름 (관리자 화면 CSS가 쓰는 별칭) */
  --muted: var(--ink-sub);
  --main: var(--primary);
  --main-dark: var(--primary-dark);
  --main-soft: var(--primary-soft);
  --accent: var(--day-sat);          /* 따뜻한 주황 포인트. 시안에 accent 칸이 없어 토요일 색을 씀 (가정) */
  --focus: var(--primary);
  --danger-ink: var(--sig-red);
  --gap: var(--s4);
  --shadow: var(--shadow-card);
  --badge-assumed-bg: var(--sig-yellow-soft);
  --badge-assumed-ink: var(--sig-yellow);
  --fs-label-legacy: var(--fs-label);

  --day: var(--primary); /* 지금 고른 요일 색 (화면이 바꿈) */
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  background: var(--bg);
  color: var(--ink);
  word-break: keep-all;
  overflow-wrap: break-word;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--fs-h1); line-height: var(--lh-h1); font-weight: 700; }
h2 { font-size: var(--fs-h2); line-height: var(--lh-h2); font-weight: 700; }
h3 { font-size: var(--fs-h3); line-height: var(--lh-h3); font-weight: 700; display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
h1:focus { outline: none; }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.num, .stat, .tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-sub); font-size: var(--fs-label); line-height: var(--lh-label); }
.caption { color: var(--ink-sub); font-size: var(--fs-caption); line-height: var(--lh-caption); }
.t-display { font-size: var(--fs-display); line-height: var(--lh-display); font-weight: 700; }
.t-label { font-size: var(--fs-label); line-height: var(--lh-label); font-weight: 500; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.plain { margin: 0; padding: 0; list-style: none; }
.page { max-width: 1440px; margin: 0 auto; padding: var(--s4) var(--s4) var(--s12); }

/* ---------- 버튼 (primary / secondary × 기본·눌림·비활성·로딩) ---------- */
.btn, .primary {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 48px; padding: var(--s3) var(--s5);
  border-radius: var(--radius-md); border: 2px solid transparent;
  font-size: var(--fs-h3); line-height: var(--lh-h3); font-weight: 700; text-decoration: none; text-align: center;
  transition: transform 0.15s ease-out;
}
.btn:active:not(:disabled), .primary:active:not(:disabled) { transform: scale(0.98); }
.btn-primary, .primary { background: var(--primary); color: var(--on-color); }
.btn-primary:active:not(:disabled), .primary:active:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--primary); border-color: var(--primary); }
.btn-secondary:active:not(:disabled) { background: var(--primary-soft); }
.btn-ghost { background: transparent; color: var(--primary); min-height: var(--touch); padding: 0 var(--s3); font-size: var(--fs-label); }
.btn-block, .primary { width: 100%; }
.primary { margin-top: var(--s4); }
.btn:disabled, .primary:disabled { background: var(--line); border-color: var(--line); color: var(--ink-sub); cursor: default; }
.btn-sm { min-height: var(--touch); padding: 0 var(--s4); font-size: var(--fs-label); }
.link { min-height: var(--touch); padding: 0; border: 0; background: none; color: var(--primary); font-weight: 600; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 카드 · 배지 · 칩 ---------- */
.card { padding: var(--s5); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-card); }
.badge {
  display: inline-flex; align-items: center; padding: 2px 10px; border-radius: var(--radius-pill);
  font-size: var(--fs-caption); line-height: var(--lh-caption); font-weight: 500; white-space: nowrap;
  background: var(--accent-soft); color: var(--day-sat);              /* 예시 */
}
.badge-real { background: var(--sig-green-soft); color: var(--sig-green); }        /* 실데이터 */
.badge-assumed { background: var(--sig-yellow-soft); color: var(--sig-yellow); }   /* 가정 */
.badge-candidate { background: var(--primary-soft); color: var(--primary); }       /* 후보(협의 전) */
.badge-guest { background: var(--paper); color: var(--ink-sub); }                  /* 비회원 체험 */
.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s1);
  min-height: var(--touch); padding: 0 var(--s4); border-radius: var(--radius-pill);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: var(--fs-label); font-weight: 500; text-decoration: none;
}
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-color); }
.slotchip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--radius-pill); font-size: var(--fs-caption); line-height: var(--lh-caption); font-weight: 500; white-space: nowrap; }
.slot-확정 { background: var(--sig-green-soft); color: var(--sig-green); }
.slot-심사 { background: var(--sig-yellow-soft); color: var(--sig-yellow); }
.slot-모집 { background: var(--primary-soft); color: var(--primary); }

/* 신호등 배지: 색 + 모양 + 글자, 색 변화는 0.3초 */
.sig {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px;
  border: 1px solid; border-radius: var(--radius-pill);
  font-size: var(--fs-label); line-height: var(--lh-label); font-weight: 700; white-space: nowrap;
  transition: background-color var(--t-signal) ease-in-out, color var(--t-signal) ease-in-out, border-color var(--t-signal) ease-in-out;
}
.sig-green { background: var(--sig-green-soft); color: var(--sig-green); border-color: var(--sig-green); }
.sig-yellow { background: var(--sig-yellow-soft); color: var(--sig-yellow); border-color: var(--sig-yellow); }
.sig-red { background: var(--sig-red-soft); color: var(--sig-red); border-color: var(--sig-red); }

/* 정직 문구: 접지 않고 항상 보인다 */
.honesty {
  margin: var(--s2) 0 var(--s4); padding: var(--s3) var(--s4);
  border-left: 4px solid var(--day-sat); border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--ink); font-size: var(--fs-label); line-height: var(--lh-label); font-weight: 700;
}
.notice-line {
  display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s3); padding: var(--s2) var(--s3);
  border-radius: var(--radius-sm); background: var(--sig-yellow-soft); color: var(--ink); font-size: var(--fs-label);
}
.demo-auth { margin-top: calc(-1 * var(--s2)); margin-bottom: var(--s4); color: var(--ink-sub); font-size: var(--fs-label); }

/* 빈 상태 (역할·기기 안내 / 결과 없음 / 내역 없음) */
.empty { display: grid; justify-items: center; gap: var(--s3); padding: var(--s8) var(--s6); text-align: center; }
.empty-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); }
.empty h1, .empty h2 { font-size: var(--fs-h2); line-height: var(--lh-h2); }
.empty p { color: var(--ink-sub); }
.empty .btn { width: 100%; }
.empty-actions { display: grid; gap: var(--s3); width: 100%; margin-top: var(--s2); }
.errorbox { display: grid; gap: var(--s3); padding: var(--s4); border-radius: var(--radius-md); background: var(--sig-red-soft); color: var(--sig-red); font-weight: 500; }
.errorbox .btn { justify-self: start; }

/* ---------- 시연 도우미 (D1) ---------- */
.demobar { position: fixed; z-index: 30; top: calc(env(safe-area-inset-top) + var(--s3)); right: var(--s3); }
.demobar-pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--touch); padding: 0 var(--s4);
  border: 0; border-radius: var(--radius-pill); background: var(--ink); color: var(--on-color);
  font-size: var(--fs-label); font-weight: 500; box-shadow: var(--shadow-card);
}
.demobar-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-soft); }
.demobar-panel {
  display: none; position: absolute; top: calc(100% + var(--s2)); right: 0;
  width: min(360px, calc(100vw - 24px)); padding: var(--s4); border-radius: var(--radius-16);
  background: var(--surface); box-shadow: var(--shadow-card); border: 1px solid var(--line);
}
.demobar[data-open="true"] .demobar-panel { display: grid; gap: var(--s3); }
.demobar-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); }
.demobar-now { color: var(--ink-sub); font-size: var(--fs-caption); }
.demobar-label { display: block; margin-bottom: 6px; color: var(--ink-sub); font-size: var(--fs-caption); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  min-height: var(--touch); padding: 0 var(--s4); border-radius: var(--radius-pill);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: var(--fs-label);
}
.seg button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-color); }
.seg button:disabled { opacity: 0.45; cursor: default; }
.demobar-reset {
  min-height: var(--touch); padding: 0 var(--s4); border-radius: var(--radius-md);
  border: 2px solid var(--primary); background: var(--surface); color: var(--primary); font-weight: 700;
}
.demobar-close { min-height: var(--touch); border: 0; background: none; color: var(--ink-sub); }
.demobar-hint { color: var(--ink-sub); font-size: var(--fs-caption); }

/* 컴퓨터(실제 화면 폭 ≥1025): 위 전체 폭 어두운 바 */
html[data-real-device="computer"] .demobar { position: static; }
html[data-real-device="computer"] .demobar-pill,
html[data-real-device="computer"] .demobar-close,
html[data-real-device="computer"] .demobar-hint,
html[data-real-device="computer"] .demobar-title { display: none; }
html[data-real-device="computer"] .demobar-panel {
  display: flex; position: static; width: auto; align-items: center; gap: var(--s4);
  padding: var(--s2) var(--s6); border: 0; border-radius: 0; background: var(--ink); color: var(--on-color); box-shadow: none;
}
html[data-real-device="computer"] .demobar-head { flex: none; }
html[data-real-device="computer"] .demobar-now { color: var(--on-color); font-size: var(--fs-label); font-weight: 700; }
html[data-real-device="computer"] .demobar-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
html[data-real-device="computer"] .seg { padding: 4px; border-radius: var(--radius-md); background: rgba(255, 255, 255, 0.08); flex-wrap: nowrap; }
html[data-real-device="computer"] .seg button { min-height: 36px; padding: 0 var(--s3); border: 0; background: transparent; color: var(--on-color); font-size: var(--fs-caption); }
html[data-real-device="computer"] .seg button[aria-pressed="true"] { background: var(--primary-soft); color: var(--ink); }
html[data-real-device="computer"] .demobar-reset { margin-left: auto; min-height: 36px; border: 0; background: var(--accent-soft); color: var(--day-sat); font-size: var(--fs-label); border-radius: var(--radius-pill); }
html[data-real-device="computer"] .demobar-group { display: flex; align-items: center; }

/* ---------- 모달 · 토스트 ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: var(--s4);
  background: rgba(30, 42, 47, 0.45); animation: fadeIn 0.2s ease-out;
}
.modal {
  width: min(400px, 100%); display: grid; gap: var(--s4); padding: var(--s5) var(--s6) var(--s6);
  border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-card);
  animation: modalIn 0.2s ease-out;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); }
.modal-head h2 { font-size: var(--fs-h2); }
.icon-btn {
  display: inline-grid; place-items: center; width: var(--touch); height: var(--touch);
  border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--ink);
}
.modal p { color: var(--ink-sub); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--s2); }
.modal-actions .btn { min-width: 88px; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px); } }
#toast-root { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s4)); z-index: 60; transform: translateX(-50%); display: grid; gap: var(--s2); pointer-events: none; }
.toast {
  padding: 10px 18px; border-radius: var(--radius-pill); background: var(--ink); color: var(--on-color);
  font-size: var(--fs-label); white-space: nowrap; opacity: 0; transform: translateY(12px);
  transition: transform var(--ease), opacity var(--ease);
}
.toast.show { opacity: 1; transform: none; }

/* ---------- 기기 판별 (화면 폭만: 모바일 ≤600 / 패드 601~1024 / 컴퓨터 ≥1025) ---------- */
.pc-only-block { display: none; }
html[data-device="computer"] .pc-only-block { display: block; }
html[data-device="computer"] .pc-gate { display: none; }
.only-real-computer { display: none !important; }
html[data-real-device="computer"] .only-real-computer { display: inline-flex !important; }
html[data-real-device="computer"] .not-real-computer { display: none !important; }

.notfound { max-width: 520px; padding-top: var(--s12); display: grid; gap: var(--s4); }

/* 움직임 줄이기: 기기 설정 또는 더보기 스위치 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-delay: 0s !important; }
}
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after {
  transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-delay: 0s !important;
}

/* "가정" 배지 툴팁: 누르면 열림 (호버로만 열리지 않음) */
.tip-wrap { position: relative; display: inline-flex; vertical-align: middle; }
.tip { display: inline-flex; align-items: center; min-width: 44px; justify-content: center; padding: 13px 0; margin: -13px 0; border: 0; background: none; cursor: pointer; }
.tip:focus-visible { outline: none; }
.tip:focus-visible .badge { outline: 3px solid var(--primary); outline-offset: 1px; }
.tip-box {
  position: absolute; z-index: 20; top: calc(100% + 6px); width: min(280px, 78vw); padding: var(--s2) var(--s3);
  border-radius: var(--radius-sm); background: var(--ink); color: var(--on-color); box-shadow: var(--shadow-card);
  font-size: var(--fs-caption); line-height: var(--lh-caption); font-weight: 400; text-align: left; white-space: normal;
}
