/* Shared page structure: the container that keeps content from stretching
   edge to edge, and the header/footer that appear on every page. */

.container {
  width: 100%;
  max-width: var(--container-width);
  margin-inline: auto;
  padding-inline: var(--space-sm);
}

/* Header and nav, matching the "Header 1" frame in Figma:
   68px tall, 64px side padding, name on the left, links on the right. */

.site-header {
  display: flex;
  align-items: baseline;   /* name and links share one baseline */
  justify-content: space-between;
  gap: var(--space-sm);
  min-height: 68px;
  padding: 24px 64px;
}

/* Orange dot after the name.
   Size: a circle looks smaller than flat-topped capitals of the same height,
   so, as type designers do with round letters, it is drawn 12% taller than
   the capitals and centred on them (a little above and below).
   Shape: a real circle (border-radius). The clip-path polygon sits just
   outside it, so it never cuts the edge, but gives the browser points to
   morph into the "back to home" triangle below. It glows slowly between the
   bright orange and the burnt orange used for orange text. */
.site-header__dot {
  display: inline-block;
  width: 0.8em;     /* fallback where the "cap" unit is not supported */
  height: 0.8em;
  vertical-align: -0.04em;
  width: 1.12cap;   /* "cap" = the height of a capital letter in the loaded font */
  height: 1.12cap;
  vertical-align: -0.06cap;
  margin-left: 0.5em;
  border-radius: 50%;
  background: var(--color-signal);
  clip-path: polygon(-12.00% 50.00%, -9.89% 33.95%, -3.69% 19.00%, 6.16% 6.16%, 19.00% -3.69%, 33.95% -9.89%, 50.00% -12.00%, 66.05% -9.89%, 81.00% -3.69%, 93.84% 6.16%, 103.69% 19.00%, 109.89% 33.95%, 112.00% 50.00%, 109.89% 66.05%, 103.69% 81.00%, 93.84% 93.84%, 81.00% 103.69%, 66.05% 109.89%, 50.00% 112.00%, 33.95% 109.89%, 19.00% 103.69%, 6.16% 93.84%, -3.69% 81.00%, -9.89% 66.05%);
  animation: dot-glow 3.2s ease-in-out infinite alternate;
  transition: clip-path .35s cubic-bezier(.65, 0, .35, 1), border-radius .35s cubic-bezier(.65, 0, .35, 1), transform .35s cubic-bezier(.65, 0, .35, 1);
}
@keyframes dot-glow {
  from { background-color: var(--color-signal); }
  to   { background-color: var(--color-signal-text); }
}
/* Away from the home page, hovering the name turns the dot into the
   site's triangle pointing back at the name: "back to home". */
body:not(.is-home):not(.is-locked) .site-header__name:hover .site-header__dot,
body:not(.is-home):not(.is-locked) .site-header__name:focus-visible .site-header__dot {
  clip-path: polygon(25.00% 50.00%, 32.11% 42.89%, 39.23% 35.77%, 46.34% 28.66%, 53.45% 21.55%, 60.56% 14.44%, 67.68% 7.32%, 74.79% 0.21%, 75.00% 9.76%, 75.00% 19.82%, 75.00% 29.88%, 75.00% 39.94%, 75.00% 50.00%, 75.00% 60.06%, 75.00% 70.12%, 75.00% 80.18%, 75.00% 90.24%, 74.79% 99.79%, 67.68% 92.68%, 60.56% 85.56%, 53.45% 78.45%, 46.34% 71.34%, 39.23% 64.23%, 32.11% 57.11%);
  border-radius: 0;
  transform: translateX(-2px) scale(1.06);   /* about the same 10px height as the other triangles */
  animation: none;
  background: var(--color-signal);
}
@media (prefers-reduced-motion: reduce) {
  .site-header__dot { animation: none; transition: none; }
}

/* Site-wide "Pause motion" switch: a small two-bar pause icon after
   "Projects". Its label drops in underneath on hover or keyboard focus,
   like the Projects menu. When motion is paused it becomes the site's
   triangle (play). */
.motion-toggle__item { position: relative; display: flex; align-items: center; }
.motion-toggle {
  position: relative;
  display: grid; place-items: center;
  width: 24px; height: 24px; margin: -6px -8px;   /* 24px target, no extra space in the row */
  padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--color-text);
}
.motion-toggle__icon {
  display: block;
  width: 6px; height: 0.71em; height: 1cap;
  border-left: 2px solid currentColor; border-right: 2px solid currentColor;
  transform: translateY(1px);   /* lines up with the capitals of the links */
  transition: color .15s ease;
}
.motion-paused .motion-toggle__icon {   /* play: the site's triangle */
  width: 0; height: 0;
  border-right: 0;
  border-top: 5px solid transparent; border-bottom: 5px solid transparent;
  border-left: 5px solid var(--color-signal);
  margin-left: 2px;
}
/* The label uses the same black callout bubble as the "Learn more"
   cursor callouts on the project pages: the sharp corner points up at
   the icon. */
.motion-toggle__label {
  position: absolute; top: 100%; right: 2px;
  z-index: 40;
  margin-top: 8px;
  padding: 9px 14px 10px;
  white-space: nowrap;
  font-weight: 700;
  line-height: 16px;
  color: #ffffff;
  background: #000000;
  border-radius: 16px;
  border-top-right-radius: 2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  opacity: 0; transform: translateY(-4px); pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
}
.motion-toggle:hover, .motion-toggle:focus-visible { color: var(--color-signal-text); outline: none; }
.motion-toggle:hover .motion-toggle__label,
.motion-toggle:focus-visible .motion-toggle__label { opacity: 1; transform: none; }
.motion-toggle:focus-visible::after {
  content: ""; position: absolute; inset: 0; border-radius: 4px;
  outline: 2px solid var(--color-signal); outline-offset: 0;
}

/* Everything that moves on its own stops while motion is paused. */
.motion-paused .site-header__dot { animation: none; }
.motion-paused .ai-pill__glow circle { animation-play-state: paused; }

/* "Next project" arrow: the same small orange triangle as the
   Projects menu hover, nudging forward on hover. */
.next-arrow {
  display: inline-block;
  margin-left: 8px;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 5px solid var(--color-signal);
  vertical-align: middle;
  transform: translateY(-1px);
  transition: transform 0.18s ease;
}
a:hover .next-arrow,
a:focus-visible .next-arrow { transform: translate(3px, -1px); }

.site-header__nav ul {
  display: flex;
  gap: 40px;
}

/* The small uppercase label style ("smallTitle" in Figma). */
.small-title {
  font-family: var(--font-label);
  font-size: 12px;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-text);
  transition: color 0.15s ease;
}

a.small-title:hover,
a.small-title:focus-visible {
  color: var(--color-signal-text);
}

/* Projects dropdown. Hidden until hovered, clicked or tabbed into;
   fades and slides down a few pixels when it opens. */
.nav-dropdown {
  position: relative;
}

.nav-dropdown__toggle {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.nav-dropdown__toggle:hover,
.nav-dropdown__toggle:focus-visible,
.nav-dropdown.is-open .nav-dropdown__toggle {
  color: var(--color-signal-text);
}

.nav-dropdown__menu {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 30;
  margin-top: 12px;
  padding: 0 0 12px 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0 !important;
  background: var(--color-bg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}

/* An invisible bridge over the gap, so the mouse can travel from
   "Projects" down into the list without it closing. */
.nav-dropdown__menu::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -13px;
  height: 13px;
}

.nav-dropdown.is-open .nav-dropdown__menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s;
}

/* Each project: right-aligned, 39px apart as in Figma. The hovered one
   turns orange with a small arrow beside it, like a game menu. */
.nav-dropdown__menu li { list-style: none; }
.nav-dropdown__menu a {
  position: relative;
  display: block;
  padding: 12.5px 0;
  white-space: nowrap;
  text-align: right;
  transition: color 0.12s ease;
}
.nav-dropdown__menu a::before {
  content: "";
  position: absolute;
  left: -11px;
  top: 50%;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 5px solid var(--color-signal);
  transform: translate(-4px, -50%);
  opacity: 0;
  transition: opacity 0.12s ease, transform 0.18s ease;
}
.nav-dropdown__menu a:hover,
.nav-dropdown__menu a:focus-visible { color: var(--color-signal-text); }
.nav-dropdown__menu a:hover::before,
.nav-dropdown__menu a:focus-visible::before { opacity: 1; transform: translate(0, -50%); }

@media (prefers-reduced-motion: reduce) {
  .nav-dropdown__menu { transition: none; transform: none; }
}

@media (max-width: 600px) {
  .site-header {
    padding: 20px 24px;
  }
  .site-header__nav ul {
    gap: 18px;
  }
  .site-header__name,
  .site-header__nav a { white-space: nowrap; }   /* keep "About me" and the dot on one line */
}
@media (max-width: 380px) {
  .site-header { padding-left: 20px; padding-right: 20px; flex-wrap: wrap; row-gap: 10px; }
  .site-header__nav ul { gap: 14px; }
}
/* The narrowest phones (and 400% zoom): the links move onto a second line
   under the name instead of pushing the page sideways. */
@media (max-width: 359px) {
  .site-header__nav { width: 100%; }
}

/* Footer */

.site-footer {
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-xl);
}

.site-footer__inner {
  padding-block: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

@media (min-width: 768px) {
  .site-footer__inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

/* ---------- Accessibility note in the bottom bar ----------
   Left side of the "Back to top" bar on About and the project pages
   (not the home page): a quiet grey line that links to "How this site was
   built". Turns burnt orange on hover, with the site's triangle. */
a.page-end__note { justify-self: start; color: var(--color-text-muted); }
a.page-end__note:hover, a.page-end__note:focus-visible { color: var(--color-signal-text); }
.page-end__note .next-arrow { border-top-width: 4px; border-bottom-width: 4px; border-left-width: 4px; margin-left: 6px; }
@media (max-width: 640px) {
  .page-end .page-end__note { grid-column: 1 / -1; order: 3; justify-self: center; margin-top: 14px; }
}

/* The pause switch only appears where something can move: never on the
   password page, and on the home page only once the visitor scrolls down
   from the intro (home.js adds "show-motion"). It keeps its space while
   hidden, so the other links never shift. */
.is-locked .motion-toggle__item { display: none; }
.is-home .motion-toggle__item { visibility: hidden; opacity: 0; transition: opacity .3s ease, visibility 0s .3s; }
.is-home.show-motion .motion-toggle__item { visibility: visible; opacity: 1; transition: opacity .3s ease, visibility 0s; }

/* Links that leave the site: the site's triangle, turned to point
   top-right (instead of the ↗ character). Nudges outwards on hover. */
.ext-arrow {
  display: inline-block;
  width: 0; height: 0;
  margin: 0 0.15em 0 0.5em;
  border-top: 5px solid transparent;    /* same size as the other triangles */
  border-bottom: 5px solid transparent;
  border-left: 5px solid var(--color-signal);
  vertical-align: 0.25em;
  transform: rotate(-45deg);
  transition: transform .18s ease;
}
a:hover .ext-arrow,
a:focus-visible .ext-arrow { transform: translate(2px, -2px) rotate(-45deg); }
