/* ==========================================================================
   David Paredes — Portfolio
   Tokens · Base · Layout · Components · Animations · Responsive
   ========================================================================== */

:root {
  --bg: #0E1621;
  --bg2: #121C29;
  --panel: #16212F;
  --panel2: #1C2A3B;
  --line: #26364A;
  --ink: #F4F1EA;
  --mut: #9AA6B6;
  --amb: #F2B33D;
  --amb-ink: #16120A;
  --teal: #5EC2B7;
  --r: 20px;
  --max: 1120px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--amb); outline-offset: 3px; border-radius: 6px; }
::selection { background: rgba(242, 179, 61, .35); }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 24px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--amb); color: var(--amb-ink); padding: 8px 14px; border-radius: 8px; z-index: 100; font-weight: 700; }
.skip:focus { left: 8px; }

/* ---------- Scroll progress ---------- */
.progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 50; transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, var(--teal), var(--amb)); }

/* ---------- Nav ---------- */
header { position: sticky; top: 0; z-index: 30; background: rgba(14, 22, 33, .78); backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid rgba(38, 54, 74, .6); transition: background .3s; }
nav { display: flex; align-items: center; justify-content: space-between; height: 68px; gap: 16px; }
.brand { font-weight: 800; letter-spacing: -.02em; text-decoration: none; font-size: 18px; }
.brand span { color: var(--amb); }
.links { display: flex; gap: 26px; align-items: center; }
.links a { text-decoration: none; color: var(--mut); font-weight: 500; font-size: 15px; position: relative; }
.links a:not(.btn)::after { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 2px; background: var(--amb);
  transform: scaleX(0); transform-origin: left; transition: transform .3s var(--ease); }
.links a:not(.btn):hover { color: var(--ink); }
.links a:not(.btn):hover::after, .links a.active::after { transform: scaleX(1); }
.links a.active { color: var(--ink); }

.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: var(--panel); }
.lang button { all: unset; cursor: pointer; font-size: 12.5px; font-weight: 700; letter-spacing: .06em; padding: 5px 9px; border-radius: 7px; color: var(--mut); transition: background .2s, color .2s; }
.lang button[aria-pressed="true"] { background: var(--amb); color: var(--amb-ink); }
.lang button:focus-visible { outline: 2px solid var(--amb); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; font-size: 15px; padding: 13px 22px;
  border-radius: 12px; transition: transform .2s var(--ease), background .2s, box-shadow .2s; will-change: transform; }
.btn-p { background: var(--amb); color: var(--amb-ink); box-shadow: 0 8px 24px -10px rgba(242, 179, 61, .6); }
.btn-p:hover { background: #F6C25C; box-shadow: 0 14px 34px -12px rgba(242, 179, 61, .75); }
.btn-g { border: 1px solid var(--line); color: var(--ink); }
.btn-g:hover { background: var(--panel); }
.btn svg { transition: transform .25s var(--ease); }
.btn:hover svg { transform: translateX(3px); }
.links .btn { padding: 9px 15px; color: var(--amb-ink); }

/* ---------- Hero ---------- */
.hero { position: relative; padding: 104px 0 96px; overflow: hidden; isolation: isolate; }
.hero .grid-bg { position: absolute; inset: 0; z-index: -2; opacity: .5;
  background-image: linear-gradient(rgba(38, 54, 74, .45) 1px, transparent 1px), linear-gradient(90deg, rgba(38, 54, 74, .45) 1px, transparent 1px);
  background-size: 56px 56px; mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 30%, transparent 75%); }
.blob { position: absolute; z-index: -1; border-radius: 50%; filter: blur(70px); opacity: .55; animation: float 18s ease-in-out infinite; }
.blob.a { width: 520px; height: 520px; right: -120px; top: -160px; background: rgba(242, 179, 61, .30); }
.blob.b { width: 460px; height: 460px; left: -180px; bottom: -220px; background: rgba(94, 194, 183, .22); animation-delay: -6s; animation-duration: 22s; }
.blob.c { width: 300px; height: 300px; left: 45%; top: 30%; background: rgba(166, 108, 255, .14); animation-delay: -12s; animation-duration: 26s; }
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -30px) scale(1.08); }
  66% { transform: translate(-30px, 25px) scale(.95); }
}
.hero-grid { display: grid; grid-template-columns: 1.35fr .65fr; gap: 56px; align-items: center; }
.kicker { font-size: 13px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--amb); margin-bottom: 20px; }
h1 { font-size: clamp(40px, 6vw, 68px); line-height: 1.05; letter-spacing: -.035em; font-weight: 800; }
.rotator { color: var(--amb); white-space: nowrap; }
.caret { display: inline-block; width: .06em; height: .9em; margin-left: .06em; background: var(--amb); vertical-align: -.08em; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.lead { font-size: clamp(17px, 2vw, 20px); color: var(--mut); margin-top: 24px; max-width: 600px; }
.lead b { color: var(--ink); font-weight: 600; }
.cta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 36px; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 36px; }
.chip { font-size: 13px; font-weight: 600; color: var(--mut); border: 1px solid var(--line); padding: 7px 12px; border-radius: 999px; background: rgba(22, 33, 47, .6); }
.chip i { font-style: normal; color: var(--teal); }
.me { position: relative; justify-self: center; }
.me .frame { position: relative; border-radius: 30px; padding: 2px; background: conic-gradient(from var(--ang, 0deg), var(--amb), var(--teal), #A66CFF, var(--amb));
  animation: spin 8s linear infinite; }
@property --ang { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
@keyframes spin { to { --ang: 360deg; } }
.me img { width: 300px; height: 300px; border-radius: 28px; object-fit: cover; background: var(--panel); box-shadow: 0 30px 80px rgba(0, 0, 0, .45); }
.me .badge { position: absolute; left: -28px; bottom: 26px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px;
  font-size: 13px; box-shadow: 0 12px 30px rgba(0, 0, 0, .35); animation: bob 5s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px); } }
.me .badge b { display: block; font-size: 15px; }
.me .badge span { color: var(--mut); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #4ADE80; margin-right: 6px; box-shadow: 0 0 0 0 rgba(74, 222, 128, .5); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(74, 222, 128, 0); } 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); } }
.scroll-hint { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); width: 24px; height: 38px; border: 2px solid var(--line); border-radius: 14px; }
.scroll-hint::after { content: ""; position: absolute; left: 50%; top: 7px; width: 4px; height: 8px; margin-left: -2px; border-radius: 2px; background: var(--amb); animation: wheel 1.8s ease-in-out infinite; }
@keyframes wheel { 0% { opacity: 0; transform: translateY(0); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(12px); } }

/* ---------- Marquee ---------- */
.marquee { border-block: 1px solid rgba(38, 54, 74, .6); background: var(--bg2); overflow: hidden; padding: 18px 0;
  mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent); -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent); }
.marquee .track { display: flex; gap: 44px; width: max-content; animation: marquee 38s linear infinite; }
.marquee:hover .track { animation-play-state: paused; }
.marquee span { font-weight: 700; font-size: 17px; color: var(--mut); white-space: nowrap; display: inline-flex; align-items: center; gap: 44px; }
.marquee span::after { content: "✦"; color: var(--amb); font-size: 12px; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- Sections ---------- */
section { padding: 96px 0; position: relative; }
.alt { background: var(--bg2); border-top: 1px solid rgba(38, 54, 74, .5); border-bottom: 1px solid rgba(38, 54, 74, .5); }
h2 { font-size: clamp(30px, 4vw, 44px); line-height: 1.1; letter-spacing: -.03em; font-weight: 800; }
h2 em, h1 em { font-style: normal; color: var(--amb); }
.sec-sub { color: var(--mut); font-size: 18px; margin-top: 14px; max-width: 640px; }

/* spotlight cards */
.spot { position: relative; overflow: hidden; }
.spot::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(242, 179, 61, .10), transparent 45%); }
.spot:hover::before { opacity: 1; }

/* ---------- Services ---------- */
.services { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 44px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 28px; transition: border-color .3s, transform .3s var(--ease); }
.card:hover { border-color: #3A4F6A; transform: translateY(-3px); }
.card .ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: rgba(242, 179, 61, .12); color: var(--amb); margin-bottom: 18px;
  transition: transform .4s var(--ease); }
.card:hover .ico { transform: rotate(-8deg) scale(1.08); }
.card h3 { font-size: 21px; letter-spacing: -.01em; }
.card p { color: var(--mut); margin-top: 10px; font-size: 15.5px; }
.card ul { list-style: none; margin-top: 16px; display: grid; gap: 8px; }
.card li { font-size: 14.5px; padding-left: 22px; position: relative; }
.card li::before { content: "→"; position: absolute; left: 0; color: var(--teal); }

/* ---------- Projects ---------- */
.projects { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; margin-top: 44px; perspective: 1200px; }
.proj { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; text-decoration: none;
  transition: border-color .3s, transform .4s var(--ease), box-shadow .4s; transform-style: preserve-3d; }
.proj:hover { border-color: #3A4F6A; box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .6); }
.proj .thumb { aspect-ratio: 16 / 10; overflow: hidden; background: var(--panel2); position: relative; }
.proj .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: center; transition: transform .8s var(--ease); }
.proj:hover .thumb img { transform: scale(1.05); }
.proj .body { padding: 24px 26px 26px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.proj .tag { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--teal); }
.proj h3 { font-size: 22px; letter-spacing: -.015em; }
.proj p { color: var(--mut); font-size: 15.5px; }
.proj .stack { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 8px; }
.proj .stack span { font-size: 12.5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--mut); background: var(--panel2); border: 1px solid var(--line); padding: 4px 9px; border-radius: 8px; }
.proj .go { font-weight: 600; font-size: 14.5px; color: var(--amb); display: inline-flex; gap: 6px; transition: gap .3s var(--ease); }
.proj:hover .go { gap: 10px; }
.feat { grid-column: 1 / -1; flex-direction: row; }
.feat .thumb { flex: 0 0 46%; aspect-ratio: auto; display: grid; place-items: center; padding: 34px; background: linear-gradient(135deg, #1B2838, #13202E); }

/* mock: shop configurator */
.shop { width: 100%; max-width: 380px; background: #F7F5F0; border-radius: 14px; color: #1d2430; padding: 18px; box-shadow: 0 20px 50px rgba(0, 0, 0, .4); font-size: 13px; }
.shop .bar { display: flex; gap: 6px; margin-bottom: 14px; }
.shop .bar i { width: 9px; height: 9px; border-radius: 50%; background: #d9d4c9; }
.shop h4 { font-size: 16px; margin-bottom: 12px; }
.shop .row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-top: 1px solid #e5e0d6; }
.shop .row b { font-weight: 600; }
.shop .field { background: #fff; border: 1px solid #e0dacf; border-radius: 8px; padding: 5px 10px; font-weight: 600; font-variant-numeric: tabular-nums; }
.shop .price { margin-top: 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.shop .price strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.shop .price small { display: block; color: #6b7280; font-size: 11.5px; }
.shop .add { background: #1d2430; color: #fff; border-radius: 9px; padding: 9px 14px; font-weight: 700; white-space: nowrap; }

/* mock: chat */
.tg { display: grid; place-items: center; }
.chat { width: 100%; max-width: 320px; }
.bubble { max-width: 300px; background: #1F2C3D; border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; padding: 12px 14px; font-size: 14px; color: var(--ink); margin: 6px 0;
  opacity: 0; transform: translateY(8px); }
.bubble.me2 { background: #2A3B22; border-color: #3B5230; border-radius: 16px 16px 4px 16px; margin-left: auto; }
.in .bubble { animation: pop .5s var(--ease) forwards; }
.in .bubble:nth-child(2) { animation-delay: .6s; }
.in .bubble:nth-child(3) { animation-delay: 1.2s; }
@keyframes pop { to { opacity: 1; transform: none; } }

.more { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; color: var(--mut); font-size: 15px; }
.more a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); transition: border-color .2s; }
.more a:hover { border-color: var(--amb); }

/* ---------- Process ---------- */
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-top: 44px; counter-reset: s; position: relative; }
.step { position: relative; padding: 26px 24px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.step::before { counter-increment: s; content: "0" counter(s); font-weight: 800; font-size: 34px; letter-spacing: -.03em; color: transparent; -webkit-text-stroke: 1.5px var(--amb); display: block; margin-bottom: 12px;
  transition: color .4s; }
.step:hover::before { color: var(--amb); }
.step h3 { font-size: 18px; }
.step p { color: var(--mut); font-size: 15px; margin-top: 8px; }

/* ---------- About ---------- */
.about { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; }
.about p { color: var(--mut); font-size: 17px; margin-top: 16px; }
.about p b { color: var(--ink); font-weight: 600; }
.tl { list-style: none; position: relative; }
.tl::before { content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl::after { content: ""; position: absolute; left: 0; top: 6px; width: 2px; height: calc((100% - 12px) * var(--fill, 0)); background: linear-gradient(var(--amb), var(--teal)); transition: height .2s linear; }
.tl li { position: relative; padding: 0 0 26px 28px; }
.tl li:last-child { padding-bottom: 0; }
.tl li::before { content: ""; position: absolute; left: -5px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 2px solid var(--teal); z-index: 1; }
.tl li.now::before { background: var(--amb); border-color: var(--amb); box-shadow: 0 0 0 5px rgba(242, 179, 61, .18); }
.tl .when { font-size: 13px; font-weight: 600; color: var(--mut); letter-spacing: .04em; text-transform: uppercase; }
.tl h3 { font-size: 17px; margin-top: 2px; }
.tl p { color: var(--mut); font-size: 15px; margin-top: 4px; }
.stack-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 40px; }
.stack-grid .card h3 { font-size: 16px; color: var(--amb); letter-spacing: .02em; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.tags span { font-size: 14px; border: 1px solid var(--line); background: var(--panel2); padding: 6px 11px; border-radius: 9px; transition: border-color .2s, color .2s; }
.tags span:hover { border-color: var(--teal); color: var(--teal); }

/* ---------- Contact ---------- */
.contact { text-align: center; padding: 120px 0; overflow: hidden; }
.contact::before { content: ""; position: absolute; left: 50%; top: 50%; width: 700px; height: 700px; transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(closest-side, rgba(242, 179, 61, .12), transparent); pointer-events: none; }
.contact h2 { font-size: clamp(34px, 5vw, 56px); position: relative; }
.contact .sec-sub { margin: 18px auto 0; position: relative; }
.contact .cta { justify-content: center; position: relative; }
footer { border-top: 1px solid var(--line); padding: 28px 0; color: var(--mut); font-size: 14px; }
footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
footer a { text-decoration: none; color: var(--mut); }
footer a:hover { color: var(--ink); }

/* ---------- Reveal ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s var(--ease), transform .7s var(--ease); transition-delay: var(--d, 0s); }
.reveal.in { opacity: 1; transform: none; }
.split .w { display: inline-block; opacity: 0; transform: translateY(.5em); animation: rise .7s var(--ease) forwards; animation-delay: calc(var(--i) * 60ms + .1s); }
@keyframes rise { to { opacity: 1; transform: none; } }
.fade-in { opacity: 0; animation: rise .8s var(--ease) forwards; animation-delay: var(--d, .4s); }
.lang-fade { animation: langfade .35s var(--ease); }
@keyframes langfade { from { opacity: .2; } to { opacity: 1; } }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .reveal, .split .w, .fade-in, .bubble { opacity: 1 !important; transform: none !important; }
  .marquee .track { animation: none; }
  .caret { display: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .hero-grid { grid-template-columns: 1fr; gap: 44px; }
  .me { justify-self: start; }
  .me img { width: 220px; height: 220px; }
  .services, .steps { grid-template-columns: 1fr 1fr; }
  .about { grid-template-columns: 1fr; gap: 40px; }
  .stack-grid { grid-template-columns: 1fr 1fr; }
  .feat { flex-direction: column; }
  .feat .thumb { flex: auto; }
  .scroll-hint { display: none; }
}
@media (max-width: 720px) {
  .links a:not(.btn) { display: none; }
  .links { gap: 12px; }
  .hero { padding: 64px 0 72px; }
  section { padding: 72px 0; }
  .services, .steps, .projects, .stack-grid { grid-template-columns: 1fr; }
  .me .badge { left: auto; right: -12px; }
  .rotator { white-space: normal; }
}
@media (max-width: 400px) {
  .links .btn { display: none; }
}
