/* =============================================================
   base.css — Modern reset + base typography for othmanbenomar.dev
   Depends on: tokens.css (must be loaded first)
   ============================================================= */

/* -----------------------------------------------------------
   Box model reset
----------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

/* -----------------------------------------------------------
   Margin / padding reset
----------------------------------------------------------- */
* {
  margin: 0;
  padding: 0;
}

/* -----------------------------------------------------------
   Root / body
----------------------------------------------------------- */
html {
  font-size: 100%; /* 16px base */
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* -----------------------------------------------------------
   Media elements — always block, never overflow
----------------------------------------------------------- */
img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

/* -----------------------------------------------------------
   Form elements — inherit font
----------------------------------------------------------- */
input, button, textarea, select {
  font: inherit;
}

/* -----------------------------------------------------------
   Text elements
----------------------------------------------------------- */
p, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
}

/* -----------------------------------------------------------
   Headings
----------------------------------------------------------- */
h1 {
  font-size: var(--text-3xl);
  line-height: var(--leading-tight);
  font-weight: var(--weight-bold);
  color: var(--color-text);
}

h2 {
  font-size: var(--text-2xl);
  line-height: var(--leading-tight);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

h3 {
  font-size: var(--text-xl);
  line-height: var(--leading-snug);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

h4 {
  font-size: var(--text-lg);
  line-height: var(--leading-snug);
  font-weight: var(--weight-medium);
  color: var(--color-text);
}

h5 {
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  font-weight: var(--weight-medium);
  color: var(--color-text);
}

h6 {
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* -----------------------------------------------------------
   Body text
----------------------------------------------------------- */
p {
  line-height: var(--leading-normal);
  color: var(--color-text);
}

p + p {
  margin-top: var(--space-4);
}

/* -----------------------------------------------------------
   Links
----------------------------------------------------------- */
a {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color var(--transition-fast), text-decoration-color var(--transition-fast);
}

a:hover {
  color: var(--color-accent-strong);
  text-decoration-color: var(--color-accent-strong);
}

a:visited {
  color: var(--color-accent);
}

/* -----------------------------------------------------------
   Focus styles — keyboard navigation (WCAG 2.4.7)
   Use :focus-visible so mouse clicks don't show ring.
----------------------------------------------------------- */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  box-shadow: var(--shadow-focus);
  border-radius: var(--radius-sm);
}

/* -----------------------------------------------------------
   Skip link — visually hidden until focused
----------------------------------------------------------- */
.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-toast);
  padding: var(--space-2) var(--space-4);
  background: var(--color-accent);
  color: var(--color-text-inverse);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-md);
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform var(--transition-fast);
}

.skip-link:focus-visible {
  transform: translateY(0);
  outline: 2px solid var(--color-text-inverse);
  outline-offset: 2px;
}

/* -----------------------------------------------------------
   Code and pre
----------------------------------------------------------- */
code, kbd, samp {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--color-surface-alt);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  overflow-x: auto;
  line-height: var(--leading-snug);
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

/* -----------------------------------------------------------
   Horizontal rule
----------------------------------------------------------- */
hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-8) 0;
}

/* -----------------------------------------------------------
   Lists (unstyled base — layout-specific styles in layout.css)
----------------------------------------------------------- */
ul, ol {
  padding-left: var(--space-6);
}

li + li {
  margin-top: var(--space-1);
}

/* -----------------------------------------------------------
   Blockquote
----------------------------------------------------------- */
blockquote {
  border-left: 3px solid var(--color-accent);
  margin-left: 0;
  padding-left: var(--space-4);
  color: var(--color-text-muted);
  font-style: italic;
}

/* -----------------------------------------------------------
   Tables
----------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

th, td {
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}

th {
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* -----------------------------------------------------------
   Hidden utility
----------------------------------------------------------- */
[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* -----------------------------------------------------------
   Print styles
----------------------------------------------------------- */
@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  body {
    font-size: 12pt;
    line-height: 1.4;
  }

  a,
  a:visited {
    text-decoration: underline;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    color: #555;
  }

  a[href^="#"]::after,
  a[href^="javascript:"]::after {
    content: "";
  }

  .site-header,
  .site-nav,
  .lang-switcher,
  .skip-link,
  .site-footer nav,
  .no-print {
    display: none !important;
  }

  h1, h2, h3 {
    page-break-after: avoid;
  }

  p, blockquote {
    orphans: 3;
    widows: 3;
  }

  @page {
    margin: 2cm;
  }
}