/* ============================================================
   BYBEIT SUPPORT — Global Styles
   Apple-style design system with Bybeit brand
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Typography — matches get.bybeit exactly */
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  --font-text:    -apple-system, BlinkMacSystemFont, "SF Pro Text",    "Helvetica Neue", Arial, sans-serif;
  --font:         -apple-system, BlinkMacSystemFont, "SF Pro Text",    "Helvetica Neue", Arial,
                  "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Courier New", monospace;

  /* Text scale */
  --text-xs:   11px;
  --text-sm:   12px;
  --text-base: 14px;
  --text-md:   17px;
  --text-lg:   19px;
  --text-xl:   24px;
  --text-2xl:  28px;
  --text-3xl:  40px;
  --text-4xl:  56px;

  /* Colors — light mode, exact match to get.bybeit */
  --bg:               #F2F2F7;
  --bg-section:       #FFFFFF;
  --surface:          #FFFFFF;
  --surface-overlay:  rgba(255, 255, 255, 0.82);

  --bg-secondary:     #FFFFFF;
  --bg-tertiary:      #e8e8ed;
  --bg-hover:         rgba(0, 0, 0, 0.04);
  --bg-card:          #FFFFFF;

  --text-primary:     #1D1D1F;
  --text-secondary:   #6E6E73;
  --text-tertiary:    #AEAEB2;
  --text-placeholder: #AEAEB2;

  /* Divider — exact match */
  --divider:          rgba(0, 0, 0, 0.08);

  /* Bybeit brand green */
  --brand:            #03FF00;
  --brand-dark:       #00d400;
  --brand-subtle:     rgba(3, 255, 0, 0.08);
  --accent:           #03FF00;
  --accent-dim:       rgba(3, 255, 0, 0.14);

  /* Links */
  --link:             #0071e3;
  --link-hover:       #0077ed;

  /* Borders (alias to divider for compatibility) */
  --border:           rgba(0, 0, 0, 0.08);
  --border-strong:    rgba(0, 0, 0, 0.14);

  /* Shadows */
  --shadow-xs:  0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-sm:  0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md:  0 4px 16px rgba(0, 0, 0, 0.10);
  --shadow-lg:  0 8px 30px rgba(0, 0, 0, 0.12);
  --shadow-xl:  0 20px 60px rgba(0, 0, 0, 0.14);

  /* Radius — exact match to get.bybeit */
  --radius-xs:   4px;
  --radius-sm:   10px;
  --radius-md:   16px;
  --radius-lg:   22px;
  --radius-xl:   28px;
  --radius-full: 9999px;

  /* Nav — floating pill, exact match */
  --nav-height: 58px;
  --nav-top:    10px;

  /* Layout */
  --content-max:    980px;
  --content-wide:   1200px;
  --content-narrow: 740px;

  /* Transitions */
  --ease:          cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-out:      cubic-bezier(0, 0, 0.2, 1);
  --duration-fast: 100ms;
  --duration-base: 200ms;
  --duration-slow: 300ms;
}

/* Dark mode — exact match to get.bybeit */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:               #000000;
    --bg-section:       #1C1C1E;
    --surface:          #2C2C2E;
    --surface-overlay:  rgba(28, 28, 30, 0.82);

    --bg-secondary:     #1C1C1E;
    --bg-tertiary:      #2C2C2E;
    --bg-hover:         rgba(255, 255, 255, 0.06);
    --bg-card:          #1C1C1E;

    --text-primary:     #F5F5F7;
    --text-secondary:   #8E8E93;
    --text-tertiary:    #636366;
    --text-placeholder: #636366;

    --divider:          rgba(255, 255, 255, 0.1);
    --border:           rgba(255, 255, 255, 0.1);
    --border-strong:    rgba(255, 255, 255, 0.16);

    --brand-subtle:     rgba(3, 255, 0, 0.12);

    --link:             #2997ff;
    --link-hover:       #47a9ff;

    --shadow-xs:  0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-sm:  0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md:  0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg:  0 8px 30px rgba(0, 0, 0, 0.6);
    --shadow-xl:  0 20px 60px rgba(0, 0, 0, 0.7);
  }
}

html[data-theme="dark"] {
  --bg:               #000000;
  --bg-section:       #1C1C1E;
  --surface:          #2C2C2E;
  --surface-overlay:  rgba(28, 28, 30, 0.82);
  --bg-secondary:     #1C1C1E;
  --bg-tertiary:      #2C2C2E;
  --bg-hover:         rgba(255, 255, 255, 0.06);
  --bg-card:          #1C1C1E;
  --text-primary:     #F5F5F7;
  --text-secondary:   #8E8E93;
  --text-tertiary:    #636366;
  --text-placeholder: #636366;
  --divider:          rgba(255, 255, 255, 0.1);
  --border:           rgba(255, 255, 255, 0.1);
  --border-strong:    rgba(255, 255, 255, 0.16);
  --brand-subtle:     rgba(3, 255, 0, 0.12);
  --link:             #2997ff;
  --link-hover:       #47a9ff;
}

html[data-theme="light"] {
  --bg:               #F2F2F7;
  --bg-section:       #FFFFFF;
  --surface:          #FFFFFF;
  --surface-overlay:  rgba(255, 255, 255, 0.82);
  --bg-secondary:     #FFFFFF;
  --bg-tertiary:      #e8e8ed;
  --bg-hover:         rgba(0, 0, 0, 0.04);
  --bg-card:          #FFFFFF;
  --text-primary:     #1D1D1F;
  --text-secondary:   #6E6E73;
  --text-tertiary:    #AEAEB2;
  --text-placeholder: #AEAEB2;
  --divider:          rgba(0, 0, 0, 0.08);
  --border:           rgba(0, 0, 0, 0.08);
  --border-strong:    rgba(0, 0, 0, 0.14);
  --brand-subtle:     rgba(3, 255, 0, 0.08);
  --link:             #0071e3;
  --link-hover:       #0077ed;
}

/* ── Base HTML ────────────────────────────────────────────── */
html {
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease);
}

a:hover {
  color: var(--link-hover);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button {
  font-family: var(--font);
  cursor: pointer;
  border: none;
  background: none;
  outline: none;
}

/* ── Navigation Bar — floating pill, 1:1 with get.bybeit ──── */

/* Spacer so content doesn't hide under the fixed nav */
.nav-spacer {
  height: calc(env(safe-area-inset-top, 0px) + var(--nav-height) + var(--nav-top) + 10px);
  flex-shrink: 0;
}

.nav {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + var(--nav-top));
  left: 12px;
  right: 12px;
  height: var(--nav-height);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--surface-overlay);
  backdrop-filter: blur(24px) saturate(200%);
  -webkit-backdrop-filter: blur(24px) saturate(200%);
  border-radius: 20px;
  border: 1px solid var(--divider);
}

/* Logo */
.nav__logo {
  display: flex;
  align-items: center;
  height: 28px;
  text-decoration: none;
  flex-shrink: 0;
}

.nav__logo-img {
  height: 28px;
  width: auto;
  display: block;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
}

/* Nav center search — hidden by default, shown only on wide desktop */
.nav__center-search {
  display: none;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 480px;
}

@media (min-width: 961px) {
  .nav__center-search {
    display: block;
  }
}

.nav__search-row {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--divider);
  background: transparent;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.nav__center-search:focus-within .nav__search-row {
  border-color: var(--link);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

.nav__search-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  color: var(--text-tertiary);
}

.nav__search-icon ion-icon {
  font-size: 14px;
}

.nav__search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--text-primary);
  min-width: 0;
  font-family: var(--font);
}

.nav__search-input::placeholder {
  color: var(--text-placeholder);
}

/* Nav search results dropdown */
.nav-search-results {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 480px;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  z-index: 300;
}

.nav-search-results.is-visible {
  display: block;
}

.nav-search-results .search-results__list {
  list-style: none;
  padding: 6px;
}

.nav-search-results .search-results__item a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-primary);
  transition: background-color var(--duration-fast) var(--ease);
}

.nav-search-results .search-results__item a:hover {
  background-color: var(--bg-hover);
}

.nav-search-results .search-results__item-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  background-color: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.nav-search-results .search-results__item-text {
  flex: 1;
  min-width: 0;
}

.nav-search-results .search-results__item-title {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.nav-search-results .search-results__item-title mark {
  background: none;
  color: var(--link);
  font-weight: 600;
}

.nav-search-results .search-results__item-category {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: 2px;
  display: block;
}

.nav-search-results .search-results__empty {
  padding: 20px 16px;
  text-align: center;
  font-size: var(--text-base);
  color: var(--text-secondary);
}

.nav-search-results .search-results__footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-align: center;
}

/* Right actions */
.nav__right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Icon button (theme toggle, search) — exact match */
.nav__icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  border: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav__icon-btn:hover {
  background: var(--bg-section);
  color: var(--text-primary);
}

.nav__icon-btn ion-icon {
  font-size: 18px;
}

/* Search button — mobile only */
.nav__search-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  border: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav__search-btn:hover {
  background: var(--bg-section);
  color: var(--text-primary);
}

.nav__search-btn ion-icon {
  font-size: 18px;
}

/* App link — matches get.bybeit "Connect" button style */
.nav__app-link {
  display: none;
}

@media (min-width: 960px) {
  .nav__app-link {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 34px;
    padding: 0 13px;
    border-radius: var(--radius-full);
    font-family: var(--font-display);
    font-size: var(--text-base);
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--divider);
    text-decoration: none;
    transition: border-color 0.15s ease, color 0.15s ease;
  }
  .nav__app-link:hover {
    border-color: var(--text-tertiary);
    color: var(--text-primary);
  }
}

/* Mobile menu toggle */
.nav__menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  border: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav__menu-toggle:hover {
  background: var(--bg-section);
  color: var(--text-primary);
}

.nav__menu-toggle ion-icon {
  font-size: 22px;
}

/* Mobile drawer */
.nav__mobile-menu {
  display: none;
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + var(--nav-top) + var(--nav-height) + 8px);
  left: 12px;
  right: 12px;
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 20px;
  z-index: 199;
  overflow: hidden;
  padding: 8px 0;
  flex-direction: column;
}

.nav__mobile-menu.is-open {
  display: flex;
}

.nav__mobile-menu a {
  display: block;
  padding: 13px 20px;
  font-size: 17px;
  font-weight: 400;
  color: var(--text-primary);
  text-decoration: none;
  transition: background 0.1s ease;
}

.nav__mobile-menu a:hover {
  background: var(--bg-hover);
}

.nav__mobile-menu a + a {
  border-top: 1px solid var(--divider);
}

.nav__mobile-menu .nav__app-link-mobile {
  display: flex;
  margin: 8px 16px 8px;
  padding: 11px 16px;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #000 !important;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  border: none;
}

/* ── Footer ───────────────────────────────────────────────── */
.footer {
  margin-top: auto;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.footer__inner {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: 28px 22px 28px;
}

.footer__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 32px 40px;
}

.footer__col-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  letter-spacing: 0.1px;
}

.footer__col ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer__col ul li a {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease);
  line-height: 1.4;
}

.footer__col ul li a:hover {
  color: var(--link);
}

.footer__bottom {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  padding-top: 0;
}

.footer__logo {
  height: 36px;
  width: auto;
  display: block;
}

.footer__bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  flex-wrap: wrap;
  gap: 12px;
}

.footer__copyright {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  line-height: 1.6;
}

.footer__bottom-links {
  display: flex;
  gap: 20px;
  list-style: none;
  flex-wrap: wrap;
}

.footer__bottom-links a {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease);
}

.footer__bottom-links a:hover {
  color: var(--link);
}

/* ── Theme toggle icon animation — exact match to get.bybeit ─ */
@keyframes theme-icon-in {
  from { transform: rotate(-45deg) scale(0.5); opacity: 0; }
  to   { transform: rotate(0deg)   scale(1);   opacity: 1; }
}

.theme-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: theme-icon-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ── Utility classes ──────────────────────────────────────── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 960px) {
  .nav__search-btn {
    display: flex;
  }
}

@media (max-width: 768px) {
  .footer__grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 28px 24px;
  }
}

@media (max-width: 480px) {
  .footer__grid {
    grid-template-columns: 1fr 1fr;
    gap: 24px 16px;
  }

  .footer__bottom-row {
    flex-direction: column;
    align-items: flex-start;
  }
}
