/* ============================================================
   TWINE — assets/css/main.css
   Global design tokens + shared components.
   Loaded on every page.
============================================================ */

/* ─── Google Fonts ───────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,400;0,9..144,600;0,9..144,700;1,9..144,300;1,9..144,400;1,9..144,600&family=Inter:wght@300;400;500;600;700&display=swap');

/* ─── Design Tokens ──────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg:        #08080F;
  --surface:   #0F0F1A;
  --surface2:  #161625;
  --surface3:  #1D1D30;
  --surface4:  #252540;

  /* Brand */
  --rose:      #D4607A;
  --rose-h:    #E07A92;
  --rose-dim:  rgba(212,96,122,0.12);
  --rose-bd:   rgba(212,96,122,0.22);
  --gold:      #B8924A;
  --gold-h:    #D4A95A;
  --gold-dim:  rgba(184,146,74,0.12);
  --gold-bd:   rgba(184,146,74,0.25);
  --success:   #5CC89A;
  --danger:    #E05C5C;
  --warn:      #D4A84A;

  /* Text */
  --t1: #EDE8FF;
  --t2: #8C889E;
  --t3: #48445A;

  /* Borders */
  --bd:  rgba(255,255,255,0.06);
  --bd2: rgba(255,255,255,0.10);
  --bd3: rgba(255,255,255,0.15);

  /* Radii */
  --r1:    6px;
  --r2:    12px;
  --r3:    18px;
  --r4:    28px;
  --rpill: 999px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.5);
  --shadow-rose: 0 8px 28px rgba(212,96,122,0.25);

  /* Spacing scale (8px base) */
  --sp1:  4px;
  --sp2:  8px;
  --sp3:  12px;
  --sp4:  16px;
  --sp5:  24px;
  --sp6:  32px;
  --sp7:  48px;
  --sp8:  64px;
  --sp9:  96px;

  /* Transitions */
  --ease: 200ms ease;
  --ease-slow: 350ms ease;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--t1);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100svh;
}

/* Grain overlay */
body::after {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  opacity: 0.025;
  pointer-events: none;
  z-index: 9999;
}

img, video { max-width: 100%; display: block; }
a { color: var(--rose); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
ul, ol { list-style: none; }

/* ─── Typography ─────────────────────────────────────────── */
.serif { font-family: 'Fraunces', Georgia, serif; }

.t-display {
  font-family: 'Fraunces', serif;
  font-size: clamp(38px, 6vw, 72px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -2px;
}
.t-display em { font-style: italic; font-weight: 300; color: var(--rose); }

.t-h1 {
  font-family: 'Fraunces', serif;
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -1px;
}
.t-h1 em { font-style: italic; font-weight: 300; color: var(--rose); }

.t-h2 {
  font-family: 'Fraunces', serif;
  font-size: clamp(20px, 2.5vw, 28px);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.5px;
}
.t-h2 em { font-style: italic; font-weight: 300; color: var(--rose); }

.t-body   { font-size: 15px; line-height: 1.65; color: var(--t2); }
.t-small  { font-size: 13px; color: var(--t2); }
.t-tiny   { font-size: 11px; color: var(--t3); }
.t-muted  { color: var(--t2); }
.t-rose   { color: var(--rose); }
.t-gold   { color: var(--gold); }
.t-white  { color: var(--t1); }

.label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--rose);
  display: flex;
  align-items: center;
  gap: 8px;
}
.label::before {
  content: '';
  display: inline-block;
  width: 18px; height: 1px;
  background: currentColor;
  flex-shrink: 0;
}
.label--gold { color: var(--gold); }
.label--muted { color: var(--t3); }

/* ─── Layout ─────────────────────────────────────────────── */
.wrap        { max-width: 1080px; margin: 0 auto; padding: 0 28px; position: relative; z-index: 2; }
.wrap--mid   { max-width: 800px; }
.wrap--narrow{ max-width: 580px; }

.divider {
  max-width: 1080px;
  margin: 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--bd2) 30%, var(--bd2) 70%, transparent);
}

.section { padding: 80px 0; }
.section--lg { padding: 100px 0; }

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--ease);
  white-space: nowrap;
  border-radius: var(--r2);
  line-height: 1;
  position: relative;
  overflow: hidden;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* Sizes */
.btn--lg  { font-size: 15px; padding: 14px 28px; border-radius: var(--r2); }
.btn--md  { font-size: 14px; padding: 11px 22px; }
.btn--sm  { font-size: 13px; padding: 8px 16px;  border-radius: var(--r1); }
.btn--xs  { font-size: 12px; padding: 6px 12px;  border-radius: var(--r1); }
.btn--full{ width: 100%; }

/* Variants */
.btn--primary {
  background: var(--rose);
  color: #fff;
}
.btn--primary:hover {
  background: var(--rose-h);
  transform: translateY(-2px);
  box-shadow: var(--shadow-rose);
}

.btn--gold {
  background: var(--gold);
  color: #fff;
}
.btn--gold:hover {
  background: var(--gold-h);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(184,146,74,0.3);
}

.btn--ghost {
  background: transparent;
  color: var(--t2);
  border: 1px solid var(--bd2);
}
.btn--ghost:hover {
  border-color: var(--rose-bd);
  color: var(--t1);
}

.btn--danger {
  background: rgba(224,92,92,0.15);
  color: var(--danger);
  border: 1px solid rgba(224,92,92,0.25);
}
.btn--danger:hover { background: rgba(224,92,92,0.25); }

.btn--text {
  background: transparent;
  color: var(--rose);
  padding: 0;
  border-radius: 0;
}
.btn--text:hover { opacity: 0.8; }

/* Loading spinner inside button */
.btn.loading { pointer-events: none; }
.btn.loading::after {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  margin-left: 4px;
}

/* ─── Form elements ──────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp4); }
.form-group:last-child { margin-bottom: 0; }

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--t2);
  letter-spacing: 0.2px;
}
.form-label span { color: var(--rose); margin-left: 2px; }

.form-input,
.form-textarea,
.form-select {
  background: var(--surface2);
  border: 1px solid var(--bd2);
  border-radius: var(--r2);
  color: var(--t1);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  transition: border-color var(--ease), box-shadow var(--ease);
  outline: none;
  width: 100%;
}
.form-input    { padding: 11px 14px; }
.form-textarea { padding: 12px 14px; resize: vertical; min-height: 100px; line-height: 1.6; }
.form-select   { padding: 11px 14px; appearance: none; cursor: pointer; }

.form-input::placeholder,
.form-textarea::placeholder { color: var(--t3); }

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--rose-bd);
  box-shadow: 0 0 0 3px rgba(212,96,122,0.08);
}

.form-input.error,
.form-textarea.error { border-color: var(--danger); }

.form-hint  { font-size: 12px; color: var(--t3); }
.form-error { font-size: 12px; color: var(--danger); }

/* Checkbox & radio */
.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--t2);
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 16px; height: 16px;
  accent-color: var(--rose);
  cursor: pointer;
  flex-shrink: 0;
}

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--bd);
  border-radius: var(--r3);
  padding: var(--sp5);
  transition: border-color var(--ease), transform var(--ease);
}
.card:hover { border-color: var(--bd2); }
.card--hover:hover { transform: translateY(-3px); }
.card--rose { border-color: var(--rose-bd); }
.card--gold { border-color: var(--gold-bd); }

/* ─── Badges / chips ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--rpill);
  padding: 3px 10px;
  white-space: nowrap;
}
.badge--rose   { background: var(--rose-dim);  border: 1px solid var(--rose-bd);  color: var(--rose-h); }
.badge--gold   { background: var(--gold-dim);  border: 1px solid var(--gold-bd);  color: var(--gold-h); }
.badge--green  { background: rgba(92,200,154,0.12); border: 1px solid rgba(92,200,154,0.25); color: var(--success); }
.badge--muted  { background: var(--surface3);  border: 1px solid var(--bd);       color: var(--t2); }
.badge--free   { background: var(--surface2);  border: 1px solid var(--bd2);      color: var(--t3); }
.badge--premium{ background: var(--rose-dim);  border: 1px solid var(--rose-bd);  color: var(--rose); }
.badge--forever{ background: var(--gold-dim);  border: 1px solid var(--gold-bd);  color: var(--gold); }

/* ─── Flash messages ─────────────────────────────────────── */
.flash {
  padding: 12px 16px;
  border-radius: var(--r2);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: var(--sp4);
  display: flex;
  align-items: center;
  gap: 10px;
}
.flash--success { background: rgba(92,200,154,0.12); border: 1px solid rgba(92,200,154,0.25); color: var(--success); }
.flash--error   { background: rgba(224,92,92,0.12);  border: 1px solid rgba(224,92,92,0.25);  color: var(--danger); }
.flash--info    { background: var(--rose-dim);        border: 1px solid var(--rose-bd);         color: var(--rose-h); }
.flash--warn    { background: var(--gold-dim);        border: 1px solid var(--gold-bd);         color: var(--gold-h); }

/* ─── Navigation (shared shell) ──────────────────────────── */
.nav {
  position: fixed; top: 0; left: 0; right: 0;
  height: 58px;
  background: rgba(8,8,15,0.80);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border-bottom: 1px solid var(--bd);
  z-index: 500;
  transition: box-shadow var(--ease);
}
.nav.scrolled { box-shadow: 0 4px 32px rgba(0,0,0,0.4); }

.nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 28px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp4);
}

.nav-logo {
  font-family: 'Fraunces', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--t1);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}
.nav-logo:hover { text-decoration: none; opacity: 0.9; }
.nav-logo-gem {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.nav-right { display: flex; align-items: center; gap: 8px; }

.nav-link {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--t2);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: var(--r1);
  transition: color var(--ease), background var(--ease);
}
.nav-link:hover { color: var(--t1); background: var(--surface2); text-decoration: none; }

/* ─── Modals ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border: 1px solid var(--bd2);
  border-radius: var(--r4);
  padding: 36px;
  width: 100%;
  max-width: 500px;
  max-height: 90svh;
  overflow-y: auto;
  transform: translateY(16px) scale(0.98);
  transition: transform 300ms ease;
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--sp5);
  gap: var(--sp4);
}
.modal-title {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--t1);
  letter-spacing: -0.4px;
}
.modal-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--bd);
  color: var(--t2);
  display: grid; place-items: center;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--ease);
}
.modal-close:hover { background: var(--surface3); color: var(--t1); }

/* ─── Empty state ────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: var(--sp9) var(--sp5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp3);
}
.empty-icon  { font-size: 40px; opacity: 0.6; }
.empty-title { font-family: 'Fraunces', serif; font-size: 20px; font-weight: 600; color: var(--t1); }
.empty-text  { font-size: 14px; color: var(--t2); max-width: 320px; line-height: 1.6; }

/* ─── Upgrade gate (shown to free users) ─────────────────── */
.upgrade-gate {
  background: linear-gradient(135deg, rgba(212,96,122,0.06), var(--surface));
  border: 1px solid var(--rose-bd);
  border-radius: var(--r3);
  padding: var(--sp5);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp3);
}
.upgrade-gate-icon { font-size: 28px; }
.upgrade-gate h3   { font-family: 'Fraunces', serif; font-size: 18px; font-weight: 600; color: var(--t1); }
.upgrade-gate p    { font-size: 14px; color: var(--t2); max-width: 340px; line-height: 1.6; }

/* ─── Loading spinner ────────────────────────────────────── */
.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--bd2);
  border-top-color: var(--rose);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  flex-shrink: 0;
}
.spinner--sm { width: 16px; height: 16px; }
.spinner--lg { width: 36px; height: 36px; border-width: 3px; }

/* ─── Divider text ───────────────────────────────────────── */
.divider-text {
  display: flex;
  align-items: center;
  gap: var(--sp3);
  color: var(--t3);
  font-size: 12px;
  font-weight: 500;
  margin: var(--sp4) 0;
}
.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--bd2);
}

/* ─── Avatar ─────────────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  background: linear-gradient(135deg, var(--rose), #a855c7);
  display: grid; place-items: center;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  font-family: 'Inter', sans-serif;
}
.avatar--sm  { width: 28px; height: 28px; font-size: 11px; }
.avatar--md  { width: 36px; height: 36px; font-size: 14px; }
.avatar--lg  { width: 48px; height: 48px; font-size: 18px; }
.avatar--xl  { width: 72px; height: 72px; font-size: 26px; }

/* ─── Pill tab switcher ───────────────────────────────────── */
.tabs {
  display: inline-flex;
  background: var(--surface2);
  border: 1px solid var(--bd2);
  border-radius: var(--rpill);
  padding: 4px;
  gap: 3px;
}
.tab-btn {
  padding: 7px 18px;
  border-radius: var(--rpill);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: 'Inter', sans-serif;
  color: var(--t3);
  background: transparent;
  transition: all var(--ease);
}
.tab-btn.active {
  background: var(--surface);
  color: var(--t1);
  border: 1px solid var(--bd2);
  box-shadow: var(--shadow-sm);
}

/* ─── Notification dot ───────────────────────────────────── */
.notif-dot {
  width: 8px; height: 8px;
  background: var(--rose);
  border-radius: 50%;
  border: 2px solid var(--bg);
  flex-shrink: 0;
}

/* ─── Page header (app pages) ────────────────────────────── */
.page-header {
  padding: 28px 0 20px;
  border-bottom: 1px solid var(--bd);
  margin-bottom: var(--sp6);
}
.page-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp4);
  flex-wrap: wrap;
}
.page-title {
  font-family: 'Fraunces', serif;
  font-size: 26px;
  font-weight: 600;
  color: var(--t1);
  letter-spacing: -0.5px;
}
.page-title em { font-style: italic; font-weight: 300; color: var(--rose); }
.page-subtitle { font-size: 14px; color: var(--t2); margin-top: 3px; }

/* ─── Skeleton loader ────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r1);
}

/* ─── Tooltip ────────────────────────────────────────────── */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface4);
  border: 1px solid var(--bd2);
  color: var(--t1);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--r1);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--ease);
  z-index: 100;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ─── Animations ─────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes bob {
  from { transform: translateY(0); }
  to   { transform: translateY(-10px); }
}
@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position:  200% center; }
}
@keyframes pulse-ring {
  0%   { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.5); opacity: 0; }
}
@keyframes slide-in-right {
  from { transform: translateX(16px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* Scroll reveal */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 550ms ease, transform 550ms ease;
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ─── Utility classes ────────────────────────────────────── */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col     { display: flex; flex-direction: column; }
.gap-1  { gap: var(--sp1); }
.gap-2  { gap: var(--sp2); }
.gap-3  { gap: var(--sp3); }
.gap-4  { gap: var(--sp4); }
.gap-5  { gap: var(--sp5); }
.mt-2   { margin-top: var(--sp2); }
.mt-3   { margin-top: var(--sp3); }
.mt-4   { margin-top: var(--sp4); }
.mt-5   { margin-top: var(--sp5); }
.mb-4   { margin-bottom: var(--sp4); }
.mb-5   { margin-bottom: var(--sp5); }
.hidden { display: none !important; }
.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;
}

/* ─── Responsive breakpoints ─────────────────────────────── */
@media (max-width: 768px) {
  .wrap { padding: 0 20px; }
  .section { padding: 60px 0; }
  .section--lg { padding: 72px 0; }
  .modal { padding: 24px 20px; border-radius: var(--r3); }
  .hide-mobile { display: none !important; }
}
@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
}
