/* 워독스 서버 탐색기 — 야전 서류철 톤 */

:root {
  --paper: #E8ECE3;
  --surface: #F6F8F2;
  --ink: #1C221B;
  --muted: #596254;
  --line: #C6CDBD;
  --olive: #4A5832;
  --olive-soft: #DAE2CC;
  --olive-ink: #35411E;
  --signal: #C25E17;
  --signal-soft: #F4DDC9;
  --signal-ink: #843B07;
  --bar: #D3DACA;
  --live: #2F6E39;
  --shadow: 0 1px 0 rgba(28, 34, 27, 0.06), 0 2px 8px rgba(28, 34, 27, 0.05);

  --font-display: 'Barlow Condensed', 'IBM Plex Sans KR', 'Apple SD Gothic Neo', sans-serif;
  --font-body: 'IBM Plex Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK KR', 'Noto Sans CJK SC', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  --radius: 6px;
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121712;
    --surface: #1A201A;
    --ink: #E2E7DC;
    --muted: #9AA492;
    --line: #323C31;
    --olive: #A9BD84;
    --olive-soft: #263020;
    --olive-ink: #C8D8A8;
    --signal: #EE9550;
    --signal-soft: #3B2918;
    --signal-ink: #F7BA88;
    --bar: #2A3229;
    --live: #7DC78A;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #121712;
  --surface: #1A201A;
  --ink: #E2E7DC;
  --muted: #9AA492;
  --line: #323C31;
  --olive: #A9BD84;
  --olive-soft: #263020;
  --olive-ink: #C8D8A8;
  --signal: #EE9550;
  --signal-soft: #3B2918;
  --signal-ink: #F7BA88;
  --bar: #2A3229;
  --live: #7DC78A;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--olive-ink); text-underline-offset: 2px; }
a:hover { color: var(--signal-ink); }

button, input, select { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
  border-radius: 3px;
}

.wrap {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.skip {
  position: absolute;
  left: 8px;
  top: -48px;
  padding: 8px 12px;
  background: var(--ink);
  color: var(--paper);
  z-index: 50;
  border-radius: var(--radius);
}
.skip:focus { top: 8px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- 머리글 ---------- */

.masthead {
  border-top: 6px solid var(--olive);
  padding: 22px 0 18px;
}

.masthead .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px 24px;
}

.eyebrow {
  margin: 0 0 2px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--olive);
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(30px, 6vw, 42px);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.lede {
  margin: 8px 0 0;
  max-width: 34em;
  color: var(--muted);
}

.status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  font-size: 14px;
  color: var(--muted);
}

.status-text {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-variant-numeric: tabular-nums;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 var(--live);
  animation: pulse 2.4s ease-out infinite;
  flex: none;
}
.status[data-state="loading"] .live-dot { background: var(--muted); animation: none; }
.status[data-state="warn"] .live-dot { background: var(--signal); animation: none; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 55%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s;
}
.btn:hover { border-color: var(--olive); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn--primary { background: var(--olive); border-color: var(--olive); color: var(--surface); }
.btn--primary:hover { background: var(--olive-ink); border-color: var(--olive-ink); }

.icon {
  width: 15px;
  height: 15px;
  flex: none;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.icon--refresh { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 11a8 8 0 1 0-2.3 5.7'/%3E%3Cpath d='M20 4v7h-7'/%3E%3C/svg%3E"); }
.icon--theme { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 1 0 0 20V2z' fill='black'/%3E%3Ccircle cx='12' cy='12' r='9' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E"); }
.icon--lock { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10V7a5 5 0 0 1 10 0v3' fill='none' stroke='black' stroke-width='2.4'/%3E%3Crect x='4' y='10' width='16' height='12' rx='2' fill='black'/%3E%3C/svg%3E"); width: 12px; height: 12px; }

.spinning .icon--refresh { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 알림 띠 ---------- */

.banner {
  margin: 0 0 12px;
}
.banner p {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--signal);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--signal-soft);
  color: var(--signal-ink);
  font-size: 14px;
}

/* ---------- 필터 바 ---------- */

.filters {
  background: var(--paper);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  margin-bottom: 14px;
}

@media (min-width: 860px) {
  .filters { position: sticky; top: 0; z-index: 10; box-shadow: 0 6px 12px -10px rgba(0, 0, 0, 0.35); }
}

.filters .wrap { display: grid; gap: 10px; }

.views {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.view-btn {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
}
.view-btn:hover { border-color: var(--olive); }
.view-btn[aria-pressed="true"] {
  background: var(--olive);
  border-color: var(--olive);
  color: var(--surface);
}
.view-btn .n {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 13px;
  color: var(--muted);
}
.view-btn[aria-pressed="true"] .n { color: var(--olive-soft); }

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 28px;
}

.search {
  position: relative;
  flex: 1 1 260px;
  min-width: 0;
}
.search input {
  width: 100%;
  min-height: 38px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.search input::placeholder { color: var(--muted); opacity: 0.85; }

.filter-toggle { display: none; }

.panel {
  display: grid;
  gap: 10px;
}

.group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.group > legend, .group-label {
  float: left;
  margin-right: 2px;
  padding: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  min-width: 44px;
}

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.seg button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 4px 12px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--olive-soft); color: var(--olive-ink); font-weight: 600; }

/* 한국 기준 핑: 막대가 많을수록 낮음 */
.ping {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 11px;
  color: var(--olive);
}
.ping i {
  display: block;
  width: 3px;
  border-radius: 1px;
  background: currentColor;
  opacity: 0.22;
}
.ping i:nth-child(1) { height: 4px; }
.ping i:nth-child(2) { height: 7px; }
.ping i:nth-child(3) { height: 11px; }
.ping[data-level="3"] i,
.ping[data-level="2"] i:nth-child(-n+2),
.ping[data-level="1"] i:nth-child(1) { opacity: 1; }
.ping[data-level="1"] { color: var(--signal); }

.filter-row--split { justify-content: space-between; }

.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 3px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  user-select: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.toggle:hover { border-color: var(--olive); color: var(--ink); }
.toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}
.toggle.is-on::before {
  content: "";
  width: 9px;
  height: 9px;
  background: currentColor;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
.toggle.is-on { background: var(--olive-soft); border-color: var(--olive); color: var(--olive-ink); font-weight: 600; }
.toggle--sniper.is-on { background: var(--signal-soft); border-color: var(--signal); color: var(--signal-ink); }
.toggle:has(input:focus-visible) { outline: 2px solid var(--signal); outline-offset: 2px; }

.sort select {
  min-height: 34px;
  padding: 4px 30px 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23596254' stroke-width='1.6'/%3E%3C/svg%3E") right 10px center / 11px no-repeat;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

@media (max-width: 719px) {
  .filter-toggle { display: inline-flex; }
  .panel[data-open="false"] { display: none; }
  .group > legend, .group-label { float: none; width: 100%; }
}

/* ---------- 목록 ---------- */

.summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--muted);
}
.summary strong { color: var(--ink); font-family: var(--font-mono); font-weight: 500; }

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.server {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  grid-template-areas:
    "pop  body fav"
    "join join join";
  gap: 8px 14px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.server.is-fav { border-left: 4px solid var(--signal); padding-left: 11px; }

@media (max-width: 599px) {
  .server {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "pop  fav"
      "body body"
      "join join";
    gap: 6px 10px;
  }
  .server .pop { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
  .server .pop .bar { flex: 1 1 64px; min-width: 64px; max-width: 160px; }
  .theme-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

@media (min-width: 860px) {
  .server {
    grid-template-columns: 104px minmax(0, 1fr) 384px 36px;
    grid-template-areas: "pop body join fav";
    align-items: start;
    padding: 14px 16px;
  }
  .server.is-fav { padding-left: 13px; }
  .server .sid { font-size: 12px; white-space: nowrap; overflow-wrap: normal; word-break: normal; }
}

.pop { grid-area: pop; display: grid; gap: 5px; align-content: start; }
.count {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.count b { font-size: 20px; font-weight: 500; color: var(--ink); }
.bar {
  height: 6px;
  border-radius: 3px;
  background: var(--bar);
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  width: calc(var(--fill, 0) * 1%);
  background: var(--olive);
  border-radius: 3px;
}
.server.is-full .bar i { background: var(--signal); }
.region {
  justify-self: start;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}
.full-badge {
  justify-self: start;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--signal-ink);
}

.body { grid-area: body; min-width: 0; }
.name {
  margin: 0;
  font-weight: 600;
  font-size: 15.5px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.name:lang(zh), .name:lang(ja), .name:lang(en) { word-break: normal; }
.ko { margin: 3px 0 0; color: var(--ink); font-size: 14.5px; }
.note { margin: 3px 0 0; color: var(--muted); font-size: 13.5px; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink);
  white-space: nowrap;
}
.chip--sniper { background: var(--signal-soft); border-color: var(--signal-soft); color: var(--signal-ink); font-weight: 600; }
.chip--infrule { border-color: var(--olive); color: var(--olive-ink); font-weight: 600; }
.chip--armed, .chip--heli { background: var(--olive-soft); border-color: var(--olive-soft); color: var(--olive-ink); }
.chip--level { border-color: var(--signal); color: var(--signal-ink); }
.chip--lock { color: var(--muted); }
.chip--auto { border-style: dashed; color: var(--muted); }

.join {
  grid-area: join;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.sid {
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 8px;
  border: 1px dashed var(--line);
  border-radius: 4px;
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--ink);
  user-select: all;
  -webkit-user-select: all;
  overflow-wrap: anywhere;
  word-break: break-all;
  cursor: text;
}
.copy { flex: none; min-width: 76px; }
.copy[data-state="copied"] { background: var(--live); border-color: var(--live); color: var(--surface); }
.copy[data-state="selected"] { background: var(--signal-soft); border-color: var(--signal); color: var(--signal-ink); }

.fav {
  grid-area: fav;
  align-self: start;
  justify-self: end;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}
.fav:hover { border-color: var(--line); color: var(--signal); }
.fav[aria-pressed="true"] { color: var(--signal); }

/* 스켈레톤 */
.server--skeleton { pointer-events: none; }
.sk {
  display: block;
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--bar) 25%, var(--paper) 50%, var(--bar) 75%);
  background-size: 300% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.sk + .sk { margin-top: 8px; }
.sk--w40 { width: 40%; } .sk--w60 { width: 60%; } .sk--w80 { width: 80%; } .sk--big { height: 20px; width: 56px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

.empty {
  padding: 28px 18px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}
.empty p { margin: 0 0 12px; }

/* ---------- 안내 ---------- */

.guide {
  display: grid;
  gap: 14px;
  margin-top: 36px;
}
@media (min-width: 860px) { .guide { grid-template-columns: 1fr 1fr; } }

.card {
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card h2 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  line-height: 1.2;
}
.steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.steps li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}
.steps li + li::before { content: "→"; color: var(--muted); margin-right: 2px; }
.steps kbd {
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--paper);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.04em;
}
.card ul { margin: 0; padding-left: 1.1em; }
.card li + li { margin-top: 6px; }
.card .hint { margin: 10px 0 0; font-size: 13.5px; color: var(--muted); }

/* ---------- 바닥글 ---------- */

.footer {
  margin-top: 36px;
  padding: 18px 0 32px;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--muted);
}
.footer p { margin: 0 0 4px; }

/* ---------- 알림 토스트 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 9px 14px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  z-index: 40;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .live-dot { animation: none; }
}
