/* ==========================================================================
   TradingView-Avis — styles.css
   - Design system : tokens (couleurs, typo, radius, shadows, spacing)
   - BEM components : header, nav, hero, sections, cards, tables, forms
   - Mobile-first + fluid type scale + micro-interactions
   ========================================================================== */

/* ------------------------------
   0) Reset & base
------------------------------ */
*,
*::before,
*::after { box-sizing: border-box; }

:root {
  /* Palette (inspirée de TradingView) */
  --brand-50:#eef6ff;
  --brand-100:#d9eaff;
  --brand-200:#b7d6ff;
  --brand-300:#89bbff;
  --brand-400:#5b9dff;
  --brand-500:#2b78ff;   /* primaire */
  --brand-600:#1f5fe0;
  --brand-700:#184bb3;
  --brand-800:#123985;
  --brand-900:#0d2a5f;

  --accent-500:#18a999;
  --danger-500:#e64b4b;
  --warning-500:#f0b429;
  --success-500:#2bb673;

  --bg:#0b1220;          /* fond sombre premium */
  --bg-alt:#0f1a2e;
  --surface:#121c33;
  --surface-2:#16223d;

  --text:#e8eefc;
  --text-dim:#b7c0d8;
  --text-invert:#0b1220;

  /* Shadows & radius */
  --radius-sm:10px;
  --radius-md:16px;
  --radius-lg:20px;
  --shadow-sm: 0 2px 8px rgb(0 0 0 / 0.15);
  --shadow-md: 0 8px 24px rgb(0 0 0 / 0.24);
  --shadow-lg: 0 16px 40px rgb(0 0 0 / 0.28);

  /* Spacing scale */
  --space-4:4px;
  --space-8:8px;
  --space-12:12px;
  --space-16:16px;
  --space-20:20px;
  --space-24:24px;
  --space-32:32px;
  --space-40:40px;
  --space-48:48px;
  --space-64:64px;
  --space-96:96px;

  /* Typo (fluid scale) */
  --ff-base: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Inter, Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  --ff-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --fs-xs: clamp(12px, 0.75vw, 13px);
  --fs-sm: clamp(14px, 0.85vw, 15px);
  --fs-md: clamp(16px, 1vw, 18px);
  --fs-lg: clamp(18px, 1.3vw, 22px);
  --fs-xl: clamp(22px, 2vw, 28px);
  --fs-2xl: clamp(28px, 3vw, 40px);
  --fs-3xl: clamp(34px, 4vw, 56px);

  /* Layout */
  --container: 1180px;
  --gutter: 20px;

  /* Transitions */
  --elevate: 200ms cubic-bezier(.2,.7,.3,1);
  --hover: 160ms ease-out;
}

html { scroll-behavior: smooth; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--ff-base);
  font-size: var(--fs-md);
  line-height: 1.6;
  color: var(--text);
  background: radial-gradient(1200px 600px at 20% -10%, #16305f 0%, transparent 60%) no-repeat, var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, picture, svg, video { display: block; max-width: 100%; height: auto; }
a { color: var(--brand-400); text-decoration: none; }
a:hover { color: var(--brand-300); text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 var(--space-16); }
h1 { font-size: var(--fs-3xl); letter-spacing: -0.02em; }
h2 { font-size: var(--fs-2xl); }
.h3, h3 { font-size: var(--fs-xl); }
.h4, h4 { font-size: var(--fs-lg); }

p { margin: 0 0 var(--space-16); }
ul, ol { margin: 0 0 var(--space-16); padding-left: 1.2rem; }
code, pre { font-family: var(--ff-mono); font-size: .95em; }
pre { padding: var(--space-16); background: var(--surface); border-radius: var(--radius-md); overflow-x: auto; }

/* Utilities */
.container {
  width: min(100% - 2*var(--gutter), var(--container));
  margin-inline: auto;
}
.center { text-align: center; }
.dim { color: var(--text-dim); }
.note { font-size: var(--fs-sm); color: var(--text-dim); }
.sr-only { position: absolute !important; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.hidden { display: none !important; }
.hp { position: absolute !important; left: -5000px; }

/* Skip link */
.skip-link {
  position: absolute; left: 8px; top: 8px;
  background: var(--brand-500); color: var(--text-invert);
  padding: 8px 12px; border-radius: var(--radius-sm);
  transform: translateY(-150%); transition: transform var(--hover);
  z-index: 1000;
}
.skip-link:focus { transform: translateY(0); }

/* ------------------------------
   1) Header & Navigation
------------------------------ */
.site-header {
  position: sticky; top: 0; z-index: 900;
  background: linear-gradient(180deg, rgba(10,16,30,.9), rgba(10,16,30,.6));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.header__inner { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; gap: var(--space-16); }
.logo img { filter: drop-shadow(0 2px 4px rgb(0 0 0 / .4)); }

.nav { position: relative; }
.nav__toggle {
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--surface); border: 1px solid rgba(255,255,255,.08);
  cursor: pointer; transition: background var(--hover), transform var(--hover);
}
.nav__toggle:hover { background: var(--surface-2); transform: translateY(-1px); }
.nav__bar { display: block; width: 20px; height: 2px; background: var(--text); margin: 3px 0; border-radius: 2px; transition: transform var(--elevate), opacity var(--elevate); }
.nav__toggle[aria-expanded="true"] .nav__bar:nth-child(1) { transform: translateY(5px) rotate(45deg); }
.nav__toggle[aria-expanded="true"] .nav__bar:nth-child(2) { opacity: 0; }
.nav__toggle[aria-expanded="true"] .nav__bar:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

.nav__menu {
  position: fixed; inset: 64px var(--gutter) auto var(--gutter);
  background: var(--surface); border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-lg); padding: var(--space-16);
  display: grid; gap: var(--space-8);
  box-shadow: var(--shadow-lg);
  transform-origin: top right; transform: scale(.98); opacity: 0; pointer-events: none;
  transition: transform var(--elevate), opacity var(--elevate);
}
.nav__menu.is-open { transform: scale(1); opacity: 1; pointer-events: auto; }
.nav__menu > li > a, .nav__menu .btn { display: block; padding: 10px 12px; border-radius: var(--radius-sm); }
.nav__menu > li > a:hover { background: rgba(255,255,255,.05); text-decoration: none; }

.nav__lang { position: relative; }
.lang__list {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-md); padding: 6px;
  display: none; min-width: 140px; box-shadow: var(--shadow-md);
}
.nav__lang:focus-within .lang__list { display: block; }
.lang__list a { display: block; padding: 8px 10px; border-radius: 8px; }
.lang__list a:hover { background: rgba(255,255,255,.06); text-decoration: none; }

.nav__cta { margin-top: var(--space-8); }

/* Desktop menu */
@media (min-width: 960px) {
  .nav__menu {
    position: static; display: flex; align-items: center; gap: var(--space-16);
    background: transparent; border: 0; border-radius: 0; padding: 0; box-shadow: none;
    opacity: 1; transform: none; pointer-events: auto;
  }
  .nav__toggle { display: none; }
  .nav__cta { margin-top: 0; }
}

/* ------------------------------
   2) Buttons
------------------------------ */
.btn {
  --btn-bg: var(--surface); --btn-color: var(--text); --btn-bd: rgba(255,255,255,.1);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 16px; border-radius: 999px; border: 1px solid var(--btn-bd);
  background: var(--btn-bg); color: var(--btn-color); font-weight: 600;
  transition: transform var(--hover), box-shadow var(--hover), background var(--hover), color var(--hover), border-color var(--hover);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgb(0 0 0 / .25); text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--brand-300); outline-offset: 2px; }
.btn--primary { --btn-bg: linear-gradient(180deg, var(--brand-400), var(--brand-600)); --btn-color: #fff; --btn-bd: transparent; }
.btn--ghost   { --btn-bg: transparent; --btn-bd: rgba(255,255,255,.2); }
.btn--outline { --btn-bg: transparent; --btn-bd: var(--brand-400); --btn-color: var(--brand-300); }
.btn--link { background: transparent; border: 0; color: var(--brand-300); padding: 8px 10px; }
.btn--sm { padding: 8px 12px; font-size: var(--fs-sm); }
.btn--lg { padding: 14px 22px; font-size: var(--fs-lg); }

/* ------------------------------
   3) Sections & grid
------------------------------ */
.section { padding: var(--space-48) 0; }
.section--alt { background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,0) 60%); }
.section__title { margin-bottom: var(--space-24); }

.grid { display: grid; gap: var(--space-20); }
.grid--2cols { grid-template-columns: 1fr; }
.grid--3cols { grid-template-columns: 1fr; }

@media (min-width: 720px) {
  .grid--2cols { grid-template-columns: 1.1fr .9fr; }
  .grid--3cols { grid-template-columns: repeat(3, 1fr); }
}

/* Cards */
.card {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-lg);
  padding: var(--space-20);
  box-shadow: var(--shadow-sm);
  transition: transform var(--hover), box-shadow var(--hover), border-color var(--hover);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: rgba(255,255,255,.16); }

.quote blockquote { margin: 0 0 8px; font-style: italic; }
.price.card { text-align: left; }
.card--highlight { outline: 2px solid var(--brand-500); }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid rgba(255,255,255,.08); }
.table { width: 100%; border-collapse: collapse; min-width: 640px; }
.table th, .table td { padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.table thead th { background: rgba(255,255,255,.05); text-align: left; white-space: nowrap; }
.table tbody tr:hover { background: rgba(255,255,255,.03); }

/* ------------------------------
   4) Hero & CTA banner
------------------------------ */
.hero { padding-top: var(--space-64); }
.hero__subtitle { color: var(--text-dim); }
.hero__actions { display: flex; gap: var(--space-12); flex-wrap: wrap; margin: var(--space-16) 0 var(--space-16); }
.hero__bullets { list-style: none; padding: 0; margin: var(--space-16) 0 0; color: var(--text-dim); }
.hero__bullets li { padding-left: 22px; position: relative; margin-bottom: 6px; }
.hero__bullets li::before { content: "✔"; position: absolute; left: 0; color: var(--accent-500); }

.cta-banner {
  position: sticky; top: 64px; z-index: 800;
  background: linear-gradient(90deg, rgba(27,54,108,.9), rgba(27,54,108,.7));
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(255,255,255,.08);
  border-bottom: 1px solid rgba(255,255,255,.08);
  padding: 8px 0;
  display: flex; justify-content: center; align-items: center; gap: var(--space-12);
}
.cta-banner p { margin: 0; font-weight: 600; }

/* ------------------------------
   5) Blog & posts
------------------------------ */
.posts-grid .post__thumb img { border-radius: var(--radius-md); }
.post__body .post__meta { color: var(--text-dim); font-size: var(--fs-sm); }
.link-cta { color: #fff; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

.article { padding-top: var(--space-32); }
.post__header { margin-bottom: var(--space-24); }
.post__hero img { border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.post__cta, .post__cta-inline { display: flex; align-items: center; gap: var(--space-12); flex-wrap: wrap; margin: var(--space-16) 0; }

/* Table of contents */
.toc { background: var(--surface); border: 1px solid rgba(255,255,255,.08); border-radius: var(--radius-md); padding: var(--space-16); margin: var(--space-24) 0; }
.toc ol { margin: 0; padding-left: 1.2rem; }
.toc a { text-decoration: underline; text-underline-offset: 3px; }

/* FAQ accordion */
.accordion__item { border: 1px solid rgba(255,255,255,.1); border-radius: var(--radius-md); background: var(--surface); margin-bottom: 12px; overflow: hidden; }
.accordion__item > summary {
  list-style: none; cursor: pointer; padding: 14px 16px; font-weight: 600; position: relative;
}
.accordion__item > summary::-webkit-details-marker { display: none; }
.accordion__item > summary::after {
  content: "▾"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%) rotate(-90deg); transition: transform var(--elevate);
}
.accordion__item[open] > summary::after { transform: translateY(-50%) rotate(0deg); }
.accordion__content { padding: 0 16px 16px; color: var(--text-dim); }

/* ------------------------------
   6) Forms (newsletter, search, cookies)
------------------------------ */
.form { display: grid; gap: var(--space-12); }
.form input[type="email"],
.form input[type="text"],
.form input[type="search"] {
  width: 100%;
  background: var(--surface);
  color: var(--text); border: 1px solid rgba(255,255,255,.16);
  border-radius: 12px; padding: 12px 14px; outline: none;
  transition: border-color var(--hover), box-shadow var(--hover);
}
.form input::placeholder { color: #8ea1c7; }
.form input:focus { border-color: var(--brand-400); box-shadow: 0 0 0 3px rgba(43,120,255,.25); }
.form__msg { min-height: 1.2em; font-size: var(--fs-sm); color: var(--text-dim); }

.blog-search { display: grid; gap: var(--space-12); }
.chip {
  border: 1px solid rgba(255,255,255,.18); background: transparent; color: var(--text);
  padding: 8px 12px; border-radius: 999px; cursor: pointer; transition: background var(--hover), border-color var(--hover);
}
.chip:hover { background: rgba(255,255,255,.06); }
.chip.is-active, .chip[aria-pressed="true"] { background: rgba(43,120,255,.15); border-color: var(--brand-400); }

/* Cookie banner */
.cookie {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 1000;
  background: var(--surface); border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: var(--space-16);
}
.cookie__inner { display: grid; gap: var(--space-12); }
.cookie__actions { display: flex; gap: var(--space-8); flex-wrap: wrap; }
.cookie__prefs { margin-top: 6px; border-top: 1px dashed rgba(255,255,255,.15); padding-top: 10px; }
.switch { display: flex; align-items: center; gap: 10px; }
.switch input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--brand-500); }

/* ------------------------------
   7) Footer
------------------------------ */
.site-footer { margin-top: var(--space-48); padding: var(--space-24) 0; background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.00)); border-top: 1px solid rgba(255,255,255,.06); }
.footer__grid { display: grid; gap: var(--space-16); align-items: start; }
.footer__nav ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.footer__nav a { color: var(--text-dim); }
.footer__nav a:hover { color: #fff; text-decoration: none; }
.affiliate-badge { display: none; opacity: .6; text-align: center; margin-top: 6px; font-size: var(--fs-sm); }

/* ------------------------------
   8) Legal pages
------------------------------ */
.legal .section { padding-top: var(--space-32); }
.legal .narrow { width: min(760px, 100%); margin-inline: auto; }
.notranslate { user-select: text; }

/* ------------------------------
   9) Helpers & media queries
------------------------------ */
.mt-16 { margin-top: var(--space-16); }
.mt-24 { margin-top: var(--space-24); }
.grid + .center { margin-top: var(--space-24); }

/* Larger screens */
@media (min-width: 1200px) {
  .hero { padding-top: var(--space-96); }
}

/* ------------------------------
   10) Animations & effects
------------------------------ */
@keyframes floatUp {
  from { transform: translateY(6px); opacity: .0; }
  to   { transform: translateY(0);   opacity: 1; }
}
.card, .btn, .table, .hero__media img, .post__hero img { animation: floatUp .5s var(--elevate) both; }

/* Focus styles for accessibility */
:focus-visible { outline: 2px solid var(--brand-300); outline-offset: 2px; border-radius: 8px; }

/* ------------------------------
   11) Images & media
------------------------------ */
picture, img { border: 0; }

/* ------------------------------
   12) Badges / notices
------------------------------ */
/* Afficher le badge d’affiliation seulement si requis
   (activer via JS ou classe .show-badge sur <footer>) */
.site-footer .affiliate-badge { display: none; }
.site-footer.show-badge .affiliate-badge { display: block; }

/* ------------------------------
   13) Accessibility prefers-reduced-motion
------------------------------ */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
