/* Controls shared by the site and the 404 page: the corner close (×) and the pill button. */

/* The close (×) in a dialog's top-right corner. No font is set, so a <button>
   keeps the browser's button font and a link keeps the site font. */
.close-button {
  position: absolute;
  top: 1rem;
  right: 1.15rem;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--soft);
  font-size: 1.5rem;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition:
    background var(--hover-fast) ease,
    color var(--hover-fast) ease;
}

/* Hover feedback only where a pointer hovers: on a touch screen a tap leaves
   :hover on what it touched, so the look would stick. */
@media (hover: hover) {
  .close-button:hover {
    background: color-mix(in srgb, var(--white) 10%, transparent);
    color: var(--white);
  }
}

/* An outlined pill link on ink: project links and the 404's way home */
.pill-button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1rem;
  border: 1px solid color-mix(in srgb, var(--white) 30%, transparent);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  color: var(--white);
  text-decoration: none;
  transition:
    background var(--hover-fast) ease,
    border-color var(--hover-fast) ease;
}

.pill-button svg {
  width: 15px;
  height: 15px;
  display: block;
  flex-shrink: 0;
}

@media (hover: hover) {
  .pill-button:hover {
    background: color-mix(in srgb, var(--white) 12%, transparent);
    border-color: color-mix(in srgb, var(--white) 60%, transparent);
  }
}

/* Small controls get an invisible hit area of at least 44px. The ::after
   reaches out by --hit-inset, so the control's own box, and its focus ring,
   stay the size of what you see. */
.nav button,
.filter-btn,
.view-btn,
.social a {
  position: relative;
}

.nav button::after,
.filter-btn::after,
.view-btn::after,
.social a::after {
  content: '';
  position: absolute;
  inset: var(--hit-inset);
}

.nav button {
  --hit-inset: -14px 0; /* 16px words → 44px tall */
}

.filter-btn {
  --hit-inset: -16px 0; /* 12px words → 44px tall */
}

/* 20px icons → 44px tall, but only 4px wider each side, so the two toggles'
   areas meet in their 8px gap instead of overlapping */
.view-btn {
  --hit-inset: -12px -4px;
}

.social a {
  --hit-inset: -8px; /* 28px icons → 44px */
}

/* Touch screens: every control a finger taps reaches 44x44px (WCAG 2.5.5,
   enhanced). Hit areas grow invisibly, except the pill: in an open card it can
   sit at the edge of the card's scroll area, which would clip an invisible
   area, so the pill itself is 44px tall. The view toggles also move apart
   (css/projects.css). A mouse keeps the sizes above. */
@media (hover: none) {
  .close-button::after,
  .rail-step::after,
  .scroll-up::after {
    content: '';
    position: absolute;
    inset: var(--hit-inset);
  }

  .rail-step {
    position: relative;
  }

  .close-button {
    --hit-inset: -5px; /* 34px → 44px */
  }

  .pill-button {
    box-sizing: border-box;
    min-height: 44px;
  }

  .rail-step {
    --hit-inset: -10px; /* 24px → 44px */
  }

  .scroll-up {
    --hit-inset: -7px; /* 30px → 44px */
  }

  .social a {
    --hit-inset: -9px; /* the icon box is a fraction under 28px, so 46px */
  }

  .view-btn {
    --hit-inset: -12px; /* 20px icons → 44px each way */
  }
}

/* Touch screens have no hover, and the tap highlight is off (css/base.css), so
   every control dims while a finger presses it: one look for all of them,
   selected or not, which the social icons already use on hover. */
@media (hover: none) {
  .nav button:active,
  .filter-btn:active,
  .view-btn:active,
  .rail-step:active:not([aria-disabled='true']),
  .social a:active,
  .scroll-up:active,
  .scroll-cue:active,
  .close-button:active,
  .pill-button:active {
    opacity: 0.55;
  }
}

/* The open panel's word and the pressed filter carry the VCR font's pointer,
   so the selection does not rest on color and weight alone (WCAG 1.4.1). The
   empty alternative text keeps it out of the button's spoken name; browsers
   without that syntax use the first declaration. */
.bar.active .nav button[aria-expanded='true']::before,
.filter-btn[aria-pressed='true']::before {
  content: '\25BA';
  content: '\25BA' / '';
  position: absolute;
  right: 100%;
  margin-right: 0.55em;
}

/* In the phone nav's tight two rows, a smaller marker set closer to its word
   keeps 8px from the previous word and from the screen edge, at 360px wide.
   Centered on the word's box, as the smaller glyph no longer shares its line. */
@media (max-width: 720px) {
  .bar.active .nav button[aria-expanded='true']::before,
  .filter-btn[aria-pressed='true']::before {
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8em;
    margin-right: 0.375em;
  }
}
