/* ========================================
   清風明月 Guest Guide — Mobile-First CSS
   ======================================== */

:root {
  /* Colors — Zen/Nature palette */
  --bg: #faf9f7;
  --bg-card: #ffffff;
  --text: #2c2c2c;
  --text-secondary: #6b6b6b;
  --accent: #5b7f5e;       /* 深い緑 — 自然 */
  --accent-light: #e8f0e8;
  --border: #e5e2de;
  --shadow: rgba(0,0,0,0.06);
  --radius: 12px;
  --emergency: #c0392b;
  --emergency-light: #fdecea;

  /* Dark mode */
  --dm-bg: #1a1a1a;
  --dm-bg-card: #262626;
  --dm-text: #e8e6e3;
  --dm-text-secondary: #9e9e9e;
  --dm-border: #3a3a3a;
  --dm-accent-light: #2a3a2a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--dm-bg);
    --bg-card: var(--dm-bg-card);
    --text: var(--dm-text);
    --text-secondary: var(--dm-text-secondary);
    --border: var(--dm-border);
    --accent-light: var(--dm-accent-light);
    --shadow: rgba(0,0,0,0.2);
  }
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* ── Header ── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.header-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.header-back {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.lang-switcher {
  display: flex;
  gap: 6px;
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.lang-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── SOS Emergency Panel ── */
.sos-panel {
  margin: 16px 0 20px;
  border: 2px solid var(--emergency);
  border-radius: var(--radius);
  background: var(--emergency-light);
  overflow: hidden;
}

@media (prefers-color-scheme: dark) {
  .sos-panel { background: #3a1a1a; }
}

.sos-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--emergency);
  color: #fff;
}

.sos-icon { font-size: 1.2rem; }

.sos-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.sos-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
}

.sos-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  text-align: center;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  box-shadow: 0 1px 4px var(--shadow);
}

.sos-btn:active {
  transform: scale(0.95);
  box-shadow: 0 0 0 3px rgba(192,57,43,0.3);
}

.sos-btn-icon { font-size: 1.5rem; }

.sos-btn-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
}

.sos-btn-number {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--emergency);
  letter-spacing: 0.02em;
}

.sos-btn-note {
  font-size: 0.65rem;
  color: var(--text-secondary);
  margin-top: -2px;
}

.sos-more {
  display: block;
  text-align: center;
  padding: 8px 16px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--emergency);
  text-decoration: none;
}

/* ── Main content ── */
.main {
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
}

/* ── Language select (top page) ── */
.lang-select-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80dvh;
  gap: 20px;
  padding: 24px;
}

.lang-select-page .logo-text {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-align: center;
  margin-bottom: 8px;
}

.lang-select-page .subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 24px;
}

.lang-card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 320px;
  padding: 20px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px var(--shadow);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.lang-card:active {
  transform: scale(0.97);
  box-shadow: 0 1px 4px var(--shadow);
}

.lang-card .flag {
  font-size: 2rem;
  line-height: 1;
}

.lang-card .lang-name {
  font-size: 1.15rem;
  font-weight: 600;
}

.lang-card .lang-name-native {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ── Category cards grid ── */
.categories {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.cat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px var(--shadow);
  text-decoration: none;
  color: var(--text);
  text-align: center;
  transition: transform 0.15s ease;
}

.cat-card:active {
  transform: scale(0.96);
}

.cat-card .icon {
  font-size: 1.8rem;
}

.cat-card .label {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
}

.cat-card.emergency {
  border-color: var(--emergency);
  background: var(--emergency-light);
}

@media (prefers-color-scheme: dark) {
  .cat-card.emergency {
    background: #3a1a1a;
    border-color: #c0392b;
  }
}

/* ── Content pages ── */
.page-title {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.page-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.content {
  line-height: 1.8;
}

.content h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 32px;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--accent);
}

.content h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-top: 24px;
  margin-bottom: 8px;
  color: var(--accent);
}

.content h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 16px;
  margin-bottom: 6px;
}

.content p {
  margin-bottom: 12px;
}

.content ul, .content ol {
  padding-left: 20px;
  margin-bottom: 12px;
}

.content li {
  margin-bottom: 6px;
}

.content strong {
  font-weight: 700;
}

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.85rem;
  overflow-x: auto;
  display: block;
}

.content th, .content td {
  padding: 8px 10px;
  border: 1px solid var(--border);
  text-align: left;
}

.content th {
  background: var(--accent-light);
  font-weight: 700;
  white-space: nowrap;
}

.content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.content blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 16px;
  margin: 12px 0;
  background: var(--accent-light);
  border-radius: 0 8px 8px 0;
  font-size: 0.9rem;
}

/* ── Emergency callout ── */
.emergency-callout {
  background: var(--emergency-light);
  border: 2px solid var(--emergency);
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0;
}

@media (prefers-color-scheme: dark) {
  .emergency-callout {
    background: #3a1a1a;
  }
}

.emergency-callout .call-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--emergency);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  margin-top: 8px;
}

/* ── Media section ── */
.media-section {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.media-section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.media-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s ease;
}

.media-card:active {
  transform: scale(0.98);
}

.media-card .media-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.media-card .media-info {
  flex: 1;
  min-width: 0;
}

.media-card .media-title {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
}

.media-card .media-type {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ── Video / Audio player ── */
.player-container {
  margin: 16px 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}

video {
  width: 100%;
  display: block;
}

audio {
  width: 100%;
  margin: 12px 0;
}

/* ── PDF embed ── */
.pdf-container {
  margin: 16px 0;
}

.pdf-container iframe {
  width: 100%;
  height: 70vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.pdf-fallback {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

/* ── Image viewer ── */
.img-viewer {
  margin: 16px 0;
  text-align: center;
}

.img-viewer img {
  max-width: 100%;
  border-radius: var(--radius);
  box-shadow: 0 2px 12px var(--shadow);
}

/* Pinch-zoom overlay */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.92);
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.lightbox.active {
  display: flex;
}

.lightbox img {
  max-width: 100%;
  max-height: 90dvh;
  object-fit: contain;
  touch-action: pinch-zoom;
}

.lightbox-close {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.2);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 24px 16px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* ── Guide list (category index) ── */
.guide-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.guide-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s ease;
}

.guide-item:active {
  transform: scale(0.98);
}

.guide-item .guide-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.guide-item .guide-title {
  font-size: 0.9rem;
  font-weight: 600;
}

/* ── Utility ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
