/* Homepage interactions: split-flap role board and the Tools & Tech wiring map. */

/* ---------- Hero column alignment ---------- */
/* Two-column hero: the copy column spans the full height of the lab panel,
   so its first line meets the panel's top edge and its buttons meet the
   panel's bottom edge, with the remaining space shared evenly. */
@media (min-width: 761px) {
  .home-hero__grid { align-items: stretch; }
  .home-hero__copy {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding-block: 2px;
  }
  .home-hero__copy > * { margin-bottom: 0; }
  .home-hero__copy .home-hero__title { margin-bottom: 0; }
}

/* ---------- Split-flap board ---------- */
.home-hero__copy { container-type: inline-size; }

.flap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0 0 18px;
}

.flap__label {
  color: var(--ink-muted);
  font: 500 clamp(.95rem, 1.4vw, 1.08rem)/1.3 var(--font-body);
}

.flap__board {
  display: inline-flex;
  gap: 3px;
  padding: 5px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: #0d0c08;
  color: var(--ink);
  font: 600 clamp(.78rem, calc((100cqi - 60px) / 19.2), 1.3rem)/1 var(--font-mono);
  letter-spacing: 0;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .55);
}

.flap__cell {
  position: relative;
  display: grid;
  place-items: center;
  width: 1.18em;
  height: 1.62em;
  overflow: hidden;
  border-radius: 3px;
  background: linear-gradient(#2a261d 0 50%, #221f17 50% 100%);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .55), inset 0 1px 0 rgba(242, 239, 230, .05);
  perspective: 120px;
}

.flap__cell::after {
  position: absolute;
  inset: 50% 0 auto;
  height: 1px;
  content: "";
  background: rgba(0, 0, 0, .7);
}

.flap__cell.is-blank { background: linear-gradient(#1c1a13 0 50%, #18160f 50% 100%); }

.flap__glyph {
  display: block;
  transform-origin: 50% 50%;
}

.flap__cell.is-flipping .flap__glyph { animation: flap-turn 120ms cubic-bezier(.3, .7, .4, 1); }

@keyframes flap-turn {
  from { opacity: .35; transform: rotateX(-80deg); }
  to { opacity: 1; transform: none; }
}

/* ---------- Skill map ---------- */
/* The map needs the full row, so the section head sits above it. */
.portfolio-home #skills > .container { display: block; }
.portfolio-home #skills .section__head { margin-bottom: clamp(20px, 3vw, 36px); }
.portfolio-home #skills .section__sub { max-width: 58ch; }

.skill-map {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) clamp(64px, 9vw, 120px) minmax(260px, .9fr);
  align-items: start;
}

.skill-map__groups {
  grid-column: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.skill-map__wires {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.skill-map__rail {
  position: relative;
  z-index: 1;
  grid-column: 3;
  border-top: 1px solid var(--rule-strong);
  padding-top: 16px;
}

.skill-group {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
  grid-template-rows: auto 1fr;
  column-gap: clamp(16px, 2.4vw, 32px);
  min-width: 0;
  padding-block: 16px 18px;
  border-top: 1px solid var(--rule-strong);
}
.skill-group h3 { grid-column: 1; }
.skill-group > p { grid-column: 1; }
.skill-group__chips { grid-column: 2; grid-row: 1 / span 2; align-self: start; }

.skill-group h3 {
  margin: 0;
  font-size: clamp(1.02rem, 1.5vw, 1.2rem);
  line-height: 1.35;
}

.skill-group > p {
  margin: 6px 0 12px;
  color: var(--ink-muted);
  font-size: .9rem;
  line-height: 1.55;
}

.skill-group__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.skill-chip {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  /* Opaque so wires can run behind neighbouring chips. */
  background: var(--paper-card);
  color: var(--ink-muted);
  font: 500 .8rem/1.2 var(--font-mono);
  cursor: pointer;
  transition: color var(--transition), background-color var(--transition), border-color var(--transition);
}

.skill-chip:hover { color: var(--ink); border-color: var(--accent-dim); }
.skill-chip.is-linked { color: var(--ink); border-color: var(--accent-dim); background: color-mix(in srgb, var(--accent) 16%, var(--paper-card)); }
.skill-chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.skill-chip:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }

.skill-map__rail-title {
  margin: 0 0 8px;
  color: var(--ink-faint);
  font: 500 .78rem/1.5 var(--font-mono);
}

.skill-map__projects {
  margin: 0;
  padding: 0;
  list-style: none;
}

.skill-map__projects a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
  text-decoration: none;
  transition: opacity var(--transition), background-color var(--transition), box-shadow var(--transition);
}

.skill-map__name { font-weight: 600; font-size: .95rem; line-height: 1.3; }
.skill-map__kind { flex: none; color: var(--ink-faint); font: .72rem/1.3 var(--font-mono); text-align: right; }

.skill-map.has-selection .skill-map__projects li:not(.is-linked) a { opacity: .38; }
.skill-map__projects li.is-linked a {
  background: linear-gradient(90deg, var(--accent-soft), transparent 80%);
  box-shadow: inset 2px 0 0 var(--accent);
}
.skill-map__projects a:hover .skill-map__name,
.skill-map__projects a:focus-visible .skill-map__name { color: var(--accent-bright); }
.skill-map__projects a:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: -2px; }

.skill-map__status {
  min-height: 3.2em;
  margin: 14px 0 0;
  color: var(--ink-muted);
  font: .82rem/1.6 var(--font-mono);
}

.skill-map__wire {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  opacity: .9;
}

.skill-map__wire.is-drawing {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: wire-draw .55s cubic-bezier(.22, 1, .36, 1) forwards;
  animation-delay: calc(var(--i, 0) * 45ms);
}

.skill-map__port { fill: var(--accent-bright); }

@keyframes wire-draw { to { stroke-dashoffset: 0; } }

@media (max-width: 980px) {
  .skill-map { grid-template-columns: minmax(0, 1fr); }
  .skill-map__wires { display: none; }
  .skill-map__rail { grid-column: 1; margin-top: 8px; }
  .skill-map__projects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; }
}

@media (max-width: 640px) {
  .skill-map__projects { grid-template-columns: minmax(0, 1fr); }
  .skill-group { display: block; }
  .skill-group > p { margin-bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .flap__cell.is-flipping .flap__glyph,
  .skill-map__wire.is-drawing { animation: none; stroke-dashoffset: 0; }
}
