/* ==========================================================================
   befethemad.com — stylesheet
   Structure: tokens → reset → layout → components → sections → responsive
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */

:root {
  /* Light theme (default) */
  --bg:            #fbfbfa;
  --bg-alt:        #f2f2f0;
  --surface:       #ffffff;
  --border:        #e2e2dd;
  --text:          #1a1a19;
  --text-muted:    #6b6b66;
  --accent:        #b4531f;
  --accent-soft:   rgba(180, 83, 31, 0.10);
  --shadow:        0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .05);

  /* Typography */
  --font-sans: ui-sans-serif, -apple-system, "Segoe UI", Inter, Roboto,
               "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;

  /* Spacing & layout */
  --wrap:        68rem;
  --wrap-narrow: 42rem;
  --gutter:      1.5rem;
  --radius:      12px;

  --transition: 180ms cubic-bezier(.4, 0, .2, 1);
}

/* Dark theme — follows the system unless the user has chosen explicitly */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #12120f;
    --bg-alt:      #191916;
    --surface:     #1d1d19;
    --border:      #2f2f29;
    --text:        #ecece7;
    --text-muted:  #9a9a92;
    --accent:      #e8935c;
    --accent-soft: rgba(232, 147, 92, 0.12);
    --shadow:      0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

:root[data-theme="dark"] {
  --bg:          #12120f;
  --bg-alt:      #191916;
  --surface:     #1d1d19;
  --border:      #2f2f29;
  --text:        #ecece7;
  --text-muted:  #9a9a92;
  --accent:      #e8935c;
  --accent-soft: rgba(232, 147, 92, 0.12);
  --shadow:      0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
}

/* --------------------------------------------------------------------------
   2. Reset & base
   -------------------------------------------------------------------------- */

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

* { margin: 0; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background var(--transition), color var(--transition);
}

img, svg { display: block; max-width: 100%; }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: opacity var(--transition);
}
a:hover { opacity: .75; }

ul, ol { padding: 0; list-style: none; }

h1, h2, h3 { line-height: 1.2; letter-spacing: -.02em; font-weight: 650; }

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: .6rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: .5rem; top: .5rem; }

/* --------------------------------------------------------------------------
   3. Layout helpers
   -------------------------------------------------------------------------- */

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.wrap--narrow { max-width: var(--wrap-narrow); }
.center { text-align: center; }
.muted  { color: var(--text-muted); font-size: .95rem; }

.prose { max-width: 42rem; }
.prose p + p { margin-top: 1rem; }

/* --------------------------------------------------------------------------
   4. Header & navigation
   -------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition), background var(--transition);
}
.site-header.is-scrolled { border-bottom-color: var(--border); }

.nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  max-width: var(--wrap);
  margin-inline: auto;
  padding: .9rem var(--gutter);
}

.nav__brand {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -.03em;
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
}
.nav__brand span { color: var(--text-muted); }

.nav__list {
  display: flex;
  gap: 1.5rem;
  font-size: .9375rem;
}
.nav__list a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}
.nav__list a:hover { color: var(--text); opacity: 1; }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle svg {
  grid-area: 1 / 1;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Show the icon for the theme you'd switch *to* */
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun  { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun  { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

/* --------------------------------------------------------------------------
   5. Buttons & tags
   -------------------------------------------------------------------------- */

.btn {
  display: inline-block;
  padding: .7rem 1.4rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: .9375rem;
  font-weight: 550;
  text-decoration: none;
  transition: border-color var(--transition), transform var(--transition),
              background var(--transition);
}
.btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  opacity: 1;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn--primary:hover { filter: brightness(1.08); }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.tags li {
  padding: .3rem .75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: .8125rem;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   6. Sections
   -------------------------------------------------------------------------- */

.section { padding: 5.5rem 0; }
.section--alt {
  background: var(--bg-alt);
  border-block: 1px solid var(--border);
}

.section__title {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  margin-bottom: 2rem;
}
.section__title--center { justify-content: center; }

.section__num {
  font-family: var(--font-mono);
  font-size: .875rem;
  font-weight: 500;
  color: var(--accent);
}

.subhead {
  font-size: .8125rem;
  font-family: var(--font-mono);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin: 2.5rem 0 .9rem;
}

/* Hero -------------------------------------------------------------------- */

.hero {
  padding: clamp(4rem, 10vw, 8rem) 0 clamp(3.5rem, 8vw, 6rem);
  background:
    radial-gradient(60rem 30rem at 15% -10%, var(--accent-soft), transparent 70%);
}

.hero__eyebrow {
  font-family: var(--font-mono);
  font-size: .875rem;
  color: var(--accent);
  margin-bottom: .75rem;
}

.hero__title {
  font-size: clamp(2.75rem, 1.8rem + 5vw, 5rem);
  letter-spacing: -.04em;
  font-weight: 700;
}

.hero__tagline {
  max-width: 34rem;
  margin-top: 1.25rem;
  font-size: clamp(1.0625rem, 1rem + .3vw, 1.25rem);
  color: var(--text-muted);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: 2.25rem;
}

/* Timeline ---------------------------------------------------------------- */

.timeline {
  display: grid;
  gap: 2.5rem;
  max-width: 46rem;
}

.timeline__item {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 1.5rem;
}

.timeline__meta {
  font-family: var(--font-mono);
  font-size: .8125rem;
  color: var(--text-muted);
  padding-top: .3rem;
  white-space: nowrap;
}

.timeline__role { font-size: 1.0625rem; }
.timeline__org  { color: var(--text-muted); font-weight: 400; }
.timeline__body p {
  margin-top: .5rem;
  color: var(--text-muted);
  font-size: .9688rem;
}

.cv-download { margin-top: 3rem; }

/* Project cards ----------------------------------------------------------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 1.25rem;
}

.card {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: transform var(--transition), border-color var(--transition),
              box-shadow var(--transition);
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.card__title { font-size: 1.125rem; }
.card__title a { color: var(--text); text-decoration: none; }
.card:hover .card__title a { color: var(--accent); }

.card__desc {
  flex: 1;
  font-size: .9375rem;
  color: var(--text-muted);
}

.card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .75rem;
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   7. Links page
   -------------------------------------------------------------------------- */

.links-page {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  padding: 4rem 0;
}

.avatar {
  width: 6rem;
  height: 6rem;
  margin: 0 auto 1.25rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--accent);
  object-fit: cover;
}

.link-list {
  display: grid;
  gap: .75rem;
  margin-top: 2.5rem;
}

.link-item {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-weight: 550;
  transition: transform var(--transition), border-color var(--transition),
              box-shadow var(--transition);
}
.link-item:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
  opacity: 1;
}
.link-item svg {
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--accent);
}
.link-item__arrow { margin-left: auto; color: var(--text-muted); }

/* --------------------------------------------------------------------------
   8. Footer & 404
   -------------------------------------------------------------------------- */

.site-footer {
  padding: 2.5rem 0;
  border-top: 1px solid var(--border);
  font-size: .9375rem;
}
.footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  justify-content: space-between;
  align-items: center;
  color: var(--text-muted);
}

.error-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  text-align: center;
}
.error-page__code {
  font-family: var(--font-mono);
  font-size: clamp(4rem, 15vw, 8rem);
  line-height: 1;
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   9. Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 40rem) {
  .nav { gap: 1rem; }
  .nav__list { gap: 1rem; font-size: .875rem; }
  .nav__list li:nth-child(2) { display: none; } /* hide "Experience" on phones */

  .section { padding: 4rem 0; }

  .timeline__item {
    grid-template-columns: 1fr;
    gap: .35rem;
  }
  .timeline__meta { padding-top: 0; }
}
