/* ============================================================
   Max Sirota, portfolio v4
   Light, conversational, icon-chip clusters that fan out
   on hover. Radius: chips 10px, avatar round.
   ============================================================ */

:root {
    --bg: #fdfdfc;
    --text: #21252b;
    --muted: #5b636d;
    --faint: #9aa1a9;
    --line: #e8e8e5;
    --chip-border: #e5e5e2;
    --link: #3b6ce7;
    --link-hover: #2f56c4;
    --gold: #d9a13b;

    --font-sans: 'Satoshi', system-ui, -apple-system, 'Segoe UI', sans-serif;

    --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

::selection {
    background: #d7e2ff;
    color: #1a2440;
}

*:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: 3px;
    border-radius: 4px;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 17px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
    overflow-x: hidden;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================================
   Layout
   ============================================================ */

.page {
    max-width: 680px;
    margin: 0 auto;
    padding: clamp(48px, 9vh, 84px) 26px 40px;
}

h1.row {
    font-size: 1.45rem;
    font-weight: 500;
}

.row {
    display: block;
    font-size: 1.36rem;
    font-weight: 400;
    line-height: 1.8;
    color: var(--text);
}

.group {
    margin-top: 36px;
}

.sub-row {
    margin-top: 10px;
}

.divider {
    height: 1px;
    background: var(--line);
    margin: 34px 0;
}

/* Everything below the divider runs slightly smaller */
.contact .row {
    font-size: 1.18rem;
}

.contact .row + .row {
    margin-top: 10px;
}

.contact-icon {
    color: var(--faint);
    font-size: 1.15rem;
    vertical-align: -2px;
    margin-right: 11px;
}

.footer {
    margin-top: 28px;
    font-size: 0.85rem;
    color: var(--faint);
}

/* Short viewports: compress the vertical rhythm so the home
   page fits without scrolling */
@media (max-height: 820px) {
    .page {
        padding: 32px 26px 28px;
    }

    .group {
        margin-top: 26px;
    }

    .sub-row {
        margin-top: 6px;
    }

    .divider {
        margin: 26px 0;
    }

    .contact .row + .row {
        margin-top: 8px;
    }

    .footer {
        margin-top: 20px;
    }
}

@media (max-height: 780px) {
    .page {
        padding: 24px 26px 20px;
    }

    .row {
        font-size: 1.24rem;
        line-height: 1.7;
    }

    h1.row {
        font-size: 1.32rem;
    }

    .contact .row {
        font-size: 1.1rem;
    }

    .group {
        margin-top: 20px;
    }
}

/* ============================================================
   Text elements
   ============================================================ */

.link {
    color: var(--link);
    text-decoration: none;
    background-image: linear-gradient(currentColor, currentColor);
    background-size: 0% 1.5px;
    background-repeat: no-repeat;
    background-position: 0 100%;
    transition: color 0.2s var(--ease), background-size 0.35s var(--ease);
}

.link:hover {
    color: var(--link-hover);
    background-size: 100% 1.5px;
}

.link-btn {
    background: none;
    border: none;
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    padding: 0;
}

.avatar {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--chip-border);
    box-shadow: 0 1px 3px rgba(20, 24, 32, 0.08);
    display: inline-block;
    vertical-align: middle;
    margin-left: 10px;
}

/* Easter egg: the avatar spins when clicked (and gets dizzy
   if you keep going) */
.avatar,
.page-avatar {
    cursor: pointer;
}

.avatar-spin {
    animation: avatar-spin 0.7s var(--ease);
}

.avatar-dizzy {
    animation: avatar-dizzy 1s ease-in-out;
}

@keyframes avatar-spin {
    to { transform: rotate(360deg); }
}

@keyframes avatar-dizzy {
    0% { transform: rotate(0); }
    20% { transform: rotate(-25deg) scale(0.94); }
    45% { transform: rotate(18deg) scale(1.05); }
    70% { transform: rotate(-10deg); }
    100% { transform: rotate(0); }
}

.eddy {
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}

.eddy-lock {
    display: inline-block;
    color: var(--gold);
    font-size: 0.85em;
    vertical-align: -1px;
}

/* Easter egg: the lock resists a little when poked */
.eddy:hover .eddy-lock {
    animation: lock-wiggle 0.5s var(--ease);
}

@keyframes lock-wiggle {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-16deg); }
    55% { transform: rotate(11deg); }
    80% { transform: rotate(-5deg); }
}

/* ============================================================
   Icon chips & fan-out clusters
   ============================================================ */

.chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: #ffffff;
    border: 1px solid var(--chip-border);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(20, 24, 32, 0.09);
    text-decoration: none;
    flex-shrink: 0;
}

.chip img {
    width: 27px;
    height: 27px;
    object-fit: contain;
}

.chip-lock {
    color: var(--gold);
    font-size: 1.3rem;
}

/* Hover card (product icons): name + what it does,
   pops in with a springy lift */
.chip-card {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: #23272e;
    color: #f5f5f3;
    text-align: left;
    padding: 8px 13px;
    border-radius: 10px;
    white-space: nowrap;
    line-height: 1.45;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(5px) scale(0.94);
    transform-origin: bottom center;
    transition: opacity 0.25s var(--ease), transform 0.35s var(--ease);
    z-index: 30;
}

.chip-card::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    width: 9px;
    height: 9px;
    background: #23272e;
    transform: translateX(-50%) rotate(45deg);
    border-radius: 2px;
}

.chip-card strong {
    font-size: 0.85rem;
    font-weight: 700;
}

.chip-card em {
    font-style: normal;
    font-size: 0.76rem;
    color: #b6bdc6;
}

.chip:hover .chip-card,
.chip:focus-visible .chip-card {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
}

.stack .chip:hover {
    z-index: 20;
}

/* Cluster: cramped and slightly rotated at rest,
   fans apart on hover (transform-only animation). */
.stack {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    background: none;
    border: none;
    padding: 0;
    margin-left: 8px;
    cursor: default;
}

button.stack {
    cursor: pointer;
}

.stack .chip {
    transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease);
    will-change: transform;
}

.stack .chip:not(:first-child) {
    margin-left: -18px;
}

.stack .chip:nth-child(1) { transform: rotate(-7deg); z-index: 1; }
.stack .chip:nth-child(2) { transform: rotate(5deg); z-index: 2; }
.stack .chip:nth-child(3) { transform: rotate(-4deg); z-index: 3; }

.stack:hover .chip,
.stack:focus-visible .chip {
    box-shadow: 0 5px 12px rgba(20, 24, 32, 0.13);
}

/* Chips fan out one after another: a tiny stagger makes the
   spread feel dealt rather than switched */
.stack:hover .chip:nth-child(1),
.stack:focus-visible .chip:nth-child(1) { transform: translateX(0) translateY(-3px) rotate(0) scale(1.07); transition-delay: 0s; }
.stack:hover .chip:nth-child(2),
.stack:focus-visible .chip:nth-child(2) { transform: translateX(24px) translateY(-3px) rotate(0) scale(1.07); transition-delay: 0.04s; }
.stack:hover .chip:nth-child(3),
.stack:focus-visible .chip:nth-child(3) { transform: translateX(48px) translateY(-3px) rotate(0) scale(1.07); transition-delay: 0.08s; }

/* ============================================================
   Mini chess board chip (home): a knight on a 2x2 board that
   hops when you hover
   ============================================================ */

.chip-board {
    margin-left: 10px;
    vertical-align: middle;
    cursor: pointer;
    overflow: visible;
    background: conic-gradient(#f0d9b5 0 25%, #b58863 0 50%, #f0d9b5 0 75%, #b58863 0);
    border-color: #d9c29a;
    transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease);
}

.chip-board .board-knight {
    width: 31px;
    height: 31px;
    filter: drop-shadow(0 1px 1px rgba(20, 24, 32, 0.25));
}

.chip-board:hover,
.chip-board:focus-visible {
    transform: translateY(-3px) rotate(-3deg) scale(1.1);
    box-shadow: 0 6px 14px rgba(20, 24, 32, 0.16);
}

.chip-board:hover .board-knight,
.chip-board:focus-visible .board-knight {
    animation: knight-hop 0.65s var(--ease);
}

@keyframes knight-hop {
    0% { transform: translateY(0) rotate(0); }
    35% { transform: translateY(-9px) rotate(-14deg); }
    60% { transform: translateY(-9px) rotate(10deg); }
    80% { transform: translateY(0) rotate(0) scale(1.05, 0.9); }
    100% { transform: translateY(0) scale(1); }
}

/* ============================================================
   Chess tease bubble ("fancy a game?")
   ============================================================ */

.knight-icon {
    position: relative;
}

.chess-tease {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 12px);
    transform: translateX(-50%) translateY(4px) scale(0.96);
    background: #23272e;
    color: #f5f5f3;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: 10px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
    z-index: 5;
}

.chess-tease::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    width: 10px;
    height: 10px;
    background: #23272e;
    transform: translateX(-50%) rotate(45deg);
    border-radius: 2px;
}

.chess-tease.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
}

/* ============================================================
   Page transitions (home <-> /stack)
   The avatar morphs between its two positions.
   ============================================================ */

@media (prefers-reduced-motion: no-preference) {
    @view-transition {
        navigation: auto;
    }

    ::view-transition-old(root),
    ::view-transition-new(root) {
        animation-duration: 0.22s;
    }

    .avatar,
    .page-avatar {
        view-transition-name: avatar;
    }
}

/* ============================================================
   Entrance: content rises in, top to bottom. Skipped when a
   view transition is animating the navigation instead
   (script.js adds .no-entrance on pagereveal).
   ============================================================ */

@media (prefers-reduced-motion: no-preference) {
    .page > * {
        animation: rise-in 0.55s var(--ease) both;
    }

    .page > *:nth-child(1) { animation-delay: 0.02s; }
    .page > *:nth-child(2) { animation-delay: 0.09s; }
    .page > *:nth-child(3) { animation-delay: 0.16s; }
    .page > *:nth-child(4) { animation-delay: 0.23s; }
    .page > *:nth-child(5) { animation-delay: 0.3s; }
    .page > *:nth-child(6) { animation-delay: 0.36s; }
    .page > *:nth-child(7) { animation-delay: 0.42s; }
    .page > *:nth-child(n+8) { animation-delay: 0.48s; }

    html.no-entrance .page > * {
        animation: none;
    }
}

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Trophy: appears next to the chess line once you've actually
   beaten Max-Bot */
.chess-trophy {
    display: inline-block;
    margin-left: 6px;
    cursor: help;
    animation: trophy-pop 0.6s var(--ease) 0.6s both;
}

.chess-trophy[hidden] {
    display: none;
}

@keyframes trophy-pop {
    0% { opacity: 0; transform: scale(0) rotate(-30deg); }
    70% { transform: scale(1.25) rotate(6deg); }
    100% { opacity: 1; transform: scale(1) rotate(0); }
}

/* Touch devices cannot hover: relax the overlap so chips read */
@media (pointer: coarse) {
    .stack .chip:not(:first-child) {
        margin-left: -10px;
    }
}

/* ============================================================
   Stack page (/stack)
   ============================================================ */

.back {
    display: inline-block;
    font-size: 1.12rem;
    margin-bottom: 44px;
}

.page-avatar {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--chip-border);
    box-shadow: 0 1px 3px rgba(20, 24, 32, 0.08);
    display: block;
    margin-bottom: 36px;
}

.list-heading {
    font-size: 1.5rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    margin-top: 56px;
    margin-bottom: 28px;
}

.tool-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.tool-item {
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 4px 16px;
    align-items: center;
}

/* Logos perk up when their row is hovered */
.tool-item .chip {
    transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease), border-color 0.35s var(--ease);
}

.tool-item .chip img {
    transition: transform 0.35s var(--ease);
}

.tool-item:hover .chip {
    transform: translateY(-3px) rotate(-4deg) scale(1.08);
    box-shadow: 0 6px 16px rgba(20, 24, 32, 0.14);
}

.tool-item:hover .chip img {
    transform: scale(1.12);
}

.tool-name {
    font-size: 1.32rem;
    font-weight: 500;
    justify-self: start; /* shrink to text so the hover underline matches it */
}

.tool-desc {
    grid-column: 2;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 1.1rem;
    padding-left: 2px;
}

.tool-desc i {
    color: var(--faint);
    font-size: 0.95rem;
}

@media (max-width: 480px) {
    .tool-item {
        grid-template-columns: 42px 1fr;
    }

    .tool-name {
        font-size: 1.1rem;
    }

    .tool-desc {
        font-size: 0.94rem;
    }
}

@media (max-width: 640px) {
    /* Keep the tease bubble inside the viewport when the piece
       cluster sits near the right edge */
    .chess-tease {
        left: auto;
        right: -8px;
        transform: translateY(4px) scale(0.96);
    }

    .chess-tease.visible {
        transform: translateY(0) scale(1);
    }

    .chess-tease::after {
        left: auto;
        right: 28px;
        transform: rotate(45deg);
    }
}

@media (max-width: 480px) {
    .row {
        font-size: 1.18rem;
    }

    h1.row {
        font-size: 1.26rem;
    }

    .avatar {
        width: 48px;
        height: 48px;
    }

    .chip {
        width: 42px;
        height: 42px;
    }

    .chip img {
        width: 23px;
        height: 23px;
    }

    .stack:hover .chip:nth-child(2) { transform: translateX(16px) rotate(0); }
    .stack:hover .chip:nth-child(3) { transform: translateX(32px) rotate(0); }
}
