/* =========================================================
   CHT ESP ORG — theme.css
   Global design tokens + Dark/Light theme + Bottom Navigation
   + Footer + responsive helpers, shared by every page.
   Link this BEFORE each page's own <style> block so page-specific
   styles keep overriding these defaults exactly as before.
   ========================================================= */

/* ---------- 1. Global color tokens ---------- */
:root{
  --g-bg:#0a0d13;
  --g-surface:#141a29;
  --g-surface-2:#171f33;
  --g-border:#232c42;
  --g-text:#f2f3f7;
  --g-muted:#8a93a6;
  --g-accent:#22c55e;
  --g-danger:#ef4444;
  --safe-bottom:env(safe-area-inset-bottom, 0px);
}
html[data-theme="light"]{
  --g-bg:#f4f6fb;
  --g-surface:#ffffff;
  --g-surface-2:#eef1f7;
  --g-border:#dde2ec;
  --g-text:#12141a;
  --g-muted:#606a7d;
  --g-accent:#16a34a;
  --g-danger:#dc2626;
}

/* Smooth theme switching */
html{transition:background-color .2s ease;}
body, .card, .bottomnav, .app-footer{transition:background-color .2s ease, color .2s ease, border-color .2s ease;}

/* ---------- 1b. Kill the native mobile "tap highlight" ----------
   On touch devices, tapping a link/card/button paints a translucent
   grey/black highlight over it. If the tap navigates to another page
   before the highlight has faded, and the user then presses Back, some
   mobile browsers restore the previous page from cache with that
   highlight (or a lingering :hover/:active paint) still stuck on the
   element — it looks like the box "went black" and won't come back to
   normal. Removing the native highlight (each page still shows its own
   :active press-down feedback) fixes this without changing any layout,
   color, or theme. */
html, body{ -webkit-tap-highlight-color:transparent; }
a, button, [role="button"], .navitem, .card, .support-card, .menu-row,
.info-row, .back-btn, .icon-btn, .support-fab, input, select, textarea{
  -webkit-tap-highlight-color:transparent;
}

/* ---------- 2. Base page spacing so fixed nav never covers content ---------- */
body{
  padding-bottom:calc(96px + var(--safe-bottom)) !important;
}
html[data-page="chteo_auth"] body,
body.no-bottomnav{
  padding-bottom:0 !important;
}

/* ---------- 3. Global Bottom Navigation ---------- */
.bottomnav{
  position:fixed;
  left:0;right:0;bottom:0;
  display:flex;justify-content:space-around;align-items:flex-start;
  background:#131826;
  border:none;
  border-top:1px solid var(--g-border);
  border-radius:0;
  padding:12px 4px calc(10px + var(--safe-bottom));
  z-index:500;
  box-shadow:0 -6px 24px rgba(0,0,0,.35);
}
html[data-theme="light"] .bottomnav{
  background:#ffffff;
  box-shadow:0 -6px 24px rgba(20,30,60,.1);
}
.bottomnav .navitem{
  display:flex;flex-direction:column;align-items:center;gap:5px;
  color:var(--g-muted);
  padding:2px 6px;flex:1;min-width:0;
  text-decoration:none;
  background:none;border:none;font-family:inherit;cursor:pointer;
}
.bottomnav .navitem.active{ color:var(--g-accent); }
.bottomnav .navitem svg{width:21px;height:21px;}
.bottomnav .navitem .lbl{font-size:8.5px;font-weight:700;white-space:nowrap;}

/* Small round thumbnail of the user's saved profile picture, shown in the
   Profile nav item instead of the generic person icon once they've set one. */
.bottomnav .navitem .nav-avatar{
  width:21px;height:21px;
  border-radius:50%;
  object-fit:cover;
  border:1.5px solid var(--g-muted);
  display:block;
}
.bottomnav .navitem.has-avatar.active .nav-avatar{
  border-color:var(--g-accent);
}
/* Support used to be raised into a big floating circle with its own
   emoji, its own border/glow — visibly different from the other four
   nav items. Fixed here at the stylesheet level (not per-page): the
   emoji glyph is hidden and redrawn as a plain monochrome icon, the
   same 21px size as the other .navitem svgs, using the same muted /
   accent color logic — so Support now looks identical to Home/Refer &
   Earn/Wallet/Profile everywhere this stylesheet is used. */
.bottomnav .support-item{margin-top:0;}
.bottomnav .support-fab{
  width:21px;height:21px;border-radius:0;
  display:flex;align-items:center;justify-content:center;
  background:var(--g-muted);
  border:none;
  box-shadow:none;
  font-size:0;
  -webkit-mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 15v-3a8 8 0 0 1 16 0v3'/%3E%3Cpath d='M4 15a2 2 0 0 1 2-2h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1H6a2 2 0 0 1-2-2Z'/%3E%3Cpath d='M20 15a2 2 0 0 0-2-2h-1a1 1 0 0 0-1 1v3a1 1 0 0 0 1 1h1a2 2 0 0 0 2-2Z'/%3E%3Cpath d='M18 18v1a2 2 0 0 1-2 2h-3'/%3E%3C/svg%3E");
  mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 15v-3a8 8 0 0 1 16 0v3'/%3E%3Cpath d='M4 15a2 2 0 0 1 2-2h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1H6a2 2 0 0 1-2-2Z'/%3E%3Cpath d='M20 15a2 2 0 0 0-2-2h-1a1 1 0 0 0-1 1v3a1 1 0 0 0 1 1h1a2 2 0 0 0 2-2Z'/%3E%3Cpath d='M18 18v1a2 2 0 0 1-2 2h-3'/%3E%3C/svg%3E");
  -webkit-mask-repeat:no-repeat;-webkit-mask-position:center;-webkit-mask-size:contain;
  mask-repeat:no-repeat;mask-position:center;mask-size:contain;
  transition:background-color .2s ease;
}
.bottomnav .navitem.active .support-fab{
  background:var(--g-accent);
}

@media(min-width:701px){
  .bottomnav{
    left:50%;right:auto;transform:translateX(-50%);
    width:min(620px,100%);
    bottom:0;
    border-radius:20px 20px 0 0;
  }
}
@media(min-width:1024px){
  .bottomnav{
    width:min(480px,100%);
  }
}

/* ---------- 4. Global Footer ---------- */
.app-footer.global-footer{
  text-align:center;
  font-size:10.5px;
  color:var(--g-muted);
  padding:18px 16px calc(130px + var(--safe-bottom));
  margin-top:8px;
}
/* When a page already renders its own .app-footer above the nav (e.g. index.html),
   don't add the huge bottom gap twice — body already reserves 96px of bottom
   padding for the fixed bottomnav (see the body rule above), so the footer
   itself only needs a small closing gap, not another full nav-height reserve. */
.phone .app-footer.global-footer,
.screen .app-footer.global-footer{
  padding-bottom:calc(14px + var(--safe-bottom));
}

/* ---------- 5. Generic responsive shell ---------- */
/* Most pages set their own fixed max-width (e.g. 380-460px) inline in a
   <style> block that is placed AFTER this stylesheet in <head>, so on an
   unconditional (non-media-query) selector of equal specificity that inline
   rule always wins the cascade — even inside these @media blocks once they
   match. The !important flags below are required so the site actually
   widens on tablet/desktop instead of staying pinned to a narrow mobile
   column with large empty gutters either side. */
@media(min-width:701px){
  .phone,.screen{ max-width:620px !important; }
}
@media(min-width:1024px){
  .phone,.screen{ max-width:760px !important; padding-left:28px !important; padding-right:28px !important; }
}
@media(min-width:1440px){
  .phone,.screen{ max-width:860px !important; }
}

/* On wide viewports the centered column would otherwise float on a flat,
   empty background. Give desktop/tablet visitors a subtle backdrop so the
   page still feels intentional rather than "broken mobile layout". */
@media(min-width:701px){
  body{
    background:
      radial-gradient(60% 40% at 50% 0%, color-mix(in srgb, var(--g-accent) 6%, transparent), transparent 70%),
      var(--g-bg);
  }
}

/* Language switcher small helper (used on language-select.html trigger elsewhere too) */
.lang-toggle-btn{
  display:inline-flex;align-items:center;gap:6px;
  background:var(--g-surface);
  border:1px solid var(--g-border);
  color:var(--g-text);
  border-radius:10px;
  padding:8px 12px;
  font-size:12.5px;
  font-weight:700;
  cursor:pointer;
}
