/* ==========================================================================
   layout.css — page structure: header, hero, sections, footer
   Depends on tokens.css and base.css.
   ========================================================================== */

.skip-link {
  z-index: 100;
}

/* --- Header ---------------------------------------------------------------
   Sticky, compact. Nav scrolls horizontally on narrow viewports instead of
   collapsing into a hamburger — that keeps every link reachable and
   operable with zero JavaScript. */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-m);
  height: var(--header-height);
  padding-inline: var(--gutter);
  background-color: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: var(--border-width) solid var(--border);
}

.site-header__name {
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: var(--step-1);
  color: var(--text);
  text-decoration: none;
}

.site-header__name:hover {
  color: var(--text);
}

.site-nav {
  display: flex;
  gap: var(--space-m);
  overflow-x: auto;
  scrollbar-width: none;
  margin-inline-start: auto;
}

.site-nav::-webkit-scrollbar {
  display: none;
}

.site-nav a {
  flex-shrink: 0;
  padding-block: var(--space-2xs);
  color: var(--text-muted);
  font-size: var(--step--1);
  font-weight: var(--weight-medium);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}

.site-nav a:hover {
  color: var(--text);
}

.site-nav a[aria-current='true'] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.theme-toggle {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-pill);
  border: var(--border-width) solid var(--border);
  color: var(--text-muted);
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.theme-toggle svg {
  width: 1.125rem;
  height: 1.125rem;
}

/* Only one of the two icons is shown, based on the resolved theme. Both
   exist in the DOM so there is no flash while JS decides. */
:root:not([data-theme='dark']) .theme-toggle .icon-moon,
:root[data-theme='dark'] .theme-toggle .icon-sun {
  display: none;
}

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

/* --- Page rhythm ----------------------------------------------------------- */

main {
  display: block;
}

.wrap {
  max-width: var(--width-wide);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

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

section:not(:first-child) {
  border-top: var(--border-width) solid var(--border);
}

.section-head {
  max-width: var(--width-content);
  margin-bottom: var(--space-l);
}

.section-head > * + * {
  margin-top: var(--space-2xs);
}

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

.hero {
  padding-block: clamp(3rem, 6vw, 5rem) var(--space-section);
}

.hero__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xl);
  align-items: center;
}

@media (min-width: 640px) {
  .hero__grid {
    grid-template-columns: 1fr auto;
  }
}

.hero__text > * + * {
  margin-top: var(--space-s);
}

.hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-3xs) var(--space-xs);
  border-radius: var(--radius-pill);
  background-color: var(--accent-soft);
  color: var(--accent-soft-text);
  font-size: var(--step--1);
  font-weight: var(--weight-medium);
}

.hero__eyebrow::before {
  content: '';
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background-color: currentColor;
}

.hero h1 {
  margin-top: var(--space-s);
}

.hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs) var(--space-m);
  color: var(--text-muted);
  font-size: var(--step--1);
}

.hero__meta span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3xs);
}

/* The years-in-data-engineering span has no icon — just text with a nested
   <span class="years-exp"> for theme.js to update. It doesn't need flex
   layout at all, and inheriting it from the rule above was the actual bug:
   flexbox's gap was inserted between "14" and "+ years..." as two separate
   flex items, showing up as a stray space (or, on a narrow viewport, a line
   break) that was never there in the plain-text version. Higher specificity
   than .hero__meta span so it reliably wins regardless of source order. */
.hero__meta span.hero__meta-years {
  display: inline;
}

.hero__meta svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-s);
  padding-top: var(--space-xs);
}

.hero__portrait {
  order: -1;
  justify-self: center;
  width: min(220px, 55vw);
  overflow: hidden;
  border-radius: var(--radius-l);
  border: var(--border-width) solid var(--border);
  box-shadow: var(--shadow-m);
}

@media (min-width: 640px) {
  .hero__portrait {
    order: initial;
    width: 240px;
  }
}

/* --- Footer ------------------------------------------------------------------ */

.site-footer {
  padding-block: var(--space-xl);
  border-top: var(--border-width) solid var(--border);
}

.site-footer__grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-m);
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-m);
}

.site-footer__links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--step--1);
}

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

.site-footer__meta {
  color: var(--text-muted);
  font-size: var(--step--1);
}

.back-to-top {
  color: var(--text-muted);
  font-size: var(--step--1);
  text-decoration: none;
}

@media (max-width: 639px) {
  /* The floating back-to-top-fab already covers this need below 640px —
     showing both would be two shortcuts doing the same thing right next
     to each other. Desktop/tablet keeps this text link, since the fab
     doesn't exist there. */
  .back-to-top {
    display: none;
  }
}

/* Floating "back to top" shortcut — mobile only. The sticky header's name
   link already gives desktop/tablet a one-click way back to #top; on a
   long page this is the same shortcut, placed in the one-handed thumb
   zone instead of the top corner. */
.back-to-top-fab {
  display: none;
}

@media (max-width: 639px) {
  .back-to-top-fab {
    display: grid;
    place-items: center;
    position: fixed;
    bottom: 5.5rem;
    right: var(--gutter);
    z-index: 15;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: var(--radius-pill);
    border: var(--border-width) solid var(--border);
    background-color: var(--surface-raised);
    color: var(--text-muted);
    box-shadow: var(--shadow-m);
    opacity: 1;
    transition: opacity 0.15s ease;
  }

  /* Hidden near the top of the page — added/removed by theme.js based on
     scroll position. Visible by default (this rule not applied) so a
     visitor without JavaScript still gets a working, always-shown button
     rather than one that can never appear. */
  .back-to-top-fab.is-hidden {
    opacity: 0;
    pointer-events: none;
  }

  .back-to-top-fab:hover,
  .back-to-top-fab:focus-visible {
    color: var(--text);
    border-color: var(--border-strong);
  }

  .back-to-top-fab svg {
    width: 1.25rem;
    height: 1.25rem;
  }
}
