/* app.css — App shell styles: reset, body, header, bottom tab bar, tiles, buttons */

@import url('themes.css');

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; }
html, body, h1, h2, h3, h4, h5, h6, p, ul, ol, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
img, video { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; background: none; border: 0; color: inherit; }
input, textarea, select { font: inherit; }

/* --- Body and app container --- */
html { font-size: var(--font-size-base); }
body {
  font-family: var(--font-body);
  color: var(--text-body);
  background: var(--chrome);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  max-width: var(--app-width);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg-main);
  position: relative;
  padding-bottom: calc(var(--bottom-bar-height) + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg);
}

/* --- Top bar --- */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  height: var(--header-height);
  background: var(--chrome);
  color: var(--text-on-dark);
}

.top-bar__brand {
  font-weight: 700;
  font-size: var(--font-size-lg);
  letter-spacing: 0.02em;
}

.top-bar__actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

.region-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  background: var(--chrome-alt);
  color: var(--text-on-dark);
  font-size: var(--font-size-sm);
}

.region-toggle[data-region="my"] .region-toggle__sg,
.region-toggle[data-region="sg"] .region-toggle__my { opacity: 0.4; }

.lang-switcher {
  position: relative;
}
.lang-switcher__button {
  padding: 6px 10px;
  border-radius: var(--radius-btn);
  background: var(--chrome-alt);
  color: var(--text-on-dark);
  font-size: var(--font-size-sm);
}
.lang-switcher__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--bg-main);
  color: var(--text-body);
  border-radius: var(--radius-btn);
  box-shadow: var(--shadow-md);
  min-width: 140px;
  overflow: hidden;
  display: none;
}
.lang-switcher[data-open="true"] .lang-switcher__menu { display: block; }
.lang-switcher__menu a { display: block; padding: 10px 14px; }
.lang-switcher__menu a:hover { background: var(--bg-section); }

.nav-drawer-toggle {
  background: transparent;
  color: var(--text-on-dark);
  font-size: 22px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-btn);
}

/* --- Bottom tab bar --- */
.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--chrome);
  color: var(--text-on-dark);
  display: flex;
  justify-content: space-around;
  height: calc(var(--bottom-bar-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  margin: 0 auto;
  max-width: var(--app-width);
}

.bottom-bar__tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-on-dark-muted);
  padding: 8px 4px;
}
.bottom-bar__tab[aria-current="page"],
.bottom-bar__tab[data-active="true"] { color: var(--primary); }
.bottom-bar__tab svg, .bottom-bar__tab img { width: 22px; height: 22px; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: var(--font-size-base);
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  min-height: 48px;
  text-align: center;
}
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-hover); }
.btn--accent { background: var(--accent); color: var(--chrome); }
.btn--accent:hover { background: var(--accent-dark); color: #fff; }
.btn--outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn--block { width: 100%; }

.btn-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin: var(--space-5) 0;
}

/* --- Tile grid --- */
.tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  padding: var(--space-5) var(--space-4);
}

.tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 96px;
  gap: 6px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  position: relative;
}
.tile:active { transform: scale(0.96); }
.tile:hover { box-shadow: var(--shadow-md); }
.tile__icon { font-size: 28px; line-height: 1; }
.tile__label { font-size: 13px; font-weight: 600; color: var(--text-body); }
.tile__badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--accent-dark);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
}

/* --- Trust row --- */
.trust-row {
  display: flex;
  gap: var(--space-3);
  overflow-x: auto;
  padding: var(--space-4);
  background: var(--bg-section);
  scrollbar-width: none;
}
.trust-row::-webkit-scrollbar { display: none; }
.trust-badge {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--space-3);
  background: var(--bg-main);
  border-radius: var(--radius-card);
  min-width: 96px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}
.trust-badge__icon { font-size: 22px; color: var(--primary); }

/* --- Footer --- */
.site-footer {
  background: var(--chrome);
  color: var(--text-on-dark-muted);
  padding: var(--space-6) var(--space-4);
  font-size: var(--font-size-sm);
}
.site-footer a { color: var(--text-on-dark); }
.site-footer__nav {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.site-footer__legal {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: var(--space-4);
  font-size: 12px;
  line-height: 1.5;
}

/* --- 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;
}

/* Region-aware CTA: hidden when a region is picked via JS */
[data-region-cta="pair"] { display: grid; }
[data-region-cta="single-my"],
[data-region-cta="single-sg"] { display: none; }
body[data-region="my"] [data-region-cta="pair"] { display: none; }
body[data-region="my"] [data-region-cta="single-my"] { display: flex; }
body[data-region="sg"] [data-region-cta="pair"] { display: none; }
body[data-region="sg"] [data-region-cta="single-sg"] { display: flex; }

/* --- Desktop enhancements --- */
@media (min-width: 768px) {
  body { padding: var(--space-6) 0; }
  .app-container {
    border-radius: 18px;
    overflow: hidden;
    min-height: calc(100vh - var(--space-6) * 2);
  }
}

/* --- Nav drawer --- */
.nav-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease);
  z-index: 90;
}
.nav-drawer-overlay[data-open="true"] { opacity: 1; pointer-events: auto; }

.nav-drawer {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  width: min(86vw, 360px);
  background: var(--bg-main);
  color: var(--text-body);
  transform: translateX(-100%);
  transition: transform var(--dur-base) var(--ease);
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.nav-drawer[data-open="true"] { transform: translateX(0); }

.nav-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  background: var(--chrome);
  color: var(--text-on-dark);
  height: var(--header-height);
}
.nav-drawer__title { font-weight: 700; font-size: var(--font-size-lg); }
.nav-drawer__close {
  background: transparent;
  color: var(--text-on-dark);
  font-size: 28px;
  width: 36px;
  height: 36px;
  line-height: 1;
  border-radius: var(--radius-btn);
}
.nav-drawer__close:hover { background: var(--chrome-alt); }

.nav-drawer__nav {
  display: flex;
  flex-direction: column;
  padding: var(--space-3) 0;
  flex: 1;
  overflow-y: auto;
}
.nav-drawer__link {
  padding: var(--space-3) var(--space-5);
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--text-body);
  border-left: 3px solid transparent;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.nav-drawer__link:hover {
  background: var(--bg-section);
  border-left-color: var(--primary);
  color: var(--primary);
}

.nav-drawer__section {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
}
.nav-drawer__label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.nav-drawer__value { font-size: var(--font-size-sm); color: var(--text-body); }
.nav-drawer__clear {
  color: var(--primary);
  font-size: 12px;
  margin-left: var(--space-2);
}
.nav-drawer__langs {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.nav-drawer__langs a {
  padding: 8px 0;
  font-size: var(--font-size-sm);
  color: var(--text-body);
}
.nav-drawer__langs a[aria-current="true"] {
  color: var(--primary);
  font-weight: 700;
}
