:root {
  /* Typography */
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Layout & color */
  --bg: #fafafa;
  --fg: #1a1a1a;
  --muted: #6b7280; /* gray-500 */
  --accent: #111827; /* near-black for underlines */
  --card: #ffffff;
  --border: #e5e7eb; /* gray-200 */
  --tag-bg: #f3f4f6; /* gray-100 */

  --maxw: 720px;
  --rhythm: 1.2rem;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0c0f;
    --fg: #e5e7eb;
    --muted: #9ca3af;
    --accent: #f3f4f6;
    --card: #0f1115;
    --border: #1f2937;
    --tag-bg: #111827;
  }
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--serif);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.wrap {
  max-width: var(--maxw);
  margin: 6vh auto 12vh;
  padding: 0 1rem;
  padding-bottom: calc(var(--rhythm) * 2);
}

header {
  margin: 0;
  position: relative; /* allow absolute-positioned theme switch */
}

/* Header social icons (top-right) */
.header-icons {
  display: inline-flex;
  gap: 0.6rem;
}

.header-icons .iconlink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  color: var(--muted);
  border-bottom: 0;
  text-decoration: none;
  transition: color 160ms ease, opacity 160ms ease;
}
.header-icons .icon {
  width: 1.15rem;
  height: 1.15rem;
}
.header-icons .iconlink:hover { color: var(--fg); }
.header-icons .iconlink:focus-visible {
  outline: 2px dashed var(--border);
  outline-offset: 3px;
}

/* On narrow screens, place icons below the toggle to avoid overlap */
@media (max-width: 480px) {
  .header-icons {
    right: 0;
    top: 36px;                     /* below the 28px-high toggle */
  }
}

.name {
  font-family: var(--mono);
  font-size: clamp(28px, 5vw, 40px);
  letter-spacing: 0.02em;
  margin: 2rem 0 0.1rem 0;
}

.subtitle {
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0 0 var(--rhythm) 0;
}

.intro {
  font-size: 1.05rem;
  /*margin: 0 0 calc(var(--rhythm) * 2);*/
  /*max-width: 60ch;*/
  white-space: pre-line; /* supports \n from .Site.Params.intro */
}

/* Hairline divider */
.rule {
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border), transparent);
  margin: calc(var(--rhythm) * 1.5) 0 calc(var(--rhythm) * 1.5);
}

/* Projects grid */
.projects {
  display: grid;
  gap: calc(var(--rhythm) * 1.25);
  grid-template-columns: 1fr;
}

.project {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  padding: calc(var(--rhythm) * 1.2);
}

.project.project-single {
  padding: 0                          /* top    */
           calc(var(--rhythm) * 1.2)  /* right  */
           30px                       /* bottom */
           calc(var(--rhythm) * 1.2); /* left   */
}

.project h3 {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 1.05rem;
  margin: 0 0 0.4rem 0;
}

.project .desc {
  margin: 0 0 0.8rem 0;
  color: var(--fg);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.tag {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1;
  padding: 0.42rem 0.56rem;
  background: var(--tag-bg);
  border: 1px dashed var(--border);
  border-radius: 999px;
  white-space: nowrap;
}

.tag[data-tag] {
  background-color: var(--tag-default);
}

/* C / C++ */
.tag[data-tag="c"],
.tag[data-tag="c++"],
.tag[data-tag="c/c++"],
.tag[data-tag="c / c++"],
.tag[data-tag="cpp"] { background-color: var(--tag-c); }

/* Blockchain */
.tag[data-tag="ethereum"],
.tag[data-tag="blockchain"] { background-color: var(--tag-blockchain); }

/* Docker / Kubernetes / DevOps */
.tag[data-tag="docker"],
.tag[data-tag="kubernetes"],
.tag[data-tag="k8s"],
.tag[data-tag="containers"],
.tag[data-tag="administration système"],
.tag[data-tag="devops"],
.tag[data-tag="gitops"],
.tag[data-tag="container"] { background-color: var(--tag-docker); }

/* JavaScript / TypeScript */
.tag[data-tag="javascript"],
.tag[data-tag="js"],
.tag[data-tag="typescript"],
.tag[data-tag="ts"] { background-color: var(--tag-js); }

/* Linux / Systems */
.tag[data-tag="linux"],
.tag[data-tag="system"],
.tag[data-tag="systems"],
.tag[data-tag="system programming"],
.tag[data-tag="programmation système"],
.tag[data-tag="unix"],
.tag[data-tag="posix"] { background-color: var(--tag-linux); }

/* Networking */
.tag[data-tag="networking"],
.tag[data-tag="network"],
.tag[data-tag="socket programming"],
.tag[data-tag="net"] { background-color: var(--tag-network); }

/* Embedded */
.tag[data-tag="embedded"],
.tag[data-tag="embarqué"],
.tag[data-tag="firmware"],
.tag[data-tag="iot"],
.tag[data-tag="microcontroller"],
.tag[data-tag="mcus"] { background-color: var(--tag-embedded); }

/* Security */
.tag[data-tag="security"],
.tag[data-tag="cybersécurité"],
.tag[data-tag="reverse engineering"],
.tag[data-tag="infosec"],
.tag[data-tag="appsec"],
.tag[data-tag="sec"] { background-color: var(--tag-security); }

/* Links */
a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 1px;
}

a:hover {
  opacity: 0.9;
}

/* Accessible focus outlines */
:focus-visible {
  outline: 2px dashed var(--border);
  outline-offset: 3px;
}

.content h2,
.content h3,
.content h4 {
  font-family: var(--mono);
}

.content img,
.content video {
  max-width: 100%;
  height: auto;
  border-radius: calc(var(--radius) - 2px);
}

.ext a {
  font-family: var(--mono);
  font-size: 0.9rem;
  border-bottom-style: dashed;
}

footer {
  margin-top: calc(var(--rhythm) * 3);
  padding-bottom: calc(var(--rhythm) * 1);
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
}

/* --- Explicit theme overrides (win over @media) --- */
html[data-theme="light"] {
  --bg: #fafafa;
  --fg: #1a1a1a;
  --muted: #6b7280;
  --accent: #111827;
  --card: #ffffff;
  --border: #e5e7eb;
  --tag-bg: #f3f4f6;
}

html[data-theme="dark"] {
  --bg: #1c1c1c;
  --fg: #e5e7eb;
  --muted: #9ca3af;
  --accent: #f3f4f6;
  --card: #252525;
  --border: #1f2937;
  --tag-bg: #252525;
}

/* --- Theme switch (checkbox-based) --- */
.theme-switch {
  position: absolute;
  top: 0;
  right: 0;
  display: inline-block;
  height: 28px;
  width: 52px;
}

.theme-switch input {
  /* Visually hidden but accessible */
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
}

.theme-switch .track {
  position: relative;
  display: inline-block;
  width: 100%;
  height: 100%;
  background: var(--tag-bg);
  border: 1px dashed var(--border);
  border-radius: 999px;
}

.theme-switch .thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: transform 160ms ease;
  will-change: transform;
}

.theme-switch .icons {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1;
  user-select: none;
  pointer-events: none;
}

/* Move thumb when checked */
.theme-switch input:checked + .track .thumb {
  transform: translateX(24px);
}

/* Icon emphasis by theme */
html[data-theme="light"] .theme-switch .sun  { opacity: 1; }
html[data-theme="light"] .theme-switch .moon { opacity: 0.5; }
html[data-theme="dark"]  .theme-switch .sun  { opacity: 0.5; }
html[data-theme="dark"]  .theme-switch .moon { opacity: 1; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}


/* --- Homepage hero layout --- */
.hero {
  display: grid;
  grid-template-columns: 1fr;          /* stack on mobile */
  gap: calc(var(--rhythm) * 1.25);
  align-items: start;
}

.hero-media {
  display: flex;
  justify-content: center;
}

.hero-body {
  text-align: center;                   /* centered on mobile */
}

@media (min-width: 760px) {
  .hero {
    grid-template-columns: auto 1fr;    /* image left, text right */
    align-items: center;
  }
  .hero-body { text-align: left; }
  .hero-media { justify-content: flex-start; }
}

/* --- Avatar image --- */
.avatar {
  display: block;
  max-width: 150px;
  width: 33vw;              /* scale a bit on small screens */
  max-height: 150px;
  height: auto;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.03),
    0 8px 24px rgba(0, 0, 0, 0.08);
  object-fit: cover;
}

html[data-theme="dark"] .avatar {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.03),
    0 10px 28px rgba(0, 0, 0, 0.45);
}

/* Shape options */
.avatar--circle { border-radius: 999px; }
.avatar--rounded { border-radius: calc(var(--radius) + 4px); }

/* Slightly smaller on narrow phones */
@media (max-width: 380px) {
  .avatar { max-width: 120px; }
}

.proj-actions .iconlink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  color: var(--muted);
  border-bottom: 0;         /* override global link underline */
  text-decoration: none;
  transition: color 160ms ease, opacity 160ms ease;
}

.proj-actions .icon {
  width: 1.2rem;
  height: 1.2rem;
}

.proj-actions .iconlink:hover {
  color: var(--fg);
}

.proj-actions .iconlink:focus-visible {
  outline: 2px dashed var(--border);
  outline-offset: 3px;
}

/* Header row within project card */
.project-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  column-gap: 0.75rem;
  margin-bottom: 0.35rem; /* small space before description */
}

.project-header .project-title {
  /* keep original h3 look but remove default margin in this row */
  margin: 0;
  /* let the title own the space; icons won't squeeze it */
  flex: 1 1 auto;
  min-width: 0;                /* allow wrapping instead of overflow */
}

.project-header .project-title a {
  /* help long titles wrap gracefully */
  overflow-wrap: anywhere;
}

/* Keep icons on the right, horizontally aligned */
.project-header .proj-actions {
  display: inline-flex;
  gap: 0.6rem;                 /* tidy horizontal gap between icons */
  margin: 0;                   /* override old margins meant for stacked layout */
  flex: 0 0 auto;              /* don't let icons grow or shrink title area */
}

/* Responsive behavior on very narrow screens */
@media (max-width: 420px) {
  .project-header {
    flex-wrap: wrap;           /* let icons move to the next line if needed */
    row-gap: 0.4rem;
  }
  .project-header .proj-actions {
    width: 100%;
    justify-content: flex-start;  /* icons appear on a new line under title */
  }
}

/* back link near the title */
.backlink {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--muted);
  border-bottom: 1px dashed var(--border);
  text-decoration: none;
  margin-bottom: 0.4rem;
}
.backlink:hover { color: var(--fg); opacity: 0.9; }

/* Unstyled metadata block (transparent, no border) */
.meta {
  background: transparent;
  border: none;
  padding: 0;
  margin: calc(var(--rhythm) * 1) 0 calc(var(--rhythm) * 1.5);
}

/* Grid layout for description + actions + tags */
.meta-grid {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  /* spacing between intro / actions / tags */
  row-gap: calc(var(--rhythm) * 0.8);  /* slightly tighter on mobile */
  column-gap: var(--rhythm);
}

/* Grid layout for description + tags/actions row */
.meta-grid {
  display: grid;
  grid-template-columns: 1fr;          /* intro, then the row */
  align-items: start;
  row-gap: calc(var(--rhythm) * 0.8);  /* spacing between intro and row */
}

/* Row: tags left, actions right; wraps on narrow viewports */
.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--rhythm);
  flex-wrap: wrap;
}

/* Tags in the row */
.meta-row .tags {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* Base actions style (reusable) */
.meta-actions {
  display: inline-flex;
  gap: 0.6rem;
  align-items: center;
}

/* Row-specific alignment for actions (right side) */
.meta-row .meta-actions {
  justify-content: flex-end;
}

/* Remove empty actions container if no links */
.meta-actions:empty { display: none; }

/* Intro in metadata has no margin; spacing comes from row-gap */
.meta-grid .intro { margin: 0; }

/* Mobile: stack row items */
@media (max-width: 520px) {
  .meta-row {
    flex-direction: column;
    align-items: flex-start;           /* tags first, icons below */
    gap: calc(var(--rhythm) * 0.6);
  }
}

/* Light theme tag palette */
html[data-theme="light"] {
  --tag-default: #f3f4f6;      /* subtle neutral fallback */

  --tag-c:          #FBE4E2;     /* Soft Red */
  --tag-blockchain: #E3ECFB;     /* Muted Blue */
  --tag-docker:     #E0F3F6;     /* Aqua */
  --tag-js:         #FFF4C6;     /* Warm Yellow */
  --tag-linux:      #E4F2EA;     /* Sage Green */
  --tag-network:    #E9E5F6;     /* Slate Purple */
  --tag-embedded:   #FFE7D6;     /* Warm Orange */
  --tag-security:   #F6D9DF;     /* Crimson */
}

/* Dark theme tag palette */
html[data-theme="dark"] {
  --tag-default: #111827;      /* neutral fallback in dark */

  --tag-c:          #4E2725;
  --tag-blockchain: #24344D;
  --tag-docker:     #1F3D44;
  --tag-js:         #3B3212;
  --tag-linux:      #1F3A2D;
  --tag-network:    #2F2A3F;
  --tag-embedded:   #4A2E1A;
  --tag-security:   #3E1E27;
}
