/* kagt.co.uk · the home hero and project cards that come alive on hover.
   Everything that moves does so only under prefers-reduced-motion: no-preference. */

/* ---------- Shared hero layout ---------- */
.hero-split .wrap { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 40px 56px; align-items: center; padding-block: clamp(64px, 10vw, 128px); }
.hero-split .words { display: grid; gap: 22px; max-width: 600px; }
.hero-split h1 { font: 600 clamp(44px, 7.6vw, 88px)/0.98 var(--display); letter-spacing: -0.025em; }
.hero-split p { font-size: clamp(18px, 2.1vw, 21px); max-width: 42ch; }
.hero-split .art { justify-self: center; position: relative; width: min(380px, 78vw); }
.hero-split .art svg { display: block; width: 100%; height: auto; overflow: visible; }
@media (max-width: 820px) {
    .hero-split .wrap { grid-template-columns: 1fr; }
    .hero-split .art { width: min(240px, 62vw); justify-self: start; }
}

/* ---------- Home hero: the pieces assemble, then the missing T slides in and clicks (navy) ---------- */
.hero-home { background: var(--navy); color: #fff; overflow: hidden; }
.hero-home h1 { font-size: clamp(42px, 7vw, 84px); }
.hero-home p { color: var(--navy-ink); }
.hero-home .art { padding: 0 12% 12% 0; }
.hero-home .art .kagt-square { fill: var(--navy-2); }
.hero-home .art .kagt-tile:not(.kagt-tile--t) .kagt-tile__bg { fill: #34457A; }
.hero-home .art .kagt-mark { --kagt-unlit: #34457A; }
.hero-home .board.is-open .kagt-tile--t .kagt-tile__bg { fill: #0A1128; }
.hero-home .board.is-open .kagt-tile--t .kagt-tile__letter { opacity: 0; }
@media (prefers-reduced-motion: no-preference) { .hero-home .board .kagt-tile--t.is-click { animation: hero-click 360ms cubic-bezier(.34, 1.4, .64, 1); } }
.hero-home .piece { position: absolute; width: calc(88% * 14 / 44); right: 0; bottom: 0; transform: rotate(-12deg); cursor: pointer; }
.hero-home .piece svg { display: block; width: 100%; height: auto; }
.hero-home .piece.is-gone { visibility: hidden; }
/* Depth per piece for the lean, in the logo's own units (about 8.6 px each at full size) */
.hero-home .art .kagt-tile--k { --d: .6px; }
.hero-home .art .kagt-tile--a { --d: .9px; }
.hero-home .art .kagt-tile--g { --d: .5px; }
.hero-home .art .kagt-tile--t { --d: 1.1px; }
@media (prefers-reduced-motion: no-preference) {
    .hero-home .art .kagt-tile { translate: calc(var(--px, 0) * var(--d)) calc(var(--py, 0) * var(--d)); transition: translate .35s cubic-bezier(.2, .7, .2, 1); }
    .hero-home .piece { translate: calc(var(--px, 0) * 22px) calc(var(--py, 0) * 22px); transition: translate .35s cubic-bezier(.2, .7, .2, 1); }
    .hero-home.play .art .kagt-square { animation: a-square 500ms cubic-bezier(.2, .7, .2, 1) both; }
    .hero-home.play .art .kagt-tile--k { animation: a-in-k 800ms cubic-bezier(.2, .7, .2, 1) 150ms both; }
    .hero-home.play .art .kagt-tile--a { animation: a-in-a 800ms cubic-bezier(.2, .7, .2, 1) 260ms both; }
    .hero-home.play .art .kagt-tile--g { animation: a-in-g 800ms cubic-bezier(.2, .7, .2, 1) 370ms both; }
    .hero-home.play .piece:not(.is-moving) { animation: piece-arrive 450ms cubic-bezier(.2, .7, .2, 1) 380ms both, piece-float 3.2s ease-in-out .85s infinite alternate; }
    .hero-home .piece.is-waiting:not(.is-moving) { animation: piece-float 3.2s ease-in-out infinite alternate; }
}
/* Finished at first paint when motion is off: no flash of the empty slot */
@media (prefers-reduced-motion: reduce) {
    .hero-home .board.is-open .kagt-tile--t .kagt-tile__bg { fill: var(--teal); }
    .hero-home .board.is-open .kagt-tile--t .kagt-tile__letter { opacity: 1; }
    .hero-home .piece { visibility: hidden; }
}
@keyframes a-square { from { opacity: 0; transform: scale(.94); } }
@keyframes a-in-k { from { opacity: 0; transform: translate(-14px, -10px) rotate(-9deg); } }
@keyframes a-in-a { from { opacity: 0; transform: translate(14px, -12px) rotate(8deg); } }
@keyframes a-in-g { from { opacity: 0; transform: translate(-12px, 12px) rotate(7deg); } }
@keyframes piece-arrive { from { opacity: 0; transform: translate(30px, 30px) rotate(-24deg); } to { opacity: 1; transform: rotate(-12deg); } }
@keyframes piece-float { from { transform: rotate(-12deg) translateY(0); } to { transform: rotate(-9deg) translateY(-8px); } }
@keyframes hero-click { 0% { transform: scale(1.08); } 100% { transform: none; } }

/* ---------- Project cards with a live stage ---------- */
.project-card.live { padding: 0; overflow: hidden; gap: 0; }
.project-card.live .body { padding: 22px 24px 24px; display: grid; gap: 14px; }
.project-card .more::after { content: "→"; display: inline-block; margin-left: 6px; transition: transform .2s cubic-bezier(.2, .7, .2, 1); }
.project-card:hover .more::after, .project-card:focus-visible .more::after { transform: translateX(5px); }
.stage { background: var(--navy); height: 176px; padding: 18px 20px; position: relative; overflow: hidden; }
.stage .label { position: absolute; right: 16px; top: 14px; font: 500 11px var(--mono); color: var(--navy-ink); }

/* Pigeonhole: an inbox that fills up */
.inbox { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.inbox .row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; background: var(--navy-2); color: #fff; border-radius: 8px; padding: 8px 10px; font-size: 13px; line-height: 1.3; }
.inbox .row span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox .row em { font: 500 11px var(--mono); font-style: normal; color: var(--navy-ink); }
.inbox .kind { font: 500 10px var(--mono); padding: 3px 6px; border-radius: 4px; background: var(--navy-3); color: var(--navy-ink); }
.inbox .row.new { background: #fff; color: var(--ink); }
.inbox .row.new .kind { background: var(--teal); color: var(--navy); }
.inbox .row.new em { color: var(--ink-2); }
.inbox .row.new { max-height: 0; padding-block: 0; margin-top: -8px; opacity: 0; transform: translateY(-8px); }
.stage .count { position: absolute; left: 20px; top: 14px; font: 700 12px var(--text); color: var(--navy-ink); }
.stage .count b { display: inline-grid; place-items: center; min-width: 20px; height: 20px; border-radius: 6px; background: var(--navy-3); color: #fff; margin-right: 6px; transition: background-color .2s; }
@media (prefers-reduced-motion: no-preference) {
    .inbox .row.new { transition: max-height .35s cubic-bezier(.2, .7, .2, 1), padding .35s, margin .35s, opacity .3s, transform .35s cubic-bezier(.34, 1.3, .64, 1); }
}
.project-card:hover .inbox .row.new, .project-card:focus-visible .inbox .row.new { max-height: 44px; padding-block: 8px; margin-top: 0; opacity: 1; transform: none; }
.project-card:hover .inbox .n1, .project-card:focus-visible .inbox .n1 { transition-delay: .15s; }
.project-card:hover .inbox .n2, .project-card:focus-visible .inbox .n2 { transition-delay: .75s; }
.project-card:hover .inbox .n3, .project-card:focus-visible .inbox .n3 { transition-delay: 1.35s; }
.project-card:hover .stage .count b, .project-card:focus-visible .stage .count b { background: var(--teal); color: var(--navy); }

/* Testing Kit: a test run that passes, then waits for a person */
.run { display: grid; gap: 7px; margin-top: 18px; font-size: 13px; }
.run .t { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; align-items: center; color: var(--navy-ink); }
.run .t span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run .st { width: 18px; height: 18px; border-radius: 5px; background: var(--navy-3); position: relative; }
.run .st::after { content: ""; position: absolute; left: 6px; top: 3px; width: 5px; height: 9px; border: solid var(--navy); border-width: 0 2px 2px 0; transform: rotate(45deg); opacity: 0; }
.run .t.check .st { background: var(--navy-3); }
.run .t.check .st::after { content: "?"; border: 0; transform: none; left: 0; top: 0; width: 18px; height: 18px; display: grid; place-items: center; font: 700 12px/18px var(--text); color: #fff; text-align: center; }
.run .sum { font: 500 11px var(--mono); color: var(--navy-ink); margin-top: 4px; opacity: 0; }
.project-card:hover .run .t, .project-card:focus-visible .run .t { color: #fff; }
@media (prefers-reduced-motion: no-preference) {
    .project-card:hover .run .t:nth-child(1) .st, .project-card:focus-visible .run .t:nth-child(1) .st { animation: t-pass .7s .15s both; }
    .project-card:hover .run .t:nth-child(2) .st, .project-card:focus-visible .run .t:nth-child(2) .st { animation: t-pass .7s .75s both; }
    .project-card:hover .run .t:nth-child(3) .st, .project-card:focus-visible .run .t:nth-child(3) .st { animation: t-pass .7s 1.35s both; }
    .project-card:hover .run .t:nth-child(-n+3) .st::after, .project-card:focus-visible .run .t:nth-child(-n+3) .st::after { animation: t-tick .2s both; }
    .project-card:hover .run .t:nth-child(1) .st::after, .project-card:focus-visible .run .t:nth-child(1) .st::after { animation-delay: .7s; }
    .project-card:hover .run .t:nth-child(2) .st::after, .project-card:focus-visible .run .t:nth-child(2) .st::after { animation-delay: 1.3s; }
    .project-card:hover .run .t:nth-child(3) .st::after, .project-card:focus-visible .run .t:nth-child(3) .st::after { animation-delay: 1.9s; }
    .project-card:hover .run .t.check .st, .project-card:focus-visible .run .t.check .st { animation: t-wait 1.2s 2.1s ease-in-out infinite; }
    .project-card:hover .run .sum, .project-card:focus-visible .run .sum { animation: t-tick .3s 2.2s both; }
}
@media (prefers-reduced-motion: reduce) {
    .project-card:hover .run .t:nth-child(-n+3) .st, .project-card:focus-visible .run .t:nth-child(-n+3) .st { background: var(--teal); }
    .project-card:hover .run .t:nth-child(-n+3) .st::after, .project-card:focus-visible .run .t:nth-child(-n+3) .st::after,
    .project-card:hover .run .sum, .project-card:focus-visible .run .sum { opacity: 1; }
}
@keyframes t-pass { 0% { background: var(--navy-3); } 45% { background: #1F6F74; transform: scale(1.12); } 100% { background: var(--teal); transform: none; } }
@keyframes t-tick { from { opacity: 0; } to { opacity: 1; } }
@keyframes t-wait { 0%, 100% { background: var(--navy-3); } 50% { background: #5A6CA3; } }

/* The inbox count goes from 2 to 5 as the new messages land */
.stage .count .n-new { display: none; }
.project-card:hover .stage .count .n-old, .project-card:focus-visible .stage .count .n-old { display: none; }
.project-card:hover .stage .count .n-new, .project-card:focus-visible .stage .count .n-new { display: inline; }
@media (prefers-reduced-motion: no-preference) {
    .project-card:hover .stage .count b, .project-card:focus-visible .stage .count b { animation: count-bump .3s 1.4s cubic-bezier(.34, 1.4, .64, 1) both; }
}
@keyframes count-bump { 0% { transform: scale(1); } 50% { transform: scale(1.2); } 100% { transform: none; } }

/* The faint board behind every navy header: a texture, not a feature. It fades further under the words. */
.hero-home .kagt-field rect, .project-hero .kagt-field rect { transition-duration: 1.2s; }
.hero-home .kagt-field, .project-hero .kagt-field { -webkit-mask-image: linear-gradient(90deg, rgba(0, 0, 0, .35), #000 65%); mask-image: linear-gradient(90deg, rgba(0, 0, 0, .35), #000 65%); }

/* ---------- Writing: posts as cards, built like the project cards ---------- */
.section-head--split { display: flex; align-items: end; justify-content: space-between; gap: 16px 32px; flex-wrap: wrap; max-width: none; }
.section-head--split > div { display: grid; gap: 10px; max-width: 64ch; }
.posts { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.post-stage { padding: 0; display: block; }
.post-stage img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-card h3 { font: 600 21px/1.25 var(--display); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.post-meta { font: 500 12px var(--mono); color: var(--ink-2); }
.post-excerpt { font-size: 15px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.post-card .more::after { content: "↗"; }
.post-card:hover .more::after, .post-card:focus-visible .more::after { transform: translate(3px, -3px); }
@media (prefers-reduced-motion: no-preference) {
    .post-stage img { transition: transform .6s cubic-bezier(.2, .7, .2, 1); }
    .post-card:hover .post-stage img, .post-card:focus-visible .post-stage img { transform: scale(1.04); }
}

/* A small logo puzzle in the corner of each post image, in the Ghana colours. Each card varies it
   (set by the build): which piece is missing (data-gap), the colour order, and how it plays on hover
   (data-motion: pop, turn or wave). The missing piece then slides in from its own side and lights teal.
   Complete and still under reduced motion. */
.post-stage { position: relative; }
.mini-puzzle { position: absolute; right: 14px; bottom: 14px; width: 50px; height: 50px; padding: 7px; border-radius: 12px; background: var(--navy);
               display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.mini-puzzle i { border-radius: 4px; transform-origin: center; }
.mini-puzzle .c-red { background: #CE1126; }
.mini-puzzle .c-gold { background: #FCD116; }
.mini-puzzle .c-green { background: #0B8A4F; }
.mini-puzzle .piece { background: var(--teal); }
@media (prefers-reduced-motion: no-preference) {
    .mini-puzzle .piece { background: #0A1128; position: relative; }  /* the empty slot; ::before is the loose piece */
    .mini-puzzle .piece::before { content: ""; position: absolute; inset: 0; border-radius: 4px; background: var(--teal); opacity: 0;
        transform: translate(var(--fx), var(--fy)) rotate(var(--fr)); transition: transform .45s cubic-bezier(.34, 1.4, .64, 1), opacity .2s; }
    .mini-puzzle[data-gap="0"] { --fx: -12px; --fy: -12px; --fr: 14deg; }
    .mini-puzzle[data-gap="1"] { --fx: 12px; --fy: -12px; --fr: -14deg; }
    .mini-puzzle[data-gap="2"] { --fx: -12px; --fy: 12px; --fr: -14deg; }
    .mini-puzzle[data-gap="3"] { --fx: 12px; --fy: 12px; --fr: 14deg; }
    :is(.post-card, .portrait):hover .mini-puzzle .piece::before, :is(.post-card, .portrait):focus-visible .mini-puzzle .piece::before { transform: none; opacity: 1; transition-delay: .65s; }
    :is(.post-card, .portrait):hover .mini-puzzle i:not(.piece), :is(.post-card, .portrait):focus-visible .mini-puzzle i:not(.piece) {
        animation-duration: .45s; animation-delay: calc(var(--n) * .15s + .05s); animation-fill-mode: both; animation-timing-function: cubic-bezier(.34, 1.4, .64, 1); }
    :is(.post-card, .portrait):hover .mini-puzzle[data-motion="pop"] i:not(.piece), :is(.post-card, .portrait):focus-visible .mini-puzzle[data-motion="pop"] i:not(.piece) { animation-name: piece-pop; }
    :is(.post-card, .portrait):hover .mini-puzzle[data-motion="turn"] i:not(.piece), :is(.post-card, .portrait):focus-visible .mini-puzzle[data-motion="turn"] i:not(.piece) { animation-name: piece-turn; }
    :is(.post-card, .portrait):hover .mini-puzzle[data-motion="wave"] i:not(.piece), :is(.post-card, .portrait):focus-visible .mini-puzzle[data-motion="wave"] i:not(.piece) { animation-name: piece-wave; }
}
@keyframes piece-pop { 0%, 100% { transform: none; } 45% { transform: scale(1.22); } }
@keyframes piece-turn { 0% { transform: none; } 100% { transform: rotate(180deg); } }
@keyframes piece-wave { 0%, 100% { transform: none; } 40% { transform: translateY(-5px); } 70% { transform: translateY(1px); } }

/* ---------- Page changes ----------
   The header stays still, the old page lifts away, the new page rises in, and the teal bar under the
   current link slides to the new one. Cross-page view transitions: Chrome and Edge 126+, Safari 18.2+.
   Other browsers get the rise-in only (components.js adds .page-rise). Nothing moves under reduced motion. */
@media (prefers-reduced-motion: no-preference) {
    .site-head { view-transition-name: site-head; }
    /* The navy header section morphs from one page's shape to the next; only what's below it rises,
       so no light strip opens up under the header mid-change */
    .hero-home, .project-hero { view-transition-name: page-hero; }
    ::view-transition-group(page-hero) { animation-duration: 420ms; animation-timing-function: cubic-bezier(.2, .7, .2, 1); }
    /* Everything else changes as the page itself (the root): the browser captures only what's on screen,
       which is reliable. Capturing all of <main> as one piece (the whole page, thousands of pixels tall)
       sometimes made the browser abort the transition. */
    ::view-transition-old(root) { animation: page-lift 180ms cubic-bezier(.4, 0, 1, 1) both; }
    ::view-transition-new(root) { animation: page-rise 420ms cubic-bezier(.2, .7, .2, 1) 90ms both; }
    ::view-transition-group(nav-current) { animation-duration: 420ms; animation-timing-function: cubic-bezier(.34, 1.3, .64, 1); }
    main.page-rise { animation: page-rise 420ms cubic-bezier(.2, .7, .2, 1) both; }
}
@keyframes page-lift { to { opacity: 0; transform: translateY(-10px); } }
@keyframes page-rise { from { opacity: 0; transform: translateY(22px); } }

/* A see-through highlight behind header subheadings: each line gets a dark navy band, so the text stays
   clear when a tile lights up behind it, while the board still shows around and between the lines. */
.hero-home p .hl, .project-hero p .hl { background: rgba(10, 17, 40, .78); color: #DCE2F0; padding: .12em .4em; border-radius: 5px;
    -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.hero-home p, .project-hero p { line-height: 1.85; margin-left: -.4em; }

/* ---------- About photo: colour reveal, tilt towards the pointer, a glint, and the corner puzzle ---------- */
.portrait { position: relative; perspective: 900px; }
.photo-frame { position: relative; display: block; border-radius: 16px; overflow: hidden; transform-style: preserve-3d;
    transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); }
.photo-frame img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; }
.photo-colour { position: absolute; inset: 0; opacity: 0; transition: opacity .6s cubic-bezier(.2, .7, .2, 1); }
/* Hover only where there's a real pointer; phones keep a tap to switch (no sticky hover after a tap) */
@media (hover: hover) { .portrait:hover .photo-colour { opacity: 1; } }
.portrait.show-colour .photo-colour { opacity: 1; }
.photo-glint { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .4s;
    background: radial-gradient(circle at var(--mx, 50%) var(--my, 30%), rgba(255, 255, 255, .22), rgba(255, 255, 255, 0) 45%); }
.portrait .mini-puzzle { right: auto; left: -14px; bottom: -14px; width: 58px; height: 58px; padding: 8px; border-radius: 14px; }
@media (prefers-reduced-motion: no-preference) {
    .photo-frame { transition: transform .5s cubic-bezier(.2, .7, .2, 1); }
    .photo-main, .photo-colour { transition: opacity .6s cubic-bezier(.2, .7, .2, 1), transform .8s cubic-bezier(.2, .7, .2, 1); }
}
@media (prefers-reduced-motion: no-preference) and (hover: hover) {
    .portrait:hover .photo-main, .portrait:hover .photo-colour { transform: scale(1.035); }
    .portrait:hover .photo-glint { opacity: 1; }
    .portrait.is-tilting .photo-frame { transition: transform .12s linear; }
}

/* ---------- Status tags: Live (teal) and Being built (gold) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip.status::before { content: ""; width: 8px; height: 8px; border-radius: 2px; }
.chip.status.live::before { background: var(--teal); }
.chip.status.building::before { background: #E0B400; }
.chip.status.live { background: #DDF6F1; color: #0B4F46; }
.chip.status.building { background: #FFF4CC; color: #5C4A00; }
.project-hero .chip.status { margin-top: 12px; }
.project-hero .chip.status.live { background: rgba(0, 191, 165, .16); color: #BFF3EA; }
.project-hero .chip.status.building { background: rgba(252, 209, 22, .14); color: #FFE894; }
