/* gejala.id — mobile-native, app-feel */
:root {
  --bg: #fafafa;
  --bg-card: #ffffff;
  --text: #18181b;
  --text-muted: #71717a;
  --border: #e4e4e7;
  --accent: #dc2626;
  --header-h: 56px;
  --nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --bg-card: #18181b;
    --text: #fafafa;
    --text-muted: #a1a1aa;
    --border: #27272a;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 16px;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

@view-transition { navigation: auto; }
@keyframes fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
::view-transition-new(root) { animation: fade-in 250ms ease; }

/* Header */
.app-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  padding: calc(8px + var(--safe-top)) 16px 8px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  height: calc(var(--header-h) + var(--safe-top));
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; flex-shrink: 0; }
.brand-icon { font-size: 20px; }
.brand-dot { color: var(--accent); }
.desktop-nav { display: none; }
.desktop-nav-link {
  padding: 8px 14px; border-radius: 8px;
  color: var(--text-muted); font-weight: 500; font-size: 14px;
  text-decoration: none; transition: all 200ms;
}
.desktop-nav-link:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.desktop-nav-link.active { color: var(--accent); background: color-mix(in oklab, var(--accent) 10%, transparent); font-weight: 600; }
.header-search {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 14px;
  color: var(--text-muted); font-size: 14px; cursor: pointer;
  min-height: 40px; appearance: none; min-width: 0;
}
.header-search:hover { border-color: var(--accent); }
.header-search-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Bottom nav */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--bg-card); border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  z-index: 50;
}
.nav-tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 4px; min-height: var(--nav-h);
  color: var(--text-muted); font-size: 11px;
  text-decoration: none; transition: color 200ms;
}
.nav-tab.active { color: var(--accent); font-weight: 600; }
.nav-icon { font-size: 22px; line-height: 1; }
.nav-label { line-height: 1; }
.nav-tab:hover { text-decoration: none; }

/* Main container */
main { padding: 16px; max-width: 720px; margin: 0 auto; }

/* Hero */
.hero {
  padding: 24px 0 32px;
  background: linear-gradient(180deg, transparent, var(--bg-card));
  border-radius: 16px; margin-bottom: 24px;
}
.hero h1 { font-size: 32px; line-height: 1.1; margin: 0 0 8px; font-weight: 800; letter-spacing: -0.5px; }
.hero-accent { color: var(--accent); }
.hero-sub { color: var(--text-muted); margin: 0 0 20px; font-size: 15px; }
.hero-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card); border: 2px solid var(--accent);
  border-radius: 16px; padding: 10px 14px;
  box-shadow: 0 4px 16px rgba(220, 38, 38, 0.12);
}
.hero-search svg { flex-shrink: 0; color: var(--accent); }
.hero-search input {
  flex: 1; border: 0; background: transparent;
  font-size: 16px; color: var(--text); outline: none;
  min-height: 40px;
}
.hero-search button {
  background: var(--accent); color: #fff;
  border: 0; border-radius: 12px;
  padding: 10px 18px; font-size: 14px; font-weight: 600;
  cursor: pointer; min-height: 40px;
}
.hero-meta { color: var(--text-muted); font-size: 12px; margin: 12px 0 0; }
.voice-btn {
  background: transparent; border: 0;
  color: var(--accent); cursor: pointer;
  width: 40px; height: 40px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  transition: background 200ms;
}
.voice-btn:hover { background: color-mix(in oklab, var(--accent) 12%, transparent); }
.voice-btn.listening {
  color: #fff; background: var(--accent);
  animation: pulse 1.2s infinite;
}
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent) 60%, transparent); } 50% { box-shadow: 0 0 0 8px transparent; } }

/* Section */
.section-heading { font-size: 20px; font-weight: 700; margin: 0 0 12px; }

/* Vertical grid */
.vgrid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
@media (min-width: 600px) { .vgrid { grid-template-columns: repeat(3, 1fr); } }
.vcard {
  display: flex; flex-direction: column; gap: 6px;
  padding: 16px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 16px;
  color: var(--text); text-decoration: none;
  transition: transform 200ms, box-shadow 200ms;
  border-left: 4px solid var(--vcolor, var(--accent));
  min-height: 110px;
}
.vcard:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.08); text-decoration: none; }
.vcard .vicon { font-size: 28px; line-height: 1; }
.vcard strong { font-size: 15px; }
.vcard small { color: var(--text-muted); font-size: 12px; }

/* Trending horizontal scroll */
.trending { margin: 24px 0; }

/* Generic horizontal scroller with prev/next buttons (desktop) */
.h-scroller { position: relative; margin: 0 -16px; }
.h-scroller-track {
  display: flex; gap: 12px;
  overflow-x: auto; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch; scroll-behavior: smooth;
  padding: 4px 16px 12px;
  scrollbar-width: none;
}
.h-scroller-track::-webkit-scrollbar { display: none; }
.h-scroller-btn {
  display: none;  /* default hidden — only shown for hover-capable pointers */
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 999px;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text); font-size: 24px; line-height: 1;
  cursor: pointer; z-index: 5;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
  transition: opacity 200ms, transform 150ms;
}
.h-scroller-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); transform: translateY(-50%) scale(1.05); }
.h-scroller-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.h-scroller-btn:disabled:hover { background: var(--bg-card); color: var(--text); transform: translateY(-50%); }
.h-scroller-prev { left: 4px; }
.h-scroller-next { right: 4px; }

/* Show buttons only on devices with proper hover (desktop mouse, not touch) */
@media (hover: hover) and (pointer: fine) {
  .h-scroller-btn { display: flex; align-items: center; justify-content: center; }
  .h-scroller { margin: 0; }
  .h-scroller-track { padding-left: 56px; padding-right: 56px; }
}

.trending-card {
  flex: 0 0 auto; width: 160px;
  scroll-snap-align: start;
  display: flex; flex-direction: column; gap: 8px; padding: 14px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; color: var(--text); text-decoration: none;
  border-top: 3px solid var(--vcolor, var(--accent));
}
.trending-icon { font-size: 22px; }
.trending-card strong { font-size: 14px; line-height: 1.3; }

/* How it works */
.how-it-works { margin: 32px 0; padding: 20px; background: var(--bg-card); border-radius: 16px; border: 1px solid var(--border); }
.how-steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.how-steps li { padding: 12px; background: var(--bg); border-radius: 12px; }
.how-steps small { color: var(--text-muted); font-size: 13px; }

/* Article (gejala page) */
.gejala-article { padding-bottom: 24px; }
.breadcrumb {
  display: flex; flex-wrap: wrap; gap: 4px;
  font-size: 13px; color: var(--text-muted);
  margin-bottom: 12px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb [aria-current] { color: var(--text); font-weight: 600; }

.gejala-header { padding: 20px 16px; background: var(--bg-card); border-radius: 16px; margin-bottom: 16px; border-left: 4px solid var(--accent); }
.gejala-vertical-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.vertical-icon { font-size: 14px; }
.gejala-header h1 { font-size: 26px; line-height: 1.15; margin: 0 0 12px; font-weight: 800; letter-spacing: -0.3px; }
.gejala-intro { font-size: 15px; color: var(--text); margin: 12px 0 0; }
.city-suffix { color: var(--accent); font-weight: 600; font-size: 0.7em; display: inline-block; }
.city-context { font-size: 13px; color: var(--text-muted); margin: 12px 0 0; padding: 8px 12px; background: var(--bg); border-radius: 8px; }

/* Triage badge */
.triage-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: color-mix(in oklab, var(--triage-color) 15%, transparent);
  color: var(--triage-color); font-weight: 700; font-size: 13px;
  border: 1px solid color-mix(in oklab, var(--triage-color) 40%, transparent);
}

/* CTA stack */
.cta-stack { display: grid; gap: 10px; margin: 16px 0 24px; }
.cta-card {
  display: grid; grid-template-columns: 44px 1fr 24px; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: 14px;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text); text-decoration: none; min-height: 60px;
  transition: transform 200ms, box-shadow 200ms;
}
.cta-card:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,0,0,.06); text-decoration: none; }
.cta-primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
  box-shadow: 0 4px 14px color-mix(in oklab, var(--accent) 30%, transparent);
}
.cta-primary:hover { color: #fff; }
.cta-secondary { border-color: var(--accent); color: var(--text); }
.cta-emoji { font-size: 26px; line-height: 1; text-align: center; }
.cta-text { display: flex; flex-direction: column; gap: 2px; }
.cta-label { font-weight: 700; font-size: 15px; }
.cta-site { font-size: 12px; opacity: .8; }
.cta-arrow { font-size: 20px; opacity: .7; }

/* Info section */
.info-section { margin: 24px 0; padding: 20px; background: var(--bg-card); border-radius: 16px; border: 1px solid var(--border); }
.info-section h2 { font-size: 18px; margin: 0 0 12px; font-weight: 700; }

/* Evidence list */
.evidence-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.evidence-list li { padding: 12px; background: var(--bg); border-radius: 10px; border-left: 3px solid var(--accent); }
.evidence-list strong { display: block; margin-bottom: 4px; font-size: 14px; }
.evidence { font-size: 13px; color: var(--text-muted); margin: 4px 0 6px; font-style: italic; }
.source-link { font-size: 12px; color: var(--accent); }

/* Drug grid */
.drug-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.drug-card { padding: 10px; background: var(--bg); border-radius: 10px; color: var(--text); text-decoration: none; border: 1px solid var(--border); }
.drug-card strong { display: block; font-size: 13px; margin-bottom: 4px; }
.drug-card small { font-size: 11px; color: var(--text-muted); }

/* Related */
.related-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.related-chip {
  padding: 6px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 999px; color: var(--text); text-decoration: none; font-size: 13px;
}
.related-chip:hover { background: var(--accent); color: #fff; border-color: var(--accent); text-decoration: none; }

.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.related-card {
  display: grid; gap: 4px;
  padding: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); text-decoration: none; min-height: 90px;
}
.related-card:hover { border-color: var(--accent); }
.related-type { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.related-card strong { font-size: 13px; line-height: 1.3; }
.related-card small { font-size: 11px; color: var(--text-muted); }
.related-site { font-size: 11px; color: var(--accent); margin-top: auto; }

/* Self-care (Coba Dulu di Rumah) */
.self-care {
  border-left: 4px solid #16a34a;
  background: color-mix(in oklab, #16a34a 6%, var(--bg-card));
}
.self-care h2 { display: flex; align-items: center; gap: 8px; color: #15803d; }
.self-care-icon { font-size: 22px; }
.self-care-body { font-size: 15px; }
.self-care-body ul { padding-left: 22px; margin: 0 0 12px; }
.self-care-body li { margin-bottom: 8px; }
.self-care-note {
  margin: 16px 0 0; padding: 10px 12px;
  background: var(--bg); border-radius: 8px;
  font-size: 13px; color: var(--text-muted);
  border-left: 3px solid #16a34a;
}
@media (prefers-color-scheme: dark) {
  .self-care { background: color-mix(in oklab, #16a34a 12%, var(--bg-card)); }
  .self-care h2 { color: #4ade80; }
}
.cta-stack-heading {
  font-size: 14px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin: 16px 0 4px;
}

/* Disclaimer */
.disclaimer {
  margin: 24px 0; padding: 12px 14px; background: rgba(234, 88, 12, 0.08);
  border-left: 3px solid #ea580c; border-radius: 6px; font-size: 13px;
}

/* Search results */
.search-results { display: grid; gap: 8px; padding: 16px 0; }
.search-result {
  padding: 12px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text); text-decoration: none;
}
.search-result strong { display: block; }
.search-result small { color: var(--text-muted); font-size: 12px; }

/* Chat */
.chat-page { display: flex; flex-direction: column; min-height: 70vh; }
.chat-history { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 16px 0; }
.chat-msg { padding: 12px 14px; border-radius: 14px; max-width: 90%; line-height: 1.5; }
.chat-msg-user { align-self: flex-end; background: var(--accent); color: #fff; }
.chat-msg-ai { align-self: flex-start; background: var(--bg-card); border: 1px solid var(--border); }
.chat-form { display: flex; gap: 8px; padding: 12px 0; }
.chat-form textarea {
  flex: 1; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg-card); color: var(--text);
  font-family: inherit; font-size: 15px; resize: vertical;
  min-height: 60px;
}
.chat-form button {
  padding: 0 18px; background: var(--accent); color: #fff;
  border: 0; border-radius: 12px; font-weight: 600; cursor: pointer;
  min-height: 60px;
}
.disclaimer-inline { font-size: 12px; color: var(--text-muted); margin: 0; padding: 0 2px; }

/* Browse / list */
.gejala-list { display: grid; gap: 8px; }
.gejala-list-item {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text); text-decoration: none;
}
.gejala-list-item:hover { border-color: var(--accent); }
.gejala-list-item small { color: var(--text-muted); font-size: 12px; }

.pagination { display: flex; justify-content: space-between; align-items: center; margin: 24px 0; padding: 12px; background: var(--bg-card); border-radius: 12px; }

.vertical-header { padding: 24px 16px; background: var(--bg-card); border-radius: 16px; margin-bottom: 16px; text-align: center; border-top: 4px solid var(--accent); }
.vertical-icon-large { font-size: 48px; }
.vertical-header h1 { margin: 8px 0; }
.vertical-header .meta { color: var(--text-muted); font-size: 13px; margin: 8px 0 0; }

.about-page h2 { margin-top: 24px; }
.about-page ul { padding-left: 22px; }

.ai-cta { margin: 32px 0; padding: 20px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; text-align: center; }
.ai-cta h2 { margin: 0 0 6px; }
.ai-cta p { color: var(--text-muted); margin: 0 0 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* === Tablet breakpoint: 768px+ === */
@media (min-width: 768px) {
  main { padding: 24px; max-width: 920px; }
  .hero h1 { font-size: 40px; }
  .gejala-header h1 { font-size: 32px; }
  .vgrid { grid-template-columns: repeat(3, 1fr); }
  .related-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .trending-card { width: 200px; }
}

/* === Desktop breakpoint: 1024px+ === */
@media (min-width: 1024px) {
  body { padding-bottom: 0; }  /* No bottom nav padding on desktop */

  /* Hide bottom nav on desktop, show inline desktop nav */
  .bottom-nav { display: none; }
  .desktop-nav {
    display: flex; align-items: center; gap: 4px;
    margin: 0 12px;
    flex: 1; justify-content: center;
  }

  /* Wider header on desktop with proper layout */
  .app-header {
    padding-left: 32px; padding-right: 32px;
    height: 64px;
    gap: 24px;
  }
  .header-search { max-width: 280px; flex: 0 1 280px; }

  main { padding: 32px; max-width: 1200px; }

  .hero {
    padding: 48px 0;
    text-align: center;
  }
  .hero h1 { font-size: 56px; max-width: 720px; margin: 0 auto 12px; }
  .hero-sub { font-size: 17px; max-width: 600px; margin: 0 auto 24px; }
  .hero-search { max-width: 720px; margin: 0 auto; }

  .vgrid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
  .vcard { min-height: 130px; padding: 20px; }

  /* Article layout: content + sidebar on desktop */
  .gejala-article {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 32px;
    align-items: start;
  }
  .gejala-article > .breadcrumb,
  .gejala-article > .gejala-header,
  .gejala-article > .ai-cta { grid-column: 1 / -1; }

  .gejala-article > .cta-stack { grid-column: 1; }
  .gejala-article > .info-section { grid-column: 1; }
  .gejala-article > .disclaimer { grid-column: 1; }
  .gejala-article > .related-section,
  .gejala-article > .info-section.related-section,
  .gejala-article > .info-section:has(.related-grid) {
    grid-column: 2;
    grid-row: span 6;
    align-self: start;
    position: sticky;
    top: 88px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
  }

  .gejala-header h1 { font-size: 36px; }
  .related-grid { grid-template-columns: 1fr; }

  .trending-card { width: 220px; }

  .browse-page main, .browse-vertical main { max-width: 1080px; }
  .gejala-list { grid-template-columns: repeat(3, 1fr); display: grid; }
}

/* === Wide desktop: 1280px+ === */
@media (min-width: 1280px) {
  .vgrid { grid-template-columns: repeat(6, 1fr); }
  .gejala-list { grid-template-columns: repeat(4, 1fr); }
  main { max-width: 1280px; }
}
