/* ====================================================================
   slowforward — shared CSS (tweaks panel + transitions)
   Page-specific styling lives inside each HTML file.
   ==================================================================== */

/* prevent any single element from triggering horizontal page scroll */
html, body{ overflow-x: clip; max-width: 100%; }
.email, .body p a{ overflow-wrap: anywhere; }

/* on narrow viewports, ch-based widths can exceed the viewport at larger
   text sizes — cap every text-column rule to its parent's width. */
@media (max-width: 1024px){
  .bio, .about, .body, .ttl, figure.photo figcaption, .modal-meta .caption, .modal-meta .desc{
    max-width: 100% !important;
  }
  /* ---- stacked (phone / tablet) reading order ----
     .right stops being a pane so its parts can be ordered independently:
     identity header first, then the page content, then the about + tools. */
  body .stage{ display: flex !important; flex-direction: column; }
  body .stage > .right{ display: contents !important; }
  .left{ order: 2; }
  .right .top{
    order: 1;
    padding: 32px clamp(20px, 5vw, 44px) 24px;
    background: var(--pane-right-bg, var(--panel));
  }
  .right .about{
    order: 3;
    margin: 0 !important;
    padding: 40px clamp(20px, 5vw, 44px);
    background: var(--pane-right-bg, var(--panel));
  }
  .right .pane-tools{
    order: 4;
    padding: 0 clamp(20px, 5vw, 44px) 40px;
    background: var(--pane-right-bg, var(--panel));
    justify-content: flex-end;
  }
  .right .top .mark{ margin-bottom: 20px; }
}

/* ---------------- page transitions ---------------- */
@view-transition { navigation: auto; }

::view-transition-old(root),
::view-transition-new(root){
  animation-duration: 380ms;
  animation-timing-function: cubic-bezier(.2,.7,.2,1);
}
::view-transition-old(root){
  animation-name: sf-fade-out;
}
::view-transition-new(root){
  animation-name: sf-fade-in;
}
@keyframes sf-fade-out{
  to { opacity: 0; transform: translateY(-4px); }
}
@keyframes sf-fade-in{
  from { opacity: 0; transform: translateY(6px); }
}

/* JS fallback fade (used when VT not supported) */
body{
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .4s cubic-bezier(.2,.7,.2,1), transform .5s cubic-bezier(.2,.7,.2,1);
}
body.sf-entered{
  opacity: 1;
  transform: none;
}
body.sf-leaving{
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .25s ease, transform .25s ease;
}

/* If View Transitions API is supported, suppress the JS fade so we don't
   double-animate. Same-origin browsers that implement VT will already
   crossfade the old/new snapshots. */
@supports (view-transition-name: none){
  body{ opacity: 1; transform: none; transition: none; }
  body.sf-leaving{ opacity: 1; transform: none; }
}

/* ---------------- tweaks panel ---------------- */
.sf-tweaks{
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 280px;
  background: #fafafa;
  color: #111;
  border: 1px solid #d8d8d8;
  box-shadow: 0 24px 48px -16px rgba(0,0,0,.18), 0 2px 4px rgba(0,0,0,.06);
  font-family: "Helvetica Neue", Helvetica, "Arial Nova", sans-serif;
  font-size: 12px;
  z-index: 9999;
  opacity: 0;
  transform: translateY(16px) scale(.98);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity .35s cubic-bezier(.2,.7,.2,1), transform .4s cubic-bezier(.2,.7,.2,1);
  border-radius: 2px;
}
.sf-tweaks.open{
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.sf-tweaks header{
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #e6e6e6;
}
.sf-tweaks header strong{
  font-weight: 500;
  letter-spacing: -0.005em;
}
.sf-tweaks header .x{
  background: transparent;
  border: 0;
  font-size: 18px;
  cursor: pointer;
  color: #777;
  padding: 0 4px;
  line-height: 1;
}
.sf-tweaks header .x:hover{ color: #111; }

.sf-tweaks .body{
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sf-tweaks section{
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sf-tweaks label{
  font-size: 11px;
  color: #888;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.sf-tweaks label .v{
  color: #111;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-transform: none;
  font-size: 12px;
}
.sf-tweaks label .u{
  color: #999;
  margin-left: 2px;
  font-size: 10px;
}

.sf-tweaks input[type=range]{
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 1px;
  background: #ccc;
  outline: none;
  margin: 4px 0;
}
.sf-tweaks input[type=range]::-webkit-slider-thumb{
  -webkit-appearance: none;
  width: 12px; height: 12px;
  background: #111; border-radius: 50%; cursor: pointer;
  margin-top: -5.5px;
  transition: transform .2s ease;
}
.sf-tweaks input[type=range]::-moz-range-thumb{
  width: 12px; height: 12px;
  background: #111; border-radius: 50%; cursor: pointer; border: 0;
}
.sf-tweaks input[type=range]:active::-webkit-slider-thumb{ transform: scale(1.2); }

.sf-tweaks .radio{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.sf-tweaks .radio button{
  background: transparent;
  border: 1px solid #d8d8d8;
  padding: 8px 10px;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  color: #444;
  transition: background .2s ease, border-color .2s ease, color .2s ease;
  border-radius: 1px;
}
.sf-tweaks .radio button:hover{ border-color: #999; color: #111; }
.sf-tweaks .radio button.active{
  background: #111; color: #fff; border-color: #111;
}

.sf-tweaks .swatches{
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.sf-tweaks .swatches button{
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  background: #fff;
  border: 1px solid #d8d8d8;
  cursor: pointer;
  height: 38px;
  overflow: hidden;
  transition: transform .2s ease, border-color .2s ease;
  border-radius: 1px;
}
.sf-tweaks .swatches button .sw{
  display: block;
  flex: 1;
}
.sf-tweaks .swatches button .sw.ink{ flex: 0 0 8px; }
.sf-tweaks .swatches button:hover{ border-color: #999; transform: translateY(-1px); }
.sf-tweaks .swatches button.active{
  outline: 1.5px solid #111;
  outline-offset: 1px;
  border-color: #111;
}

.sf-tweaks .reset{
  margin-top: 4px;
  border-top: 1px solid #ececec;
  padding-top: 12px;
}
.sf-tweaks .reset-btn{
  width: 100%;
  background: transparent;
  border: 1px solid #d8d8d8;
  padding: 8px;
  font-size: 12px;
  cursor: pointer;
  color: #555;
  transition: border-color .2s ease, color .2s ease;
}
.sf-tweaks .reset-btn:hover{ border-color: #111; color: #111; }

@media (max-width: 520px){
  .sf-tweaks{ right: 10px; left: 10px; bottom: 10px; width: auto; }
}

/* ---------------- text-size picker (right pane) ---------------- */
.text-size{
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  padding: 0;
}
.text-size button{
  background: transparent;
  border: 0;
  padding: 6px 8px 4px;
  color: var(--mute);
  font-family: inherit;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  letter-spacing: -0.01em;
  transition: color .2s ease, opacity .2s ease;
}
.text-size button[data-size="16"]{ font-size: 13px; }
.text-size button[data-size="18"]{ font-size: 16px; }
.text-size button[data-size="20"]{ font-size: 19px; }
.text-size button:hover{ color: var(--ink); }
.text-size button.active{
  color: var(--ink);
  position: relative;
}
.text-size button.active::after{
  content: "";
  position: absolute;
  left: 6px; right: 6px;
  bottom: 0;
  height: 1px;
  background: var(--ink);
}

/* Top-right placement inside the right pane */
.right{ position: sticky; }
.pane-tools{
  position: absolute;
  top: 28px;
  right: clamp(40px, 6vw, 96px);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.pane-tools .sep{
  display: inline-block;
  width: 1px;
  height: 18px;
  background: var(--mute);
  opacity: .5;
}
.right .text-size{ position: static; align-items: center; }

/* swap-panels icon button */
.panel-swap{
  background: transparent;
  border: 0;
  padding: 4px;
  margin: 0;
  cursor: pointer;
  color: var(--mute);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color .2s ease, transform .35s cubic-bezier(.65,.05,.36,1);
  line-height: 0;
}
.panel-swap:hover{ color: var(--ink); }
/* a hairline ring, half filled, about the cap height of the middle "A";
   it turns over when the panels swap, the filled half changing sides */
.panel-swap .half{
  display: block;
  box-sizing: border-box;
  width: 12px; height: 12px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: linear-gradient(to right, currentColor 50%, transparent 50%);
  transition: transform .5s cubic-bezier(.65,.05,.36,1);
}
body[data-panels="swapped"] .panel-swap .half{ transform: rotate(180deg); }

@media (max-width: 1024px){
  .pane-tools{
    position: static;
    margin: 0;
    display: flex;
  }
  .text-size button{ padding: 10px 10px 8px; }
}

/* ---------------- non-zoomable figures ----------------
   `zoom: false` in an :::image block, or plain markdown images —
   rendered without modal wiring. */
figure.photo.static{ cursor: default; }
figure.photo.static:hover .ph{ transform: none; }

/* panel-swap sweep (assets/shared.js): a same-document view transition.
   The old snapshot stays still, the new one is uncovered from the cream pane
   towards the white one (data-swapping="ltr" or "rtl"), and a hairline with
   its own transition name travels along the edge. Edge and line both animate
   layout-bound properties (clip-path, left) so they advance in the same frame.
   The panes' own background fades are held off so the new snapshot is final. */
html[data-swapping] .left,
html[data-swapping] .right{ transition: none !important; }
html[data-swapping]::view-transition-old(root){ animation: none; }
html[data-swapping]::view-transition-new(root),
html[data-swapping]::view-transition-group(sf-swap-line){
  animation-duration: .72s;
  animation-timing-function: cubic-bezier(.65,0,.35,1);
  animation-fill-mode: both;
}
html[data-swapping="ltr"]::view-transition-new(root){ animation-name: sf-sweep-ltr; }
html[data-swapping="rtl"]::view-transition-new(root){ animation-name: sf-sweep-rtl; }
html[data-swapping="ltr"]::view-transition-group(sf-swap-line){ animation-name: sf-line-ltr; }
html[data-swapping="rtl"]::view-transition-group(sf-swap-line){ animation-name: sf-line-rtl; }
html[data-swapping]::view-transition-group(sf-swap-line){
  background: color-mix(in oklab, var(--ink) 35%, transparent);
}
html[data-swapping]::view-transition-new(sf-swap-line){ animation: none; }
/* the falling code (assets/rain.js) rides above the sweep as its own live
   layer, so it keeps animating without the page being re-captured; its ink
   is the same on either background, so it needs no reveal of its own */
html[data-swapping] .right > .rain{ view-transition-name: sf-rain; }
html[data-swapping]::view-transition-group(sf-rain),
html[data-swapping]::view-transition-new(sf-rain){ animation: none; }
html[data-swapping]::view-transition-old(sf-rain){ display: none; }
.swap-line{
  position: fixed; top: 0; left: 0;
  width: 1px; height: 100vh;
  pointer-events: none;   /* transparent itself: the line is painted on its transition group */
  view-transition-name: sf-swap-line;
}
@keyframes sf-sweep-ltr{
  from{ clip-path: inset(0 100% 0 0); }
  to  { clip-path: inset(0 0 0 0); }
}
@keyframes sf-sweep-rtl{
  from{ clip-path: inset(0 0 0 100%); }
  to  { clip-path: inset(0 0 0 0); }
}
@keyframes sf-line-ltr{
  from{ left: 0; }
  95% { opacity: 1; }
  to  { left: calc(100vw - 1px); opacity: 0; }
}
@keyframes sf-line-rtl{
  from{ left: calc(100vw - 1px); }
  95% { opacity: 1; }
  to  { left: 0; opacity: 0; }
}
