:root {
  color-scheme: light;
  --paper: #f1efe9;
  --card: #fbfaf7;
  --ink: #2e3431;
  --muted: #5d625e;
  --sun: #d9892b;
  --teal: #2c5a4c;
  --sage: #b7bfa2;
  --coffee: #3a2a21;
  --footer-bg: #1c201e;
  --footer-text: #f1efe9;
  --footer-link: #b7bfa2;
  --divider: #e2dfd6;
  --image-bg: #e4e1d8;
  --steel: #c9cdc8;
  --steel-light: #e3e5e1;
  --glass: rgba(255, 255, 255, .45);
  --shadow: 0 8px 20px 2px rgba(28, 32, 30, .07);
  --shadow-lift: 0 14px 30px 4px rgba(28, 32, 30, .12);
  --radius: 6px;
  --serif: 'Literata', Georgia, serif;
  --sans: 'Space Grotesk', system-ui, sans-serif;
  --nav: 'Space Grotesk', system-ui, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #1b201e;
  --card: #252c27;
  --ink: #e2e0d9;
  --muted: #b4bcb3;
  --sun: #e0a45e;
  --teal: #adcbb7;
  --sage: #6d7f6b;
  --footer-bg: #131815;
  --footer-link: #b7c5ab;
  --divider: #3d483e;
  --image-bg: #303a32;
  --steel: #68736b;
  --steel-light: #8e9a90;
  --glass: rgba(255, 255, 255, .08);
  --shadow: 0 8px 20px 2px rgba(0, 0, 0, .16);
  --shadow-lift: 0 14px 30px 4px rgba(0, 0, 0, .24);
}

* { box-sizing: border-box; }
/* Prevent double-tap zoom while preserving scrolling and pinch-to-zoom. */
html { scroll-behavior: smooth; scroll-padding-top: 24px; touch-action: manipulation; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 17px/1.65 var(--sans); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
h1, h2, h3, p, ul, figure { margin: 0; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 4px; border-radius: 6px; }

.skip { position: absolute; left: 16px; top: -60px; background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: 8px; z-index: 1000; }
.skip:focus { top: 16px; }

/* page-in fade, borrowed from the inspiration's .fader */
.fader { position: fixed; inset: 0; background: var(--paper); z-index: 999; pointer-events: none; animation: fade-out .5s cubic-bezier(.785, .135, .15, .86) forwards; }
.fader.out { animation: fade-in .25s cubic-bezier(.785, .135, .15, .86) forwards; }
@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* header: centred logo, nav spread underneath */
.header { padding: 28px 16px 0; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.header-top { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px; width: min(1120px, 100%); }
.header-top .logo { grid-column: 2; }
.header-tools { display: flex; align-items: center; justify-self: end; gap: 8px; }
.language-switch { display: flex; align-items: center; justify-self: end; gap: 6px; min-height: 44px; padding: 0 6px; border: 0; background: transparent; font: 500 13px 'JetBrains Mono', ui-monospace, monospace; color: var(--muted); cursor: pointer; }
.language-switch[hidden] { display: none; }
.language-switch [data-language] { padding: 10px 2px 8px; border-bottom: 2px solid transparent; }
.language-switch:hover { color: var(--ink); }
.language-switch .is-active { color: var(--ink); border-bottom-color: var(--sun); }
.theme-toggle { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--teal); cursor: pointer; }
.theme-toggle[hidden] { display: none; }
.theme-toggle:hover { background: var(--card); color: var(--ink); }
.theme-toggle svg { grid-area: 1 / 1; width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.theme-sun, [data-theme="dark"] .theme-moon { display: none; }
[data-theme="dark"] .theme-sun { display: block; }
.logo { display: flex; align-items: center; gap: 12px; font: 500 15px 'JetBrains Mono', ui-monospace, monospace; letter-spacing: 2px; }
.logo-mark { display: grid; place-items: center; flex-shrink: 0; width: 54px; height: 54px; border-radius: 50%; background: var(--sun); transition: transform .4s; }
/* Keep the square artwork inside the circle at every logo size. */
.logo-mark img { width: 70%; height: 70%; }
.logo:hover .logo-mark { transform: translateY(-2px); }
.nav { display: flex; justify-content: space-around; width: min(760px, 100%); }
.nav a { font: 500 19px var(--nav); color: var(--teal); padding-bottom: 6px; border-bottom: 2px solid transparent; transition: border-color .2s, color .2s; }
.nav a:hover, .nav a.active { border-color: var(--sun); color: var(--ink); }

main, .footer { width: min(1120px, 100% - 32px); margin: 0 auto; }

/* intro */
.intro { display: grid; grid-template-columns: 1.05fr .95fr; align-items: center; gap: 32px; padding: 64px 0 48px; min-height: min(76vh, 720px); }
.intro-copy { position: relative; padding: 24px; isolation: isolate; }
.circle { position: absolute; border-radius: 50%; background: var(--sun); z-index: -1; animation: drift 14s ease-in-out infinite alternate; }
.c1 { width: 96px; height: 96px; top: -6px; left: 0; opacity: .35; }
.c2 { width: 180px; height: 180px; top: 70px; left: 46%; opacity: .22; animation-delay: -5s; }
.c3 { width: 320px; height: 320px; top: 150px; left: -120px; opacity: .12; animation-delay: -9s; }
@keyframes drift { to { transform: translate(14px, -18px) scale(1.04); } }

h1 { font: 500 clamp(40px, 6vw, 72px)/1.05 var(--nav); letter-spacing: -2.5px; margin-bottom: 24px; }
.intro-greeting { display: block; }
.intro-build, .intro-ending { white-space: nowrap; }
/* Signal-tear treatment inspired by Codrops' CSSGlitchEffect. */
.cyber-glitch { display: inline-grid; white-space: nowrap; }
.glitch-slice { grid-area: 1 / 1; animation: signal-tear 4.2s .65s steps(1, end) infinite; }
.glitch-top { --tear-x: -.055em; --tear-y: -.012em; clip-path: inset(-15% -20% 59%); }
.glitch-middle { --tear-x: .13em; --tear-y: .015em; clip-path: inset(41% -20% 32%); }
.glitch-bottom { --tear-x: -.08em; --tear-y: 0em; clip-path: inset(68% -20% -15%); }
.glitch-slice[aria-hidden] { pointer-events: none; user-select: none; }
@keyframes signal-tear {
  0%, 13%, 62%, 67%, 100% { transform: none; text-shadow: none; }
  2%, 8% { transform: translate(var(--tear-x), var(--tear-y)); text-shadow: -.035em 0 #00c7d9, .035em 0 #f12b62; }
  4% { transform: translate(calc(var(--tear-x) * -.6), 0) skewX(5deg); text-shadow: .045em 0 #00c7d9, -.025em 0 #f12b62; }
  6%, 10% { transform: none; text-shadow: none; }
  11% { transform: translate(calc(var(--tear-x) * .4), 0); text-shadow: -.025em 0 #00c7d9; }
  64% { transform: translate(calc(var(--tear-x) * -.45), 0); text-shadow: .03em 0 #f12b62, -.025em 0 #00c7d9; }
}
.lede { font: 400 clamp(19px, 2vw, 23px)/1.55 var(--nav); max-width: 34ch; color: var(--ink); }
.intro-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 14px 24px; margin-top: 34px; }
.button { display: inline-block; background: var(--ink); color: var(--paper); font: 600 15px var(--nav); letter-spacing: .6px; text-transform: uppercase; padding: 14px 26px; border-radius: var(--radius); box-shadow: var(--shadow); transition: background .2s, transform .2s; }
.button:hover { background: var(--sun); color: var(--ink); transform: translateY(-2px); }
.text-link { color: var(--teal); font: 500 17px var(--nav); }
.text-link:hover { color: var(--ink); }

.doodle svg { width: 100%; max-width: 440px; margin-left: auto; display: block; overflow: visible; }
.coffee-light { display: none; }
[data-theme="dark"] .coffee-light { display: inline; }
.bulb-cord { fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; }
.bulb-glass { fill: #ffd58a; fill-opacity: .18; stroke: #efd09a; stroke-width: 1.6; stroke-linejoin: round; }
.bulb-filament { fill: none; stroke: #ffe6b5; stroke-width: .8; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 1.5px #ffc66f); }
.bulb-shine { fill: none; stroke: #fff2d5; stroke-width: 1.2; stroke-linecap: round; opacity: .65; }
.bulb-socket { fill: var(--steel); stroke: var(--ink); stroke-width: 1.6; stroke-linejoin: round; }
[data-theme="dark"] .drip { fill: #dba56f; stroke: #f5d4a1; stroke-width: .6; filter: drop-shadow(0 0 3px #dba56f66); }
.ink-line { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1600; stroke-dashoffset: 1600; animation: draw 2.6s .3s ease forwards; }
.ink-line.thin { stroke-width: 1.6; }
.ink-line.dash { stroke-dasharray: 3 7; stroke-dashoffset: 0; animation: none; opacity: .5; }
.steel { fill: var(--steel); stroke: var(--ink); stroke-width: 2.4; stroke-linejoin: round; }
.steel-light { fill: var(--steel-light); stroke: var(--ink); stroke-width: 2.4; stroke-linejoin: round; }
.shine { fill: none; stroke: #fff; stroke-width: 5; stroke-linecap: round; opacity: .7; }
.coffee { fill: var(--coffee); }
.milk { fill: #eadcbc; }
.glass { fill: var(--glass); stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.drip { fill: var(--coffee); animation: drip 1.8s ease-in infinite; }
.drip:nth-of-type(2) { animation-delay: -.9s; }
.steam { stroke: var(--muted); stroke-dasharray: 220; stroke-dashoffset: 220; animation: steam 3.2s ease-in-out infinite; }
.steam:nth-of-type(2) { animation-delay: -1.6s; }
.steam-left { transform: translate(-20px, 14px); }
.steam-right { transform: translate(20px, 14px); }
@keyframes drip { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { transform: translateY(84px); opacity: 0; } }
@keyframes steam { 0% { stroke-dashoffset: 220; opacity: 0; } 30% { opacity: .8; } 100% { stroke-dashoffset: -220; opacity: 0; } }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* work */
.work { padding: 56px 0 24px; }
.work-head { display: flex; justify-content: space-between; align-items: end; flex-wrap: wrap; gap: 18px 32px; margin-bottom: 34px; }
h2 { font: 500 clamp(30px, 4vw, 42px)/1.15 var(--nav); letter-spacing: -1.2px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: 500 15px var(--nav); color: var(--ink); background: transparent; border: 1.5px solid var(--sage); border-radius: var(--radius); padding: 6px 16px; cursor: pointer; transition: background .2s, border-color .2s; }
.chip:hover { border-color: var(--teal); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 26px; }
.card { min-width: 0; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); transition: transform .3s, box-shadow .3s, opacity .3s; }
.card[hidden] { display: none; }
.card a { display: flex; flex-direction: column; height: 100%; padding: 12px 12px 20px; }
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); }
.card-image { aspect-ratio: 4 / 3; border-radius: 3px; overflow: hidden; background: var(--image-bg); margin-bottom: 18px; }
.card-image img { width: 100%; height: 100%; object-fit: cover; color: transparent; transition: transform .6s, opacity .5s; }
.card-image img.is-loading { opacity: 0; }
.card-image:has(img.is-loading) { animation: image-pulse 1.4s ease-in-out infinite; }
@keyframes image-pulse { 50% { opacity: .6; } }
.card:hover .card-image img { transform: scale(1.04); }
.card h3 { font: 500 23px var(--sans); letter-spacing: -.3px; padding: 0 8px; margin-bottom: 6px; }
.card p { color: var(--muted); font-size: 15.5px; line-height: 1.6; padding: 0 8px; flex: 1; }
.tag { align-self: flex-start; margin: 16px 8px 0; font: 600 12px var(--nav); letter-spacing: .8px; text-transform: uppercase; color: var(--teal); }

.face { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px; padding: 20px; text-align: center; }
.face span { font-size: 40px; line-height: 1; }
.face small { font-size: 14px; opacity: .8; }
.halyard-face { background: #e9efff; color: #1d2340; }
.halyard-face span { font: 600 38px var(--nav); letter-spacing: -1px; }
.orbit-face { background: #f2f3fa; color: #5f6fd6; }
.orbit-face span { font: 600 36px var(--nav); color: #1d2340; }
.orbit-face svg { width: 80%; height: 60px; }
.pip-face { background: #efdfdb; color: #352637; }
.pip-lockup { display: flex; align-items: center; justify-content: center; gap: 6px; width: 230px; max-width: 100%; }
.pip-face .pip-mascot { width: 48%; height: auto; aspect-ratio: 1; object-fit: contain; }
.pip-face .pip-logo { width: 48%; height: auto; aspect-ratio: 8 / 5; }

.fine { margin-top: 28px; font-size: 14px; color: var(--muted); text-align: center; }

/* about */
.about { padding: 72px 0 32px; }
.about-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(28px, 5vw, 56px); display: grid; grid-template-columns: 1fr 1fr; gap: 20px 56px; }
.about-card h2 { grid-column: 1 / -1; }
.about-card p { font-size: 18px; }
.services { list-style: none; padding: 0; }
.services li { display: flex; gap: 16px; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--divider); font-weight: 500; }
.services li:last-child { border-bottom: 0; }
.services .service-number { font: 600 13px var(--nav); color: var(--teal); }

/* hello */
.hello { position: relative; isolation: isolate; text-align: center; padding: 96px 16px 112px; }
.c4 { width: 220px; height: 220px; left: calc(50% - 110px); top: 40px; opacity: .18; }
.hello p { margin-top: 14px; color: var(--muted); }

.contact-toggle { display: inline-flex; align-items: center; gap: 16px; min-height: 48px; margin-top: 24px; padding: 10px 20px; border: 1px solid var(--teal); border-radius: var(--radius); background: transparent; color: var(--teal); font: 500 16px var(--nav); cursor: pointer; }
.contact-toggle[hidden], .contact-details[hidden] { display: none; }
.contact-toggle:hover { background: var(--card); }
.contact-arrow { transition: transform .2s; }
.contact-toggle[aria-expanded="true"] .contact-arrow { transform: rotate(180deg); }
.contact-details { display: grid; max-width: 480px; margin: 24px auto 0; text-align: left; }
.contact-copy { display: grid; grid-template-columns: 80px minmax(0, 1fr) auto; align-items: baseline; gap: 12px; width: 100%; min-height: 52px; padding: 12px 0; border: 0; border-bottom: 1px solid var(--divider); background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.contact-label { color: var(--muted); font-size: 14px; }
.contact-value { font-size: 16px; overflow-wrap: anywhere; user-select: text; }
.contact-copy:hover .contact-value { text-decoration: underline; text-underline-offset: 4px; }
.contact-copy > :last-child { color: var(--teal); font-size: 20px; }
.contact-hint { color: var(--muted); font-size: 13px; }
.hello .contact-status { min-height: 2.8em; margin-top: 10px; font-size: 14px; }
@media (max-width: 400px) {
  .contact-copy { grid-template-columns: 62px minmax(0, 1fr) auto; gap: 8px; }
  .contact-value { font-size: 14px; }
  .contact-label { font-size: 12px; }
}

/* footer */
.footer { width: 100%; background: var(--footer-bg); color: var(--footer-text); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; padding: 28px max(16px, calc(50% - 560px)); }
.footer a { justify-self: end; color: var(--footer-link); font: 500 16px var(--nav); }
.footer a:hover { color: var(--sun); }
.bugs { display: flex; gap: 14px; }
.bugs svg { width: 30px; height: 30px; fill: none; stroke: var(--sage); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.bugs svg:nth-child(2) { stroke: var(--sun); transform: rotate(24deg); }
.bugs svg:nth-child(3) { transform: rotate(-18deg); }

/* Let the final showcase fill the remaining columns, counting only visible cards. */
.card--wide { --card-span: 1; --card-ratio: 4 / 3; grid-column: span var(--card-span); }
.card--wide .card-image { aspect-ratio: var(--card-ratio); }
@media (min-width: 961px) {
  .card--wide:nth-child(3n + 1 of :not([hidden])) { --card-span: 3; --card-ratio: 3 / 1; }
  .card--wide:nth-child(3n + 2 of :not([hidden])) { --card-span: 2; --card-ratio: 8 / 3; }
}
@media (min-width: 721px) and (max-width: 960px) {
  .card--wide:nth-child(2n + 1 of :not([hidden])) { --card-span: 2; --card-ratio: 8 / 3; }
}

/* tablet */
@media (max-width: 960px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
}

/* phone: bottom tab bar, single column */
@media (max-width: 720px) {
  body { padding-bottom: 72px; }
  .header { padding-top: 22px; }
  .header-top { display: flex; justify-content: space-between; gap: 12px; }
  .header-top .logo { font-size: 13px; gap: 9px; letter-spacing: 1.5px; }
  .header-top .logo-mark { width: 44px; height: 44px; }
  .nav { position: fixed; z-index: 500; left: 0; right: 0; bottom: 0; width: 100%; background: var(--footer-bg); border-radius: 0; padding: 12px 8px calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 20px rgba(58, 46, 47, .1); }
  .nav a { color: var(--footer-text); font-size: 16px; }
  .nav a.active { color: var(--footer-text); border-color: var(--sun); }
  .intro { grid-template-columns: 1fr; padding: 32px 0 16px; min-height: 0; }
  .intro-copy { padding: 16px 4px; }
  .doodle { order: -1; }
  .doodle svg { max-width: 220px; margin: 0 auto; }
  .c3 { width: 240px; height: 240px; }
  .cards, .about-card { grid-template-columns: 1fr; }
  .footer { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .footer a { justify-self: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .glitch-top { clip-path: none; }
  .glitch-slice[aria-hidden] { display: none; }
  .ink-line { stroke-dashoffset: 0; }
  .fader { display: none; }
  html { scroll-behavior: auto; }
}
