/* ---------------------------------------
   THE PROJECT HUB
   Inside the black hole, over the darkness (z-index 500 in style.css).
   Hidden and inert until hub.js opens it; then the branches draw, the
   stars fade in one after another, and the card rises. Animation is
   opacity, transform and the branches' dash offset only.
--------------------------------------- */

.project-hub {
  --gold: #f2a93b;
  --cream: #fdfbd4;
  --dim: rgba(253, 251, 212, 0.7);
  --line: rgba(242, 169, 59, 0.45);
  --rise-ease: cubic-bezier(0.16, 1, 0.3, 1);

  /* Pinned to the screen, so the hub covers what is actually visible however
     a phone's bars move, and can't be scrolled away (PROJECT-HUB.md, B2). */
  position: fixed;
  inset: 0;
  /* Room for Safari's see-through address bar on iPhones (set at the end). */
  bottom: var(--hub-bottom-room, 0px);
  z-index: 600;
  font-family: 'Orbitron', sans-serif;
  color: var(--cream);
  opacity: 0;
  visibility: hidden;
  /* Hidden after the fade, so nothing can be reached while closed. */
  transition: opacity 700ms ease, visibility 0s linear 700ms;
}

.project-hub.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity 700ms ease, visibility 0s;
}


/* ---- Branches ---- */

.hub-branches {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

/* Each path has pathLength 1, so one dash of length 1 draws it in. */
.hub-branches path {
  fill: none;
  stroke: var(--line);
  stroke-width: 1.2;
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
  transition:
    stroke-dashoffset 900ms var(--rise-ease) calc(200ms + var(--hub-order, 0) * 90ms),
    stroke 300ms ease;
}

.project-hub.is-open .hub-branches path {
  stroke-dashoffset: 0;
}

.hub-branches path.is-chosen {
  stroke: var(--gold);
  stroke-width: 1.6;
}


/* ---- Stars ----
   A star's dot is centred on its place (hub-layout.js); the label runs to
   its right. The button is at least 44 px tall so it is easy to tap. */

.hub-star {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 0;
  padding: 0 10px 0 0;
  border: 0;
  background: none;
  color: var(--cream);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transform: translate(-7px, -50%);
  opacity: 0;
  transition: opacity 500ms ease calc(300ms + var(--hub-order, 0) * 90ms);
}

.project-hub.is-open .hub-star {
  opacity: 1;
}

/* A folded branch (hub.js sets hidden). Needed because .hub-star sets display. */
.hub-star[hidden] {
  display: none;
}

.hub-dot {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 22%, var(--gold) 48%, rgba(242, 169, 59, 0) 74%);
  box-shadow: 0 0 12px rgba(242, 169, 59, 0.55);
  transition: box-shadow 300ms ease, transform 300ms var(--rise-ease);
}

/* A dark backing, so the branches pass behind a label rather than through
   its letters. The negative margin keeps the text where it was. */
.hub-label {
  margin-left: -6px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(3, 3, 3, 0.92);
  transition: color 300ms ease;
}

/* xeya's branches: smaller stars, quieter labels. */
.hub-star.hub-branch {
  transform: translate(-5px, -50%);
  font-size: 11px;
  color: var(--dim);
}

.hub-star.hub-branch .hub-dot {
  width: 10px;
  height: 10px;
}

/* Sina, the root: the biggest star, not a button. */
.hub-star.hub-root {
  transform: translate(-11px, -50%);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--gold);
  cursor: default;
}

/* In the spread tree the root's label sits on its left, out of the branches;
   the dot stays centred on the root's place. */
.hub-star.hub-root.label-left {
  flex-direction: row-reverse;
  padding: 0 0 0 10px;
  transform: translate(calc(-100% + 11px), -50%);
}

.hub-root.label-left .hub-label {
  margin-left: 0;
  margin-right: -6px;
}

.hub-root .hub-dot {
  width: 22px;
  height: 22px;
  box-shadow: 0 0 24px rgba(242, 169, 59, 0.8), 0 0 60px rgba(242, 169, 59, 0.3);
}

.hub-star[aria-pressed="true"] .hub-label,
.hub-star:hover .hub-label,
.hub-star:focus-visible .hub-label {
  color: var(--gold);
}

.hub-star[aria-pressed="true"] .hub-dot {
  transform: scale(1.25);
  box-shadow: 0 0 18px rgba(242, 169, 59, 0.9), 0 0 40px rgba(242, 169, 59, 0.35);
}

.hub-star:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: 4px;
  border-radius: 999px;
}


/* ---- The card ----
   The box is the most room the card may take (hub-layout.js); the card
   sits in it, centred on a wide screen and at the top on a tall one, and
   scrolls inside if its text is longer. */

.hub-card-box {
  position: absolute;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  pointer-events: none;
}

.project-hub[data-mode="tall"] .hub-card-box {
  align-items: flex-start;
}

.hub-card {
  box-sizing: border-box;
  width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(4, 5, 10, 0.84);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  /* The text scrolls in .hub-card-body, set in from this rounded border,
     so the scrollbar stays on the straight edge (PROJECT-HUB.md, H4). */
  overflow: hidden;
  pointer-events: auto;
  opacity: 0;
  transform: translate3d(0, 12px, 0);
  transition: opacity 600ms ease 600ms, transform 600ms var(--rise-ease) 600ms;
}

.project-hub.is-open .hub-card {
  opacity: 1;
  transform: none;
}

.hub-card-body {
  flex: 0 1 auto;
  min-height: 0;
  /* With the padding, the same 20px / 22px around the text as before. */
  margin: 10px 6px 10px 0;
  padding: 10px 16px 10px 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(242, 169, 59, 0.55) transparent;
  /* Lets the link button tighten its spacing on narrow cards (below). */
  container-type: inline-size;
}

.hub-kicker {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

/* Folded branches: the project and its parts as tabs (hub.js, partsFor). */
.hub-parts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}

.hub-part {
  min-height: 32px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: var(--dim);
  font: inherit;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
}

.hub-part[aria-pressed="true"],
.hub-part:hover,
.hub-part:focus-visible {
  border-color: var(--gold);
  color: var(--gold);
}

.hub-title {
  margin: 0 0 10px;
  color: var(--cream);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

/* The role: its title in bold capitals, the sentence after it in plain gold
   type, so a long role stays easy to read. */
.hub-role {
  margin: 0 0 12px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
  letter-spacing: 0.02em;
}

.hub-role-title {
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cream);
}

.hub-line {
  margin: 0 0 14px;
  white-space: pre-line; /* keeps the paragraphs in a card's text */
  color: var(--cream);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.7;
  letter-spacing: 0.02em;
}

.hub-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.hub-stack li {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--dim);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hub-link {
  display: inline-flex;
  align-items: center;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--cream);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-decoration: none;
  text-transform: uppercase;
  /* One line, never wrapped in two (PROJECT-HUB.md, H3). */
  white-space: nowrap;
  max-width: 100%;
  box-sizing: border-box;
  transition: border-color 300ms ease, color 300ms ease;
}

.hub-link:hover,
.hub-link:focus-visible {
  border-color: var(--gold);
  color: var(--gold);
}

.hub-link-arrow {
  margin-left: 10px;
  color: var(--gold);
}

/* Narrow cards: tighter spacing, so the button still fits on one line. */
@container (max-width: 330px) {
  .hub-link {
    padding: 8px 12px;
    font-size: 10px;
    letter-spacing: 0.1em;
  }

  .hub-link-arrow {
    margin-left: 6px;
  }
}

@container (max-width: 260px) {
  .hub-link {
    font-size: 9px;
    letter-spacing: 0.05em;
  }
}


/* ---- Reduced motion: everything at its end state at once ---- */

.project-hub.is-instant,
.project-hub.is-instant * {
  transition: none !important;
}

@media (prefers-reduced-motion: reduce) {

  .project-hub,
  .project-hub * {
    transition: none !important;
  }

}


/* ---- Contact me ----
   In the strip along the bottom that the layout leaves free (CONTACT_ROOM in
   hub.js), so it never covers a star or the card. Fades in after the card. */

.hub-contact {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 44px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9em;
  font-size: clamp(10px, 3vw, 13px);
  letter-spacing: 0.1em;
  color: var(--dim);
  pointer-events: none;
  opacity: 0;
  transition: opacity 600ms ease;
}

.project-hub.is-open .hub-contact {
  opacity: 1;
  transition: opacity 600ms ease 900ms;
}

.hub-contact-link {
  color: var(--gold);
  text-decoration: none;
  pointer-events: auto;
}

.hub-contact-link:hover,
.hub-contact-link:focus-visible {
  text-decoration: underline;
  text-underline-offset: 3px;
}


/* ---- iPhones: room for Safari's see-through address bar ----
   The floating bar covers the bottom of the screen even at 100svh, so the
   card and the contact line stay above it. -webkit-touch-callout exists
   only on iOS, so computers and Android are unchanged. Only on taller iPhones:
   on a short one (an SE) it would leave the card too little height, and
   the card's text scrolls out from under the bar anyway (PROJECT-HUB.md, B2). */
@supports (-webkit-touch-callout: none) {
  @media (min-height: 700px) {
    .project-hub {
      --hub-bottom-room: 76px;
    }
  }
}
