/* ━━━ FlipForge Design System ━━━ */
/* Native System Font Stack (Offline Ready) */

/* ── Color Tokens ── */
:root {
  --brand: #6366f1;
  --brand-dark: #4f46e5;
  --brand-light: #e0e7ff;
  --brand-glow: rgba(99,102,241,0.25);
  --fg: #0f0f10;
  --fg-muted: #6b7280;
  --fg-subtle: #9ca3af;
  --bg: #ffffff;
  --bg-surface: #f9fafb;
  --bg-elevated: #f3f4f6;
  --border: rgba(0,0,0,0.08);
  --border-strong: rgba(0,0,0,0.15);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.14);
  --shadow-glow: 0 0 30px var(--brand-glow);
  --flip-speed: 0.65s;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --nav-h: 64px;
  --sidebar-w: 240px;
  --panel-w: 280px;
}

/* ── Dark Mode ── */
[data-theme="dark"] {
  --fg: #f0f0f2;
  --fg-muted: #9ca3af;
  --fg-subtle: #6b7280;
  --bg: #0f0f14;
  --bg-surface: #16161d;
  --bg-elevated: #1e1e28;
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.15);
  --brand-light: rgba(99,102,241,0.15);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.7;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
img, video, svg { display: block; max-width: 100%; }
a { color: var(--brand); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--brand-dark); }
ul, ol { list-style: none; }
button, input, select, textarea {
  font: inherit; color: inherit; border: none; outline: none; background: none;
}
button { cursor: pointer; }
::selection { background: var(--brand); color: #fff; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 2px; }

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 { font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; color: var(--fg); }
h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 3.5vw, 2.25rem); }
h3 { font-size: clamp(1.15rem, 2.5vw, 1.5rem); }
h4 { font-size: 1.15rem; }
p { color: var(--fg-muted); }
.fb-text-sm { font-size: 0.85rem; }
.fb-text-xs { font-size: 0.75rem; }
.fb-text-lg { font-size: 1.15rem; }
.fb-text-gradient {
  background: linear-gradient(135deg, var(--brand), #a78bfa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Layout Utilities ── */
.fb-container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.fb-container--sm { max-width: 720px; }
.fb-container--lg { max-width: 1400px; }
.fb-section { padding: 80px 0; }
.fb-section--lg { padding: 120px 0; }
.fb-grid { display: grid; gap: 24px; }
.fb-grid--2 { grid-template-columns: repeat(2, 1fr); }
.fb-grid--3 { grid-template-columns: repeat(3, 1fr); }
.fb-grid--4 { grid-template-columns: repeat(4, 1fr); }
.fb-flex { display: flex; align-items: center; gap: 12px; }
.fb-flex--between { justify-content: space-between; }
.fb-flex--center { justify-content: center; }
.fb-flex--col { flex-direction: column; align-items: stretch; }
.fb-text-center { text-align: center; }

@media (max-width: 1024px) {
  .fb-grid--3, .fb-grid--4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .fb-grid--2, .fb-grid--3, .fb-grid--4 { grid-template-columns: 1fr; }
  .fb-section { padding: 48px 0; }
  .fb-section--lg { padding: 72px 0; }
  .fb-container { padding: 0 16px; }
}

/* ── Buttons ── */
.fb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 22px; border-radius: var(--radius-md); font-weight: 500;
  font-size: 0.9rem; transition: all 0.25s var(--ease-out); white-space: nowrap;
  position: relative; overflow: hidden;
}
.fb-btn::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(rgba(255,255,255,0.15), transparent);
  opacity: 0; transition: opacity 0.25s;
}
.fb-btn:hover::after { opacity: 1; }
.fb-btn--primary {
  background: var(--brand); color: #fff; box-shadow: var(--shadow-sm), 0 0 0 0 var(--brand-glow);
}
.fb-btn--primary:hover {
  background: var(--brand-dark); transform: translateY(-1px);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}
.fb-btn--ghost {
  border: 1px solid var(--border-strong); color: var(--fg); background: transparent;
}
.fb-btn--ghost:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }
.fb-btn--sm { padding: 6px 14px; font-size: 0.8rem; border-radius: var(--radius-sm); }
.fb-btn--lg { padding: 14px 32px; font-size: 1rem; border-radius: var(--radius-lg); }
.fb-btn--icon {
  width: 36px; height: 36px; padding: 0; border-radius: var(--radius-sm);
  border: 1px solid var(--border); color: var(--fg-muted);
}
.fb-btn--icon:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }
.fb-btn--danger { background: var(--danger); color: #fff; }

/* ── Cards ── */
.fb-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 28px; transition: all 0.35s var(--ease-out);
}
.fb-card:hover { border-color: var(--brand); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.fb-card__icon {
  width: 44px; height: 44px; border-radius: var(--radius-md); display: flex;
  align-items: center; justify-content: center; background: var(--brand-light);
  color: var(--brand); margin-bottom: 16px;
}
.fb-card__icon svg { width: 22px; height: 22px; }
.fb-card__title { font-size: 1.05rem; font-weight: 600; margin-bottom: 8px; }
.fb-card__text { font-size: 0.9rem; color: var(--fg-muted); line-height: 1.6; }

/* ── Inputs ── */
.fb-input {
  width: 100%; padding: 10px 14px; background: var(--bg-surface);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  font-size: 0.9rem; transition: all 0.2s;
}
.fb-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.fb-input--sm { padding: 6px 10px; font-size: 0.8rem; }
.fb-textarea { min-height: 80px; resize: vertical; }
.fb-select { appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.fb-label { display: block; font-size: 0.8rem; font-weight: 500; margin-bottom: 6px; color: var(--fg); }
.fb-field { margin-bottom: 16px; }
.fb-toggle { position: relative; width: 40px; height: 22px; cursor: pointer; }
.fb-toggle input { display: none; }
.fb-toggle__track {
  position: absolute; inset: 0; background: var(--bg-elevated);
  border: 1px solid var(--border-strong); border-radius: 11px; transition: all 0.25s;
}
.fb-toggle input:checked + .fb-toggle__track { background: var(--brand); border-color: var(--brand); }
.fb-toggle__thumb {
  position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  background: #fff; border-radius: 50%; transition: transform 0.25s var(--ease-spring);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.fb-toggle input:checked ~ .fb-toggle__thumb { transform: translateX(18px); }

/* ── Badge ── */
.fb-badge {
  display: inline-flex; align-items: center; padding: 4px 12px;
  border-radius: 20px; font-size: 0.75rem; font-weight: 500;
  background: var(--brand-light); color: var(--brand); gap: 6px;
}
.fb-badge--success { background: #dcfce7; color: #16a34a; }
[data-theme="dark"] .fb-badge--success { background: rgba(34,197,94,0.15); }

/* ── Modal ── */
.fb-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transition: all 0.3s var(--ease-out);
}
.fb-modal-overlay.is-active { opacity: 1; visibility: visible; }
.fb-modal {
  background: var(--bg); border-radius: var(--radius-xl); padding: 32px;
  max-width: 520px; width: 90%; max-height: 85vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); transform: translateY(20px) scale(0.97);
  transition: transform 0.35s var(--ease-out);
}
.fb-modal-overlay.is-active .fb-modal { transform: translateY(0) scale(1); }
.fb-modal__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.fb-modal__title { font-size: 1.2rem; font-weight: 600; }
.fb-modal__close {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); color: var(--fg-muted); transition: all 0.2s;
}
.fb-modal__close:hover { background: var(--bg-elevated); color: var(--fg); }

/* ── Tabs ── */
.fb-tabs { display: flex; border-bottom: 1px solid var(--border); gap: 0; }
.fb-tab {
  padding: 10px 16px; font-size: 0.8rem; font-weight: 500; color: var(--fg-muted);
  border-bottom: 2px solid transparent; transition: all 0.2s; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
}
.fb-tab:hover { color: var(--fg); }
.fb-tab.is-active { color: var(--brand); border-bottom-color: var(--brand); }
.fb-tab-panel { display: none; padding: 16px 0; }
.fb-tab-panel.is-active { display: block; }

/* ── Tooltip ── */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip); position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%); padding: 4px 10px; background: var(--fg);
  color: var(--bg); font-size: 0.7rem; border-radius: var(--radius-sm);
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ── Navbar (shared) ── */
.fb-nav {
  position: fixed; top: 0; left: 0; right: 0; height: var(--nav-h); z-index: 100;
  display: flex; align-items: center; padding: 0 24px;
  background: rgba(255,255,255,0.8); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); transition: all 0.3s;
}
[data-theme="dark"] .fb-nav { background: rgba(15,15,20,0.85); }
.fb-nav.is-scrolled { box-shadow: var(--shadow-sm); }
.fb-nav__inner { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 1200px; margin: 0 auto; }
.fb-nav__logo { display: flex; align-items: center; gap: 8px; font-size: 1.2rem; font-weight: 700; color: var(--fg); }
.fb-nav__logo svg { width: 28px; height: 28px; }
.fb-nav__links { display: flex; gap: 32px; }
.fb-nav__link { font-size: 0.9rem; font-weight: 450; color: var(--fg-muted); transition: color 0.2s; }
.fb-nav__link:hover, .fb-nav__link.is-active { color: var(--fg); }
.fb-nav__actions { display: flex; align-items: center; gap: 12px; }
.fb-nav__theme-btn {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); color: var(--fg-muted); transition: all 0.2s;
}
.fb-nav__theme-btn:hover { background: var(--bg-elevated); color: var(--fg); }
.fb-nav__hamburger { display: none; flex-direction: column; gap: 5px; width: 24px; cursor: pointer; }
.fb-nav__hamburger span { display: block; height: 2px; background: var(--fg); border-radius: 2px; transition: all 0.3s; }
.fb-nav__mobile { display: none; }

@media (max-width: 768px) {
  .fb-nav__links, .fb-nav__actions .fb-btn { display: none; }
  .fb-nav__hamburger { display: flex; }
  .fb-nav__mobile {
    position: fixed; top: var(--nav-h); left: 0; right: 0; bottom: 0;
    background: var(--bg); z-index: 99; padding: 24px;
    transform: translateY(-100%); opacity: 0; transition: all 0.35s var(--ease-out);
    pointer-events: none;
  }
  .fb-nav__mobile.is-open { display: block; transform: translateY(0); opacity: 1; pointer-events: all; }
  .fb-nav__mobile a { display: block; padding: 14px 0; font-size: 1.1rem; font-weight: 500; color: var(--fg); border-bottom: 1px solid var(--border); }
}

/* ── Footer (shared) ── */
.fb-footer {
  background: var(--bg-surface); border-top: 1px solid var(--border);
  padding: 64px 0 24px;
}
.fb-footer__grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 40px; margin-bottom: 48px; }
.fb-footer__brand { font-size: 1.1rem; font-weight: 700; color: var(--fg); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.fb-footer__tagline { font-size: 0.85rem; color: var(--fg-muted); max-width: 280px; }
.fb-footer__heading { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg); margin-bottom: 16px; }
.fb-footer__link { display: block; font-size: 0.85rem; color: var(--fg-muted); padding: 4px 0; transition: color 0.2s; }
.fb-footer__link:hover { color: var(--brand); }
.fb-footer__bottom { border-top: 1px solid var(--border); padding-top: 24px; display: flex; align-items: center; justify-content: space-between; }
.fb-footer__copy { font-size: 0.8rem; color: var(--fg-subtle); }
.fb-footer__socials { display: flex; gap: 12px; }
.fb-footer__socials a { color: var(--fg-muted); transition: color 0.2s; }
.fb-footer__socials a:hover { color: var(--brand); }

@media (max-width: 768px) {
  .fb-footer__grid { grid-template-columns: 1fr 1fr; }
  .fb-footer__bottom { flex-direction: column; gap: 12px; text-align: center; }
}
@media (max-width: 480px) {
  .fb-footer__grid { grid-template-columns: 1fr; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-subtle); }

/* ── Animations ── */
@keyframes fb-fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fb-slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fb-scaleIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes fb-spin { to { transform: rotate(360deg); } }
@keyframes fb-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes fb-marquee { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }

.fb-animate { animation: fb-fadeIn 0.6s var(--ease-out) both; }
.fb-animate--delay-1 { animation-delay: 0.1s; }
.fb-animate--delay-2 { animation-delay: 0.2s; }
.fb-animate--delay-3 { animation-delay: 0.3s; }
.fb-animate--delay-4 { animation-delay: 0.4s; }

/* ── Spinner ── */
.fb-spinner {
  width: 20px; height: 20px; border: 2px solid var(--border);
  border-top-color: var(--brand); border-radius: 50%;
  animation: fb-spin 0.6s linear infinite;
}

/* ── Color Picker wrapper ── */
.fb-color-picker { display: flex; align-items: center; gap: 10px; }
.fb-color-picker input[type="color"] {
  width: 36px; height: 36px; border: 2px solid var(--border); border-radius: var(--radius-sm);
  padding: 2px; cursor: pointer; background: none;
}
.fb-color-picker input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.fb-color-picker input[type="color"]::-webkit-color-swatch { border: none; border-radius: 3px; }

/* ── Slider ── */
.fb-slider { width: 100%; height: 4px; appearance: none; background: var(--bg-elevated); border-radius: 2px; outline: none; }
.fb-slider::-webkit-slider-thumb {
  appearance: none; width: 16px; height: 16px; background: var(--brand);
  border-radius: 50%; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* ── Accordion ── */
.fb-accordion { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.fb-accordion__item { border-bottom: 1px solid var(--border); }
.fb-accordion__item:last-child { border-bottom: none; }
.fb-accordion__trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; font-size: 0.95rem; font-weight: 500; color: var(--fg);
  text-align: left; cursor: pointer; transition: background 0.2s;
}
.fb-accordion__trigger:hover { background: var(--bg-surface); }
.fb-accordion__trigger svg { width: 18px; height: 18px; color: var(--fg-muted); transition: transform 0.3s var(--ease-out); flex-shrink: 0; }
.fb-accordion__item.is-open .fb-accordion__trigger svg { transform: rotate(180deg); }
.fb-accordion__content { max-height: 0; overflow: hidden; transition: max-height 0.4s var(--ease-out); }
.fb-accordion__body { padding: 0 24px 18px; font-size: 0.9rem; color: var(--fg-muted); line-height: 1.7; }

/* ── Dropdown ── */
.fb-dropdown { position: relative; }
.fb-dropdown__menu {
  position: absolute; top: calc(100% + 4px); right: 0; min-width: 180px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: 4px; z-index: 50;
  opacity: 0; transform: translateY(-4px); pointer-events: none;
  transition: all 0.2s var(--ease-out);
}
.fb-dropdown.is-open .fb-dropdown__menu { opacity: 1; transform: translateY(0); pointer-events: all; }
.fb-dropdown__item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px;
  font-size: 0.85rem; color: var(--fg); border-radius: var(--radius-sm); transition: background 0.15s;
}
.fb-dropdown__item:hover { background: var(--bg-surface); }
.fb-dropdown__divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Toast ── */
.fb-toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.fb-toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); font-size: 0.85rem; min-width: 280px;
  animation: fb-slideUp 0.35s var(--ease-out);
}
.fb-toast--success { border-left: 3px solid var(--success); }
.fb-toast--error { border-left: 3px solid var(--danger); }
.fb-toast--info { border-left: 3px solid var(--info); }

/* ── Reading layout (privacy/policy pages) ── */
.fb-reading { max-width: 720px; margin: 0 auto; padding: calc(var(--nav-h) + 48px) 24px 80px; }
.fb-reading h1 { margin-bottom: 8px; }
.fb-reading .fb-reading__date { font-size: 0.85rem; color: var(--fg-subtle); margin-bottom: 40px; }
.fb-reading h2 { font-size: 1.35rem; margin-top: 40px; margin-bottom: 12px; }
.fb-reading h3 { font-size: 1.1rem; margin-top: 24px; margin-bottom: 8px; }
.fb-reading p { margin-bottom: 16px; font-size: 1.05rem; line-height: 1.8; }
.fb-reading ul { margin-bottom: 16px; padding-left: 24px; }
.fb-reading ul li { position: relative; padding-left: 16px; margin-bottom: 8px; color: var(--fg-muted); font-size: 1.05rem; }
.fb-reading ul li::before { content: ''; position: absolute; left: 0; top: 10px; width: 5px; height: 5px; background: var(--brand); border-radius: 50%; }
.fb-reading a { color: var(--brand); text-decoration: underline; }
.fb-btn--icon svg {
  margin: 9px; transition: all 0.2s;
}
