/* デザイン: ChatGPT案をベースに、動作側(app.js)の都合で状態規則を調整。
   契約: body[data-state="loading|ready|error"]、要素ID
   #status #accuracy #coords #warn #btn-line #btn-copy #btn-refresh
   #warn は app.js が hidden 属性で出し入れする。 */
:root {
  color-scheme: light dark;

  --bg: #f5f6f7;
  --surface: #ffffff;
  --text: #202124;
  --muted: #73777d;
  --border: #e5e7eb;
  --green: #06c755;
  --green-text: #ffffff;
  --blue: #2878d0;
  --warning-bg: #fff4df;
  --warning-text: #956000;
  --error: #d93025;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17191c;
    --surface: #24272b;
    --text: #f1f3f4;
    --muted: #a1a6ad;
    --border: #383c42;
    --warning-bg: #39301e;
    --warning-text: #ffd27a;
    --error: #ff7168;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Noto Sans JP", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 40px 24px 24px;
  display: flex;
  flex-direction: column;
}

.header { margin-bottom: 32px; }
.header h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: 0.02em; }
.subtitle { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

.location-card {
  padding: 24px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.status-row { display: flex; align-items: center; gap: 10px; }
#status { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.5; }

.status-indicator {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #9ca3af;
}

#accuracy { margin: 20px 0 0; font-size: 15px; font-weight: 600; }

#coords {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

#warn {
  margin: 18px 0 0;
  padding: 12px;
  border-radius: 8px;
  background: var(--warning-bg);
  color: var(--warning-text);
  font-size: 13px;
  line-height: 1.5;
}

.actions { display: flex; flex-direction: column; gap: 12px; margin-top: 32px; }

button {
  width: 100%;
  min-height: 58px;
  padding: 14px 20px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

#btn-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 64px;
  background: var(--green);
  color: var(--green-text);
  font-size: 18px;
}

.line-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 26px;
  border-radius: 9px;
  background: #ffffff;
  color: #06a94b;
  font-size: 10px;
  font-weight: 800;
}

#btn-copy {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
}
#btn-copy span { margin-right: 6px; }

#btn-refresh {
  min-height: 44px;
  padding: 8px;
  background: transparent;
  color: var(--blue);
  font-size: 14px;
  font-weight: 600;
}

.footer { margin-top: auto; padding-top: 40px; text-align: center; }
.footer p { margin: 0; color: var(--muted); font-size: 11px; }

/* 状態ごとの見た目 */
/* loading: 取得中。送信系ボタンは押せない */
body[data-state="loading"] .status-indicator { background: #e5a000; animation: pulse 1.2s ease-in-out infinite; }
body[data-state="loading"] #accuracy,
body[data-state="loading"] #coords { display: none; }
body[data-state="loading"] #btn-line { opacity: 0.45; filter: saturate(0.5); pointer-events: none; }
body[data-state="loading"] #btn-copy,
body[data-state="loading"] #btn-refresh { opacity: 0.5; pointer-events: none; }

/* ready: 取得完了 */
body[data-state="ready"] .status-indicator { background: var(--green); }

/* error: 失敗。再試行を促す */
body[data-state="error"] .status-indicator { background: var(--error); }
body[data-state="error"] #status { color: var(--error); }
body[data-state="error"] #accuracy,
body[data-state="error"] #coords { display: none; }
body[data-state="error"] #btn-line,
body[data-state="error"] #btn-copy { opacity: 0.4; pointer-events: none; }
body[data-state="error"] #btn-refresh {
  min-height: 58px;
  background: var(--blue);
  color: #ffffff;
  font-size: 16px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

@media (prefers-reduced-motion: reduce) {
  .status-indicator { animation: none !important; }
}
