/* Content panels and their unfold choreography, entry cards (experience, research, education), and skills. */

/* The room that opens between the nav words and the social icons */
.panel {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(5rem + var(--safe-top));
  bottom: calc(6rem + var(--safe-bottom));
  padding: 0 var(--gutter);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  /* Visible at once on show. On hide, stay visible long enough for the boxes to
     fold, then vanish (no cross-fade). */
  transition: opacity 0s linear var(--panel-hide-delay);
}

.bar.active .panel.shown {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0s;
}

/* Ink boxes unfold from the center, logos fade in, then text wipes in left to
   right, line by line. All of it reverses on collapse, faster. */
.entry-card,
.skill-box,
.skills-legend,
.panel-inner.projects {
  transform: scaleY(0);
  transform-origin: center;
  transition: transform var(--fold) ease;
}

.bar.active .panel.shown .entry-card,
.bar.active .panel.shown .skill-box,
.bar.active .panel.shown .skills-legend,
.bar.active .panel.shown .panel-inner.projects {
  transform: scaleY(1);
  transition: transform var(--unfold) ease;
}

/* Logos fade in once the box has formed, rather than wiping */
.entry-logo {
  opacity: 0;
  transition: opacity var(--logo-fade-out) ease;
}

.bar.active .panel.shown .entry-logo {
  opacity: 1;
  transition: opacity var(--logo-fade-in) ease var(--logo-delay);
}

/* Text lines wipe in left to right (logos excluded). The close button shows
   only on an open card, after the wipe, so it takes no part; that also lets
   its own hover transition apply. */
.entry-text > *,
.skill-box > h3,
.skill-section > h4,
.skills-legend > *,
.project-card > :not(.close-button) {
  clip-path: inset(0 100% 0 0);
  transition: clip-path var(--wipe-out) ease;
}

.bar.active .panel.shown .entry-text > *,
.bar.active .panel.shown .skill-box > h3,
.bar.active .panel.shown .skill-section > h4,
.bar.active .panel.shown .skills-legend > *,
.bar.active .panel.shown .project-card > :not(.close-button) {
  /* Ends a little past the box, so a focus ring around a title or link
     inside the line is not clipped */
  clip-path: inset(calc(-1 * var(--focus-ring-room)));
  transition: clip-path var(--wipe-in) ease;
  transition-delay: var(--wipe-start);
}

/* Skill pills rise from below and overshoot slightly; their resting (hidden)
   state is in the .skill-pill rule */
.bar.active .panel.shown .skill-pill {
  transform: translateY(0);
  opacity: 1;
  transition:
    transform var(--pill-rise) var(--ease-bounce) var(--pill-delay),
    opacity var(--pill-fade-in) ease var(--pill-delay);
}

/* Stagger the wipe line by line. js/render.js sets each line's --i to its
   position, so the order holds however many lines an entry has. */
.bar.active .panel.shown .entry-text > *,
.bar.active .panel.shown .project-card > :not(.close-button) {
  transition-delay: calc(var(--wipe-start) + var(--i, 0) * var(--wipe-step));
}

/* Experience bullets wipe one line at a time, not as a block */
.entry-text > .bullets {
  clip-path: none;
}

.bullets > li {
  clip-path: inset(0 100% 0 0);
  transition: clip-path var(--wipe-out) ease;
}

.bar.active .panel.shown .bullets > li {
  clip-path: inset(calc(-1 * var(--focus-ring-room)));
  transition: clip-path var(--wipe-in) ease;
  transition-delay: calc(var(--bullet-wipe-start) + var(--i, 0) * var(--wipe-step));
}

.panel-inner {
  max-width: 640px;
  line-height: 1.6;
  font-size: var(--text-base);
}

/* Edge fades (js/edge-fades.js): content fades out at an edge it runs on
   past, sideways or up and down, and nowhere else. A mask on the scroller
   itself, so it works over any background and needs no overlay to place.
   The curve eases in over --fade-before at the start and out over
   --fade-after at the end; both widths animate, so a fade eases away as the
   scroll reaches that end. */
@property --fade-before {
  syntax: '<length>';
  inherits: false;
  initial-value: 0px;
}

@property --fade-after {
  syntax: '<length>';
  inherits: false;
  initial-value: 0px;
}

.edge-fade {
  --fade-axis: to right;
  --fade-size: var(--fade-x);
  mask-image: linear-gradient(
    var(--fade-axis),
    transparent,
    rgb(0 0 0 / 0.04) calc(var(--fade-before) * 0.18),
    rgb(0 0 0 / 0.26) calc(var(--fade-before) * 0.4),
    rgb(0 0 0 / 0.6) calc(var(--fade-before) * 0.64),
    rgb(0 0 0 / 0.88) calc(var(--fade-before) * 0.85),
    #000 var(--fade-before),
    #000 calc(100% - var(--fade-after)),
    rgb(0 0 0 / 0.88) calc(100% - var(--fade-after) * 0.85),
    rgb(0 0 0 / 0.6) calc(100% - var(--fade-after) * 0.64),
    rgb(0 0 0 / 0.26) calc(100% - var(--fade-after) * 0.4),
    rgb(0 0 0 / 0.04) calc(100% - var(--fade-after) * 0.18),
    transparent
  );
  transition:
    --fade-before var(--edge-fade) ease,
    --fade-after var(--edge-fade) ease;
}

.edge-fade.fade-vertical {
  --fade-axis: to bottom;
  --fade-size: var(--fade-y);
}

.edge-fade.show-before {
  --fade-before: var(--fade-size);
}

.edge-fade.show-after {
  --fade-after: var(--fade-size);
}

/* The mask hides anything outside the scroller's box, so a focusable
   scroller draws its ring just inside. */
.edge-fade:focus-visible {
  outline-offset: calc(-1 * var(--focus-ring-width));
}

/* Stacked panels never spill past their panel: when the window is too short or
   narrow, the cards scroll inside it instead of covering the nav above and the
   icons below. The projects rail manages its own overflow. */
.panel-inner.skills,
.panel-inner.entry-list {
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-on-paper) transparent;
}

/* On a touch screen a swipe that reaches a panel's end, the rail's included,
   stops there, instead of scrolling the page and dragging the stage off screen
   (or, sideways, going back a page). */
@media (hover: none) {
  .panel-inner {
    overscroll-behavior: contain;
  }
}

.entry-list {
  max-width: var(--entry-w);
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  text-align: left;
}

.entry-card {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  box-sizing: border-box;
  background: var(--ink);
  border-radius: var(--radius-surface);
  padding: 1.5rem 1.75rem;
}

.entry-card.experience {
  align-items: flex-start;
}

/* Experience: the cards sit side by side, newest at left, when both fit, and
   stack below that width, scrolling inside the panel like the other lists.
   Wrapping decides it, so there is no breakpoint to keep in step with the
   card width. The bottom inset keeps the cards clear of the social icons. */
.experience-panel {
  bottom: calc(7rem + var(--safe-bottom));
}

/* Phones held sideways (touch, 500px tall or less) leave a panel about 200px.
   While one is open, the social row and the credit step aside and the panel
   takes their space; both return when it closes. */
@media (hover: none) and (max-height: 500px) {
  .bar.active .social,
  .bar.active .credit {
    visibility: hidden;
  }

  .panel,
  .experience-panel {
    bottom: calc(1.25rem + var(--safe-bottom));
  }
}

.experience-panel .panel-inner.entry-list {
  max-width: calc(2 * var(--entry-w) + var(--rail-gap));
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--rail-gap);
}

.experience-panel .entry-card {
  flex: 0 1 var(--entry-w);
}

.entry-text .bullets {
  margin: 0.7rem 0 0;
  padding-left: 0;
  list-style: none;
}

.entry-text .bullets li {
  position: relative;
  margin: 0.4rem 0;
  padding-left: 1.1rem;
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--soft);
}

.entry-text .bullets li::before {
  content: '*';
  position: absolute;
  left: 0;
  color: var(--green);
}

.entry-text .bullets strong {
  color: var(--white);
  font-weight: 700;
}

.entry-logo {
  width: 84px;
  height: 84px;
  object-fit: contain;
  flex-shrink: 0;
}

/* Research logos include a wordmark, so they get a double-width slot at the
   same height. Both cards share it, which keeps their text columns aligned. */
.research-list .entry-logo {
  width: 168px;
}

.entry-logo-link {
  display: inline-flex;
  flex-shrink: 0;
}

.entry-text h3 {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.01em;
}

.entry-text .meta {
  margin: 0.35rem 0 0.6rem;
  font-size: var(--text-xs);
  line-height: 1.5;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.entry-text .degree {
  margin: 0.1rem 0;
  font-size: var(--text-md);
  color: var(--bright);
}

.entry-text .activities {
  margin: 0.55rem 0 0;
  font-size: var(--text-xs);
  line-height: 1.5;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.entry-text .activities a {
  color: inherit;
  text-decoration: underline;
}

.entry-text .activities .sep {
  font-size: 1.5em;
  line-height: 0;
  vertical-align: -0.1em;
}

.entry-text .activities .role-group {
  white-space: nowrap;
}

/* Research: a paragraph set like the experience bullets, with its links in
   the technical accent. */
.entry-text .summary {
  margin: 0.6rem 0 0;
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--soft);
}

.entry-text .summary a {
  color: var(--technical);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--technical) 40%, transparent);
  transition: border-color var(--hover) ease;
}

@media (hover: hover) {
  .entry-text .summary a:hover {
    border-bottom-color: var(--technical);
  }
}

/* Narrow phones: the logo moves above the text, which keeps the desktop's
   left alignment (and its bullets) in the full card width. */
@media (max-width: 480px) {
  .entry-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.9rem;
  }
}

/* A grid, so the boxes share one height but are never shorter than their
   pills: on a short window the row stays full height and the list scrolls
   (a stretched flex row would squeeze the boxes and spill their pills).
   Five tracks: the sectioned Tools box takes two, and sets its sections in
   two columns, so it stays as short as the others. */
.panel-inner.skills {
  max-width: 1280px;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1.25rem;
}

.skill-box.sectioned {
  grid-column: span 2;
}

.skill-sections {
  columns: 2;
  column-gap: 1.25rem;
}

.skill-section {
  break-inside: avoid;
  padding-bottom: 1rem;
}

.skill-section h4 {
  margin: 0 0 0.6rem;
  font-size: var(--text-xs);
  font-weight: 400;
  letter-spacing: 0.12em;
  color: var(--muted);
}

/* The legend under the boxes: an ink chip, so the two pill colors show on the
   ground they are made for, marked like the project tags. */
.skills-legend {
  grid-column: 1 / -1;
  justify-self: center;
  display: flex;
  gap: 1.5rem;
  margin: 0;
  padding: 0.45rem 1.1rem;
  border-radius: var(--radius-pill);
  background: var(--ink);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  line-height: 1.5;
  color: var(--soft);
}

.legend-kind::before {
  margin-right: 0.45rem;
  font-family: 'Apple Symbols', 'Segoe UI Symbol', 'Arial Unicode MS', sans-serif;
}

.legend-kind.technical::before {
  content: '</>';
  color: var(--technical);
}

.legend-kind.creative::before {
  content: '\2726';
  color: var(--creative);
}

/* Each box spans two of the list's rows, title and pills, as a subgrid, so
   every title in a row of boxes takes the tallest title's height and the
   dividers under them line up, even when one title wraps. */
.skill-box {
  box-sizing: border-box;
  display: grid;
  grid-row: span 2;
  grid-template-rows: subgrid;
  row-gap: 0;
  align-content: start;
  background: var(--ink);
  border-radius: var(--radius-surface);
  padding: 2rem 1.5rem;
  min-height: 360px;
  color: var(--white);
  text-align: center;
}

/* Mid widths, such as a half-screen window: five tracks get too narrow, so
   the three short boxes share a row and Tools takes the full row below, its
   sections in three columns. */
@media (min-width: 721px) and (max-width: 1100px) {
  .panel-inner.skills {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .skill-box {
    min-height: 0;
  }

  .skill-box.sectioned {
    grid-column: 1 / -1;
  }

  .skill-sections {
    columns: 3;
  }
}

.skill-box h3 {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin: 0 0 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--hairline);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--white);
}

.skill-body {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: flex-start;
  gap: 0.5rem;
}

.skill-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.34rem 0.7rem;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--white) 7%, transparent);
  border: 1px solid var(--hairline);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  line-height: 1;
  color: var(--bright);
  white-space: nowrap;
  transform: translateY(16px);
  opacity: 0;
  transition:
    transform var(--pill-out) ease,
    opacity var(--pill-out) ease;
}

.skill-pill.technical {
  color: var(--technical);
  border-color: color-mix(in srgb, var(--technical) 40%, transparent);
  background: color-mix(in srgb, var(--technical) 8%, transparent);
}

.skill-pill.creative {
  color: var(--creative);
  border-color: color-mix(in srgb, var(--creative) 40%, transparent);
  background: color-mix(in srgb, var(--creative) 8%, transparent);
}

/* Phones (≤ 720px): the nav wraps onto two rows, so every panel starts lower,
   and the skill boxes stack instead of sitting side by side. */
@media (max-width: 720px) {
  /* Start every panel below the wrapped nav, so the projects filter and other
     content never overlap the words. The scrolling lists inside carry the
     gutter themselves (below), so the panel adds none: one inset, not two,
     and the scroll area spans the screen. */
  .panel {
    top: calc(7rem + var(--safe-top));
    padding: 0;
  }

  /* Skills stack vertically and scroll within the panel; min-height: 0 trims
     each box to its pills. */
  .panel-inner.skills {
    max-width: none;
    width: 100%;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    padding: 0 var(--gutter);
  }

  .skill-box {
    min-height: 0;
  }

  .skill-box.sectioned {
    grid-column: auto;
  }

  .skill-sections {
    columns: 1;
  }

  /* Research, experience, and education cards run taller here, so their panels
     get more room above and below. */
  .research-panel,
  .experience-panel,
  .education-panel {
    top: calc(8rem + var(--safe-top));
    bottom: calc(7rem + var(--safe-bottom));
  }

  .panel-inner.research-list,
  .panel-inner.entry-list {
    max-width: none;
    width: 100%;
    gap: 1rem;
    padding: 0 var(--gutter);
  }
}
