/* Freelancer 3D online portfolio (/p/<slug>/).
   Style: "3D & depth" on a dark stage — perspective, layered translateZ, soft glow.
   Every animated effect is off under prefers-reduced-motion; content never depends on it. */
:root {
  --bg: #060912;
  --bg-2: #0c1222;
  --surface: rgba(255, 255, 255, .045);
  --surface-2: rgba(255, 255, 255, .08);
  --edge: rgba(255, 255, 255, .1);
  --edge-2: rgba(255, 255, 255, .18);
  --ink: #eef2fb;
  --ink-2: #c8d0e0;
  --muted: #9aa6bd;
  --a1: #2dd4bf;
  --a2: #a78bfa;
  --on-accent: #06121a;
  --glow: rgba(45, 212, 191, .35);
  --head: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --body: "Archivo", "Segoe UI", system-ui, sans-serif;
  --radius: 18px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --z-nav: 40;
  --z-dialog: 100;
}
.theme-midnight { --bg: #050816; --bg-2: #0a1030; --a1: #38bdf8; --a2: #818cf8; --glow: rgba(56, 189, 248, .35); --on-accent: #041020; }
.theme-sunset { --bg: #0f0709; --bg-2: #1c0d14; --a1: #fbbf24; --a2: #fb7185; --glow: rgba(251, 146, 60, .35); --on-accent: #1a0a00; }
.theme-emerald { --bg: #04100b; --bg-2: #0a1c14; --a1: #34d399; --a2: #bef264; --glow: rgba(52, 211, 153, .35); --on-accent: #03140c; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body.p3 { margin: 0; min-height: 100dvh; background: radial-gradient(1200px 700px at 80% -10%, color-mix(in srgb, var(--a2) 18%, transparent), transparent 60%), radial-gradient(900px 600px at -10% 30%, color-mix(in srgb, var(--a1) 12%, transparent), transparent 60%), var(--bg); color: var(--ink); font: 400 16px/1.65 var(--body); overflow-x: hidden; }
.i { width: 1.1em; height: 1.1em; fill: currentColor; flex: 0 0 auto; }
a { color: var(--a1); }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--a1); outline-offset: 3px; border-radius: 6px; }
.p3-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.p3-skip { position: absolute; left: 16px; top: -60px; z-index: 200; padding: 10px 16px; border-radius: 10px; background: var(--a1); color: var(--on-accent); font-weight: 700; text-decoration: none; }
.p3-skip:focus { top: 12px; }

.p3-bg { pointer-events: none; }
.p3-nav, main, .p3-footer, .p3-preview { position: relative; z-index: 1; }
/* Side cards of the 3D carousel reach past the screen edge; clip them so phones never scroll sideways. */
main { overflow-x: clip; }

/* Nav */
.p3-nav { position: sticky; top: 0; z-index: var(--z-nav); display: flex; align-items: center; gap: 20px; padding: 12px clamp(16px, 4vw, 48px); background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(14px) saturate(140%); border-bottom: 1px solid var(--edge); }
.p3-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font: 600 16px var(--head); text-decoration: none; }
.p3-mono { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--a1), var(--a2)); color: var(--on-accent); font-size: 14px; font-weight: 700; }
.p3-nav nav { display: flex; gap: 4px; margin-left: auto; }
.p3-nav nav a { padding: 8px 12px; border-radius: 9px; color: var(--ink-2); font-size: 14.5px; text-decoration: none; transition: color .2s ease, background .2s ease; }
.p3-nav nav a:hover { color: var(--ink); background: var(--surface-2); }
.p3-preview { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; margin: 0; padding: 10px 16px; background: #3b2a06; color: #ffe6a8; font-size: 14px; }
.p3-preview--owner { background: color-mix(in srgb, var(--a1) 16%, var(--bg)); color: var(--ink); }
.p3-preview a { color: inherit; font-weight: 700; }

/* Buttons */
.p3-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 12px 22px; border: 0; border-radius: 14px; background: linear-gradient(135deg, var(--a1), var(--a2)); color: var(--on-accent); font: 600 15.5px var(--head); text-decoration: none; cursor: pointer; box-shadow: 0 10px 30px -10px var(--glow), inset 0 1px 0 rgba(255, 255, 255, .35); transition: transform .2s var(--ease-out), box-shadow .2s ease; }
.p3-btn:hover { transform: translateY(-2px); box-shadow: 0 16px 40px -12px var(--glow), inset 0 1px 0 rgba(255, 255, 255, .35); }
.p3-btn:active { transform: translateY(0) scale(.98); }
.p3-btn--ghost { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--edge-2); }
.p3-btn--ghost:hover { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--a1); }
.p3-btn--sm { min-height: 40px; padding: 8px 14px; font-size: 14px; border-radius: 11px; }
.p3-btn--lg { min-height: 54px; padding: 14px 28px; font-size: 16.5px; }
.p3-round { display: inline-grid; place-items: center; width: 48px; height: 48px; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--ink); cursor: pointer; box-shadow: inset 0 0 0 1px var(--edge-2); transition: background .2s ease, transform .2s var(--ease-out); }
.p3-round:hover { background: color-mix(in srgb, var(--a1) 22%, transparent); }
.p3-round:active { transform: scale(.94); }
.p3-round:disabled { opacity: .35; cursor: not-allowed; }

/* Layout */
.p3-wrap { width: min(1180px, 100%); margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }
.p3-narrow { width: min(820px, 100%); }
.p3-section { padding: clamp(64px, 10vw, 120px) 0; }
.p3-head { max-width: 640px; margin-bottom: 40px; }
.p3-eyebrow { margin: 0 0 10px; color: var(--a1); font: 600 13px var(--head); letter-spacing: .16em; text-transform: uppercase; }
h1, h2, h3 { font-family: var(--head); line-height: 1.1; margin: 0; letter-spacing: -.02em; }
h2 { font-size: clamp(30px, 4.6vw, 48px); }
h3 { font-size: 20px; letter-spacing: -.01em; }
.p3-muted { color: var(--muted); margin: 10px 0 0; }
.p3-prose { color: var(--ink-2); }
.p3-prose p { margin: 0 0 12px; }
.p3-about .p3-prose { font-size: clamp(18px, 2.2vw, 22px); line-height: 1.6; color: var(--ink); }

/* Hero */
.p3-hero { display: grid; grid-template-columns: 1.1fr .9fr; align-items: center; gap: clamp(32px, 6vw, 80px); width: min(1180px, 100%); min-height: calc(100dvh - 64px); margin: 0 auto; padding: clamp(40px, 8vw, 96px) clamp(16px, 4vw, 40px); }
.p3-status { display: inline-flex; align-items: center; gap: 10px; margin: 0 0 22px; padding: 7px 14px 7px 12px; border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--edge); color: var(--ink-2); font-size: 14px; }
.p3-status i { width: 9px; height: 9px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 4px rgba(52, 211, 153, .18); animation: p3-pulse 2.4s ease-in-out infinite; }
.p3-status.is-busy i { background: #fbbf24; box-shadow: 0 0 0 4px rgba(251, 191, 36, .18); }
.p3-hero h1 { font-size: clamp(44px, 8vw, 88px); background: linear-gradient(120deg, var(--ink) 30%, var(--a1) 70%, var(--a2)); -webkit-background-clip: text; background-clip: text; color: transparent; padding-bottom: .06em; text-wrap: balance; }
.p3-role { margin: 14px 0 0; color: var(--ink); font: 500 clamp(18px, 2.4vw, 24px) var(--head); }
.p3-lede { margin: 16px 0 0; max-width: 52ch; color: var(--muted); font-size: 18px; }
.p3-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.p3-actions--center { justify-content: center; }
.p3-stats { display: flex; flex-wrap: wrap; gap: 12px; margin: 40px 0 0; }
.p3-stats div { display: flex; flex-direction: column-reverse; min-width: 120px; padding: 14px 16px; border-radius: 14px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--edge); }
.p3-stats dt { color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.p3-stats dd { margin: 0 0 2px; font: 700 30px var(--head); font-variant-numeric: tabular-nums; color: var(--ink); }

/* 3D profile card */
.p3-card-stage { position: relative; display: grid; place-items: center; perspective: 1100px; }
.p3-card { --rx: 0deg; --ry: 0deg; --gx: 50%; --gy: 30%; position: relative; width: min(360px, 100%); aspect-ratio: 3 / 4.1; padding: 28px; border-radius: 26px; background: linear-gradient(160deg, color-mix(in srgb, var(--bg-2) 85%, var(--a2)) 0%, var(--bg-2) 45%, color-mix(in srgb, var(--bg-2) 80%, var(--a1)) 100%); box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .7), 0 0 0 1px var(--edge-2), inset 0 1px 0 rgba(255, 255, 255, .12); transform-style: preserve-3d; transform: rotateX(var(--rx)) rotateY(var(--ry)); transition: transform .5s var(--ease-out); display: flex; flex-direction: column; align-items: center; text-align: center; }
.p3-card.is-tracking { transition: transform .08s linear; }
.p3-card > * { transform-style: preserve-3d; }
.p3-card-glare { position: absolute; inset: 0; border-radius: inherit; background: radial-gradient(circle at var(--gx) var(--gy), rgba(255, 255, 255, .22), transparent 45%); mix-blend-mode: overlay; pointer-events: none; transform: translateZ(1px); }
.p3-card-grid { position: absolute; inset: 0; border-radius: inherit; background-image: linear-gradient(var(--edge) 1px, transparent 1px), linear-gradient(90deg, var(--edge) 1px, transparent 1px); background-size: 28px 28px; mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 70%); opacity: .6; pointer-events: none; }
.p3-card-photo { width: 168px; height: 168px; margin-top: 12px; padding: 5px; border-radius: 50%; background: conic-gradient(from 200deg, var(--a1), var(--a2), var(--a1)); transform: translateZ(70px); box-shadow: 0 24px 50px -16px var(--glow); }
.p3-card-photo img, .p3-card-photo span { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: var(--bg-2); color: var(--ink); font: 700 56px var(--head); }
.p3-card-body { margin-top: 22px; transform: translateZ(50px); }
.p3-card-body b { display: block; font: 700 24px var(--head); }
.p3-card-body span { display: block; margin-top: 4px; color: var(--muted); font-size: 14.5px; }
.p3-card-badge { display: inline-flex; align-items: center; gap: 6px; margin: 16px 0 0; padding: 6px 12px; border-radius: 999px; background: color-mix(in srgb, var(--a1) 16%, transparent); color: var(--a1); font: 600 13px var(--head); transform: translateZ(40px); }
.p3-card-links { display: flex; gap: 8px; margin: auto 0 0; padding: 18px 0 0; list-style: none; transform: translateZ(55px); }
.p3-card-links a { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--edge-2); transition: background .2s ease, color .2s ease; }
.p3-card-links a:hover { background: var(--a1); color: var(--on-accent); }
.p3-card-foot { margin: 14px 0 0; color: var(--muted); font: 600 10.5px var(--head); letter-spacing: .3em; transform: translateZ(20px); }
.p3-card-shadow { width: 70%; height: 30px; margin-top: 26px; border-radius: 50%; background: radial-gradient(closest-side, var(--glow), transparent); filter: blur(8px); }

/* Cover-flow carousel */
.p3-flow { position: relative; }
.p3-flow-track { display: flex; gap: 18px; margin: 0; padding: 4px 4px 18px; list-style: none; overflow-x: auto; scroll-snap-type: x mandatory; }
.p3-slide { flex: 0 0 min(340px, 82vw); scroll-snap-align: center; }
.p3-flow.is-3d { perspective: 1400px; }
.p3-flow.is-3d .p3-flow-track { position: relative; display: block; height: 470px; overflow: visible; padding: 0; transform-style: preserve-3d; touch-action: pan-y; cursor: grab; }
.p3-flow.is-3d .p3-flow-track.is-dragging { cursor: grabbing; }
.p3-flow.is-3d .p3-slide { position: absolute; left: 50%; top: 0; width: min(360px, 78vw); margin-left: calc(min(360px, 78vw) / -2); transition: transform .7s var(--ease-out), opacity .5s ease, filter .5s ease; will-change: transform; }
.p3-flow.is-3d .p3-slide:not(.is-active) .p3-slide-card { pointer-events: auto; }
.p3-flow.is-3d .p3-slide.is-far { opacity: 0; pointer-events: none; }
.p3-slide-card { display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 440px; padding: 0; border: 0; border-radius: var(--radius); background: var(--bg-2); color: var(--ink); text-align: left; font: inherit; cursor: pointer; overflow: hidden; box-shadow: 0 30px 60px -24px rgba(0, 0, 0, .8), inset 0 0 0 1px var(--edge-2); transition: box-shadow .3s ease; }
.p3-slide.is-active .p3-slide-card { box-shadow: 0 40px 80px -24px rgba(0, 0, 0, .9), 0 0 0 1px var(--a1), 0 0 60px -20px var(--glow); }
.p3-slide-media { display: block; aspect-ratio: 4 / 3; background: linear-gradient(135deg, color-mix(in srgb, var(--a1) 25%, var(--bg-2)), color-mix(in srgb, var(--a2) 25%, var(--bg-2))); overflow: hidden; }
.p3-slide-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--ease-out); }
.p3-slide-card:hover .p3-slide-media img { transform: scale(1.05); }
.p3-slide-placeholder { display: grid; place-items: center; height: 100%; color: var(--ink); opacity: .7; }
.p3-slide-placeholder .i { width: 64px; height: 64px; }
.p3-slide-body { display: flex; flex-direction: column; gap: 6px; flex: 1; padding: 18px 20px 20px; }
.p3-slide-body small { color: var(--a1); font: 600 12px var(--head); letter-spacing: .12em; text-transform: uppercase; }
.p3-slide-body b { font: 700 20px/1.25 var(--head); }
.p3-slide-body > span { color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.p3-slide-body em { display: inline-flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 6px; color: var(--a1); font-style: normal; font-weight: 600; font-size: 14px; }
.p3-flow-controls { display: flex; justify-content: center; align-items: center; gap: 18px; margin-top: 24px; }
.p3-flow-count { margin: 0; min-width: 64px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.p3-flow-count b { color: var(--ink); font-family: var(--head); }

/* Project dialog */
.p3-dialog { width: min(860px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: 22px; background: var(--bg-2); color: var(--ink); box-shadow: 0 50px 100px -20px rgba(0, 0, 0, .9), 0 0 0 1px var(--edge-2); }
.p3-dialog::backdrop { background: rgba(2, 4, 10, .72); backdrop-filter: blur(6px); }
.p3-dialog[open] { animation: p3-pop .45s var(--ease-out); }
.p3-dialog-inner { position: relative; padding: clamp(22px, 4vw, 40px); }
.p3-dialog h3 { font-size: clamp(24px, 3.4vw, 34px); padding-right: 56px; }
.p3-dialog-close { position: absolute; top: 16px; right: 16px; }
.p3-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 22px 0; padding: 0; list-style: none; }
.p3-gallery figure { margin: 0; }
.p3-gallery img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 12px; }
.p3-gallery figcaption { margin-top: 6px; color: var(--muted); font-size: 13px; }

/* Skills sphere */
.p3-skills { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(32px, 6vw, 72px); align-items: center; }
.p3-sphere-stage { position: relative; display: grid; place-items: center; aspect-ratio: 1; max-width: 480px; width: 100%; margin: 0 auto; border-radius: 50%; background: radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--a2) 14%, transparent), transparent 65%); touch-action: none; cursor: grab; user-select: none; }
.p3-sphere-stage.is-dragging { cursor: grabbing; }
.p3-sphere { position: relative; width: 100%; height: 100%; }
.p3-sphere-tag { position: absolute; left: 50%; top: 50%; padding: 5px 12px; border-radius: 999px; background: color-mix(in srgb, var(--bg-2) 70%, transparent); box-shadow: inset 0 0 0 1px var(--edge-2); color: var(--ink); font: 600 14px var(--head); white-space: nowrap; transform: translate(-50%, -50%); will-change: transform, opacity; }
.p3-sphere-tag[data-level="5"], .p3-sphere-tag[data-level="4"] { background: color-mix(in srgb, var(--a1) 22%, var(--bg-2)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--a1) 60%, transparent); }
.p3-hint { position: absolute; bottom: 4%; margin: 0; color: var(--muted); font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase; }
.no-js .p3-sphere-stage { display: none; }
.no-js .p3-skills { grid-template-columns: 1fr; }
.p3-skill-list { display: grid; gap: 8px; margin: 24px 0 0; padding: 0; list-style: none; }
.p3-skill-list li { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--edge); }
.p3-skill-list li > span:first-child { font-weight: 600; }
.p3-skill-list small { color: var(--muted); font-size: 13px; }
.p3-meter { display: inline-flex; gap: 4px; }
.p3-meter i { width: 14px; height: 6px; border-radius: 3px; background: var(--edge-2); }
.p3-meter i.on { background: linear-gradient(90deg, var(--a1), var(--a2)); }

/* Services */
.p3-services { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; margin: 0; padding: 0; list-style: none; perspective: 1000px; }
.p3-service { --rx: 0deg; --ry: 0deg; --gx: 50%; --gy: 0%; position: relative; padding: 26px; border-radius: var(--radius); background: linear-gradient(170deg, var(--surface-2), var(--surface)); box-shadow: inset 0 0 0 1px var(--edge); transform: rotateX(var(--rx)) rotateY(var(--ry)); transform-style: preserve-3d; transition: transform .5s var(--ease-out), box-shadow .3s ease; }
.p3-service.is-tracking { transition: transform .08s linear; }
.p3-service:hover { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--a1) 60%, transparent), 0 30px 60px -30px var(--glow); }
.p3-service-num { margin-bottom: 18px; font: 700 42px var(--head); background: linear-gradient(135deg, var(--a1), var(--a2)); -webkit-background-clip: text; background-clip: text; color: transparent; transform: translateZ(40px); }
.p3-service h3 { transform: translateZ(30px); }
.p3-service p { margin: 10px 0 0; color: var(--muted); font-size: 15px; transform: translateZ(20px); }
.p3-service .p3-price { color: var(--a1); font-weight: 600; }

/* Journey timeline */
.p3-journey { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 32px; perspective: 1200px; }
.p3-timeline { position: relative; margin: 0; padding: 0 0 0 28px; list-style: none; }
.p3-timeline::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: linear-gradient(var(--a1), var(--a2), transparent); }
.p3-timeline li { position: relative; margin-bottom: 18px; padding: 20px 22px; border-radius: var(--radius); background: var(--surface); box-shadow: inset 0 0 0 1px var(--edge); }
.p3-timeline li::before { content: ""; position: absolute; left: -27px; top: 26px; width: 14px; height: 14px; border-radius: 50%; background: var(--bg); box-shadow: 0 0 0 3px var(--a1), 0 0 18px var(--glow); }
.p3-timeline--edu li::before { box-shadow: 0 0 0 3px var(--a2), 0 0 18px var(--glow); }
.p3-timeline time { color: var(--a1); font: 600 13px var(--head); letter-spacing: .06em; }
.p3-timeline h3 { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 19px; }
.p3-timeline .p3-muted { margin-top: 4px; }
.p3-timeline .p3-prose { margin-top: 10px; font-size: 15px; }
.p3-timeline .p3-prose p:last-child { margin-bottom: 0; }

/* Certificates & languages */
.p3-creds { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 32px; }
.p3-chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; padding: 0; list-style: none; }
.p3-chips li { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 12px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--edge); }
.p3-chips .i { color: var(--a1); }
.p3-chips a, .p3-chips span { color: var(--ink); font-weight: 600; text-decoration: none; }
.p3-chips a:hover { color: var(--a1); }
.p3-chips small { color: var(--muted); font-size: 13px; }

/* Contact keycaps */
.p3-contact { text-align: center; }
.p3-contact h2 { font-size: clamp(36px, 6vw, 64px); }
.p3-keys { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin: 48px 0 0; padding: 0; list-style: none; perspective: 600px; }
.p3-key { display: block; min-width: 108px; border-radius: 16px; background: color-mix(in srgb, var(--a1) 40%, #000); padding-bottom: 8px; text-decoration: none; box-shadow: 0 18px 30px -14px rgba(0, 0, 0, .8); transform: rotateX(18deg); transition: transform .25s var(--ease-out), padding .12s ease; }
.p3-key-cap { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 18px 14px; border-radius: 16px; background: linear-gradient(180deg, color-mix(in srgb, var(--bg-2) 70%, #fff 6%), var(--bg-2)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), inset 0 0 0 1px var(--edge-2); color: var(--ink); transition: transform .12s ease, background .2s ease; }
.p3-key-cap .i { width: 26px; height: 26px; color: var(--a1); }
.p3-key-cap b { font: 600 13.5px var(--head); }
.p3-key:hover { transform: rotateX(8deg) translateY(-4px); }
.p3-key:hover .p3-key-cap { background: linear-gradient(180deg, color-mix(in srgb, var(--a1) 22%, var(--bg-2)), var(--bg-2)); }
.p3-key:active { padding-bottom: 2px; transform: rotateX(8deg) translateY(2px); }

.p3-footer { padding: 40px 16px 56px; border-top: 1px solid var(--edge); text-align: center; color: var(--muted); font-size: 14px; }
.p3-footer p { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin: 6px 0; }
.p3-footer .i { color: var(--a1); }

/* Scroll reveal (only when JS runs and motion is allowed) */
.js .p3-anim [data-reveal] { opacity: 0; transform: translateY(28px); transition: opacity .8s var(--ease-out), transform .8s var(--ease-out); transition-delay: calc(var(--i, 0) * 60ms); }
.js .p3-anim [data-reveal="depth"] { transform: translateZ(-180px) rotateX(18deg); transform-origin: 50% 100%; }
.js .p3-anim [data-reveal].in { opacity: 1; transform: none; }
.js .p3-anim .p3-service[data-reveal].in { transform: rotateX(var(--rx)) rotateY(var(--ry)); }

@keyframes p3-pulse { 50% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); } }
@keyframes p3-pop { from { opacity: 0; transform: translateY(24px) scale(.96) rotateX(8deg); } }

@media (max-width: 920px) {
  .p3-hero { grid-template-columns: 1fr; min-height: 0; text-align: left; }
  .p3-card-stage { order: -1; }
  .p3-card { width: min(320px, 100%); }
  .p3-skills { grid-template-columns: 1fr; }
  .p3-sphere-stage { max-width: 380px; }
}
@media (max-width: 640px) {
  .p3-nav { gap: 10px; }
  .p3-nav nav { display: none; }
  .p3-brand span:last-child { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .p3-nav .p3-btn { margin-left: auto; }
  .p3-stats div { flex: 1 1 40%; min-width: 0; }
  .p3-flow.is-3d .p3-flow-track { height: 450px; }
  .p3-skill-list li { grid-template-columns: 1fr auto; }
  .p3-skill-list small { display: none; }
  .p3-journey { grid-template-columns: 1fr; }
  .p3-key { min-width: 92px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .p3-card, .p3-service, .p3-flow.is-3d .p3-slide, .p3-key, .p3-btn, .p3-slide-media img { transition: none; }
  .p3-key { transform: none; }
}

/* =====================================================================
   Professional finish (2026-11): the theme's 3D scene lives behind the
   top section only, fades as you scroll, and everything else stays calm.
   The theme palette arrives as inline custom properties on <body>.
   ===================================================================== */
body.p3 { --hero: 0; background: var(--bg); }

/* Reading progress */
.p3-progress { position: fixed; inset: 0 0 auto; z-index: 60; height: 2px; pointer-events: none; }
.p3-progress i { display: block; height: 100%; width: 100%; transform-origin: 0 50%; transform: scaleX(var(--read, 0)); background: linear-gradient(90deg, var(--a1), var(--a2)); opacity: .85; }

/* Scene: behind the hero only, softened and faded towards the content */
.p3-hero { position: relative; isolation: isolate; width: 100%; max-width: none; padding-left: max(clamp(16px, 4vw, 40px), calc((100% - 1180px) / 2 + clamp(16px, 4vw, 40px))); padding-right: max(clamp(16px, 4vw, 40px), calc((100% - 1180px) / 2 + clamp(16px, 4vw, 40px))); }
.p3-hero .p3-bg { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; opacity: calc(.55 - var(--hero) * .4);
  -webkit-mask-image: linear-gradient(#000 55%, transparent); mask-image: linear-gradient(#000 55%, transparent); }
.p3-hero::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(900px 520px at 78% 20%, color-mix(in srgb, var(--a2) 14%, transparent), transparent 65%), radial-gradient(700px 480px at 10% 40%, color-mix(in srgb, var(--a1) 10%, transparent), transparent 65%); }
.p3-hero h1 { animation: p3-fade-up .9s var(--ease-out) both; }
.p3-role, .p3-lede, .p3-actions, .p3-stats { animation: p3-fade-up .9s var(--ease-out) both; animation-delay: .1s; }
.p3-lede { animation-delay: .16s; }
.p3-actions { animation-delay: .22s; }
.p3-stats { animation-delay: .28s; }
.p3-card { animation: p3-fade-up 1s var(--ease-out) .15s backwards; }
@keyframes p3-fade-up { from { opacity: 0; transform: translateY(16px); } }

/* Hero card: a gentle tilt on hover, a slight settle while scrolling away */
.p3-card-lift { transform: translateY(calc(var(--hero) * 24px)) scale(calc(1 - var(--hero) * .04)); }
.p3-card-grid { opacity: .35; }

/* Stats: one tidy row */
.p3-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(118px, 100%), 1fr)); max-width: 560px; }
.p3-stats div { min-width: 0; }

/* Skills: an even grid with level bars */
.p3-skill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.p3-skill-grid li { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px 12px; padding: 16px 18px; border-radius: 14px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--edge); transition: box-shadow .2s ease, background .2s ease; }
.p3-skill-grid li:hover { background: var(--surface-2); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--a1) 45%, transparent); }
.p3-skill-name { font-weight: 600; color: var(--ink); }
.p3-skill-level { color: var(--muted); font-size: 12.5px; }
.p3-bar { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: var(--edge); overflow: hidden; }
.p3-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--a1), var(--a2)); }

/* Calm reveals: fade up only */
.js .p3-anim [data-reveal], .js .p3-anim [data-reveal="depth"] { transform: translateY(18px); transform-origin: 50% 50%; transition-duration: .7s; }
.js .p3-anim .p3-skill-grid [data-reveal] { transition-delay: calc(min(var(--i, 0), 8) * 40ms); }

/* Theme accents that stay subtle */
.p3-preview--try { background: color-mix(in srgb, var(--a2) 22%, var(--bg)); color: var(--ink); }
.scene-matrix { --head: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, monospace; }
.scene-matrix h1, .scene-matrix h2 { letter-spacing: -.03em; }
.scene-blueprint .p3-card { background: linear-gradient(160deg, #0b2550, #071a3a); }
.scene-blueprint .p3-card-grid { background-image: linear-gradient(rgba(125, 211, 252, .16) 1px, transparent 1px), linear-gradient(90deg, rgba(125, 211, 252, .16) 1px, transparent 1px); background-size: 20px 20px; mask-image: none; opacity: .5; }
.scene-royal .p3-card { box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .8), 0 0 0 1px color-mix(in srgb, var(--a1) 45%, transparent), inset 0 1px 0 rgba(255, 255, 255, .15); }
.scene-royal .p3-hero h1 { background: linear-gradient(120deg, #fff8e7 25%, var(--a1) 70%, #d97706); -webkit-background-clip: text; background-clip: text; color: transparent; }
.scene-studio .p3-slide-media { position: relative; }
.scene-studio .p3-slide-media::after { content: ""; position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(0, 0, 0, .45); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .75); }
.scene-studio .p3-slide-media::before { content: ""; position: absolute; z-index: 1; left: 50%; top: 50%; margin: -9px 0 0 -5px; border-left: 16px solid #fff; border-top: 9px solid transparent; border-bottom: 9px solid transparent; }

@media (max-width: 920px) {
  .p3-hero { grid-template-columns: minmax(0, 1fr); }
  .p3-hero .p3-bg { opacity: .4; }
}
@media (max-width: 640px) {
  .p3-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .p3-card-lift { transform: none !important; }
}

/* Light themes (Paper, Nordic, or a light background in the theme builder) */
.mode-light .p3-card { box-shadow: 0 30px 60px -30px rgba(15, 23, 42, .28), 0 0 0 1px var(--edge-2), inset 0 1px 0 rgba(255, 255, 255, .8); }
.mode-light .p3-card-glare { mix-blend-mode: soft-light; }
.mode-light .p3-slide-card, .mode-light .p3-dialog { box-shadow: 0 24px 50px -26px rgba(15, 23, 42, .35), inset 0 0 0 1px var(--edge-2); }
.mode-light .p3-dialog::backdrop { background: rgba(15, 23, 42, .45); }
.mode-light .p3-key { background: color-mix(in srgb, var(--a1) 30%, #cbd5e1); box-shadow: 0 14px 24px -14px rgba(15, 23, 42, .35); }
.mode-light .p3-key-cap { background: linear-gradient(180deg, #ffffff, var(--bg-2)); }
.mode-light .p3-preview:not(.p3-preview--owner):not(.p3-preview--try) { background: #fef3c7; color: #78350f; }
.mode-light .p3-hero .p3-bg { opacity: calc(.8 - var(--hero) * .5); }
.mode-light .p3-btn { box-shadow: 0 10px 24px -12px var(--glow), inset 0 1px 0 rgba(255, 255, 255, .35); }
