/* The pinned bio column: who, what, where to find, what is playing. */
.bio {
    display: flex;
    flex-direction: column;
    gap: 26px;
    padding: 44px 40px 36px;
}

/* The surface under the column: the flat panel, and over it the gradient
   bio-glow.js draws, let in once its first frame is there. */
.bio-glow {
    overflow: hidden;
    background: var(--panel);
}

.bio-glow canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity var(--reveal-dur) var(--reveal-ease);
}

.bio-glow.is-lit canvas {
    opacity: var(--glow-opacity);
}

.who {
    display: flex;
    align-items: center;
    gap: 16px;
}

.who__avatar {
    flex: none;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--raised);
    overflow: hidden;
}

/* The picture is GitHub's to serve. It stays out until it has decoded
   (avatar.js), then comes into focus over the circle that held its place. */
.who__avatar img {
    transition:
        opacity var(--reveal-dur) var(--reveal-ease),
        filter var(--reveal-dur) var(--reveal-ease);
}

.js .who__avatar img:not(.is-loaded) {
    opacity: 0;
    filter: blur(var(--reveal-blur));
}

.who__meta {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.45;
}

.who__clock {
    color: var(--accent);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.bio__name {
    font-size: clamp(40px, 3.6vw, 54px);
    font-weight: 900;
    font-stretch: 125%;
    line-height: 0.92;
    letter-spacing: -0.03em;
}

.bio__line {
    max-width: 34ch;
    color: var(--muted);
    font-size: 18px;
    line-height: 1.5;
}

.bio__line strong {
    color: var(--fg);
    font-weight: 500;
}

/* Icon tiles in one row, sized by the column, with a line under them that
   names the one in hand (socials.js). The cap keeps them tiles when the column
   is as wide as a tablet. */
.socials {
    container-type: inline-size;
    display: grid;
    gap: 10px;
    max-width: 360px;
}

.socials__row {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
}

/* A tile is its link and, inside it, the face: an <svg> the icon is drawn
   into. The link keeps still as the thing to aim at while the face moves, so
   a tile never slides out from under the pointer that moved it. */
.social {
    --social-bg: var(--raised);
    display: grid;
    aspect-ratio: 1;
    /* Held to its column: a box with a ratio would otherwise take its width
       from the finger-sized min-height below and close the gaps. */
    justify-self: stretch;
}

/* The face leans with the row (socials.js hands each tile its share, --lean):
   up and a little larger under the pointer, less so beside it, and back with
   a spring once the row is let go. A press sinks it. */
.social__face {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-sm);
    background: var(--social-bg);
    fill: currentColor;
    transform:
        translateY(calc(var(--lean, 0) * var(--lean-lift)))
        scale(calc(1 + var(--lean, 0) * var(--lean-grow)));
    transition:
        transform var(--lean-dur) var(--lean-now-ease, var(--lean-return-ease)),
        scale var(--press-dur) var(--press-ease),
        background-color 200ms var(--ease-smooth-out),
        color 200ms var(--ease-smooth-out);
}

/* In hand, the row moves cleanly; the spring is kept for the way back. */
.socials__row:is(:hover, :has(:focus-visible)) {
    --lean-now-ease: var(--lean-ease);
}

.social:active .social__face {
    scale: var(--press-scale);
}

/* The ring goes round the face, wherever the lean has put it. */
.social:focus-visible {
    outline: none;
}

.social:focus-visible .social__face {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

/* Only where the pointer hovers; a tap would leave the tile lit. */
@media (hover: hover) {
    .social:hover {
        --social-bg: var(--accent);
        color: var(--on-accent);
    }
}

@media (hover: none) {
    .social:active {
        --social-bg: var(--raised-hover);
    }
}

@media (pointer: coarse) {
    .social {
        min-height: 44px;
    }
}

/* ── the icons, drawn in parts so each can make a move of its own ── */

/* A part that moves turns and grows about its own middle. */
.social__icon,
.social__flap,
.social__play,
.social__lens,
.social__flash,
.social__ring {
    transform-box: fill-box;
    transform-origin: center;
}

.social--telegram .social__icon {
    stroke: currentColor;
    stroke-width: 1;
    stroke-linejoin: round;
}

/* The flap of the envelope is hinged where its sides end. */
.social__flap {
    transform-origin: 50% 28%;
}

/* Cut out of the icon: the tile shows through, whatever colour it is. */
.social__play {
    fill: var(--social-bg);
    stroke: var(--social-bg);
    stroke-width: 0.8;
    stroke-linejoin: round;
    transition: fill 200ms var(--ease-smooth-out), stroke 200ms var(--ease-smooth-out);
}

.social__lines {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
}

.social__flash {
    fill: currentColor;
    stroke: none;
}

.social__wave {
    fill: none;
    stroke: var(--social-bg);
    stroke-width: 2.1;
    stroke-linecap: round;
    transition: stroke 200ms var(--ease-smooth-out);
}

.social__wave:nth-of-type(2) {
    stroke-width: 1.8;
}

.social__wave:nth-of-type(3) {
    stroke-width: 1.5;
}

/* Sound leaving the Spotify mark: rings its own size, out of sight behind its
   edge until they are sent out past it, the second half a round after the
   first (--ring-round). */
.social__ring {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    vector-effect: non-scaling-stroke;
    opacity: 0;
}

.social__ring + .social__ring {
    animation-delay: calc(var(--ring-round) / 2);
}

/* What each icon does when its tile is taken up. socials.js marks the tile
   (.is-waking) and lets the move play through, whether or not the pointer
   stays for it. One is a state instead: the envelope stands open for as long
   as it is in hand. */
@media (prefers-reduced-motion: no-preference) {
    .social__flap {
        transition: transform var(--duration-fast) var(--ease-smooth-out);
    }

    .social--email:focus-visible .social__flap {
        transform: scaleY(-1);
    }

    @media (hover: hover) {
        .social--email:hover .social__flap {
            transform: scaleY(-1);
        }
    }

    .social--telegram.is-waking .social__icon {
        animation: social-fly 640ms both;
    }

    .social--github.is-waking .social__icon {
        animation: social-tilt 560ms var(--ease-in-out) both;
    }

    .social--youtube.is-waking .social__play {
        animation: social-nudge 420ms var(--ease-smooth-out) both;
    }

    .social--instagram.is-waking .social__lens {
        animation: social-shutter 460ms var(--ease-smooth-out) both;
    }

    .social--instagram.is-waking .social__flash {
        animation: social-flash 460ms var(--ease-in-out) both;
    }

    .social--spotify.is-waking .social__ring {
        --ring-round: 1000ms;
        animation-name: social-ring;
        animation-duration: var(--ring-round);
        animation-timing-function: var(--ease-out);
    }
}

/* Off past one corner of the tile and back in at the opposite one. */
@keyframes social-fly {
    0% {
        transform: none;
        animation-timing-function: cubic-bezier(0.5, 0, 0.9, 0.4);
    }

    45% {
        transform: translate(46px, -46px);
        animation-timing-function: step-end;
    }

    46% {
        transform: translate(-46px, 46px);
        animation-timing-function: var(--ease-smooth-out);
    }

    100% {
        transform: none;
    }
}

@keyframes social-tilt {
    35% { transform: rotate(-14deg); }
    70% { transform: rotate(6deg); }
}

@keyframes social-nudge {
    40% { transform: translateX(1.8px) scale(1.15); }
}

@keyframes social-shutter {
    35% { transform: scale(0.55); }
    70% { transform: scale(1.08); }
}

@keyframes social-flash {
    30%, 45% { opacity: 0.15; }
}

/* From the edge of the mark out toward the edge of the tile, fading on the way. */
@keyframes social-ring {
    0% {
        transform: none;
        opacity: 0.5;
    }

    100% {
        transform: scale(2.3);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .social__face {
        transform: none;
        scale: none;
    }
}

/* ── music: now playing + playlists, pinned to the bottom of the column ── */

.music {
    display: grid;
    gap: 10px;
    margin-top: auto;
}

.music__title {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    transition: opacity 0.3s ease;
}

.music__title.loading {
    opacity: 0.45;
}

#spotify-now-playing {
    /* Named, since the cover's corner is worked out from it. */
    --np-radius: var(--radius-xl);
    min-height: 88px;
    border-radius: var(--np-radius);
    background: var(--raised);
    overflow: hidden;
    transition: background-color 200ms var(--ease-smooth-out);
}

@media (hover: hover) {
    #spotify-now-playing:hover {
        background: var(--raised-hover);
    }
}

.np-card {
    animation: fade-in var(--reveal-dur) var(--reveal-ease);
}

/* The card and the placeholder that holds its place (index.html) share one
   layout, so the card lands exactly on the shapes that stood in for it. */
.np-card,
.np-placeholder {
    display: flex;
    align-items: center;
    gap: 14px;
    --np-pad: 12px;
    min-height: 88px;
    padding: var(--np-pad);
}

@keyframes fade-in {
    from { opacity: 0; }
}

.np-card__art {
    /* Cross-fades covers via .t-icon-swap; a photo shrinking far reads as a
       glitch, so this slot barely scales. */
    --icon-swap-start-scale: 0.94;
    position: relative;
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    /* Concentric with the card around it: its corner, less the gap between.
       That comes to the playlist covers' corner below. */
    border-radius: calc(var(--np-radius) - var(--np-pad));
    overflow: hidden;
    background: var(--raised-hover);
    outline: 1px solid oklch(1 0 0 / 0.1);
    outline-offset: -1px;
}

.np-card__art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.np-card__badge {
    position: absolute;
    right: 4px;
    bottom: 4px;
    display: grid;
    place-items: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--spotify);
}

.np-card__badge svg {
    width: 10px;
    height: 10px;
    fill: #000;
}

/* Only shown while Spotify reports isPlaying, so the pulse is real. It pops in
   when the music starts and shrinks away, quicker, when it stops. */
.np-card__pulse {
    position: absolute;
    top: 5px;
    left: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--spotify);
    transition:
        transform var(--badge-pop-dur) var(--badge-pop-ease),
        opacity var(--badge-fade-dur) var(--badge-pop-ease),
        filter var(--badge-pop-dur) var(--badge-pop-ease);
}

.np-card.is-stale .np-card__pulse {
    transform: scale(0);
    opacity: 0;
    filter: blur(var(--badge-blur));
    transition:
        transform var(--badge-pop-close-dur) var(--badge-close-ease),
        opacity var(--badge-fade-close-dur) var(--badge-close-ease),
        filter var(--badge-pop-close-dur) var(--badge-close-ease);
}

/* The ring is a copy of the dot that grows and fades: transform and opacity
   only, so a loop that runs as long as the music does never repaints. */
.np-card__pulse::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: inherit;
    animation: np-pulse 1.8s infinite;
}

@keyframes np-pulse {
    from { opacity: 0.6; transform: scale(1); }
    70%, to { opacity: 0; transform: scale(3); }
}

.np-card.is-stale .np-card__pulse::after {
    animation: none;
}

.np-card__info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1 1 auto;
    min-width: 0;
}

/* The ellipsis sits on the swapping span itself: as an inline-block it would
   be clipped whole by the line instead of trimmed to "…". */
.np-card__title .t-text-swap,
.np-card__artist .t-text-swap {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.np-card__title {
    font-size: 16px;
    font-weight: 700;
}

.np-card__artist {
    color: var(--muted);
    font-size: 13px;
}

.np-card__progress {
    height: 3px;
    margin-top: 8px;
    border-radius: 2px;
    background: var(--line);
    overflow: hidden;
}

/* Full width, scaled to how far the track is (spotify.js): the run to the end
   of the track is one animation of the transform, with no layout in it. */
.np-card__bar {
    height: 100%;
    background: var(--spotify);
    transform: scaleX(0);
    transform-origin: left;
    transition: background-color 200ms var(--ease-smooth-out);
}

.np-card.is-stale .np-card__bar {
    background: var(--muted);
}

/* A line of the placeholder: a bar where the title or the artist will be,
   inside that line's own box so it takes the height the words will. */
.np-ghost {
    display: inline-block;
    width: var(--ghost-w);
    height: 0.7em;
    border-radius: 3px;
    background: var(--raised-hover);
    vertical-align: middle;
}

/* Without JS no card ever comes, so nothing stands in for one. */
html:not(.js) .np-placeholder {
    visibility: hidden;
}

.np-card__title .np-ghost { --ghost-w: 62%; }
.np-card__artist .np-ghost { --ghost-w: 38%; }

.np-message {
    animation: fade-in var(--reveal-dur) var(--reveal-ease);
    display: grid;
    place-items: center;
    min-height: 88px;
    padding: 12px 16px;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.playlists {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-top: 6px;
}

/* Hold the row's height until the covers arrive: the music block is pinned to
   the bottom of the column, so a row landing late would shove it upward. */
.playlists__ghost {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    background: var(--raised);
}

/* Covers land together once decoded, each a beat after the one before. The
   tile keeps the ghost's colour until its cover is in, then lets it go, so
   the row never dips to the column background between the two. */
.playlists.is-ready > li {
    border-radius: var(--radius-sm);
    animation: playlist-ghost var(--reveal-dur) calc(var(--i) * var(--stagger-stagger)) backwards;
}

.playlists.is-ready img {
    animation: fade-in var(--reveal-dur) var(--reveal-ease) calc(var(--i) * var(--stagger-stagger)) backwards;
}

@keyframes playlist-ghost {
    from, to { background: var(--raised); }
}

.playlist img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background: var(--raised);
    outline: 1px solid oklch(1 0 0 / 0.08);
    outline-offset: -1px;
    transition: transform 260ms var(--ease-smooth-out);
}

.playlist:focus-visible img {
    transform: translateY(-4px) rotate(-3deg);
}

/* Only where the pointer hovers; a tap would leave the cover tipped. */
@media (hover: hover) {
    .playlist:hover img {
        transform: translateY(-4px) rotate(-3deg);
    }
}

.socials__caption,
.playlists__caption {
    min-height: 1.5em;
    color: var(--muted);
    font-size: 13px;
}

/* The line under the tiles reads the one being hovered. A finger hovers
   nothing, so there it would only ever count the tiles above it. */
@media (hover: none) {
    .socials__caption {
        display: none;
    }
}

.socials__caption b,
.playlists__caption b {
    color: var(--fg);
    font-weight: 600;
}

.playlists__error {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 13px;
}

@media (max-width: 900px) {
    .bio {
        padding: 32px 20px 28px;
    }

    /* Stacked, the surface ends where the works begin: it thins out into the
       page behind it over its last stretch rather than stopping at a line. */
    .bio-glow {
        mask-image: linear-gradient(to bottom, #000 calc(100% - 180px), transparent);
    }

    /* Stacked, the column can be tablet-wide; the music block keeps the
       width it was drawn for instead of swelling its covers across it. */
    .music {
        max-width: 480px;
        margin-top: 4px;
    }
}
