/* ============================================================
   ALIEN THEME KIT  —  alien-theme.css
   One stylesheet for hub.aliensmokeshop.com and every app.
   Dark + Light modes, laptop + phone friendly.

   HOW IT WORKS
   - <html data-theme="dark">  or  data-theme="light"   (alien-theme.js sets this)
   - Every color below is a CSS variable. Apps use the variables,
     never hard-coded hex, so both modes "just work".
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=DM+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Syne:wght@800&display=swap');

/* ---------- 1. TOKENS ---------- */
:root {
  /* brand constants (same in both modes) */
  --alien-green:       #63FF9E;   /* neon accent on dark */
  --alien-green-logo:  #00E60B;   /* storefront / logo green */
  --alien-green-bar:   #00BD09;   /* progress bars */
  --alien-green-text:  #007806;   /* text-safe green on white */
  --void:              #050607;

  --font-head: 'Space Grotesk', 'DM Sans', system-ui, sans-serif;   /* app headings */
  --font-brand: 'Syne', 'Space Grotesk', system-ui, sans-serif;     /* hero / wordmark only */
  --font-body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 20px;
  --space:     16px;
  --nav-h:     60px;
  --content-max: 1200px;
  --transition: 160ms ease;
}

/* ---------- DARK (default) — softened, not pitch black ---------- */
:root,
[data-theme="dark"] {
  color-scheme: dark;

  --bg:            #0E1411;   /* page — dark green-grey, not void black */
  --bg-2:          #131A16;   /* subtle sections */
  --surface:       #1A2320;   /* cards, panels — clearly lighter than the page */
  --surface-2:     #232E29;   /* hover / nested cards / inputs */
  --surface-3:     #2D3A33;   /* active / selected */

  --text:          #F2F6F3;   /* main text */
  --text-2:        #C6D0CA;   /* secondary — still ~9:1 on cards */
  --text-3:        #97A49D;   /* muted / labels — ~5:1, never dimmer than this */

  --border:        rgba(242,246,243,0.16);   /* visible edges */
  --border-strong: rgba(242,246,243,0.30);

  --accent:        #63FF9E;   /* links, highlights, active tabs */
  --accent-strong: #3DF285;   /* hover */
  --accent-soft:   rgba(99,255,158,0.12);   /* tinted backgrounds */
  --accent-ring:   rgba(99,255,158,0.35);   /* focus ring */
  --on-accent:     #05240F;   /* text ON a green button */

  --success:       #63FF9E;
  --warning:       #FFC857;
  --danger:        #FF6B6B;
  --info:          #7DD3FC;
  --success-soft:  rgba(99,255,158,0.12);
  --warning-soft:  rgba(255,200,87,0.14);
  --danger-soft:   rgba(255,107,107,0.14);
  --info-soft:     rgba(125,211,252,0.14);

  --shadow:        0 8px 28px rgba(0,0,0,0.55);
  --shadow-sm:     0 2px 10px rgba(0,0,0,0.40);
  --glow:          0 0 0 1.5px rgba(99,255,158,0.45), 0 0 24px rgba(99,255,158,0.15);
}
/* dark-mode readability: lifted cards, clear edges, no dim text */
[data-theme="dark"] .a-card,
[data-theme="dark"] .a-tile,
[data-theme="dark"] .a-stat,
[data-theme="dark"] .a-table-wrap { border: 1px solid var(--border); box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.04); }
[data-theme="dark"] .a-table th { background: var(--surface-2); color: var(--text-2); border-bottom: 1.5px solid var(--border-strong); }
[data-theme="dark"] .a-input, [data-theme="dark"] .a-select, [data-theme="dark"] .a-textarea { background: var(--bg-2); border-color: var(--border-strong); }
[data-theme="dark"] .a-badge { border: 1px solid rgba(242,246,243,0.10); }
[data-theme="dark"] small, [data-theme="dark"] .muted { color: var(--text-3); }

/* ---------- READABILITY FLOOR (both modes) ----------
   Apps that used 11–12px labels get lifted. Nothing under 13px, body never under 15px. */
body { font-size: clamp(15px, 0.95rem + 0.1vw, 16.5px); }
small, .small, .muted, .a-badge, .a-table th, .a-stat .label, .a-label, .a-tabbar a { font-size: max(0.8rem, 13px); }
.a-table { font-size: max(0.95rem, 15px); }
.a-tile p, .a-card p { font-size: max(0.94rem, 15px); }
.a-nav .a-links a { font-size: max(0.95rem, 15px); }

/* ---------- LIGHT — still green & alien, fully readable ---------- */
[data-theme="light"] {
  color-scheme: light;

  --bg:            #EDF3EF;   /* a touch darker so white cards pop */
  --bg-2:          #E2EBE5;
  --surface:       #FFFFFF;
  --surface-2:     #F1F6F2;
  --surface-3:     #DDEBE1;

  --text:          #0F1210;
  --text-2:        #3E4842;
  --text-3:        #5E6962;

  --border:        rgba(15,18,16,0.22);   /* bolder outlines */
  --border-strong: rgba(15,18,16,0.38);

  --accent:        #007806;   /* text-safe green */
  --accent-strong: #005E04;
  --accent-soft:   rgba(0,189,9,0.12);
  --accent-ring:   rgba(0,120,6,0.30);
  --on-accent:     #FFFFFF;

  --success:       #007806;
  --warning:       #9A5B00;
  --danger:        #C62828;
  --info:          #0B6E99;
  --success-soft:  rgba(0,189,9,0.12);
  --warning-soft:  rgba(255,170,0,0.16);
  --danger-soft:   rgba(198,40,40,0.10);
  --info-soft:     rgba(11,110,153,0.10);

  --shadow:        0 10px 30px rgba(15,18,16,0.16), 0 2px 6px rgba(15,18,16,0.10);
  --shadow-sm:     0 3px 10px rgba(15,18,16,0.12), 0 1px 2px rgba(15,18,16,0.08);
  --glow:          0 0 0 2px rgba(0,120,6,0.45), 0 8px 24px rgba(0,120,6,0.18);
}
/* light-mode depth: thicker edges, real shadows, visible nav/table lines */
[data-theme="light"] .a-card,
[data-theme="light"] .a-tile,
[data-theme="light"] .a-stat,
[data-theme="light"] .a-table-wrap { border: 1.5px solid var(--border); box-shadow: var(--shadow-sm); }
[data-theme="light"] .a-tile:hover { box-shadow: var(--glow); border-color: var(--accent); }
[data-theme="light"] .a-tile .icon { background: #FFFFFF; color: var(--accent); border: 1.5px solid rgba(0,120,6,0.45); box-shadow: 0 2px 6px rgba(15,18,16,0.12); }
[data-theme="light"] .a-nav { border-bottom: 2px solid var(--border); box-shadow: 0 2px 10px rgba(15,18,16,0.08); }
[data-theme="light"] .a-btn { border-width: 1.5px; box-shadow: 0 1px 2px rgba(15,18,16,0.08); }
[data-theme="light"] .a-btn-primary { box-shadow: 0 3px 10px rgba(0,120,6,0.30); }
[data-theme="light"] .a-input, [data-theme="light"] .a-select, [data-theme="light"] .a-textarea { border-width: 1.5px; background: #FFFFFF; }
[data-theme="light"] .a-table th { background: var(--surface-3); color: var(--text-2); border-bottom: 2px solid var(--border-strong); }
[data-theme="light"] .a-table td { border-bottom-color: var(--border); }
[data-theme="light"] .a-badge { border: 1px solid rgba(15,18,16,0.12); }
[data-theme="light"] .a-badge-green  { border-color: rgba(0,120,6,0.3); }
[data-theme="light"] .a-badge-yellow { border-color: rgba(154,91,0,0.3); }
[data-theme="light"] .a-badge-red    { border-color: rgba(198,40,40,0.3); }
[data-theme="light"] .a-badge-blue   { border-color: rgba(11,110,153,0.3); }
[data-theme="light"] .a-chip { background: #FFFFFF; border: 1.5px solid var(--border); box-shadow: 0 1px 2px rgba(15,18,16,0.08); }
[data-theme="light"] .a-theme-toggle { background: #FFFFFF; border: 1.5px solid var(--border); }
[data-theme="light"] .a-theme-toggle button[aria-pressed="true"] { background: var(--accent-soft); }
[data-theme="light"] .a-tabs { border-bottom-width: 2px; }
[data-theme="light"] .a-tabs button.active { border-bottom-width: 3px; }
[data-theme="light"] .a-alert { border: 1.5px solid var(--border); }
[data-theme="light"] .a-alert-green  { border-color: rgba(0,120,6,0.35); }
[data-theme="light"] .a-alert-yellow { border-color: rgba(154,91,0,0.35); }
[data-theme="light"] .a-alert-red    { border-color: rgba(198,40,40,0.35); }
[data-theme="light"] .a-progress { background: var(--surface-3); border: 1px solid var(--border); }

/* Follow the phone/laptop system setting when the user hasn't chosen. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) { color-scheme: light; }
}

/* ---------- 2. BASE ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 700; letter-spacing: -0.01em; margin: 0 0 .4em; line-height: 1.15; }
.a-brand-hero, .a-brand { font-family: var(--font-brand); font-weight: 800; }   /* Syne only here */
h1 { font-size: clamp(1.6rem, 2.5vw + 1rem, 2.4rem); }
h2 { font-size: clamp(1.3rem, 1.5vw + .9rem, 1.7rem); }
h3 { font-size: 1.15rem; }
p  { margin: 0 0 1em; color: var(--text-2); }
a  { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: underline; }
small, .muted { color: var(--text-3); }
code, .mono { font-family: var(--font-mono); font-size: .9em; background: var(--surface-2); padding: .1em .4em; border-radius: 6px; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--space) 0; }
img, svg, video { max-width: 100%; height: auto; }
:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); border-radius: var(--radius-sm); }
::selection { background: var(--accent-soft); }

/* ---------- 3. LAYOUT ---------- */
.a-container { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 0 var(--space); }
.a-grid { display: grid; gap: var(--space); grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.a-stack { display: flex; flex-direction: column; gap: var(--space); }
.a-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.a-spacer { flex: 1; }

/* ---------- 4. NAV BAR ---------- */
.a-nav {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 var(--space);
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.a-nav .a-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-brand); font-weight: 800; font-size: 1.05rem; color: var(--text); white-space: nowrap; }
.a-nav .a-brand img, .a-nav .a-brand svg { width: 30px; height: 30px; border-radius: 8px; }
.a-nav .a-brand .dot { color: var(--accent); }
.a-nav .a-links { display: flex; gap: 4px; margin-left: 8px; }
.a-nav .a-links a { padding: 7px 12px; border-radius: 999px; color: var(--text-2); font-weight: 500; }
.a-nav .a-links a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.a-nav .a-links a.active { background: var(--accent-soft); color: var(--accent); }

/* ---------- 5. BUTTONS ---------- */
.a-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.a-btn:hover { background: var(--surface-2); text-decoration: none; }
.a-btn:active { transform: translateY(1px); }
.a-btn-primary { background: var(--accent); border-color: transparent; color: var(--on-accent); }
.a-btn-primary:hover { background: var(--accent-strong); color: var(--on-accent); }
.a-btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.a-btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.a-btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.a-btn-sm { min-height: 34px; padding: 0 12px; font-size: .9rem; }
.a-btn-icon { width: 42px; padding: 0; }
.a-btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- 6. CARDS & TILES ---------- */
.a-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
}
.a-card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.a-tile {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; color: var(--text);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.a-tile:hover { transform: translateY(-2px); box-shadow: var(--glow); border-color: var(--accent-ring); text-decoration: none; }
.a-tile .icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 1.3rem; }
.a-tile h3 { margin: 0; }
.a-tile p { margin: 0; font-size: .92rem; }
.a-tile .foot { margin-top: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- 7. FORMS ---------- */
.a-label { display: block; font-size: .85rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.a-input, .a-select, .a-textarea {
  width: 100%; min-height: 44px; padding: 10px 14px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: inherit; font-size: 16px; /* 16px stops iOS auto-zoom */
}
.a-input:focus, .a-select:focus, .a-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); outline: none; }
.a-input::placeholder { color: var(--text-3); }
.a-textarea { min-height: 110px; resize: vertical; }
.a-select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.a-field { margin-bottom: 14px; }
.a-switch { position: relative; width: 46px; height: 26px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); cursor: pointer; transition: background var(--transition); flex: none; }
.a-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-2); transition: transform var(--transition), background var(--transition); }
.a-switch[aria-checked="true"] { background: var(--accent); border-color: transparent; }
.a-switch[aria-checked="true"]::after { transform: translateX(20px); background: var(--on-accent); }

/* ---------- 8. BADGES / CHIPS / ALERTS ---------- */
.a-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; background: var(--surface-3); color: var(--text-2); }
.a-badge-green  { background: var(--success-soft); color: var(--success); }
.a-badge-yellow { background: var(--warning-soft); color: var(--warning); }
.a-badge-red    { background: var(--danger-soft);  color: var(--danger); }
.a-badge-blue   { background: var(--info-soft);    color: var(--info); }
.a-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: .9rem; }
.a-alert { padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); display: flex; gap: 10px; }
.a-alert-green  { background: var(--success-soft); border-color: transparent; color: var(--text); }
.a-alert-yellow { background: var(--warning-soft); border-color: transparent; }
.a-alert-red    { background: var(--danger-soft);  border-color: transparent; }

/* ---------- 9. TABLES (scroll sideways on phones) ---------- */
.a-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.a-table { width: 100%; border-collapse: collapse; min-width: 560px; font-size: .95rem; }
.a-table th, .a-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.a-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); background: var(--bg-2); position: sticky; top: 0; }
.a-table tr:last-child td { border-bottom: 0; }
.a-table tbody tr:hover td { background: var(--surface-2); }
.a-table .num { text-align: right; }
.a-table, .a-stat .value, .num, .mono { font-variant-numeric: tabular-nums; }

/* ---------- 10. STATS / PROGRESS ---------- */
.a-stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.a-stat .label { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.a-stat .value { font-family: var(--font-head); font-weight: 800; font-size: 1.8rem; line-height: 1.1; margin-top: 4px; }
.a-stat .delta { font-size: .85rem; color: var(--success); }
.a-progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.a-progress > span { display: block; height: 100%; background: var(--alien-green-bar); border-radius: 999px; }
[data-theme="dark"] .a-progress > span { background: var(--accent); }

/* ---------- 11. TABS ---------- */
.a-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.a-tabs::-webkit-scrollbar { display: none; }
.a-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap; margin-bottom: -1px; }
.a-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- 12. THEME TOGGLE + INSTALL (rendered by alien-theme.js) ---------- */
.a-theme-toggle { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.a-theme-toggle button { border: 0; background: transparent; color: var(--text-3); width: 34px; height: 30px; border-radius: 999px; cursor: pointer; display: grid; place-items: center; font-size: 15px; }
.a-theme-toggle button[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.a-install-btn { display: none; }
.a-install-btn.show { display: inline-flex; }

/* install sheet (iOS / Safari instructions) */
.a-sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 90; display: none; }
.a-sheet { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(520px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); z-index: 91; display: none; box-shadow: var(--shadow); }
.a-sheet.open, .a-sheet-backdrop.open { display: block; }
.a-sheet ol { padding-left: 20px; color: var(--text-2); }
.a-sheet ol li { margin-bottom: 8px; }
@media (min-width: 720px) { .a-sheet { bottom: auto; top: 50%; transform: translate(-50%, -50%); border-radius: var(--radius-lg); } }

/* ---------- 13. RESPONSIVE ---------- */
@media (max-width: 720px) {
  :root { --space: 14px; --nav-h: 56px; }
  body { font-size: 15.5px; }
  .a-nav .a-links { display: none; }          /* hide inline links; apps use a menu/tab bar on phones */
  .a-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .a-card, .a-tile { padding: 16px; }
  .a-btn { min-height: 44px; }                /* thumb-size targets */
  .a-row > .a-btn { flex: 1 1 auto; }
}
@media (max-width: 420px) {
  .a-grid { grid-template-columns: 1fr 1fr; }
}
/* Bottom tab bar for phone apps (optional) */
.a-tabbar { display: none; }
@media (max-width: 720px) {
  .a-tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; display: flex; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .a-tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: .7rem; font-weight: 600; color: var(--text-3); }
  .a-tabbar a .ico { font-size: 1.25rem; }
  .a-tabbar a.active { color: var(--accent); }
  body.has-tabbar { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* Print: always light, no chrome */
@media print { :root { --bg:#fff; --surface:#fff; --text:#000; --text-2:#222; --border:#ccc; } .a-nav, .a-tabbar, .a-theme-toggle, .a-install-btn { display: none !important; } }

/* ---------- 14. VERSION CHIP ---------- */
.a-version { font-size: 12.5px; color: var(--text-3); letter-spacing: .02em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.a-version-fixed { position: fixed; left: 8px; right: auto; bottom: calc(4px + env(safe-area-inset-bottom)); z-index: 5; padding: 2px 7px; font-size: 11.5px; opacity: .75; border-radius: 999px; background: color-mix(in srgb, var(--surface) 85%, transparent); border: 1px solid var(--border); backdrop-filter: blur(8px); pointer-events: none; }
body.has-tabbar .a-version-fixed { bottom: calc(74px + env(safe-area-inset-bottom)); }
@media print { .a-version-fixed { display: none; } }
