@import url("./tokens.css");

* { box-sizing: border-box; }
html { scroll-behavior: smooth; overscroll-behavior-y: contain; }
:root {
  --portal-primary: var(--color-primary);
  --portal-primary-hover: var(--color-primary-dark);
  --portal-primary-soft: var(--color-primary-soft);
  --portal-accent: var(--color-accent);
  --portal-friendly: var(--color-friendly);
  --portal-ink: var(--color-text);
  --portal-muted: var(--color-muted);
  --portal-border: var(--color-line);
  --portal-surface: var(--color-surface);
  --portal-background: var(--color-bg);
  --portal-focus: rgba(37, 99, 235, .30);
  --z-map: 10;
  --z-map-control: 20;
  --z-sheet: 30;
  --z-header: 100;
  --z-skip: 1000;
}
body {
  margin: 0;
  min-height: 100vh;
  background: var(--portal-background);
  color: var(--portal-ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select, a { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--portal-focus); outline-offset: 2px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: var(--z-skip); display: inline-flex; min-height: 44px; align-items: center; padding: 10px 16px; border-radius: 10px; background: var(--portal-ink); color: #fff; font-weight: 800; text-decoration: none; transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }

.app-shell { width: min(100%, 1180px); margin: 0 auto; }
.topbar {
  display: flex; align-items: center;
  min-height: 70px; padding: max(12px, env(safe-area-inset-top)) clamp(18px, 4vw, 34px) 12px;
  border-bottom: 1px solid var(--portal-border); background: rgba(248, 250, 255, .94);
  position: sticky; top: 0; z-index: var(--z-header); backdrop-filter: blur(14px);
}
.brand { display: inline-flex; min-height: 48px; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark { display: block; width: 48px; height: 48px; object-fit: contain; }
.brand strong, .brand small { display: block; }
.brand strong { display: inline-flex; align-items: flex-start; gap: 3px; font-size: 21px; font-weight: 900; letter-spacing: -.06em; line-height: 1; }
.brand strong::after { width: 6px; height: 6px; margin-top: -1px; border-radius: 2px; background: var(--portal-accent); content: ""; transform: rotate(45deg); }
.brand small { margin-top: 4px; color: var(--portal-muted); font-size: 11px; font-weight: 700; letter-spacing: -.015em; }
.btn-icon { width: 17px; height: 17px; }
.notice { margin: 14px 18px 0; padding: 12px 14px; border: 1px solid #edc564; border-radius: 14px; background: #fff8df; color: #765514; font-size: 13px; font-weight: 700; }

.discovery { padding: 32px clamp(18px, 4vw, 34px) 22px; background: radial-gradient(circle at 92% 10%, rgba(255,216,77,.28), transparent 26%), radial-gradient(circle at 76% 90%, rgba(37,99,235,.10), transparent 32%), var(--portal-background); }
.eyebrow { display: flex; align-items: center; gap: 7px; margin: 0 0 9px; color: var(--portal-primary); font-size: 13px; font-weight: 900; letter-spacing: .035em; }
.eyebrow::before { width: 8px; height: 8px; border-radius: 2px; background: var(--portal-accent); content: ""; transform: rotate(45deg); }
h1 { margin: 0; font-size: clamp(29px, 6vw, 46px); line-height: 1.14; letter-spacing: -.055em; }
.search-box { margin-top: 24px; }
.field-label, .region-filters legend { display: block; margin: 0 0 8px; color: var(--portal-ink); font-size: 14px; font-weight: 800; }
.field-hint { margin: 8px 2px 0; color: var(--portal-muted); font-size: 13px; line-height: 1.5; }
.search-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; min-height: 56px; padding: 5px 6px 5px 16px; border: 1px solid var(--portal-border); border-radius: 18px; background: #fff; box-shadow: 0 12px 30px rgba(30,64,175,.08); transition: border-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease); }
.search-row:focus-within { border-color: var(--portal-primary); box-shadow: var(--shadow-popover), var(--focus-ring); }
.search-icon { display: inline-flex; color: var(--portal-muted); }
.search-row input { min-width: 0; min-height: 44px; border: 0; outline: 0; background: transparent; color: var(--portal-ink); font-size: 16px; }
.search-row input::placeholder { color: #8a94a4; }
.search-row button { min-height: 44px; padding: 0 19px; border: 0; border-radius: 13px; background: var(--portal-primary); color: #fff; font-weight: 800; transition: background-color var(--dur-base) var(--ease); }
.search-row button:hover { background: var(--portal-primary-hover); filter: none; }
.region-filters { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin: 18px 0 0; padding: 0; border: 0; }
.region-filters legend { grid-column: 1 / -1; width: 100%; margin-bottom: 0; }
.region-filters label > span { display: block; margin: 0 0 6px 2px; color: var(--portal-muted); font-size: 12px; font-weight: 700; }
.region-filters select, .reset-button { width: 100%; min-height: 44px; padding: 0 11px; border: 1px solid var(--portal-border); border-radius: 12px; background: rgba(255,255,255,.94); color: #465064; font-size: 14px; font-weight: 700; }
.region-filters select:disabled { opacity: .55; }
.reset-button { align-self: end; width: auto; padding: 0 14px; }

.category-tabs { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin-top: 24px; }
.category-tab { display: grid; min-width: 0; min-height: 76px; justify-items: center; align-content: start; gap: 6px; padding: 0; border: 0; background: transparent; color: var(--portal-muted); }
.category-tab strong { max-width: 100%; font-size: 12px; line-height: 1.25; text-align: center; overflow-wrap: anywhere; }
.category-icon { display: grid; width: 56px; height: 56px; place-items: center; border: 1px solid var(--portal-border); border-radius: 18px; background: #fff; color: var(--portal-muted); transition: border-color var(--dur-base) var(--ease), background-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease); }
.category-tab[data-category="all"] .category-icon { background: #f3f6fc; }
.category-tab[data-category="hospital"] .category-icon { background: #fff3f1; }
.category-tab[data-category="pharmacy"] .category-icon { background: #eef4ff; }
.category-tab[data-category="festival"] .category-icon { background: #f5f1ff; }
.category-tab[data-category="onnuri"] .category-icon { background: #fff8e7; }
.category-tab[data-category="restaurant"] .category-icon { background: #fff2ee; }
.category-icon img { display: block; width: 50px; height: 50px; object-fit: contain; }
.category-tab.is-active { color: var(--portal-ink); }
.category-tab.is-active .category-icon { border-color: var(--portal-primary); background: var(--portal-primary-soft); box-shadow: 0 7px 18px rgba(40, 104, 232, .16); }

.map-stage { position: relative; margin: 0 clamp(18px, 4vw, 34px); overflow: hidden; border: 1px solid var(--portal-border); border-radius: 24px; background: #e8edf5; box-shadow: var(--shadow-1); }
.map { width: 100%; height: min(54vh, 560px); min-height: 390px; }
.map-topline { position: absolute; z-index: var(--z-map-control); top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; gap: 8px; pointer-events: none; }
.data-badge, .map-scope-badge { padding: 7px 10px; border: 1px solid rgba(51,65,85,.16); border-radius: 999px; background: rgba(255,255,255,.94); color: #465064; font-size: 12px; font-weight: 800; box-shadow: 0 5px 14px rgba(30,41,59,.09); }
.floating-location { position: absolute; right: 14px; bottom: 16px; z-index: var(--z-map-control); display: grid; width: 44px; height: 44px; padding: 0; place-items: center; border: 0; border-radius: 0; background: transparent; color: #334155; box-shadow: none; }
.floating-location .btn-icon { width: 20px; height: 20px; filter: drop-shadow(0 1px 1px #fff) drop-shadow(0 0 2px #fff); }
.floating-location:hover { color: var(--portal-primary); }

.result-sheet { position: relative; z-index: var(--z-sheet); margin: -22px clamp(18px, 4vw, 34px) 0; padding: 22px clamp(15px, 3vw, 24px) 24px; border: 1px solid var(--portal-border); border-radius: 25px 25px 20px 20px; background: #fff; box-shadow: 0 -8px 28px rgba(30,41,59,.08); }
.result-summary { display: flex; align-items: end; justify-content: space-between; gap: 14px; padding-bottom: 13px; border-bottom: 1px solid #e8edf5; }
.result-summary p { margin: 0; color: var(--portal-muted); font-size: 14px; line-height: 1.5; }
.result-summary strong { display: block; margin-top: 2px; font-size: 21px; letter-spacing: -.03em; }
#resultHint { max-width: 210px; text-align: right; line-height: 1.4; }
.place-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding-top: 14px; }
.place-card { position: relative; min-width: 0; overflow: hidden; padding: 18px; border: 1px solid var(--portal-border); border-radius: 19px; background: linear-gradient(180deg, #fff 0%, #fff 76%, #fbfcff 100%); box-shadow: 0 4px 16px rgba(30,64,175,.035); transition: border-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease); }
.place-card::before { position: absolute; inset: 0 0 auto; height: 3px; background: var(--portal-primary); content: ""; }
.place-card:hover { border-color: #bdcbe0; box-shadow: 0 12px 28px rgba(30,64,175,.08); }
.place-card[data-category="hospital"]::before { background: #e0554e; }
.place-card[data-category="pharmacy"]::before { background: #2563eb; }
.place-card[data-category="festival"]::before { background: #8056c7; }
.place-card[data-category="onnuri"]::before { background: #b16a18; }
.place-card[data-category="restaurant"]::before { background: #f05c42; }
.card-head { display: flex; align-items: center; gap: 6px; min-height: 23px; }
.category-badge, .status-badge, .distance-chip { display: inline-flex; align-items: center; min-height: 26px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.category-badge { gap: 5px; background: #f1f5f9; color: #526074; }
.category-badge::before { width: 6px; height: 6px; flex: 0 0 auto; border-radius: 999px; background: currentColor; content: ""; }
.place-card[data-category="hospital"] .category-badge { background: #fff0ee; color: #b83f39; }
.place-card[data-category="pharmacy"] .category-badge { background: #eaf2ff; color: #1d55b4; }
.place-card[data-category="festival"] .category-badge { background: #f3eeff; color: #7042ad; }
.place-card[data-category="onnuri"] .category-badge { background: #fff5dc; color: #8b5615; }
.place-card[data-category="restaurant"] .category-badge { background: #fff0ec; color: #b63d2c; }
.status-badge { background: #edf7ef; color: #26723a; }
.status-badge[data-status="closed"], .status-badge[data-status="ended"] { background: #f2efec; color: #716b65; }
.status-badge[data-status="upcoming"] { background: #edf1ff; color: #485aa0; }
.distance-chip { margin-left: auto; background: var(--portal-primary); color: #fff; }
.place-cover { position: relative; aspect-ratio: 16 / 7; margin: 13px -18px 0; overflow: hidden; background: linear-gradient(135deg,#eee9ff,#f9f7ff); }
.place-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.place-cover img[data-remote="false"] { padding: 10px; object-fit: contain; background: radial-gradient(circle at 78% 18%,rgba(255,216,77,.52) 0 7%,transparent 8%),linear-gradient(135deg,#eee9ff,#fbfaff); }
.place-cover figcaption { position: absolute; right: 8px; bottom: 8px; max-width: calc(100% - 16px); padding: 4px 7px; border-radius: 999px; background: rgba(20,25,38,.72); color: #fff; font-size: 10px; line-height: 1.3; backdrop-filter: blur(5px); }
.place-name { margin: 13px 0 12px; font-size: 19px; line-height: 1.3; letter-spacing: -.035em; overflow-wrap: anywhere; }
.place-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin: 0 0 12px; }
.place-fact { min-width: 0; padding: 10px; border: 1px solid #e7edf7; border-radius: 12px; background: #f8faff; }
.place-fact dt { display: flex; align-items: center; gap: 5px; margin: 0; color: #667185; font-size: 11px; font-weight: 700; line-height: 1.25; }
.place-fact dt .btn-icon { width: 14px; height: 14px; flex: 0 0 auto; color: var(--portal-primary); }
.place-fact dd { margin: 6px 0 0; color: #303a4d; font-size: 13px; font-weight: 800; line-height: 1.35; overflow-wrap: anywhere; }
.place-address, .place-caveat { display: flex; align-items: flex-start; gap: 7px; margin: 7px 0 0; color: #4f5b70; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.place-address .btn-icon, .place-caveat .btn-icon { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 2px; color: #7a879b; }
.place-caveat { color: #8a5a37; }
.place-caveat .btn-icon { color: #b16a18; }
.place-source { margin: 12px 0 0; padding-top: 10px; border-top: 1px dashed #dce4f0; color: #7a8596; font-size: 11px; line-height: 1.4; }
.card-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
.card-actions a, .card-actions button, .card-actions .phone-link { display: inline-flex; min-width: 0; min-height: 44px; align-items: center; justify-content: center; gap: 5px; padding: 0 8px; border: 1px solid var(--portal-border); border-radius: 11px; background: #fff; color: #465064; font-size: 13px; font-weight: 800; text-align: center; text-decoration: none; }
.card-actions .focus-on-map { border-color: var(--portal-primary); background: var(--portal-primary); color: #fff; }
.card-actions a, .card-actions button { cursor: pointer; transition: background-color var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease), color var(--dur-base) var(--ease); }
.empty-state { grid-column: 1 / -1; display: grid; justify-items: center; gap: 9px; padding: 34px 18px; border: 1px dashed #c7d2e2; border-radius: 17px; color: var(--portal-muted); text-align: center; font-size: 14px; line-height: 1.5; }
.empty-state strong { color: #3b4658; font-size: 16px; }
.empty-reset { min-height: 44px; margin-top: 4px; padding: 0 16px; border: 1px solid var(--portal-primary); border-radius: 12px; background: #fff; color: var(--portal-primary); font-weight: 800; }
.loading-state { grid-column: 1 / -1; display: flex; min-height: 120px; align-items: center; justify-content: center; gap: 10px; color: var(--portal-muted); font-size: 14px; }
.loading-spinner { width: 22px; height: 22px; border: 3px solid #dce4f0; border-top-color: var(--portal-primary); border-radius: 999px; animation: loading-spin .8s linear infinite; }
@keyframes loading-spin { to { transform: rotate(360deg); } }
.pagination { display: grid; grid-template-columns: 72px 1fr 72px; align-items: center; gap: 10px; margin-top: 16px; }
.pagination button { min-height: 44px; border: 1px solid var(--portal-border); border-radius: 11px; background: #fff; font-weight: 800; }
.pagination button:disabled { opacity: .4; }
.pagination span { text-align: center; color: var(--portal-muted); font-size: 14px; font-weight: 800; }

.user-location-marker { position: relative; width: 68px; height: 68px; pointer-events: none; }
.user-location-marker__pulse { position: absolute; inset: 0; border-radius: 999px; background: rgba(40,104,232,.15); animation: pulse 2.4s ease infinite; }
.user-location-marker__guide { position: absolute; inset: 5px; display: block; width: 58px; height: 58px; object-fit: contain; filter: drop-shadow(0 5px 8px rgba(30,64,175,.26)); }
@keyframes pulse { 0% { opacity: .9; transform: scale(.4); } 75%,100% { opacity: 0; transform: scale(1); } }
.kakao-info-window { position: relative; width: min(310px, calc(100vw - 34px)); overflow: hidden; border: 1px solid #d8e2f0; border-radius: 19px; background: linear-gradient(180deg,#fff 0%,#fbfcff 100%); color: var(--portal-ink); box-shadow: 0 18px 44px rgba(30,64,175,.2); font-family: var(--font-sans); line-height: 1.4; }
.kakao-info-window::before { position: absolute; inset: 0 0 auto; height: 3px; background: var(--portal-primary); content: ""; }
.kakao-info-window[data-category="hospital"]::before { background: #e0554e; }
.kakao-info-window[data-category="festival"]::before { background: #8056c7; }
.kakao-info-window[data-category="onnuri"]::before { background: #b16a18; }
.kakao-info-window[data-category="restaurant"]::before { background: #f05c42; }
.kakao-info-body { padding: 18px; }
.kakao-info-cover { position: relative; aspect-ratio: 16 / 7; margin: 0; overflow: hidden; background: #f3efff; }
.kakao-info-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.kakao-info-cover img[data-remote="false"] { padding: 8px; object-fit: contain; background: radial-gradient(circle at 78% 18%,rgba(255,216,77,.52) 0 7%,transparent 8%),linear-gradient(135deg,#eee9ff,#fbfaff); }
.kakao-info-cover figcaption { position: absolute; right: 7px; bottom: 7px; max-width: calc(100% - 14px); padding: 3px 6px; border-radius: 999px; background: rgba(20,25,38,.72); color: #fff; font-size: 9px; backdrop-filter: blur(5px); }
.kakao-info-badges { display: flex; align-items: center; gap: 6px; min-height: 26px; padding-right: 34px; }
.kakao-info-category, .kakao-info-status { display: inline-flex; min-height: 24px; align-items: center; padding: 0 8px; border-radius: 999px; background: #eef4ff; color: #315da8; font-size: 11px; font-weight: 800; }
.kakao-info-status { background: #edf7ef; color: #26723a; }
.kakao-info-status[data-status="closed"], .kakao-info-status[data-status="ended"] { background: #f2efec; color: #716b65; }
.kakao-info-title { display: block; margin-top: 9px; padding-right: 30px; font-size: 18px; line-height: 1.3; letter-spacing: -.03em; }
.kakao-info-facts { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; margin-top: 12px; }
.kakao-info-fact { display: flex; min-width: 0; align-items: flex-start; gap: 6px; padding: 9px; border: 1px solid #e7edf7; border-radius: 11px; background: #f8faff; color: #344056; font-size: 12px; font-weight: 800; }
.kakao-info-fact .btn-icon { flex: 0 0 auto; color: var(--portal-primary); }
.kakao-info-fact small { display: block; margin-bottom: 2px; color: #778297; font-size: 10px; font-weight: 700; }
.kakao-info-window[data-category="festival"] .kakao-info-facts { grid-template-columns: 1fr; gap: 0; overflow: hidden; border: 1px solid #e7edf7; border-radius: 11px; background: #f8faff; }
.kakao-info-window[data-category="festival"] .kakao-info-fact { display: grid; grid-template-columns: 16px minmax(0, 1fr); align-items: center; border: 0; border-radius: 0; background: transparent; font-size: 13px; line-height: 1.45; }
.kakao-info-window[data-category="festival"] .kakao-info-fact + .kakao-info-fact { border-top: 1px solid #e7edf7; }
.kakao-info-address { display: flex; align-items: flex-start; gap: 6px; margin-top: 11px; color: #556176; font-size: 12px; line-height: 1.45; }
.kakao-info-address .btn-icon { flex: 0 0 auto; margin-top: 1px; color: #7a879b; }
.kakao-info-source { margin-top: 8px; color: #8993a3; font-size: 11px; line-height: 1.35; }
.kakao-info-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 13px; }
.kakao-info-link { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: 5px; border: 1px solid #dce4f0; border-radius: 11px; color: #465064; font-size: 13px; font-weight: 900; text-decoration: none; }
.kakao-info-link.is-primary { border-color: var(--portal-primary); background: var(--portal-primary); color: #fff; }
.kakao-info-close { position: absolute; top: 5px; right: 5px; z-index: 2; width: 44px; height: 44px; border: 0; border-radius: 999px; background: rgba(255,255,255,.88); color: #5f5953; font-size: 20px; box-shadow: 0 4px 12px rgba(30,41,59,.1); }

.site-footer { display: flex; align-items: center; gap: 14px; padding: 24px clamp(18px, 4vw, 34px) max(32px, env(safe-area-inset-bottom)); color: var(--portal-muted); font-size: 13px; line-height: 1.5; }
.site-footer strong { color: var(--portal-ink); font-size: 15px; }
.site-footer p { margin: 0; flex: 1; }
.site-footer a { display: inline-flex; min-height: 44px; align-items: center; color: var(--portal-primary); font-weight: 800; }

button:hover, a:hover { filter: brightness(.97); }
button:active, a:active { filter: brightness(.9); }
button:disabled, select:disabled { cursor: not-allowed; }

@media (max-width: 640px) {
  .topbar { min-height: 62px; }
  .discovery { padding-top: 24px; }
  .region-filters { grid-template-columns: 1fr 1fr auto; }
  .map-stage { margin-inline: 0; border-left: 0; border-right: 0; border-radius: 0; }
  .map { height: 49vh; min-height: 350px; }
  .result-sheet { margin-inline: 0; border-left: 0; border-right: 0; border-bottom: 0; border-radius: 25px 25px 0 0; }
  .place-list { grid-template-columns: 1fr; }
  .place-card[data-category="festival"] .place-facts { grid-template-columns: 1fr; gap: 0; overflow: hidden; border: 1px solid #e7edf7; border-radius: 14px; background: #f8faff; }
  .place-card[data-category="festival"] .place-fact { display: grid; grid-template-columns: minmax(80px, .6fr) minmax(0, 1.4fr); align-items: center; gap: 12px; padding: 11px 13px; border: 0; border-radius: 0; background: transparent; }
  .place-card[data-category="festival"] .place-fact + .place-fact { border-top: 1px solid #e7edf7; }
  .place-card[data-category="festival"] .place-fact dt { font-size: 13px; }
  .place-card[data-category="festival"] .place-fact dd { margin: 0; font-size: 16px; line-height: 1.45; }
  #resultHint { max-width: 145px; }
  .site-footer { align-items: flex-start; flex-wrap: wrap; }
  .site-footer p { flex-basis: 70%; }
}

@media (max-width: 390px) {
  .discovery { padding-inline: 16px; }
  .category-tabs { gap: 4px; }
  .category-icon { width: 50px; height: 50px; border-radius: 16px; }
  .category-icon img { width: 45px; height: 45px; }
  .category-tab { min-height: 74px; }
  .category-tab strong { font-size: 11px; }
  .map-scope-badge { display: none; }
}

@media (max-width: 340px) {
  .region-filters { grid-template-columns: 1fr 1fr; }
  .reset-button { grid-column: 1 / -1; width: 100%; }
  .card-actions { grid-template-columns: 1fr; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .topbar { position: static; }
  .discovery { padding-top: 20px; }
  .map { height: 72vh; min-height: 280px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
