/* MATE X 호환 기기 확인 페이지 */

:root {
  --bg: #f6f6fb;
  --surface: #ffffff;
  --surface-2: #fafaff;
  --line: #eceaf4;
  --line-2: #e2e0ee;
  --text: #1b1b2f;
  --text-2: #61617d;
  --text-3: #9a9ab4;

  --accent: #6d28d9;
  --accent-soft: #f1ebfe;

  --ok-fg: #0b7a4b;   --ok-bg: #e2f8ee;   --ok-line: #b6e6cf;
  --soon-fg: #1454c8; --soon-bg: #e8f0ff; --soon-line: #bcd5ff;
  --tbd-fg: #5f6470;  --tbd-bg: #eef0f4;  --tbd-line: #dadee6;
  --no-fg: #c3253c;   --no-bg: #ffe9ec;   --no-line: #f8c6ce;
  --warn-fg: #9a6100; --warn-bg: #fff3dc; --warn-line: #f4dca8;

  --radius: 16px;
  --shadow: 0 1px 2px rgba(27, 27, 47, .04), 0 8px 24px -16px rgba(27, 27, 47, .18);
  --side-w: 216px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1013;
    --surface: #171a20;
    --surface-2: #1c1f26;
    --line: #262a33;
    --line-2: #333846;
    --text: #eef1f5;
    --text-2: #a3aab6;
    --text-3: #767d8a;

    --accent: #a78bfa;
    --accent-soft: #241c3d;

    --ok-fg: #63d9a3;   --ok-bg: #10291f;   --ok-line: #1e5540;
    --soon-fg: #86b4ff; --soon-bg: #141f36; --soon-line: #274476;
    --tbd-fg: #a8b0be;  --tbd-bg: #22262d;  --tbd-line: #39404c;
    --no-fg: #ff8f9d;   --no-bg: #2d1519;   --no-line: #662c35;
    --warn-fg: #e8b45c; --warn-bg: #2a2113; --warn-line: #5c4520;

    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -16px rgba(0, 0, 0, .8);
  }
}

* { box-sizing: border-box; }

/* display 를 지정한 요소는 hidden 속성만으로 숨겨지지 않는다. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
               "Noto Sans KR", "Malgun Gothic", "맑은 고딕", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}

.shell {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* --------------------------------------------------------------- 사이드바 */

.side {
  padding: 22px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.side__top { margin-bottom: 22px; }
.side__logo {
  padding: 0 10px;
  margin-bottom: 12px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--accent);
}

/* 언어 선택 */
.lang {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--bg);
  border-radius: 9px;
}
.lang__btn {
  flex: 1;
  padding: 5px 4px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text-3);
  background: none;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}
.lang__btn:hover { color: var(--text); }
.lang__btn[aria-pressed="true"] {
  color: var(--accent);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.side__label {
  margin: 0 0 8px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--text-3);
}
.side__nav { display: grid; gap: 2px; }

.navitem {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  color: var(--text-2);
  background: none;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}
.navitem:hover { background: var(--bg); color: var(--text); }
.navitem[aria-selected="true"] {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 6px 16px -8px var(--accent);
}
@media (prefers-color-scheme: dark) {
  .navitem[aria-selected="true"] { color: #14101f; }
}
.navitem__count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  opacity: .75;
}

.side__foot {
  margin: 22px 10px 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text-3);
}

/* ------------------------------------------------------------------ 본문 */

.main {
  min-width: 0;
  padding: 24px 26px max(28px, env(safe-area-inset-bottom));
}

.head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}
.head h1 {
  margin: 0;
  font-size: clamp(21px, 3.4vw, 26px);
  font-weight: 800;
  letter-spacing: -.02em;
}
.head__brand { color: var(--accent); }
.lede { margin: 4px 0 0; font-size: 13.5px; color: var(--text-2); }

.search { position: relative; display: flex; align-items: center; min-width: 220px; }
.search__icon {
  position: absolute; left: 13px; width: 17px; height: 17px;
  fill: none; stroke: var(--text-3); stroke-width: 2; stroke-linecap: round;
  pointer-events: none;
}
#q {
  width: 100%;
  height: 34px;
  padding: 0 34px;
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  appearance: none;
}
#q::placeholder { color: var(--text-3); }
#q:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#q::-webkit-search-cancel-button { display: none; }
.search__clear {
  position: absolute; right: 8px;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  font-size: 19px; line-height: 1;
  color: var(--text-3);
  background: none; border: 0; border-radius: 50%; cursor: pointer;
}
.search__clear:hover { background: var(--bg); color: var(--text); }

/* 상태 타일 */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  font: inherit;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.stat:hover { border-color: var(--accent); background: var(--surface-2); }
.stat:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.stat__dot {
  flex: none;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 800; line-height: 1;
  border-radius: 50%;
}

/* 이름과 숫자는 세로로 쌓는다. 한 줄에 붙으면 '지원24' 처럼 읽힌다. */
.stat__text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }

/* 누를 수 있다는 표시. 켜지면 채워진다. */
.stat__check {
  flex: none;
  margin-left: auto;
  width: 16px; height: 16px;
  display: grid; place-items: center;
  border: 1.5px solid var(--line-2);
  border-radius: 5px;
}
.stat__check::after {
  content: '✓';
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  color: transparent;
}
.stat[aria-pressed="true"] .stat__check {
  background: var(--accent);
  border-color: var(--accent);
}
.stat[aria-pressed="true"] .stat__check::after { color: #fff; }
@media (prefers-color-scheme: dark) {
  .stat[aria-pressed="true"] .stat__check::after { color: #14101f; }
}
.stat--ok   .stat__dot { color: var(--ok-fg);   background: var(--ok-bg); }
.stat--soon .stat__dot { color: var(--soon-fg); background: var(--soon-bg); }
.stat--tbd  .stat__dot { color: var(--tbd-fg);  background: var(--tbd-bg); }
.stat--no   .stat__dot { color: var(--no-fg);   background: var(--no-bg); }

.stat__label { font-size: 11.5px; line-height: 1.3; color: var(--text-2); }
.stat__value { font-size: 18px; font-weight: 800; line-height: 1.15; letter-spacing: -.02em; }
.stat[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* 목록 패널 */
.panel {
  padding: 18px 20px 8px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel__head {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 14px;
}
.panel__head h2 { margin: 0; font-size: 16px; font-weight: 750; letter-spacing: -.01em; }
.panel__count { font-size: 12.5px; color: var(--text-3); }

/* 배율·상태 칸은 max-content 로 둔다. 고정 폭을 주면 'Not supported' 같은
   긴 번역이 넘치거나, 반대로 화면이 좁을 때 기기명 칸을 눌러 잘리게 만든다.
   남는 자리는 전부 기기명이 가져간다. */
.thead, .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px max-content max-content;
  align-items: center;
  gap: 12px;
}
.thead {
  padding: 0 8px 8px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--text-3);
  border-bottom: 1px solid var(--line);
}
.thead__status, .row__status { text-align: right; }

.list { display: block; }

.group {
  padding: 14px 8px 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--accent);
}
.group:first-child { padding-top: 8px; }

.row {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
/* 모델명은 한 줄을 보장한다. 넘치면 줄바꿈 대신 말줄임으로 처리한다. */
.row__name { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.row__label {
  display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row__year, .row__cam { font-size: 12.5px; color: var(--text-2); }
.row__cam { white-space: nowrap; font-variant-numeric: tabular-nums; }
.row__cam .sep { margin: 0 4px; font-style: normal; color: var(--text-3); }

.badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  border-radius: 999px;
  border: 1px solid transparent;
}
.badge--ok   { color: var(--ok-fg);   background: var(--ok-bg);   border-color: var(--ok-line); }
.badge--soon { color: var(--soon-fg); background: var(--soon-bg); border-color: var(--soon-line); }
.badge--tbd  { color: var(--tbd-fg);  background: var(--tbd-bg);  border-color: var(--tbd-line); }
.badge--no   { color: var(--no-fg);   background: var(--no-bg);   border-color: var(--no-line); }
.badge__eta {
  display: block; margin-top: 1px;
  font-size: 10.5px; font-weight: 600; opacity: .85;
}

mark { padding: 0 1px; color: inherit; background: var(--accent-soft); border-radius: 3px; }

/* --------------------------------------------------- 상태 메시지 · 안내 */

.state { padding: 40px 16px; text-align: center; }
.state--row {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--text-3); font-size: 13.5px;
}
.state__title { margin: 0; font-weight: 650; }
.state__sub { margin: 6px 0 16px; font-size: 13.5px; color: var(--text-2); }

.spinner {
  width: 15px; height: 15px;
  border: 2px solid var(--line-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

.notice {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  margin: 0 0 16px;
  padding: 12px 15px;
  font-size: 13px;
  border-radius: 12px;
  border: 1px solid transparent;
}
.notice--warn  { color: var(--warn-fg); background: var(--warn-bg); border-color: var(--warn-line); }
.notice--error { color: var(--no-fg);   background: var(--no-bg);   border-color: var(--no-line); }
.notice strong { font-weight: 700; }

.btn {
  padding: 8px 15px;
  font: inherit; font-size: 13.5px; font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 10px;
  cursor: pointer;
}
@media (prefers-color-scheme: dark) { .btn { color: #14101f; } }
.btn--sm { padding: 6px 12px; font-size: 12.5px; }
.btn--ghost { color: var(--text-2); background: none; border-color: var(--line-2); }

.legend {
  margin-top: 16px;
  padding: 18px 20px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.legend h2 { margin: 0 0 12px; font-size: 13.5px; font-weight: 750; }
.legend dl { display: grid; gap: 9px; margin: 0; }
.legend dl > div { display: flex; align-items: center; gap: 12px; }
.legend dt { flex: none; width: 58px; }
.legend dd { margin: 0; font-size: 13px; color: var(--text-2); }

.foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 0 4px;
}
.foot__meta { margin: 0; font-size: 12px; color: var(--text-3); }

/* ------------------------------------------------------------- 좁은 화면 */

/* 태블릿 폭. 사이드바를 줄이지 않으면 본문이 좁아 기기명이 잘린다. */
@media (min-width: 721px) and (max-width: 980px) {
  :root { --side-w: 176px; }
  .main { padding: 20px 18px 28px; }
  .panel { padding: 16px 14px 8px; }
  .thead, .row { gap: 10px; }
}

@media (max-width: 720px) {
  .shell { grid-template-columns: minmax(0, 1fr); }

  /* 사이드바는 위쪽 가로 막대로 바뀐다 */
  .side {
    position: sticky; top: 0; z-index: 5;
    padding: 12px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  /* 좁은 화면에서는 로고와 언어 선택을 한 줄에 나란히 둔다. */
  .side__top {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    margin-bottom: 10px;
  }
  .side__logo { margin-bottom: 0; font-size: 15px; }
  .lang { flex: none; }
  .lang__btn { flex: none; padding: 5px 8px; }
  .side__label, .side__foot { display: none; }
  /* 가로 스크롤로 두면 영어·일본어에서 마지막 브랜드가 화면 밖으로 밀린다.
     줄바꿈으로 흘려보내 항상 전부 보이게 한다. */
  .side__nav {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
  }
  .navitem { flex: 0 0 auto; padding: 7px 11px; font-size: 13px; white-space: nowrap; }
  .navitem__count { margin-left: 5px; font-size: 11px; }

  .main { padding: 16px 14px 32px; }
  .head { align-items: stretch; }
  .search { width: 100%; }
  /* iOS 는 16px 미만 입력칸에 포커스가 가면 화면을 확대해 버린다. */
  #q { height: 40px; font-size: 16px; }

  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat { gap: 9px; padding: 10px 12px; }
  .stat__dot { width: 30px; height: 30px; font-size: 13px; }
  .stat__value { font-size: 18px; }
  .stat__label { font-size: 11.5px; }

  .panel { padding: 14px 12px 6px; }

  /* 한 줄 유지: 출시연도는 기기명 뒤로 붙이고 열을 셋으로 줄인다 */
  .thead, .row { grid-template-columns: minmax(0, 1fr) minmax(0, 78px) max-content; gap: 7px; }
  .thead span:nth-child(2), .row__year { display: none; }
  /* 출시연도를 모델명 위 한 줄로 올린다. 이름은 온전히 한 줄을 차지한다. */
  .row__name { font-size: 12.5px; }
  .row__name .row__yearInline {
    display: block;
    margin-bottom: 1px;
    font-size: 10.5px; font-weight: 500; line-height: 1.3;
    color: var(--text-3);
  }
  /* 배율이 길면 두 줄로 흘려보낸다. 칸을 밀어내는 것보다 낫다. */
  .row__cam { font-size: 11px; white-space: normal; line-height: 1.35; }
  .row__cam .sep { margin: 0 1.5px; }
  .badge { padding: 3px 7px; font-size: 11px; }
  .thead { font-size: 10.5px; }
}

/* 아주 좁은 화면(구형 소형 기기). 영어는 'Not supported' 배지가 넓어
   기기명·배율·상태를 한 줄에 다 담을 수 없다. 이 구간에서만 기기명이
   두 줄로 흐르게 둔다. 이름이 잘려 안 보이는 것보다 낫다. */
@media (max-width: 360px) {
  .thead, .row { grid-template-columns: minmax(0, 1fr) minmax(0, 68px) max-content; gap: 6px; }
  .row__name { font-size: 12px; }
  .row__label { white-space: normal; overflow: visible; text-overflow: clip; }
  .row__cam { font-size: 10.5px; }
  .badge { padding: 3px 6px; font-size: 10.5px; }
  .main { padding: 14px 10px 28px; }
  .panel { padding: 12px 10px 6px; }
}

@media (min-width: 721px) {
  .row__yearInline { display: none; }
}
