/* ============================================================
   main.css — Niche Theme Hugo
   Budget : < 15 KB minifié | System fonts | Mobile-first
   ============================================================ */

/* --- Custom properties ------------------------------------ */
:root {
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "Source Code Pro", monospace;

  --color-bg:       #ffffff;
  --color-text:     #1a1a2e;
  --color-muted:    #6b7280;
  --color-accent:   #2563eb;
  --color-accent-h: #1d4ed8;
  --color-border:   #e5e7eb;
  --color-surface:  #f9fafb;

  --radius:    0.5rem;
  --max-w:     72rem;
  --narrow-w:  44rem;
  --gap:       1.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg:      #0f172a;
    --color-text:    #e2e8f0;
    --color-muted:   #94a3b8;
    --color-accent:  #60a5fa;
    --color-accent-h:#93c5fd;
    --color-border:  #1e293b;
    --color-surface: #1e293b;
  }
}

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

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

body {
  font-family: var(--font-body);
  font-size: clamp(1rem, 2.2vw, 1.125rem);
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

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

a { color: var(--color-accent); text-decoration-skip-ink: auto; }
a:hover { color: var(--color-accent-h); }

h1, h2, h3, h4 {
  line-height: 1.25;
  font-weight: 700;
  margin-block: 1.5rem 0.5rem;
}

h1 { font-size: clamp(1.75rem, 5vw, 2.5rem); }
h2 { font-size: clamp(1.4rem, 3.5vw, 1.875rem); }
h3 { font-size: clamp(1.15rem, 2.5vw, 1.375rem); }

p { margin-block: 0 1rem; }

ul, ol { padding-left: 1.5rem; margin-block: 0 1rem; }

blockquote {
  border-left: 4px solid var(--color-accent);
  padding: 0.5rem 1rem;
  margin: 1.5rem 0;
  color: var(--color-muted);
  font-style: italic;
}

pre, code {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

pre {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  margin-block: 1.5rem;
}

code { background: var(--color-surface); padding: 0.15em 0.4em; border-radius: 0.25rem; }
pre code { background: none; padding: 0; }

hr { border: none; border-top: 1px solid var(--color-border); margin: 2rem 0; }

table { width: 100%; border-collapse: collapse; margin-block: 1.5rem; }
th, td { text-align: left; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--color-border); }
th { font-weight: 600; background: var(--color-surface); }

/* --- Layout containers ------------------------------------ */
.container {
  width: min(var(--max-w), 100% - 2rem);
  margin-inline: auto;
}

.container--narrow {
  width: min(var(--narrow-w), 100% - 2rem);
  margin-inline: auto;
}

/* --- Skip link -------------------------------------------- */
.skip-link {
  position: absolute;
  top: -3rem;
  left: 1rem;
  background: var(--color-accent);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-weight: 600;
  z-index: 9999;
  transition: top 0.2s;
}
.skip-link:focus { top: 1rem; }

/* --- Header / Nav ----------------------------------------- */
.site-header {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-block: 0.875rem;
}

.nav__logo {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--color-text);
  text-decoration: none;
  margin-right: auto;
}

.nav__menu {
  display: flex;
  gap: 1.5rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav__menu a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9375rem;
  transition: color 0.15s;
}

.nav__menu a[aria-current="page"],
.nav__menu a:hover { color: var(--color-accent); }

.nav__toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.nav__toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

@media (max-width: 640px) {
  .nav__toggle { display: flex; }

  .nav__menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    padding: 1rem;
    gap: 0.75rem;
  }

  .nav__menu.is-open { display: flex; }
}

/* --- Footer ----------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding-block: 2rem;
  margin-top: 4rem;
  color: var(--color-muted);
  font-size: 0.875rem;
}

.site-footer .container { display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; align-items: center; }
.site-footer a { color: var(--color-muted); }
.site-footer a:hover { color: var(--color-accent); }

/* --- Breadcrumb ------------------------------------------- */
.breadcrumb { font-size: 0.875rem; color: var(--color-muted); margin-block: 1.5rem 1rem; }
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; list-style: none; padding: 0; margin: 0; }
.breadcrumb li + li::before { content: "›"; margin-right: 0.5rem; }
.breadcrumb a { color: var(--color-muted); }
.breadcrumb [aria-current="page"] { color: var(--color-text); }

/* --- Tags ------------------------------------------------- */
.tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2em 0.6em;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  color: var(--color-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.tag:hover { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }
.tag--category { background: var(--color-surface); }

/* --- Post ------------------------------------------------- */
.post { padding-block: 2rem 3rem; }

.post__header { padding-block: 2rem; }

.post__categories { margin-block: 0.5rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }

.post__title { margin-top: 0.5rem; }

.post__lead {
  font-size: 1.2em;
  color: var(--color-muted);
  margin-top: 0.75rem;
  line-height: 1.5;
}

.post__meta {
  font-size: 0.875rem;
  color: var(--color-muted);
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  align-items: center;
}

.post__hero {
  margin-block: 1.5rem 0;
  border-radius: var(--radius);
  overflow: hidden;
}

.post__hero img { width: 100%; }

.post__hero figcaption {
  font-size: 0.8125rem;
  color: var(--color-muted);
  text-align: center;
  padding: 0.5rem;
}

.post__body { padding-block: 2rem; }

.post__body > * + * { margin-top: 0; }

.post__footer { padding-block: 1.5rem 0; border-top: 1px solid var(--color-border); }

.post__tags { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.post__tags > span { font-size: 0.875rem; color: var(--color-muted); }

/* --- Card grid -------------------------------------------- */
.card-grid {
  list-style: none;
  padding: 0;
  margin: 2rem 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: var(--gap);
}

.card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); transform: translateY(-2px); }

.card__img-link img { width: 100%; aspect-ratio: 16/9; object-fit: cover; }

.card__body { padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }

.card__title { font-size: 1.05rem; margin: 0; }

.card__link {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 600;
}

.card__link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.card { position: relative; }

.card__excerpt { font-size: 0.9rem; color: var(--color-muted); flex: 1; }

.card__meta, .card__date { font-size: 0.8125rem; color: var(--color-muted); }

.card__cats { display: flex; flex-wrap: wrap; gap: 0.25rem; }

/* --- List page -------------------------------------------- */
.list__header { margin-block: 2rem; }
.list__title { margin-top: 0; }
.list__description { color: var(--color-muted); margin-top: 0.75rem; }
.list__empty { color: var(--color-muted); margin-top: 2rem; }

/* --- Pagination ------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-block: 2rem;
  font-size: 0.9375rem;
}

.pagination__prev, .pagination__next {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--color-text);
  transition: background 0.15s;
}

.pagination__prev:hover, .pagination__next:hover { background: var(--color-surface); }
.pagination__info { color: var(--color-muted); font-size: 0.875rem; }

/* --- Related articles ------------------------------------- */
.related { margin-block: 3rem; }
.related__title { margin-top: 0; font-size: 1.25rem; }

/* --- 404 page --------------------------------------------- */
.error-page {
  text-align: center;
  padding-block: 4rem;
}

.error-page__title { font-size: clamp(2rem, 6vw, 3rem); }
.error-page__lead { color: var(--color-muted); margin-block: 0.75rem 1.5rem; }
.error-page__suggestions { margin-top: 3rem; text-align: left; max-width: 28rem; margin-inline: auto; }
.error-page__suggestions h2 { font-size: 1.125rem; }
.error-page__suggestions ul { margin-top: 0.5rem; }
.error-page__suggestions li { margin-bottom: 0.5rem; }

/* --- Button ----------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
  background: var(--color-accent);
  color: #fff;
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
  font-size: 0.9375rem;
}

.btn:hover { background: var(--color-accent-h); color: #fff; }

/* --- Image wrapper ---------------------------------------- */
.img-wrap { margin-block: 1.5rem; }
.img-wrap img { border-radius: var(--radius); width: 100%; }
.img-wrap figcaption { font-size: 0.8125rem; color: var(--color-muted); text-align: center; margin-top: 0.4rem; }

/* --- Print ------------------------------------------------ */
@media print {
  .site-header, .site-footer, .related, .pagination, .nav__toggle { display: none; }
  body { font-size: 12pt; color: #000; }
  a { color: #000; text-decoration: underline; }
  a[href]::after { content: " (" attr(href) ")"; font-size: 0.75em; }
}
