/* ---- The dock (js/dock.js) ----
 * A row of the three folders (work, side projects, archive) and the
 * Thoughts stack, like the macOS Dock: hovering magnifies them, the page
 * or list you're on has a dot under it. On the homepage it floats at the
 * bottom of the screen (the floating tab's class, css/view-tab.css, gives
 * it its spot and its fade near the footer), and a click switches lists.
 * (The carousel / list button is in the nav, css/home.css.) On project pages it sits at the bottom of the left
 * panel (floating at the bottom of the screen at 991px and below), and a
 * click opens that list on the homepage. Moving between them, it slides
 * from one spot to the other, like the nav (js/dock.js).
 */

.dock {
  --dock-icon: 5.25rem; /* a folder (phones size theirs to fit, below) */
  display: flex;
  align-items: center;
  gap: 1.5rem;
  width: fit-content;
  padding: 1rem 1.5rem 0.75rem;
  border-radius: var(--radius); /* the site's corners, like the thumbnails */
  /* The floating tab's clear glass (css/view-tab.css), a little more blur */
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0.06) 100%);
  -webkit-backdrop-filter: blur(10px) saturate(170%);
  backdrop-filter: blur(10px) saturate(170%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    inset 0 0 0 1px rgba(255, 255, 255, 0.25),
    0 0 0 0.5px rgba(0, 0, 0, 0.06),
    0 8px 24px rgba(0, 0, 0, 0.08),
    0 2px 6px rgba(0, 0, 0, 0.04);
}
html.is-dark .dock {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.02) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 8px 24px rgba(0, 0, 0, 0.35);
}
.dock_folders {
  display: flex;
  align-items: flex-end;
  gap: 1.875rem; /* room to magnify and fan out without overlapping */
}
.dock_item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.dock_item[hidden] {
  display: none;
}
/* The one under the mouse is magnified the most, so it's drawn over its
   neighbours (the archive folder grows over the Thoughts stack, not under it) */
@media (hover: hover) {
  .dock_item:hover {
    z-index: 1;
  }
}
.dock_item:focus-visible {
  outline: 2px solid var(--black);
  outline-offset: 4px;
  border-radius: 0.5rem;
}
/* Bounces on a click (js/dock.js) */
.dock_bounce {
  display: block;
}

/* A folder: its back, the pieces inside, and the front flap. Grows from
   its bottom edge, so it rises out of the dock as it's magnified. */
.dock_folder {
  position: relative;
  display: block;
  width: var(--dock-icon);
  perspective: 200px;
  transform-origin: 50% 100%;
  transition: scale 0.35s cubic-bezier(0.22, 1, 0.36, 1); /* settling back */
}
.dock.is-magnifying .dock_folder {
  transition: scale 0.12s ease-out; /* following the mouse */
}
.dock_folder .folder {
  width: 100%;
}
.dock_folder img {
  display: block;
  width: 100%;
  height: auto;
}

/* The pieces inside, each its own image, laid out like a pile
   (positions are % of the pile, back to front). Work: Figma
   "Folder-Contents-Work-Projects" (1428:1334), wider than the folder, so
   the bottles and the Stryker helmet stick out past its sides. */
.is-pieces {
  aspect-ratio: 981 / 806;
}
.is-pieces.is-side-pile {
  aspect-ratio: 972 / 806;
}
.is-pieces.is-work-pile {
  aspect-ratio: 1;
}
.folder-piece {
  position: absolute;
  display: block;
  height: auto;
  transform-origin: 50% 100%;
}
.dock_folder .folder-piece.is-uber { left: -9.1%; top: -3.1%; width: 38.4%; }
.dock_folder .folder-piece.is-drydown { left: 14.5%; top: -4.1%; width: 30.9%; }
.dock_folder .folder-piece.is-ipad { left: 28.9%; top: -6.1%; width: 48.6%; }
.dock_folder .folder-piece.is-stryker { left: 59%; top: 22.3%; width: 54.1%; }
.dock_folder .folder-piece.is-trubenefits { left: -13%; top: 21.9%; width: 33.8%; }
.dock_folder .folder-piece.is-acuvue { left: 58.7%; top: -3.1%; width: 47.2%; }
.dock_folder .folder-piece.is-ipod { left: 4.5%; top: 5.5%; width: 27%; }
.dock_folder .folder-piece.is-shirt { left: 36%; top: -5.5%; width: 60%; }
.dock_folder .folder-piece.is-cd { left: 26%; top: 16%; width: 36%; }
.dock_folder .folder-piece.is-card { left: 4%; top: 42.5%; width: 36%; }
.dock_folder .folder-piece.is-magazine { left: 18%; top: 30.5%; width: 54%; }
.dock_folder .folder-piece.is-postcard { left: 48%; top: 54%; width: 37.5%; }
/* Archive: a floppy disk, standing straight up in the middle */
.dock_folder .folder-piece.is-floppy { left: 25%; top: -4%; width: 50%; }

/* Hover: the flap tips open and the pieces lift a little */
.dock_folder .folder.is-front {
  transform-origin: bottom center;
  transition: transform 0.25s cubic-bezier(0.32, 0, 0.67, 0);
}
.dock_folder .folder.is-contents {
  transition: translate 0.35s cubic-bezier(0.65, 0, 0.35, 1);
}
@media (hover: hover) {
  .dock_item:hover .folder.is-front {
    transform: rotateX(-28deg);
    transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  .dock_item:hover .folder.is-contents {
    translate: 0 -12%;
    transition: translate 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  }
}

/* ---- Thoughts (experiment) ----
   A little stack of the Thoughts page's note sheets (css/thoughts.css:
   the same paper and ruled lines) after the folders, a link to the page.
   Hovering spreads them up into a loose column, each a little higher
   than the one under it, so they stay clear of the folders beside them. */
.dock_notes {
  --paper-color: #fff;
  --paper-img: url("../images/thoughts/note-paper-small.avif");
  --paper-rule: #dedede;
  --paper-gray: #787474;
  --sheet-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  position: relative;
  display: block;
  /* a sheet's shape, a little under a folder's height (the folders'
     fronts are lower than their tabs), so the row reads as one height */
  width: calc(var(--dock-icon) * 0.54);
  /* Raised to sit on the folders' bottom edge: their images have a soft
     shadow under the folder, so their visible bottom is higher than their box */
  margin-bottom: calc(var(--dock-icon) * 0.11);
  aspect-ratio: 147 / 190.5;
  transform-origin: 50% 100%;
  transition: scale 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
html.is-dark .dock_notes {
  --paper-color: #201c1c;
  --paper-img: url("../images/thoughts/note-paper-small-dark.avif");
  --paper-rule: #3a3434;
  --paper-gray: #9b9696;
  --sheet-shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.1), 0 1px 5px rgba(0, 0, 0, 0.5);
}
.dock.is-magnifying .dock_notes {
  transition: scale 0.12s ease-out;
}
.dock_note {
  position: absolute;
  inset: 0;
  /* Only the stack's own box takes the mouse: the sheets tip out past it,
     and spread up on hover, so hovering a sheet's edge would start the
     spread, move it out from under the mouse, end it, and loop (a stutter) */
  pointer-events: none;
  border-radius: 6%/4.6%;
  background: var(--paper-color) var(--paper-img) center / cover;
  box-shadow: var(--sheet-shadow);
  transform-origin: 50% 100%;
  transition:
    translate 0.35s cubic-bezier(0.65, 0, 0.35, 1),
    rotate 0.35s cubic-bezier(0.65, 0, 0.35, 1);
}
/* A pile, like the Thoughts page's as it loads: the two under the top one
   peek out at the sides */
.dock_note:nth-child(1) { translate: -14% 3%; rotate: -8deg; }
.dock_note:nth-child(2) { translate: 13% 1%; rotate: 7deg; }
.dock_note:nth-child(3) { rotate: -1deg; }
/* Each sheet: the Thoughts sheet's ruled lines (seven, 18 apart on a
   147 × 190.5 sheet) and its note's date under them, the newest on top
   (js/dock.js) */
.dock_note {
  container-type: inline-size;
}
.dock_note::before {
  content: "";
  position: absolute;
  top: 15.2%;
  left: 10.9%;
  right: 10.2%;
  height: 57.2%;
  background: repeating-linear-gradient(to bottom, var(--paper-rule) 0 1px, transparent 1px 16.5%); /* 18 of the box's 109 */
}
.dock_note-date {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8.9%;
  color: var(--paper-gray);
  font-family: Geist, sans-serif;
  font-size: 9.52cqw;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.01em;
  text-align: center;
  white-space: nowrap;
}
@media (hover: hover) {
  .dock_item.is-thoughts:hover .dock_note {
    transition:
      translate 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) var(--note-delay, 0ms),
      rotate 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) var(--note-delay, 0ms);
  }
  .dock_item.is-thoughts:hover .dock_note:nth-child(1) { translate: 0 0; rotate: -4deg; }
  .dock_item.is-thoughts:hover .dock_note:nth-child(2) { translate: 0 -13%; rotate: 3deg; --note-delay: 40ms; }
  .dock_item.is-thoughts:hover .dock_note:nth-child(3) { translate: 0 -26%; rotate: -1deg; --note-delay: 80ms; }
}

/* The page or list you're on: a dot under it, like an open app. One dot
   (.dock_indicator, js/dock.js) glides from item to item and takes on
   each one's color (--dot: the folder's, the same ones the old folder
   sparkles used; the site's black for Thoughts). Each item's own
   .dock_dot is only its spot. */
.dock_dot {
  width: 5px;
  height: 5px;
  visibility: hidden;
}
.dock_item[data-dock-to="work"] { --dot: #f2c230; }
.dock_item[data-dock-to="side"] { --dot: #4fb8f0; }
.dock_item[data-dock-to="archive"] { --dot: #c76ce6; }
.dock_item.is-thoughts { --dot: var(--black); }
.dock_folders {
  position: relative; /* the dot's spots are measured from here */
}
.dock_indicator {
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transition:
    translate 0.5s cubic-bezier(0.65, 0, 0.35, 1),
    background-color 0.5s ease,
    opacity 0.3s ease;
}

/* The floating tab is a pill; the dock is a rounded rectangle */
.view-tab.dock {
  gap: 1.5rem;
  padding: 1rem 1.5rem 0.75rem;
  border-radius: var(--radius); /* the site's corners, like the thumbnails */
  -webkit-backdrop-filter: blur(10px) saturate(170%);
  backdrop-filter: blur(10px) saturate(170%);
}

/* ---- Project pages: at the bottom of the left panel ----
   The panel (css/project-panel.css) is a window tall here, so the dock
   sits at its foot; the text above scrolls if it runs out of room. */
@media screen and (min-width: 992px) {
  .project-panel.has-dock {
    height: calc(100vh - 2.5rem);
  }
  /* Centered in the column, and 1.5rem off the window's bottom like the
     homepage's (the panel ends 1.25rem up), so sliding between the two is
     a move straight across */
  .dock.is-panel {
    flex: none;
    align-self: center;
    margin-top: auto;
    margin-bottom: 0.25rem;
  }
  .project-panel.has-dock .project-panel_content {
    margin-bottom: 1.5rem;
  }
}
/* Smaller desktops: the panel's column is narrower than the dock, so its
   items keep their tighter spacing there */
@media screen and (min-width: 992px) and (max-width: 1279px) {
  .dock.is-panel .dock_folders {
    gap: 1.25rem;
  }
}
/* 991px and below: the panel stacks above the grid, so the dock floats at
   the bottom of the screen, like the homepage's */
@media screen and (max-width: 991px) {
  .dock.is-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(1.5rem + env(safe-area-inset-bottom));
    z-index: 5;
    margin-inline: auto;
  }
}
@media screen and (max-width: 479px) {
  .dock.is-panel {
    bottom: calc(2rem + env(safe-area-inset-bottom));
  }
}
/* The Thoughts page: floating at the bottom of the screen at every size,
   like the homepage's, and under an open note (css/thoughts.css, z-index 5) */
.dock.is-floating {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(1.5rem + env(safe-area-inset-bottom));
  z-index: 4;
  margin-inline: auto;
}
@media screen and (max-width: 479px) {
  .dock.is-floating {
    bottom: calc(2rem + env(safe-area-inset-bottom));
  }
}
/* Phones: the folders grow into the page's width (inside its 1rem
   gutters): whatever the padding and gaps leave (7.25rem with the
   gutters), shared by the three folders and the Thoughts stack (0.54 of a
   folder), up to their desktop size. The same on every page. */
@media screen and (max-width: 479px) {
  .view-tab.dock,
  .dock.is-built {
    --dock-icon: min(4.5rem, calc((100vw - 7.25rem) / 3.54));
    padding-inline: 1.125rem;
  }
  .dock_folders {
    gap: 1rem;
  }
}
/* Fades out and drops away as the footer comes up (html.footer-near,
   js/site-footer.js), like the homepage's */
.dock.is-built {
  transition:
    opacity 0.3s ease,
    translate 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    scale 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
/* 991px and below, where it floats over the page: it drops away while
   you scroll down and comes back when you scroll up (js/dock.js) */
.dock.is-built.is-scrolled-away {
  opacity: 0;
  translate: 0 calc(100% + 1.5rem);
  pointer-events: none;
}
html.footer-near .dock.is-built {
  opacity: 0;
  translate: 0 1.5rem;
  scale: 0.92;
  pointer-events: none;
}
/* Page load: fades up after the panel's text (css/page-intro.css), unless
   it's sliding over from the last page (js/dock.js) */
html.page-intro .dock.is-built:not(.is-sliding) {
  animation: page-intro var(--intro-ms) var(--intro-ease) backwards;
  animation-delay: calc(2 * var(--intro-gap));
}
/* The homepage's dock (the floating tab's fade-up, css/view-tab.css) too.
   Arriving from a project page it's hidden until the slide starts
   (`dock-slide`, set by js/page-arrival.js), in case the page paints first. */
html.page-intro .view-tab.dock.is-sliding,
html.dock-slide .view-tab.dock {
  animation: none;
}
html.dock-slide .view-tab.dock:not(.is-sliding) {
  opacity: 0;
  animation: dock-slide-failsafe 0s 3s forwards; /* shown anyway if js/dock.js never runs */
}
@keyframes dock-slide-failsafe {
  to { opacity: 1; }
}

/* While a view transition shows them (css/project-panel.css), the dock and
   the nav's glass buttons are drawn on their own, so their glass can't
   blur what's behind it: the dots would show through sharp, then blur as
   it ends. Backed with the page's color instead, which is what the blur
   makes of the dots anyway. */
html:active-view-transition .dock,
html:active-view-transition .email-button,
html:active-view-transition .theme-button {
  background: var(--glass-bg), var(--page-bg, #fff);
}

/* ---- The homepage's folder drop (js/folder-intro.js) ----
   Big copies of the folders in a row in the middle of the screen, over
   the carousel, that fly down into the dock */
.dock-intro_row {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}
/* They stand on one line, like in the dock */
.dock-intro_line {
  display: flex;
  align-items: flex-end;
  column-gap: min(3rem, 7vw);
}
.dock-intro_item {
  position: relative;
  width: 7.5rem;
}
/* The Thoughts stack: the dock's proportions (css/dock.css .dock_notes,
   0.54 of a folder wide, raised 0.11 of one), at the copies' size */
.dock-intro_item.is-notes {
  width: calc(7.5rem * 0.54);
  padding-bottom: calc(7.5rem * 0.11);
}
.dock-intro_item .dock_notes {
  width: 100%;
  margin: 0;
  transition: none;
}
/* Shrinks, leans and squashes around its bottom middle */
.dock-intro_body {
  transform-origin: 50% 100%;
}
.dock-intro_item .dock_folder {
  width: 100%;
  transition: none;
}
@media screen and (max-width: 767px) {
  .dock-intro_item {
    width: 5.5rem;
  }
  .dock-intro_item.is-notes {
    width: calc(5.5rem * 0.54);
    padding-bottom: calc(5.5rem * 0.11);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dock_folder,
  .dock_folder .folder {
    transition: none !important;
  }
}

/* Going between the homepage and Thoughts (js/dock.js): no more clicks
   while the page switches */
html.is-switching body {
  pointer-events: none;
}
