/* Themes: light (cool paper + blue), dark (ink + lime), lilac (purple tint, light bg + pink) */
/* One size drives the hero, "Say hi", the contact buttons and the footer. */
:root { --fs: clamp(1.9rem, min(5.2vw, 8.2vh), 4.2rem); }

:root,
[data-theme="light"] {
    --bg: #F2F5F9;
    --ink: #0F1B2D;
    --muted: #5B6B80;
    --accent: #2F5BFF;
    --accent-ink: #FFFFFF;
    --pop: #FFB020;
    --chip: #DDE6F3;
    --chip-ink: #0F1B2D;
}
[data-theme="dark"] {
    --bg: #0D0C12;
    --ink: #F3F1EA;
    --muted: #8D8A99;
    --accent: #C8FF3D;
    --accent-ink: #0D0C12;
    --pop: #FF6B9A;
    --chip: #23212C;
    --chip-ink: #F3F1EA;
}
[data-theme="lilac"] {
    --bg: #EEE7FF;
    --ink: #24104F;
    --muted: #6E5A9E;
    --accent: #7A3CFF;
    --accent-ink: #FFFFFF;
    --pop: #FF5CA8;
    --chip: #D9CBFF;
    --chip-ink: #24104F;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-size-adjust: 100%;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: 'Bricolage Grotesque', system-ui, sans-serif;
    min-height: 100dvh;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

.page {
    max-width: 1280px;
    min-height: 100dvh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    /* top: scales with the viewport height but always clears the fixed theme button */
    padding: max(4.25rem, 8vh) clamp(22px, 5.5vw, 48px) max(1.5rem, env(safe-area-inset-bottom));
}

/* ---------- rebus text ---------- */
.rebus {
    text-wrap: balance;
    line-height: 1.22;
    letter-spacing: -0.02em;
}
.hero { font-size: var(--fs); }
.mid  { font-size: var(--fs); display: inline; }

.sans   { font-weight: 800; letter-spacing: -0.035em; }
.serif  { font-family: 'Instrument Serif', serif; font-style: italic; font-weight: 400; letter-spacing: -0.01em; font-size: 1.12em; }
.script { margin-right: 0.15em; font-family: 'Caveat', cursive; font-weight: 700; font-size: 1.15em; color: var(--accent); }
.nowrap { white-space: nowrap; }
.sym    { color: var(--pop); display: inline-block; }
.i { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sym .i { width: 0.75em; height: 0.75em; vertical-align: -0.05em; stroke-width: 3; }
.mid .sym .i { vertical-align: -0.04em; }   /* optically centred on the "Say hi" letters */

/* ---------- chips: the "picture" words ---------- */
.chip {
    --tilt: 0deg;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: -0.14em;
    height: 0.95em;
    min-width: 1.35em;
    padding: 0 0.22em;
    border-radius: 0.32em;
    background: var(--chip);
    color: var(--chip-ink);
    overflow: hidden;
    transform: rotate(var(--tilt));
    transition: transform .45s cubic-bezier(.34, 1.56, .64, 1);
    text-decoration: none;
}
.chip:focus-visible { transform: rotate(0deg) scale(1.12); z-index: 5; }
.chip .i { width: 0.7em; height: 0.7em; }
.chip { position: relative; }

.chip.photo {
    padding: 0;
    width: 1.1em;
    min-width: 0;
    height: 1.1em;
    vertical-align: -0.2em;
    margin: 0 0.16em;
    background: none;
    border-radius: 50%;
    overflow: hidden;
    /* white ring, then a ring in the theme accent, then a soft glow */
    box-shadow: 0 0 0 0.05em #fff,
                0 0 0 0.11em var(--accent),
                0 0.14em 0.5em 0.08em color-mix(in srgb, var(--accent) 45%, transparent);
}
.chip.photo img {
    width: 100%; height: 100%;
    object-fit: cover; object-position: 50% 30%;
    display: block;
    border-radius: 50%;
}

.chip.phone { background: var(--accent); color: var(--accent-ink); }
.chip.phone .phone-img {
    /* the PNG is only a shape: it is used as a mask so the icon takes the chip's ink colour in every theme */
    width: 0.8em; height: 0.8em; display: block;
    background-color: currentColor;
    -webkit-mask: url('../img/iphone.png') center / contain no-repeat;
            mask: url('../img/iphone.png') center / contain no-repeat;
}
.chip.ball  { background: var(--chip); }
.chip.wifi  { background: var(--pop); color: #fff; }
.chip.key   { background: var(--ink); color: var(--bg); }
.chip.bolt  { background: var(--accent); color: var(--accent-ink); }
.chip.code  { background: var(--accent); color: var(--accent-ink); }
.chip.star  { background: var(--pop); color: #fff; }

.chip.word {
    font-weight: 800;
    letter-spacing: -0.04em;
    padding: 0 0.3em;
    line-height: 1.1;
    overflow: visible;
    background: var(--ink);
    color: var(--bg);
}
.chip.word.alt { background: var(--accent); color: var(--accent-ink); }
/* link chips (Novibet, QRiFi) read as clickable: soft shadow that lifts on hover */
.chip.word {
    box-shadow: 0 0.12em 0.4em -0.08em color-mix(in srgb, var(--ink) 45%, transparent),
                0 0.02em 0.08em rgba(0, 0, 0, .18);
}
.chip.word.alt {
    box-shadow: 0 0.12em 0.4em -0.08em color-mix(in srgb, var(--accent) 60%, transparent),
                0 0.02em 0.08em rgba(0, 0, 0, .18);
}

.wave { display: inline-block; vertical-align: -0.1em; transform-origin: 70% 80%; }
.wave { color: var(--pop); cursor: pointer; }
.wave {
    -webkit-user-select: none; user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}
.wave:focus:not(:focus-visible) { outline: none; }
.wave .wave-icon { width: 0.78em; height: 0.78em; display: block; pointer-events: none; stroke-width: 2.2; }

/* ---------- links block ---------- */
.block { margin-top: clamp(2.5rem, 7vh, 4.5rem); }
.links { list-style: none; display: inline; }
.links li { display: inline; }
.chip.link {
    font-size: calc(var(--fs) * 0.6);
    font-weight: 800;
    letter-spacing: -0.03em;
    gap: 0.35em;
    padding: 0 0.5em 0 0.3em;
    height: 1.5em;
    margin: 0.12em 0.08em;
    vertical-align: 0.45em;       /* raises the buttons onto the "Say hi" centre line */
}
.chip.link .i { width: 0.85em; height: 0.85em; }
.chip.link.cv { background: var(--ink); color: var(--bg); }
.cv-row .chip.cv { font-size: calc(var(--fs) * 0.78); padding: 0 0.6em 0 0.45em; height: 1.45em; gap: 0.4em; }   /* résumé is the main call to action: larger */

.cv-row { margin-top: clamp(2rem, 6vh, 3.5rem); }
.cv-row + .block { margin-top: clamp(1.5rem, 4.5vh, 2.75rem); }

.foot {
    margin-top: auto;               /* sticks to the bottom on tall screens */
    padding-top: clamp(2.5rem, 8vh, 5rem);
    display: flex; flex-wrap: wrap; justify-content: center;
}
.eco {
    --leaf: #2E9E5B;
    display: inline-flex; align-items: center; gap: 0.55em;
    padding: 0.55em 1em 0.55em 0.8em;
    border-radius: 999px;
    color: var(--ink);
    background: color-mix(in srgb, var(--leaf) 16%, var(--bg));
    box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--leaf) 45%, transparent);
    text-decoration: none;
    font-size: clamp(0.8rem, calc(var(--fs) * 0.24), 1.05rem);
    line-height: 1.3;
    max-width: 100%;
    transition: transform .4s cubic-bezier(.34, 1.56, .64, 1), box-shadow .3s;
}
@media (max-width: 380px) { .eco { padding: 0.5em 0.9em 0.5em 0.7em; } }
[data-theme="dark"] .eco { --leaf: #5BD58A; }
.eco .i { width: 1.25em; height: 1.25em; color: var(--leaf); transform-origin: 50% 100%; transition: transform .5s cubic-bezier(.34, 1.56, .64, 1); }
.eco b { font-weight: 800; }

/* ---------- theme button ---------- */
.theme-btn {
    position: fixed; top: max(14px, env(safe-area-inset-top)); right: 14px; z-index: 10;
    width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
    cursor: pointer; display: grid; place-items: center;
    background: transparent; color: var(--ink);
    transition: background-color .2s, transform .35s cubic-bezier(.34, 1.56, .64, 1);
}
.theme-icon { width: 26px; height: 26px; transition: transform .5s cubic-bezier(.34, 1.4, .64, 1); }
.theme-btn:active .theme-icon { transform: rotate(180deg); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* ---------- motion ---------- */
@media (prefers-reduced-motion: no-preference) {
    .chip, .wave { will-change: transform; }
}
@keyframes wave {
    0%, 100% { transform: translateX(0) rotate(0); }
    20%, 60% { transform: translateX(-0.04em) rotate(-8deg); }
    40%, 80% { transform: translateX(0.04em) rotate(7deg); }
}

/* Blur Text (ReactBits idea, vanilla): everything in the hero resolves from blur, in reading order.
   Only filter/opacity animate, so tilted chips and the wave loop keep their own transforms. */
@media (prefers-reduced-motion: no-preference) {
    .js .hero > .serif, .js .hero > .sans, .js .hero > .script,
    .js .hero .chip, .js .hero .sym, .js .hero .wave,
    .js .cv-row .chip, .js .mid, .js .mid .sym, .js .links .chip, .js .foot .eco {
        animation: blur-in .8s cubic-bezier(.22, 1, .36, 1) backwards;
        animation-delay: calc(var(--w, 0) * 10ms);
    }
    .js .hero .wave {
        /* same animation list at all times: hover only changes the wave speed, so blur-in never replays */
        --wave-dur: 2s;
        animation: blur-in .8s cubic-bezier(.22, 1, .36, 1) backwards,
                   wave var(--wave-dur) ease-in-out .9s infinite;
        animation-delay: calc(var(--w, 0) * 10ms), .9s;
    }
}
@keyframes blur-in {
    from { filter: blur(12px); opacity: 0; }
    to   { filter: blur(0); opacity: 1; }
}

/* circular theme reveal (View Transitions) */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

/* ---------- hover (mouse only) ----------
   Touch screens keep :hover after a tap, which left buttons stuck highlighted.
   Hover styles therefore apply only where a real pointer can hover. */
@media (hover: hover) and (pointer: fine) {
    .chip:hover, .chip:focus-visible { z-index: 5; }   /* raised chip must paint above its neighbours */
    .chip:hover { transform: rotate(0deg) scale(1.22); }
    .chip.photo:hover { transform: rotate(0deg) scale(1.15); }
    .chip.word:hover { box-shadow: 0 0.22em 0.7em -0.06em color-mix(in srgb, var(--ink) 55%, transparent); }
    .chip.word:hover { background: var(--pop); color: #fff; }
    .chip.link:hover { background: var(--accent); color: var(--accent-ink); }
    .chip.link.cv:hover { background: var(--pop); color: #fff; }
    .eco:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 1.5px var(--leaf), 0 8px 20px -8px var(--leaf); }
    .eco:hover .i { transform: rotate(-18deg) scale(1.15); }
    .theme-btn:hover { background: var(--chip); transform: scale(1.08); }
    .js .hero .wave:hover { --wave-dur: .9s; }
}

/* touch: short press feedback, nothing sticky */
@media (hover: none) {
    .chip:active, .theme-btn:active { transform: scale(0.96); }
    a, button { -webkit-tap-highlight-color: transparent; }
}

/* phones: tighter vertical rhythm between hero, résumé, contact and footer */
@media (max-width: 600px) {
    .cv-row { margin-top: 1.75rem; }
    .cv-row + .block { margin-top: 1.35rem; }
    .block { margin-top: 1.25rem; }
    .foot { padding-top: 1.25rem; }
}
