/* ============================================================
   Clément Legal — AI Consulting
   Stylesheet. Written by hand; no framework, no build step.

   01  Tokens
   02  Reset & base
   03  Typography primitives
   04  Chrome: header, rail, footer
   05  Hero
   06  Sections
   07  Motion
   08  Responsive
   09  Print
   ============================================================ */

/* ── 01  Tokens ─────────────────────────────────────────── */

:root {
  /* Paper & ink. Warm neutrals — never pure black, never pure white. */
  --paper:      #f5f4f0;
  --paper-2:    #efeee9;
  --ink:        #131211;
  --ink-soft:   #4a4843;
  --ink-muted:  #78756d;
  --ink-faint:  #a8a49a;
  --rule:       rgba(19, 18, 17, 0.14);
  --rule-soft:  rgba(19, 18, 17, 0.07);
  --accent:     #a8492b;

  /* Type */
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono:  "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Rhythm */
  --pad:     clamp(1.25rem, 5vw, 4.5rem);
  --gutter:  clamp(1.25rem, 2.6vw, 2.5rem);
  --section: clamp(4.5rem, 10vw, 9.5rem);
  --max:     1560px;

  /* Motion */
  --ease:      cubic-bezier(0.22, 0.7, 0.2, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
}

:root:not([data-theme="light"]) {
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:     #100f0e;
    --paper-2:   #171614;
    --ink:       #eeece6;
    --ink-soft:  #b6b2a9;
    --ink-muted: #8b8780;
    --ink-faint: #5d5a54;
    --rule:      rgba(238, 236, 230, 0.16);
    --rule-soft: rgba(238, 236, 230, 0.08);
    --accent:    #cf6a45;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper:     #100f0e;
  --paper-2:   #171614;
  --ink:       #eeece6;
  --ink-soft:  #b6b2a9;
  --ink-muted: #8b8780;
  --ink-faint: #5d5a54;
  --rule:      rgba(238, 236, 230, 0.16);
  --rule-soft: rgba(238, 236, 230, 0.08);
  --accent:    #cf6a45;
  color-scheme: dark;
}

/* ── 02  Reset & base ───────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: clamp(0.9375rem, 0.83rem + 0.28vw, 1.0625rem);
  font-weight: 300;
  line-height: 1.62;
  letter-spacing: -0.005em;
  text-wrap: pretty;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  /* clip, not hidden: hidden would make the body a scroll container and
     break the sticky section labels. Nothing overflows, this is a net. */
  overflow-x: clip;
  transition: background-color 0.5s var(--ease-soft), color 0.5s var(--ease-soft);
}

/* A whisper of grain, so the off-white reads as paper rather than #fff. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.022;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body::after { opacity: 0.03; }
}
:root[data-theme="dark"] body::after { opacity: 0.03; }

main { display: block; }

h1, h2, h3, p, dl, dd, figure { margin: 0; }
ol, ul { margin: 0; padding: 0; list-style: none; }

a { color: inherit; text-decoration: none; }

::selection { background: var(--ink); color: var(--paper); }

:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 4px;
  border-radius: 1px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1.25rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.skip:focus { left: 1rem; top: 1rem; }

/* ── 03  Typography primitives ──────────────────────────── */

/* Small mono label — the connective tissue of the whole site. */
.section__label i,
.section__label h2,
.hero__eyebrow,
.hero__role,
.hero__meta,
.rail,
.head,
.foot,
.now dt,
.copy,
.practice__n,
.tenets i {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 400;
  font-style: normal;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  line-height: 1.4;
}

.dot {
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-right: 0.7em;
  border-radius: 50%;
  background: var(--ink-faint);
  vertical-align: 0.15em;
}
.dot--live {
  background: var(--accent);
  animation: pulse 3.6s var(--ease-soft) infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.25; }
}

/* Underline that draws in on hover. */
.link {
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 1px;
  transition: background-size 0.55s var(--ease), color 0.35s var(--ease-soft);
  padding-bottom: 0.15em;
}
.link:hover, .link:focus-visible { background-size: 100% 1px; }

/* ── 04  Chrome ─────────────────────────────────────────── */

.head {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(1rem, 2.2vw, 1.75rem) var(--pad);
  transition: background-color 0.45s var(--ease-soft), border-color 0.45s var(--ease-soft);
  border-bottom: 1px solid transparent;
}
.head::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--paper);
  opacity: 0;
  transition: opacity 0.45s var(--ease-soft);
  z-index: -1;
}
.head.is-pinned::before { opacity: 0.94; }
.head.is-pinned { border-bottom-color: var(--rule-soft); }

.head__id {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
}
.head__mark {
  width: 6px;
  height: 6px;
  background: var(--accent);
  transform: rotate(45deg);
  transition: transform 0.7s var(--ease);
}
.head__id:hover .head__mark { transform: rotate(225deg); }

.head__name {
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
  white-space: nowrap;
}
.head.is-named .head__name { opacity: 1; transform: none; }

.head__nav {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2vw, 1.75rem);
}
.head__nav .link { color: var(--ink-muted); }
.head__nav .link:hover { color: var(--ink); }

.toggle {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  transition: border-color 0.4s var(--ease-soft), transform 0.5s var(--ease);
}
.toggle:hover { border-color: var(--ink-muted); transform: rotate(180deg); }
.toggle__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink);
  clip-path: inset(0 0 0 50%);
  transition: background-color 0.4s var(--ease-soft);
}

/* Right-hand section index. Desktop only — it is a luxury, not a necessity. */
.rail {
  position: fixed;
  right: clamp(1rem, 1.9vw, 1.9rem);
  top: 50%;
  transform: translateY(-50%);
  z-index: 40;
  display: none;
  opacity: 0;
  transition: opacity 0.6s var(--ease-soft);
}
.rail.is-visible { opacity: 1; }
.rail ol { display: grid; gap: 0.85rem; justify-items: end; }
.rail a {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink-faint);
  transition: color 0.4s var(--ease-soft);
}
.rail a:hover { color: var(--ink); }
.rail a.is-current { color: var(--accent); }

/* The rail keeps to its own lane: numbers only, until the viewport is
   wide enough that a label can sit in the margin without crowding text. */
.rail em {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
@media (min-width: 1700px) {
  .rail em {
    position: static;
    width: auto;
    height: auto;
    clip-path: none;
    opacity: 0;
    transform: translateX(6px);
    transition: opacity 0.45s var(--ease), transform 0.45s var(--ease);
  }
  .rail a:hover em,
  .rail a.is-current em { opacity: 1; transform: none; }
}

.foot {
  max-width: var(--max);
  margin-inline: auto;
  padding: clamp(2.25rem, 4vw, 3.25rem) var(--pad) clamp(1.75rem, 3vw, 2.5rem);
  border-top: 1px solid var(--rule);
  color: var(--ink-muted);
}

.foot__index {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.9rem clamp(1rem, 3vw, 2.5rem);
  padding-bottom: clamp(2rem, 4vw, 3rem);
}
.foot__index ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem clamp(1.1rem, 2.6vw, 2.25rem);
}
.foot__index i { color: var(--ink-faint); margin-right: 0.75em; }
.foot__index a:hover { color: var(--ink); }

.foot__base {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;
  gap: var(--gutter);
  padding-top: clamp(1.5rem, 3vw, 2.25rem);
  border-top: 1px solid var(--rule-soft);
}
.foot__colophon { text-align: center; }
.foot__year { text-align: right; }

/* ── 05  Hero ───────────────────────────────────────────── */

.hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(7rem, 14vh, 11rem) var(--pad) clamp(1.5rem, 3vw, 2.25rem);
  max-width: var(--max);
  margin-inline: auto;
}

.hero__inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(1.5rem, 3vw, 2.5rem);
}

.hero__eyebrow { color: var(--ink-muted); }

.hero__name {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(3rem, 28.5vw, 11rem);
  line-height: 0.92;
  letter-spacing: -0.022em;
  margin-left: -0.035em; /* optical: pull the C to the true margin */
}

.hero__under {
  display: grid;
  gap: clamp(1.5rem, 3vw, 2rem);
  align-items: start;
  padding-top: clamp(0.9rem, 2vw, 1.6rem);
  position: relative;
}

.hero__role { color: var(--ink); }

.hero__line {
  font-family: var(--serif);
  font-size: clamp(1.5rem, 3.4vw, 2.75rem);
  line-height: 1.16;
  letter-spacing: -0.012em;
  color: var(--ink);
  max-width: 22ch;
}
.hero__line em {
  font-style: italic;
  color: var(--ink-soft);
}

.hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem clamp(1.25rem, 4vw, 4rem);
  padding-top: clamp(1rem, 2vw, 1.4rem);
  position: relative;
  color: var(--ink-muted);
}

/* The two hero rules are drawn rather than switched on: they arrive after
   the name, left to right, and settle before the meta line fades in. */
.hero__under::before,
.hero__meta::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: var(--rule);
  transform: scaleX(0);
  transform-origin: left;
}
body.is-ready .hero__under::before {
  animation: draw 1.5s var(--ease) 0.32s forwards;
}
body.is-ready .hero__meta::before {
  animation: draw 1.5s var(--ease) 0.5s forwards;
}
@keyframes draw {
  to { transform: none; }
}
.hero__time { margin-left: auto; color: var(--ink-soft); }
.hero__time time { font-variant-numeric: tabular-nums; }

/* ── 06  Sections ───────────────────────────────────────── */

.section {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0 var(--gutter);
  max-width: var(--max);
  margin-inline: auto;
  padding: var(--section) var(--pad);
  border-top: 1px solid var(--rule);
}

.section__label {
  grid-column: 1 / -1;
  display: flex;
  gap: 1rem;
  margin-bottom: clamp(2rem, 4vw, 3rem);
  color: var(--ink-faint);
}
.section__label h2 { color: var(--ink); }

.section__body { grid-column: 1 / -1; }

.lead {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.5rem, 3.6vw, 3.05rem);
  line-height: 1.2;
  letter-spacing: -0.014em;
  color: var(--ink);
  max-width: 22ch;
  text-wrap: balance;
}
.section--intro .lead { max-width: 34ch; }

.cols {
  display: grid;
  gap: var(--gutter);
  margin-top: clamp(2.5rem, 5vw, 4.5rem);
  color: var(--ink-soft);
}
.cols p { max-width: 46ch; }

/* Practice — an index, not a set of cards. */
.practice__item {
  position: relative;
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr);
  gap: 0.35rem var(--gutter);
  padding: clamp(1.35rem, 2.4vw, 2rem) 0;
  border-top: 1px solid var(--rule-soft);
}
.practice__item:first-child { border-top-color: var(--rule); }
.practice__item:last-child { border-bottom: 1px solid var(--rule-soft); }
.practice__item::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -1px;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.75s var(--ease);
}
.practice__item:hover::after { transform: scaleX(1); }

.practice__n {
  color: var(--ink-faint);
  padding-top: 0.45em;
  transition: color 0.45s var(--ease-soft);
}
.practice__item:hover .practice__n { color: var(--accent); }

.practice__t {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.25rem, 2.2vw, 1.9rem);
  line-height: 1.18;
  letter-spacing: -0.012em;
  transition: transform 0.6s var(--ease);
}
.practice__item:hover .practice__t { transform: translateX(0.35rem); }

.practice__d {
  grid-column: 2;
  color: var(--ink-muted);
  max-width: 52ch;
  margin-top: 0.5rem;
}

/* Approach */
.tenets li {
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr);
  gap: var(--gutter);
  padding: clamp(1.35rem, 2.6vw, 2.1rem) 0;
  border-top: 1px solid var(--rule-soft);
}
.tenets li:first-child { border-top-color: var(--rule); }
.tenets li:last-child { border-bottom: 1px solid var(--rule-soft); }
.tenets i {
  color: var(--ink-faint);
  padding-top: 0.75em;
  text-transform: none;
  letter-spacing: 0.1em;
}
.tenets p {
  font-family: var(--serif);
  font-size: clamp(1.3rem, 2.75vw, 2.4rem);
  line-height: 1.2;
  letter-spacing: -0.014em;
  max-width: 24ch;
  text-wrap: balance;
}

/* Currently / contact detail rows */
.now { display: grid; }
.now__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.4rem var(--gutter);
  padding: clamp(1.1rem, 2vw, 1.6rem) 0;
  border-top: 1px solid var(--rule-soft);
}
.now__row:first-child { border-top-color: var(--rule); }
.now__row:last-child { border-bottom: 1px solid var(--rule-soft); }
.now dt { color: var(--ink-faint); padding-top: 0.35em; }
.now dd { margin: 0; color: var(--ink-soft); max-width: 54ch; }
.now--entries .now__row {
  grid-template-columns: minmax(0, 1fr);
  gap: 0.8rem;
  padding: clamp(1.3rem, 2.3vw, 1.95rem) 0;
}
.now--entries dt { padding-top: 0; }
.now--entries dd {
  font-family: var(--serif);
  font-size: clamp(1.15rem, 1.85vw, 1.6rem);
  line-height: 1.34;
  letter-spacing: -0.008em;
  color: var(--ink);
  max-width: 42ch;
}

.now--tight { margin-top: clamp(3rem, 6vw, 5rem); }
.now--tight dd { color: var(--ink-soft); }
.now--tight time { font-variant-numeric: tabular-nums; }

/* Contact */
.contact__intro { color: var(--ink-muted); max-width: 40ch; }

.contact__mail {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem clamp(0.75rem, 2vw, 1.5rem);
  margin-top: clamp(1.25rem, 2.5vw, 2rem);
}
.contact__mail a {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 5.4vw, 4.25rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 1px;
  transition: background-size 0.7s var(--ease);
  padding-bottom: 0.08em;
  word-break: break-word;
}
.contact__mail a:hover,
.contact__mail a:focus-visible { background-size: 100% 1px; }

.copy {
  align-self: center;
  padding: 0.45em 0.9em;
  border: 1px solid var(--rule);
  border-radius: 100px;
  background: none;
  color: var(--ink-muted);
  cursor: pointer;
  transition: border-color 0.4s var(--ease-soft), color 0.4s var(--ease-soft);
}
.copy:hover { border-color: var(--ink-muted); color: var(--ink); }
.copy.is-done { color: var(--accent); border-color: var(--accent); }

/* ── 07  Motion ─────────────────────────────────────────── */

.r {
  opacity: 0;
  transform: translateY(0.6rem);
}
body.is-ready .r {
  animation: rise 1.05s var(--ease) forwards;
  animation-delay: calc(var(--d, 0) * 95ms);
}
@keyframes rise {
  to { opacity: 1; transform: none; }
}

.reveal {
  opacity: 0;
  transform: translateY(0.85rem);
  transition:
    opacity 0.95s var(--ease),
    transform 0.95s var(--ease);
  transition-delay: calc(var(--i, 0) * 65ms);
}
.reveal.is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .r, .reveal { opacity: 1 !important; transform: none !important; }
}

/* ── 08  Responsive ─────────────────────────────────────── */

@media (min-width: 640px) {
  .now__row { grid-template-columns: 7.5rem minmax(0, 1fr); }
}

@media (min-width: 641px) {
  /* Above phone width the name holds a single line, edge to edge. */
  .hero__name {
    font-size: clamp(2.9rem, 16.5vw, 15.5rem);
    line-height: 0.88;
    white-space: nowrap;
  }
}

@media (min-width: 900px) {
  .hero__under {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: var(--gutter);
  }
  .hero__role { grid-column: 1 / span 3; padding-top: 0.25rem; }
  .hero__line { grid-column: 6 / -1; }

  /* The grid axis, drawn. One hairline in the gutter turns an implied
     column edge into the spine the whole page is hung from. */
  .section__body {
    margin-left: calc(var(--gutter) / -2);
    padding-left: calc(var(--gutter) / 2);
    border-left: 1px solid var(--rule-soft);
  }

  .section__label {
    grid-column: 1 / span 2;
    grid-row: 1;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0;
    position: sticky;
    top: 6.5rem;
    align-self: start;
  }
  .section__body { grid-column: 4 / -1; grid-row: 1; }

  .cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .practice__item { grid-template-columns: 3.5rem minmax(0, 1.05fr) minmax(0, 1.25fr); }
  .tenets li { grid-template-columns: 3.5rem minmax(0, 1fr); }
  .practice__d { grid-column: 3; margin-top: 0; padding-top: 0.5em; }

  .now__row { grid-template-columns: 7.5rem minmax(0, 1fr); }
}

@media (min-width: 1180px) {
  .rail { display: block; }
}

@media (max-width: 899px) {
  .foot__base {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    text-align: left;
  }
  .foot__colophon, .foot__year { text-align: left; }
  .hero__time { margin-left: 0; width: 100%; }
}

/* ── 09  Print ──────────────────────────────────────────── */

@media print {
  .head, .rail, .toggle, .copy, .skip, body::after { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .hero { min-height: auto; padding-top: 0; }
  .section { break-inside: avoid; border-top: 1px solid #ccc; }
  .r, .reveal { opacity: 1 !important; transform: none !important; }
  a[href^="mailto"]::after { content: " (" attr(href) ")"; font-size: 9pt; }
}
