/* =============================================================
   layout.css — Layout primitives for othmanbenomar.dev
   Depends on: tokens.css, base.css (loaded before this)
   Breakpoints:
     xs: <576px  | sm: 576–767px | md: 768–991px
     lg: 992–1199px | xl: 1200px+
   ============================================================= */

/* -----------------------------------------------------------
   Container
----------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-xl);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

@media (min-width: 576px)  { .container { padding-inline: var(--space-6); } }
@media (min-width: 992px)  { .container { padding-inline: var(--space-8); } }
@media (min-width: 1200px) { .container { max-width: var(--container-xl); padding-inline: var(--space-8); } }

.container--sm  { max-width: var(--container-sm); }
.container--md  { max-width: var(--container-md); }
.container--lg  { max-width: var(--container-lg); }

/* -----------------------------------------------------------
   Grid utilities
   .grid          – base CSS Grid wrapper
   .grid-2        – 2-column at md+
   .grid-3        – 3-column at lg+
   .grid-6        – 3×2 featured-rail: 3 cols lg+, 2 cols sm–md, 1 col xs
   .grid-auto     – auto-fill 280px columns
----------------------------------------------------------- */
.grid {
  display: grid;
  gap: var(--space-6);
}

/* 2-column grid */
.grid-2 {
  grid-template-columns: 1fr;
}
@media (min-width: 768px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
}

/* 3-column grid */
.grid-3 {
  grid-template-columns: 1fr;
}
@media (min-width: 576px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 992px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}

/* 6-card featured rail: 3×2 */
.grid-6 {
  grid-template-columns: 1fr;
}
@media (min-width: 576px) {
  .grid-6 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 992px) {
  .grid-6 { grid-template-columns: repeat(3, 1fr); }
}

/* Auto-fill grid */
.grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* Gap modifiers */
.grid--gap-sm { gap: var(--space-4); }
.grid--gap-lg { gap: var(--space-8); }

/* -----------------------------------------------------------
   Stack — vertical flex with gap
----------------------------------------------------------- */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.stack--sm { gap: var(--space-2); }
.stack--lg { gap: var(--space-8); }

/* -----------------------------------------------------------
   Cluster — horizontal flex with wrap
----------------------------------------------------------- */
.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}
.cluster--sm { gap: var(--space-2); }
.cluster--lg { gap: var(--space-6); }

/* -----------------------------------------------------------
   Card primitive
----------------------------------------------------------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-alt);
}

.card-body {
  padding: var(--space-6);
  flex: 1;
}

.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-alt);
}

/* Card tag / badge */
.card-tag {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-accent-bg);
  color: var(--color-accent-strong);
}

/* Card icon */
.card-icon {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-3);
  display: block;
}

/* Card title */
.card-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

/* Card description */
.card-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: var(--leading-normal);
}

/* Card link — full-card click target */
.card-link {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.card-link:hover .card-title {
  color: var(--color-accent);
}

/* -----------------------------------------------------------
   Site header
----------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: var(--space-3);
}

/* Logo / wordmark */
.site-logo {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.site-logo:hover {
  color: var(--color-accent);
}

/* -----------------------------------------------------------
   Site nav
----------------------------------------------------------- */
.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  list-style: none;
  padding: 0;
  margin: 0;
}

.site-nav__item {
  /* no extra styles needed */
}

.site-nav__link {
  display: block;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.site-nav__link:hover,
.site-nav__link[aria-current="page"] {
  color: var(--color-accent);
  background: var(--color-accent-bg);
}

/* Mobile nav toggle (hidden on desktop) */
.site-nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  cursor: pointer;
  color: var(--color-text);
  line-height: 1;
}

@media (max-width: 767px) {
  .site-nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: var(--space-2) var(--space-4);
  }

  .site-nav.is-open {
    display: flex;
  }

  .site-nav__link {
    padding: var(--space-3) var(--space-2);
    border-radius: 0;
    border-bottom: 1px solid var(--color-border);
  }

  .site-nav__link:last-child {
    border-bottom: none;
  }
}

/* Language switcher */
.lang-switcher {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
}

.lang-switcher__btn {
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--color-text-muted);
  font-weight: var(--weight-medium);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.lang-switcher__btn:hover,
.lang-switcher__btn[aria-current="true"] {
  color: var(--color-accent);
  background: var(--color-accent-bg);
}

.lang-switcher__sep {
  color: var(--color-border);
}

/* -----------------------------------------------------------
   Main content area
----------------------------------------------------------- */
.site-main {
  flex: 1;
  padding-block: var(--space-12);
}

/* Page hero / section header */
.page-hero {
  padding-block: var(--space-16) var(--space-12);
  text-align: center;
}

.page-hero__title {
  font-size: var(--text-4xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  color: var(--color-text);
  margin-bottom: var(--space-4);
}

.page-hero__subtitle {
  font-size: var(--text-xl);
  color: var(--color-text-muted);
  max-width: 60ch;
  margin-inline: auto;
  line-height: var(--leading-normal);
}

@media (max-width: 575px) {
  .page-hero__title { font-size: var(--text-2xl); }
  .page-hero__subtitle { font-size: var(--text-base); }
}

/* Section */
.section {
  padding-block: var(--space-16);
}

.section--sm {
  padding-block: var(--space-8);
}

.section__header {
  margin-bottom: var(--space-10);
  text-align: center;
}

.section__title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

.section__subtitle {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  max-width: 55ch;
  margin-inline: auto;
}

/* -----------------------------------------------------------
   Site footer
----------------------------------------------------------- */
.site-footer {
  background: var(--color-surface-alt);
  border-top: 1px solid var(--color-border);
  padding-block: var(--space-10);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-8);
  justify-content: space-between;
  align-items: flex-start;
}

.site-footer__brand {
  max-width: 28ch;
}

.site-footer__brand-name {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.site-footer__tagline {
  color: var(--color-text-muted);
  line-height: var(--leading-normal);
}

.site-footer__links {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.site-footer__links a {
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.site-footer__links a:hover {
  color: var(--color-accent);
}

.site-footer__bottom {
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

@media (max-width: 575px) {
  .site-footer__inner { flex-direction: column; }
  .site-footer__bottom { flex-direction: column; text-align: center; }
}

/* -----------------------------------------------------------
   KPI / stat tiles (used on home page)
----------------------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--space-4);
  text-align: center;
}

.kpi-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-4);
  box-shadow: var(--shadow-sm);
}

.kpi-tile__value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--color-accent);
  line-height: 1;
  margin-bottom: var(--space-2);
}

.kpi-tile__label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: var(--weight-medium);
}

/* -----------------------------------------------------------
   Filter / tag bar (used on projects page)
----------------------------------------------------------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-8);
}

.filter-btn {
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-btn:hover,
.filter-btn.is-active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-text-inverse);
}

/* -----------------------------------------------------------
   Utility classes
----------------------------------------------------------- */
.text-center  { text-align: center; }
.text-left    { text-align: left; }
.text-right   { text-align: right; }
.text-muted   { color: var(--color-text-muted); }
.text-accent  { color: var(--color-accent); }
.text-sm      { font-size: var(--text-sm); }
.text-lg      { font-size: var(--text-lg); }
.font-bold    { font-weight: var(--weight-bold); }
.font-medium  { font-weight: var(--weight-medium); }

.mt-auto  { margin-top: auto; }
.mb-0     { margin-bottom: 0; }
.pt-0     { padding-top: 0; }
.pb-0     { padding-bottom: 0; }

.w-full   { width: 100%; }
.h-full   { height: 100%; }
.flex     { display: flex; }
.flex-col { flex-direction: column; }
.flex-1   { flex: 1; }
.items-center   { align-items: center; }
.justify-center { justify-content: center; }
.justify-between{ justify-content: space-between; }
.gap-2    { gap: var(--space-2); }
.gap-4    { gap: var(--space-4); }
.gap-6    { gap: var(--space-6); }

.rounded     { border-radius: var(--radius-md); }
.rounded-lg  { border-radius: var(--radius-lg); }
.rounded-full{ border-radius: var(--radius-full); }

.shadow    { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

.bg-surface     { background: var(--color-surface); }
.bg-surface-alt { background: var(--color-surface-alt); }
.border         { border: 1px solid var(--color-border); }

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, var(--color-surface-alt) 25%, var(--color-border) 50%, var(--color-surface-alt) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
  color: transparent;
  pointer-events: none;
  user-select: none;
}

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}