/* ======================================================
   Task 8: Design tokens, base, login
   ====================================================== */
:root {
  --bg: #FAFAF8; --surface: #FFFFFF; --text: #1A1A1A; --muted: #6E7378;
  --border: #E7E7E4; --accent: #2B62B8; --accent-press: #234F94;
  --unvisited: #9AA0A6; --favorite: #E8A317; --visited: #1E9E6A;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  font-family: Pretendard, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
button { font-family: inherit; cursor: pointer; }
.btn { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 10px 14px; font-weight: 600; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:active { background: var(--accent-press); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login .card { width: min(360px, 100%); padding: 28px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }
.login p { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.login input { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 16px; }
.login .btn-primary { width: 100%; margin-top: 12px; padding: 12px; }
.login .err { color: #C0392B; font-size: 13px; margin-top: 10px; min-height: 16px; }

/* ======================================================
   Task 9: Home screen and modal styles
   ====================================================== */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; }
.brand { font-weight: 700; font-size: 17px; }
.home { padding: 18px; max-width: 980px; margin: 0 auto; }
.grp { font-size: 14px; color: var(--muted); margin: 22px 4px 10px; }
.fair-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.fair-card { text-align: left; padding: 16px; display: grid; gap: 6px; }
.fc-name { font-weight: 700; font-size: 16px; }
.fc-prog { font-size: 14px; }
.muted { color: var(--muted); }
.empty { padding: 28px; text-align: center; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; padding: 16px; z-index: 50; }
.sheet { width: min(440px, 100%); padding: 20px; max-height: 90vh; overflow: auto; }
.sheet label { display: block; font-size: 13px; color: var(--muted); margin-top: 12px; }
.sheet input, .sheet textarea { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px; margin-top: 4px; }
.sheet .row { display: flex; gap: 10px; } .sheet .row label { flex: 1; }
.sheet .actions { display: flex; gap: 8px; align-items: center; margin-top: 18px; }

/* ======================================================
   Task 10: Fair map, pin controls, zoom/fab styles
   ====================================================== */
.fair-bar { gap: 10px; } .fair-bar .brand { flex: 1; text-align: center; }
.fair-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.seg { margin-left: auto; display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 14px; font-weight: 600; }
.seg button.on { background: var(--accent); color: #fff; }
.stagewrap { position: relative; overflow: hidden; height: calc(100dvh - 116px); background: #F0F0EC; touch-action: none; display: grid; place-items: center; }
/* The stage is sized in JS to the image's contain-fit box, so pins (anchored
   to the stage at left:x% top:y%) stay on the image content across any viewport. */
.stage { position: relative; transform-origin: center center; }
.stage img { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.pins { position: absolute; inset: 0; pointer-events: none; }
.pin { position: absolute; transform: translate(-50%, -50%); pointer-events: auto; border: 0; background: transparent; display: grid; justify-items: center; gap: 2px; }
.pin .dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); border: 2px solid #fff; }
.pin.unvisited .dot { background: var(--unvisited); }
.pin.favorite .dot { background: var(--favorite); }
.pin.visited .dot { background: var(--visited); }
.pin .plabel { font-size: 11px; background: rgba(255,255,255,.92); border-radius: 6px; padding: 1px 5px; white-space: nowrap; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.zoombar { position: fixed; right: 14px; bottom: 84px; display: grid; gap: 6px; }
.zoombar button { min-width: 40px; height: 40px; padding: 0 9px; white-space: nowrap; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-size: 15px; box-shadow: var(--shadow); }
.fab { position: fixed; right: 14px; bottom: 18px; border: 0; background: var(--accent); color: #fff; border-radius: 999px; padding: 14px 20px; font-weight: 700; box-shadow: var(--shadow); }
.fab.on { background: var(--accent-press); }
.sheet-bottom { align-items: end; } .sheet-bottom .sheet { width: min(520px, 100%); border-radius: var(--radius) var(--radius) 0 0; }
.toggles { display: flex; gap: 8px; margin-top: 12px; }
.toggle { flex: 1; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 12px; font-weight: 600; }
.toggle.on.fav { background: var(--favorite); color: #fff; border-color: var(--favorite); }
.toggle.on.vis { background: var(--visited); color: #fff; border-color: var(--visited); }

/* ======================================================
   Task 11: List view styles
   ====================================================== */
.listpane { width: 100%; height: 100%; place-self: stretch; overflow: auto; padding: 14px 16px; background: var(--bg); }
.search { width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 15px; background: var(--surface); }
.pinlist { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.pinrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; cursor: pointer; }
.pr-name { font-weight: 600; } .pr-status { white-space: nowrap; font-size: 14px; }

/* Transient toast (global error / session messages) */
#toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(8px); background: #1A1A1A; color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: 90vw; text-align: center; }
#toast.show { opacity: .96; transform: translateX(-50%) translateY(0); }

/* ======================================================
   Task 13: Responsive breakpoints
   ====================================================== */
@media (max-width: 760px) {
  .fair-controls { gap: 8px; }
  .seg { margin-left: 0; }
  .chips { order: 3; width: 100%; overflow-x: auto; }
  .stagewrap { height: calc(100dvh - 150px); }
  .home { padding: 14px; }
}
@media (min-width: 1100px) {
  /* desktop: show list beside map when in list view is handled by view toggle;
     keep the map centered with a max width for very wide screens */
  .stagewrap { max-width: 100%; }
}
