/* ===== Variables (Themes) ===== */
:root {
  --bg: #0f0f0f;
  --surface: #18181b;
  --border: #27272a;
  --text: #e4e4e4;
  --text-muted: #71717a;
  --text-soft: #d4d4d8;
  --accent: #fff;
}

[data-theme="light"] {
  --bg: #fafafa;
  --surface: #fff;
  --border: #e4e4e7;
  --text: #18181b;
  --text-muted: #71717a;
  --text-soft: #3f3f46;
  --accent: #18181b;
}

/* ===== Base / Layout ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: 'Anuphan', sans-serif;
  background: var(--bg);
  min-height: 100vh;
  color: var(--text);
  padding: clamp(1rem, 4vw, 2rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: background 0.25s, color 0.25s;
  position: relative;
}

/* พื้นหลังโลโก้ SUTH เรียงซ้ำ จาง */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url('assets/img/logo_SUTH.png');
  background-repeat: repeat;
  background-size: min(280px, 50vw) auto;
  opacity: 0.02;
  pointer-events: none;
  z-index: 0;
}

/* ===== Component: Theme Toggle ===== */
.theme-toggle {
  position: fixed;
  top: clamp(0.75rem, 2vw, 1.25rem);
  right: clamp(0.75rem, 2vw, 1.25rem);
  width: clamp(2.5rem, 8vw, 3.25rem);
  height: clamp(2.5rem, 8vw, 3.25rem);
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  transition: background 0.2s, border-color 0.2s;
  z-index: 10;
}

.theme-toggle:hover { opacity: 0.9; }

/* ===== Component: Container ===== */
.container {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border-radius: clamp(12px, 3vw, 20px);
  padding: clamp(1.25rem, 4vw, 2.5rem);
  max-width: min(96vw, 720px);
  width: 100%;
  border: 1px solid var(--border);
  transition: background 0.25s, border-color 0.25s;
}

.app-brand {
  text-align: center;
  margin-bottom: clamp(1rem, 3vw, 1.75rem);
  line-height: 0;
}

.app-brand img {
  height: clamp(48px, 12vw, 72px);
  width: auto;
  object-fit: contain;
  display: inline-block;
}

/* ===== Component: Device Section ===== */
.device-section { transition: opacity 0.2s; }

.device-section.hide { display: none !important; }

.device-section h2 {
  font-size: clamp(0.7rem, 2.2vw, 0.85rem);
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.device-section h2 i { font-size: 1.1em; color: var(--text-muted); }

.device-type {
  font-size: clamp(1.2rem, 3.5vw, 1.5rem);
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.device-type.android { color: #22c55e; }
.device-type.ios { color: #3b82f6; }
.device-type.desktop { color: #f59e0b; }
.device-type.unknown { color: var(--text-muted); }

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.badge.android { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.badge.ios { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.badge.desktop { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.badge.unknown { background: rgba(161, 161, 170, 0.2); color: var(--text-muted); }

.detail-list { list-style: none; margin-top: 1.25rem; }

.detail-list li {
  padding: clamp(0.4rem, 1.5vw, 0.6rem) 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: clamp(0.8rem, 2.2vw, 0.95rem);
}

.detail-list li:last-child { border-bottom: none; }

.detail-list .label { color: var(--text-muted); font-weight: 400; }

.detail-list .value {
  color: var(--text-soft);
  text-align: right;
  word-break: break-all;
  font-weight: 500;
}

/* ===== Component: App Links ===== */
.app-links {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.app-links h3 {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.app-links .links { display: flex; flex-direction: column; gap: 0.5rem; }

.app-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: clamp(0.65rem, 2vw, 0.9rem) clamp(0.9rem, 3vw, 1.25rem);
  border-radius: clamp(8px, 2vw, 12px);
  text-decoration: none;
  font-weight: 500;
  font-size: clamp(0.85rem, 2.2vw, 1rem);
  font-family: 'Anuphan', sans-serif;
  transition: background 0.2s, opacity 0.2s;
}

.app-links a:hover { opacity: 0.92; }

.app-links a.app-store {
  background: var(--bg);
  border: 1px solid #3b82f6;
  color: #3b82f6;
}

.app-links a.app-store:hover { background: rgba(59, 130, 246, 0.12); }

.app-links a.play-store {
  background: var(--bg);
  border: 1px solid #22c55e;
  color: #16a34a;
}

.app-links a.play-store:hover { background: rgba(34, 197, 94, 0.12); }

.app-links a i { font-size: 1.1rem; }

/* ===== Component: Desktop View (QR + Intro) ===== */
.desktop-view { display: none; }

.desktop-view.show { display: block; }

.intro-section {
  text-align: center;
  margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
}

.intro-tagline {
  font-size: clamp(1rem, 2.8vw, 1.25rem);
  line-height: 1.5;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 0.35rem;
  letter-spacing: 0.02em;
}

.intro-desc {
  font-size: clamp(0.85rem, 2.2vw, 1rem);
  color: var(--text-muted);
  font-weight: 400;
  margin-bottom: clamp(1.25rem, 3vw, 1.75rem);
}

.feature-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem 1.25rem;
  max-width: 420px;
  margin: 0 auto clamp(1.5rem, 4vw, 2rem);
  text-align: left;
}

.feature-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: clamp(0.8rem, 2.2vw, 0.95rem);
  color: var(--text-soft);
}

.feature-list li i {
  font-size: 1.15rem;
  color: var(--accent);
  opacity: 0.9;
  flex-shrink: 0;
}

.intro-cta {
  font-size: clamp(0.85rem, 2.2vw, 0.95rem);
  color: var(--text-muted);
  font-weight: 500;
}

.desktop-view .qrcode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(1rem, 4vw, 2rem);
  margin-top: clamp(0.75rem, 2vw, 1.25rem);
}

.desktop-view .qrcode-card {
  text-align: center;
  padding: clamp(1rem, 3vw, 1.5rem);
  border-radius: clamp(10px, 2.5vw, 16px);
  border: 1px solid var(--border);
  background: var(--bg);
  transition: border-color 0.2s;
}

.desktop-view .qrcode-card img {
  width: 100%;
  max-width: min(180px, 35vw);
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  display: block;
  margin: 0 auto clamp(0.5rem, 1.5vw, 0.75rem);
  border-radius: clamp(6px, 1.5vw, 10px);
}

.desktop-view .qrcode-card span {
  font-size: clamp(0.8rem, 2.2vw, 0.95rem);
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.desktop-view .qrcode-card span i { font-size: 1.1em; }

.desktop-view .qrcode-card.ios span { color: #3b82f6; }

.desktop-view .qrcode-card.android span { color: #22c55e; }

/* ===== Responsive ===== */
@media (max-width: 380px) {
  .feature-list { grid-template-columns: 1fr; }
  .desktop-view .qrcode-grid { grid-template-columns: 1fr; }
  .desktop-view .qrcode-card img { max-width: 160px; }
}

@media (min-width: 520px) {
  .feature-list { grid-template-columns: repeat(3, 1fr); max-width: 100%; }
}

@media (min-width: 480px) {
  .container { max-width: min(92vw, 640px); }
  .desktop-view .qrcode-card img { max-width: 200px; }
}

@media (min-width: 768px) {
  .container { max-width: min(88vw, 720px); padding: clamp(1.5rem, 5vw, 3rem); }
  .desktop-view .qrcode-card img { max-width: 220px; }
}

@media (min-width: 1024px) {
  .container { max-width: 800px; }
  .desktop-view .qrcode-card img { max-width: 240px; }
}
